stop method

Stops a running instance, shutting it down cleanly, and allows you to restart the instance at a later time. Stopped instances do not incur VM usage charges while they are stopped. However, resources that the VM is using, such as persistent disks and static IP addresses, will continue to be charged until they are deleted. For more information, seeStopping an instance.

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