Compute V1 Client - Class InstanceGroupManagersClient (1.22.0)

Reference documentation and code samples for the Compute V1 Client class InstanceGroupManagersClient.

Service Description: The InstanceGroupManagers 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 \ Client

Methods

__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 false.

↳ 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 rest. Advanced usage: Additionally, it is possible to pass in an already instantiated Google\ApiCore\Transport\TransportInterface object. Note that when this object is provided, any settings in $transportConfig, and any $apiEndpoint setting, will be ignored.

↳ 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

abandonInstances

Flags the specified instances to be removed from the managed instance group. Abandoning an instance does not delete the instance, but it does remove the instance from any target pools that are applied by the managed instance group. This method reduces the targetSize of the managed instance group by the number of instances that you abandon. This operation is marked as DONE when the action is scheduled even if the instances have not yet been removed from the group. You must separately verify the status of the abandoning action with the listmanagedinstances method. If the group is part of a backend service that has enabled connection draining, it can take up to 60 seconds after the connection draining duration has elapsed before the VM instance is removed or deleted. You can specify a maximum of 1000 instances with this method per request.

The async variant is InstanceGroupManagersClient::abandonInstancesAsync() .

Parameters
Name Description
request Google\Cloud\Compute\V1\AbandonInstancesInstanceGroupManagerRequest

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
Example
use Google\ApiCore\ApiException;
use Google\ApiCore\OperationResponse;
use Google\Cloud\Compute\V1\AbandonInstancesInstanceGroupManagerRequest;
use Google\Cloud\Compute\V1\Client\InstanceGroupManagersClient;
use Google\Cloud\Compute\V1\InstanceGroupManagersAbandonInstancesRequest;
use Google\Rpc\Status;

/**
 * @param string $instanceGroupManager The name of the managed instance group.
 * @param string $project              Project ID for this request.
 * @param string $zone                 The name of the zone where the managed instance group is located.
 */
function abandon_instances_sample(
    string $instanceGroupManager,
    string $project,
    string $zone
): void {
    // Create a client.
    $instanceGroupManagersClient = new InstanceGroupManagersClient();

    // Prepare the request message.
    $instanceGroupManagersAbandonInstancesRequestResource = new InstanceGroupManagersAbandonInstancesRequest();
    $request = (new AbandonInstancesInstanceGroupManagerRequest())
        ->setInstanceGroupManager($instanceGroupManager)
        ->setInstanceGroupManagersAbandonInstancesRequestResource(
            $instanceGroupManagersAbandonInstancesRequestResource
        )
        ->setProject($project)
        ->setZone($zone);

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

    abandon_instances_sample($instanceGroupManager, $project, $zone);
}

aggregatedList

Retrieves the list of managed instance groups and groups them by zone. To prevent failure, Google recommends that you set the returnPartialSuccess parameter to true.

The async variant is InstanceGroupManagersClient::aggregatedListAsync() .

Parameters
Name Description
request Google\Cloud\Compute\V1\AggregatedListInstanceGroupManagersRequest

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
Example
use Google\ApiCore\ApiException;
use Google\ApiCore\PagedListResponse;
use Google\Cloud\Compute\V1\AggregatedListInstanceGroupManagersRequest;
use Google\Cloud\Compute\V1\Client\InstanceGroupManagersClient;

/**
 * @param string $project Project ID for this request.
 */
function aggregated_list_sample(string $project): void
{
    // Create a client.
    $instanceGroupManagersClient = new InstanceGroupManagersClient();

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

    // Call the API and handle any network failures.
    try {
        /** @var PagedListResponse $response */
        $response = $instanceGroupManagersClient->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);
}

applyUpdatesToInstances

Applies changes to selected instances on the managed instance group. This method can be used to apply new overrides and/or new versions.

The async variant is InstanceGroupManagersClient::applyUpdatesToInstancesAsync() .

Parameters
Name Description
request Google\Cloud\Compute\V1\ApplyUpdatesToInstancesInstanceGroupManagerRequest

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
Example
use Google\ApiCore\ApiException;
use Google\ApiCore\OperationResponse;
use Google\Cloud\Compute\V1\ApplyUpdatesToInstancesInstanceGroupManagerRequest;
use Google\Cloud\Compute\V1\Client\InstanceGroupManagersClient;
use Google\Cloud\Compute\V1\InstanceGroupManagersApplyUpdatesRequest;
use Google\Rpc\Status;

/**
 * @param string $instanceGroupManager The name of the managed instance group, should conform to RFC1035.
 * @param string $project              Project ID for this request.
 * @param string $zone                 The name of the zone where the managed instance group is located. Should conform to RFC1035.
 */
function apply_updates_to_instances_sample(
    string $instanceGroupManager,
    string $project,
    string $zone
): void {
    // Create a client.
    $instanceGroupManagersClient = new InstanceGroupManagersClient();

    // Prepare the request message.
    $instanceGroupManagersApplyUpdatesRequestResource = new InstanceGroupManagersApplyUpdatesRequest();
    $request = (new ApplyUpdatesToInstancesInstanceGroupManagerRequest())
        ->setInstanceGroupManager($instanceGroupManager)
        ->setInstanceGroupManagersApplyUpdatesRequestResource(
            $instanceGroupManagersApplyUpdatesRequestResource
        )
        ->setProject($project)
        ->setZone($zone);

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

    apply_updates_to_instances_sample($instanceGroupManager, $project, $zone);
}

createInstances

Creates instances with per-instance configurations in this managed instance group. Instances are created using the current instance template. The create instances operation is marked DONE if the createInstances request is successful. The underlying actions take additional time. You must separately verify the status of the creating or actions with the listmanagedinstances method.

The async variant is InstanceGroupManagersClient::createInstancesAsync() .

Parameters
Name Description
request Google\Cloud\Compute\V1\CreateInstancesInstanceGroupManagerRequest

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
Example
use Google\ApiCore\ApiException;
use Google\ApiCore\OperationResponse;
use Google\Cloud\Compute\V1\Client\InstanceGroupManagersClient;
use Google\Cloud\Compute\V1\CreateInstancesInstanceGroupManagerRequest;
use Google\Cloud\Compute\V1\InstanceGroupManagersCreateInstancesRequest;
use Google\Rpc\Status;

/**
 * @param string $instanceGroupManager The name of the managed instance group. It should conform to RFC1035.
 * @param string $project              Project ID for this request.
 * @param string $zone                 The name of the zone where the managed instance group is located. It should conform to RFC1035.
 */
function create_instances_sample(
    string $instanceGroupManager,
    string $project,
    string $zone
): void {
    // Create a client.
    $instanceGroupManagersClient = new InstanceGroupManagersClient();

    // Prepare the request message.
    $instanceGroupManagersCreateInstancesRequestResource = new InstanceGroupManagersCreateInstancesRequest();
    $request = (new CreateInstancesInstanceGroupManagerRequest())
        ->setInstanceGroupManager($instanceGroupManager)
        ->setInstanceGroupManagersCreateInstancesRequestResource(
            $instanceGroupManagersCreateInstancesRequestResource
        )
        ->setProject($project)
        ->setZone($zone);

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

    create_instances_sample($instanceGroupManager, $project, $zone);
}

delete

Deletes the specified managed instance group and all of the instances in that group. Note that the instance group must not belong to a backend service. Read Deleting an instance group for more information.

The async variant is InstanceGroupManagersClient::deleteAsync() .

Parameters
Name Description
request Google\Cloud\Compute\V1\DeleteInstanceGroupManagerRequest

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
Example
use Google\ApiCore\ApiException;
use Google\ApiCore\OperationResponse;
use Google\Cloud\Compute\V1\Client\InstanceGroupManagersClient;
use Google\Cloud\Compute\V1\DeleteInstanceGroupManagerRequest;
use Google\Rpc\Status;

/**
 * @param string $instanceGroupManager The name of the managed instance group to delete.
 * @param string $project              Project ID for this request.
 * @param string $zone                 The name of the zone where the managed instance group is located.
 */
function delete_sample(string $instanceGroupManager, string $project, string $zone): void
{
    // Create a client.
    $instanceGroupManagersClient = new InstanceGroupManagersClient();

    // Prepare the request message.
    $request = (new DeleteInstanceGroupManagerRequest())
        ->setInstanceGroupManager($instanceGroupManager)
        ->setProject($project)
        ->setZone($zone);

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

    delete_sample($instanceGroupManager, $project, $zone);
}

deleteInstances

Flags the specified instances in the managed instance group for immediate deletion. The instances are also removed from any target pools of which they were a member. This method reduces the targetSize of the managed instance group by the number of instances that you delete. This operation is marked as DONE when the action is scheduled even if the instances are still being deleted. You must separately verify the status of the deleting action with the listmanagedinstances method. If the group is part of a backend service that has enabled connection draining, it can take up to 60 seconds after the connection draining duration has elapsed before the VM instance is removed or deleted. You can specify a maximum of 1000 instances with this method per request.

The async variant is InstanceGroupManagersClient::deleteInstancesAsync() .

Parameters
Name Description
request Google\Cloud\Compute\V1\DeleteInstancesInstanceGroupManagerRequest

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
Example
use Google\ApiCore\ApiException;
use Google\ApiCore\OperationResponse;
use Google\Cloud\Compute\V1\Client\InstanceGroupManagersClient;
use Google\Cloud\Compute\V1\DeleteInstancesInstanceGroupManagerRequest;
use Google\Cloud\Compute\V1\InstanceGroupManagersDeleteInstancesRequest;
use Google\Rpc\Status;

/**
 * @param string $instanceGroupManager The name of the managed instance group.
 * @param string $project              Project ID for this request.
 * @param string $zone                 The name of the zone where the managed instance group is located.
 */
function delete_instances_sample(
    string $instanceGroupManager,
    string $project,
    string $zone
): void {
    // Create a client.
    $instanceGroupManagersClient = new InstanceGroupManagersClient();

    // Prepare the request message.
    $instanceGroupManagersDeleteInstancesRequestResource = new InstanceGroupManagersDeleteInstancesRequest();
    $request = (new DeleteInstancesInstanceGroupManagerRequest())
        ->setInstanceGroupManager($instanceGroupManager)
        ->setInstanceGroupManagersDeleteInstancesRequestResource(
            $instanceGroupManagersDeleteInstancesRequestResource
        )
        ->setProject($project)
        ->setZone($zone);

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

    delete_instances_sample($instanceGroupManager, $project, $zone);
}

deletePerInstanceConfigs

Deletes selected per-instance configurations for the managed instance group.

The async variant is InstanceGroupManagersClient::deletePerInstanceConfigsAsync() .

Parameters
Name Description
request Google\Cloud\Compute\V1\DeletePerInstanceConfigsInstanceGroupManagerRequest

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
Example
use Google\ApiCore\ApiException;
use Google\ApiCore\OperationResponse;
use Google\Cloud\Compute\V1\Client\InstanceGroupManagersClient;
use Google\Cloud\Compute\V1\DeletePerInstanceConfigsInstanceGroupManagerRequest;
use Google\Cloud\Compute\V1\InstanceGroupManagersDeletePerInstanceConfigsReq;
use Google\Rpc\Status;

/**
 * @param string $instanceGroupManager The name of the managed instance group. It should conform to RFC1035.
 * @param string $project              Project ID for this request.
 * @param string $zone                 The name of the zone where the managed instance group is located. It should conform to RFC1035.
 */
function delete_per_instance_configs_sample(
    string $instanceGroupManager,
    string $project,
    string $zone
): void {
    // Create a client.
    $instanceGroupManagersClient = new InstanceGroupManagersClient();

    // Prepare the request message.
    $instanceGroupManagersDeletePerInstanceConfigsReqResource = new InstanceGroupManagersDeletePerInstanceConfigsReq();
    $request = (new DeletePerInstanceConfigsInstanceGroupManagerRequest())
        ->setInstanceGroupManager($instanceGroupManager)
        ->setInstanceGroupManagersDeletePerInstanceConfigsReqResource(
            $instanceGroupManagersDeletePerInstanceConfigsReqResource
        )
        ->setProject($project)
        ->setZone($zone);

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

    delete_per_instance_configs_sample($instanceGroupManager, $project, $zone);
}

get

Returns all of the details about the specified managed instance group.

The async variant is InstanceGroupManagersClient::getAsync() .

Parameters
Name Description
request Google\Cloud\Compute\V1\GetInstanceGroupManagerRequest

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\InstanceGroupManager
Example
use Google\ApiCore\ApiException;
use Google\Cloud\Compute\V1\Client\InstanceGroupManagersClient;
use Google\Cloud\Compute\V1\GetInstanceGroupManagerRequest;
use Google\Cloud\Compute\V1\InstanceGroupManager;

/**
 * @param string $instanceGroupManager The name of the managed instance group.
 * @param string $project              Project ID for this request.
 * @param string $zone                 The name of the zone where the managed instance group is located.
 */
function get_sample(string $instanceGroupManager, string $project, string $zone): void
{
    // Create a client.
    $instanceGroupManagersClient = new InstanceGroupManagersClient();

    // Prepare the request message.
    $request = (new GetInstanceGroupManagerRequest())
        ->setInstanceGroupManager($instanceGroupManager)
        ->setProject($project)
        ->setZone($zone);

    // Call the API and handle any network failures.
    try {
        /** @var InstanceGroupManager $response */
        $response = $instanceGroupManagersClient->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
{
    $instanceGroupManager = '[INSTANCE_GROUP_MANAGER]';
    $project = '[PROJECT]';
    $zone = '[ZONE]';

    get_sample($instanceGroupManager, $project, $zone);
}

insert

Creates a managed instance group using the information that you specify in the request. After the group is created, instances in the group are created using the specified instance template. This operation is marked as DONE when the group is created even if the instances in the group have not yet been created. You must separately verify the status of the individual instances with the listmanagedinstances method. A managed instance group can have up to 1000 VM instances per group. Please contact Cloud Support if you need an increase in this limit.

The async variant is InstanceGroupManagersClient::insertAsync() .

Parameters
Name Description
request Google\Cloud\Compute\V1\InsertInstanceGroupManagerRequest

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
Example
use Google\ApiCore\ApiException;
use Google\ApiCore\OperationResponse;
use Google\Cloud\Compute\V1\Client\InstanceGroupManagersClient;
use Google\Cloud\Compute\V1\InsertInstanceGroupManagerRequest;
use Google\Cloud\Compute\V1\InstanceGroupManager;
use Google\Rpc\Status;

/**
 * @param string $project Project ID for this request.
 * @param string $zone    The name of the zone where you want to create the managed instance group.
 */
function insert_sample(string $project, string $zone): void
{
    // Create a client.
    $instanceGroupManagersClient = new InstanceGroupManagersClient();

    // Prepare the request message.
    $instanceGroupManagerResource = new InstanceGroupManager();
    $request = (new InsertInstanceGroupManagerRequest())
        ->setInstanceGroupManagerResource($instanceGroupManagerResource)
        ->setProject($project)
        ->setZone($zone);

    // Call the API and handle any network failures.
    try {
        /** @var OperationResponse $response */
        $response = $instanceGroupManagersClient->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 a list of managed instance groups that are contained within the specified project and zone.

The async variant is InstanceGroupManagersClient::listAsync() .

Parameters
Name Description
request Google\Cloud\Compute\V1\ListInstanceGroupManagersRequest

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
Example
use Google\ApiCore\ApiException;
use Google\ApiCore\PagedListResponse;
use Google\Cloud\Compute\V1\Client\InstanceGroupManagersClient;
use Google\Cloud\Compute\V1\ListInstanceGroupManagersRequest;

/**
 * @param string $project Project ID for this request.
 * @param string $zone    The name of the zone where the managed instance group is located.
 */
function list_sample(string $project, string $zone): void
{
    // Create a client.
    $instanceGroupManagersClient = new InstanceGroupManagersClient();

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

    // Call the API and handle any network failures.
    try {
        /** @var PagedListResponse $response */
        $response = $instanceGroupManagersClient->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);
}

listErrors

Lists all errors thrown by actions on instances for a given managed instance group. The filter and orderBy query parameters are not supported.

The async variant is InstanceGroupManagersClient::listErrorsAsync() .

Parameters
Name Description
request Google\Cloud\Compute\V1\ListErrorsInstanceGroupManagersRequest

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
Example
use Google\ApiCore\ApiException;
use Google\ApiCore\PagedListResponse;
use Google\Cloud\Compute\V1\Client\InstanceGroupManagersClient;
use Google\Cloud\Compute\V1\ListErrorsInstanceGroupManagersRequest;

/**
 * @param string $instanceGroupManager The name of the managed instance group. It must be a string that meets the requirements in RFC1035, or an unsigned long integer: must match regexp pattern: (?:[a-z](?:[-a-z0-9]{0,61}[a-z0-9])?)|1-9{0,19}.
 * @param string $project              Project ID for this request.
 * @param string $zone                 The name of the zone where the managed instance group is located. It should conform to RFC1035.
 */
function list_errors_sample(string $instanceGroupManager, string $project, string $zone): void
{
    // Create a client.
    $instanceGroupManagersClient = new InstanceGroupManagersClient();

    // Prepare the request message.
    $request = (new ListErrorsInstanceGroupManagersRequest())
        ->setInstanceGroupManager($instanceGroupManager)
        ->setProject($project)
        ->setZone($zone);

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

    list_errors_sample($instanceGroupManager, $project, $zone);
}

listManagedInstances

Lists all of the instances in the managed instance group. Each instance in the list has a currentAction, which indicates the action that the managed instance group is performing on the instance. For example, if the group is still creating an instance, the currentAction is CREATING. If a previous action failed, the list displays the errors for that failed action. The orderBy query parameter is not supported. The pageToken query parameter is supported only if the group's listManagedInstancesResults field is set to PAGINATED.

The async variant is InstanceGroupManagersClient::listManagedInstancesAsync() .

Parameters
Name Description
request Google\Cloud\Compute\V1\ListManagedInstancesInstanceGroupManagersRequest

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
Example
use Google\ApiCore\ApiException;
use Google\ApiCore\PagedListResponse;
use Google\Cloud\Compute\V1\Client\InstanceGroupManagersClient;
use Google\Cloud\Compute\V1\ListManagedInstancesInstanceGroupManagersRequest;

/**
 * @param string $instanceGroupManager The name of the managed instance group.
 * @param string $project              Project ID for this request.
 * @param string $zone                 The name of the zone where the managed instance group is located.
 */
function list_managed_instances_sample(
    string $instanceGroupManager,
    string $project,
    string $zone
): void {
    // Create a client.
    $instanceGroupManagersClient = new InstanceGroupManagersClient();

    // Prepare the request message.
    $request = (new ListManagedInstancesInstanceGroupManagersRequest())
        ->setInstanceGroupManager($instanceGroupManager)
        ->setProject($project)
        ->setZone($zone);

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

    list_managed_instances_sample($instanceGroupManager, $project, $zone);
}

listPerInstanceConfigs

Lists all of the per-instance configurations defined for the managed instance group. The orderBy query parameter is not supported.

The async variant is InstanceGroupManagersClient::listPerInstanceConfigsAsync() .

Parameters
Name Description
request Google\Cloud\Compute\V1\ListPerInstanceConfigsInstanceGroupManagersRequest

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
Example
use Google\ApiCore\ApiException;
use Google\ApiCore\PagedListResponse;
use Google\Cloud\Compute\V1\Client\InstanceGroupManagersClient;
use Google\Cloud\Compute\V1\ListPerInstanceConfigsInstanceGroupManagersRequest;

/**
 * @param string $instanceGroupManager The name of the managed instance group. It should conform to RFC1035.
 * @param string $project              Project ID for this request.
 * @param string $zone                 The name of the zone where the managed instance group is located. It should conform to RFC1035.
 */
function list_per_instance_configs_sample(
    string $instanceGroupManager,
    string $project,
    string $zone
): void {
    // Create a client.
    $instanceGroupManagersClient = new InstanceGroupManagersClient();

    // Prepare the request message.
    $request = (new ListPerInstanceConfigsInstanceGroupManagersRequest())
        ->setInstanceGroupManager($instanceGroupManager)
        ->setProject($project)
        ->setZone($zone);

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

    list_per_instance_configs_sample($instanceGroupManager, $project, $zone);
}

patch

Updates a managed instance group using the information that you specify in the request. This operation is marked as DONE when the group is patched even if the instances in the group are still in the process of being patched. You must separately verify the status of the individual instances with the listManagedInstances method. This method supports PATCH semantics and uses the JSON merge patch format and processing rules. If you update your group to specify a new template or instance configuration, it's possible that your intended specification for each VM in the group is different from the current state of that VM. To learn how to apply an updated configuration to the VMs in a MIG, see Updating instances in a MIG.

The async variant is InstanceGroupManagersClient::patchAsync() .

Parameters
Name Description
request Google\Cloud\Compute\V1\PatchInstanceGroupManagerRequest

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
Example
use Google\ApiCore\ApiException;
use Google\ApiCore\OperationResponse;
use Google\Cloud\Compute\V1\Client\InstanceGroupManagersClient;
use Google\Cloud\Compute\V1\InstanceGroupManager;
use Google\Cloud\Compute\V1\PatchInstanceGroupManagerRequest;
use Google\Rpc\Status;

/**
 * @param string $instanceGroupManager The name of the instance group manager.
 * @param string $project              Project ID for this request.
 * @param string $zone                 The name of the zone where you want to create the managed instance group.
 */
function patch_sample(string $instanceGroupManager, string $project, string $zone): void
{
    // Create a client.
    $instanceGroupManagersClient = new InstanceGroupManagersClient();

    // Prepare the request message.
    $instanceGroupManagerResource = new InstanceGroupManager();
    $request = (new PatchInstanceGroupManagerRequest())
        ->setInstanceGroupManager($instanceGroupManager)
        ->setInstanceGroupManagerResource($instanceGroupManagerResource)
        ->setProject($project)
        ->setZone($zone);

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

    patch_sample($instanceGroupManager, $project, $zone);
}

patchPerInstanceConfigs

Inserts or patches per-instance configurations for the managed instance group. perInstanceConfig.name serves as a key used to distinguish whether to perform insert or patch.

The async variant is InstanceGroupManagersClient::patchPerInstanceConfigsAsync() .

Parameters
Name Description
request Google\Cloud\Compute\V1\PatchPerInstanceConfigsInstanceGroupManagerRequest

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
Example
use Google\ApiCore\ApiException;
use Google\ApiCore\OperationResponse;
use Google\Cloud\Compute\V1\Client\InstanceGroupManagersClient;
use Google\Cloud\Compute\V1\InstanceGroupManagersPatchPerInstanceConfigsReq;
use Google\Cloud\Compute\V1\PatchPerInstanceConfigsInstanceGroupManagerRequest;
use Google\Rpc\Status;

/**
 * @param string $instanceGroupManager The name of the managed instance group. It should conform to RFC1035.
 * @param string $project              Project ID for this request.
 * @param string $zone                 The name of the zone where the managed instance group is located. It should conform to RFC1035.
 */
function patch_per_instance_configs_sample(
    string $instanceGroupManager,
    string $project,
    string $zone
): void {
    // Create a client.
    $instanceGroupManagersClient = new InstanceGroupManagersClient();

    // Prepare the request message.
    $instanceGroupManagersPatchPerInstanceConfigsReqResource = new InstanceGroupManagersPatchPerInstanceConfigsReq();
    $request = (new PatchPerInstanceConfigsInstanceGroupManagerRequest())
        ->setInstanceGroupManager($instanceGroupManager)
        ->setInstanceGroupManagersPatchPerInstanceConfigsReqResource(
            $instanceGroupManagersPatchPerInstanceConfigsReqResource
        )
        ->setProject($project)
        ->setZone($zone);

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

    patch_per_instance_configs_sample($instanceGroupManager, $project, $zone);
}

recreateInstances

Flags the specified VM instances in the managed instance group to be immediately recreated. Each instance is recreated using the group's current configuration. This operation is marked as DONE when the flag is set even if the instances have not yet been recreated. You must separately verify the status of each instance by checking its currentAction field; for more information, see Checking the status of managed instances. If the group is part of a backend service that has enabled connection draining, it can take up to 60 seconds after the connection draining duration has elapsed before the VM instance is removed or deleted. You can specify a maximum of 1000 instances with this method per request.

The async variant is InstanceGroupManagersClient::recreateInstancesAsync() .

Parameters
Name Description
request Google\Cloud\Compute\V1\RecreateInstancesInstanceGroupManagerRequest

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
Example
use Google\ApiCore\ApiException;
use Google\ApiCore\OperationResponse;
use Google\Cloud\Compute\V1\Client\InstanceGroupManagersClient;
use Google\Cloud\Compute\V1\InstanceGroupManagersRecreateInstancesRequest;
use Google\Cloud\Compute\V1\RecreateInstancesInstanceGroupManagerRequest;
use Google\Rpc\Status;

/**
 * @param string $instanceGroupManager The name of the managed instance group.
 * @param string $project              Project ID for this request.
 * @param string $zone                 The name of the zone where the managed instance group is located.
 */
function recreate_instances_sample(
    string $instanceGroupManager,
    string $project,
    string $zone
): void {
    // Create a client.
    $instanceGroupManagersClient = new InstanceGroupManagersClient();

    // Prepare the request message.
    $instanceGroupManagersRecreateInstancesRequestResource = new InstanceGroupManagersRecreateInstancesRequest();
    $request = (new RecreateInstancesInstanceGroupManagerRequest())
        ->setInstanceGroupManager($instanceGroupManager)
        ->setInstanceGroupManagersRecreateInstancesRequestResource(
            $instanceGroupManagersRecreateInstancesRequestResource
        )
        ->setProject($project)
        ->setZone($zone);

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

    recreate_instances_sample($instanceGroupManager, $project, $zone);
}

resize

Resizes the managed instance group. If you increase the size, the group creates new instances using the current instance template. If you decrease the size, the group deletes instances. The resize operation is marked DONE when the resize actions are scheduled even if the group has not yet added or deleted any instances. You must separately verify the status of the creating or deleting actions with the listmanagedinstances method. When resizing down, the instance group arbitrarily chooses the order in which VMs are deleted. The group takes into account some VM attributes when making the selection including: + The status of the VM instance. + The health of the VM instance. + The instance template version the VM is based on. + For regional managed instance groups, the location of the VM instance. This list is subject to change. If the group is part of a backend service that has enabled connection draining, it can take up to 60 seconds after the connection draining duration has elapsed before the VM instance is removed or deleted.

The async variant is InstanceGroupManagersClient::resizeAsync() .

Parameters
Name Description
request Google\Cloud\Compute\V1\ResizeInstanceGroupManagerRequest

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
Example
use Google\ApiCore\ApiException;
use Google\ApiCore\OperationResponse;
use Google\Cloud\Compute\V1\Client\InstanceGroupManagersClient;
use Google\Cloud\Compute\V1\ResizeInstanceGroupManagerRequest;
use Google\Rpc\Status;

/**
 * @param string $instanceGroupManager The name of the managed instance group.
 * @param string $project              Project ID for this request.
 * @param int    $size                 The number of running instances that the managed instance group should maintain at any given time. The group automatically adds or removes instances to maintain the number of instances specified by this parameter.
 * @param string $zone                 The name of the zone where the managed instance group is located.
 */
function resize_sample(
    string $instanceGroupManager,
    string $project,
    int $size,
    string $zone
): void {
    // Create a client.
    $instanceGroupManagersClient = new InstanceGroupManagersClient();

    // Prepare the request message.
    $request = (new ResizeInstanceGroupManagerRequest())
        ->setInstanceGroupManager($instanceGroupManager)
        ->setProject($project)
        ->setSize($size)
        ->setZone($zone);

    // Call the API and handle any network failures.
    try {
        /** @var OperationResponse $response */
        $response = $instanceGroupManagersClient->resize($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
{
    $instanceGroupManager = '[INSTANCE_GROUP_MANAGER]';
    $project = '[PROJECT]';
    $size = 0;
    $zone = '[ZONE]';

    resize_sample($instanceGroupManager, $project, $size, $zone);
}

resumeInstances

Flags the specified instances in the managed instance group to be resumed. This method increases the targetSize and decreases the targetSuspendedSize of the managed instance group by the number of instances that you resume. The resumeInstances operation is marked DONE if the resumeInstances request is successful. The underlying actions take additional time. You must separately verify the status of the RESUMING action with the listmanagedinstances method. In this request, you can only specify instances that are suspended. For example, if an instance was previously suspended using the suspendInstances method, it can be resumed using the resumeInstances method. If a health check is attached to the managed instance group, the specified instances will be verified as healthy after they are resumed. You can specify a maximum of 1000 instances with this method per request.

The async variant is InstanceGroupManagersClient::resumeInstancesAsync() .

Parameters
Name Description
request Google\Cloud\Compute\V1\ResumeInstancesInstanceGroupManagerRequest

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
Example
use Google\ApiCore\ApiException;
use Google\ApiCore\OperationResponse;
use Google\Cloud\Compute\V1\Client\InstanceGroupManagersClient;
use Google\Cloud\Compute\V1\InstanceGroupManagersResumeInstancesRequest;
use Google\Cloud\Compute\V1\ResumeInstancesInstanceGroupManagerRequest;
use Google\Rpc\Status;

/**
 * @param string $instanceGroupManager The name of the managed instance group.
 * @param string $project              Project ID for this request.
 * @param string $zone                 The name of the zone where the managed instance group is located.
 */
function resume_instances_sample(
    string $instanceGroupManager,
    string $project,
    string $zone
): void {
    // Create a client.
    $instanceGroupManagersClient = new InstanceGroupManagersClient();

    // Prepare the request message.
    $instanceGroupManagersResumeInstancesRequestResource = new InstanceGroupManagersResumeInstancesRequest();
    $request = (new ResumeInstancesInstanceGroupManagerRequest())
        ->setInstanceGroupManager($instanceGroupManager)
        ->setInstanceGroupManagersResumeInstancesRequestResource(
            $instanceGroupManagersResumeInstancesRequestResource
        )
        ->setProject($project)
        ->setZone($zone);

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

    resume_instances_sample($instanceGroupManager, $project, $zone);
}

setInstanceTemplate

Specifies the instance template to use when creating new instances in this group. The templates for existing instances in the group do not change unless you run recreateInstances, run applyUpdatesToInstances, or set the group's updatePolicy.type to PROACTIVE.

The async variant is InstanceGroupManagersClient::setInstanceTemplateAsync() .

Parameters
Name Description
request Google\Cloud\Compute\V1\SetInstanceTemplateInstanceGroupManagerRequest

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
Example
use Google\ApiCore\ApiException;
use Google\ApiCore\OperationResponse;
use Google\Cloud\Compute\V1\Client\InstanceGroupManagersClient;
use Google\Cloud\Compute\V1\InstanceGroupManagersSetInstanceTemplateRequest;
use Google\Cloud\Compute\V1\SetInstanceTemplateInstanceGroupManagerRequest;
use Google\Rpc\Status;

/**
 * @param string $instanceGroupManager The name of the managed instance group.
 * @param string $project              Project ID for this request.
 * @param string $zone                 The name of the zone where the managed instance group is located.
 */
function set_instance_template_sample(
    string $instanceGroupManager,
    string $project,
    string $zone
): void {
    // Create a client.
    $instanceGroupManagersClient = new InstanceGroupManagersClient();

    // Prepare the request message.
    $instanceGroupManagersSetInstanceTemplateRequestResource = new InstanceGroupManagersSetInstanceTemplateRequest();
    $request = (new SetInstanceTemplateInstanceGroupManagerRequest())
        ->setInstanceGroupManager($instanceGroupManager)
        ->setInstanceGroupManagersSetInstanceTemplateRequestResource(
            $instanceGroupManagersSetInstanceTemplateRequestResource
        )
        ->setProject($project)
        ->setZone($zone);

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

    set_instance_template_sample($instanceGroupManager, $project, $zone);
}

setTargetPools

Modifies the target pools to which all instances in this managed instance group are assigned. The target pools automatically apply to all of the instances in the managed instance group. This operation is marked DONE when you make the request even if the instances have not yet been added to their target pools. The change might take some time to apply to all of the instances in the group depending on the size of the group.

The async variant is InstanceGroupManagersClient::setTargetPoolsAsync() .

Parameters
Name Description
request Google\Cloud\Compute\V1\SetTargetPoolsInstanceGroupManagerRequest

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
Example
use Google\ApiCore\ApiException;
use Google\ApiCore\OperationResponse;
use Google\Cloud\Compute\V1\Client\InstanceGroupManagersClient;
use Google\Cloud\Compute\V1\InstanceGroupManagersSetTargetPoolsRequest;
use Google\Cloud\Compute\V1\SetTargetPoolsInstanceGroupManagerRequest;
use Google\Rpc\Status;

/**
 * @param string $instanceGroupManager The name of the managed instance group.
 * @param string $project              Project ID for this request.
 * @param string $zone                 The name of the zone where the managed instance group is located.
 */
function set_target_pools_sample(
    string $instanceGroupManager,
    string $project,
    string $zone
): void {
    // Create a client.
    $instanceGroupManagersClient = new InstanceGroupManagersClient();

    // Prepare the request message.
    $instanceGroupManagersSetTargetPoolsRequestResource = new InstanceGroupManagersSetTargetPoolsRequest();
    $request = (new SetTargetPoolsInstanceGroupManagerRequest())
        ->setInstanceGroupManager($instanceGroupManager)
        ->setInstanceGroupManagersSetTargetPoolsRequestResource(
            $instanceGroupManagersSetTargetPoolsRequestResource
        )
        ->setProject($project)
        ->setZone($zone);

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

    set_target_pools_sample($instanceGroupManager, $project, $zone);
}

startInstances

Flags the specified instances in the managed instance group to be started. This method increases the targetSize and decreases the targetStoppedSize of the managed instance group by the number of instances that you start. The startInstances operation is marked DONE if the startInstances request is successful. The underlying actions take additional time. You must separately verify the status of the STARTING action with the listmanagedinstances method. In this request, you can only specify instances that are stopped. For example, if an instance was previously stopped using the stopInstances method, it can be started using the startInstances method. If a health check is attached to the managed instance group, the specified instances will be verified as healthy after they are started. You can specify a maximum of 1000 instances with this method per request.

The async variant is InstanceGroupManagersClient::startInstancesAsync() .

Parameters
Name Description
request Google\Cloud\Compute\V1\StartInstancesInstanceGroupManagerRequest

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
Example
use Google\ApiCore\ApiException;
use Google\ApiCore\OperationResponse;
use Google\Cloud\Compute\V1\Client\InstanceGroupManagersClient;
use Google\Cloud\Compute\V1\InstanceGroupManagersStartInstancesRequest;
use Google\Cloud\Compute\V1\StartInstancesInstanceGroupManagerRequest;
use Google\Rpc\Status;

/**
 * @param string $instanceGroupManager The name of the managed instance group.
 * @param string $project              Project ID for this request.
 * @param string $zone                 The name of the zone where the managed instance group is located.
 */
function start_instances_sample(string $instanceGroupManager, string $project, string $zone): void
{
    // Create a client.
    $instanceGroupManagersClient = new InstanceGroupManagersClient();

    // Prepare the request message.
    $instanceGroupManagersStartInstancesRequestResource = new InstanceGroupManagersStartInstancesRequest();
    $request = (new StartInstancesInstanceGroupManagerRequest())
        ->setInstanceGroupManager($instanceGroupManager)
        ->setInstanceGroupManagersStartInstancesRequestResource(
            $instanceGroupManagersStartInstancesRequestResource
        )
        ->setProject($project)
        ->setZone($zone);

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

    start_instances_sample($instanceGroupManager, $project, $zone);
}

stopInstances

Flags the specified instances in the managed instance group to be immediately stopped. You can only specify instances that are running in this request. This method reduces the targetSize and increases the targetStoppedSize of the managed instance group by the number of instances that you stop. The stopInstances operation is marked DONE if the stopInstances request is successful. The underlying actions take additional time. You must separately verify the status of the STOPPING action with the listmanagedinstances method. If the standbyPolicy.initialDelaySec field is set, the group delays stopping the instances until initialDelaySec have passed from instance.creationTimestamp (that is, when the instance was created). This delay gives your application time to set itself up and initialize on the instance. If more than initialDelaySec seconds have passed since instance.creationTimestamp when this method is called, there will be zero delay. If the group is part of a backend service that has enabled connection draining, it can take up to 60 seconds after the connection draining duration has elapsed before the VM instance is stopped. Stopped instances can be started using the startInstances method. You can specify a maximum of 1000 instances with this method per request.

The async variant is InstanceGroupManagersClient::stopInstancesAsync() .

Parameters
Name Description
request Google\Cloud\Compute\V1\StopInstancesInstanceGroupManagerRequest

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
Example
use Google\ApiCore\ApiException;
use Google\ApiCore\OperationResponse;
use Google\Cloud\Compute\V1\Client\InstanceGroupManagersClient;
use Google\Cloud\Compute\V1\InstanceGroupManagersStopInstancesRequest;
use Google\Cloud\Compute\V1\StopInstancesInstanceGroupManagerRequest;
use Google\Rpc\Status;

/**
 * @param string $instanceGroupManager The name of the managed instance group.
 * @param string $project              Project ID for this request.
 * @param string $zone                 The name of the zone where the managed instance group is located.
 */
function stop_instances_sample(string $instanceGroupManager, string $project, string $zone): void
{
    // Create a client.
    $instanceGroupManagersClient = new InstanceGroupManagersClient();

    // Prepare the request message.
    $instanceGroupManagersStopInstancesRequestResource = new InstanceGroupManagersStopInstancesRequest();
    $request = (new StopInstancesInstanceGroupManagerRequest())
        ->setInstanceGroupManager($instanceGroupManager)
        ->setInstanceGroupManagersStopInstancesRequestResource(
            $instanceGroupManagersStopInstancesRequestResource
        )
        ->setProject($project)
        ->setZone($zone);

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

    stop_instances_sample($instanceGroupManager, $project, $zone);
}

suspendInstances

Flags the specified instances in the managed instance group to be immediately suspended. You can only specify instances that are running in this request. This method reduces the targetSize and increases the targetSuspendedSize of the managed instance group by the number of instances that you suspend. The suspendInstances operation is marked DONE if the suspendInstances request is successful. The underlying actions take additional time. You must separately verify the status of the SUSPENDING action with the listmanagedinstances method. If the standbyPolicy.initialDelaySec field is set, the group delays suspension of the instances until initialDelaySec have passed from instance.creationTimestamp (that is, when the instance was created). This delay gives your application time to set itself up and initialize on the instance. If more than initialDelaySec seconds have passed since instance.creationTimestamp when this method is called, there will be zero delay. If the group is part of a backend service that has enabled connection draining, it can take up to 60 seconds after the connection draining duration has elapsed before the VM instance is suspended. Suspended instances can be resumed using the resumeInstances method. You can specify a maximum of 1000 instances with this method per request.

The async variant is InstanceGroupManagersClient::suspendInstancesAsync() .

Parameters
Name Description
request Google\Cloud\Compute\V1\SuspendInstancesInstanceGroupManagerRequest

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
Example
use Google\ApiCore\ApiException;
use Google\ApiCore\OperationResponse;
use Google\Cloud\Compute\V1\Client\InstanceGroupManagersClient;
use Google\Cloud\Compute\V1\InstanceGroupManagersSuspendInstancesRequest;
use Google\Cloud\Compute\V1\SuspendInstancesInstanceGroupManagerRequest;
use Google\Rpc\Status;

/**
 * @param string $instanceGroupManager The name of the managed instance group.
 * @param string $project              Project ID for this request.
 * @param string $zone                 The name of the zone where the managed instance group is located.
 */
function suspend_instances_sample(
    string $instanceGroupManager,
    string $project,
    string $zone
): void {
    // Create a client.
    $instanceGroupManagersClient = new InstanceGroupManagersClient();

    // Prepare the request message.
    $instanceGroupManagersSuspendInstancesRequestResource = new InstanceGroupManagersSuspendInstancesRequest();
    $request = (new SuspendInstancesInstanceGroupManagerRequest())
        ->setInstanceGroupManager($instanceGroupManager)
        ->setInstanceGroupManagersSuspendInstancesRequestResource(
            $instanceGroupManagersSuspendInstancesRequestResource
        )
        ->setProject($project)
        ->setZone($zone);

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

    suspend_instances_sample($instanceGroupManager, $project, $zone);
}

updatePerInstanceConfigs

Inserts or updates per-instance configurations for the managed instance group. perInstanceConfig.name serves as a key used to distinguish whether to perform insert or patch.

The async variant is InstanceGroupManagersClient::updatePerInstanceConfigsAsync() .

Parameters
Name Description
request Google\Cloud\Compute\V1\UpdatePerInstanceConfigsInstanceGroupManagerRequest

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
Example
use Google\ApiCore\ApiException;
use Google\ApiCore\OperationResponse;
use Google\Cloud\Compute\V1\Client\InstanceGroupManagersClient;
use Google\Cloud\Compute\V1\InstanceGroupManagersUpdatePerInstanceConfigsReq;
use Google\Cloud\Compute\V1\UpdatePerInstanceConfigsInstanceGroupManagerRequest;
use Google\Rpc\Status;

/**
 * @param string $instanceGroupManager The name of the managed instance group. It should conform to RFC1035.
 * @param string $project              Project ID for this request.
 * @param string $zone                 The name of the zone where the managed instance group is located. It should conform to RFC1035.
 */
function update_per_instance_configs_sample(
    string $instanceGroupManager,
    string $project,
    string $zone
): void {
    // Create a client.
    $instanceGroupManagersClient = new InstanceGroupManagersClient();

    // Prepare the request message.
    $instanceGroupManagersUpdatePerInstanceConfigsReqResource = new InstanceGroupManagersUpdatePerInstanceConfigsReq();
    $request = (new UpdatePerInstanceConfigsInstanceGroupManagerRequest())
        ->setInstanceGroupManager($instanceGroupManager)
        ->setInstanceGroupManagersUpdatePerInstanceConfigsReqResource(
            $instanceGroupManagersUpdatePerInstanceConfigsReqResource
        )
        ->setProject($project)
        ->setZone($zone);

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

    update_per_instance_configs_sample($instanceGroupManager, $project, $zone);
}

abandonInstancesAsync

Parameters
Name Description
request Google\Cloud\Compute\V1\AbandonInstancesInstanceGroupManagerRequest
optionalArgs array
Returns
Type Description
GuzzleHttp\Promise\PromiseInterface<Google\ApiCore\OperationResponse>

aggregatedListAsync

Parameters
Name Description
request Google\Cloud\Compute\V1\AggregatedListInstanceGroupManagersRequest
optionalArgs array
Returns
Type Description
GuzzleHttp\Promise\PromiseInterface<Google\ApiCore\PagedListResponse>

applyUpdatesToInstancesAsync

Parameters
Name Description
request Google\Cloud\Compute\V1\ApplyUpdatesToInstancesInstanceGroupManagerRequest
optionalArgs array
Returns
Type Description
GuzzleHttp\Promise\PromiseInterface<Google\ApiCore\OperationResponse>

createInstancesAsync

Parameters
Name Description
request Google\Cloud\Compute\V1\CreateInstancesInstanceGroupManagerRequest
optionalArgs array
Returns
Type Description
GuzzleHttp\Promise\PromiseInterface<Google\ApiCore\OperationResponse>

deleteAsync

Parameters
Name Description
request Google\Cloud\Compute\V1\DeleteInstanceGroupManagerRequest
optionalArgs array
Returns
Type Description
GuzzleHttp\Promise\PromiseInterface<Google\ApiCore\OperationResponse>

deleteInstancesAsync

Parameters
Name Description
request Google\Cloud\Compute\V1\DeleteInstancesInstanceGroupManagerRequest
optionalArgs array
Returns
Type Description
GuzzleHttp\Promise\PromiseInterface<Google\ApiCore\OperationResponse>

deletePerInstanceConfigsAsync

Parameters
Name Description
request Google\Cloud\Compute\V1\DeletePerInstanceConfigsInstanceGroupManagerRequest
optionalArgs array
Returns
Type Description
GuzzleHttp\Promise\PromiseInterface<Google\ApiCore\OperationResponse>

getAsync

Parameters
Name Description
request Google\Cloud\Compute\V1\GetInstanceGroupManagerRequest
optionalArgs array
Returns
Type Description
GuzzleHttp\Promise\PromiseInterface<Google\Cloud\Compute\V1\InstanceGroupManager>

insertAsync

Parameters
Name Description
request Google\Cloud\Compute\V1\InsertInstanceGroupManagerRequest
optionalArgs array
Returns
Type Description
GuzzleHttp\Promise\PromiseInterface<Google\ApiCore\OperationResponse>

listAsync

Parameters
Name Description
request Google\Cloud\Compute\V1\ListInstanceGroupManagersRequest
optionalArgs array
Returns
Type Description
GuzzleHttp\Promise\PromiseInterface<Google\ApiCore\PagedListResponse>

listErrorsAsync

Parameters
Name Description
request Google\Cloud\Compute\V1\ListErrorsInstanceGroupManagersRequest
optionalArgs array
Returns
Type Description
GuzzleHttp\Promise\PromiseInterface<Google\ApiCore\PagedListResponse>

listManagedInstancesAsync

Parameters
Name Description
request Google\Cloud\Compute\V1\ListManagedInstancesInstanceGroupManagersRequest
optionalArgs array
Returns
Type Description
GuzzleHttp\Promise\PromiseInterface<Google\ApiCore\PagedListResponse>

listPerInstanceConfigsAsync

Parameters
Name Description
request Google\Cloud\Compute\V1\ListPerInstanceConfigsInstanceGroupManagersRequest
optionalArgs array
Returns
Type Description
GuzzleHttp\Promise\PromiseInterface<Google\ApiCore\PagedListResponse>

patchAsync

Parameters
Name Description
request Google\Cloud\Compute\V1\PatchInstanceGroupManagerRequest
optionalArgs array
Returns
Type Description
GuzzleHttp\Promise\PromiseInterface<Google\ApiCore\OperationResponse>

patchPerInstanceConfigsAsync

Parameters
Name Description
request Google\Cloud\Compute\V1\PatchPerInstanceConfigsInstanceGroupManagerRequest
optionalArgs array
Returns
Type Description
GuzzleHttp\Promise\PromiseInterface<Google\ApiCore\OperationResponse>

recreateInstancesAsync

Parameters
Name Description
request Google\Cloud\Compute\V1\RecreateInstancesInstanceGroupManagerRequest
optionalArgs array
Returns
Type Description
GuzzleHttp\Promise\PromiseInterface<Google\ApiCore\OperationResponse>

resizeAsync

Parameters
Name Description
request Google\Cloud\Compute\V1\ResizeInstanceGroupManagerRequest
optionalArgs array
Returns
Type Description
GuzzleHttp\Promise\PromiseInterface<Google\ApiCore\OperationResponse>

resumeInstancesAsync

Parameters
Name Description
request Google\Cloud\Compute\V1\ResumeInstancesInstanceGroupManagerRequest
optionalArgs array
Returns
Type Description
GuzzleHttp\Promise\PromiseInterface<Google\ApiCore\OperationResponse>

setInstanceTemplateAsync

Parameters
Name Description
request Google\Cloud\Compute\V1\SetInstanceTemplateInstanceGroupManagerRequest
optionalArgs array
Returns
Type Description
GuzzleHttp\Promise\PromiseInterface<Google\ApiCore\OperationResponse>

setTargetPoolsAsync

Parameters
Name Description
request Google\Cloud\Compute\V1\SetTargetPoolsInstanceGroupManagerRequest
optionalArgs array
Returns
Type Description
GuzzleHttp\Promise\PromiseInterface<Google\ApiCore\OperationResponse>

startInstancesAsync

Parameters
Name Description
request Google\Cloud\Compute\V1\StartInstancesInstanceGroupManagerRequest
optionalArgs array
Returns
Type Description
GuzzleHttp\Promise\PromiseInterface<Google\ApiCore\OperationResponse>

stopInstancesAsync

Parameters
Name Description
request Google\Cloud\Compute\V1\StopInstancesInstanceGroupManagerRequest
optionalArgs array
Returns
Type Description
GuzzleHttp\Promise\PromiseInterface<Google\ApiCore\OperationResponse>

suspendInstancesAsync

Parameters
Name Description
request Google\Cloud\Compute\V1\SuspendInstancesInstanceGroupManagerRequest
optionalArgs array
Returns
Type Description
GuzzleHttp\Promise\PromiseInterface<Google\ApiCore\OperationResponse>

updatePerInstanceConfigsAsync

Parameters
Name Description
request Google\Cloud\Compute\V1\UpdatePerInstanceConfigsInstanceGroupManagerRequest
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