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

Large diffs are not rendered by default.

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_GlobalVmExtensionPolicies_AggregatedList_sync]
use Google\ApiCore\ApiException;
use Google\ApiCore\PagedListResponse;
use Google\Cloud\Compute\V1\AggregatedListGlobalVmExtensionPoliciesRequest;
use Google\Cloud\Compute\V1\Client\GlobalVmExtensionPoliciesClient;

/**
* Retrieves the list of all VM Extension Policy resources
* available to the specified project.
*
* To prevent failure, it's 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.
$globalVmExtensionPoliciesClient = new GlobalVmExtensionPoliciesClient();

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

// Call the API and handle any network failures.
try {
/** @var PagedListResponse $response */
$response = $globalVmExtensionPoliciesClient->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_GlobalVmExtensionPolicies_AggregatedList_sync]
92 changes: 92 additions & 0 deletions Compute/samples/V1/GlobalVmExtensionPoliciesClient/delete.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
<?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_GlobalVmExtensionPolicies_Delete_sync]
use Google\ApiCore\ApiException;
use Google\ApiCore\OperationResponse;
use Google\Cloud\Compute\V1\Client\GlobalVmExtensionPoliciesClient;
use Google\Cloud\Compute\V1\DeleteGlobalVmExtensionPolicyRequest;
use Google\Cloud\Compute\V1\GlobalVmExtensionPolicyRolloutOperationRolloutInput;
use Google\Rpc\Status;

/**
* Purge scoped resources (zonal policies) from a global VM extension
* policy, and then delete the global VM extension policy. Purge of the scoped
* resources is a pre-condition of the global VM extension policy deletion.
* The deletion of the global VM extension policy happens after the purge
* rollout is done, so it's not a part of the LRO. It's an automatic process
* that triggers in the backend.
*
* @param string $globalVmExtensionPolicy Name of the global VM extension policy to purge scoped resources for.
* @param string $project Project ID for this request.
*/
function delete_sample(string $globalVmExtensionPolicy, string $project): void
{
// Create a client.
$globalVmExtensionPoliciesClient = new GlobalVmExtensionPoliciesClient();

// Prepare the request message.
$globalVmExtensionPolicyRolloutOperationRolloutInputResource = new GlobalVmExtensionPolicyRolloutOperationRolloutInput();
$request = (new DeleteGlobalVmExtensionPolicyRequest())
->setGlobalVmExtensionPolicy($globalVmExtensionPolicy)
->setGlobalVmExtensionPolicyRolloutOperationRolloutInputResource(
$globalVmExtensionPolicyRolloutOperationRolloutInputResource
)
->setProject($project);

// Call the API and handle any network failures.
try {
/** @var OperationResponse $response */
$response = $globalVmExtensionPoliciesClient->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
{
$globalVmExtensionPolicy = '[GLOBAL_VM_EXTENSION_POLICY]';
$project = '[PROJECT]';

delete_sample($globalVmExtensionPolicy, $project);
}
// [END compute_v1_generated_GlobalVmExtensionPolicies_Delete_sync]
73 changes: 73 additions & 0 deletions Compute/samples/V1/GlobalVmExtensionPoliciesClient/get.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_GlobalVmExtensionPolicies_Get_sync]
use Google\ApiCore\ApiException;
use Google\Cloud\Compute\V1\Client\GlobalVmExtensionPoliciesClient;
use Google\Cloud\Compute\V1\GetGlobalVmExtensionPolicyRequest;
use Google\Cloud\Compute\V1\GlobalVmExtensionPolicy;

/**
* Gets details of a global VM extension policy.
*
* @param string $globalVmExtensionPolicy Name of the GlobalVmExtensionPolicy resource to return.
* @param string $project Project ID for this request.
*/
function get_sample(string $globalVmExtensionPolicy, string $project): void
{
// Create a client.
$globalVmExtensionPoliciesClient = new GlobalVmExtensionPoliciesClient();

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

// Call the API and handle any network failures.
try {
/** @var GlobalVmExtensionPolicy $response */
$response = $globalVmExtensionPoliciesClient->get($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
{
$globalVmExtensionPolicy = '[GLOBAL_VM_EXTENSION_POLICY]';
$project = '[PROJECT]';

get_sample($globalVmExtensionPolicy, $project);
}
// [END compute_v1_generated_GlobalVmExtensionPolicies_Get_sync]
82 changes: 82 additions & 0 deletions Compute/samples/V1/GlobalVmExtensionPoliciesClient/insert.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
<?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_GlobalVmExtensionPolicies_Insert_sync]
use Google\ApiCore\ApiException;
use Google\ApiCore\OperationResponse;
use Google\Cloud\Compute\V1\Client\GlobalVmExtensionPoliciesClient;
use Google\Cloud\Compute\V1\GlobalVmExtensionPolicy;
use Google\Cloud\Compute\V1\InsertGlobalVmExtensionPolicyRequest;
use Google\Rpc\Status;

/**
* Creates a new project level GlobalVmExtensionPolicy.
*
* @param string $project Project ID for this request.
*/
function insert_sample(string $project): void
{
// Create a client.
$globalVmExtensionPoliciesClient = new GlobalVmExtensionPoliciesClient();

// Prepare the request message.
$globalVmExtensionPolicyResource = new GlobalVmExtensionPolicy();
$request = (new InsertGlobalVmExtensionPolicyRequest())
->setGlobalVmExtensionPolicyResource($globalVmExtensionPolicyResource)
->setProject($project);

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

insert_sample($project);
}
// [END compute_v1_generated_GlobalVmExtensionPolicies_Insert_sync]
Loading
Loading