PHP Class GDS\Gateway\RESTv1

https://cloud.google.com/datastore/reference/rest/
Inheritance: extends GDS\Gateway
Show file Open project: tomwalder/php-gds

Public Methods

Method Description
__construct ( $str_project_id, null $str_namespace = null ) Create the auth middleware and set up the HTTP Client
beginTransaction ( boolean $bol_cross_group = FALSE ) : null Start a transaction
deleteMulti ( array $arr_entities ) : mixed Delete 1-many entities
getEndCursor ( ) : mixed Get the end cursor from the last response
getHttpClient ( ) : GuzzleHttp\ClientInterface Get the current HTTP Client in use
gql ( string $str_gql, null | array $arr_params = null ) : mixed Fetch some Entities, based on the supplied GQL and, optionally, parameters
setHttpClient ( GuzzleHttp\ClientInterface $obj_client ) Use a pre-configured HTTP Client

Protected Methods

Method Description
configureObjectValueParamForQuery ( object $obj_val, object $mix_value ) Configure a Value parameter, based on the supplied object-type value
createMapper ( ) : RESTv1 Create a mapper that's right for this Gateway
extractAutoIDs ( ) : array Extract Auto Insert IDs from the last response
fetchByKeyPart ( array $arr_key_parts, $str_setter ) : mixed Fetch 1-many Entities, using the Key parts provided
httpClient ( ) : GuzzleHttp\ClientInterface Lazily initialise the HTTP Client when needed. Once.
initHttpClient ( ) : GuzzleHttp\ClientInterface Configure HTTP Client
upsert ( array $arr_entities ) : Entity[] Put an array of Entities into the Datastore. Return any that need AutoIDs

Private Methods

Method Description
actionUrl ( $str_action ) : string Build a URL for a Datastore action
addParamsToQuery ( stdClass $obj_query, array $arr_params ) Add Parameters to a GQL Query object
applyPartition ( stdClass $obj_request ) : stdClass Apply project and namespace to a query
applyTransaction ( stdClass $obj_request ) : mixed If we are in a transaction, apply it to the request object
buildCommitRequest ( ) : object Build a basic commit request (used by upsert, delete)
buildQueryParamValue ( $mix_value ) : stdClass Build a JSON representation of a value
executePostRequest ( $str_action, null $obj_request_body = null ) Execute a POST request against the API

Method Details

__construct() public method

Create the auth middleware and set up the HTTP Client
public __construct ( $str_project_id, null $str_namespace = null )
$str_project_id
$str_namespace null

beginTransaction() public method

POST /v1/projects/{projectId}:beginTransaction
public beginTransaction ( boolean $bol_cross_group = FALSE ) : null
$bol_cross_group boolean
return null

configureObjectValueParamForQuery() protected method

Configure a Value parameter, based on the supplied object-type value
protected configureObjectValueParamForQuery ( object $obj_val, object $mix_value )
$obj_val object
$mix_value object

createMapper() protected method

Create a mapper that's right for this Gateway
protected createMapper ( ) : RESTv1
return GDS\Mapper\RESTv1

deleteMulti() public method

Delete 1-many entities
public deleteMulti ( array $arr_entities ) : mixed
$arr_entities array
return mixed

extractAutoIDs() protected method

https://cloud.google.com/datastore/reference/rest/v1/projects/commit#MutationResult
protected extractAutoIDs ( ) : array
return array

fetchByKeyPart() protected method

Consumes Schema
protected fetchByKeyPart ( array $arr_key_parts, $str_setter ) : mixed
$arr_key_parts array
$str_setter
return mixed

getEndCursor() public method

Get the end cursor from the last response
public getEndCursor ( ) : mixed
return mixed

getHttpClient() public method

Get the current HTTP Client in use
public getHttpClient ( ) : GuzzleHttp\ClientInterface
return GuzzleHttp\ClientInterface

gql() public method

POST /v1/projects/{projectId}:runQuery
public gql ( string $str_gql, null | array $arr_params = null ) : mixed
$str_gql string
$arr_params null | array
return mixed

httpClient() protected method

Lazily initialise the HTTP Client when needed. Once.
protected httpClient ( ) : GuzzleHttp\ClientInterface
return GuzzleHttp\ClientInterface

initHttpClient() protected method

Configure HTTP Client
protected initHttpClient ( ) : GuzzleHttp\ClientInterface
return GuzzleHttp\ClientInterface

setHttpClient() public method

Use a pre-configured HTTP Client
public setHttpClient ( GuzzleHttp\ClientInterface $obj_client )
$obj_client GuzzleHttp\ClientInterface

upsert() protected method

Put an array of Entities into the Datastore. Return any that need AutoIDs
protected upsert ( array $arr_entities ) : Entity[]
$arr_entities array
return GDS\Entity[]