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: [Filestore] Added REGIONAL tier support in the v1 API #6790

Merged
merged 2 commits into from
Nov 17, 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 Filestore/metadata/V1/CloudFilestoreService.php
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
<?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 file_v1_generated_CloudFilestoreManager_RevertInstance_sync]
use Google\ApiCore\ApiException;
use Google\ApiCore\OperationResponse;
use Google\Cloud\Filestore\V1\CloudFilestoreManagerClient;
use Google\Cloud\Filestore\V1\Instance;
use Google\Rpc\Status;

/**
* Revert an existing instance's file system to a specified snapshot.
*
* @param string $formattedName Required.
* `projects/{project_id}/locations/{location_id}/instances/{instance_id}`.
* The resource name of the instance, in the format
* Please see {@see CloudFilestoreManagerClient::instanceName()} for help formatting this field.
* @param string $targetSnapshotId The snapshot resource ID, in the format 'my-snapshot', where the
* specified ID is the {snapshot_id} of the fully qualified name like
* `projects/{project_id}/locations/{location_id}/instances/{instance_id}/snapshots/{snapshot_id}`
*/
function revert_instance_sample(string $formattedName, string $targetSnapshotId): void
{
// Create a client.
$cloudFilestoreManagerClient = new CloudFilestoreManagerClient();

// Call the API and handle any network failures.
try {
/** @var OperationResponse $response */
$response = $cloudFilestoreManagerClient->revertInstance($formattedName, $targetSnapshotId);
$response->pollUntilComplete();

if ($response->operationSucceeded()) {
/** @var Instance $result */
$result = $response->getResult();
printf('Operation successful with response data: %s' . PHP_EOL, $result->serializeToJsonString());
} else {
/** @var Status $error */
$error = $response->getError();
printf('Operation failed with error data: %s' . PHP_EOL, $error->serializeToJsonString());
}
} catch (ApiException $ex) {
printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage());
}
}

/**
* Helper to execute the sample.
*
* 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 callSample(): void
{
$formattedName = CloudFilestoreManagerClient::instanceName('[PROJECT]', '[LOCATION]', '[INSTANCE]');
$targetSnapshotId = '[TARGET_SNAPSHOT_ID]';

revert_instance_sample($formattedName, $targetSnapshotId);
}
// [END file_v1_generated_CloudFilestoreManager_RevertInstance_sync]
34 changes: 34 additions & 0 deletions Filestore/src/V1/Backup.php

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

8 changes: 8 additions & 0 deletions Filestore/src/V1/Backup/State.php

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

26 changes: 26 additions & 0 deletions Filestore/src/V1/Client/CloudFilestoreManagerClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
use Google\Cloud\Filestore\V1\ListInstancesRequest;
use Google\Cloud\Filestore\V1\ListSnapshotsRequest;
use Google\Cloud\Filestore\V1\RestoreInstanceRequest;
use Google\Cloud\Filestore\V1\RevertInstanceRequest;
use Google\Cloud\Filestore\V1\Snapshot;
use Google\Cloud\Filestore\V1\UpdateBackupRequest;
use Google\Cloud\Filestore\V1\UpdateInstanceRequest;
Expand Down Expand Up @@ -105,6 +106,7 @@
* @method PromiseInterface listInstancesAsync(ListInstancesRequest $request, array $optionalArgs = [])
* @method PromiseInterface listSnapshotsAsync(ListSnapshotsRequest $request, array $optionalArgs = [])
* @method PromiseInterface restoreInstanceAsync(RestoreInstanceRequest $request, array $optionalArgs = [])
* @method PromiseInterface revertInstanceAsync(RevertInstanceRequest $request, array $optionalArgs = [])
* @method PromiseInterface updateBackupAsync(UpdateBackupRequest $request, array $optionalArgs = [])
* @method PromiseInterface updateInstanceAsync(UpdateInstanceRequest $request, array $optionalArgs = [])
* @method PromiseInterface updateSnapshotAsync(UpdateSnapshotRequest $request, array $optionalArgs = [])
Expand Down Expand Up @@ -679,6 +681,30 @@ public function restoreInstance(RestoreInstanceRequest $request, array $callOpti
return $this->startApiCall('RestoreInstance', $request, $callOptions)->wait();
}

/**
* Revert an existing instance's file system to a specified snapshot.
*
* The async variant is {@see CloudFilestoreManagerClient::revertInstanceAsync()} .
*
* @param RevertInstanceRequest $request A request to house fields associated with the call.
* @param array $callOptions {
* Optional.
*
* @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 OperationResponse
*
* @throws ApiException Thrown if the API call fails.
*/
public function revertInstance(RevertInstanceRequest $request, array $callOptions = []): OperationResponse
{
return $this->startApiCall('RevertInstance', $request, $callOptions)->wait();
}

/**
* Updates the settings of a specific backup.
*
Expand Down
20 changes: 16 additions & 4 deletions Filestore/src/V1/FileShareConfig.php

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

84 changes: 84 additions & 0 deletions Filestore/src/V1/Gapic/CloudFilestoreManagerGapicClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@
use Google\Cloud\Filestore\V1\ListSnapshotsRequest;
use Google\Cloud\Filestore\V1\ListSnapshotsResponse;
use Google\Cloud\Filestore\V1\RestoreInstanceRequest;
use Google\Cloud\Filestore\V1\RevertInstanceRequest;
use Google\Cloud\Filestore\V1\Snapshot;
use Google\Cloud\Filestore\V1\UpdateBackupRequest;
use Google\Cloud\Filestore\V1\UpdateInstanceRequest;
Expand Down Expand Up @@ -1482,6 +1483,89 @@ public function restoreInstance($name, $fileShare, array $optionalArgs = [])
)->wait();
}

/**
* Revert an existing instance's file system to a specified snapshot.
*
* Sample code:
* ```
* $cloudFilestoreManagerClient = new CloudFilestoreManagerClient();
* try {
* $formattedName = $cloudFilestoreManagerClient->instanceName('[PROJECT]', '[LOCATION]', '[INSTANCE]');
* $targetSnapshotId = 'target_snapshot_id';
* $operationResponse = $cloudFilestoreManagerClient->revertInstance($formattedName, $targetSnapshotId);
* $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 = $cloudFilestoreManagerClient->revertInstance($formattedName, $targetSnapshotId);
* $operationName = $operationResponse->getName();
* // ... do other work
* $newOperationResponse = $cloudFilestoreManagerClient->resumeOperation($operationName, 'revertInstance');
* while (!$newOperationResponse->isDone()) {
* // ... do other work
* $newOperationResponse->reload();
* }
* if ($newOperationResponse->operationSucceeded()) {
* $result = $newOperationResponse->getResult();
* // doSomethingWith($result)
* } else {
* $error = $newOperationResponse->getError();
* // handleError($error)
* }
* } finally {
* $cloudFilestoreManagerClient->close();
* }
* ```
*
* @param string $name Required.
* `projects/{project_id}/locations/{location_id}/instances/{instance_id}`.
* The resource name of the instance, in the format
* @param string $targetSnapshotId Required. The snapshot resource ID, in the format 'my-snapshot', where the
* specified ID is the {snapshot_id} of the fully qualified name like
* `projects/{project_id}/locations/{location_id}/instances/{instance_id}/snapshots/{snapshot_id}`
* @param array $optionalArgs {
* Optional.
*
* @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\OperationResponse
*
* @throws ApiException if the remote call fails
*/
public function revertInstance(
$name,
$targetSnapshotId,
array $optionalArgs = []
) {
$request = new RevertInstanceRequest();
$requestParamHeaders = [];
$request->setName($name);
$request->setTargetSnapshotId($targetSnapshotId);
$requestParamHeaders['name'] = $name;
$requestParams = new RequestParamsHeaderDescriptor(
$requestParamHeaders
);
$optionalArgs['headers'] = isset($optionalArgs['headers'])
? array_merge($requestParams->getHeader(), $optionalArgs['headers'])
: $requestParams->getHeader();
return $this->startOperationsCall(
'RevertInstance',
$optionalArgs,
$request,
$this->getOperationsClient()
)->wait();
}

/**
* Updates the settings of a specific backup.
*
Expand Down
Loading