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. Sample code to get started:
$instanceGroupManagersClient = new InstanceGroupManagersClient();
try {
$instanceGroupManager = 'instance_group_manager';
$instanceGroupManagersAbandonInstancesRequestResource = new InstanceGroupManagersAbandonInstancesRequest();
$project = 'project';
$zone = 'zone';
$operationResponse = $instanceGroupManagersClient->abandonInstances($instanceGroupManager, $instanceGroupManagersAbandonInstancesRequestResource, $project, $zone);
$operationResponse->pollUntilComplete();
if ($operationResponse->operationSucceeded()) {
// if creating/modifying, retrieve the target resource
} else {
$error = $operationResponse->getError();
// handleError($error)
}
// Alternatively:
// start the operation, keep the operation name, and resume later
$operationResponse = $instanceGroupManagersClient->abandonInstances($instanceGroupManager, $instanceGroupManagersAbandonInstancesRequestResource, $project, $zone);
$operationName = $operationResponse->getName();
// ... do other work
$newOperationResponse = $instanceGroupManagersClient->resumeOperation($operationName, 'abandonInstances');
while (!$newOperationResponse->isDone()) {
// ... do other work
$newOperationResponse->reload();
}
if ($newOperationResponse->operationSucceeded()) {
// if creating/modifying, retrieve the target resource
} else {
$error = $newOperationResponse->getError();
// handleError($error)
}
} finally {
$instanceGroupManagersClient->close();
}
This service has a new (beta) implementation. See Google\Cloud\Compute\V1\Client\InstanceGroupManagersClient to use the new surface.
Namespace
Google \ Cloud \ Compute \ V1Methods
__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. |
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.
Parameters | |
---|---|
Name | Description |
instanceGroupManager |
string
The name of the managed instance group. |
instanceGroupManagersAbandonInstancesRequestResource |
Google\Cloud\Compute\V1\InstanceGroupManagersAbandonInstancesRequest
The body resource for this request |
project |
string
Project ID for this request. |
zone |
string
The name of the zone where the managed instance group is located. |
optionalArgs |
array
Optional. |
↳ requestId |
string
An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). |
↳ 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\InstanceGroupManagersAbandonInstancesRequest;
use Google\Cloud\Compute\V1\InstanceGroupManagersClient;
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 any non-scalar elements to be passed along with the request.
$instanceGroupManagersAbandonInstancesRequestResource = new InstanceGroupManagersAbandonInstancesRequest();
// Call the API and handle any network failures.
try {
/** @var OperationResponse $response */
$response = $instanceGroupManagersClient->abandonInstances(
$instanceGroupManager,
$instanceGroupManagersAbandonInstancesRequestResource,
$project,
$zone
);
$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.
Parameters | |
---|---|
Name | Description |
project |
string
Project ID for this request. |
optionalArgs |
array
Optional. |
↳ filter |
string
A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either |
↳ includeAllScopes |
bool
Indicates whether every visible scope for each scope type (zone, region, global) should be included in the response. For new resource types added after this field, the flag has no effect as new resource types will always include every visible scope for each scope type in response. For resource types which predate this field, if this flag is omitted or false, only scopes of the scope types where the resource type is expected to be found will be included. |
↳ maxResults |
int
The maximum number of results per page that should be returned. If the number of available results is larger than |
↳ orderBy |
string
Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using |
↳ pageToken |
string
A page token is used to specify a page of values to be returned. If no page token is specified (the default), the first page of values will be returned. Any page token used here must have been generated by a previous call to the API. |
↳ returnPartialSuccess |
bool
Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. |
↳ 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\InstanceGroupManagersClient;
/**
* @param string $project Project ID for this request.
*/
function aggregated_list_sample(string $project): void
{
// Create a client.
$instanceGroupManagersClient = new InstanceGroupManagersClient();
// Call the API and handle any network failures.
try {
/** @var PagedListResponse $response */
$response = $instanceGroupManagersClient->aggregatedList($project);
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.
Parameters | |
---|---|
Name | Description |
instanceGroupManager |
string
The name of the managed instance group, should conform to RFC1035. |
instanceGroupManagersApplyUpdatesRequestResource |
Google\Cloud\Compute\V1\InstanceGroupManagersApplyUpdatesRequest
The body resource for this request |
project |
string
Project ID for this request. |
zone |
string
The name of the zone where the managed instance group is located. Should conform to RFC1035. |
optionalArgs |
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\InstanceGroupManagersApplyUpdatesRequest;
use Google\Cloud\Compute\V1\InstanceGroupManagersClient;
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 any non-scalar elements to be passed along with the request.
$instanceGroupManagersApplyUpdatesRequestResource = new InstanceGroupManagersApplyUpdatesRequest();
// Call the API and handle any network failures.
try {
/** @var OperationResponse $response */
$response = $instanceGroupManagersClient->applyUpdatesToInstances(
$instanceGroupManager,
$instanceGroupManagersApplyUpdatesRequestResource,
$project,
$zone
);
$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.
Parameters | |
---|---|
Name | Description |
instanceGroupManager |
string
The name of the managed instance group. It should conform to RFC1035. |
instanceGroupManagersCreateInstancesRequestResource |
Google\Cloud\Compute\V1\InstanceGroupManagersCreateInstancesRequest
The body resource for this request |
project |
string
Project ID for this request. |
zone |
string
The name of the zone where the managed instance group is located. It should conform to RFC1035. |
optionalArgs |
array
Optional. |
↳ requestId |
string
An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). |
↳ 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\InstanceGroupManagersClient;
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 any non-scalar elements to be passed along with the request.
$instanceGroupManagersCreateInstancesRequestResource = new InstanceGroupManagersCreateInstancesRequest();
// Call the API and handle any network failures.
try {
/** @var OperationResponse $response */
$response = $instanceGroupManagersClient->createInstances(
$instanceGroupManager,
$instanceGroupManagersCreateInstancesRequestResource,
$project,
$zone
);
$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.
Parameters | |
---|---|
Name | Description |
instanceGroupManager |
string
The name of the managed instance group to delete. |
project |
string
Project ID for this request. |
zone |
string
The name of the zone where the managed instance group is located. |
optionalArgs |
array
Optional. |
↳ requestId |
string
An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). |
↳ 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\InstanceGroupManagersClient;
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();
// Call the API and handle any network failures.
try {
/** @var OperationResponse $response */
$response = $instanceGroupManagersClient->delete($instanceGroupManager, $project, $zone);
$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.
Parameters | |
---|---|
Name | Description |
instanceGroupManager |
string
The name of the managed instance group. |
instanceGroupManagersDeleteInstancesRequestResource |
Google\Cloud\Compute\V1\InstanceGroupManagersDeleteInstancesRequest
The body resource for this request |
project |
string
Project ID for this request. |
zone |
string
The name of the zone where the managed instance group is located. |
optionalArgs |
array
Optional. |
↳ requestId |
string
An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). |
↳ 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\InstanceGroupManagersClient;
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 any non-scalar elements to be passed along with the request.
$instanceGroupManagersDeleteInstancesRequestResource = new InstanceGroupManagersDeleteInstancesRequest();
// Call the API and handle any network failures.
try {
/** @var OperationResponse $response */
$response = $instanceGroupManagersClient->deleteInstances(
$instanceGroupManager,
$instanceGroupManagersDeleteInstancesRequestResource,
$project,
$zone
);
$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.
Parameters | |
---|---|
Name | Description |
instanceGroupManager |
string
The name of the managed instance group. It should conform to RFC1035. |
instanceGroupManagersDeletePerInstanceConfigsReqResource |
Google\Cloud\Compute\V1\InstanceGroupManagersDeletePerInstanceConfigsReq
The body resource for this request |
project |
string
Project ID for this request. |
zone |
string
The name of the zone where the managed instance group is located. It should conform to RFC1035. |
optionalArgs |
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\InstanceGroupManagersClient;
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 any non-scalar elements to be passed along with the request.
$instanceGroupManagersDeletePerInstanceConfigsReqResource = new InstanceGroupManagersDeletePerInstanceConfigsReq();
// Call the API and handle any network failures.
try {
/** @var OperationResponse $response */
$response = $instanceGroupManagersClient->deletePerInstanceConfigs(
$instanceGroupManager,
$instanceGroupManagersDeletePerInstanceConfigsReqResource,
$project,
$zone
);
$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.
Parameters | |
---|---|
Name | Description |
instanceGroupManager |
string
The name of the managed instance group. |
project |
string
Project ID for this request. |
zone |
string
The name of the zone where the managed instance group is located. |
optionalArgs |
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 |
use Google\ApiCore\ApiException;
use Google\Cloud\Compute\V1\InstanceGroupManager;
use Google\Cloud\Compute\V1\InstanceGroupManagersClient;
/**
* @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();
// Call the API and handle any network failures.
try {
/** @var InstanceGroupManager $response */
$response = $instanceGroupManagersClient->get($instanceGroupManager, $project, $zone);
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.
Parameters | |
---|---|
Name | Description |
instanceGroupManagerResource |
Google\Cloud\Compute\V1\InstanceGroupManager
The body resource for this request |
project |
string
Project ID for this request. |
zone |
string
The name of the zone where you want to create the managed instance group. |
optionalArgs |
array
Optional. |
↳ requestId |
string
An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). |
↳ 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\InstanceGroupManager;
use Google\Cloud\Compute\V1\InstanceGroupManagersClient;
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 any non-scalar elements to be passed along with the request.
$instanceGroupManagerResource = new InstanceGroupManager();
// Call the API and handle any network failures.
try {
/** @var OperationResponse $response */
$response = $instanceGroupManagersClient->insert($instanceGroupManagerResource, $project, $zone);
$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.
Parameters | |
---|---|
Name | Description |
project |
string
Project ID for this request. |
zone |
string
The name of the zone where the managed instance group is located. |
optionalArgs |
array
Optional. |
↳ filter |
string
A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either |
↳ maxResults |
int
The maximum number of results per page that should be returned. If the number of available results is larger than |
↳ orderBy |
string
Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using |
↳ pageToken |
string
A page token is used to specify a page of values to be returned. If no page token is specified (the default), the first page of values will be returned. Any page token used here must have been generated by a previous call to the API. |
↳ returnPartialSuccess |
bool
Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. |
↳ 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\InstanceGroupManagersClient;
/**
* @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();
// Call the API and handle any network failures.
try {
/** @var PagedListResponse $response */
$response = $instanceGroupManagersClient->list($project, $zone);
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.
Parameters | |
---|---|
Name | Description |
instanceGroupManager |
string
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?)|1-9{0,19}. |
project |
string
Project ID for this request. |
zone |
string
The name of the zone where the managed instance group is located. It should conform to RFC1035. |
optionalArgs |
array
Optional. |
↳ filter |
string
A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either |
↳ maxResults |
int
The maximum number of results per page that should be returned. If the number of available results is larger than |
↳ orderBy |
string
Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using |
↳ pageToken |
string
A page token is used to specify a page of values to be returned. If no page token is specified (the default), the first page of values will be returned. Any page token used here must have been generated by a previous call to the API. |
↳ returnPartialSuccess |
bool
Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. |
↳ 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\InstanceGroupManagersClient;
/**
* @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();
// Call the API and handle any network failures.
try {
/** @var PagedListResponse $response */
$response = $instanceGroupManagersClient->listErrors($instanceGroupManager, $project, $zone);
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 in the alpha and beta API and only if the group's listManagedInstancesResults
field is set to PAGINATED
.
Parameters | |
---|---|
Name | Description |
instanceGroupManager |
string
The name of the managed instance group. |
project |
string
Project ID for this request. |
zone |
string
The name of the zone where the managed instance group is located. |
optionalArgs |
array
Optional. |
↳ filter |
string
A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either |
↳ maxResults |
int
The maximum number of results per page that should be returned. If the number of available results is larger than |
↳ orderBy |
string
Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using |
↳ pageToken |
string
A page token is used to specify a page of values to be returned. If no page token is specified (the default), the first page of values will be returned. Any page token used here must have been generated by a previous call to the API. |
↳ returnPartialSuccess |
bool
Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. |
↳ 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\InstanceGroupManagersClient;
/**
* @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();
// Call the API and handle any network failures.
try {
/** @var PagedListResponse $response */
$response = $instanceGroupManagersClient->listManagedInstances(
$instanceGroupManager,
$project,
$zone
);
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.
Parameters | |
---|---|
Name | Description |
instanceGroupManager |
string
The name of the managed instance group. It should conform to RFC1035. |
project |
string
Project ID for this request. |
zone |
string
The name of the zone where the managed instance group is located. It should conform to RFC1035. |
optionalArgs |
array
Optional. |
↳ filter |
string
A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either |
↳ maxResults |
int
The maximum number of results per page that should be returned. If the number of available results is larger than |
↳ orderBy |
string
Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using |
↳ pageToken |
string
A page token is used to specify a page of values to be returned. If no page token is specified (the default), the first page of values will be returned. Any page token used here must have been generated by a previous call to the API. |
↳ returnPartialSuccess |
bool
Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. |
↳ 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\InstanceGroupManagersClient;
/**
* @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();
// Call the API and handle any network failures.
try {
/** @var PagedListResponse $response */
$response = $instanceGroupManagersClient->listPerInstanceConfigs(
$instanceGroupManager,
$project,
$zone
);
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.
Parameters | |
---|---|
Name | Description |
instanceGroupManager |
string
The name of the instance group manager. |
instanceGroupManagerResource |
Google\Cloud\Compute\V1\InstanceGroupManager
The body resource for this request |
project |
string
Project ID for this request. |
zone |
string
The name of the zone where you want to create the managed instance group. |
optionalArgs |
array
Optional. |
↳ requestId |
string
An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). |
↳ 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\InstanceGroupManager;
use Google\Cloud\Compute\V1\InstanceGroupManagersClient;
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 any non-scalar elements to be passed along with the request.
$instanceGroupManagerResource = new InstanceGroupManager();
// Call the API and handle any network failures.
try {
/** @var OperationResponse $response */
$response = $instanceGroupManagersClient->patch(
$instanceGroupManager,
$instanceGroupManagerResource,
$project,
$zone
);
$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.
Parameters | |
---|---|
Name | Description |
instanceGroupManager |
string
The name of the managed instance group. It should conform to RFC1035. |
instanceGroupManagersPatchPerInstanceConfigsReqResource |
Google\Cloud\Compute\V1\InstanceGroupManagersPatchPerInstanceConfigsReq
The body resource for this request |
project |
string
Project ID for this request. |
zone |
string
The name of the zone where the managed instance group is located. It should conform to RFC1035. |
optionalArgs |
array
Optional. |
↳ requestId |
string
An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). |
↳ 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\InstanceGroupManagersClient;
use Google\Cloud\Compute\V1\InstanceGroupManagersPatchPerInstanceConfigsReq;
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 any non-scalar elements to be passed along with the request.
$instanceGroupManagersPatchPerInstanceConfigsReqResource = new InstanceGroupManagersPatchPerInstanceConfigsReq();
// Call the API and handle any network failures.
try {
/** @var OperationResponse $response */
$response = $instanceGroupManagersClient->patchPerInstanceConfigs(
$instanceGroupManager,
$instanceGroupManagersPatchPerInstanceConfigsReqResource,
$project,
$zone
);
$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.
Parameters | |
---|---|
Name | Description |
instanceGroupManager |
string
The name of the managed instance group. |
instanceGroupManagersRecreateInstancesRequestResource |
Google\Cloud\Compute\V1\InstanceGroupManagersRecreateInstancesRequest
The body resource for this request |
project |
string
Project ID for this request. |
zone |
string
The name of the zone where the managed instance group is located. |
optionalArgs |
array
Optional. |
↳ requestId |
string
An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). |
↳ 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\InstanceGroupManagersClient;
use Google\Cloud\Compute\V1\InstanceGroupManagersRecreateInstancesRequest;
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 any non-scalar elements to be passed along with the request.
$instanceGroupManagersRecreateInstancesRequestResource = new InstanceGroupManagersRecreateInstancesRequest();
// Call the API and handle any network failures.
try {
/** @var OperationResponse $response */
$response = $instanceGroupManagersClient->recreateInstances(
$instanceGroupManager,
$instanceGroupManagersRecreateInstancesRequestResource,
$project,
$zone
);
$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.
Parameters | |
---|---|
Name | Description |
instanceGroupManager |
string
The name of the managed instance group. |
project |
string
Project ID for this request. |
size |
int
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. |
zone |
string
The name of the zone where the managed instance group is located. |
optionalArgs |
array
Optional. |
↳ requestId |
string
An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). |
↳ 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\InstanceGroupManagersClient;
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();
// Call the API and handle any network failures.
try {
/** @var OperationResponse $response */
$response = $instanceGroupManagersClient->resize($instanceGroupManager, $project, $size, $zone);
$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);
}
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.
Parameters | |
---|---|
Name | Description |
instanceGroupManager |
string
The name of the managed instance group. |
instanceGroupManagersSetInstanceTemplateRequestResource |
Google\Cloud\Compute\V1\InstanceGroupManagersSetInstanceTemplateRequest
The body resource for this request |
project |
string
Project ID for this request. |
zone |
string
The name of the zone where the managed instance group is located. |
optionalArgs |
array
Optional. |
↳ requestId |
string
An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). |
↳ 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\InstanceGroupManagersClient;
use Google\Cloud\Compute\V1\InstanceGroupManagersSetInstanceTemplateRequest;
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 any non-scalar elements to be passed along with the request.
$instanceGroupManagersSetInstanceTemplateRequestResource = new InstanceGroupManagersSetInstanceTemplateRequest();
// Call the API and handle any network failures.
try {
/** @var OperationResponse $response */
$response = $instanceGroupManagersClient->setInstanceTemplate(
$instanceGroupManager,
$instanceGroupManagersSetInstanceTemplateRequestResource,
$project,
$zone
);
$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.
Parameters | |
---|---|
Name | Description |
instanceGroupManager |
string
The name of the managed instance group. |
instanceGroupManagersSetTargetPoolsRequestResource |
Google\Cloud\Compute\V1\InstanceGroupManagersSetTargetPoolsRequest
The body resource for this request |
project |
string
Project ID for this request. |
zone |
string
The name of the zone where the managed instance group is located. |
optionalArgs |
array
Optional. |
↳ requestId |
string
An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). |
↳ 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\InstanceGroupManagersClient;
use Google\Cloud\Compute\V1\InstanceGroupManagersSetTargetPoolsRequest;
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 any non-scalar elements to be passed along with the request.
$instanceGroupManagersSetTargetPoolsRequestResource = new InstanceGroupManagersSetTargetPoolsRequest();
// Call the API and handle any network failures.
try {
/** @var OperationResponse $response */
$response = $instanceGroupManagersClient->setTargetPools(
$instanceGroupManager,
$instanceGroupManagersSetTargetPoolsRequestResource,
$project,
$zone
);
$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);
}
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.
Parameters | |
---|---|
Name | Description |
instanceGroupManager |
string
The name of the managed instance group. It should conform to RFC1035. |
instanceGroupManagersUpdatePerInstanceConfigsReqResource |
Google\Cloud\Compute\V1\InstanceGroupManagersUpdatePerInstanceConfigsReq
The body resource for this request |
project |
string
Project ID for this request. |
zone |
string
The name of the zone where the managed instance group is located. It should conform to RFC1035. |
optionalArgs |
array
Optional. |
↳ requestId |
string
An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). |
↳ 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\InstanceGroupManagersClient;
use Google\Cloud\Compute\V1\InstanceGroupManagersUpdatePerInstanceConfigsReq;
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 any non-scalar elements to be passed along with the request.
$instanceGroupManagersUpdatePerInstanceConfigsReqResource = new InstanceGroupManagersUpdatePerInstanceConfigsReq();
// Call the API and handle any network failures.
try {
/** @var OperationResponse $response */
$response = $instanceGroupManagersClient->updatePerInstanceConfigs(
$instanceGroupManager,
$instanceGroupManagersUpdatePerInstanceConfigsReqResource,
$project,
$zone
);
$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);
}
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 |
Constants
SERVICE_NAME
Value: 'google.cloud.compute.v1.InstanceGroupManagers'
The name of the service.
SERVICE_ADDRESS
Value: 'compute.googleapis.com'
The default address of the service.
DEFAULT_SERVICE_PORT
Value: 443
The default port of the service.
CODEGEN_NAME
Value: 'gapic'
The name of the code generator, to be included in the agent header.