Skip to content
Open
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
2 changes: 1 addition & 1 deletion Compute/metadata/V1/Compute.php

Large diffs are not rendered by default.

77 changes: 77 additions & 0 deletions Compute/samples/V1/BackendBucketsClient/aggregated_list.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
<?php
/*
* Copyright 2026 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 compute_v1_generated_BackendBuckets_AggregatedList_sync]
use Google\ApiCore\ApiException;
use Google\ApiCore\PagedListResponse;
use Google\Cloud\Compute\V1\AggregatedListBackendBucketsRequest;
use Google\Cloud\Compute\V1\Client\BackendBucketsClient;

/**
* Retrieves the list of all BackendBucket resources, regional and global,
* available to the specified project.
*
* To prevent failure, it is recommended that you set the
* `returnPartialSuccess` parameter to `true`.
*
* @param string $project Name of the project scoping this request.
*/
function aggregated_list_sample(string $project): void
{
// Create a client.
$backendBucketsClient = new BackendBucketsClient();

// Prepare the request message.
$request = (new AggregatedListBackendBucketsRequest())
->setProject($project);

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

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
{
$project = '[PROJECT]';

aggregated_list_sample($project);
}
// [END compute_v1_generated_BackendBuckets_AggregatedList_sync]
73 changes: 73 additions & 0 deletions Compute/samples/V1/BackendBucketsClient/list_usable.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
<?php
/*
* Copyright 2026 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 compute_v1_generated_BackendBuckets_ListUsable_sync]
use Google\ApiCore\ApiException;
use Google\ApiCore\PagedListResponse;
use Google\Cloud\Compute\V1\Client\BackendBucketsClient;
use Google\Cloud\Compute\V1\ListUsableBackendBucketsRequest;

/**
* Retrieves a list of all usable backend buckets in the specified project.
*
* @param string $project Project ID for this request.
*/
function list_usable_sample(string $project): void
{
// Create a client.
$backendBucketsClient = new BackendBucketsClient();

// Prepare the request message.
$request = (new ListUsableBackendBucketsRequest())
->setProject($project);

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

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
{
$project = '[PROJECT]';

list_usable_sample($project);
}
// [END compute_v1_generated_BackendBuckets_ListUsable_sync]
89 changes: 89 additions & 0 deletions Compute/samples/V1/DisksClient/update_kms_key.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
<?php
/*
* Copyright 2026 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 compute_v1_generated_Disks_UpdateKmsKey_sync]
use Google\ApiCore\ApiException;
use Google\ApiCore\OperationResponse;
use Google\Cloud\Compute\V1\Client\DisksClient;
use Google\Cloud\Compute\V1\DiskUpdateKmsKeyRequest;
use Google\Cloud\Compute\V1\UpdateKmsKeyDiskRequest;
use Google\Rpc\Status;

/**
* Rotates the customer-managed
* encryption key to the latest version for the specified persistent disk.
*
* @param string $disk Name of the Disk resource, should conform to RFC1035.
* @param string $project Project ID for this request.
* @param string $zone The name of the zone for this request.
*/
function update_kms_key_sample(string $disk, string $project, string $zone): void
{
// Create a client.
$disksClient = new DisksClient();

// Prepare the request message.
$diskUpdateKmsKeyRequestResource = new DiskUpdateKmsKeyRequest();
$request = (new UpdateKmsKeyDiskRequest())
->setDisk($disk)
->setDiskUpdateKmsKeyRequestResource($diskUpdateKmsKeyRequestResource)
->setProject($project)
->setZone($zone);

// Call the API and handle any network failures.
try {
/** @var OperationResponse $response */
$response = $disksClient->updateKmsKey($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
{
$disk = '[DISK]';
$project = '[PROJECT]';
$zone = '[ZONE]';

update_kms_key_sample($disk, $project, $zone);
}
// [END compute_v1_generated_Disks_UpdateKmsKey_sync]
85 changes: 85 additions & 0 deletions Compute/samples/V1/InstantSnapshotGroupsClient/delete.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
<?php
/*
* Copyright 2026 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 compute_v1_generated_InstantSnapshotGroups_Delete_sync]
use Google\ApiCore\ApiException;
use Google\ApiCore\OperationResponse;
use Google\Cloud\Compute\V1\Client\InstantSnapshotGroupsClient;
use Google\Cloud\Compute\V1\DeleteInstantSnapshotGroupRequest;
use Google\Rpc\Status;

/**
* deletes a Zonal InstantSnapshotGroup resource
*
* @param string $instantSnapshotGroup Name of the InstantSnapshot resource to delete.
* @param string $project Project ID for this request.
* @param string $zone The name of the zone for this request.
*/
function delete_sample(string $instantSnapshotGroup, string $project, string $zone): void
{
// Create a client.
$instantSnapshotGroupsClient = new InstantSnapshotGroupsClient();

// Prepare the request message.
$request = (new DeleteInstantSnapshotGroupRequest())
->setInstantSnapshotGroup($instantSnapshotGroup)
->setProject($project)
->setZone($zone);

// Call the API and handle any network failures.
try {
/** @var OperationResponse $response */
$response = $instantSnapshotGroupsClient->delete($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
{
$instantSnapshotGroup = '[INSTANT_SNAPSHOT_GROUP]';
$project = '[PROJECT]';
$zone = '[ZONE]';

delete_sample($instantSnapshotGroup, $project, $zone);
}
// [END compute_v1_generated_InstantSnapshotGroups_Delete_sync]
Loading
Loading