deleteBucket method
Deletes a Amazon Lightsail bucket.
May throw AccessDeniedException.
May throw InvalidInputException.
May throw NotFoundException.
May throw RegionSetupInProgressException.
May throw ServiceException.
May throw UnauthenticatedException.
Parameter bucketName :
The name of the bucket to delete.
Use the GetBuckets action to get a list of bucket names that you can specify.
Parameter forceDelete :
A Boolean value that indicates whether to force delete the bucket.
You must force delete the bucket if it has one of the following conditions:
- The bucket is the origin of a distribution.
- The bucket has instances that were granted access to it using the SetResourceAccessForBucket action.
- The bucket has objects.
- The bucket has access keys.
Implementation
Future<DeleteBucketResult> deleteBucket({
required String bucketName,
bool? forceDelete,
}) async {
final headers = <String, String>{
'Content-Type': 'application/x-amz-json-1.1',
'X-Amz-Target': 'Lightsail_20161128.DeleteBucket'
};
final jsonResponse = await _protocol.send(
method: 'POST',
requestUri: '/',
exceptionFnMap: _exceptionFns,
// TODO queryParams
headers: headers,
payload: {
'bucketName': bucketName,
if (forceDelete != null) 'forceDelete': forceDelete,
},
);
return DeleteBucketResult.fromJson(jsonResponse.body);
}