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: [AiPlatform] add StopNotebookRuntime method #7782

Merged
merged 2 commits into from
Oct 31, 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 AiPlatform/metadata/V1/NotebookService.php
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
<?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 aiplatform_v1_generated_NotebookService_StopNotebookRuntime_sync]
use Google\ApiCore\ApiException;
use Google\ApiCore\OperationResponse;
use Google\Cloud\AIPlatform\V1\Client\NotebookServiceClient;
use Google\Cloud\AIPlatform\V1\StopNotebookRuntimeRequest;
use Google\Cloud\AIPlatform\V1\StopNotebookRuntimeResponse;
use Google\Rpc\Status;

/**
* Stops a NotebookRuntime.
*
* @param string $formattedName The name of the NotebookRuntime resource to be stopped.
* Instead of checking whether the name is in valid NotebookRuntime resource
* name format, directly throw NotFound exception if there is no such
* NotebookRuntime in spanner. Please see
* {@see NotebookServiceClient::notebookRuntimeName()} for help formatting this field.
*/
function stop_notebook_runtime_sample(string $formattedName): void
{
// Create a client.
$notebookServiceClient = new NotebookServiceClient();

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

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

if ($response->operationSucceeded()) {
/** @var StopNotebookRuntimeResponse $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 = NotebookServiceClient::notebookRuntimeName(
'[PROJECT]',
'[LOCATION]',
'[NOTEBOOK_RUNTIME]'
);

stop_notebook_runtime_sample($formattedName);
}
// [END aiplatform_v1_generated_NotebookService_StopNotebookRuntime_sync]
28 changes: 28 additions & 0 deletions AiPlatform/src/V1/Client/NotebookServiceClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
use Google\Cloud\AIPlatform\V1\NotebookRuntime;
use Google\Cloud\AIPlatform\V1\NotebookRuntimeTemplate;
use Google\Cloud\AIPlatform\V1\StartNotebookRuntimeRequest;
use Google\Cloud\AIPlatform\V1\StopNotebookRuntimeRequest;
use Google\Cloud\AIPlatform\V1\UpdateNotebookRuntimeTemplateRequest;
use Google\Cloud\AIPlatform\V1\UpgradeNotebookRuntimeRequest;
use Google\Cloud\Iam\V1\GetIamPolicyRequest;
Expand Down Expand Up @@ -88,6 +89,7 @@
* @method PromiseInterface listNotebookRuntimeTemplatesAsync(ListNotebookRuntimeTemplatesRequest $request, array $optionalArgs = [])
* @method PromiseInterface listNotebookRuntimesAsync(ListNotebookRuntimesRequest $request, array $optionalArgs = [])
* @method PromiseInterface startNotebookRuntimeAsync(StartNotebookRuntimeRequest $request, array $optionalArgs = [])
* @method PromiseInterface stopNotebookRuntimeAsync(StopNotebookRuntimeRequest $request, array $optionalArgs = [])
* @method PromiseInterface updateNotebookRuntimeTemplateAsync(UpdateNotebookRuntimeTemplateRequest $request, array $optionalArgs = [])
* @method PromiseInterface upgradeNotebookRuntimeAsync(UpgradeNotebookRuntimeRequest $request, array $optionalArgs = [])
* @method PromiseInterface getLocationAsync(GetLocationRequest $request, array $optionalArgs = [])
Expand Down Expand Up @@ -824,6 +826,32 @@ public function startNotebookRuntime(
return $this->startApiCall('StartNotebookRuntime', $request, $callOptions)->wait();
}

/**
* Stops a NotebookRuntime.
*
* The async variant is {@see NotebookServiceClient::stopNotebookRuntimeAsync()} .
*
* @example samples/V1/NotebookServiceClient/stop_notebook_runtime.php
*
* @param StopNotebookRuntimeRequest $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 stopNotebookRuntime(StopNotebookRuntimeRequest $request, array $callOptions = []): OperationResponse
{
return $this->startApiCall('StopNotebookRuntime', $request, $callOptions)->wait();
}

/**
* Updates a NotebookRuntimeTemplate.
*
Expand Down
78 changes: 78 additions & 0 deletions AiPlatform/src/V1/StopNotebookRuntimeOperationMetadata.php

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

97 changes: 97 additions & 0 deletions AiPlatform/src/V1/StopNotebookRuntimeRequest.php

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

34 changes: 34 additions & 0 deletions AiPlatform/src/V1/StopNotebookRuntimeResponse.php

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

5 changes: 5 additions & 0 deletions AiPlatform/src/V1/gapic_metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -1795,6 +1795,11 @@
"startNotebookRuntime"
]
},
"StopNotebookRuntime": {
"methods": [
"stopNotebookRuntime"
]
},
"UpdateNotebookRuntimeTemplate": {
"methods": [
"updateNotebookRuntimeTemplate"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,11 @@
"retry_codes_name": "no_retry_codes",
"retry_params_name": "no_retry_params"
},
"StopNotebookRuntime": {
"timeout_millis": 60000,
"retry_codes_name": "no_retry_codes",
"retry_params_name": "no_retry_params"
},
"UpdateNotebookRuntimeTemplate": {
"timeout_millis": 60000,
"retry_codes_name": "no_retry_codes",
Expand Down
Loading
Loading