copyImage method
Copies the image within the same region or to a new region within the same AWS account. Note that any tags you added to the image will not be copied.
May throw ResourceAlreadyExistsException. May throw ResourceNotFoundException. May throw ResourceNotAvailableException. May throw LimitExceededException. May throw InvalidAccountStatusException. May throw IncompatibleImageException.
Parameter destinationImageName :
The name that the image will have when it is copied to the destination.
Parameter destinationRegion :
The destination region to which the image will be copied. This parameter
is required, even if you are copying an image within the same region.
Parameter sourceImageName :
The name of the image to copy.
Parameter destinationImageDescription :
The description that the image will have when it is copied to the
destination.
Implementation
Future<CopyImageResponse> copyImage({
required String destinationImageName,
required String destinationRegion,
required String sourceImageName,
String? destinationImageDescription,
}) async {
ArgumentError.checkNotNull(destinationImageName, 'destinationImageName');
ArgumentError.checkNotNull(destinationRegion, 'destinationRegion');
_s.validateStringLength(
'destinationRegion',
destinationRegion,
1,
32,
isRequired: true,
);
ArgumentError.checkNotNull(sourceImageName, 'sourceImageName');
_s.validateStringLength(
'destinationImageDescription',
destinationImageDescription,
0,
256,
);
final headers = <String, String>{
'Content-Type': 'application/x-amz-json-1.1',
'X-Amz-Target': 'PhotonAdminProxyService.CopyImage'
};
final jsonResponse = await _protocol.send(
method: 'POST',
requestUri: '/',
exceptionFnMap: _exceptionFns,
// TODO queryParams
headers: headers,
payload: {
'DestinationImageName': destinationImageName,
'DestinationRegion': destinationRegion,
'SourceImageName': sourceImageName,
if (destinationImageDescription != null)
'DestinationImageDescription': destinationImageDescription,
},
);
return CopyImageResponse.fromJson(jsonResponse.body);
}