getBuckets method

Future<GetBucketsResult> getBuckets({
  1. String? bucketName,
  2. bool? includeConnectedResources,
  3. bool? includeCors,
  4. String? pageToken,
})

Returns information about one or more Amazon Lightsail buckets. The information returned includes the synchronization status of the Amazon Simple Storage Service (Amazon S3) account-level block public access feature for your Lightsail buckets.

For more information about buckets, see Buckets in Amazon Lightsail in the Amazon Lightsail Developer Guide.

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 for which to return information.

When omitted, the response includes all of your buckets in the Amazon Web Services Region where the request is made.

Parameter includeConnectedResources : A Boolean value that indicates whether to include Lightsail instances that were given access to the bucket using the SetResourceAccessForBucket action.

Parameter includeCors : A Boolean value that indicates whether to include Lightsail bucket CORS configuration in the response. For more information, see Configuring cross-origin resource sharing (CORS).

Parameter pageToken : The token to advance to the next page of results from your request.

To get a page token, perform an initial GetBuckets request. If your results are paginated, the response will return a next page token that you can specify as the page token in a subsequent request.

Implementation

Future<GetBucketsResult> getBuckets({
  String? bucketName,
  bool? includeConnectedResources,
  bool? includeCors,
  String? pageToken,
}) async {
  final headers = <String, String>{
    'Content-Type': 'application/x-amz-json-1.1',
    'X-Amz-Target': 'Lightsail_20161128.GetBuckets'
  };
  final jsonResponse = await _protocol.send(
    method: 'POST',
    requestUri: '/',
    exceptionFnMap: _exceptionFns,
    // TODO queryParams
    headers: headers,
    payload: {
      if (bucketName != null) 'bucketName': bucketName,
      if (includeConnectedResources != null)
        'includeConnectedResources': includeConnectedResources,
      if (includeCors != null) 'includeCors': includeCors,
      if (pageToken != null) 'pageToken': pageToken,
    },
  );

  return GetBucketsResult.fromJson(jsonResponse.body);
}