stopInstance method
Stops a specific Amazon Lightsail instance that is currently running.
The stop instance
operation supports tag-based access control
via resource tags applied to the resource identified by instance
name
. For more information, see the Lightsail
Dev Guide.
May throw ServiceException. May throw InvalidInputException. May throw NotFoundException. May throw OperationFailureException. May throw AccessDeniedException. May throw AccountSetupInProgressException. May throw UnauthenticatedException.
Parameter instanceName
:
The name of the instance (a virtual private server) to stop.
Parameter force
:
When set to True
, forces a Lightsail instance that is stuck
in a stopping
state to stop.
Implementation
Future<StopInstanceResult> stopInstance({
required String instanceName,
bool? force,
}) async {
ArgumentError.checkNotNull(instanceName, 'instanceName');
final headers = <String, String>{
'Content-Type': 'application/x-amz-json-1.1',
'X-Amz-Target': 'Lightsail_20161128.StopInstance'
};
final jsonResponse = await _protocol.send(
method: 'POST',
requestUri: '/',
exceptionFnMap: _exceptionFns,
// TODO queryParams
headers: headers,
payload: {
'instanceName': instanceName,
if (force != null) 'force': force,
},
);
return StopInstanceResult.fromJson(jsonResponse.body);
}