Skip to content

Commit

Permalink
feat: Promote network_configs field to v2 API (#8007)
Browse files Browse the repository at this point in the history
feat: Make v6e available for GA
feat: Add UNKNOWN to TPU node state, This state will be used to prevent a node from being marked as READY during diagnose after it has failed repair
feat: Make V5Litepod accelerator config available for v2
feat: Make v5p available for GA
docs: A comment for field `network_config` in message `.google.cloud.tpu.v2.Node` is changed
PiperOrigin-RevId: 714369166
Source-Link: googleapis/googleapis@276b372
Source-Link: googleapis/googleapis-gen@5b65431
Copy-Tag: eyJwIjoiVHB1Ly5Pd2xCb3QueWFtbCIsImgiOiI1YjY1NDMxNTI3YWQ3YmFkOTQwZGRlYzBkMGFiOWVlMmVmMTJjZTkyIn0=
  • Loading branch information
gcf-owl-bot[bot] authored Jan 15, 2025
1 parent 2a26e00 commit 7103c1c
Show file tree
Hide file tree
Showing 41 changed files with 4,257 additions and 7 deletions.
Binary file modified Tpu/metadata/V2/CloudTpu.php
Binary file not shown.
85 changes: 85 additions & 0 deletions Tpu/samples/V2/TpuClient/create_queued_resource.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
<?php
/*
* Copyright 2025 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 tpu_v2_generated_Tpu_CreateQueuedResource_sync]
use Google\ApiCore\ApiException;
use Google\ApiCore\OperationResponse;
use Google\Cloud\Tpu\V2\Client\TpuClient;
use Google\Cloud\Tpu\V2\CreateQueuedResourceRequest;
use Google\Cloud\Tpu\V2\QueuedResource;
use Google\Rpc\Status;

/**
* Creates a QueuedResource TPU instance.
*
* @param string $formattedParent The parent resource name. Please see
* {@see TpuClient::locationName()} for help formatting this field.
*/
function create_queued_resource_sample(string $formattedParent): void
{
// Create a client.
$tpuClient = new TpuClient();

// Prepare the request message.
$queuedResource = new QueuedResource();
$request = (new CreateQueuedResourceRequest())
->setParent($formattedParent)
->setQueuedResource($queuedResource);

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

if ($response->operationSucceeded()) {
/** @var QueuedResource $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
{
$formattedParent = TpuClient::locationName('[PROJECT]', '[LOCATION]');

create_queued_resource_sample($formattedParent);
}
// [END tpu_v2_generated_Tpu_CreateQueuedResource_sync]
80 changes: 80 additions & 0 deletions Tpu/samples/V2/TpuClient/delete_queued_resource.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
<?php
/*
* Copyright 2025 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 tpu_v2_generated_Tpu_DeleteQueuedResource_sync]
use Google\ApiCore\ApiException;
use Google\ApiCore\OperationResponse;
use Google\Cloud\Tpu\V2\Client\TpuClient;
use Google\Cloud\Tpu\V2\DeleteQueuedResourceRequest;
use Google\Rpc\Status;

/**
* Deletes a QueuedResource TPU instance.
*
* @param string $formattedName The resource name. Please see
* {@see TpuClient::queuedResourceName()} for help formatting this field.
*/
function delete_queued_resource_sample(string $formattedName): void
{
// Create a client.
$tpuClient = new TpuClient();

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

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

if ($response->operationSucceeded()) {
printf('Operation completed successfully.' . PHP_EOL);
} 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 = TpuClient::queuedResourceName('[PROJECT]', '[LOCATION]', '[QUEUED_RESOURCE]');

delete_queued_resource_sample($formattedName);
}
// [END tpu_v2_generated_Tpu_DeleteQueuedResource_sync]
71 changes: 71 additions & 0 deletions Tpu/samples/V2/TpuClient/get_queued_resource.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
<?php
/*
* Copyright 2025 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 tpu_v2_generated_Tpu_GetQueuedResource_sync]
use Google\ApiCore\ApiException;
use Google\Cloud\Tpu\V2\Client\TpuClient;
use Google\Cloud\Tpu\V2\GetQueuedResourceRequest;
use Google\Cloud\Tpu\V2\QueuedResource;

/**
* Gets details of a queued resource.
*
* @param string $formattedName The resource name. Please see
* {@see TpuClient::queuedResourceName()} for help formatting this field.
*/
function get_queued_resource_sample(string $formattedName): void
{
// Create a client.
$tpuClient = new TpuClient();

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

// Call the API and handle any network failures.
try {
/** @var QueuedResource $response */
$response = $tpuClient->getQueuedResource($request);
printf('Response data: %s' . PHP_EOL, $response->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 = TpuClient::queuedResourceName('[PROJECT]', '[LOCATION]', '[QUEUED_RESOURCE]');

get_queued_resource_sample($formattedName);
}
// [END tpu_v2_generated_Tpu_GetQueuedResource_sync]
76 changes: 76 additions & 0 deletions Tpu/samples/V2/TpuClient/list_queued_resources.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
<?php
/*
* Copyright 2025 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 tpu_v2_generated_Tpu_ListQueuedResources_sync]
use Google\ApiCore\ApiException;
use Google\ApiCore\PagedListResponse;
use Google\Cloud\Tpu\V2\Client\TpuClient;
use Google\Cloud\Tpu\V2\ListQueuedResourcesRequest;
use Google\Cloud\Tpu\V2\QueuedResource;

/**
* Lists queued resources.
*
* @param string $formattedParent The parent resource name. Please see
* {@see TpuClient::locationName()} for help formatting this field.
*/
function list_queued_resources_sample(string $formattedParent): void
{
// Create a client.
$tpuClient = new TpuClient();

// Prepare the request message.
$request = (new ListQueuedResourcesRequest())
->setParent($formattedParent);

// Call the API and handle any network failures.
try {
/** @var PagedListResponse $response */
$response = $tpuClient->listQueuedResources($request);

/** @var QueuedResource $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());
}
}

/**
* 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
{
$formattedParent = TpuClient::locationName('[PROJECT]', '[LOCATION]');

list_queued_resources_sample($formattedParent);
}
// [END tpu_v2_generated_Tpu_ListQueuedResources_sync]
83 changes: 83 additions & 0 deletions Tpu/samples/V2/TpuClient/reset_queued_resource.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
<?php
/*
* Copyright 2025 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 tpu_v2_generated_Tpu_ResetQueuedResource_sync]
use Google\ApiCore\ApiException;
use Google\ApiCore\OperationResponse;
use Google\Cloud\Tpu\V2\Client\TpuClient;
use Google\Cloud\Tpu\V2\QueuedResource;
use Google\Cloud\Tpu\V2\ResetQueuedResourceRequest;
use Google\Rpc\Status;

/**
* Resets a QueuedResource TPU instance
*
* @param string $formattedName The name of the queued resource. Please see
* {@see TpuClient::queuedResourceName()} for help formatting this field.
*/
function reset_queued_resource_sample(string $formattedName): void
{
// Create a client.
$tpuClient = new TpuClient();

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

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

if ($response->operationSucceeded()) {
/** @var QueuedResource $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 = TpuClient::queuedResourceName('[PROJECT]', '[LOCATION]', '[QUEUED_RESOURCE]');

reset_queued_resource_sample($formattedName);
}
// [END tpu_v2_generated_Tpu_ResetQueuedResource_sync]
Loading

0 comments on commit 7103c1c

Please sign in to comment.