createInstanceSnapshot method
Creates a snapshot of a specific virtual private server, or instance. You can use a snapshot to create a new instance that is based on that snapshot.
The create instance snapshot
operation supports tag-based
access control via request tags. 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 Lightsail instance on which to base your snapshot.
Parameter instanceSnapshotName
:
The name for your new snapshot.
Parameter tags
:
The tag keys and optional values to add to the resource during create.
Use the TagResource
action to tag a resource after it's
created.
Implementation
Future<CreateInstanceSnapshotResult> createInstanceSnapshot({
required String instanceName,
required String instanceSnapshotName,
List<Tag>? tags,
}) async {
ArgumentError.checkNotNull(instanceName, 'instanceName');
ArgumentError.checkNotNull(instanceSnapshotName, 'instanceSnapshotName');
final headers = <String, String>{
'Content-Type': 'application/x-amz-json-1.1',
'X-Amz-Target': 'Lightsail_20161128.CreateInstanceSnapshot'
};
final jsonResponse = await _protocol.send(
method: 'POST',
requestUri: '/',
exceptionFnMap: _exceptionFns,
// TODO queryParams
headers: headers,
payload: {
'instanceName': instanceName,
'instanceSnapshotName': instanceSnapshotName,
if (tags != null) 'tags': tags,
},
);
return CreateInstanceSnapshotResult.fromJson(jsonResponse.body);
}