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(parallelstore/v1beta): [Parallelstore] add ImportData and ExportData RPCs #7267

Merged
merged 2 commits into from
Apr 30, 2024
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 Parallelstore/metadata/V1Beta/Parallelstore.php
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
<?php
/*
* Copyright 2024 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 parallelstore_v1beta_generated_Parallelstore_ExportData_sync]
use Google\ApiCore\ApiException;
use Google\ApiCore\OperationResponse;
use Google\Cloud\Parallelstore\V1beta\Client\ParallelstoreClient;
use Google\Cloud\Parallelstore\V1beta\ExportDataRequest;
use Google\Cloud\Parallelstore\V1beta\ExportDataResponse;
use Google\Rpc\Status;

/**
* ExportData copies data from Parallelstore to Cloud Storage
*
* @param string $formattedName Name of the resource. Please see
* {@see ParallelstoreClient::instanceName()} for help formatting this field.
*/
function export_data_sample(string $formattedName): void
{
// Create a client.
$parallelstoreClient = new ParallelstoreClient();

// Prepare the request message.
$request = (new ExportDataRequest())
->setName($formattedName);

// Call the API and handle any network failures.
try {
/** @var OperationResponse $response */
$response = $parallelstoreClient->exportData($request);
$response->pollUntilComplete();

if ($response->operationSucceeded()) {
/** @var ExportDataResponse $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 = ParallelstoreClient::instanceName('[PROJECT]', '[LOCATION]', '[INSTANCE]');

export_data_sample($formattedName);
}
// [END parallelstore_v1beta_generated_Parallelstore_ExportData_sync]
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
<?php
/*
* Copyright 2024 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 parallelstore_v1beta_generated_Parallelstore_ImportData_sync]
use Google\ApiCore\ApiException;
use Google\ApiCore\OperationResponse;
use Google\Cloud\Parallelstore\V1beta\Client\ParallelstoreClient;
use Google\Cloud\Parallelstore\V1beta\ImportDataRequest;
use Google\Cloud\Parallelstore\V1beta\ImportDataResponse;
use Google\Rpc\Status;

/**
* ImportData copies data from Cloud Storage to Parallelstore.
*
* @param string $formattedName Name of the resource. Please see
* {@see ParallelstoreClient::instanceName()} for help formatting this field.
*/
function import_data_sample(string $formattedName): void
{
// Create a client.
$parallelstoreClient = new ParallelstoreClient();

// Prepare the request message.
$request = (new ImportDataRequest())
->setName($formattedName);

// Call the API and handle any network failures.
try {
/** @var OperationResponse $response */
$response = $parallelstoreClient->importData($request);
$response->pollUntilComplete();

if ($response->operationSucceeded()) {
/** @var ImportDataResponse $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 = ParallelstoreClient::instanceName('[PROJECT]', '[LOCATION]', '[INSTANCE]');

import_data_sample($formattedName);
}
// [END parallelstore_v1beta_generated_Parallelstore_ImportData_sync]
60 changes: 60 additions & 0 deletions Parallelstore/src/V1beta/Client/ParallelstoreClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,9 @@
use Google\Cloud\Location\Location;
use Google\Cloud\Parallelstore\V1beta\CreateInstanceRequest;
use Google\Cloud\Parallelstore\V1beta\DeleteInstanceRequest;
use Google\Cloud\Parallelstore\V1beta\ExportDataRequest;
use Google\Cloud\Parallelstore\V1beta\GetInstanceRequest;
use Google\Cloud\Parallelstore\V1beta\ImportDataRequest;
use Google\Cloud\Parallelstore\V1beta\Instance;
use Google\Cloud\Parallelstore\V1beta\ListInstancesRequest;
use Google\Cloud\Parallelstore\V1beta\UpdateInstanceRequest;
Expand Down Expand Up @@ -78,7 +80,9 @@
*
* @method PromiseInterface createInstanceAsync(CreateInstanceRequest $request, array $optionalArgs = [])
* @method PromiseInterface deleteInstanceAsync(DeleteInstanceRequest $request, array $optionalArgs = [])
* @method PromiseInterface exportDataAsync(ExportDataRequest $request, array $optionalArgs = [])
* @method PromiseInterface getInstanceAsync(GetInstanceRequest $request, array $optionalArgs = [])
* @method PromiseInterface importDataAsync(ImportDataRequest $request, array $optionalArgs = [])
* @method PromiseInterface listInstancesAsync(ListInstancesRequest $request, array $optionalArgs = [])
* @method PromiseInterface updateInstanceAsync(UpdateInstanceRequest $request, array $optionalArgs = [])
* @method PromiseInterface getLocationAsync(GetLocationRequest $request, array $optionalArgs = [])
Expand Down Expand Up @@ -406,6 +410,34 @@ public function deleteInstance(DeleteInstanceRequest $request, array $callOption
return $this->startApiCall('DeleteInstance', $request, $callOptions)->wait();
}

/**
* ExportData copies data from Parallelstore to Cloud Storage
*
* The async variant is {@see ParallelstoreClient::exportDataAsync()} .
*
* @example samples/V1beta/ParallelstoreClient/export_data.php
*
* @param ExportDataRequest $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.
*
* @experimental
*/
public function exportData(ExportDataRequest $request, array $callOptions = []): OperationResponse
{
return $this->startApiCall('ExportData', $request, $callOptions)->wait();
}

/**
* Gets details of a single Instance.
*
Expand Down Expand Up @@ -434,6 +466,34 @@ public function getInstance(GetInstanceRequest $request, array $callOptions = []
return $this->startApiCall('GetInstance', $request, $callOptions)->wait();
}

/**
* ImportData copies data from Cloud Storage to Parallelstore.
*
* The async variant is {@see ParallelstoreClient::importDataAsync()} .
*
* @example samples/V1beta/ParallelstoreClient/import_data.php
*
* @param ImportDataRequest $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.
*
* @experimental
*/
public function importData(ImportDataRequest $request, array $callOptions = []): OperationResponse
{
return $this->startApiCall('ImportData', $request, $callOptions)->wait();
}

/**
* Lists Instances in a given project and location.
*
Expand Down
77 changes: 77 additions & 0 deletions Parallelstore/src/V1beta/ExportDataMetadata.php

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

Loading
Loading