diff --git a/Datastore/metadata/V1/Datastore.php b/Datastore/metadata/V1/Datastore.php index dd57a6eaac78..143a3d0d1483 100644 Binary files a/Datastore/metadata/V1/Datastore.php and b/Datastore/metadata/V1/Datastore.php differ diff --git a/Datastore/src/V1/Gapic/DatastoreGapicClient.php b/Datastore/src/V1/Gapic/DatastoreGapicClient.php index 569641761270..bf7597e3a4ec 100644 --- a/Datastore/src/V1/Gapic/DatastoreGapicClient.php +++ b/Datastore/src/V1/Gapic/DatastoreGapicClient.php @@ -47,6 +47,7 @@ use Google\Cloud\Datastore\V1\LookupResponse; use Google\Cloud\Datastore\V1\Mutation; use Google\Cloud\Datastore\V1\PartitionId; +use Google\Cloud\Datastore\V1\PropertyMask; use Google\Cloud\Datastore\V1\Query; use Google\Cloud\Datastore\V1\ReadOptions; use Google\Cloud\Datastore\V1\ReserveIdsRequest; @@ -414,6 +415,13 @@ public function commit($projectId, $mode, $mutations, array $optionalArgs = []) * database. * @type ReadOptions $readOptions * The options for this lookup request. + * @type PropertyMask $propertyMask + * The properties to return. Defaults to returning all properties. + * + * If this field is set and an entity has a property not referenced in the + * mask, it will be absent from [LookupResponse.found.entity.properties][]. + * + * The entity's key is always returned. * @type RetrySettings|array $retrySettings * Retry settings to use for this call. Can be a {@see RetrySettings} object, or an * associative array of retry settings parameters. See the documentation on @@ -440,6 +448,10 @@ public function lookup($projectId, $keys, array $optionalArgs = []) $request->setReadOptions($optionalArgs['readOptions']); } + if (isset($optionalArgs['propertyMask'])) { + $request->setPropertyMask($optionalArgs['propertyMask']); + } + $requestParams = new RequestParamsHeaderDescriptor($requestParamHeaders); $optionalArgs['headers'] = isset($optionalArgs['headers']) ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) : $requestParams->getHeader(); return $this->startCall('Lookup', LookupResponse::class, $optionalArgs, $request)->wait(); @@ -669,6 +681,12 @@ public function runAggregationQuery($projectId, array $optionalArgs = []) * The query to run. * @type GqlQuery $gqlQuery * The GQL query to run. This query must be a non-aggregation query. + * @type PropertyMask $propertyMask + * The properties to return. + * This field must not be set for a projection query. + * + * See + * [LookupRequest.property_mask][google.datastore.v1.LookupRequest.property_mask]. * @type ExplainOptions $explainOptions * Optional. Explain options for the query. If set, additional query * statistics will be returned. If not, only query results will be returned. @@ -706,6 +724,10 @@ public function runQuery($projectId, $partitionId, array $optionalArgs = []) $request->setGqlQuery($optionalArgs['gqlQuery']); } + if (isset($optionalArgs['propertyMask'])) { + $request->setPropertyMask($optionalArgs['propertyMask']); + } + if (isset($optionalArgs['explainOptions'])) { $request->setExplainOptions($optionalArgs['explainOptions']); } diff --git a/Datastore/src/V1/LookupRequest.php b/Datastore/src/V1/LookupRequest.php index 8cf7654fe0c5..e714464e4d5f 100644 --- a/Datastore/src/V1/LookupRequest.php +++ b/Datastore/src/V1/LookupRequest.php @@ -41,6 +41,15 @@ class LookupRequest extends \Google\Protobuf\Internal\Message * Generated from protobuf field repeated .google.datastore.v1.Key keys = 3 [(.google.api.field_behavior) = REQUIRED]; */ private $keys; + /** + * The properties to return. Defaults to returning all properties. + * If this field is set and an entity has a property not referenced in the + * mask, it will be absent from [LookupResponse.found.entity.properties][]. + * The entity's key is always returned. + * + * Generated from protobuf field .google.datastore.v1.PropertyMask property_mask = 5; + */ + private $property_mask = null; /** * @param string $projectId Required. The ID of the project against which to make the request. @@ -75,6 +84,11 @@ public static function build(string $projectId, \Google\Cloud\Datastore\V1\ReadO * The options for this lookup request. * @type array<\Google\Cloud\Datastore\V1\Key>|\Google\Protobuf\Internal\RepeatedField $keys * Required. Keys of entities to look up. + * @type \Google\Cloud\Datastore\V1\PropertyMask $property_mask + * The properties to return. Defaults to returning all properties. + * If this field is set and an entity has a property not referenced in the + * mask, it will be absent from [LookupResponse.found.entity.properties][]. + * The entity's key is always returned. * } */ public function __construct($data = NULL) { @@ -200,5 +214,47 @@ public function setKeys($var) return $this; } + /** + * The properties to return. Defaults to returning all properties. + * If this field is set and an entity has a property not referenced in the + * mask, it will be absent from [LookupResponse.found.entity.properties][]. + * The entity's key is always returned. + * + * Generated from protobuf field .google.datastore.v1.PropertyMask property_mask = 5; + * @return \Google\Cloud\Datastore\V1\PropertyMask|null + */ + public function getPropertyMask() + { + return $this->property_mask; + } + + public function hasPropertyMask() + { + return isset($this->property_mask); + } + + public function clearPropertyMask() + { + unset($this->property_mask); + } + + /** + * The properties to return. Defaults to returning all properties. + * If this field is set and an entity has a property not referenced in the + * mask, it will be absent from [LookupResponse.found.entity.properties][]. + * The entity's key is always returned. + * + * Generated from protobuf field .google.datastore.v1.PropertyMask property_mask = 5; + * @param \Google\Cloud\Datastore\V1\PropertyMask $var + * @return $this + */ + public function setPropertyMask($var) + { + GPBUtil::checkMessage($var, \Google\Cloud\Datastore\V1\PropertyMask::class); + $this->property_mask = $var; + + return $this; + } + } diff --git a/Datastore/src/V1/Mutation.php b/Datastore/src/V1/Mutation.php index b0c00ef5b2a3..22be69b75280 100644 --- a/Datastore/src/V1/Mutation.php +++ b/Datastore/src/V1/Mutation.php @@ -15,6 +15,18 @@ */ class Mutation extends \Google\Protobuf\Internal\Message { + /** + * The properties to write in this mutation. + * None of the properties in the mask may have a reserved name, except for + * `__key__`. + * This field is ignored for `delete`. + * If the entity already exists, only properties referenced in the mask are + * updated, others are left untouched. + * Properties referenced in the mask but not in the entity are deleted. + * + * Generated from protobuf field .google.datastore.v1.PropertyMask property_mask = 9; + */ + private $property_mask = null; protected $operation; protected $conflict_detection_strategy; @@ -44,6 +56,14 @@ class Mutation extends \Google\Protobuf\Internal\Message * The update time of the entity that this mutation is being applied * to. If this does not match the current update time on the server, the * mutation conflicts. + * @type \Google\Cloud\Datastore\V1\PropertyMask $property_mask + * The properties to write in this mutation. + * None of the properties in the mask may have a reserved name, except for + * `__key__`. + * This field is ignored for `delete`. + * If the entity already exists, only properties referenced in the mask are + * updated, others are left untouched. + * Properties referenced in the mask but not in the entity are deleted. * } */ public function __construct($data = NULL) { @@ -253,6 +273,54 @@ public function setUpdateTime($var) return $this; } + /** + * The properties to write in this mutation. + * None of the properties in the mask may have a reserved name, except for + * `__key__`. + * This field is ignored for `delete`. + * If the entity already exists, only properties referenced in the mask are + * updated, others are left untouched. + * Properties referenced in the mask but not in the entity are deleted. + * + * Generated from protobuf field .google.datastore.v1.PropertyMask property_mask = 9; + * @return \Google\Cloud\Datastore\V1\PropertyMask|null + */ + public function getPropertyMask() + { + return $this->property_mask; + } + + public function hasPropertyMask() + { + return isset($this->property_mask); + } + + public function clearPropertyMask() + { + unset($this->property_mask); + } + + /** + * The properties to write in this mutation. + * None of the properties in the mask may have a reserved name, except for + * `__key__`. + * This field is ignored for `delete`. + * If the entity already exists, only properties referenced in the mask are + * updated, others are left untouched. + * Properties referenced in the mask but not in the entity are deleted. + * + * Generated from protobuf field .google.datastore.v1.PropertyMask property_mask = 9; + * @param \Google\Cloud\Datastore\V1\PropertyMask $var + * @return $this + */ + public function setPropertyMask($var) + { + GPBUtil::checkMessage($var, \Google\Cloud\Datastore\V1\PropertyMask::class); + $this->property_mask = $var; + + return $this; + } + /** * @return string */ diff --git a/Datastore/src/V1/PropertyMask.php b/Datastore/src/V1/PropertyMask.php new file mode 100644 index 000000000000..1768924cdfb4 --- /dev/null +++ b/Datastore/src/V1/PropertyMask.php @@ -0,0 +1,96 @@ +google.datastore.v1.PropertyMask + */ +class PropertyMask extends \Google\Protobuf\Internal\Message +{ + /** + * The paths to the properties covered by this mask. + * A path is a list of property names separated by dots (`.`), for example + * `foo.bar` means the property `bar` inside the entity property `foo` inside + * the entity associated with this path. + * If a property name contains a dot `.` or a backslash `\`, then that + * name must be escaped. + * A path must not be empty, and may not reference a value inside an + * [array value][google.datastore.v1.Value.array_value]. + * + * Generated from protobuf field repeated string paths = 1; + */ + private $paths; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type array|\Google\Protobuf\Internal\RepeatedField $paths + * The paths to the properties covered by this mask. + * A path is a list of property names separated by dots (`.`), for example + * `foo.bar` means the property `bar` inside the entity property `foo` inside + * the entity associated with this path. + * If a property name contains a dot `.` or a backslash `\`, then that + * name must be escaped. + * A path must not be empty, and may not reference a value inside an + * [array value][google.datastore.v1.Value.array_value]. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Datastore\V1\Datastore::initOnce(); + parent::__construct($data); + } + + /** + * The paths to the properties covered by this mask. + * A path is a list of property names separated by dots (`.`), for example + * `foo.bar` means the property `bar` inside the entity property `foo` inside + * the entity associated with this path. + * If a property name contains a dot `.` or a backslash `\`, then that + * name must be escaped. + * A path must not be empty, and may not reference a value inside an + * [array value][google.datastore.v1.Value.array_value]. + * + * Generated from protobuf field repeated string paths = 1; + * @return \Google\Protobuf\Internal\RepeatedField + */ + public function getPaths() + { + return $this->paths; + } + + /** + * The paths to the properties covered by this mask. + * A path is a list of property names separated by dots (`.`), for example + * `foo.bar` means the property `bar` inside the entity property `foo` inside + * the entity associated with this path. + * If a property name contains a dot `.` or a backslash `\`, then that + * name must be escaped. + * A path must not be empty, and may not reference a value inside an + * [array value][google.datastore.v1.Value.array_value]. + * + * Generated from protobuf field repeated string paths = 1; + * @param array|\Google\Protobuf\Internal\RepeatedField $var + * @return $this + */ + public function setPaths($var) + { + $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::STRING); + $this->paths = $arr; + + return $this; + } + +} + diff --git a/Datastore/src/V1/RunQueryRequest.php b/Datastore/src/V1/RunQueryRequest.php index d7e47465a55c..2d1f158a209c 100644 --- a/Datastore/src/V1/RunQueryRequest.php +++ b/Datastore/src/V1/RunQueryRequest.php @@ -44,6 +44,15 @@ class RunQueryRequest extends \Google\Protobuf\Internal\Message * Generated from protobuf field .google.datastore.v1.ReadOptions read_options = 1; */ private $read_options = null; + /** + * The properties to return. + * This field must not be set for a projection query. + * See + * [LookupRequest.property_mask][google.datastore.v1.LookupRequest.property_mask]. + * + * Generated from protobuf field .google.datastore.v1.PropertyMask property_mask = 10; + */ + private $property_mask = null; /** * Optional. Explain options for the query. If set, additional query * statistics will be returned. If not, only query results will be returned. @@ -76,6 +85,11 @@ class RunQueryRequest extends \Google\Protobuf\Internal\Message * The query to run. * @type \Google\Cloud\Datastore\V1\GqlQuery $gql_query * The GQL query to run. This query must be a non-aggregation query. + * @type \Google\Cloud\Datastore\V1\PropertyMask $property_mask + * The properties to return. + * This field must not be set for a projection query. + * See + * [LookupRequest.property_mask][google.datastore.v1.LookupRequest.property_mask]. * @type \Google\Cloud\Datastore\V1\ExplainOptions $explain_options * Optional. Explain options for the query. If set, additional query * statistics will be returned. If not, only query results will be returned. @@ -282,6 +296,48 @@ public function setGqlQuery($var) return $this; } + /** + * The properties to return. + * This field must not be set for a projection query. + * See + * [LookupRequest.property_mask][google.datastore.v1.LookupRequest.property_mask]. + * + * Generated from protobuf field .google.datastore.v1.PropertyMask property_mask = 10; + * @return \Google\Cloud\Datastore\V1\PropertyMask|null + */ + public function getPropertyMask() + { + return $this->property_mask; + } + + public function hasPropertyMask() + { + return isset($this->property_mask); + } + + public function clearPropertyMask() + { + unset($this->property_mask); + } + + /** + * The properties to return. + * This field must not be set for a projection query. + * See + * [LookupRequest.property_mask][google.datastore.v1.LookupRequest.property_mask]. + * + * Generated from protobuf field .google.datastore.v1.PropertyMask property_mask = 10; + * @param \Google\Cloud\Datastore\V1\PropertyMask $var + * @return $this + */ + public function setPropertyMask($var) + { + GPBUtil::checkMessage($var, \Google\Cloud\Datastore\V1\PropertyMask::class); + $this->property_mask = $var; + + return $this; + } + /** * Optional. Explain options for the query. If set, additional query * statistics will be returned. If not, only query results will be returned.