Reference documentation and code samples for the Compute V1 Client class InstancesClient.
Service Description: The Instances API.
This class provides the ability to make remote calls to the backing service through method calls that map to API methods.
Namespace
Google \ Cloud \ Compute \ V1 \ ClientMethods
__construct
Constructor.
Parameters | |
---|---|
Name | Description |
options |
array
Optional. Options for configuring the service API wrapper. |
↳ apiEndpoint |
string
The address of the API remote host. May optionally include the port, formatted as "
|
↳ credentials |
string|array|FetchAuthTokenInterface|CredentialsWrapper
The credentials to be used by the client to authorize API calls. This option accepts either a path to a credentials file, or a decoded credentials file as a PHP array. Advanced usage: In addition, this option can also accept a pre-constructed Google\Auth\FetchAuthTokenInterface object or Google\ApiCore\CredentialsWrapper object. Note that when one of these objects are provided, any settings in $credentialsConfig will be ignored. |
↳ credentialsConfig |
array
Options used to configure credentials, including auth token caching, for the client. For a full list of supporting configuration options, see Google\ApiCore\CredentialsWrapper::build() . |
↳ disableRetries |
bool
Determines whether or not retries defined by the client configuration should be disabled. Defaults to |
↳ clientConfig |
string|array
Client method configuration, including retry settings. This option can be either a path to a JSON file, or a PHP array containing the decoded JSON data. By default this settings points to the default client config file, which is provided in the resources folder. |
↳ transport |
string|TransportInterface
The transport used for executing network requests. At the moment, supports only |
↳ transportConfig |
array
Configuration options that will be used to construct the transport. Options for each supported transport type should be passed in a key for that transport. For example: $transportConfig = [ 'rest' => [...], ]; See the Google\ApiCore\Transport\RestTransport::build() method for the supported options. |
↳ clientCertSource |
callable
A callable which returns the client cert as a string. This can be used to provide a certificate and private key to the transport layer for mTLS. |
↳ logger |
false|LoggerInterface
A PSR-3 compliant logger. If set to false, logging is disabled, ignoring the 'GOOGLE_SDK_PHP_LOGGING' environment flag |
addAccessConfig
Adds an access config to an instance's network interface.
The async variant is InstancesClient::addAccessConfigAsync() .
Parameters | |
---|---|
Name | Description |
request |
Google\Cloud\Compute\V1\AddAccessConfigInstanceRequest
A request to house fields associated with the call. |
callOptions |
array
Optional. |
↳ retrySettings |
RetrySettings|array
Retry settings to use for this call. Can be a Google\ApiCore\RetrySettings object, or an associative array of retry settings parameters. See the documentation on Google\ApiCore\RetrySettings for example usage. |
Returns | |
---|---|
Type | Description |
Google\ApiCore\OperationResponse |
use Google\ApiCore\ApiException;
use Google\ApiCore\OperationResponse;
use Google\Cloud\Compute\V1\AccessConfig;
use Google\Cloud\Compute\V1\AddAccessConfigInstanceRequest;
use Google\Cloud\Compute\V1\Client\InstancesClient;
use Google\Rpc\Status;
/**
* @param string $instance The instance name for this request.
* @param string $networkInterface The name of the network interface to add to this instance.
* @param string $project Project ID for this request.
* @param string $zone The name of the zone for this request.
*/
function add_access_config_sample(
string $instance,
string $networkInterface,
string $project,
string $zone
): void {
// Create a client.
$instancesClient = new InstancesClient();
// Prepare the request message.
$accessConfigResource = new AccessConfig();
$request = (new AddAccessConfigInstanceRequest())
->setAccessConfigResource($accessConfigResource)
->setInstance($instance)
->setNetworkInterface($networkInterface)
->setProject($project)
->setZone($zone);
// Call the API and handle any network failures.
try {
/** @var OperationResponse $response */
$response = $instancesClient->addAccessConfig($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
{
$instance = '[INSTANCE]';
$networkInterface = '[NETWORK_INTERFACE]';
$project = '[PROJECT]';
$zone = '[ZONE]';
add_access_config_sample($instance, $networkInterface, $project, $zone);
}
addResourcePolicies
Adds existing resource policies to an instance. You can only add one policy right now which will be applied to this instance for scheduling live migrations.
The async variant is InstancesClient::addResourcePoliciesAsync() .
Parameters | |
---|---|
Name | Description |
request |
Google\Cloud\Compute\V1\AddResourcePoliciesInstanceRequest
A request to house fields associated with the call. |
callOptions |
array
Optional. |
↳ retrySettings |
RetrySettings|array
Retry settings to use for this call. Can be a Google\ApiCore\RetrySettings object, or an associative array of retry settings parameters. See the documentation on Google\ApiCore\RetrySettings for example usage. |
Returns | |
---|---|
Type | Description |
Google\ApiCore\OperationResponse |
use Google\ApiCore\ApiException;
use Google\ApiCore\OperationResponse;
use Google\Cloud\Compute\V1\AddResourcePoliciesInstanceRequest;
use Google\Cloud\Compute\V1\Client\InstancesClient;
use Google\Cloud\Compute\V1\InstancesAddResourcePoliciesRequest;
use Google\Rpc\Status;
/**
* @param string $instance The instance name for this request.
* @param string $project Project ID for this request.
* @param string $zone The name of the zone for this request.
*/
function add_resource_policies_sample(string $instance, string $project, string $zone): void
{
// Create a client.
$instancesClient = new InstancesClient();
// Prepare the request message.
$instancesAddResourcePoliciesRequestResource = new InstancesAddResourcePoliciesRequest();
$request = (new AddResourcePoliciesInstanceRequest())
->setInstance($instance)
->setInstancesAddResourcePoliciesRequestResource($instancesAddResourcePoliciesRequestResource)
->setProject($project)
->setZone($zone);
// Call the API and handle any network failures.
try {
/** @var OperationResponse $response */
$response = $instancesClient->addResourcePolicies($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
{
$instance = '[INSTANCE]';
$project = '[PROJECT]';
$zone = '[ZONE]';
add_resource_policies_sample($instance, $project, $zone);
}
aggregatedList
Retrieves an aggregated list of all of the instances in your project across all regions and zones. The performance of this method degrades when a filter is specified on a project that has a very large number of instances. To prevent failure, Google recommends that you set the returnPartialSuccess
parameter to true
.
The async variant is InstancesClient::aggregatedListAsync() .
Parameters | |
---|---|
Name | Description |
request |
Google\Cloud\Compute\V1\AggregatedListInstancesRequest
A request to house fields associated with the call. |
callOptions |
array
Optional. |
↳ retrySettings |
RetrySettings|array
Retry settings to use for this call. Can be a Google\ApiCore\RetrySettings object, or an associative array of retry settings parameters. See the documentation on Google\ApiCore\RetrySettings for example usage. |
Returns | |
---|---|
Type | Description |
Google\ApiCore\PagedListResponse |
use Google\ApiCore\ApiException;
use Google\ApiCore\PagedListResponse;
use Google\Cloud\Compute\V1\AggregatedListInstancesRequest;
use Google\Cloud\Compute\V1\Client\InstancesClient;
/**
* @param string $project Project ID for this request.
*/
function aggregated_list_sample(string $project): void
{
// Create a client.
$instancesClient = new InstancesClient();
// Prepare the request message.
$request = (new AggregatedListInstancesRequest())
->setProject($project);
// Call the API and handle any network failures.
try {
/** @var PagedListResponse $response */
$response = $instancesClient->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);
}
attachDisk
Attaches an existing Disk resource to an instance. You must first create the disk before you can attach it. It is not possible to create and attach a disk at the same time. For more information, read Adding a persistent disk to your instance.
The async variant is InstancesClient::attachDiskAsync() .
Parameters | |
---|---|
Name | Description |
request |
Google\Cloud\Compute\V1\AttachDiskInstanceRequest
A request to house fields associated with the call. |
callOptions |
array
Optional. |
↳ retrySettings |
RetrySettings|array
Retry settings to use for this call. Can be a Google\ApiCore\RetrySettings object, or an associative array of retry settings parameters. See the documentation on Google\ApiCore\RetrySettings for example usage. |
Returns | |
---|---|
Type | Description |
Google\ApiCore\OperationResponse |
use Google\ApiCore\ApiException;
use Google\ApiCore\OperationResponse;
use Google\Cloud\Compute\V1\AttachDiskInstanceRequest;
use Google\Cloud\Compute\V1\AttachedDisk;
use Google\Cloud\Compute\V1\Client\InstancesClient;
use Google\Rpc\Status;
/**
* @param string $instance The instance name for this request.
* @param string $project Project ID for this request.
* @param string $zone The name of the zone for this request.
*/
function attach_disk_sample(string $instance, string $project, string $zone): void
{
// Create a client.
$instancesClient = new InstancesClient();
// Prepare the request message.
$attachedDiskResource = new AttachedDisk();
$request = (new AttachDiskInstanceRequest())
->setAttachedDiskResource($attachedDiskResource)
->setInstance($instance)
->setProject($project)
->setZone($zone);
// Call the API and handle any network failures.
try {
/** @var OperationResponse $response */
$response = $instancesClient->attachDisk($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
{
$instance = '[INSTANCE]';
$project = '[PROJECT]';
$zone = '[ZONE]';
attach_disk_sample($instance, $project, $zone);
}
bulkInsert
Creates multiple instances. Count specifies the number of instances to create. For more information, see About bulk creation of VMs.
The async variant is InstancesClient::bulkInsertAsync() .
Parameters | |
---|---|
Name | Description |
request |
Google\Cloud\Compute\V1\BulkInsertInstanceRequest
A request to house fields associated with the call. |
callOptions |
array
Optional. |
↳ retrySettings |
RetrySettings|array
Retry settings to use for this call. Can be a Google\ApiCore\RetrySettings object, or an associative array of retry settings parameters. See the documentation on Google\ApiCore\RetrySettings for example usage. |
Returns | |
---|---|
Type | Description |
Google\ApiCore\OperationResponse |
use Google\ApiCore\ApiException;
use Google\ApiCore\OperationResponse;
use Google\Cloud\Compute\V1\BulkInsertInstanceRequest;
use Google\Cloud\Compute\V1\BulkInsertInstanceResource;
use Google\Cloud\Compute\V1\Client\InstancesClient;
use Google\Rpc\Status;
/**
* @param string $project Project ID for this request.
* @param string $zone The name of the zone for this request.
*/
function bulk_insert_sample(string $project, string $zone): void
{
// Create a client.
$instancesClient = new InstancesClient();
// Prepare the request message.
$bulkInsertInstanceResourceResource = new BulkInsertInstanceResource();
$request = (new BulkInsertInstanceRequest())
->setBulkInsertInstanceResourceResource($bulkInsertInstanceResourceResource)
->setProject($project)
->setZone($zone);
// Call the API and handle any network failures.
try {
/** @var OperationResponse $response */
$response = $instancesClient->bulkInsert($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]';
$zone = '[ZONE]';
bulk_insert_sample($project, $zone);
}
delete
Deletes the specified Instance resource. For more information, see Deleting an instance.
The async variant is InstancesClient::deleteAsync() .
Parameters | |
---|---|
Name | Description |
request |
Google\Cloud\Compute\V1\DeleteInstanceRequest
A request to house fields associated with the call. |
callOptions |
array
Optional. |
↳ retrySettings |
RetrySettings|array
Retry settings to use for this call. Can be a Google\ApiCore\RetrySettings object, or an associative array of retry settings parameters. See the documentation on Google\ApiCore\RetrySettings for example usage. |
Returns | |
---|---|
Type | Description |
Google\ApiCore\OperationResponse |
use Google\ApiCore\ApiException;
use Google\ApiCore\OperationResponse;
use Google\Cloud\Compute\V1\Client\InstancesClient;
use Google\Cloud\Compute\V1\DeleteInstanceRequest;
use Google\Rpc\Status;
/**
* @param string $instance Name of the instance 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 $instance, string $project, string $zone): void
{
// Create a client.
$instancesClient = new InstancesClient();
// Prepare the request message.
$request = (new DeleteInstanceRequest())
->setInstance($instance)
->setProject($project)
->setZone($zone);
// Call the API and handle any network failures.
try {
/** @var OperationResponse $response */
$response = $instancesClient->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
{
$instance = '[INSTANCE]';
$project = '[PROJECT]';
$zone = '[ZONE]';
delete_sample($instance, $project, $zone);
}
deleteAccessConfig
Deletes an access config from an instance's network interface.
The async variant is InstancesClient::deleteAccessConfigAsync() .
Parameters | |
---|---|
Name | Description |
request |
Google\Cloud\Compute\V1\DeleteAccessConfigInstanceRequest
A request to house fields associated with the call. |
callOptions |
array
Optional. |
↳ retrySettings |
RetrySettings|array
Retry settings to use for this call. Can be a Google\ApiCore\RetrySettings object, or an associative array of retry settings parameters. See the documentation on Google\ApiCore\RetrySettings for example usage. |
Returns | |
---|---|
Type | Description |
Google\ApiCore\OperationResponse |
use Google\ApiCore\ApiException;
use Google\ApiCore\OperationResponse;
use Google\Cloud\Compute\V1\Client\InstancesClient;
use Google\Cloud\Compute\V1\DeleteAccessConfigInstanceRequest;
use Google\Rpc\Status;
/**
* @param string $accessConfig The name of the access config to delete.
* @param string $instance The instance name for this request.
* @param string $networkInterface The name of the network interface.
* @param string $project Project ID for this request.
* @param string $zone The name of the zone for this request.
*/
function delete_access_config_sample(
string $accessConfig,
string $instance,
string $networkInterface,
string $project,
string $zone
): void {
// Create a client.
$instancesClient = new InstancesClient();
// Prepare the request message.
$request = (new DeleteAccessConfigInstanceRequest())
->setAccessConfig($accessConfig)
->setInstance($instance)
->setNetworkInterface($networkInterface)
->setProject($project)
->setZone($zone);
// Call the API and handle any network failures.
try {
/** @var OperationResponse $response */
$response = $instancesClient->deleteAccessConfig($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
{
$accessConfig = '[ACCESS_CONFIG]';
$instance = '[INSTANCE]';
$networkInterface = '[NETWORK_INTERFACE]';
$project = '[PROJECT]';
$zone = '[ZONE]';
delete_access_config_sample($accessConfig, $instance, $networkInterface, $project, $zone);
}
detachDisk
Detaches a disk from an instance.
The async variant is InstancesClient::detachDiskAsync() .
Parameters | |
---|---|
Name | Description |
request |
Google\Cloud\Compute\V1\DetachDiskInstanceRequest
A request to house fields associated with the call. |
callOptions |
array
Optional. |
↳ retrySettings |
RetrySettings|array
Retry settings to use for this call. Can be a Google\ApiCore\RetrySettings object, or an associative array of retry settings parameters. See the documentation on Google\ApiCore\RetrySettings for example usage. |
Returns | |
---|---|
Type | Description |
Google\ApiCore\OperationResponse |
use Google\ApiCore\ApiException;
use Google\ApiCore\OperationResponse;
use Google\Cloud\Compute\V1\Client\InstancesClient;
use Google\Cloud\Compute\V1\DetachDiskInstanceRequest;
use Google\Rpc\Status;
/**
* @param string $deviceName The device name of the disk to detach. Make a get() request on the instance to view currently attached disks and device names.
* @param string $instance Instance name for this request.
* @param string $project Project ID for this request.
* @param string $zone The name of the zone for this request.
*/
function detach_disk_sample(
string $deviceName,
string $instance,
string $project,
string $zone
): void {
// Create a client.
$instancesClient = new InstancesClient();
// Prepare the request message.
$request = (new DetachDiskInstanceRequest())
->setDeviceName($deviceName)
->setInstance($instance)
->setProject($project)
->setZone($zone);
// Call the API and handle any network failures.
try {
/** @var OperationResponse $response */
$response = $instancesClient->detachDisk($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
{
$deviceName = '[DEVICE_NAME]';
$instance = '[INSTANCE]';
$project = '[PROJECT]';
$zone = '[ZONE]';
detach_disk_sample($deviceName, $instance, $project, $zone);
}
get
Returns the specified Instance resource.
The async variant is InstancesClient::getAsync() .
Parameters | |
---|---|
Name | Description |
request |
Google\Cloud\Compute\V1\GetInstanceRequest
A request to house fields associated with the call. |
callOptions |
array
Optional. |
↳ retrySettings |
RetrySettings|array
Retry settings to use for this call. Can be a Google\ApiCore\RetrySettings object, or an associative array of retry settings parameters. See the documentation on Google\ApiCore\RetrySettings for example usage. |
Returns | |
---|---|
Type | Description |
Google\Cloud\Compute\V1\Instance |
use Google\ApiCore\ApiException;
use Google\Cloud\Compute\V1\Client\InstancesClient;
use Google\Cloud\Compute\V1\GetInstanceRequest;
use Google\Cloud\Compute\V1\Instance;
/**
* @param string $instance Name of the instance resource to return.
* @param string $project Project ID for this request.
* @param string $zone The name of the zone for this request.
*/
function get_sample(string $instance, string $project, string $zone): void
{
// Create a client.
$instancesClient = new InstancesClient();
// Prepare the request message.
$request = (new GetInstanceRequest())
->setInstance($instance)
->setProject($project)
->setZone($zone);
// Call the API and handle any network failures.
try {
/** @var Instance $response */
$response = $instancesClient->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
{
$instance = '[INSTANCE]';
$project = '[PROJECT]';
$zone = '[ZONE]';
get_sample($instance, $project, $zone);
}
getEffectiveFirewalls
Returns effective firewalls applied to an interface of the instance.
The async variant is InstancesClient::getEffectiveFirewallsAsync() .
Parameters | |
---|---|
Name | Description |
request |
Google\Cloud\Compute\V1\GetEffectiveFirewallsInstanceRequest
A request to house fields associated with the call. |
callOptions |
array
Optional. |
↳ retrySettings |
RetrySettings|array
Retry settings to use for this call. Can be a Google\ApiCore\RetrySettings object, or an associative array of retry settings parameters. See the documentation on Google\ApiCore\RetrySettings for example usage. |
Returns | |
---|---|
Type | Description |
Google\Cloud\Compute\V1\InstancesGetEffectiveFirewallsResponse |
use Google\ApiCore\ApiException;
use Google\Cloud\Compute\V1\Client\InstancesClient;
use Google\Cloud\Compute\V1\GetEffectiveFirewallsInstanceRequest;
use Google\Cloud\Compute\V1\InstancesGetEffectiveFirewallsResponse;
/**
* @param string $instance Name of the instance scoping this request.
* @param string $networkInterface The name of the network interface to get the effective firewalls.
* @param string $project Project ID for this request.
* @param string $zone The name of the zone for this request.
*/
function get_effective_firewalls_sample(
string $instance,
string $networkInterface,
string $project,
string $zone
): void {
// Create a client.
$instancesClient = new InstancesClient();
// Prepare the request message.
$request = (new GetEffectiveFirewallsInstanceRequest())
->setInstance($instance)
->setNetworkInterface($networkInterface)
->setProject($project)
->setZone($zone);
// Call the API and handle any network failures.
try {
/** @var InstancesGetEffectiveFirewallsResponse $response */
$response = $instancesClient->getEffectiveFirewalls($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
{
$instance = '[INSTANCE]';
$networkInterface = '[NETWORK_INTERFACE]';
$project = '[PROJECT]';
$zone = '[ZONE]';
get_effective_firewalls_sample($instance, $networkInterface, $project, $zone);
}
getGuestAttributes
Returns the specified guest attributes entry.
The async variant is InstancesClient::getGuestAttributesAsync() .
Parameters | |
---|---|
Name | Description |
request |
Google\Cloud\Compute\V1\GetGuestAttributesInstanceRequest
A request to house fields associated with the call. |
callOptions |
array
Optional. |
↳ retrySettings |
RetrySettings|array
Retry settings to use for this call. Can be a Google\ApiCore\RetrySettings object, or an associative array of retry settings parameters. See the documentation on Google\ApiCore\RetrySettings for example usage. |
Returns | |
---|---|
Type | Description |
Google\Cloud\Compute\V1\GuestAttributes |
use Google\ApiCore\ApiException;
use Google\Cloud\Compute\V1\Client\InstancesClient;
use Google\Cloud\Compute\V1\GetGuestAttributesInstanceRequest;
use Google\Cloud\Compute\V1\GuestAttributes;
/**
* @param string $instance Name of the instance scoping this request.
* @param string $project Project ID for this request.
* @param string $zone The name of the zone for this request.
*/
function get_guest_attributes_sample(string $instance, string $project, string $zone): void
{
// Create a client.
$instancesClient = new InstancesClient();
// Prepare the request message.
$request = (new GetGuestAttributesInstanceRequest())
->setInstance($instance)
->setProject($project)
->setZone($zone);
// Call the API and handle any network failures.
try {
/** @var GuestAttributes $response */
$response = $instancesClient->getGuestAttributes($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
{
$instance = '[INSTANCE]';
$project = '[PROJECT]';
$zone = '[ZONE]';
get_guest_attributes_sample($instance, $project, $zone);
}
getIamPolicy
Gets the access control policy for a resource. May be empty if no such policy or resource exists.
The async variant is InstancesClient::getIamPolicyAsync() .
Parameters | |
---|---|
Name | Description |
request |
Google\Cloud\Compute\V1\GetIamPolicyInstanceRequest
A request to house fields associated with the call. |
callOptions |
array
Optional. |
↳ retrySettings |
RetrySettings|array
Retry settings to use for this call. Can be a Google\ApiCore\RetrySettings object, or an associative array of retry settings parameters. See the documentation on Google\ApiCore\RetrySettings for example usage. |
Returns | |
---|---|
Type | Description |
Google\Cloud\Compute\V1\Policy |
use Google\ApiCore\ApiException;
use Google\Cloud\Compute\V1\Client\InstancesClient;
use Google\Cloud\Compute\V1\GetIamPolicyInstanceRequest;
use Google\Cloud\Compute\V1\Policy;
/**
* @param string $project Project ID for this request.
* @param string $resource Name or id of the resource for this request.
* @param string $zone The name of the zone for this request.
*/
function get_iam_policy_sample(string $project, string $resource, string $zone): void
{
// Create a client.
$instancesClient = new InstancesClient();
// Prepare the request message.
$request = (new GetIamPolicyInstanceRequest())
->setProject($project)
->setResource($resource)
->setZone($zone);
// Call the API and handle any network failures.
try {
/** @var Policy $response */
$response = $instancesClient->getIamPolicy($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]';
$resource = '[RESOURCE]';
$zone = '[ZONE]';
get_iam_policy_sample($project, $resource, $zone);
}
getScreenshot
Returns the screenshot from the specified instance.
The async variant is InstancesClient::getScreenshotAsync() .
Parameters | |
---|---|
Name | Description |
request |
Google\Cloud\Compute\V1\GetScreenshotInstanceRequest
A request to house fields associated with the call. |
callOptions |
array
Optional. |
↳ retrySettings |
RetrySettings|array
Retry settings to use for this call. Can be a Google\ApiCore\RetrySettings object, or an associative array of retry settings parameters. See the documentation on Google\ApiCore\RetrySettings for example usage. |
Returns | |
---|---|
Type | Description |
Google\Cloud\Compute\V1\Screenshot |
use Google\ApiCore\ApiException;
use Google\Cloud\Compute\V1\Client\InstancesClient;
use Google\Cloud\Compute\V1\GetScreenshotInstanceRequest;
use Google\Cloud\Compute\V1\Screenshot;
/**
* @param string $instance Name of the instance scoping this request.
* @param string $project Project ID for this request.
* @param string $zone The name of the zone for this request.
*/
function get_screenshot_sample(string $instance, string $project, string $zone): void
{
// Create a client.
$instancesClient = new InstancesClient();
// Prepare the request message.
$request = (new GetScreenshotInstanceRequest())
->setInstance($instance)
->setProject($project)
->setZone($zone);
// Call the API and handle any network failures.
try {
/** @var Screenshot $response */
$response = $instancesClient->getScreenshot($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
{
$instance = '[INSTANCE]';
$project = '[PROJECT]';
$zone = '[ZONE]';
get_screenshot_sample($instance, $project, $zone);
}
getSerialPortOutput
Returns the last 1 MB of serial port output from the specified instance.
The async variant is InstancesClient::getSerialPortOutputAsync() .
Parameters | |
---|---|
Name | Description |
request |
Google\Cloud\Compute\V1\GetSerialPortOutputInstanceRequest
A request to house fields associated with the call. |
callOptions |
array
Optional. |
↳ retrySettings |
RetrySettings|array
Retry settings to use for this call. Can be a Google\ApiCore\RetrySettings object, or an associative array of retry settings parameters. See the documentation on Google\ApiCore\RetrySettings for example usage. |
Returns | |
---|---|
Type | Description |
Google\Cloud\Compute\V1\SerialPortOutput |
use Google\ApiCore\ApiException;
use Google\Cloud\Compute\V1\Client\InstancesClient;
use Google\Cloud\Compute\V1\GetSerialPortOutputInstanceRequest;
use Google\Cloud\Compute\V1\SerialPortOutput;
/**
* @param string $instance Name of the instance for this request.
* @param string $project Project ID for this request.
* @param string $zone The name of the zone for this request.
*/
function get_serial_port_output_sample(string $instance, string $project, string $zone): void
{
// Create a client.
$instancesClient = new InstancesClient();
// Prepare the request message.
$request = (new GetSerialPortOutputInstanceRequest())
->setInstance($instance)
->setProject($project)
->setZone($zone);
// Call the API and handle any network failures.
try {
/** @var SerialPortOutput $response */
$response = $instancesClient->getSerialPortOutput($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
{
$instance = '[INSTANCE]';
$project = '[PROJECT]';
$zone = '[ZONE]';
get_serial_port_output_sample($instance, $project, $zone);
}
getShieldedInstanceIdentity
Returns the Shielded Instance Identity of an instance
The async variant is InstancesClient::getShieldedInstanceIdentityAsync() .
Parameters | |
---|---|
Name | Description |
request |
Google\Cloud\Compute\V1\GetShieldedInstanceIdentityInstanceRequest
A request to house fields associated with the call. |
callOptions |
array
Optional. |
↳ retrySettings |
RetrySettings|array
Retry settings to use for this call. Can be a Google\ApiCore\RetrySettings object, or an associative array of retry settings parameters. See the documentation on Google\ApiCore\RetrySettings for example usage. |
Returns | |
---|---|
Type | Description |
Google\Cloud\Compute\V1\ShieldedInstanceIdentity |
use Google\ApiCore\ApiException;
use Google\Cloud\Compute\V1\Client\InstancesClient;
use Google\Cloud\Compute\V1\GetShieldedInstanceIdentityInstanceRequest;
use Google\Cloud\Compute\V1\ShieldedInstanceIdentity;
/**
* @param string $instance Name or id of the instance scoping this request.
* @param string $project Project ID for this request.
* @param string $zone The name of the zone for this request.
*/
function get_shielded_instance_identity_sample(
string $instance,
string $project,
string $zone
): void {
// Create a client.
$instancesClient = new InstancesClient();
// Prepare the request message.
$request = (new GetShieldedInstanceIdentityInstanceRequest())
->setInstance($instance)
->setProject($project)
->setZone($zone);
// Call the API and handle any network failures.
try {
/** @var ShieldedInstanceIdentity $response */
$response = $instancesClient->getShieldedInstanceIdentity($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
{
$instance = '[INSTANCE]';
$project = '[PROJECT]';
$zone = '[ZONE]';
get_shielded_instance_identity_sample($instance, $project, $zone);
}
insert
Creates an instance resource in the specified project using the data included in the request.
The async variant is InstancesClient::insertAsync() .
Parameters | |
---|---|
Name | Description |
request |
Google\Cloud\Compute\V1\InsertInstanceRequest
A request to house fields associated with the call. |
callOptions |
array
Optional. |
↳ retrySettings |
RetrySettings|array
Retry settings to use for this call. Can be a Google\ApiCore\RetrySettings object, or an associative array of retry settings parameters. See the documentation on Google\ApiCore\RetrySettings for example usage. |
Returns | |
---|---|
Type | Description |
Google\ApiCore\OperationResponse |
use Google\ApiCore\ApiException;
use Google\ApiCore\OperationResponse;
use Google\Cloud\Compute\V1\Client\InstancesClient;
use Google\Cloud\Compute\V1\InsertInstanceRequest;
use Google\Cloud\Compute\V1\Instance;
use Google\Rpc\Status;
/**
* @param string $project Project ID for this request.
* @param string $zone The name of the zone for this request.
*/
function insert_sample(string $project, string $zone): void
{
// Create a client.
$instancesClient = new InstancesClient();
// Prepare the request message.
$instanceResource = new Instance();
$request = (new InsertInstanceRequest())
->setInstanceResource($instanceResource)
->setProject($project)
->setZone($zone);
// Call the API and handle any network failures.
try {
/** @var OperationResponse $response */
$response = $instancesClient->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]';
$zone = '[ZONE]';
insert_sample($project, $zone);
}
list
Retrieves the list of instances contained within the specified zone.
The async variant is InstancesClient::listAsync() .
Parameters | |
---|---|
Name | Description |
request |
Google\Cloud\Compute\V1\ListInstancesRequest
A request to house fields associated with the call. |
callOptions |
array
Optional. |
↳ retrySettings |
RetrySettings|array
Retry settings to use for this call. Can be a Google\ApiCore\RetrySettings object, or an associative array of retry settings parameters. See the documentation on Google\ApiCore\RetrySettings for example usage. |
Returns | |
---|---|
Type | Description |
Google\ApiCore\PagedListResponse |
use Google\ApiCore\ApiException;
use Google\ApiCore\PagedListResponse;
use Google\Cloud\Compute\V1\Client\InstancesClient;
use Google\Cloud\Compute\V1\ListInstancesRequest;
/**
* @param string $project Project ID for this request.
* @param string $zone The name of the zone for this request.
*/
function list_sample(string $project, string $zone): void
{
// Create a client.
$instancesClient = new InstancesClient();
// Prepare the request message.
$request = (new ListInstancesRequest())
->setProject($project)
->setZone($zone);
// Call the API and handle any network failures.
try {
/** @var PagedListResponse $response */
$response = $instancesClient->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
{
$project = '[PROJECT]';
$zone = '[ZONE]';
list_sample($project, $zone);
}
listReferrers
Retrieves a list of resources that refer to the VM instance specified in the request. For example, if the VM instance is part of a managed or unmanaged instance group, the referrers list includes the instance group. For more information, read Viewing referrers to VM instances.
The async variant is InstancesClient::listReferrersAsync() .
Parameters | |
---|---|
Name | Description |
request |
Google\Cloud\Compute\V1\ListReferrersInstancesRequest
A request to house fields associated with the call. |
callOptions |
array
Optional. |
↳ retrySettings |
RetrySettings|array
Retry settings to use for this call. Can be a Google\ApiCore\RetrySettings object, or an associative array of retry settings parameters. See the documentation on Google\ApiCore\RetrySettings for example usage. |
Returns | |
---|---|
Type | Description |
Google\ApiCore\PagedListResponse |
use Google\ApiCore\ApiException;
use Google\ApiCore\PagedListResponse;
use Google\Cloud\Compute\V1\Client\InstancesClient;
use Google\Cloud\Compute\V1\ListReferrersInstancesRequest;
/**
* @param string $instance Name of the target instance scoping this request, or '-' if the request should span over all instances in the container.
* @param string $project Project ID for this request.
* @param string $zone The name of the zone for this request.
*/
function list_referrers_sample(string $instance, string $project, string $zone): void
{
// Create a client.
$instancesClient = new InstancesClient();
// Prepare the request message.
$request = (new ListReferrersInstancesRequest())
->setInstance($instance)
->setProject($project)
->setZone($zone);
// Call the API and handle any network failures.
try {
/** @var PagedListResponse $response */
$response = $instancesClient->listReferrers($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
{
$instance = '[INSTANCE]';
$project = '[PROJECT]';
$zone = '[ZONE]';
list_referrers_sample($instance, $project, $zone);
}
performMaintenance
Perform a manual maintenance on the instance.
The async variant is InstancesClient::performMaintenanceAsync() .
Parameters | |
---|---|
Name | Description |
request |
Google\Cloud\Compute\V1\PerformMaintenanceInstanceRequest
A request to house fields associated with the call. |
callOptions |
array
Optional. |
↳ retrySettings |
RetrySettings|array
Retry settings to use for this call. Can be a Google\ApiCore\RetrySettings object, or an associative array of retry settings parameters. See the documentation on Google\ApiCore\RetrySettings for example usage. |
Returns | |
---|---|
Type | Description |
Google\ApiCore\OperationResponse |
use Google\ApiCore\ApiException;
use Google\ApiCore\OperationResponse;
use Google\Cloud\Compute\V1\Client\InstancesClient;
use Google\Cloud\Compute\V1\PerformMaintenanceInstanceRequest;
use Google\Rpc\Status;
/**
* @param string $instance Name of the instance scoping this request.
* @param string $project Project ID for this request.
* @param string $zone The name of the zone for this request.
*/
function perform_maintenance_sample(string $instance, string $project, string $zone): void
{
// Create a client.
$instancesClient = new InstancesClient();
// Prepare the request message.
$request = (new PerformMaintenanceInstanceRequest())
->setInstance($instance)
->setProject($project)
->setZone($zone);
// Call the API and handle any network failures.
try {
/** @var OperationResponse $response */
$response = $instancesClient->performMaintenance($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
{
$instance = '[INSTANCE]';
$project = '[PROJECT]';
$zone = '[ZONE]';
perform_maintenance_sample($instance, $project, $zone);
}
removeResourcePolicies
Removes resource policies from an instance.
The async variant is InstancesClient::removeResourcePoliciesAsync() .
Parameters | |
---|---|
Name | Description |
request |
Google\Cloud\Compute\V1\RemoveResourcePoliciesInstanceRequest
A request to house fields associated with the call. |
callOptions |
array
Optional. |
↳ retrySettings |
RetrySettings|array
Retry settings to use for this call. Can be a Google\ApiCore\RetrySettings object, or an associative array of retry settings parameters. See the documentation on Google\ApiCore\RetrySettings for example usage. |
Returns | |
---|---|
Type | Description |
Google\ApiCore\OperationResponse |
use Google\ApiCore\ApiException;
use Google\ApiCore\OperationResponse;
use Google\Cloud\Compute\V1\Client\InstancesClient;
use Google\Cloud\Compute\V1\InstancesRemoveResourcePoliciesRequest;
use Google\Cloud\Compute\V1\RemoveResourcePoliciesInstanceRequest;
use Google\Rpc\Status;
/**
* @param string $instance The instance name for this request.
* @param string $project Project ID for this request.
* @param string $zone The name of the zone for this request.
*/
function remove_resource_policies_sample(string $instance, string $project, string $zone): void
{
// Create a client.
$instancesClient = new InstancesClient();
// Prepare the request message.
$instancesRemoveResourcePoliciesRequestResource = new InstancesRemoveResourcePoliciesRequest();
$request = (new RemoveResourcePoliciesInstanceRequest())
->setInstance($instance)
->setInstancesRemoveResourcePoliciesRequestResource($instancesRemoveResourcePoliciesRequestResource)
->setProject($project)
->setZone($zone);
// Call the API and handle any network failures.
try {
/** @var OperationResponse $response */
$response = $instancesClient->removeResourcePolicies($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
{
$instance = '[INSTANCE]';
$project = '[PROJECT]';
$zone = '[ZONE]';
remove_resource_policies_sample($instance, $project, $zone);
}
reset
Performs a reset on the instance. This is a hard reset. The VM does not do a graceful shutdown. For more information, see Resetting an instance.
The async variant is InstancesClient::resetAsync() .
Parameters | |
---|---|
Name | Description |
request |
Google\Cloud\Compute\V1\ResetInstanceRequest
A request to house fields associated with the call. |
callOptions |
array
Optional. |
↳ retrySettings |
RetrySettings|array
Retry settings to use for this call. Can be a Google\ApiCore\RetrySettings object, or an associative array of retry settings parameters. See the documentation on Google\ApiCore\RetrySettings for example usage. |
Returns | |
---|---|
Type | Description |
Google\ApiCore\OperationResponse |
use Google\ApiCore\ApiException;
use Google\ApiCore\OperationResponse;
use Google\Cloud\Compute\V1\Client\InstancesClient;
use Google\Cloud\Compute\V1\ResetInstanceRequest;
use Google\Rpc\Status;
/**
* @param string $instance Name of the instance scoping this request.
* @param string $project Project ID for this request.
* @param string $zone The name of the zone for this request.
*/
function reset_sample(string $instance, string $project, string $zone): void
{
// Create a client.
$instancesClient = new InstancesClient();
// Prepare the request message.
$request = (new ResetInstanceRequest())
->setInstance($instance)
->setProject($project)
->setZone($zone);
// Call the API and handle any network failures.
try {
/** @var OperationResponse $response */
$response = $instancesClient->reset($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
{
$instance = '[INSTANCE]';
$project = '[PROJECT]';
$zone = '[ZONE]';
reset_sample($instance, $project, $zone);
}
resume
Resumes an instance that was suspended using the instances().suspend method.
The async variant is InstancesClient::resumeAsync() .
Parameters | |
---|---|
Name | Description |
request |
Google\Cloud\Compute\V1\ResumeInstanceRequest
A request to house fields associated with the call. |
callOptions |
array
Optional. |
↳ retrySettings |
RetrySettings|array
Retry settings to use for this call. Can be a Google\ApiCore\RetrySettings object, or an associative array of retry settings parameters. See the documentation on Google\ApiCore\RetrySettings for example usage. |
Returns | |
---|---|
Type | Description |
Google\ApiCore\OperationResponse |
use Google\ApiCore\ApiException;
use Google\ApiCore\OperationResponse;
use Google\Cloud\Compute\V1\Client\InstancesClient;
use Google\Cloud\Compute\V1\ResumeInstanceRequest;
use Google\Rpc\Status;
/**
* @param string $instance Name of the instance resource to resume.
* @param string $project Project ID for this request.
* @param string $zone The name of the zone for this request.
*/
function resume_sample(string $instance, string $project, string $zone): void
{
// Create a client.
$instancesClient = new InstancesClient();
// Prepare the request message.
$request = (new ResumeInstanceRequest())
->setInstance($instance)
->setProject($project)
->setZone($zone);
// Call the API and handle any network failures.
try {
/** @var OperationResponse $response */
$response = $instancesClient->resume($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
{
$instance = '[INSTANCE]';
$project = '[PROJECT]';
$zone = '[ZONE]';
resume_sample($instance, $project, $zone);
}
sendDiagnosticInterrupt
Sends diagnostic interrupt to the instance.
The async variant is InstancesClient::sendDiagnosticInterruptAsync() .
Parameters | |
---|---|
Name | Description |
request |
Google\Cloud\Compute\V1\SendDiagnosticInterruptInstanceRequest
A request to house fields associated with the call. |
callOptions |
array
Optional. |
↳ retrySettings |
RetrySettings|array
Retry settings to use for this call. Can be a Google\ApiCore\RetrySettings object, or an associative array of retry settings parameters. See the documentation on Google\ApiCore\RetrySettings for example usage. |
Returns | |
---|---|
Type | Description |
Google\Cloud\Compute\V1\SendDiagnosticInterruptInstanceResponse |
use Google\ApiCore\ApiException;
use Google\Cloud\Compute\V1\Client\InstancesClient;
use Google\Cloud\Compute\V1\SendDiagnosticInterruptInstanceRequest;
use Google\Cloud\Compute\V1\SendDiagnosticInterruptInstanceResponse;
/**
* @param string $instance Name of the instance scoping this request.
* @param string $project Project ID for this request.
* @param string $zone The name of the zone for this request.
*/
function send_diagnostic_interrupt_sample(string $instance, string $project, string $zone): void
{
// Create a client.
$instancesClient = new InstancesClient();
// Prepare the request message.
$request = (new SendDiagnosticInterruptInstanceRequest())
->setInstance($instance)
->setProject($project)
->setZone($zone);
// Call the API and handle any network failures.
try {
/** @var SendDiagnosticInterruptInstanceResponse $response */
$response = $instancesClient->sendDiagnosticInterrupt($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
{
$instance = '[INSTANCE]';
$project = '[PROJECT]';
$zone = '[ZONE]';
send_diagnostic_interrupt_sample($instance, $project, $zone);
}
setDeletionProtection
Sets deletion protection on the instance.
The async variant is InstancesClient::setDeletionProtectionAsync() .
Parameters | |
---|---|
Name | Description |
request |
Google\Cloud\Compute\V1\SetDeletionProtectionInstanceRequest
A request to house fields associated with the call. |
callOptions |
array
Optional. |
↳ retrySettings |
RetrySettings|array
Retry settings to use for this call. Can be a Google\ApiCore\RetrySettings object, or an associative array of retry settings parameters. See the documentation on Google\ApiCore\RetrySettings for example usage. |
Returns | |
---|---|
Type | Description |
Google\ApiCore\OperationResponse |
use Google\ApiCore\ApiException;
use Google\ApiCore\OperationResponse;
use Google\Cloud\Compute\V1\Client\InstancesClient;
use Google\Cloud\Compute\V1\SetDeletionProtectionInstanceRequest;
use Google\Rpc\Status;
/**
* @param string $project Project ID for this request.
* @param string $resource Name or id of the resource for this request.
* @param string $zone The name of the zone for this request.
*/
function set_deletion_protection_sample(string $project, string $resource, string $zone): void
{
// Create a client.
$instancesClient = new InstancesClient();
// Prepare the request message.
$request = (new SetDeletionProtectionInstanceRequest())
->setProject($project)
->setResource($resource)
->setZone($zone);
// Call the API and handle any network failures.
try {
/** @var OperationResponse $response */
$response = $instancesClient->setDeletionProtection($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]';
$resource = '[RESOURCE]';
$zone = '[ZONE]';
set_deletion_protection_sample($project, $resource, $zone);
}
setDiskAutoDelete
Sets the auto-delete flag for a disk attached to an instance.
The async variant is InstancesClient::setDiskAutoDeleteAsync() .
Parameters | |
---|---|
Name | Description |
request |
Google\Cloud\Compute\V1\SetDiskAutoDeleteInstanceRequest
A request to house fields associated with the call. |
callOptions |
array
Optional. |
↳ retrySettings |
RetrySettings|array
Retry settings to use for this call. Can be a Google\ApiCore\RetrySettings object, or an associative array of retry settings parameters. See the documentation on Google\ApiCore\RetrySettings for example usage. |
Returns | |
---|---|
Type | Description |
Google\ApiCore\OperationResponse |
use Google\ApiCore\ApiException;
use Google\ApiCore\OperationResponse;
use Google\Cloud\Compute\V1\Client\InstancesClient;
use Google\Cloud\Compute\V1\SetDiskAutoDeleteInstanceRequest;
use Google\Rpc\Status;
/**
* @param bool $autoDelete Whether to auto-delete the disk when the instance is deleted.
* @param string $deviceName The device name of the disk to modify. Make a get() request on the instance to view currently attached disks and device names.
* @param string $instance The instance name for this request.
* @param string $project Project ID for this request.
* @param string $zone The name of the zone for this request.
*/
function set_disk_auto_delete_sample(
bool $autoDelete,
string $deviceName,
string $instance,
string $project,
string $zone
): void {
// Create a client.
$instancesClient = new InstancesClient();
// Prepare the request message.
$request = (new SetDiskAutoDeleteInstanceRequest())
->setAutoDelete($autoDelete)
->setDeviceName($deviceName)
->setInstance($instance)
->setProject($project)
->setZone($zone);
// Call the API and handle any network failures.
try {
/** @var OperationResponse $response */
$response = $instancesClient->setDiskAutoDelete($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
{
$autoDelete = false;
$deviceName = '[DEVICE_NAME]';
$instance = '[INSTANCE]';
$project = '[PROJECT]';
$zone = '[ZONE]';
set_disk_auto_delete_sample($autoDelete, $deviceName, $instance, $project, $zone);
}
setIamPolicy
Sets the access control policy on the specified resource. Replaces any existing policy.
The async variant is InstancesClient::setIamPolicyAsync() .
Parameters | |
---|---|
Name | Description |
request |
Google\Cloud\Compute\V1\SetIamPolicyInstanceRequest
A request to house fields associated with the call. |
callOptions |
array
Optional. |
↳ retrySettings |
RetrySettings|array
Retry settings to use for this call. Can be a Google\ApiCore\RetrySettings object, or an associative array of retry settings parameters. See the documentation on Google\ApiCore\RetrySettings for example usage. |
Returns | |
---|---|
Type | Description |
Google\Cloud\Compute\V1\Policy |
use Google\ApiCore\ApiException;
use Google\Cloud\Compute\V1\Client\InstancesClient;
use Google\Cloud\Compute\V1\Policy;
use Google\Cloud\Compute\V1\SetIamPolicyInstanceRequest;
use Google\Cloud\Compute\V1\ZoneSetPolicyRequest;
/**
* @param string $project Project ID for this request.
* @param string $resource Name or id of the resource for this request.
* @param string $zone The name of the zone for this request.
*/
function set_iam_policy_sample(string $project, string $resource, string $zone): void
{
// Create a client.
$instancesClient = new InstancesClient();
// Prepare the request message.
$zoneSetPolicyRequestResource = new ZoneSetPolicyRequest();
$request = (new SetIamPolicyInstanceRequest())
->setProject($project)
->setResource($resource)
->setZone($zone)
->setZoneSetPolicyRequestResource($zoneSetPolicyRequestResource);
// Call the API and handle any network failures.
try {
/** @var Policy $response */
$response = $instancesClient->setIamPolicy($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]';
$resource = '[RESOURCE]';
$zone = '[ZONE]';
set_iam_policy_sample($project, $resource, $zone);
}
setLabels
Sets labels on an instance. To learn more about labels, read the Labeling Resources documentation.
The async variant is InstancesClient::setLabelsAsync() .
Parameters | |
---|---|
Name | Description |
request |
Google\Cloud\Compute\V1\SetLabelsInstanceRequest
A request to house fields associated with the call. |
callOptions |
array
Optional. |
↳ retrySettings |
RetrySettings|array
Retry settings to use for this call. Can be a Google\ApiCore\RetrySettings object, or an associative array of retry settings parameters. See the documentation on Google\ApiCore\RetrySettings for example usage. |
Returns | |
---|---|
Type | Description |
Google\ApiCore\OperationResponse |
use Google\ApiCore\ApiException;
use Google\ApiCore\OperationResponse;
use Google\Cloud\Compute\V1\Client\InstancesClient;
use Google\Cloud\Compute\V1\InstancesSetLabelsRequest;
use Google\Cloud\Compute\V1\SetLabelsInstanceRequest;
use Google\Rpc\Status;
/**
* @param string $instance Name of the instance scoping this request.
* @param string $project Project ID for this request.
* @param string $zone The name of the zone for this request.
*/
function set_labels_sample(string $instance, string $project, string $zone): void
{
// Create a client.
$instancesClient = new InstancesClient();
// Prepare the request message.
$instancesSetLabelsRequestResource = new InstancesSetLabelsRequest();
$request = (new SetLabelsInstanceRequest())
->setInstance($instance)
->setInstancesSetLabelsRequestResource($instancesSetLabelsRequestResource)
->setProject($project)
->setZone($zone);
// Call the API and handle any network failures.
try {
/** @var OperationResponse $response */
$response = $instancesClient->setLabels($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
{
$instance = '[INSTANCE]';
$project = '[PROJECT]';
$zone = '[ZONE]';
set_labels_sample($instance, $project, $zone);
}
setMachineResources
Changes the number and/or type of accelerator for a stopped instance to the values specified in the request.
The async variant is InstancesClient::setMachineResourcesAsync() .
Parameters | |
---|---|
Name | Description |
request |
Google\Cloud\Compute\V1\SetMachineResourcesInstanceRequest
A request to house fields associated with the call. |
callOptions |
array
Optional. |
↳ retrySettings |
RetrySettings|array
Retry settings to use for this call. Can be a Google\ApiCore\RetrySettings object, or an associative array of retry settings parameters. See the documentation on Google\ApiCore\RetrySettings for example usage. |
Returns | |
---|---|
Type | Description |
Google\ApiCore\OperationResponse |
use Google\ApiCore\ApiException;
use Google\ApiCore\OperationResponse;
use Google\Cloud\Compute\V1\Client\InstancesClient;
use Google\Cloud\Compute\V1\InstancesSetMachineResourcesRequest;
use Google\Cloud\Compute\V1\SetMachineResourcesInstanceRequest;
use Google\Rpc\Status;
/**
* @param string $instance Name of the instance scoping this request.
* @param string $project Project ID for this request.
* @param string $zone The name of the zone for this request.
*/
function set_machine_resources_sample(string $instance, string $project, string $zone): void
{
// Create a client.
$instancesClient = new InstancesClient();
// Prepare the request message.
$instancesSetMachineResourcesRequestResource = new InstancesSetMachineResourcesRequest();
$request = (new SetMachineResourcesInstanceRequest())
->setInstance($instance)
->setInstancesSetMachineResourcesRequestResource($instancesSetMachineResourcesRequestResource)
->setProject($project)
->setZone($zone);
// Call the API and handle any network failures.
try {
/** @var OperationResponse $response */
$response = $instancesClient->setMachineResources($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
{
$instance = '[INSTANCE]';
$project = '[PROJECT]';
$zone = '[ZONE]';
set_machine_resources_sample($instance, $project, $zone);
}
setMachineType
Changes the machine type for a stopped instance to the machine type specified in the request.
The async variant is InstancesClient::setMachineTypeAsync() .
Parameters | |
---|---|
Name | Description |
request |
Google\Cloud\Compute\V1\SetMachineTypeInstanceRequest
A request to house fields associated with the call. |
callOptions |
array
Optional. |
↳ retrySettings |
RetrySettings|array
Retry settings to use for this call. Can be a Google\ApiCore\RetrySettings object, or an associative array of retry settings parameters. See the documentation on Google\ApiCore\RetrySettings for example usage. |
Returns | |
---|---|
Type | Description |
Google\ApiCore\OperationResponse |
use Google\ApiCore\ApiException;
use Google\ApiCore\OperationResponse;
use Google\Cloud\Compute\V1\Client\InstancesClient;
use Google\Cloud\Compute\V1\InstancesSetMachineTypeRequest;
use Google\Cloud\Compute\V1\SetMachineTypeInstanceRequest;
use Google\Rpc\Status;
/**
* @param string $instance Name of the instance scoping this request.
* @param string $project Project ID for this request.
* @param string $zone The name of the zone for this request.
*/
function set_machine_type_sample(string $instance, string $project, string $zone): void
{
// Create a client.
$instancesClient = new InstancesClient();
// Prepare the request message.
$instancesSetMachineTypeRequestResource = new InstancesSetMachineTypeRequest();
$request = (new SetMachineTypeInstanceRequest())
->setInstance($instance)
->setInstancesSetMachineTypeRequestResource($instancesSetMachineTypeRequestResource)
->setProject($project)
->setZone($zone);
// Call the API and handle any network failures.
try {
/** @var OperationResponse $response */
$response = $instancesClient->setMachineType($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
{
$instance = '[INSTANCE]';
$project = '[PROJECT]';
$zone = '[ZONE]';
set_machine_type_sample($instance, $project, $zone);
}
setMetadata
Sets metadata for the specified instance to the data included in the request.
The async variant is InstancesClient::setMetadataAsync() .
Parameters | |
---|---|
Name | Description |
request |
Google\Cloud\Compute\V1\SetMetadataInstanceRequest
A request to house fields associated with the call. |
callOptions |
array
Optional. |
↳ retrySettings |
RetrySettings|array
Retry settings to use for this call. Can be a Google\ApiCore\RetrySettings object, or an associative array of retry settings parameters. See the documentation on Google\ApiCore\RetrySettings for example usage. |
Returns | |
---|---|
Type | Description |
Google\ApiCore\OperationResponse |
use Google\ApiCore\ApiException;
use Google\ApiCore\OperationResponse;
use Google\Cloud\Compute\V1\Client\InstancesClient;
use Google\Cloud\Compute\V1\Metadata;
use Google\Cloud\Compute\V1\SetMetadataInstanceRequest;
use Google\Rpc\Status;
/**
* @param string $instance Name of the instance scoping this request.
* @param string $project Project ID for this request.
* @param string $zone The name of the zone for this request.
*/
function set_metadata_sample(string $instance, string $project, string $zone): void
{
// Create a client.
$instancesClient = new InstancesClient();
// Prepare the request message.
$metadataResource = new Metadata();
$request = (new SetMetadataInstanceRequest())
->setInstance($instance)
->setMetadataResource($metadataResource)
->setProject($project)
->setZone($zone);
// Call the API and handle any network failures.
try {
/** @var OperationResponse $response */
$response = $instancesClient->setMetadata($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
{
$instance = '[INSTANCE]';
$project = '[PROJECT]';
$zone = '[ZONE]';
set_metadata_sample($instance, $project, $zone);
}
setMinCpuPlatform
Changes the minimum CPU platform that this instance should use. This method can only be called on a stopped instance. For more information, read Specifying a Minimum CPU Platform.
The async variant is InstancesClient::setMinCpuPlatformAsync() .
Parameters | |
---|---|
Name | Description |
request |
Google\Cloud\Compute\V1\SetMinCpuPlatformInstanceRequest
A request to house fields associated with the call. |
callOptions |
array
Optional. |
↳ retrySettings |
RetrySettings|array
Retry settings to use for this call. Can be a Google\ApiCore\RetrySettings object, or an associative array of retry settings parameters. See the documentation on Google\ApiCore\RetrySettings for example usage. |
Returns | |
---|---|
Type | Description |
Google\ApiCore\OperationResponse |
use Google\ApiCore\ApiException;
use Google\ApiCore\OperationResponse;
use Google\Cloud\Compute\V1\Client\InstancesClient;
use Google\Cloud\Compute\V1\InstancesSetMinCpuPlatformRequest;
use Google\Cloud\Compute\V1\SetMinCpuPlatformInstanceRequest;
use Google\Rpc\Status;
/**
* @param string $instance Name of the instance scoping this request.
* @param string $project Project ID for this request.
* @param string $zone The name of the zone for this request.
*/
function set_min_cpu_platform_sample(string $instance, string $project, string $zone): void
{
// Create a client.
$instancesClient = new InstancesClient();
// Prepare the request message.
$instancesSetMinCpuPlatformRequestResource = new InstancesSetMinCpuPlatformRequest();
$request = (new SetMinCpuPlatformInstanceRequest())
->setInstance($instance)
->setInstancesSetMinCpuPlatformRequestResource($instancesSetMinCpuPlatformRequestResource)
->setProject($project)
->setZone($zone);
// Call the API and handle any network failures.
try {
/** @var OperationResponse $response */
$response = $instancesClient->setMinCpuPlatform($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
{
$instance = '[INSTANCE]';
$project = '[PROJECT]';
$zone = '[ZONE]';
set_min_cpu_platform_sample($instance, $project, $zone);
}
setName
Sets name of an instance.
The async variant is InstancesClient::setNameAsync() .
Parameters | |
---|---|
Name | Description |
request |
Google\Cloud\Compute\V1\SetNameInstanceRequest
A request to house fields associated with the call. |
callOptions |
array
Optional. |
↳ retrySettings |
RetrySettings|array
Retry settings to use for this call. Can be a Google\ApiCore\RetrySettings object, or an associative array of retry settings parameters. See the documentation on Google\ApiCore\RetrySettings for example usage. |
Returns | |
---|---|
Type | Description |
Google\ApiCore\OperationResponse |
use Google\ApiCore\ApiException;
use Google\ApiCore\OperationResponse;
use Google\Cloud\Compute\V1\Client\InstancesClient;
use Google\Cloud\Compute\V1\InstancesSetNameRequest;
use Google\Cloud\Compute\V1\SetNameInstanceRequest;
use Google\Rpc\Status;
/**
* @param string $instance The instance name for this request.
* @param string $project Project ID for this request.
* @param string $zone The name of the zone for this request.
*/
function set_name_sample(string $instance, string $project, string $zone): void
{
// Create a client.
$instancesClient = new InstancesClient();
// Prepare the request message.
$instancesSetNameRequestResource = new InstancesSetNameRequest();
$request = (new SetNameInstanceRequest())
->setInstance($instance)
->setInstancesSetNameRequestResource($instancesSetNameRequestResource)
->setProject($project)
->setZone($zone);
// Call the API and handle any network failures.
try {
/** @var OperationResponse $response */
$response = $instancesClient->setName($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
{
$instance = '[INSTANCE]';
$project = '[PROJECT]';
$zone = '[ZONE]';
set_name_sample($instance, $project, $zone);
}
setScheduling
Sets an instance's scheduling options. You can only call this method on a stopped instance, that is, a VM instance that is in a TERMINATED
state. See Instance Life Cycle for more information on the possible instance states. For more information about setting scheduling options for a VM, see Set VM host maintenance policy.
The async variant is InstancesClient::setSchedulingAsync() .
Parameters | |
---|---|
Name | Description |
request |
Google\Cloud\Compute\V1\SetSchedulingInstanceRequest
A request to house fields associated with the call. |
callOptions |
array
Optional. |
↳ retrySettings |
RetrySettings|array
Retry settings to use for this call. Can be a Google\ApiCore\RetrySettings object, or an associative array of retry settings parameters. See the documentation on Google\ApiCore\RetrySettings for example usage. |
Returns | |
---|---|
Type | Description |
Google\ApiCore\OperationResponse |
use Google\ApiCore\ApiException;
use Google\ApiCore\OperationResponse;
use Google\Cloud\Compute\V1\Client\InstancesClient;
use Google\Cloud\Compute\V1\Scheduling;
use Google\Cloud\Compute\V1\SetSchedulingInstanceRequest;
use Google\Rpc\Status;
/**
* @param string $instance Instance name for this request.
* @param string $project Project ID for this request.
* @param string $zone The name of the zone for this request.
*/
function set_scheduling_sample(string $instance, string $project, string $zone): void
{
// Create a client.
$instancesClient = new InstancesClient();
// Prepare the request message.
$schedulingResource = new Scheduling();
$request = (new SetSchedulingInstanceRequest())
->setInstance($instance)
->setProject($project)
->setSchedulingResource($schedulingResource)
->setZone($zone);
// Call the API and handle any network failures.
try {
/** @var OperationResponse $response */
$response = $instancesClient->setScheduling($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
{
$instance = '[INSTANCE]';
$project = '[PROJECT]';
$zone = '[ZONE]';
set_scheduling_sample($instance, $project, $zone);
}
setSecurityPolicy
Sets the Google Cloud Armor security policy for the specified instance. For more information, see Google Cloud Armor Overview
The async variant is InstancesClient::setSecurityPolicyAsync() .
Parameters | |
---|---|
Name | Description |
request |
Google\Cloud\Compute\V1\SetSecurityPolicyInstanceRequest
A request to house fields associated with the call. |
callOptions |
array
Optional. |
↳ retrySettings |
RetrySettings|array
Retry settings to use for this call. Can be a Google\ApiCore\RetrySettings object, or an associative array of retry settings parameters. See the documentation on Google\ApiCore\RetrySettings for example usage. |
Returns | |
---|---|
Type | Description |
Google\ApiCore\OperationResponse |
use Google\ApiCore\ApiException;
use Google\ApiCore\OperationResponse;
use Google\Cloud\Compute\V1\Client\InstancesClient;
use Google\Cloud\Compute\V1\InstancesSetSecurityPolicyRequest;
use Google\Cloud\Compute\V1\SetSecurityPolicyInstanceRequest;
use Google\Rpc\Status;
/**
* @param string $instance Name of the Instance resource to which the security policy should be set. The name should conform to RFC1035.
* @param string $project Project ID for this request.
* @param string $zone Name of the zone scoping this request.
*/
function set_security_policy_sample(string $instance, string $project, string $zone): void
{
// Create a client.
$instancesClient = new InstancesClient();
// Prepare the request message.
$instancesSetSecurityPolicyRequestResource = new InstancesSetSecurityPolicyRequest();
$request = (new SetSecurityPolicyInstanceRequest())
->setInstance($instance)
->setInstancesSetSecurityPolicyRequestResource($instancesSetSecurityPolicyRequestResource)
->setProject($project)
->setZone($zone);
// Call the API and handle any network failures.
try {
/** @var OperationResponse $response */
$response = $instancesClient->setSecurityPolicy($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
{
$instance = '[INSTANCE]';
$project = '[PROJECT]';
$zone = '[ZONE]';
set_security_policy_sample($instance, $project, $zone);
}
setServiceAccount
Sets the service account on the instance. For more information, read Changing the service account and access scopes for an instance.
The async variant is InstancesClient::setServiceAccountAsync() .
Parameters | |
---|---|
Name | Description |
request |
Google\Cloud\Compute\V1\SetServiceAccountInstanceRequest
A request to house fields associated with the call. |
callOptions |
array
Optional. |
↳ retrySettings |
RetrySettings|array
Retry settings to use for this call. Can be a Google\ApiCore\RetrySettings object, or an associative array of retry settings parameters. See the documentation on Google\ApiCore\RetrySettings for example usage. |
Returns | |
---|---|
Type | Description |
Google\ApiCore\OperationResponse |
use Google\ApiCore\ApiException;
use Google\ApiCore\OperationResponse;
use Google\Cloud\Compute\V1\Client\InstancesClient;
use Google\Cloud\Compute\V1\InstancesSetServiceAccountRequest;
use Google\Cloud\Compute\V1\SetServiceAccountInstanceRequest;
use Google\Rpc\Status;
/**
* @param string $instance Name of the instance resource to start.
* @param string $project Project ID for this request.
* @param string $zone The name of the zone for this request.
*/
function set_service_account_sample(string $instance, string $project, string $zone): void
{
// Create a client.
$instancesClient = new InstancesClient();
// Prepare the request message.
$instancesSetServiceAccountRequestResource = new InstancesSetServiceAccountRequest();
$request = (new SetServiceAccountInstanceRequest())
->setInstance($instance)
->setInstancesSetServiceAccountRequestResource($instancesSetServiceAccountRequestResource)
->setProject($project)
->setZone($zone);
// Call the API and handle any network failures.
try {
/** @var OperationResponse $response */
$response = $instancesClient->setServiceAccount($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
{
$instance = '[INSTANCE]';
$project = '[PROJECT]';
$zone = '[ZONE]';
set_service_account_sample($instance, $project, $zone);
}
setShieldedInstanceIntegrityPolicy
Sets the Shielded Instance integrity policy for an instance. You can only use this method on a running instance. This method supports PATCH semantics and uses the JSON merge patch format and processing rules.
The async variant is InstancesClient::setShieldedInstanceIntegrityPolicyAsync() .
Parameters | |
---|---|
Name | Description |
request |
Google\Cloud\Compute\V1\SetShieldedInstanceIntegrityPolicyInstanceRequest
A request to house fields associated with the call. |
callOptions |
array
Optional. |
↳ retrySettings |
RetrySettings|array
Retry settings to use for this call. Can be a Google\ApiCore\RetrySettings object, or an associative array of retry settings parameters. See the documentation on Google\ApiCore\RetrySettings for example usage. |
Returns | |
---|---|
Type | Description |
Google\ApiCore\OperationResponse |
use Google\ApiCore\ApiException;
use Google\ApiCore\OperationResponse;
use Google\Cloud\Compute\V1\Client\InstancesClient;
use Google\Cloud\Compute\V1\SetShieldedInstanceIntegrityPolicyInstanceRequest;
use Google\Cloud\Compute\V1\ShieldedInstanceIntegrityPolicy;
use Google\Rpc\Status;
/**
* @param string $instance Name or id of the instance scoping this request.
* @param string $project Project ID for this request.
* @param string $zone The name of the zone for this request.
*/
function set_shielded_instance_integrity_policy_sample(
string $instance,
string $project,
string $zone
): void {
// Create a client.
$instancesClient = new InstancesClient();
// Prepare the request message.
$shieldedInstanceIntegrityPolicyResource = new ShieldedInstanceIntegrityPolicy();
$request = (new SetShieldedInstanceIntegrityPolicyInstanceRequest())
->setInstance($instance)
->setProject($project)
->setShieldedInstanceIntegrityPolicyResource($shieldedInstanceIntegrityPolicyResource)
->setZone($zone);
// Call the API and handle any network failures.
try {
/** @var OperationResponse $response */
$response = $instancesClient->setShieldedInstanceIntegrityPolicy($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
{
$instance = '[INSTANCE]';
$project = '[PROJECT]';
$zone = '[ZONE]';
set_shielded_instance_integrity_policy_sample($instance, $project, $zone);
}
setTags
Sets network tags for the specified instance to the data included in the request.
The async variant is InstancesClient::setTagsAsync() .
Parameters | |
---|---|
Name | Description |
request |
Google\Cloud\Compute\V1\SetTagsInstanceRequest
A request to house fields associated with the call. |
callOptions |
array
Optional. |
↳ retrySettings |
RetrySettings|array
Retry settings to use for this call. Can be a Google\ApiCore\RetrySettings object, or an associative array of retry settings parameters. See the documentation on Google\ApiCore\RetrySettings for example usage. |
Returns | |
---|---|
Type | Description |
Google\ApiCore\OperationResponse |
use Google\ApiCore\ApiException;
use Google\ApiCore\OperationResponse;
use Google\Cloud\Compute\V1\Client\InstancesClient;
use Google\Cloud\Compute\V1\SetTagsInstanceRequest;
use Google\Cloud\Compute\V1\Tags;
use Google\Rpc\Status;
/**
* @param string $instance Name of the instance scoping this request.
* @param string $project Project ID for this request.
* @param string $zone The name of the zone for this request.
*/
function set_tags_sample(string $instance, string $project, string $zone): void
{
// Create a client.
$instancesClient = new InstancesClient();
// Prepare the request message.
$tagsResource = new Tags();
$request = (new SetTagsInstanceRequest())
->setInstance($instance)
->setProject($project)
->setTagsResource($tagsResource)
->setZone($zone);
// Call the API and handle any network failures.
try {
/** @var OperationResponse $response */
$response = $instancesClient->setTags($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
{
$instance = '[INSTANCE]';
$project = '[PROJECT]';
$zone = '[ZONE]';
set_tags_sample($instance, $project, $zone);
}
simulateMaintenanceEvent
Simulates a host maintenance event on a VM. For more information, see Simulate a host maintenance event.
The async variant is InstancesClient::simulateMaintenanceEventAsync() .
Parameters | |
---|---|
Name | Description |
request |
Google\Cloud\Compute\V1\SimulateMaintenanceEventInstanceRequest
A request to house fields associated with the call. |
callOptions |
array
Optional. |
↳ retrySettings |
RetrySettings|array
Retry settings to use for this call. Can be a Google\ApiCore\RetrySettings object, or an associative array of retry settings parameters. See the documentation on Google\ApiCore\RetrySettings for example usage. |
Returns | |
---|---|
Type | Description |
Google\ApiCore\OperationResponse |
use Google\ApiCore\ApiException;
use Google\ApiCore\OperationResponse;
use Google\Cloud\Compute\V1\Client\InstancesClient;
use Google\Cloud\Compute\V1\SimulateMaintenanceEventInstanceRequest;
use Google\Rpc\Status;
/**
* @param string $instance Name of the instance scoping this request.
* @param string $project Project ID for this request.
* @param string $zone The name of the zone for this request.
*/
function simulate_maintenance_event_sample(string $instance, string $project, string $zone): void
{
// Create a client.
$instancesClient = new InstancesClient();
// Prepare the request message.
$request = (new SimulateMaintenanceEventInstanceRequest())
->setInstance($instance)
->setProject($project)
->setZone($zone);
// Call the API and handle any network failures.
try {
/** @var OperationResponse $response */
$response = $instancesClient->simulateMaintenanceEvent($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
{
$instance = '[INSTANCE]';
$project = '[PROJECT]';
$zone = '[ZONE]';
simulate_maintenance_event_sample($instance, $project, $zone);
}
start
Starts an instance that was stopped using the instances().stop method. For more information, see Restart an instance.
The async variant is InstancesClient::startAsync() .
Parameters | |
---|---|
Name | Description |
request |
Google\Cloud\Compute\V1\StartInstanceRequest
A request to house fields associated with the call. |
callOptions |
array
Optional. |
↳ retrySettings |
RetrySettings|array
Retry settings to use for this call. Can be a Google\ApiCore\RetrySettings object, or an associative array of retry settings parameters. See the documentation on Google\ApiCore\RetrySettings for example usage. |
Returns | |
---|---|
Type | Description |
Google\ApiCore\OperationResponse |
use Google\ApiCore\ApiException;
use Google\ApiCore\OperationResponse;
use Google\Cloud\Compute\V1\Client\InstancesClient;
use Google\Cloud\Compute\V1\StartInstanceRequest;
use Google\Rpc\Status;
/**
* @param string $instance Name of the instance resource to start.
* @param string $project Project ID for this request.
* @param string $zone The name of the zone for this request.
*/
function start_sample(string $instance, string $project, string $zone): void
{
// Create a client.
$instancesClient = new InstancesClient();
// Prepare the request message.
$request = (new StartInstanceRequest())
->setInstance($instance)
->setProject($project)
->setZone($zone);
// Call the API and handle any network failures.
try {
/** @var OperationResponse $response */
$response = $instancesClient->start($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
{
$instance = '[INSTANCE]';
$project = '[PROJECT]';
$zone = '[ZONE]';
start_sample($instance, $project, $zone);
}
startWithEncryptionKey
Starts an instance that was stopped using the instances().stop method. For more information, see Restart an instance.
The async variant is InstancesClient::startWithEncryptionKeyAsync() .
Parameters | |
---|---|
Name | Description |
request |
Google\Cloud\Compute\V1\StartWithEncryptionKeyInstanceRequest
A request to house fields associated with the call. |
callOptions |
array
Optional. |
↳ retrySettings |
RetrySettings|array
Retry settings to use for this call. Can be a Google\ApiCore\RetrySettings object, or an associative array of retry settings parameters. See the documentation on Google\ApiCore\RetrySettings for example usage. |
Returns | |
---|---|
Type | Description |
Google\ApiCore\OperationResponse |
use Google\ApiCore\ApiException;
use Google\ApiCore\OperationResponse;
use Google\Cloud\Compute\V1\Client\InstancesClient;
use Google\Cloud\Compute\V1\InstancesStartWithEncryptionKeyRequest;
use Google\Cloud\Compute\V1\StartWithEncryptionKeyInstanceRequest;
use Google\Rpc\Status;
/**
* @param string $instance Name of the instance resource to start.
* @param string $project Project ID for this request.
* @param string $zone The name of the zone for this request.
*/
function start_with_encryption_key_sample(string $instance, string $project, string $zone): void
{
// Create a client.
$instancesClient = new InstancesClient();
// Prepare the request message.
$instancesStartWithEncryptionKeyRequestResource = new InstancesStartWithEncryptionKeyRequest();
$request = (new StartWithEncryptionKeyInstanceRequest())
->setInstance($instance)
->setInstancesStartWithEncryptionKeyRequestResource($instancesStartWithEncryptionKeyRequestResource)
->setProject($project)
->setZone($zone);
// Call the API and handle any network failures.
try {
/** @var OperationResponse $response */
$response = $instancesClient->startWithEncryptionKey($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
{
$instance = '[INSTANCE]';
$project = '[PROJECT]';
$zone = '[ZONE]';
start_with_encryption_key_sample($instance, $project, $zone);
}
stop
Stops a running instance, shutting it down cleanly, and allows you to restart the instance at a later time. Stopped instances do not incur VM usage charges while they are stopped. However, resources that the VM is using, such as persistent disks and static IP addresses, will continue to be charged until they are deleted. For more information, see Stopping an instance.
The async variant is InstancesClient::stopAsync() .
Parameters | |
---|---|
Name | Description |
request |
Google\Cloud\Compute\V1\StopInstanceRequest
A request to house fields associated with the call. |
callOptions |
array
Optional. |
↳ retrySettings |
RetrySettings|array
Retry settings to use for this call. Can be a Google\ApiCore\RetrySettings object, or an associative array of retry settings parameters. See the documentation on Google\ApiCore\RetrySettings for example usage. |
Returns | |
---|---|
Type | Description |
Google\ApiCore\OperationResponse |
use Google\ApiCore\ApiException;
use Google\ApiCore\OperationResponse;
use Google\Cloud\Compute\V1\Client\InstancesClient;
use Google\Cloud\Compute\V1\StopInstanceRequest;
use Google\Rpc\Status;
/**
* @param string $instance Name of the instance resource to stop.
* @param string $project Project ID for this request.
* @param string $zone The name of the zone for this request.
*/
function stop_sample(string $instance, string $project, string $zone): void
{
// Create a client.
$instancesClient = new InstancesClient();
// Prepare the request message.
$request = (new StopInstanceRequest())
->setInstance($instance)
->setProject($project)
->setZone($zone);
// Call the API and handle any network failures.
try {
/** @var OperationResponse $response */
$response = $instancesClient->stop($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
{
$instance = '[INSTANCE]';
$project = '[PROJECT]';
$zone = '[ZONE]';
stop_sample($instance, $project, $zone);
}
suspend
This method suspends a running instance, saving its state to persistent storage, and allows you to resume the instance at a later time. Suspended instances have no compute costs (cores or RAM), and incur only storage charges for the saved VM memory and localSSD data. Any charged resources the virtual machine was using, such as persistent disks and static IP addresses, will continue to be charged while the instance is suspended. For more information, see Suspending and resuming an instance.
The async variant is InstancesClient::suspendAsync() .
Parameters | |
---|---|
Name | Description |
request |
Google\Cloud\Compute\V1\SuspendInstanceRequest
A request to house fields associated with the call. |
callOptions |
array
Optional. |
↳ retrySettings |
RetrySettings|array
Retry settings to use for this call. Can be a Google\ApiCore\RetrySettings object, or an associative array of retry settings parameters. See the documentation on Google\ApiCore\RetrySettings for example usage. |
Returns | |
---|---|
Type | Description |
Google\ApiCore\OperationResponse |
use Google\ApiCore\ApiException;
use Google\ApiCore\OperationResponse;
use Google\Cloud\Compute\V1\Client\InstancesClient;
use Google\Cloud\Compute\V1\SuspendInstanceRequest;
use Google\Rpc\Status;
/**
* @param string $instance Name of the instance resource to suspend.
* @param string $project Project ID for this request.
* @param string $zone The name of the zone for this request.
*/
function suspend_sample(string $instance, string $project, string $zone): void
{
// Create a client.
$instancesClient = new InstancesClient();
// Prepare the request message.
$request = (new SuspendInstanceRequest())
->setInstance($instance)
->setProject($project)
->setZone($zone);
// Call the API and handle any network failures.
try {
/** @var OperationResponse $response */
$response = $instancesClient->suspend($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
{
$instance = '[INSTANCE]';
$project = '[PROJECT]';
$zone = '[ZONE]';
suspend_sample($instance, $project, $zone);
}
testIamPermissions
Returns permissions that a caller has on the specified resource.
The async variant is InstancesClient::testIamPermissionsAsync() .
Parameters | |
---|---|
Name | Description |
request |
Google\Cloud\Compute\V1\TestIamPermissionsInstanceRequest
A request to house fields associated with the call. |
callOptions |
array
Optional. |
↳ retrySettings |
RetrySettings|array
Retry settings to use for this call. Can be a Google\ApiCore\RetrySettings object, or an associative array of retry settings parameters. See the documentation on Google\ApiCore\RetrySettings for example usage. |
Returns | |
---|---|
Type | Description |
Google\Cloud\Compute\V1\TestPermissionsResponse |
use Google\ApiCore\ApiException;
use Google\Cloud\Compute\V1\Client\InstancesClient;
use Google\Cloud\Compute\V1\TestIamPermissionsInstanceRequest;
use Google\Cloud\Compute\V1\TestPermissionsRequest;
use Google\Cloud\Compute\V1\TestPermissionsResponse;
/**
* @param string $project Project ID for this request.
* @param string $resource Name or id of the resource for this request.
* @param string $zone The name of the zone for this request.
*/
function test_iam_permissions_sample(string $project, string $resource, string $zone): void
{
// Create a client.
$instancesClient = new InstancesClient();
// Prepare the request message.
$testPermissionsRequestResource = new TestPermissionsRequest();
$request = (new TestIamPermissionsInstanceRequest())
->setProject($project)
->setResource($resource)
->setTestPermissionsRequestResource($testPermissionsRequestResource)
->setZone($zone);
// Call the API and handle any network failures.
try {
/** @var TestPermissionsResponse $response */
$response = $instancesClient->testIamPermissions($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]';
$resource = '[RESOURCE]';
$zone = '[ZONE]';
test_iam_permissions_sample($project, $resource, $zone);
}
update
Updates an instance only if the necessary resources are available. This method can update only a specific set of instance properties. See Updating a running instance for a list of updatable instance properties.
The async variant is InstancesClient::updateAsync() .
Parameters | |
---|---|
Name | Description |
request |
Google\Cloud\Compute\V1\UpdateInstanceRequest
A request to house fields associated with the call. |
callOptions |
array
Optional. |
↳ retrySettings |
RetrySettings|array
Retry settings to use for this call. Can be a Google\ApiCore\RetrySettings object, or an associative array of retry settings parameters. See the documentation on Google\ApiCore\RetrySettings for example usage. |
Returns | |
---|---|
Type | Description |
Google\ApiCore\OperationResponse |
use Google\ApiCore\ApiException;
use Google\ApiCore\OperationResponse;
use Google\Cloud\Compute\V1\Client\InstancesClient;
use Google\Cloud\Compute\V1\Instance;
use Google\Cloud\Compute\V1\UpdateInstanceRequest;
use Google\Rpc\Status;
/**
* @param string $instance Name of the instance resource to update.
* @param string $project Project ID for this request.
* @param string $zone The name of the zone for this request.
*/
function update_sample(string $instance, string $project, string $zone): void
{
// Create a client.
$instancesClient = new InstancesClient();
// Prepare the request message.
$instanceResource = new Instance();
$request = (new UpdateInstanceRequest())
->setInstance($instance)
->setInstanceResource($instanceResource)
->setProject($project)
->setZone($zone);
// Call the API and handle any network failures.
try {
/** @var OperationResponse $response */
$response = $instancesClient->update($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
{
$instance = '[INSTANCE]';
$project = '[PROJECT]';
$zone = '[ZONE]';
update_sample($instance, $project, $zone);
}
updateAccessConfig
Updates the specified access config from an instance's network interface with the data included in the request. This method supports PATCH semantics and uses the JSON merge patch format and processing rules.
The async variant is InstancesClient::updateAccessConfigAsync() .
Parameters | |
---|---|
Name | Description |
request |
Google\Cloud\Compute\V1\UpdateAccessConfigInstanceRequest
A request to house fields associated with the call. |
callOptions |
array
Optional. |
↳ retrySettings |
RetrySettings|array
Retry settings to use for this call. Can be a Google\ApiCore\RetrySettings object, or an associative array of retry settings parameters. See the documentation on Google\ApiCore\RetrySettings for example usage. |
Returns | |
---|---|
Type | Description |
Google\ApiCore\OperationResponse |
use Google\ApiCore\ApiException;
use Google\ApiCore\OperationResponse;
use Google\Cloud\Compute\V1\AccessConfig;
use Google\Cloud\Compute\V1\Client\InstancesClient;
use Google\Cloud\Compute\V1\UpdateAccessConfigInstanceRequest;
use Google\Rpc\Status;
/**
* @param string $instance The instance name for this request.
* @param string $networkInterface The name of the network interface where the access config is attached.
* @param string $project Project ID for this request.
* @param string $zone The name of the zone for this request.
*/
function update_access_config_sample(
string $instance,
string $networkInterface,
string $project,
string $zone
): void {
// Create a client.
$instancesClient = new InstancesClient();
// Prepare the request message.
$accessConfigResource = new AccessConfig();
$request = (new UpdateAccessConfigInstanceRequest())
->setAccessConfigResource($accessConfigResource)
->setInstance($instance)
->setNetworkInterface($networkInterface)
->setProject($project)
->setZone($zone);
// Call the API and handle any network failures.
try {
/** @var OperationResponse $response */
$response = $instancesClient->updateAccessConfig($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
{
$instance = '[INSTANCE]';
$networkInterface = '[NETWORK_INTERFACE]';
$project = '[PROJECT]';
$zone = '[ZONE]';
update_access_config_sample($instance, $networkInterface, $project, $zone);
}
updateDisplayDevice
Updates the Display config for a VM instance. You can only use this method on a stopped VM instance. This method supports PATCH semantics and uses the JSON merge patch format and processing rules.
The async variant is InstancesClient::updateDisplayDeviceAsync() .
Parameters | |
---|---|
Name | Description |
request |
Google\Cloud\Compute\V1\UpdateDisplayDeviceInstanceRequest
A request to house fields associated with the call. |
callOptions |
array
Optional. |
↳ retrySettings |
RetrySettings|array
Retry settings to use for this call. Can be a Google\ApiCore\RetrySettings object, or an associative array of retry settings parameters. See the documentation on Google\ApiCore\RetrySettings for example usage. |
Returns | |
---|---|
Type | Description |
Google\ApiCore\OperationResponse |
use Google\ApiCore\ApiException;
use Google\ApiCore\OperationResponse;
use Google\Cloud\Compute\V1\Client\InstancesClient;
use Google\Cloud\Compute\V1\DisplayDevice;
use Google\Cloud\Compute\V1\UpdateDisplayDeviceInstanceRequest;
use Google\Rpc\Status;
/**
* @param string $instance Name of the instance scoping this request.
* @param string $project Project ID for this request.
* @param string $zone The name of the zone for this request.
*/
function update_display_device_sample(string $instance, string $project, string $zone): void
{
// Create a client.
$instancesClient = new InstancesClient();
// Prepare the request message.
$displayDeviceResource = new DisplayDevice();
$request = (new UpdateDisplayDeviceInstanceRequest())
->setDisplayDeviceResource($displayDeviceResource)
->setInstance($instance)
->setProject($project)
->setZone($zone);
// Call the API and handle any network failures.
try {
/** @var OperationResponse $response */
$response = $instancesClient->updateDisplayDevice($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
{
$instance = '[INSTANCE]';
$project = '[PROJECT]';
$zone = '[ZONE]';
update_display_device_sample($instance, $project, $zone);
}
updateNetworkInterface
Updates an instance's network interface. This method can only update an interface's alias IP range and attached network. See Modifying alias IP ranges for an existing instance for instructions on changing alias IP ranges. See Migrating a VM between networks for instructions on migrating an interface. This method follows PATCH semantics.
The async variant is InstancesClient::updateNetworkInterfaceAsync() .
Parameters | |
---|---|
Name | Description |
request |
Google\Cloud\Compute\V1\UpdateNetworkInterfaceInstanceRequest
A request to house fields associated with the call. |
callOptions |
array
Optional. |
↳ retrySettings |
RetrySettings|array
Retry settings to use for this call. Can be a Google\ApiCore\RetrySettings object, or an associative array of retry settings parameters. See the documentation on Google\ApiCore\RetrySettings for example usage. |
Returns | |
---|---|
Type | Description |
Google\ApiCore\OperationResponse |
use Google\ApiCore\ApiException;
use Google\ApiCore\OperationResponse;
use Google\Cloud\Compute\V1\Client\InstancesClient;
use Google\Cloud\Compute\V1\NetworkInterface;
use Google\Cloud\Compute\V1\UpdateNetworkInterfaceInstanceRequest;
use Google\Rpc\Status;
/**
* @param string $instance The instance name for this request.
* @param string $networkInterface The name of the network interface to update.
* @param string $project Project ID for this request.
* @param string $zone The name of the zone for this request.
*/
function update_network_interface_sample(
string $instance,
string $networkInterface,
string $project,
string $zone
): void {
// Create a client.
$instancesClient = new InstancesClient();
// Prepare the request message.
$networkInterfaceResource = new NetworkInterface();
$request = (new UpdateNetworkInterfaceInstanceRequest())
->setInstance($instance)
->setNetworkInterface($networkInterface)
->setNetworkInterfaceResource($networkInterfaceResource)
->setProject($project)
->setZone($zone);
// Call the API and handle any network failures.
try {
/** @var OperationResponse $response */
$response = $instancesClient->updateNetworkInterface($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
{
$instance = '[INSTANCE]';
$networkInterface = '[NETWORK_INTERFACE]';
$project = '[PROJECT]';
$zone = '[ZONE]';
update_network_interface_sample($instance, $networkInterface, $project, $zone);
}
updateShieldedInstanceConfig
Updates the Shielded Instance config for an instance. You can only use this method on a stopped instance. This method supports PATCH semantics and uses the JSON merge patch format and processing rules.
The async variant is InstancesClient::updateShieldedInstanceConfigAsync() .
Parameters | |
---|---|
Name | Description |
request |
Google\Cloud\Compute\V1\UpdateShieldedInstanceConfigInstanceRequest
A request to house fields associated with the call. |
callOptions |
array
Optional. |
↳ retrySettings |
RetrySettings|array
Retry settings to use for this call. Can be a Google\ApiCore\RetrySettings object, or an associative array of retry settings parameters. See the documentation on Google\ApiCore\RetrySettings for example usage. |
Returns | |
---|---|
Type | Description |
Google\ApiCore\OperationResponse |
use Google\ApiCore\ApiException;
use Google\ApiCore\OperationResponse;
use Google\Cloud\Compute\V1\Client\InstancesClient;
use Google\Cloud\Compute\V1\ShieldedInstanceConfig;
use Google\Cloud\Compute\V1\UpdateShieldedInstanceConfigInstanceRequest;
use Google\Rpc\Status;
/**
* @param string $instance Name or id of the instance scoping this request.
* @param string $project Project ID for this request.
* @param string $zone The name of the zone for this request.
*/
function update_shielded_instance_config_sample(
string $instance,
string $project,
string $zone
): void {
// Create a client.
$instancesClient = new InstancesClient();
// Prepare the request message.
$shieldedInstanceConfigResource = new ShieldedInstanceConfig();
$request = (new UpdateShieldedInstanceConfigInstanceRequest())
->setInstance($instance)
->setProject($project)
->setShieldedInstanceConfigResource($shieldedInstanceConfigResource)
->setZone($zone);
// Call the API and handle any network failures.
try {
/** @var OperationResponse $response */
$response = $instancesClient->updateShieldedInstanceConfig($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
{
$instance = '[INSTANCE]';
$project = '[PROJECT]';
$zone = '[ZONE]';
update_shielded_instance_config_sample($instance, $project, $zone);
}
addAccessConfigAsync
Parameters | |
---|---|
Name | Description |
request |
Google\Cloud\Compute\V1\AddAccessConfigInstanceRequest
|
optionalArgs |
array
|
Returns | |
---|---|
Type | Description |
GuzzleHttp\Promise\PromiseInterface<Google\ApiCore\OperationResponse> |
addResourcePoliciesAsync
Parameters | |
---|---|
Name | Description |
request |
Google\Cloud\Compute\V1\AddResourcePoliciesInstanceRequest
|
optionalArgs |
array
|
Returns | |
---|---|
Type | Description |
GuzzleHttp\Promise\PromiseInterface<Google\ApiCore\OperationResponse> |
aggregatedListAsync
Parameters | |
---|---|
Name | Description |
request |
Google\Cloud\Compute\V1\AggregatedListInstancesRequest
|
optionalArgs |
array
|
Returns | |
---|---|
Type | Description |
GuzzleHttp\Promise\PromiseInterface<Google\ApiCore\PagedListResponse> |
attachDiskAsync
Parameters | |
---|---|
Name | Description |
request |
Google\Cloud\Compute\V1\AttachDiskInstanceRequest
|
optionalArgs |
array
|
Returns | |
---|---|
Type | Description |
GuzzleHttp\Promise\PromiseInterface<Google\ApiCore\OperationResponse> |
bulkInsertAsync
Parameters | |
---|---|
Name | Description |
request |
Google\Cloud\Compute\V1\BulkInsertInstanceRequest
|
optionalArgs |
array
|
Returns | |
---|---|
Type | Description |
GuzzleHttp\Promise\PromiseInterface<Google\ApiCore\OperationResponse> |
deleteAsync
Parameters | |
---|---|
Name | Description |
request |
Google\Cloud\Compute\V1\DeleteInstanceRequest
|
optionalArgs |
array
|
Returns | |
---|---|
Type | Description |
GuzzleHttp\Promise\PromiseInterface<Google\ApiCore\OperationResponse> |
deleteAccessConfigAsync
Parameters | |
---|---|
Name | Description |
request |
Google\Cloud\Compute\V1\DeleteAccessConfigInstanceRequest
|
optionalArgs |
array
|
Returns | |
---|---|
Type | Description |
GuzzleHttp\Promise\PromiseInterface<Google\ApiCore\OperationResponse> |
detachDiskAsync
Parameters | |
---|---|
Name | Description |
request |
Google\Cloud\Compute\V1\DetachDiskInstanceRequest
|
optionalArgs |
array
|
Returns | |
---|---|
Type | Description |
GuzzleHttp\Promise\PromiseInterface<Google\ApiCore\OperationResponse> |
getAsync
Parameters | |
---|---|
Name | Description |
request |
Google\Cloud\Compute\V1\GetInstanceRequest
|
optionalArgs |
array
|
Returns | |
---|---|
Type | Description |
GuzzleHttp\Promise\PromiseInterface<Google\Cloud\Compute\V1\Instance> |
getEffectiveFirewallsAsync
Parameters | |
---|---|
Name | Description |
request |
Google\Cloud\Compute\V1\GetEffectiveFirewallsInstanceRequest
|
optionalArgs |
array
|
Returns | |
---|---|
Type | Description |
GuzzleHttp\Promise\PromiseInterface<Google\Cloud\Compute\V1\InstancesGetEffectiveFirewallsResponse> |
getGuestAttributesAsync
Parameters | |
---|---|
Name | Description |
request |
Google\Cloud\Compute\V1\GetGuestAttributesInstanceRequest
|
optionalArgs |
array
|
Returns | |
---|---|
Type | Description |
GuzzleHttp\Promise\PromiseInterface<Google\Cloud\Compute\V1\GuestAttributes> |
getIamPolicyAsync
Parameters | |
---|---|
Name | Description |
request |
Google\Cloud\Compute\V1\GetIamPolicyInstanceRequest
|
optionalArgs |
array
|
Returns | |
---|---|
Type | Description |
GuzzleHttp\Promise\PromiseInterface<Google\Cloud\Compute\V1\Policy> |
getScreenshotAsync
Parameters | |
---|---|
Name | Description |
request |
Google\Cloud\Compute\V1\GetScreenshotInstanceRequest
|
optionalArgs |
array
|
Returns | |
---|---|
Type | Description |
GuzzleHttp\Promise\PromiseInterface<Google\Cloud\Compute\V1\Screenshot> |
getSerialPortOutputAsync
Parameters | |
---|---|
Name | Description |
request |
Google\Cloud\Compute\V1\GetSerialPortOutputInstanceRequest
|
optionalArgs |
array
|
Returns | |
---|---|
Type | Description |
GuzzleHttp\Promise\PromiseInterface<Google\Cloud\Compute\V1\SerialPortOutput> |
getShieldedInstanceIdentityAsync
Parameters | |
---|---|
Name | Description |
request |
Google\Cloud\Compute\V1\GetShieldedInstanceIdentityInstanceRequest
|
optionalArgs |
array
|
Returns | |
---|---|
Type | Description |
GuzzleHttp\Promise\PromiseInterface<Google\Cloud\Compute\V1\ShieldedInstanceIdentity> |
insertAsync
Parameters | |
---|---|
Name | Description |
request |
Google\Cloud\Compute\V1\InsertInstanceRequest
|
optionalArgs |
array
|
Returns | |
---|---|
Type | Description |
GuzzleHttp\Promise\PromiseInterface<Google\ApiCore\OperationResponse> |
listAsync
Parameters | |
---|---|
Name | Description |
request |
Google\Cloud\Compute\V1\ListInstancesRequest
|
optionalArgs |
array
|
Returns | |
---|---|
Type | Description |
GuzzleHttp\Promise\PromiseInterface<Google\ApiCore\PagedListResponse> |
listReferrersAsync
Parameters | |
---|---|
Name | Description |
request |
Google\Cloud\Compute\V1\ListReferrersInstancesRequest
|
optionalArgs |
array
|
Returns | |
---|---|
Type | Description |
GuzzleHttp\Promise\PromiseInterface<Google\ApiCore\PagedListResponse> |
performMaintenanceAsync
Parameters | |
---|---|
Name | Description |
request |
Google\Cloud\Compute\V1\PerformMaintenanceInstanceRequest
|
optionalArgs |
array
|
Returns | |
---|---|
Type | Description |
GuzzleHttp\Promise\PromiseInterface<Google\ApiCore\OperationResponse> |
removeResourcePoliciesAsync
Parameters | |
---|---|
Name | Description |
request |
Google\Cloud\Compute\V1\RemoveResourcePoliciesInstanceRequest
|
optionalArgs |
array
|
Returns | |
---|---|
Type | Description |
GuzzleHttp\Promise\PromiseInterface<Google\ApiCore\OperationResponse> |
resetAsync
Parameters | |
---|---|
Name | Description |
request |
Google\Cloud\Compute\V1\ResetInstanceRequest
|
optionalArgs |
array
|
Returns | |
---|---|
Type | Description |
GuzzleHttp\Promise\PromiseInterface<Google\ApiCore\OperationResponse> |
resumeAsync
Parameters | |
---|---|
Name | Description |
request |
Google\Cloud\Compute\V1\ResumeInstanceRequest
|
optionalArgs |
array
|
Returns | |
---|---|
Type | Description |
GuzzleHttp\Promise\PromiseInterface<Google\ApiCore\OperationResponse> |
sendDiagnosticInterruptAsync
Parameters | |
---|---|
Name | Description |
request |
Google\Cloud\Compute\V1\SendDiagnosticInterruptInstanceRequest
|
optionalArgs |
array
|
Returns | |
---|---|
Type | Description |
GuzzleHttp\Promise\PromiseInterface<Google\Cloud\Compute\V1\SendDiagnosticInterruptInstanceResponse> |
setDeletionProtectionAsync
Parameters | |
---|---|
Name | Description |
request |
Google\Cloud\Compute\V1\SetDeletionProtectionInstanceRequest
|
optionalArgs |
array
|
Returns | |
---|---|
Type | Description |
GuzzleHttp\Promise\PromiseInterface<Google\ApiCore\OperationResponse> |
setDiskAutoDeleteAsync
Parameters | |
---|---|
Name | Description |
request |
Google\Cloud\Compute\V1\SetDiskAutoDeleteInstanceRequest
|
optionalArgs |
array
|
Returns | |
---|---|
Type | Description |
GuzzleHttp\Promise\PromiseInterface<Google\ApiCore\OperationResponse> |
setIamPolicyAsync
Parameters | |
---|---|
Name | Description |
request |
Google\Cloud\Compute\V1\SetIamPolicyInstanceRequest
|
optionalArgs |
array
|
Returns | |
---|---|
Type | Description |
GuzzleHttp\Promise\PromiseInterface<Google\Cloud\Compute\V1\Policy> |
setLabelsAsync
Parameters | |
---|---|
Name | Description |
request |
Google\Cloud\Compute\V1\SetLabelsInstanceRequest
|
optionalArgs |
array
|
Returns | |
---|---|
Type | Description |
GuzzleHttp\Promise\PromiseInterface<Google\ApiCore\OperationResponse> |
setMachineResourcesAsync
Parameters | |
---|---|
Name | Description |
request |
Google\Cloud\Compute\V1\SetMachineResourcesInstanceRequest
|
optionalArgs |
array
|
Returns | |
---|---|
Type | Description |
GuzzleHttp\Promise\PromiseInterface<Google\ApiCore\OperationResponse> |
setMachineTypeAsync
Parameters | |
---|---|
Name | Description |
request |
Google\Cloud\Compute\V1\SetMachineTypeInstanceRequest
|
optionalArgs |
array
|
Returns | |
---|---|
Type | Description |
GuzzleHttp\Promise\PromiseInterface<Google\ApiCore\OperationResponse> |
setMetadataAsync
Parameters | |
---|---|
Name | Description |
request |
Google\Cloud\Compute\V1\SetMetadataInstanceRequest
|
optionalArgs |
array
|
Returns | |
---|---|
Type | Description |
GuzzleHttp\Promise\PromiseInterface<Google\ApiCore\OperationResponse> |
setMinCpuPlatformAsync
Parameters | |
---|---|
Name | Description |
request |
Google\Cloud\Compute\V1\SetMinCpuPlatformInstanceRequest
|
optionalArgs |
array
|
Returns | |
---|---|
Type | Description |
GuzzleHttp\Promise\PromiseInterface<Google\ApiCore\OperationResponse> |
setNameAsync
Parameters | |
---|---|
Name | Description |
request |
Google\Cloud\Compute\V1\SetNameInstanceRequest
|
optionalArgs |
array
|
Returns | |
---|---|
Type | Description |
GuzzleHttp\Promise\PromiseInterface<Google\ApiCore\OperationResponse> |
setSchedulingAsync
Parameters | |
---|---|
Name | Description |
request |
Google\Cloud\Compute\V1\SetSchedulingInstanceRequest
|
optionalArgs |
array
|
Returns | |
---|---|
Type | Description |
GuzzleHttp\Promise\PromiseInterface<Google\ApiCore\OperationResponse> |
setSecurityPolicyAsync
Parameters | |
---|---|
Name | Description |
request |
Google\Cloud\Compute\V1\SetSecurityPolicyInstanceRequest
|
optionalArgs |
array
|
Returns | |
---|---|
Type | Description |
GuzzleHttp\Promise\PromiseInterface<Google\ApiCore\OperationResponse> |
setServiceAccountAsync
Parameters | |
---|---|
Name | Description |
request |
Google\Cloud\Compute\V1\SetServiceAccountInstanceRequest
|
optionalArgs |
array
|
Returns | |
---|---|
Type | Description |
GuzzleHttp\Promise\PromiseInterface<Google\ApiCore\OperationResponse> |
setShieldedInstanceIntegrityPolicyAsync
Parameters | |
---|---|
Name | Description |
request |
Google\Cloud\Compute\V1\SetShieldedInstanceIntegrityPolicyInstanceRequest
|
optionalArgs |
array
|
Returns | |
---|---|
Type | Description |
GuzzleHttp\Promise\PromiseInterface<Google\ApiCore\OperationResponse> |
setTagsAsync
Parameters | |
---|---|
Name | Description |
request |
Google\Cloud\Compute\V1\SetTagsInstanceRequest
|
optionalArgs |
array
|
Returns | |
---|---|
Type | Description |
GuzzleHttp\Promise\PromiseInterface<Google\ApiCore\OperationResponse> |
simulateMaintenanceEventAsync
Parameters | |
---|---|
Name | Description |
request |
Google\Cloud\Compute\V1\SimulateMaintenanceEventInstanceRequest
|
optionalArgs |
array
|
Returns | |
---|---|
Type | Description |
GuzzleHttp\Promise\PromiseInterface<Google\ApiCore\OperationResponse> |
startAsync
Parameters | |
---|---|
Name | Description |
request |
Google\Cloud\Compute\V1\StartInstanceRequest
|
optionalArgs |
array
|
Returns | |
---|---|
Type | Description |
GuzzleHttp\Promise\PromiseInterface<Google\ApiCore\OperationResponse> |
startWithEncryptionKeyAsync
Parameters | |
---|---|
Name | Description |
request |
Google\Cloud\Compute\V1\StartWithEncryptionKeyInstanceRequest
|
optionalArgs |
array
|
Returns | |
---|---|
Type | Description |
GuzzleHttp\Promise\PromiseInterface<Google\ApiCore\OperationResponse> |
stopAsync
Parameters | |
---|---|
Name | Description |
request |
Google\Cloud\Compute\V1\StopInstanceRequest
|
optionalArgs |
array
|
Returns | |
---|---|
Type | Description |
GuzzleHttp\Promise\PromiseInterface<Google\ApiCore\OperationResponse> |
suspendAsync
Parameters | |
---|---|
Name | Description |
request |
Google\Cloud\Compute\V1\SuspendInstanceRequest
|
optionalArgs |
array
|
Returns | |
---|---|
Type | Description |
GuzzleHttp\Promise\PromiseInterface<Google\ApiCore\OperationResponse> |
testIamPermissionsAsync
Parameters | |
---|---|
Name | Description |
request |
Google\Cloud\Compute\V1\TestIamPermissionsInstanceRequest
|
optionalArgs |
array
|
Returns | |
---|---|
Type | Description |
GuzzleHttp\Promise\PromiseInterface<Google\Cloud\Compute\V1\TestPermissionsResponse> |
updateAsync
Parameters | |
---|---|
Name | Description |
request |
Google\Cloud\Compute\V1\UpdateInstanceRequest
|
optionalArgs |
array
|
Returns | |
---|---|
Type | Description |
GuzzleHttp\Promise\PromiseInterface<Google\ApiCore\OperationResponse> |
updateAccessConfigAsync
Parameters | |
---|---|
Name | Description |
request |
Google\Cloud\Compute\V1\UpdateAccessConfigInstanceRequest
|
optionalArgs |
array
|
Returns | |
---|---|
Type | Description |
GuzzleHttp\Promise\PromiseInterface<Google\ApiCore\OperationResponse> |
updateDisplayDeviceAsync
Parameters | |
---|---|
Name | Description |
request |
Google\Cloud\Compute\V1\UpdateDisplayDeviceInstanceRequest
|
optionalArgs |
array
|
Returns | |
---|---|
Type | Description |
GuzzleHttp\Promise\PromiseInterface<Google\ApiCore\OperationResponse> |
updateNetworkInterfaceAsync
Parameters | |
---|---|
Name | Description |
request |
Google\Cloud\Compute\V1\UpdateNetworkInterfaceInstanceRequest
|
optionalArgs |
array
|
Returns | |
---|---|
Type | Description |
GuzzleHttp\Promise\PromiseInterface<Google\ApiCore\OperationResponse> |
updateShieldedInstanceConfigAsync
Parameters | |
---|---|
Name | Description |
request |
Google\Cloud\Compute\V1\UpdateShieldedInstanceConfigInstanceRequest
|
optionalArgs |
array
|
Returns | |
---|---|
Type | Description |
GuzzleHttp\Promise\PromiseInterface<Google\ApiCore\OperationResponse> |
getOperationsClient
Return an ZoneOperationsClient object with the same endpoint as $this.
Returns | |
---|---|
Type | Description |
Google\Cloud\Compute\V1\ZoneOperationsClient |
resumeOperation
Resume an existing long running operation that was previously started by a long running API method. If $methodName is not provided, or does not match a long running API method, then the operation can still be resumed, but the OperationResponse object will not deserialize the final response.
Parameters | |
---|---|
Name | Description |
operationName |
string
The name of the long running operation |
methodName |
string
The name of the method used to start the operation |
Returns | |
---|---|
Type | Description |
Google\ApiCore\OperationResponse |