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.

84 changes: 84 additions & 0 deletions Compute/samples/V1/HostsClient/get.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
<?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_Hosts_Get_sync]
use Google\ApiCore\ApiException;
use Google\Cloud\Compute\V1\Client\HostsClient;
use Google\Cloud\Compute\V1\GetHostRequest;
use Google\Cloud\Compute\V1\Host;

/**
* Retrieves information about the specified host.
*
* @param string $association The parent resource association for the Host. This field specifies the
* hierarchical context (e.g., reservation, block, sub-block) when
* accessing the host. For example, reservations/reservation_name,
* reservations/reservation_name/reservationBlocks/reservation_block_name or
* reservations/reservation_name/reservationBlocks/reservation_block_name/reservationSubBlocks/reservation_sub_block_name.
* @param string $host The name of the host, formatted as RFC1035 or a resource ID
* number.
* @param string $project The project ID for this request.
* @param string $zone The name of the zone for this request, formatted as RFC1035.
*/
function get_sample(string $association, string $host, string $project, string $zone): void
{
// Create a client.
$hostsClient = new HostsClient();

// Prepare the request message.
$request = (new GetHostRequest())
->setAssociation($association)
->setHost($host)
->setProject($project)
->setZone($zone);

// Call the API and handle any network failures.
try {
/** @var Host $response */
$response = $hostsClient->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
{
$association = '[ASSOCIATION]';
$host = '[HOST]';
$project = '[PROJECT]';
$zone = '[ZONE]';

get_sample($association, $host, $project, $zone);
}
// [END compute_v1_generated_Hosts_Get_sync]
98 changes: 98 additions & 0 deletions Compute/samples/V1/HostsClient/get_version.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
<?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_Hosts_GetVersion_sync]
use Google\ApiCore\ApiException;
use Google\ApiCore\OperationResponse;
use Google\Cloud\Compute\V1\Client\HostsClient;
use Google\Cloud\Compute\V1\GetVersionHostRequest;
use Google\Cloud\Compute\V1\HostsGetVersionRequest;
use Google\Rpc\Status;

/**
* Allows customers to get SBOM versions of a host.
*
* @param string $association The parent resource association for the Host. This field specifies the
* hierarchical context (e.g., reservation, block, sub-block) when
* accessing the host.
* @param string $host The name of the host, formatted as RFC1035 or a resource ID
* number.
* @param string $project Project ID for this request.
* @param string $zone Name of the zone for this request. Zone name should conform to RFC1035.
*/
function get_version_sample(
string $association,
string $host,
string $project,
string $zone
): void {
// Create a client.
$hostsClient = new HostsClient();

// Prepare the request message.
$hostsGetVersionRequestResource = new HostsGetVersionRequest();
$request = (new GetVersionHostRequest())
->setAssociation($association)
->setHost($host)
->setHostsGetVersionRequestResource($hostsGetVersionRequestResource)
->setProject($project)
->setZone($zone);

// Call the API and handle any network failures.
try {
/** @var OperationResponse $response */
$response = $hostsClient->getVersion($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
{
$association = '[ASSOCIATION]';
$host = '[HOST]';
$project = '[PROJECT]';
$zone = '[ZONE]';

get_version_sample($association, $host, $project, $zone);
}
// [END compute_v1_generated_Hosts_GetVersion_sync]
83 changes: 83 additions & 0 deletions Compute/samples/V1/HostsClient/list.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
<?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_Hosts_List_sync]
use Google\ApiCore\ApiException;
use Google\ApiCore\PagedListResponse;
use Google\Cloud\Compute\V1\Client\HostsClient;
use Google\Cloud\Compute\V1\ListHostsRequest;

/**
* Retrieves a list of hosts.
*
* @param string $association The parent resource association for the Host. This field specifies the
* hierarchical context (e.g., reservation, block, sub-block) when
* accessing the host. For example, reservations/reservation_name,
* reservations/reservation_name/reservationBlocks/reservation_block_name or
* reservations/reservation_name/reservationBlocks/reservation_block_name/reservationSubBlocks/reservation_sub_block_name.
* @param string $project The project ID for this request.
* @param string $zone The name of the zone for this request, formatted as RFC1035.
*/
function list_sample(string $association, string $project, string $zone): void
{
// Create a client.
$hostsClient = new HostsClient();

// Prepare the request message.
$request = (new ListHostsRequest())
->setAssociation($association)
->setProject($project)
->setZone($zone);

// Call the API and handle any network failures.
try {
/** @var PagedListResponse $response */
$response = $hostsClient->list($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
{
$association = '[ASSOCIATION]';
$project = '[PROJECT]';
$zone = '[ZONE]';

list_sample($association, $project, $zone);
}
// [END compute_v1_generated_Hosts_List_sync]
73 changes: 73 additions & 0 deletions Compute/samples/V1/ReliabilityRisksClient/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_ReliabilityRisks_Get_sync]
use Google\ApiCore\ApiException;
use Google\Cloud\Compute\V1\Client\ReliabilityRisksClient;
use Google\Cloud\Compute\V1\GetReliabilityRiskRequest;
use Google\Cloud\Compute\V1\ReliabilityRisk;

/**
* Returns the specified ReliabilityRisk resource.
*
* @param string $project Project ID for this request.
* @param string $reliabilityRisk Name of the ReliabilityRisk resource to return.
*/
function get_sample(string $project, string $reliabilityRisk): void
{
// Create a client.
$reliabilityRisksClient = new ReliabilityRisksClient();

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

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

get_sample($project, $reliabilityRisk);
}
// [END compute_v1_generated_ReliabilityRisks_Get_sync]
Loading
Loading