Google\Cloud\Datastore\DatastoreClient::allocateId PHP Method

allocateId() public method

Key MUST be in an incomplete state (i.e. including a kind but not an ID or name in its final pathElement). This method will execute a service request. Example: $key = $datastore->key('Person'); $keyWithAllocatedId = $datastore->allocateId($key);
See also: https://cloud.google.com/datastore/reference/rest/v1/projects/allocateIds allocateIds
public allocateId ( Key $key, array $options = [] ) : Key
$key Key The incomplete key.
$options array [optional] Configuration options.
return Key
    public function allocateId(Key $key, array $options = [])
    {
        $res = $this->allocateIds([$key], $options);
        return $res[0];
    }