Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: [Cloud Memorystore for Redis] Support Maintenance Window #5157

Merged
merged 4 commits into from
Mar 29, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file modified Redis/metadata/V1/CloudRedis.php
Binary file not shown.
33 changes: 33 additions & 0 deletions Redis/src/V1/CloudRedisGrpcClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,23 @@ public function GetInstance(\Google\Cloud\Redis\V1\GetInstanceRequest $argument,
$metadata, $options);
}

/**
* Gets the AUTH string for a Redis instance. If AUTH is not enabled for the
* instance the response will be empty. This information is not included in
* the details returned to GetInstance.
* @param \Google\Cloud\Redis\V1\GetInstanceAuthStringRequest $argument input argument
* @param array $metadata metadata
* @param array $options call options
* @return \Grpc\UnaryCall
*/
public function GetInstanceAuthString(\Google\Cloud\Redis\V1\GetInstanceAuthStringRequest $argument,
$metadata = [], $options = []) {
return $this->_simpleRequest('/google.cloud.redis.v1.CloudRedis/GetInstanceAuthString',
$argument,
['\Google\Cloud\Redis\V1\InstanceAuthString', 'decode'],
$metadata, $options);
}

/**
* Creates a Redis instance based on the specified tier and memory size.
*
Expand Down Expand Up @@ -219,4 +236,20 @@ public function DeleteInstance(\Google\Cloud\Redis\V1\DeleteInstanceRequest $arg
$metadata, $options);
}

/**
* Reschedule maintenance for a given instance in a given project and
* location.
* @param \Google\Cloud\Redis\V1\RescheduleMaintenanceRequest $argument input argument
* @param array $metadata metadata
* @param array $options call options
* @return \Grpc\UnaryCall
*/
public function RescheduleMaintenance(\Google\Cloud\Redis\V1\RescheduleMaintenanceRequest $argument,
$metadata = [], $options = []) {
return $this->_simpleRequest('/google.cloud.redis.v1.CloudRedis/RescheduleMaintenance',
$argument,
['\Google\LongRunning\Operation', 'decode'],
$metadata, $options);
}

}
131 changes: 130 additions & 1 deletion Redis/src/V1/Gapic/CloudRedisGapicClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,18 +41,23 @@
use Google\Cloud\Redis\V1\DeleteInstanceRequest;
use Google\Cloud\Redis\V1\ExportInstanceRequest;
use Google\Cloud\Redis\V1\FailoverInstanceRequest;
use Google\Cloud\Redis\V1\GetInstanceAuthStringRequest;
use Google\Cloud\Redis\V1\GetInstanceRequest;
use Google\Cloud\Redis\V1\ImportInstanceRequest;
use Google\Cloud\Redis\V1\InputConfig;
use Google\Cloud\Redis\V1\Instance;
use Google\Cloud\Redis\V1\InstanceAuthString;
use Google\Cloud\Redis\V1\ListInstancesRequest;
use Google\Cloud\Redis\V1\ListInstancesResponse;
use Google\Cloud\Redis\V1\OutputConfig;
use Google\Cloud\Redis\V1\UpdateInstanceRequest;
use Google\Cloud\Redis\V1\RescheduleMaintenanceRequest;

use Google\Cloud\Redis\V1\RescheduleMaintenanceRequest\RescheduleType;
use Google\Cloud\Redis\V1\UpdateInstanceRequest;
use Google\Cloud\Redis\V1\UpgradeInstanceRequest;
use Google\LongRunning\Operation;
use Google\Protobuf\FieldMask;
use Google\Protobuf\Timestamp;

/**
* Service Description: Configures and manages Cloud Memorystore for Redis instances
Expand Down Expand Up @@ -725,6 +730,50 @@ public function getInstance($name, array $optionalArgs = [])
return $this->startCall('GetInstance', Instance::class, $optionalArgs, $request)->wait();
}

/**
* Gets the AUTH string for a Redis instance. If AUTH is not enabled for the
* instance the response will be empty. This information is not included in
* the details returned to GetInstance.
*
* Sample code:
* ```
* $cloudRedisClient = new Google\Cloud\Redis\V1\CloudRedisClient();
* try {
* $formattedName = $cloudRedisClient->instanceName('[PROJECT]', '[LOCATION]', '[INSTANCE]');
* $response = $cloudRedisClient->getInstanceAuthString($formattedName);
* } finally {
* $cloudRedisClient->close();
* }
* ```
*
* @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 array $optionalArgs {
* Optional.
*
* @type RetrySettings|array $retrySettings
* Retry settings to use for this call. Can be a
* {@see Google\ApiCore\RetrySettings} object, or an associative array of retry
* settings parameters. See the documentation on
* {@see Google\ApiCore\RetrySettings} for example usage.
* }
*
* @return \Google\Cloud\Redis\V1\InstanceAuthString
*
* @throws ApiException if the remote call fails
*/
public function getInstanceAuthString($name, array $optionalArgs = [])
{
$request = new GetInstanceAuthStringRequest();
$requestParamHeaders = [];
$request->setName($name);
$requestParamHeaders['name'] = $name;
$requestParams = new RequestParamsHeaderDescriptor($requestParamHeaders);
$optionalArgs['headers'] = isset($optionalArgs['headers']) ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) : $requestParams->getHeader();
return $this->startCall('GetInstanceAuthString', InstanceAuthString::class, $optionalArgs, $request)->wait();
}

/**
* Import a Redis RDB snapshot file from Cloud Storage into a Redis instance.
*
Expand Down Expand Up @@ -881,6 +930,86 @@ public function listInstances($parent, array $optionalArgs = [])
return $this->getPagedListResponse('ListInstances', $optionalArgs, ListInstancesResponse::class, $request);
}

/**
* Reschedule maintenance for a given instance in a given project and
* location.
*
* Sample code:
* ```
* $cloudRedisClient = new Google\Cloud\Redis\V1\CloudRedisClient();
* try {
* $formattedName = $cloudRedisClient->instanceName('[PROJECT]', '[LOCATION]', '[INSTANCE]');
* $rescheduleType = RescheduleType::RESCHEDULE_TYPE_UNSPECIFIED;
* $operationResponse = $cloudRedisClient->rescheduleMaintenance($formattedName, $rescheduleType);
* $operationResponse->pollUntilComplete();
* if ($operationResponse->operationSucceeded()) {
* $result = $operationResponse->getResult();
* // doSomethingWith($result)
* } else {
* $error = $operationResponse->getError();
* // handleError($error)
* }
* // Alternatively:
* // start the operation, keep the operation name, and resume later
* $operationResponse = $cloudRedisClient->rescheduleMaintenance($formattedName, $rescheduleType);
* $operationName = $operationResponse->getName();
* // ... do other work
* $newOperationResponse = $cloudRedisClient->resumeOperation($operationName, 'rescheduleMaintenance');
* while (!$newOperationResponse->isDone()) {
* // ... do other work
* $newOperationResponse->reload();
* }
* if ($newOperationResponse->operationSucceeded()) {
* $result = $newOperationResponse->getResult();
* // doSomethingWith($result)
* } else {
* $error = $newOperationResponse->getError();
* // handleError($error)
* }
* } finally {
* $cloudRedisClient->close();
* }
* ```
*
* @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.
* For allowed values, use constants defined on {@see \Google\Cloud\Redis\V1\RescheduleMaintenanceRequest\RescheduleType}
* @param array $optionalArgs {
* Optional.
*
* @type Timestamp $scheduleTime
* Optional. Timestamp when the maintenance shall be rescheduled to if
* reschedule_type=SPECIFIC_TIME, in RFC 3339 format, for
* example `2012-11-15T16:19:00.094Z`.
* @type RetrySettings|array $retrySettings
* Retry settings to use for this call. Can be a
* {@see Google\ApiCore\RetrySettings} object, or an associative array of retry
* settings parameters. See the documentation on
* {@see Google\ApiCore\RetrySettings} for example usage.
* }
*
* @return \Google\ApiCore\OperationResponse
*
* @throws ApiException if the remote call fails
*/
public function rescheduleMaintenance($name, $rescheduleType, array $optionalArgs = [])
{
$request = new RescheduleMaintenanceRequest();
$requestParamHeaders = [];
$request->setName($name);
$request->setRescheduleType($rescheduleType);
$requestParamHeaders['name'] = $name;
if (isset($optionalArgs['scheduleTime'])) {
$request->setScheduleTime($optionalArgs['scheduleTime']);
}

$requestParams = new RequestParamsHeaderDescriptor($requestParamHeaders);
$optionalArgs['headers'] = isset($optionalArgs['headers']) ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) : $requestParams->getHeader();
return $this->startOperationsCall('RescheduleMaintenance', $optionalArgs, $request, $this->getOperationsClient())->wait();
}

/**
* Updates the metadata and configuration of a specific Redis instance.
*
Expand Down
75 changes: 75 additions & 0 deletions Redis/src/V1/GetInstanceAuthStringRequest.php

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading