From e22bb9f1766f6f02df14195dc9f463543a3a726a Mon Sep 17 00:00:00 2001 From: "gcf-owl-bot[bot]" <78513119+gcf-owl-bot[bot]@users.noreply.github.com> Date: Sat, 6 May 2023 17:12:00 +0530 Subject: [PATCH] feat: Add CMEK key field (#6187) * feat: [Cloud Memorystore for Redis] Add CMEK key field feat: [Cloud Memorystore for Redis] Add suspension_reasons field feat: [Cloud Memorystore for Redis] Add persistence support feat: [Cloud Memorystore for Redis] Add self service update maintenance version support PiperOrigin-RevId: 529822563 Source-Link: https://github.com/googleapis/googleapis/commit/6a0ac6d06db9019ffc37f079db79f027f95eff9f Source-Link: https://github.com/googleapis/googleapis-gen/commit/66da9c322deb75fb89d5a3505f572644d4f07698 Copy-Tag: eyJwIjoiUmVkaXMvLk93bEJvdC55YW1sIiwiaCI6IjY2ZGE5YzMyMmRlYjc1ZmI4OWQ1YTM1MDVmNTcyNjQ0ZDRmMDc2OTgifQ== --- Redis/metadata/V1/CloudRedis.php | Bin 9746 -> 10724 bytes .../V1/CloudRedisClient/create_instance.php | 6 +- .../V1/CloudRedisClient/get_location.php | 53 +++ .../V1/CloudRedisClient/list_locations.php | 58 +++ .../reschedule_maintenance.php | 3 +- .../V1/CloudRedisClient/update_instance.php | 6 +- Redis/src/V1/CreateInstanceRequest.php | 3 +- Redis/src/V1/DeleteInstanceRequest.php | 3 +- Redis/src/V1/Gapic/CloudRedisGapicClient.php | 127 ++++++- Redis/src/V1/GetInstanceAuthStringRequest.php | 3 +- Redis/src/V1/Instance.php | 332 ++++++++++++++---- Redis/src/V1/Instance/SuspensionReason.php | 57 +++ Redis/src/V1/Instance_SuspensionReason.php | 16 + Redis/src/V1/ListInstancesRequest.php | 12 +- Redis/src/V1/MaintenanceSchedule.php | 40 ++- Redis/src/V1/PersistenceConfig.php | 221 ++++++++++++ .../V1/PersistenceConfig/PersistenceMode.php | 65 ++++ .../V1/PersistenceConfig/SnapshotPeriod.php | 78 ++++ .../V1/PersistenceConfig_PersistenceMode.php | 16 + .../V1/PersistenceConfig_SnapshotPeriod.php | 16 + Redis/src/V1/RescheduleMaintenanceRequest.php | 15 +- Redis/src/V1/UpdateInstanceRequest.php | 3 +- Redis/src/V1/UpgradeInstanceRequest.php | 3 +- Redis/src/V1/WeeklyMaintenanceWindow.php | 12 +- Redis/src/V1/gapic_metadata.json | 10 + .../resources/cloud_redis_client_config.json | 10 + .../cloud_redis_descriptor_config.php | 14 + Redis/tests/Unit/V1/CloudRedisClientTest.php | 154 ++++++++ 28 files changed, 1232 insertions(+), 104 deletions(-) create mode 100644 Redis/samples/V1/CloudRedisClient/get_location.php create mode 100644 Redis/samples/V1/CloudRedisClient/list_locations.php create mode 100644 Redis/src/V1/Instance/SuspensionReason.php create mode 100644 Redis/src/V1/Instance_SuspensionReason.php create mode 100644 Redis/src/V1/PersistenceConfig.php create mode 100644 Redis/src/V1/PersistenceConfig/PersistenceMode.php create mode 100644 Redis/src/V1/PersistenceConfig/SnapshotPeriod.php create mode 100644 Redis/src/V1/PersistenceConfig_PersistenceMode.php create mode 100644 Redis/src/V1/PersistenceConfig_SnapshotPeriod.php diff --git a/Redis/metadata/V1/CloudRedis.php b/Redis/metadata/V1/CloudRedis.php index 62e8634343c2e7c315b740a3d2fee5aeffa2116a..4ea5dd6cdb88f9f82e638d1c58eab12f2fbb5371 100644 GIT binary patch delta 838 zcmZXQ!Ee$~9LLuJI-VPr#~h8o#t2Rl=#^1w+l^H$&u8=)m_H{HpT z7cVCEFYxBUg9#o@^bgU*gC`FjG~RuMMPQto{=VPe=lgr#H>Dr=!%ARwOUt8f&pqz{ z;;(Z2ryVa9{JNNETUNV6*L$|*T8+blb?RHZ-@%Xk%UJ(iNDE1D1uQfV9oOnon{;(k zZ_^feN{_{Cn#+arf$tIrWdM8Bb_~a*W|NYpWgZx9@e(tf+sJuu6Y*=>NG=T2;o<`T zokOQbO~YObrO9lh~tExP~>PU|Cg21xc8FY6_baxes-D(iW)O*eo%O#9ySS^tskZ$@UX>4!U{~A7VGliLl zpu1qv2buJ_JEFNpmx@7eIl7v>2jUY!j;q@)85ly$kbS{rcEI_uEdNHB21yN7u#Brn zDIii-i|AC9b6~b8V<}%^#d7d02vmxBfzLbxk;yCJGDu)W((txgC5$Pn#R*br1~QbY zAhNC2DnbCxgD{pK4gRnYgaVkW?xNDep^k+Rya1wXqEzc-lWm+B&t$&wAn8T3N$)+p K(N9JG#{U8FfCfhZ delta 66 zcmV-I0KNa@Q<6-uAp?_K1Ns7{Lz7qp+>=oStpc79vIbBEvtbNv0tGr?>OozT&=DY$ YN)J8+-2w_6lOYlulYAI9v+xo07cAZvS^xk5 diff --git a/Redis/samples/V1/CloudRedisClient/create_instance.php b/Redis/samples/V1/CloudRedisClient/create_instance.php index 46286de5e202..0b3fd9d54a75 100644 --- a/Redis/samples/V1/CloudRedisClient/create_instance.php +++ b/Redis/samples/V1/CloudRedisClient/create_instance.php @@ -63,8 +63,10 @@ * Note: Redis instances are managed and addressed at regional level so * location_id here refers to a GCP region; however, users may choose which * specific zone (or collection of zones for cross-zone instances) an instance - * should be provisioned in. Refer to [location_id][google.cloud.redis.v1.Instance.location_id] and - * [alternative_location_id][google.cloud.redis.v1.Instance.alternative_location_id] fields for more details. + * should be provisioned in. Refer to + * [location_id][google.cloud.redis.v1.Instance.location_id] and + * [alternative_location_id][google.cloud.redis.v1.Instance.alternative_location_id] + * fields for more details. * @param int $instanceTier The service tier of the instance. * @param int $instanceMemorySizeGb Redis memory size in GiB. */ diff --git a/Redis/samples/V1/CloudRedisClient/get_location.php b/Redis/samples/V1/CloudRedisClient/get_location.php new file mode 100644 index 000000000000..d6657575afbb --- /dev/null +++ b/Redis/samples/V1/CloudRedisClient/get_location.php @@ -0,0 +1,53 @@ +getLocation(); + printf('Response data: %s' . PHP_EOL, $response->serializeToJsonString()); + } catch (ApiException $ex) { + printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage()); + } +} +// [END redis_v1_generated_CloudRedis_GetLocation_sync] diff --git a/Redis/samples/V1/CloudRedisClient/list_locations.php b/Redis/samples/V1/CloudRedisClient/list_locations.php new file mode 100644 index 000000000000..79a983dacfad --- /dev/null +++ b/Redis/samples/V1/CloudRedisClient/list_locations.php @@ -0,0 +1,58 @@ +listLocations(); + + /** @var Location $element */ + foreach ($response as $element) { + printf('Element data: %s' . PHP_EOL, $element->serializeToJsonString()); + } + } catch (ApiException $ex) { + printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage()); + } +} +// [END redis_v1_generated_CloudRedis_ListLocations_sync] diff --git a/Redis/samples/V1/CloudRedisClient/reschedule_maintenance.php b/Redis/samples/V1/CloudRedisClient/reschedule_maintenance.php index bd362dbb5d0f..99e298021494 100644 --- a/Redis/samples/V1/CloudRedisClient/reschedule_maintenance.php +++ b/Redis/samples/V1/CloudRedisClient/reschedule_maintenance.php @@ -38,7 +38,8 @@ * `projects/{project_id}/locations/{location_id}/instances/{instance_id}` * where `location_id` refers to a GCP region. Please see * {@see CloudRedisClient::instanceName()} for help formatting this field. - * @param int $rescheduleType If reschedule type is SPECIFIC_TIME, must set up schedule_time as well. + * @param int $rescheduleType If reschedule type is SPECIFIC_TIME, must set up schedule_time as + * well. */ function reschedule_maintenance_sample(string $formattedName, int $rescheduleType): void { diff --git a/Redis/samples/V1/CloudRedisClient/update_instance.php b/Redis/samples/V1/CloudRedisClient/update_instance.php index e6586fdee462..c9f08aa35b94 100644 --- a/Redis/samples/V1/CloudRedisClient/update_instance.php +++ b/Redis/samples/V1/CloudRedisClient/update_instance.php @@ -45,8 +45,10 @@ * Note: Redis instances are managed and addressed at regional level so * location_id here refers to a GCP region; however, users may choose which * specific zone (or collection of zones for cross-zone instances) an instance - * should be provisioned in. Refer to [location_id][google.cloud.redis.v1.Instance.location_id] and - * [alternative_location_id][google.cloud.redis.v1.Instance.alternative_location_id] fields for more details. + * should be provisioned in. Refer to + * [location_id][google.cloud.redis.v1.Instance.location_id] and + * [alternative_location_id][google.cloud.redis.v1.Instance.alternative_location_id] + * fields for more details. * @param int $instanceTier The service tier of the instance. * @param int $instanceMemorySizeGb Redis memory size in GiB. */ diff --git a/Redis/src/V1/CreateInstanceRequest.php b/Redis/src/V1/CreateInstanceRequest.php index 2827b1398d58..c364681478dc 100644 --- a/Redis/src/V1/CreateInstanceRequest.php +++ b/Redis/src/V1/CreateInstanceRequest.php @@ -9,7 +9,8 @@ use Google\Protobuf\Internal\GPBUtil; /** - * Request for [CreateInstance][google.cloud.redis.v1.CloudRedis.CreateInstance]. + * Request for + * [CreateInstance][google.cloud.redis.v1.CloudRedis.CreateInstance]. * * Generated from protobuf message google.cloud.redis.v1.CreateInstanceRequest */ diff --git a/Redis/src/V1/DeleteInstanceRequest.php b/Redis/src/V1/DeleteInstanceRequest.php index eb84902cf1ec..cf7de8105e6b 100644 --- a/Redis/src/V1/DeleteInstanceRequest.php +++ b/Redis/src/V1/DeleteInstanceRequest.php @@ -9,7 +9,8 @@ use Google\Protobuf\Internal\GPBUtil; /** - * Request for [DeleteInstance][google.cloud.redis.v1.CloudRedis.DeleteInstance]. + * Request for + * [DeleteInstance][google.cloud.redis.v1.CloudRedis.DeleteInstance]. * * Generated from protobuf message google.cloud.redis.v1.DeleteInstanceRequest */ diff --git a/Redis/src/V1/Gapic/CloudRedisGapicClient.php b/Redis/src/V1/Gapic/CloudRedisGapicClient.php index 22bf3402c077..7b6f9b5ee0f4 100644 --- a/Redis/src/V1/Gapic/CloudRedisGapicClient.php +++ b/Redis/src/V1/Gapic/CloudRedisGapicClient.php @@ -25,6 +25,7 @@ namespace Google\Cloud\Redis\V1\Gapic; use Google\ApiCore\ApiException; +use Google\ApiCore\Call; use Google\ApiCore\CredentialsWrapper; use Google\ApiCore\GapicClientTrait; use Google\ApiCore\LongRunning\OperationsClient; @@ -35,6 +36,10 @@ use Google\ApiCore\Transport\TransportInterface; use Google\ApiCore\ValidationException; use Google\Auth\FetchAuthTokenInterface; +use Google\Cloud\Location\GetLocationRequest; +use Google\Cloud\Location\ListLocationsRequest; +use Google\Cloud\Location\ListLocationsResponse; +use Google\Cloud\Location\Location; use Google\Cloud\Redis\V1\CreateInstanceRequest; use Google\Cloud\Redis\V1\DeleteInstanceRequest; use Google\Cloud\Redis\V1\ExportInstanceRequest; @@ -950,7 +955,8 @@ public function listInstances($parent, array $optionalArgs = []) * @param string $name Required. Redis instance resource name using the form: * `projects/{project_id}/locations/{location_id}/instances/{instance_id}` * where `location_id` refers to a GCP region. - * @param int $rescheduleType Required. If reschedule type is SPECIFIC_TIME, must set up schedule_time as well. + * @param int $rescheduleType Required. If reschedule type is SPECIFIC_TIME, must set up schedule_time as + * well. * For allowed values, use constants defined on {@see \Google\Cloud\Redis\V1\RescheduleMaintenanceRequest\RescheduleType} * @param array $optionalArgs { * Optional. @@ -1134,4 +1140,123 @@ public function upgradeInstance($name, $redisVersion, array $optionalArgs = []) $optionalArgs['headers'] = isset($optionalArgs['headers']) ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) : $requestParams->getHeader(); return $this->startOperationsCall('UpgradeInstance', $optionalArgs, $request, $this->getOperationsClient())->wait(); } + + /** + * Gets information about a location. + * + * Sample code: + * ``` + * $cloudRedisClient = new Google\Cloud\Redis\V1\CloudRedisClient(); + * try { + * $response = $cloudRedisClient->getLocation(); + * } finally { + * $cloudRedisClient->close(); + * } + * ``` + * + * @param array $optionalArgs { + * Optional. + * + * @type string $name + * Resource name for the location. + * @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 + * {@see RetrySettings} for example usage. + * } + * + * @return \Google\Cloud\Location\Location + * + * @throws ApiException if the remote call fails + */ + public function getLocation(array $optionalArgs = []) + { + $request = new GetLocationRequest(); + $requestParamHeaders = []; + if (isset($optionalArgs['name'])) { + $request->setName($optionalArgs['name']); + $requestParamHeaders['name'] = $optionalArgs['name']; + } + + $requestParams = new RequestParamsHeaderDescriptor($requestParamHeaders); + $optionalArgs['headers'] = isset($optionalArgs['headers']) ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) : $requestParams->getHeader(); + return $this->startCall('GetLocation', Location::class, $optionalArgs, $request, Call::UNARY_CALL, 'google.cloud.location.Locations')->wait(); + } + + /** + * Lists information about the supported locations for this service. + * + * Sample code: + * ``` + * $cloudRedisClient = new Google\Cloud\Redis\V1\CloudRedisClient(); + * try { + * // Iterate over pages of elements + * $pagedResponse = $cloudRedisClient->listLocations(); + * foreach ($pagedResponse->iteratePages() as $page) { + * foreach ($page as $element) { + * // doSomethingWith($element); + * } + * } + * // Alternatively: + * // Iterate through all elements + * $pagedResponse = $cloudRedisClient->listLocations(); + * foreach ($pagedResponse->iterateAllElements() as $element) { + * // doSomethingWith($element); + * } + * } finally { + * $cloudRedisClient->close(); + * } + * ``` + * + * @param array $optionalArgs { + * Optional. + * + * @type string $name + * The resource that owns the locations collection, if applicable. + * @type string $filter + * The standard list filter. + * @type int $pageSize + * The maximum number of resources contained in the underlying API + * response. The API may return fewer values in a page, even if + * there are additional values to be retrieved. + * @type string $pageToken + * A page token is used to specify a page of values to be returned. + * If no page token is specified (the default), the first page + * of values will be returned. Any page token used here must have + * been generated by a previous call to the API. + * @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 + * {@see RetrySettings} for example usage. + * } + * + * @return \Google\ApiCore\PagedListResponse + * + * @throws ApiException if the remote call fails + */ + public function listLocations(array $optionalArgs = []) + { + $request = new ListLocationsRequest(); + $requestParamHeaders = []; + if (isset($optionalArgs['name'])) { + $request->setName($optionalArgs['name']); + $requestParamHeaders['name'] = $optionalArgs['name']; + } + + if (isset($optionalArgs['filter'])) { + $request->setFilter($optionalArgs['filter']); + } + + if (isset($optionalArgs['pageSize'])) { + $request->setPageSize($optionalArgs['pageSize']); + } + + if (isset($optionalArgs['pageToken'])) { + $request->setPageToken($optionalArgs['pageToken']); + } + + $requestParams = new RequestParamsHeaderDescriptor($requestParamHeaders); + $optionalArgs['headers'] = isset($optionalArgs['headers']) ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) : $requestParams->getHeader(); + return $this->getPagedListResponse('ListLocations', $optionalArgs, ListLocationsResponse::class, $request, 'google.cloud.location.Locations'); + } } diff --git a/Redis/src/V1/GetInstanceAuthStringRequest.php b/Redis/src/V1/GetInstanceAuthStringRequest.php index 46812dc615d4..56ab52dfd300 100644 --- a/Redis/src/V1/GetInstanceAuthStringRequest.php +++ b/Redis/src/V1/GetInstanceAuthStringRequest.php @@ -9,7 +9,8 @@ use Google\Protobuf\Internal\GPBUtil; /** - * Request for [GetInstanceAuthString][google.cloud.redis.v1.CloudRedis.GetInstanceAuthString]. + * Request for + * [GetInstanceAuthString][google.cloud.redis.v1.CloudRedis.GetInstanceAuthString]. * * Generated from protobuf message google.cloud.redis.v1.GetInstanceAuthStringRequest */ diff --git a/Redis/src/V1/Instance.php b/Redis/src/V1/Instance.php index 0bd0cdcc13d8..549a74248cbc 100644 --- a/Redis/src/V1/Instance.php +++ b/Redis/src/V1/Instance.php @@ -22,8 +22,10 @@ class Instance extends \Google\Protobuf\Internal\Message * Note: Redis instances are managed and addressed at regional level so * location_id here refers to a GCP region; however, users may choose which * specific zone (or collection of zones for cross-zone instances) an instance - * should be provisioned in. Refer to [location_id][google.cloud.redis.v1.Instance.location_id] and - * [alternative_location_id][google.cloud.redis.v1.Instance.alternative_location_id] fields for more details. + * should be provisioned in. Refer to + * [location_id][google.cloud.redis.v1.Instance.location_id] and + * [alternative_location_id][google.cloud.redis.v1.Instance.alternative_location_id] + * fields for more details. * * Generated from protobuf field string name = 1 [(.google.api.field_behavior) = REQUIRED]; */ @@ -86,11 +88,11 @@ class Instance extends \Google\Protobuf\Internal\Message */ private $reserved_ip_range = ''; /** - * Optional. Additional IP range for node placement. Required when enabling read - * replicas on an existing instance. For DIRECT_PEERING mode value must be a - * CIDR range of size /28, or "auto". For PRIVATE_SERVICE_ACCESS mode value - * must be the name of an allocated address range associated with the private - * service access connection, or "auto". + * Optional. Additional IP range for node placement. Required when enabling + * read replicas on an existing instance. For DIRECT_PEERING mode value must + * be a CIDR range of size /28, or "auto". For PRIVATE_SERVICE_ACCESS mode + * value must be the name of an allocated address range associated with the + * private service access connection, or "auto". * * Generated from protobuf field string secondary_ip_range = 30 [(.google.api.field_behavior) = OPTIONAL]; */ @@ -193,9 +195,9 @@ class Instance extends \Google\Protobuf\Internal\Message */ private $connect_mode = 0; /** - * Optional. Indicates whether OSS Redis AUTH is enabled for the instance. If set to - * "true" AUTH is enabled on the instance. Default value is "false" meaning - * AUTH is disabled. + * Optional. Indicates whether OSS Redis AUTH is enabled for the instance. If + * set to "true" AUTH is enabled on the instance. Default value is "false" + * meaning AUTH is disabled. * * Generated from protobuf field bool auth_enabled = 23 [(.google.api.field_behavior) = OPTIONAL]; */ @@ -228,11 +230,11 @@ class Instance extends \Google\Protobuf\Internal\Message */ private $maintenance_schedule = null; /** - * Optional. The number of replica nodes. The valid range for the Standard Tier with - * read replicas enabled is [1-5] and defaults to 2. If read replicas are not - * enabled for a Standard Tier instance, the only valid value is 1 and the - * default is 1. The valid value for basic tier is 0 and the default is also - * 0. + * Optional. The number of replica nodes. The valid range for the Standard + * Tier with read replicas enabled is [1-5] and defaults to 2. If read + * replicas are not enabled for a Standard Tier instance, the only valid value + * is 1 and the default is 1. The valid value for basic tier is 0 and the + * default is also 0. * * Generated from protobuf field int32 replica_count = 31 [(.google.api.field_behavior) = OPTIONAL]; */ @@ -260,11 +262,45 @@ class Instance extends \Google\Protobuf\Internal\Message */ private $read_endpoint_port = 0; /** - * Optional. Read replicas mode for the instance. Defaults to READ_REPLICAS_DISABLED. + * Optional. Read replicas mode for the instance. Defaults to + * READ_REPLICAS_DISABLED. * * Generated from protobuf field .google.cloud.redis.v1.Instance.ReadReplicasMode read_replicas_mode = 35 [(.google.api.field_behavior) = OPTIONAL]; */ private $read_replicas_mode = 0; + /** + * Optional. The KMS key reference that the customer provides when trying to + * create the instance. + * + * Generated from protobuf field string customer_managed_key = 36 [(.google.api.field_behavior) = OPTIONAL]; + */ + private $customer_managed_key = ''; + /** + * Optional. Persistence configuration parameters + * + * Generated from protobuf field .google.cloud.redis.v1.PersistenceConfig persistence_config = 37 [(.google.api.field_behavior) = OPTIONAL]; + */ + private $persistence_config = null; + /** + * Optional. reasons that causes instance in "SUSPENDED" state. + * + * Generated from protobuf field repeated .google.cloud.redis.v1.Instance.SuspensionReason suspension_reasons = 38 [(.google.api.field_behavior) = OPTIONAL]; + */ + private $suspension_reasons; + /** + * Optional. The self service update maintenance version. + * The version is date based such as "20210712_00_00". + * + * Generated from protobuf field string maintenance_version = 39 [(.google.api.field_behavior) = OPTIONAL]; + */ + private $maintenance_version = ''; + /** + * Optional. The available maintenance versions that an instance could update + * to. + * + * Generated from protobuf field repeated string available_maintenance_versions = 40 [(.google.api.field_behavior) = OPTIONAL]; + */ + private $available_maintenance_versions; /** * Constructor. @@ -279,8 +315,10 @@ class Instance extends \Google\Protobuf\Internal\Message * Note: Redis instances are managed and addressed at regional level so * location_id here refers to a GCP region; however, users may choose which * specific zone (or collection of zones for cross-zone instances) an instance - * should be provisioned in. Refer to [location_id][google.cloud.redis.v1.Instance.location_id] and - * [alternative_location_id][google.cloud.redis.v1.Instance.alternative_location_id] fields for more details. + * should be provisioned in. Refer to + * [location_id][google.cloud.redis.v1.Instance.location_id] and + * [alternative_location_id][google.cloud.redis.v1.Instance.alternative_location_id] + * fields for more details. * @type string $display_name * An arbitrary and optional user-provided name for the instance. * @type array|\Google\Protobuf\Internal\MapField $labels @@ -315,11 +353,11 @@ class Instance extends \Google\Protobuf\Internal\Message * example, 10.0.0.0/29 or 192.168.0.0/29. For READ_REPLICAS_ENABLED * the default block size is /28. * @type string $secondary_ip_range - * Optional. Additional IP range for node placement. Required when enabling read - * replicas on an existing instance. For DIRECT_PEERING mode value must be a - * CIDR range of size /28, or "auto". For PRIVATE_SERVICE_ACCESS mode value - * must be the name of an allocated address range associated with the private - * service access connection, or "auto". + * Optional. Additional IP range for node placement. Required when enabling + * read replicas on an existing instance. For DIRECT_PEERING mode value must + * be a CIDR range of size /28, or "auto". For PRIVATE_SERVICE_ACCESS mode + * value must be the name of an allocated address range associated with the + * private service access connection, or "auto". * @type string $host * Output only. Hostname or IP address of the exposed Redis endpoint used by * clients to connect to the service. @@ -370,9 +408,9 @@ class Instance extends \Google\Protobuf\Internal\Message * Optional. The network connect mode of the Redis instance. * If not provided, the connect mode defaults to DIRECT_PEERING. * @type bool $auth_enabled - * Optional. Indicates whether OSS Redis AUTH is enabled for the instance. If set to - * "true" AUTH is enabled on the instance. Default value is "false" meaning - * AUTH is disabled. + * Optional. Indicates whether OSS Redis AUTH is enabled for the instance. If + * set to "true" AUTH is enabled on the instance. Default value is "false" + * meaning AUTH is disabled. * @type array<\Google\Cloud\Redis\V1\TlsCertificate>|\Google\Protobuf\Internal\RepeatedField $server_ca_certs * Output only. List of server CA certificates for the instance. * @type int $transit_encryption_mode @@ -385,11 +423,11 @@ class Instance extends \Google\Protobuf\Internal\Message * Output only. Date and time of upcoming maintenance events which have been * scheduled. * @type int $replica_count - * Optional. The number of replica nodes. The valid range for the Standard Tier with - * read replicas enabled is [1-5] and defaults to 2. If read replicas are not - * enabled for a Standard Tier instance, the only valid value is 1 and the - * default is 1. The valid value for basic tier is 0 and the default is also - * 0. + * Optional. The number of replica nodes. The valid range for the Standard + * Tier with read replicas enabled is [1-5] and defaults to 2. If read + * replicas are not enabled for a Standard Tier instance, the only valid value + * is 1 and the default is 1. The valid value for basic tier is 0 and the + * default is also 0. * @type array<\Google\Cloud\Redis\V1\NodeInfo>|\Google\Protobuf\Internal\RepeatedField $nodes * Output only. Info per node. * @type string $read_endpoint @@ -401,7 +439,21 @@ class Instance extends \Google\Protobuf\Internal\Message * Output only. The port number of the exposed readonly redis * endpoint. Standard tier only. Write requests should target 'port'. * @type int $read_replicas_mode - * Optional. Read replicas mode for the instance. Defaults to READ_REPLICAS_DISABLED. + * Optional. Read replicas mode for the instance. Defaults to + * READ_REPLICAS_DISABLED. + * @type string $customer_managed_key + * Optional. The KMS key reference that the customer provides when trying to + * create the instance. + * @type \Google\Cloud\Redis\V1\PersistenceConfig $persistence_config + * Optional. Persistence configuration parameters + * @type array|\Google\Protobuf\Internal\RepeatedField $suspension_reasons + * Optional. reasons that causes instance in "SUSPENDED" state. + * @type string $maintenance_version + * Optional. The self service update maintenance version. + * The version is date based such as "20210712_00_00". + * @type array|\Google\Protobuf\Internal\RepeatedField $available_maintenance_versions + * Optional. The available maintenance versions that an instance could update + * to. * } */ public function __construct($data = NULL) { @@ -416,8 +468,10 @@ public function __construct($data = NULL) { * Note: Redis instances are managed and addressed at regional level so * location_id here refers to a GCP region; however, users may choose which * specific zone (or collection of zones for cross-zone instances) an instance - * should be provisioned in. Refer to [location_id][google.cloud.redis.v1.Instance.location_id] and - * [alternative_location_id][google.cloud.redis.v1.Instance.alternative_location_id] fields for more details. + * should be provisioned in. Refer to + * [location_id][google.cloud.redis.v1.Instance.location_id] and + * [alternative_location_id][google.cloud.redis.v1.Instance.alternative_location_id] + * fields for more details. * * Generated from protobuf field string name = 1 [(.google.api.field_behavior) = REQUIRED]; * @return string @@ -434,8 +488,10 @@ public function getName() * Note: Redis instances are managed and addressed at regional level so * location_id here refers to a GCP region; however, users may choose which * specific zone (or collection of zones for cross-zone instances) an instance - * should be provisioned in. Refer to [location_id][google.cloud.redis.v1.Instance.location_id] and - * [alternative_location_id][google.cloud.redis.v1.Instance.alternative_location_id] fields for more details. + * should be provisioned in. Refer to + * [location_id][google.cloud.redis.v1.Instance.location_id] and + * [alternative_location_id][google.cloud.redis.v1.Instance.alternative_location_id] + * fields for more details. * * Generated from protobuf field string name = 1 [(.google.api.field_behavior) = REQUIRED]; * @param string $var @@ -648,11 +704,11 @@ public function setReservedIpRange($var) } /** - * Optional. Additional IP range for node placement. Required when enabling read - * replicas on an existing instance. For DIRECT_PEERING mode value must be a - * CIDR range of size /28, or "auto". For PRIVATE_SERVICE_ACCESS mode value - * must be the name of an allocated address range associated with the private - * service access connection, or "auto". + * Optional. Additional IP range for node placement. Required when enabling + * read replicas on an existing instance. For DIRECT_PEERING mode value must + * be a CIDR range of size /28, or "auto". For PRIVATE_SERVICE_ACCESS mode + * value must be the name of an allocated address range associated with the + * private service access connection, or "auto". * * Generated from protobuf field string secondary_ip_range = 30 [(.google.api.field_behavior) = OPTIONAL]; * @return string @@ -663,11 +719,11 @@ public function getSecondaryIpRange() } /** - * Optional. Additional IP range for node placement. Required when enabling read - * replicas on an existing instance. For DIRECT_PEERING mode value must be a - * CIDR range of size /28, or "auto". For PRIVATE_SERVICE_ACCESS mode value - * must be the name of an allocated address range associated with the private - * service access connection, or "auto". + * Optional. Additional IP range for node placement. Required when enabling + * read replicas on an existing instance. For DIRECT_PEERING mode value must + * be a CIDR range of size /28, or "auto". For PRIVATE_SERVICE_ACCESS mode + * value must be the name of an allocated address range associated with the + * private service access connection, or "auto". * * Generated from protobuf field string secondary_ip_range = 30 [(.google.api.field_behavior) = OPTIONAL]; * @param string $var @@ -1054,9 +1110,9 @@ public function setConnectMode($var) } /** - * Optional. Indicates whether OSS Redis AUTH is enabled for the instance. If set to - * "true" AUTH is enabled on the instance. Default value is "false" meaning - * AUTH is disabled. + * Optional. Indicates whether OSS Redis AUTH is enabled for the instance. If + * set to "true" AUTH is enabled on the instance. Default value is "false" + * meaning AUTH is disabled. * * Generated from protobuf field bool auth_enabled = 23 [(.google.api.field_behavior) = OPTIONAL]; * @return bool @@ -1067,9 +1123,9 @@ public function getAuthEnabled() } /** - * Optional. Indicates whether OSS Redis AUTH is enabled for the instance. If set to - * "true" AUTH is enabled on the instance. Default value is "false" meaning - * AUTH is disabled. + * Optional. Indicates whether OSS Redis AUTH is enabled for the instance. If + * set to "true" AUTH is enabled on the instance. Default value is "false" + * meaning AUTH is disabled. * * Generated from protobuf field bool auth_enabled = 23 [(.google.api.field_behavior) = OPTIONAL]; * @param bool $var @@ -1214,11 +1270,11 @@ public function setMaintenanceSchedule($var) } /** - * Optional. The number of replica nodes. The valid range for the Standard Tier with - * read replicas enabled is [1-5] and defaults to 2. If read replicas are not - * enabled for a Standard Tier instance, the only valid value is 1 and the - * default is 1. The valid value for basic tier is 0 and the default is also - * 0. + * Optional. The number of replica nodes. The valid range for the Standard + * Tier with read replicas enabled is [1-5] and defaults to 2. If read + * replicas are not enabled for a Standard Tier instance, the only valid value + * is 1 and the default is 1. The valid value for basic tier is 0 and the + * default is also 0. * * Generated from protobuf field int32 replica_count = 31 [(.google.api.field_behavior) = OPTIONAL]; * @return int @@ -1229,11 +1285,11 @@ public function getReplicaCount() } /** - * Optional. The number of replica nodes. The valid range for the Standard Tier with - * read replicas enabled is [1-5] and defaults to 2. If read replicas are not - * enabled for a Standard Tier instance, the only valid value is 1 and the - * default is 1. The valid value for basic tier is 0 and the default is also - * 0. + * Optional. The number of replica nodes. The valid range for the Standard + * Tier with read replicas enabled is [1-5] and defaults to 2. If read + * replicas are not enabled for a Standard Tier instance, the only valid value + * is 1 and the default is 1. The valid value for basic tier is 0 and the + * default is also 0. * * Generated from protobuf field int32 replica_count = 31 [(.google.api.field_behavior) = OPTIONAL]; * @param int $var @@ -1334,7 +1390,8 @@ public function setReadEndpointPort($var) } /** - * Optional. Read replicas mode for the instance. Defaults to READ_REPLICAS_DISABLED. + * Optional. Read replicas mode for the instance. Defaults to + * READ_REPLICAS_DISABLED. * * Generated from protobuf field .google.cloud.redis.v1.Instance.ReadReplicasMode read_replicas_mode = 35 [(.google.api.field_behavior) = OPTIONAL]; * @return int @@ -1345,7 +1402,8 @@ public function getReadReplicasMode() } /** - * Optional. Read replicas mode for the instance. Defaults to READ_REPLICAS_DISABLED. + * Optional. Read replicas mode for the instance. Defaults to + * READ_REPLICAS_DISABLED. * * Generated from protobuf field .google.cloud.redis.v1.Instance.ReadReplicasMode read_replicas_mode = 35 [(.google.api.field_behavior) = OPTIONAL]; * @param int $var @@ -1359,5 +1417,151 @@ public function setReadReplicasMode($var) return $this; } + /** + * Optional. The KMS key reference that the customer provides when trying to + * create the instance. + * + * Generated from protobuf field string customer_managed_key = 36 [(.google.api.field_behavior) = OPTIONAL]; + * @return string + */ + public function getCustomerManagedKey() + { + return $this->customer_managed_key; + } + + /** + * Optional. The KMS key reference that the customer provides when trying to + * create the instance. + * + * Generated from protobuf field string customer_managed_key = 36 [(.google.api.field_behavior) = OPTIONAL]; + * @param string $var + * @return $this + */ + public function setCustomerManagedKey($var) + { + GPBUtil::checkString($var, True); + $this->customer_managed_key = $var; + + return $this; + } + + /** + * Optional. Persistence configuration parameters + * + * Generated from protobuf field .google.cloud.redis.v1.PersistenceConfig persistence_config = 37 [(.google.api.field_behavior) = OPTIONAL]; + * @return \Google\Cloud\Redis\V1\PersistenceConfig|null + */ + public function getPersistenceConfig() + { + return $this->persistence_config; + } + + public function hasPersistenceConfig() + { + return isset($this->persistence_config); + } + + public function clearPersistenceConfig() + { + unset($this->persistence_config); + } + + /** + * Optional. Persistence configuration parameters + * + * Generated from protobuf field .google.cloud.redis.v1.PersistenceConfig persistence_config = 37 [(.google.api.field_behavior) = OPTIONAL]; + * @param \Google\Cloud\Redis\V1\PersistenceConfig $var + * @return $this + */ + public function setPersistenceConfig($var) + { + GPBUtil::checkMessage($var, \Google\Cloud\Redis\V1\PersistenceConfig::class); + $this->persistence_config = $var; + + return $this; + } + + /** + * Optional. reasons that causes instance in "SUSPENDED" state. + * + * Generated from protobuf field repeated .google.cloud.redis.v1.Instance.SuspensionReason suspension_reasons = 38 [(.google.api.field_behavior) = OPTIONAL]; + * @return \Google\Protobuf\Internal\RepeatedField + */ + public function getSuspensionReasons() + { + return $this->suspension_reasons; + } + + /** + * Optional. reasons that causes instance in "SUSPENDED" state. + * + * Generated from protobuf field repeated .google.cloud.redis.v1.Instance.SuspensionReason suspension_reasons = 38 [(.google.api.field_behavior) = OPTIONAL]; + * @param array|\Google\Protobuf\Internal\RepeatedField $var + * @return $this + */ + public function setSuspensionReasons($var) + { + $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::ENUM, \Google\Cloud\Redis\V1\Instance\SuspensionReason::class); + $this->suspension_reasons = $arr; + + return $this; + } + + /** + * Optional. The self service update maintenance version. + * The version is date based such as "20210712_00_00". + * + * Generated from protobuf field string maintenance_version = 39 [(.google.api.field_behavior) = OPTIONAL]; + * @return string + */ + public function getMaintenanceVersion() + { + return $this->maintenance_version; + } + + /** + * Optional. The self service update maintenance version. + * The version is date based such as "20210712_00_00". + * + * Generated from protobuf field string maintenance_version = 39 [(.google.api.field_behavior) = OPTIONAL]; + * @param string $var + * @return $this + */ + public function setMaintenanceVersion($var) + { + GPBUtil::checkString($var, True); + $this->maintenance_version = $var; + + return $this; + } + + /** + * Optional. The available maintenance versions that an instance could update + * to. + * + * Generated from protobuf field repeated string available_maintenance_versions = 40 [(.google.api.field_behavior) = OPTIONAL]; + * @return \Google\Protobuf\Internal\RepeatedField + */ + public function getAvailableMaintenanceVersions() + { + return $this->available_maintenance_versions; + } + + /** + * Optional. The available maintenance versions that an instance could update + * to. + * + * Generated from protobuf field repeated string available_maintenance_versions = 40 [(.google.api.field_behavior) = OPTIONAL]; + * @param array|\Google\Protobuf\Internal\RepeatedField $var + * @return $this + */ + public function setAvailableMaintenanceVersions($var) + { + $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::STRING); + $this->available_maintenance_versions = $arr; + + return $this; + } + } diff --git a/Redis/src/V1/Instance/SuspensionReason.php b/Redis/src/V1/Instance/SuspensionReason.php new file mode 100644 index 000000000000..88c2c61370ca --- /dev/null +++ b/Redis/src/V1/Instance/SuspensionReason.php @@ -0,0 +1,57 @@ +google.cloud.redis.v1.Instance.SuspensionReason + */ +class SuspensionReason +{ + /** + * Not set. + * + * Generated from protobuf enum SUSPENSION_REASON_UNSPECIFIED = 0; + */ + const SUSPENSION_REASON_UNSPECIFIED = 0; + /** + * Something wrong with the CMEK key provided by customer. + * + * Generated from protobuf enum CUSTOMER_MANAGED_KEY_ISSUE = 1; + */ + const CUSTOMER_MANAGED_KEY_ISSUE = 1; + + private static $valueToName = [ + self::SUSPENSION_REASON_UNSPECIFIED => 'SUSPENSION_REASON_UNSPECIFIED', + self::CUSTOMER_MANAGED_KEY_ISSUE => 'CUSTOMER_MANAGED_KEY_ISSUE', + ]; + + public static function name($value) + { + if (!isset(self::$valueToName[$value])) { + throw new UnexpectedValueException(sprintf( + 'Enum %s has no name defined for value %s', __CLASS__, $value)); + } + return self::$valueToName[$value]; + } + + + public static function value($name) + { + $const = __CLASS__ . '::' . strtoupper($name); + if (!defined($const)) { + throw new UnexpectedValueException(sprintf( + 'Enum %s has no value defined for name %s', __CLASS__, $name)); + } + return constant($const); + } +} + +// Adding a class alias for backwards compatibility with the previous class name. +class_alias(SuspensionReason::class, \Google\Cloud\Redis\V1\Instance_SuspensionReason::class); + diff --git a/Redis/src/V1/Instance_SuspensionReason.php b/Redis/src/V1/Instance_SuspensionReason.php new file mode 100644 index 000000000000..e112d790ebbc --- /dev/null +++ b/Redis/src/V1/Instance_SuspensionReason.php @@ -0,0 +1,16 @@ +string page_token = 3; */ @@ -61,7 +62,8 @@ class ListInstancesRequest extends \Google\Protobuf\Internal\Message * to determine if there are more instances left to be queried. * @type string $page_token * The `next_page_token` value returned from a previous - * [ListInstances][google.cloud.redis.v1.CloudRedis.ListInstances] request, if any. + * [ListInstances][google.cloud.redis.v1.CloudRedis.ListInstances] request, if + * any. * } */ public function __construct($data = NULL) { @@ -137,7 +139,8 @@ public function setPageSize($var) /** * The `next_page_token` value returned from a previous - * [ListInstances][google.cloud.redis.v1.CloudRedis.ListInstances] request, if any. + * [ListInstances][google.cloud.redis.v1.CloudRedis.ListInstances] request, if + * any. * * Generated from protobuf field string page_token = 3; * @return string @@ -149,7 +152,8 @@ public function getPageToken() /** * The `next_page_token` value returned from a previous - * [ListInstances][google.cloud.redis.v1.CloudRedis.ListInstances] request, if any. + * [ListInstances][google.cloud.redis.v1.CloudRedis.ListInstances] request, if + * any. * * Generated from protobuf field string page_token = 3; * @param string $var diff --git a/Redis/src/V1/MaintenanceSchedule.php b/Redis/src/V1/MaintenanceSchedule.php index 09a6220ca41f..ea039f84b371 100644 --- a/Redis/src/V1/MaintenanceSchedule.php +++ b/Redis/src/V1/MaintenanceSchedule.php @@ -17,13 +17,15 @@ class MaintenanceSchedule extends \Google\Protobuf\Internal\Message { /** - * Output only. The start time of any upcoming scheduled maintenance for this instance. + * Output only. The start time of any upcoming scheduled maintenance for this + * instance. * * Generated from protobuf field .google.protobuf.Timestamp start_time = 1 [(.google.api.field_behavior) = OUTPUT_ONLY]; */ private $start_time = null; /** - * Output only. The end time of any upcoming scheduled maintenance for this instance. + * Output only. The end time of any upcoming scheduled maintenance for this + * instance. * * Generated from protobuf field .google.protobuf.Timestamp end_time = 2 [(.google.api.field_behavior) = OUTPUT_ONLY]; */ @@ -36,8 +38,8 @@ class MaintenanceSchedule extends \Google\Protobuf\Internal\Message */ protected $can_reschedule = false; /** - * Output only. The deadline that the maintenance schedule start time can not go beyond, - * including reschedule. + * Output only. The deadline that the maintenance schedule start time can not + * go beyond, including reschedule. * * Generated from protobuf field .google.protobuf.Timestamp schedule_deadline_time = 5 [(.google.api.field_behavior) = OUTPUT_ONLY]; */ @@ -50,14 +52,16 @@ class MaintenanceSchedule extends \Google\Protobuf\Internal\Message * Optional. Data for populating the Message object. * * @type \Google\Protobuf\Timestamp $start_time - * Output only. The start time of any upcoming scheduled maintenance for this instance. + * Output only. The start time of any upcoming scheduled maintenance for this + * instance. * @type \Google\Protobuf\Timestamp $end_time - * Output only. The end time of any upcoming scheduled maintenance for this instance. + * Output only. The end time of any upcoming scheduled maintenance for this + * instance. * @type bool $can_reschedule * If the scheduled maintenance can be rescheduled, default is true. * @type \Google\Protobuf\Timestamp $schedule_deadline_time - * Output only. The deadline that the maintenance schedule start time can not go beyond, - * including reschedule. + * Output only. The deadline that the maintenance schedule start time can not + * go beyond, including reschedule. * } */ public function __construct($data = NULL) { @@ -66,7 +70,8 @@ public function __construct($data = NULL) { } /** - * Output only. The start time of any upcoming scheduled maintenance for this instance. + * Output only. The start time of any upcoming scheduled maintenance for this + * instance. * * Generated from protobuf field .google.protobuf.Timestamp start_time = 1 [(.google.api.field_behavior) = OUTPUT_ONLY]; * @return \Google\Protobuf\Timestamp|null @@ -87,7 +92,8 @@ public function clearStartTime() } /** - * Output only. The start time of any upcoming scheduled maintenance for this instance. + * Output only. The start time of any upcoming scheduled maintenance for this + * instance. * * Generated from protobuf field .google.protobuf.Timestamp start_time = 1 [(.google.api.field_behavior) = OUTPUT_ONLY]; * @param \Google\Protobuf\Timestamp $var @@ -102,7 +108,8 @@ public function setStartTime($var) } /** - * Output only. The end time of any upcoming scheduled maintenance for this instance. + * Output only. The end time of any upcoming scheduled maintenance for this + * instance. * * Generated from protobuf field .google.protobuf.Timestamp end_time = 2 [(.google.api.field_behavior) = OUTPUT_ONLY]; * @return \Google\Protobuf\Timestamp|null @@ -123,7 +130,8 @@ public function clearEndTime() } /** - * Output only. The end time of any upcoming scheduled maintenance for this instance. + * Output only. The end time of any upcoming scheduled maintenance for this + * instance. * * Generated from protobuf field .google.protobuf.Timestamp end_time = 2 [(.google.api.field_behavior) = OUTPUT_ONLY]; * @param \Google\Protobuf\Timestamp $var @@ -168,8 +176,8 @@ public function setCanReschedule($var) } /** - * Output only. The deadline that the maintenance schedule start time can not go beyond, - * including reschedule. + * Output only. The deadline that the maintenance schedule start time can not + * go beyond, including reschedule. * * Generated from protobuf field .google.protobuf.Timestamp schedule_deadline_time = 5 [(.google.api.field_behavior) = OUTPUT_ONLY]; * @return \Google\Protobuf\Timestamp|null @@ -190,8 +198,8 @@ public function clearScheduleDeadlineTime() } /** - * Output only. The deadline that the maintenance schedule start time can not go beyond, - * including reschedule. + * Output only. The deadline that the maintenance schedule start time can not + * go beyond, including reschedule. * * Generated from protobuf field .google.protobuf.Timestamp schedule_deadline_time = 5 [(.google.api.field_behavior) = OUTPUT_ONLY]; * @param \Google\Protobuf\Timestamp $var diff --git a/Redis/src/V1/PersistenceConfig.php b/Redis/src/V1/PersistenceConfig.php new file mode 100644 index 000000000000..d72ac3519299 --- /dev/null +++ b/Redis/src/V1/PersistenceConfig.php @@ -0,0 +1,221 @@ +google.cloud.redis.v1.PersistenceConfig + */ +class PersistenceConfig extends \Google\Protobuf\Internal\Message +{ + /** + * Optional. Controls whether Persistence features are enabled. + * If not provided, the existing value will be used. + * + * Generated from protobuf field .google.cloud.redis.v1.PersistenceConfig.PersistenceMode persistence_mode = 1 [(.google.api.field_behavior) = OPTIONAL]; + */ + private $persistence_mode = 0; + /** + * Optional. Period between RDB snapshots. Snapshots will be attempted every + * period starting from the provided snapshot start time. For example, a start + * time of 01/01/2033 06:45 and SIX_HOURS snapshot period will do nothing + * until 01/01/2033, and then trigger snapshots every day at 06:45, 12:45, + * 18:45, and 00:45 the next day, and so on. If not provided, + * TWENTY_FOUR_HOURS will be used as default. + * + * Generated from protobuf field .google.cloud.redis.v1.PersistenceConfig.SnapshotPeriod rdb_snapshot_period = 2 [(.google.api.field_behavior) = OPTIONAL]; + */ + private $rdb_snapshot_period = 0; + /** + * Output only. The next time that a snapshot attempt is scheduled to occur. + * + * Generated from protobuf field .google.protobuf.Timestamp rdb_next_snapshot_time = 4 [(.google.api.field_behavior) = OUTPUT_ONLY]; + */ + private $rdb_next_snapshot_time = null; + /** + * Optional. Date and time that the first snapshot was/will be attempted, and + * to which future snapshots will be aligned. If not provided, the current + * time will be used. + * + * Generated from protobuf field .google.protobuf.Timestamp rdb_snapshot_start_time = 5 [(.google.api.field_behavior) = OPTIONAL]; + */ + private $rdb_snapshot_start_time = null; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type int $persistence_mode + * Optional. Controls whether Persistence features are enabled. + * If not provided, the existing value will be used. + * @type int $rdb_snapshot_period + * Optional. Period between RDB snapshots. Snapshots will be attempted every + * period starting from the provided snapshot start time. For example, a start + * time of 01/01/2033 06:45 and SIX_HOURS snapshot period will do nothing + * until 01/01/2033, and then trigger snapshots every day at 06:45, 12:45, + * 18:45, and 00:45 the next day, and so on. If not provided, + * TWENTY_FOUR_HOURS will be used as default. + * @type \Google\Protobuf\Timestamp $rdb_next_snapshot_time + * Output only. The next time that a snapshot attempt is scheduled to occur. + * @type \Google\Protobuf\Timestamp $rdb_snapshot_start_time + * Optional. Date and time that the first snapshot was/will be attempted, and + * to which future snapshots will be aligned. If not provided, the current + * time will be used. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Cloud\Redis\V1\CloudRedis::initOnce(); + parent::__construct($data); + } + + /** + * Optional. Controls whether Persistence features are enabled. + * If not provided, the existing value will be used. + * + * Generated from protobuf field .google.cloud.redis.v1.PersistenceConfig.PersistenceMode persistence_mode = 1 [(.google.api.field_behavior) = OPTIONAL]; + * @return int + */ + public function getPersistenceMode() + { + return $this->persistence_mode; + } + + /** + * Optional. Controls whether Persistence features are enabled. + * If not provided, the existing value will be used. + * + * Generated from protobuf field .google.cloud.redis.v1.PersistenceConfig.PersistenceMode persistence_mode = 1 [(.google.api.field_behavior) = OPTIONAL]; + * @param int $var + * @return $this + */ + public function setPersistenceMode($var) + { + GPBUtil::checkEnum($var, \Google\Cloud\Redis\V1\PersistenceConfig\PersistenceMode::class); + $this->persistence_mode = $var; + + return $this; + } + + /** + * Optional. Period between RDB snapshots. Snapshots will be attempted every + * period starting from the provided snapshot start time. For example, a start + * time of 01/01/2033 06:45 and SIX_HOURS snapshot period will do nothing + * until 01/01/2033, and then trigger snapshots every day at 06:45, 12:45, + * 18:45, and 00:45 the next day, and so on. If not provided, + * TWENTY_FOUR_HOURS will be used as default. + * + * Generated from protobuf field .google.cloud.redis.v1.PersistenceConfig.SnapshotPeriod rdb_snapshot_period = 2 [(.google.api.field_behavior) = OPTIONAL]; + * @return int + */ + public function getRdbSnapshotPeriod() + { + return $this->rdb_snapshot_period; + } + + /** + * Optional. Period between RDB snapshots. Snapshots will be attempted every + * period starting from the provided snapshot start time. For example, a start + * time of 01/01/2033 06:45 and SIX_HOURS snapshot period will do nothing + * until 01/01/2033, and then trigger snapshots every day at 06:45, 12:45, + * 18:45, and 00:45 the next day, and so on. If not provided, + * TWENTY_FOUR_HOURS will be used as default. + * + * Generated from protobuf field .google.cloud.redis.v1.PersistenceConfig.SnapshotPeriod rdb_snapshot_period = 2 [(.google.api.field_behavior) = OPTIONAL]; + * @param int $var + * @return $this + */ + public function setRdbSnapshotPeriod($var) + { + GPBUtil::checkEnum($var, \Google\Cloud\Redis\V1\PersistenceConfig\SnapshotPeriod::class); + $this->rdb_snapshot_period = $var; + + return $this; + } + + /** + * Output only. The next time that a snapshot attempt is scheduled to occur. + * + * Generated from protobuf field .google.protobuf.Timestamp rdb_next_snapshot_time = 4 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * @return \Google\Protobuf\Timestamp|null + */ + public function getRdbNextSnapshotTime() + { + return $this->rdb_next_snapshot_time; + } + + public function hasRdbNextSnapshotTime() + { + return isset($this->rdb_next_snapshot_time); + } + + public function clearRdbNextSnapshotTime() + { + unset($this->rdb_next_snapshot_time); + } + + /** + * Output only. The next time that a snapshot attempt is scheduled to occur. + * + * Generated from protobuf field .google.protobuf.Timestamp rdb_next_snapshot_time = 4 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * @param \Google\Protobuf\Timestamp $var + * @return $this + */ + public function setRdbNextSnapshotTime($var) + { + GPBUtil::checkMessage($var, \Google\Protobuf\Timestamp::class); + $this->rdb_next_snapshot_time = $var; + + return $this; + } + + /** + * Optional. Date and time that the first snapshot was/will be attempted, and + * to which future snapshots will be aligned. If not provided, the current + * time will be used. + * + * Generated from protobuf field .google.protobuf.Timestamp rdb_snapshot_start_time = 5 [(.google.api.field_behavior) = OPTIONAL]; + * @return \Google\Protobuf\Timestamp|null + */ + public function getRdbSnapshotStartTime() + { + return $this->rdb_snapshot_start_time; + } + + public function hasRdbSnapshotStartTime() + { + return isset($this->rdb_snapshot_start_time); + } + + public function clearRdbSnapshotStartTime() + { + unset($this->rdb_snapshot_start_time); + } + + /** + * Optional. Date and time that the first snapshot was/will be attempted, and + * to which future snapshots will be aligned. If not provided, the current + * time will be used. + * + * Generated from protobuf field .google.protobuf.Timestamp rdb_snapshot_start_time = 5 [(.google.api.field_behavior) = OPTIONAL]; + * @param \Google\Protobuf\Timestamp $var + * @return $this + */ + public function setRdbSnapshotStartTime($var) + { + GPBUtil::checkMessage($var, \Google\Protobuf\Timestamp::class); + $this->rdb_snapshot_start_time = $var; + + return $this; + } + +} + diff --git a/Redis/src/V1/PersistenceConfig/PersistenceMode.php b/Redis/src/V1/PersistenceConfig/PersistenceMode.php new file mode 100644 index 000000000000..0a752391e7d4 --- /dev/null +++ b/Redis/src/V1/PersistenceConfig/PersistenceMode.php @@ -0,0 +1,65 @@ +google.cloud.redis.v1.PersistenceConfig.PersistenceMode + */ +class PersistenceMode +{ + /** + * Not set. + * + * Generated from protobuf enum PERSISTENCE_MODE_UNSPECIFIED = 0; + */ + const PERSISTENCE_MODE_UNSPECIFIED = 0; + /** + * Persistence is disabled for the instance, + * and any existing snapshots are deleted. + * + * Generated from protobuf enum DISABLED = 1; + */ + const DISABLED = 1; + /** + * RDB based Persistence is enabled. + * + * Generated from protobuf enum RDB = 2; + */ + const RDB = 2; + + private static $valueToName = [ + self::PERSISTENCE_MODE_UNSPECIFIED => 'PERSISTENCE_MODE_UNSPECIFIED', + self::DISABLED => 'DISABLED', + self::RDB => 'RDB', + ]; + + public static function name($value) + { + if (!isset(self::$valueToName[$value])) { + throw new UnexpectedValueException(sprintf( + 'Enum %s has no name defined for value %s', __CLASS__, $value)); + } + return self::$valueToName[$value]; + } + + + public static function value($name) + { + $const = __CLASS__ . '::' . strtoupper($name); + if (!defined($const)) { + throw new UnexpectedValueException(sprintf( + 'Enum %s has no value defined for name %s', __CLASS__, $name)); + } + return constant($const); + } +} + +// Adding a class alias for backwards compatibility with the previous class name. +class_alias(PersistenceMode::class, \Google\Cloud\Redis\V1\PersistenceConfig_PersistenceMode::class); + diff --git a/Redis/src/V1/PersistenceConfig/SnapshotPeriod.php b/Redis/src/V1/PersistenceConfig/SnapshotPeriod.php new file mode 100644 index 000000000000..43807bc8a3c1 --- /dev/null +++ b/Redis/src/V1/PersistenceConfig/SnapshotPeriod.php @@ -0,0 +1,78 @@ +google.cloud.redis.v1.PersistenceConfig.SnapshotPeriod + */ +class SnapshotPeriod +{ + /** + * Not set. + * + * Generated from protobuf enum SNAPSHOT_PERIOD_UNSPECIFIED = 0; + */ + const SNAPSHOT_PERIOD_UNSPECIFIED = 0; + /** + * Snapshot every 1 hour. + * + * Generated from protobuf enum ONE_HOUR = 3; + */ + const ONE_HOUR = 3; + /** + * Snapshot every 6 hours. + * + * Generated from protobuf enum SIX_HOURS = 4; + */ + const SIX_HOURS = 4; + /** + * Snapshot every 12 hours. + * + * Generated from protobuf enum TWELVE_HOURS = 5; + */ + const TWELVE_HOURS = 5; + /** + * Snapshot every 24 hours. + * + * Generated from protobuf enum TWENTY_FOUR_HOURS = 6; + */ + const TWENTY_FOUR_HOURS = 6; + + private static $valueToName = [ + self::SNAPSHOT_PERIOD_UNSPECIFIED => 'SNAPSHOT_PERIOD_UNSPECIFIED', + self::ONE_HOUR => 'ONE_HOUR', + self::SIX_HOURS => 'SIX_HOURS', + self::TWELVE_HOURS => 'TWELVE_HOURS', + self::TWENTY_FOUR_HOURS => 'TWENTY_FOUR_HOURS', + ]; + + public static function name($value) + { + if (!isset(self::$valueToName[$value])) { + throw new UnexpectedValueException(sprintf( + 'Enum %s has no name defined for value %s', __CLASS__, $value)); + } + return self::$valueToName[$value]; + } + + + public static function value($name) + { + $const = __CLASS__ . '::' . strtoupper($name); + if (!defined($const)) { + throw new UnexpectedValueException(sprintf( + 'Enum %s has no value defined for name %s', __CLASS__, $name)); + } + return constant($const); + } +} + +// Adding a class alias for backwards compatibility with the previous class name. +class_alias(SnapshotPeriod::class, \Google\Cloud\Redis\V1\PersistenceConfig_SnapshotPeriod::class); + diff --git a/Redis/src/V1/PersistenceConfig_PersistenceMode.php b/Redis/src/V1/PersistenceConfig_PersistenceMode.php new file mode 100644 index 000000000000..e67b171cd4da --- /dev/null +++ b/Redis/src/V1/PersistenceConfig_PersistenceMode.php @@ -0,0 +1,16 @@ +google.cloud.redis.v1.RescheduleMaintenanceRequest */ @@ -24,7 +25,8 @@ class RescheduleMaintenanceRequest extends \Google\Protobuf\Internal\Message */ private $name = ''; /** - * Required. If reschedule type is SPECIFIC_TIME, must set up schedule_time as well. + * Required. If reschedule type is SPECIFIC_TIME, must set up schedule_time as + * well. * * Generated from protobuf field .google.cloud.redis.v1.RescheduleMaintenanceRequest.RescheduleType reschedule_type = 2 [(.google.api.field_behavior) = REQUIRED]; */ @@ -49,7 +51,8 @@ class RescheduleMaintenanceRequest extends \Google\Protobuf\Internal\Message * `projects/{project_id}/locations/{location_id}/instances/{instance_id}` * where `location_id` refers to a GCP region. * @type int $reschedule_type - * Required. If reschedule type is SPECIFIC_TIME, must set up schedule_time as well. + * Required. If reschedule type is SPECIFIC_TIME, must set up schedule_time as + * well. * @type \Google\Protobuf\Timestamp $schedule_time * Optional. Timestamp when the maintenance shall be rescheduled to if * reschedule_type=SPECIFIC_TIME, in RFC 3339 format, for @@ -92,7 +95,8 @@ public function setName($var) } /** - * Required. If reschedule type is SPECIFIC_TIME, must set up schedule_time as well. + * Required. If reschedule type is SPECIFIC_TIME, must set up schedule_time as + * well. * * Generated from protobuf field .google.cloud.redis.v1.RescheduleMaintenanceRequest.RescheduleType reschedule_type = 2 [(.google.api.field_behavior) = REQUIRED]; * @return int @@ -103,7 +107,8 @@ public function getRescheduleType() } /** - * Required. If reschedule type is SPECIFIC_TIME, must set up schedule_time as well. + * Required. If reschedule type is SPECIFIC_TIME, must set up schedule_time as + * well. * * Generated from protobuf field .google.cloud.redis.v1.RescheduleMaintenanceRequest.RescheduleType reschedule_type = 2 [(.google.api.field_behavior) = REQUIRED]; * @param int $var diff --git a/Redis/src/V1/UpdateInstanceRequest.php b/Redis/src/V1/UpdateInstanceRequest.php index 8eacfd2c4924..54e75b04cddf 100644 --- a/Redis/src/V1/UpdateInstanceRequest.php +++ b/Redis/src/V1/UpdateInstanceRequest.php @@ -9,7 +9,8 @@ use Google\Protobuf\Internal\GPBUtil; /** - * Request for [UpdateInstance][google.cloud.redis.v1.CloudRedis.UpdateInstance]. + * Request for + * [UpdateInstance][google.cloud.redis.v1.CloudRedis.UpdateInstance]. * * Generated from protobuf message google.cloud.redis.v1.UpdateInstanceRequest */ diff --git a/Redis/src/V1/UpgradeInstanceRequest.php b/Redis/src/V1/UpgradeInstanceRequest.php index 96891fb70290..55774e2bc17b 100644 --- a/Redis/src/V1/UpgradeInstanceRequest.php +++ b/Redis/src/V1/UpgradeInstanceRequest.php @@ -9,7 +9,8 @@ use Google\Protobuf\Internal\GPBUtil; /** - * Request for [UpgradeInstance][google.cloud.redis.v1.CloudRedis.UpgradeInstance]. + * Request for + * [UpgradeInstance][google.cloud.redis.v1.CloudRedis.UpgradeInstance]. * * Generated from protobuf message google.cloud.redis.v1.UpgradeInstanceRequest */ diff --git a/Redis/src/V1/WeeklyMaintenanceWindow.php b/Redis/src/V1/WeeklyMaintenanceWindow.php index bc3da9261730..e2005ba33dbf 100644 --- a/Redis/src/V1/WeeklyMaintenanceWindow.php +++ b/Redis/src/V1/WeeklyMaintenanceWindow.php @@ -29,7 +29,8 @@ class WeeklyMaintenanceWindow extends \Google\Protobuf\Internal\Message */ private $start_time = null; /** - * Output only. Duration of the maintenance window. The current window is fixed at 1 hour. + * Output only. Duration of the maintenance window. The current window is + * fixed at 1 hour. * * Generated from protobuf field .google.protobuf.Duration duration = 3 [(.google.api.field_behavior) = OUTPUT_ONLY]; */ @@ -46,7 +47,8 @@ class WeeklyMaintenanceWindow extends \Google\Protobuf\Internal\Message * @type \Google\Type\TimeOfDay $start_time * Required. Start time of the window in UTC time. * @type \Google\Protobuf\Duration $duration - * Output only. Duration of the maintenance window. The current window is fixed at 1 hour. + * Output only. Duration of the maintenance window. The current window is + * fixed at 1 hour. * } */ public function __construct($data = NULL) { @@ -117,7 +119,8 @@ public function setStartTime($var) } /** - * Output only. Duration of the maintenance window. The current window is fixed at 1 hour. + * Output only. Duration of the maintenance window. The current window is + * fixed at 1 hour. * * Generated from protobuf field .google.protobuf.Duration duration = 3 [(.google.api.field_behavior) = OUTPUT_ONLY]; * @return \Google\Protobuf\Duration|null @@ -138,7 +141,8 @@ public function clearDuration() } /** - * Output only. Duration of the maintenance window. The current window is fixed at 1 hour. + * Output only. Duration of the maintenance window. The current window is + * fixed at 1 hour. * * Generated from protobuf field .google.protobuf.Duration duration = 3 [(.google.api.field_behavior) = OUTPUT_ONLY]; * @param \Google\Protobuf\Duration $var diff --git a/Redis/src/V1/gapic_metadata.json b/Redis/src/V1/gapic_metadata.json index be3a1913c2fc..66b8e98718c8 100644 --- a/Redis/src/V1/gapic_metadata.json +++ b/Redis/src/V1/gapic_metadata.json @@ -64,6 +64,16 @@ "methods": [ "upgradeInstance" ] + }, + "GetLocation": { + "methods": [ + "getLocation" + ] + }, + "ListLocations": { + "methods": [ + "listLocations" + ] } } } diff --git a/Redis/src/V1/resources/cloud_redis_client_config.json b/Redis/src/V1/resources/cloud_redis_client_config.json index 66153e4f6cdd..364a78c114b5 100644 --- a/Redis/src/V1/resources/cloud_redis_client_config.json +++ b/Redis/src/V1/resources/cloud_redis_client_config.json @@ -80,6 +80,16 @@ "timeout_millis": 600000, "retry_codes_name": "no_retry_1_codes", "retry_params_name": "no_retry_1_params" + }, + "GetLocation": { + "timeout_millis": 60000, + "retry_codes_name": "no_retry_codes", + "retry_params_name": "no_retry_params" + }, + "ListLocations": { + "timeout_millis": 60000, + "retry_codes_name": "no_retry_codes", + "retry_params_name": "no_retry_params" } } } diff --git a/Redis/src/V1/resources/cloud_redis_descriptor_config.php b/Redis/src/V1/resources/cloud_redis_descriptor_config.php index 4e4128a24135..d6bc80c6e208 100644 --- a/Redis/src/V1/resources/cloud_redis_descriptor_config.php +++ b/Redis/src/V1/resources/cloud_redis_descriptor_config.php @@ -93,6 +93,20 @@ 'resourcesGetMethod' => 'getInstances', ], ], + 'GetLocation' => [ + 'interfaceOverride' => 'google.cloud.location.Locations', + ], + 'ListLocations' => [ + 'pageStreaming' => [ + 'requestPageTokenGetMethod' => 'getPageToken', + 'requestPageTokenSetMethod' => 'setPageToken', + 'requestPageSizeGetMethod' => 'getPageSize', + 'requestPageSizeSetMethod' => 'setPageSize', + 'responsePageTokenGetMethod' => 'getNextPageToken', + 'resourcesGetMethod' => 'getLocations', + ], + 'interfaceOverride' => 'google.cloud.location.Locations', + ], ], ], ]; diff --git a/Redis/tests/Unit/V1/CloudRedisClientTest.php b/Redis/tests/Unit/V1/CloudRedisClientTest.php index 4514917ae97c..af6ab2a03950 100644 --- a/Redis/tests/Unit/V1/CloudRedisClientTest.php +++ b/Redis/tests/Unit/V1/CloudRedisClientTest.php @@ -27,6 +27,8 @@ use Google\ApiCore\LongRunning\OperationsClient; use Google\ApiCore\Testing\GeneratedTest; use Google\ApiCore\Testing\MockTransport; +use Google\Cloud\Location\ListLocationsResponse; +use Google\Cloud\Location\Location; use Google\Cloud\Redis\V1\CloudRedisClient; use Google\Cloud\Redis\V1\InputConfig; use Google\Cloud\Redis\V1\Instance; @@ -110,6 +112,8 @@ public function createInstanceTest() $replicaCount = 564075208; $readEndpoint = 'readEndpoint-2081202658'; $readEndpointPort = 1676143102; + $customerManagedKey = 'customerManagedKey-1392642338'; + $maintenanceVersion = 'maintenanceVersion-588975188'; $expectedResponse = new Instance(); $expectedResponse->setName($name); $expectedResponse->setDisplayName($displayName); @@ -129,6 +133,8 @@ public function createInstanceTest() $expectedResponse->setReplicaCount($replicaCount); $expectedResponse->setReadEndpoint($readEndpoint); $expectedResponse->setReadEndpointPort($readEndpointPort); + $expectedResponse->setCustomerManagedKey($customerManagedKey); + $expectedResponse->setMaintenanceVersion($maintenanceVersion); $anyResponse = new Any(); $anyResponse->setValue($expectedResponse->serializeToString()); $completeOperation = new Operation(); @@ -400,6 +406,8 @@ public function exportInstanceTest() $replicaCount = 564075208; $readEndpoint = 'readEndpoint-2081202658'; $readEndpointPort = 1676143102; + $customerManagedKey = 'customerManagedKey-1392642338'; + $maintenanceVersion = 'maintenanceVersion-588975188'; $expectedResponse = new Instance(); $expectedResponse->setName($name2); $expectedResponse->setDisplayName($displayName); @@ -419,6 +427,8 @@ public function exportInstanceTest() $expectedResponse->setReplicaCount($replicaCount); $expectedResponse->setReadEndpoint($readEndpoint); $expectedResponse->setReadEndpointPort($readEndpointPort); + $expectedResponse->setCustomerManagedKey($customerManagedKey); + $expectedResponse->setMaintenanceVersion($maintenanceVersion); $anyResponse = new Any(); $anyResponse->setValue($expectedResponse->serializeToString()); $completeOperation = new Operation(); @@ -557,6 +567,8 @@ public function failoverInstanceTest() $replicaCount = 564075208; $readEndpoint = 'readEndpoint-2081202658'; $readEndpointPort = 1676143102; + $customerManagedKey = 'customerManagedKey-1392642338'; + $maintenanceVersion = 'maintenanceVersion-588975188'; $expectedResponse = new Instance(); $expectedResponse->setName($name2); $expectedResponse->setDisplayName($displayName); @@ -576,6 +588,8 @@ public function failoverInstanceTest() $expectedResponse->setReplicaCount($replicaCount); $expectedResponse->setReadEndpoint($readEndpoint); $expectedResponse->setReadEndpointPort($readEndpointPort); + $expectedResponse->setCustomerManagedKey($customerManagedKey); + $expectedResponse->setMaintenanceVersion($maintenanceVersion); $anyResponse = new Any(); $anyResponse->setValue($expectedResponse->serializeToString()); $completeOperation = new Operation(); @@ -698,6 +712,8 @@ public function getInstanceTest() $replicaCount = 564075208; $readEndpoint = 'readEndpoint-2081202658'; $readEndpointPort = 1676143102; + $customerManagedKey = 'customerManagedKey-1392642338'; + $maintenanceVersion = 'maintenanceVersion-588975188'; $expectedResponse = new Instance(); $expectedResponse->setName($name2); $expectedResponse->setDisplayName($displayName); @@ -717,6 +733,8 @@ public function getInstanceTest() $expectedResponse->setReplicaCount($replicaCount); $expectedResponse->setReadEndpoint($readEndpoint); $expectedResponse->setReadEndpointPort($readEndpointPort); + $expectedResponse->setCustomerManagedKey($customerManagedKey); + $expectedResponse->setMaintenanceVersion($maintenanceVersion); $transport->addResponse($expectedResponse); // Mock request $formattedName = $gapicClient->instanceName('[PROJECT]', '[LOCATION]', '[INSTANCE]'); @@ -864,6 +882,8 @@ public function importInstanceTest() $replicaCount = 564075208; $readEndpoint = 'readEndpoint-2081202658'; $readEndpointPort = 1676143102; + $customerManagedKey = 'customerManagedKey-1392642338'; + $maintenanceVersion = 'maintenanceVersion-588975188'; $expectedResponse = new Instance(); $expectedResponse->setName($name2); $expectedResponse->setDisplayName($displayName); @@ -883,6 +903,8 @@ public function importInstanceTest() $expectedResponse->setReplicaCount($replicaCount); $expectedResponse->setReadEndpoint($readEndpoint); $expectedResponse->setReadEndpointPort($readEndpointPort); + $expectedResponse->setCustomerManagedKey($customerManagedKey); + $expectedResponse->setMaintenanceVersion($maintenanceVersion); $anyResponse = new Any(); $anyResponse->setValue($expectedResponse->serializeToString()); $completeOperation = new Operation(); @@ -1089,6 +1111,8 @@ public function rescheduleMaintenanceTest() $replicaCount = 564075208; $readEndpoint = 'readEndpoint-2081202658'; $readEndpointPort = 1676143102; + $customerManagedKey = 'customerManagedKey-1392642338'; + $maintenanceVersion = 'maintenanceVersion-588975188'; $expectedResponse = new Instance(); $expectedResponse->setName($name2); $expectedResponse->setDisplayName($displayName); @@ -1108,6 +1132,8 @@ public function rescheduleMaintenanceTest() $expectedResponse->setReplicaCount($replicaCount); $expectedResponse->setReadEndpoint($readEndpoint); $expectedResponse->setReadEndpointPort($readEndpointPort); + $expectedResponse->setCustomerManagedKey($customerManagedKey); + $expectedResponse->setMaintenanceVersion($maintenanceVersion); $anyResponse = new Any(); $anyResponse->setValue($expectedResponse->serializeToString()); $completeOperation = new Operation(); @@ -1246,6 +1272,8 @@ public function updateInstanceTest() $replicaCount = 564075208; $readEndpoint = 'readEndpoint-2081202658'; $readEndpointPort = 1676143102; + $customerManagedKey = 'customerManagedKey-1392642338'; + $maintenanceVersion = 'maintenanceVersion-588975188'; $expectedResponse = new Instance(); $expectedResponse->setName($name); $expectedResponse->setDisplayName($displayName); @@ -1265,6 +1293,8 @@ public function updateInstanceTest() $expectedResponse->setReplicaCount($replicaCount); $expectedResponse->setReadEndpoint($readEndpoint); $expectedResponse->setReadEndpointPort($readEndpointPort); + $expectedResponse->setCustomerManagedKey($customerManagedKey); + $expectedResponse->setMaintenanceVersion($maintenanceVersion); $anyResponse = new Any(); $anyResponse->setValue($expectedResponse->serializeToString()); $completeOperation = new Operation(); @@ -1415,6 +1445,8 @@ public function upgradeInstanceTest() $replicaCount = 564075208; $readEndpoint = 'readEndpoint-2081202658'; $readEndpointPort = 1676143102; + $customerManagedKey = 'customerManagedKey-1392642338'; + $maintenanceVersion = 'maintenanceVersion-588975188'; $expectedResponse = new Instance(); $expectedResponse->setName($name2); $expectedResponse->setDisplayName($displayName); @@ -1434,6 +1466,8 @@ public function upgradeInstanceTest() $expectedResponse->setReplicaCount($replicaCount); $expectedResponse->setReadEndpoint($readEndpoint); $expectedResponse->setReadEndpointPort($readEndpointPort); + $expectedResponse->setCustomerManagedKey($customerManagedKey); + $expectedResponse->setMaintenanceVersion($maintenanceVersion); $anyResponse = new Any(); $anyResponse->setValue($expectedResponse->serializeToString()); $completeOperation = new Operation(); @@ -1532,4 +1566,124 @@ public function upgradeInstanceExceptionTest() $this->assertTrue($transport->isExhausted()); $this->assertTrue($operationsTransport->isExhausted()); } + + /** @test */ + public function getLocationTest() + { + $transport = $this->createTransport(); + $gapicClient = $this->createClient([ + 'transport' => $transport, + ]); + $this->assertTrue($transport->isExhausted()); + // Mock response + $name2 = 'name2-1052831874'; + $locationId = 'locationId552319461'; + $displayName = 'displayName1615086568'; + $expectedResponse = new Location(); + $expectedResponse->setName($name2); + $expectedResponse->setLocationId($locationId); + $expectedResponse->setDisplayName($displayName); + $transport->addResponse($expectedResponse); + $response = $gapicClient->getLocation(); + $this->assertEquals($expectedResponse, $response); + $actualRequests = $transport->popReceivedCalls(); + $this->assertSame(1, count($actualRequests)); + $actualFuncCall = $actualRequests[0]->getFuncCall(); + $actualRequestObject = $actualRequests[0]->getRequestObject(); + $this->assertSame('/google.cloud.location.Locations/GetLocation', $actualFuncCall); + $this->assertTrue($transport->isExhausted()); + } + + /** @test */ + public function getLocationExceptionTest() + { + $transport = $this->createTransport(); + $gapicClient = $this->createClient([ + 'transport' => $transport, + ]); + $this->assertTrue($transport->isExhausted()); + $status = new stdClass(); + $status->code = Code::DATA_LOSS; + $status->details = 'internal error'; + $expectedExceptionMessage = json_encode([ + 'message' => 'internal error', + 'code' => Code::DATA_LOSS, + 'status' => 'DATA_LOSS', + 'details' => [], + ], JSON_PRETTY_PRINT); + $transport->addResponse(null, $status); + try { + $gapicClient->getLocation(); + // If the $gapicClient method call did not throw, fail the test + $this->fail('Expected an ApiException, but no exception was thrown.'); + } catch (ApiException $ex) { + $this->assertEquals($status->code, $ex->getCode()); + $this->assertEquals($expectedExceptionMessage, $ex->getMessage()); + } + // Call popReceivedCalls to ensure the stub is exhausted + $transport->popReceivedCalls(); + $this->assertTrue($transport->isExhausted()); + } + + /** @test */ + public function listLocationsTest() + { + $transport = $this->createTransport(); + $gapicClient = $this->createClient([ + 'transport' => $transport, + ]); + $this->assertTrue($transport->isExhausted()); + // Mock response + $nextPageToken = ''; + $locationsElement = new Location(); + $locations = [ + $locationsElement, + ]; + $expectedResponse = new ListLocationsResponse(); + $expectedResponse->setNextPageToken($nextPageToken); + $expectedResponse->setLocations($locations); + $transport->addResponse($expectedResponse); + $response = $gapicClient->listLocations(); + $this->assertEquals($expectedResponse, $response->getPage()->getResponseObject()); + $resources = iterator_to_array($response->iterateAllElements()); + $this->assertSame(1, count($resources)); + $this->assertEquals($expectedResponse->getLocations()[0], $resources[0]); + $actualRequests = $transport->popReceivedCalls(); + $this->assertSame(1, count($actualRequests)); + $actualFuncCall = $actualRequests[0]->getFuncCall(); + $actualRequestObject = $actualRequests[0]->getRequestObject(); + $this->assertSame('/google.cloud.location.Locations/ListLocations', $actualFuncCall); + $this->assertTrue($transport->isExhausted()); + } + + /** @test */ + public function listLocationsExceptionTest() + { + $transport = $this->createTransport(); + $gapicClient = $this->createClient([ + 'transport' => $transport, + ]); + $this->assertTrue($transport->isExhausted()); + $status = new stdClass(); + $status->code = Code::DATA_LOSS; + $status->details = 'internal error'; + $expectedExceptionMessage = json_encode([ + 'message' => 'internal error', + 'code' => Code::DATA_LOSS, + 'status' => 'DATA_LOSS', + 'details' => [], + ], JSON_PRETTY_PRINT); + $transport->addResponse(null, $status); + try { + $gapicClient->listLocations(); + // If the $gapicClient method call did not throw, fail the test + $this->fail('Expected an ApiException, but no exception was thrown.'); + } catch (ApiException $ex) { + $this->assertEquals($status->code, $ex->getCode()); + $this->assertEquals($expectedExceptionMessage, $ex->getMessage()); + } + // Call popReceivedCalls to ensure the stub is exhausted + $transport->popReceivedCalls(); + $this->assertTrue($transport->isExhausted()); + } }