Skip to content

Commit

Permalink
[CHANGE ME] Re-generated Redis to pick up changes in the API or clien…
Browse files Browse the repository at this point in the history
…t library generator.
  • Loading branch information
yoshi-automation committed Oct 8, 2019
1 parent 9986719 commit 319e21e
Show file tree
Hide file tree
Showing 11 changed files with 737 additions and 775 deletions.
321 changes: 151 additions & 170 deletions Redis/src/V1/Gapic/CloudRedisGapicClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -77,40 +77,21 @@
* $cloudRedisClient = new Google\Cloud\Redis\V1\CloudRedisClient();
* try {
* $formattedParent = $cloudRedisClient->locationName('[PROJECT]', '[LOCATION]');
* $instanceId = 'test_instance';
* $tier = Google\Cloud\Redis\V1\Instance\Tier::BASIC;
* $memorySizeGb = 1;
* $instance = new Google\Cloud\Redis\V1\Instance();
* $instance->setTier($tier);
* $instance->setMemorySizeGb($memorySizeGb);
* $operationResponse = $cloudRedisClient->createInstance($formattedParent, $instanceId, $instance);
* $operationResponse->pollUntilComplete();
* if ($operationResponse->operationSucceeded()) {
* $result = $operationResponse->getResult();
* // doSomethingWith($result)
* } else {
* $error = $operationResponse->getError();
* // handleError($error)
* // Iterate over pages of elements
* $pagedResponse = $cloudRedisClient->listInstances($formattedParent);
* foreach ($pagedResponse->iteratePages() as $page) {
* foreach ($page as $element) {
* // doSomethingWith($element);
* }
* }
*
*
* // Alternatively:
*
* // start the operation, keep the operation name, and resume later
* $operationResponse = $cloudRedisClient->createInstance($formattedParent, $instanceId, $instance);
* $operationName = $operationResponse->getName();
* // ... do other work
* $newOperationResponse = $cloudRedisClient->resumeOperation($operationName, 'createInstance');
* while (!$newOperationResponse->isDone()) {
* // ... do other work
* $newOperationResponse->reload();
* }
* if ($newOperationResponse->operationSucceeded()) {
* $result = $newOperationResponse->getResult();
* // doSomethingWith($result)
* } else {
* $error = $newOperationResponse->getError();
* // handleError($error)
* // Iterate through all elements
* $pagedResponse = $cloudRedisClient->listInstances($formattedParent);
* foreach ($pagedResponse->iterateAllElements() as $element) {
* // doSomethingWith($element);
* }
* } finally {
* $cloudRedisClient->close();
Expand Down Expand Up @@ -386,6 +367,147 @@ public function __construct(array $options = [])
$this->operationsClient = $this->createOperationsClient($clientOptions);
}

/**
* Lists all Redis instances owned by a project in either the specified
* location (region) or all locations.
*
* The location should have the following format:
* * `projects/{project_id}/locations/{location_id}`
*
* If `location_id` is specified as `-` (wildcard), then all regions
* available to the project are queried, and the results are aggregated.
*
* Sample code:
* ```
* $cloudRedisClient = new Google\Cloud\Redis\V1\CloudRedisClient();
* try {
* $formattedParent = $cloudRedisClient->locationName('[PROJECT]', '[LOCATION]');
* // Iterate over pages of elements
* $pagedResponse = $cloudRedisClient->listInstances($formattedParent);
* foreach ($pagedResponse->iteratePages() as $page) {
* foreach ($page as $element) {
* // doSomethingWith($element);
* }
* }
*
*
* // Alternatively:
*
* // Iterate through all elements
* $pagedResponse = $cloudRedisClient->listInstances($formattedParent);
* foreach ($pagedResponse->iterateAllElements() as $element) {
* // doSomethingWith($element);
* }
* } finally {
* $cloudRedisClient->close();
* }
* ```
*
* @param string $parent Required. The resource name of the instance location using the form:
* `projects/{project_id}/locations/{location_id}`
* where `location_id` refers to a GCP region.
* @param array $optionalArgs {
* Optional.
*
* @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 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\PagedListResponse
*
* @throws ApiException if the remote call fails
* @experimental
*/
public function listInstances($parent, array $optionalArgs = [])
{
$request = new ListInstancesRequest();
$request->setParent($parent);
if (isset($optionalArgs['pageSize'])) {
$request->setPageSize($optionalArgs['pageSize']);
}
if (isset($optionalArgs['pageToken'])) {
$request->setPageToken($optionalArgs['pageToken']);
}

$requestParams = new RequestParamsHeaderDescriptor([
'parent' => $request->getParent(),
]);
$optionalArgs['headers'] = isset($optionalArgs['headers'])
? array_merge($requestParams->getHeader(), $optionalArgs['headers'])
: $requestParams->getHeader();

return $this->getPagedListResponse(
'ListInstances',
$optionalArgs,
ListInstancesResponse::class,
$request
);
}

/**
* Gets the details of a specific Redis instance.
*
* Sample code:
* ```
* $cloudRedisClient = new Google\Cloud\Redis\V1\CloudRedisClient();
* try {
* $formattedName = $cloudRedisClient->instanceName('[PROJECT]', '[LOCATION]', '[INSTANCE]');
* $response = $cloudRedisClient->getInstance($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\Instance
*
* @throws ApiException if the remote call fails
* @experimental
*/
public function getInstance($name, array $optionalArgs = [])
{
$request = new GetInstanceRequest();
$request->setName($name);

$requestParams = new RequestParamsHeaderDescriptor([
'name' => $request->getName(),
]);
$optionalArgs['headers'] = isset($optionalArgs['headers'])
? array_merge($requestParams->getHeader(), $optionalArgs['headers'])
: $requestParams->getHeader();

return $this->startCall(
'GetInstance',
Instance::class,
$optionalArgs,
$request
)->wait();
}

/**
* Creates a Redis instance based on the specified tier and memory size.
*
Expand Down Expand Up @@ -593,147 +715,6 @@ public function updateInstance($updateMask, $instance, array $optionalArgs = [])
)->wait();
}

/**
* Lists all Redis instances owned by a project in either the specified
* location (region) or all locations.
*
* The location should have the following format:
* * `projects/{project_id}/locations/{location_id}`
*
* If `location_id` is specified as `-` (wildcard), then all regions
* available to the project are queried, and the results are aggregated.
*
* Sample code:
* ```
* $cloudRedisClient = new Google\Cloud\Redis\V1\CloudRedisClient();
* try {
* $formattedParent = $cloudRedisClient->locationName('[PROJECT]', '[LOCATION]');
* // Iterate over pages of elements
* $pagedResponse = $cloudRedisClient->listInstances($formattedParent);
* foreach ($pagedResponse->iteratePages() as $page) {
* foreach ($page as $element) {
* // doSomethingWith($element);
* }
* }
*
*
* // Alternatively:
*
* // Iterate through all elements
* $pagedResponse = $cloudRedisClient->listInstances($formattedParent);
* foreach ($pagedResponse->iterateAllElements() as $element) {
* // doSomethingWith($element);
* }
* } finally {
* $cloudRedisClient->close();
* }
* ```
*
* @param string $parent Required. The resource name of the instance location using the form:
* `projects/{project_id}/locations/{location_id}`
* where `location_id` refers to a GCP region.
* @param array $optionalArgs {
* Optional.
*
* @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 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\PagedListResponse
*
* @throws ApiException if the remote call fails
* @experimental
*/
public function listInstances($parent, array $optionalArgs = [])
{
$request = new ListInstancesRequest();
$request->setParent($parent);
if (isset($optionalArgs['pageSize'])) {
$request->setPageSize($optionalArgs['pageSize']);
}
if (isset($optionalArgs['pageToken'])) {
$request->setPageToken($optionalArgs['pageToken']);
}

$requestParams = new RequestParamsHeaderDescriptor([
'parent' => $request->getParent(),
]);
$optionalArgs['headers'] = isset($optionalArgs['headers'])
? array_merge($requestParams->getHeader(), $optionalArgs['headers'])
: $requestParams->getHeader();

return $this->getPagedListResponse(
'ListInstances',
$optionalArgs,
ListInstancesResponse::class,
$request
);
}

/**
* Gets the details of a specific Redis instance.
*
* Sample code:
* ```
* $cloudRedisClient = new Google\Cloud\Redis\V1\CloudRedisClient();
* try {
* $formattedName = $cloudRedisClient->instanceName('[PROJECT]', '[LOCATION]', '[INSTANCE]');
* $response = $cloudRedisClient->getInstance($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\Instance
*
* @throws ApiException if the remote call fails
* @experimental
*/
public function getInstance($name, array $optionalArgs = [])
{
$request = new GetInstanceRequest();
$request->setName($name);

$requestParams = new RequestParamsHeaderDescriptor([
'name' => $request->getName(),
]);
$optionalArgs['headers'] = isset($optionalArgs['headers'])
? array_merge($requestParams->getHeader(), $optionalArgs['headers'])
: $requestParams->getHeader();

return $this->startCall(
'GetInstance',
Instance::class,
$optionalArgs,
$request
)->wait();
}

/**
* Import a Redis RDB snapshot file from Cloud Storage into a Redis instance.
*
Expand Down
12 changes: 6 additions & 6 deletions Redis/src/V1/resources/cloud_redis_client_config.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,24 +20,24 @@
}
},
"methods": {
"CreateInstance": {
"ListInstances": {
"timeout_millis": 60000,
"retry_codes_name": "non_idempotent",
"retry_params_name": "default"
},
"UpdateInstance": {
"GetInstance": {
"timeout_millis": 60000,
"retry_codes_name": "non_idempotent",
"retry_params_name": "default"
},
"ListInstances": {
"CreateInstance": {
"timeout_millis": 60000,
"retry_codes_name": "idempotent",
"retry_codes_name": "non_idempotent",
"retry_params_name": "default"
},
"GetInstance": {
"UpdateInstance": {
"timeout_millis": 60000,
"retry_codes_name": "idempotent",
"retry_codes_name": "non_idempotent",
"retry_params_name": "default"
},
"ImportInstance": {
Expand Down
Loading

0 comments on commit 319e21e

Please sign in to comment.