suspendInstances method
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 thetargetSize 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 theSUSPENDING action with thelistmanagedinstances 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 thaninitialDelaySec seconds have passed sinceinstance.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.
Throws a http.ClientException if there were problems communicating with
the API service. Throws a ServiceException if the API method failed for
any reason.
Implementation
Future<Operation> suspendInstances(
SuspendInstancesInstanceGroupManagerRequest request,
) async {
final url = _endPoint.replace(
path:
'/compute/v1/projects/${request.project}/zones/${request.zone}/instanceGroupManagers/${request.instanceGroupManager}/suspendInstances',
queryParameters: {'requestId': ?request.requestId},
);
final response = await _client.post(
url,
body: request.instanceGroupManagersSuspendInstancesRequestResource,
);
return Operation.fromJson(response);
}