deleteInstances method

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 thetargetSize 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 thelistmanagedinstances 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.

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> deleteInstances(
  DeleteInstancesInstanceGroupManagerRequest request,
) async {
  final url = _endPoint.replace(
    path:
        '/compute/v1/projects/${request.project}/zones/${request.zone}/instanceGroupManagers/${request.instanceGroupManager}/deleteInstances',
    queryParameters: {
      if (request.noGracefulShutdown case final $1?)
        'noGracefulShutdown': '${$1}',
      'requestId': ?request.requestId,
    },
  );
  final response = await _client.post(
    url,
    body: request.instanceGroupManagersDeleteInstancesRequestResource,
  );
  return Operation.fromJson(response);
}