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: [Redis] [Cloud Memorystore for Redis] Add CMEK key field #6187

Merged
merged 2 commits into from
May 6, 2023
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.
6 changes: 4 additions & 2 deletions Redis/samples/V1/CloudRedisClient/create_instance.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*/
Expand Down
53 changes: 53 additions & 0 deletions Redis/samples/V1/CloudRedisClient/get_location.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
<?php
/*
* Copyright 2023 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

/*
* GENERATED CODE WARNING
* This file was automatically generated - do not edit!
*/

require_once __DIR__ . '/../../../vendor/autoload.php';

// [START redis_v1_generated_CloudRedis_GetLocation_sync]
use Google\ApiCore\ApiException;
use Google\Cloud\Location\Location;
use Google\Cloud\Redis\V1\CloudRedisClient;

/**
* Gets information about a location.
*
* This sample has been automatically generated and should be regarded as a code
* template only. It will require modifications to work:
* - It may require correct/in-range values for request initialization.
* - It may require specifying regional endpoints when creating the service client,
* please see the apiEndpoint client configuration option for more details.
*/
function get_location_sample(): void
{
// Create a client.
$cloudRedisClient = new CloudRedisClient();

// Call the API and handle any network failures.
try {
/** @var Location $response */
$response = $cloudRedisClient->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]
58 changes: 58 additions & 0 deletions Redis/samples/V1/CloudRedisClient/list_locations.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
<?php
/*
* Copyright 2023 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

/*
* GENERATED CODE WARNING
* This file was automatically generated - do not edit!
*/

require_once __DIR__ . '/../../../vendor/autoload.php';

// [START redis_v1_generated_CloudRedis_ListLocations_sync]
use Google\ApiCore\ApiException;
use Google\ApiCore\PagedListResponse;
use Google\Cloud\Location\Location;
use Google\Cloud\Redis\V1\CloudRedisClient;

/**
* Lists information about the supported locations for this service.
*
* This sample has been automatically generated and should be regarded as a code
* template only. It will require modifications to work:
* - It may require correct/in-range values for request initialization.
* - It may require specifying regional endpoints when creating the service client,
* please see the apiEndpoint client configuration option for more details.
*/
function list_locations_sample(): void
{
// Create a client.
$cloudRedisClient = new CloudRedisClient();

// Call the API and handle any network failures.
try {
/** @var PagedListResponse $response */
$response = $cloudRedisClient->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]
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down
6 changes: 4 additions & 2 deletions Redis/samples/V1/CloudRedisClient/update_instance.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*/
Expand Down
3 changes: 2 additions & 1 deletion Redis/src/V1/CreateInstanceRequest.php

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

3 changes: 2 additions & 1 deletion Redis/src/V1/DeleteInstanceRequest.php

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

127 changes: 126 additions & 1 deletion Redis/src/V1/Gapic/CloudRedisGapicClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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');
}
}
3 changes: 2 additions & 1 deletion Redis/src/V1/GetInstanceAuthStringRequest.php

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

Loading