resize method

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

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