updateBucket method

Future<UpdateBucketResult> updateBucket({
  1. required String bucketName,
  2. BucketAccessLogConfig? accessLogConfig,
  3. AccessRules? accessRules,
  4. BucketCorsConfig? cors,
  5. List<String>? readonlyAccessAccounts,
  6. String? versioning,
})

Updates an existing Amazon Lightsail bucket.

Use this action to update the configuration of an existing bucket, such as versioning, public accessibility, and the Amazon Web Services accounts that can access the 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 update.

Parameter accessLogConfig : An object that describes the access log configuration for the bucket.

Parameter accessRules : An object that sets the public accessibility of objects in the specified bucket.

Parameter cors : Sets the cross-origin resource sharing (CORS) configuration for your bucket. If a CORS configuration exists, it is replaced with the specified configuration. For AWS CLI operations, this parameter can also be passed as a file. For more information, see Configuring cross-origin resource sharing (CORS).

Parameter readonlyAccessAccounts : An array of strings to specify the Amazon Web Services account IDs that can access the bucket.

You can give a maximum of 10 Amazon Web Services accounts access to a bucket.

Parameter versioning : Specifies whether to enable or suspend versioning of objects in the bucket.

The following options can be specified:

  • Enabled - Enables versioning of objects in the specified bucket.
  • Suspended - Suspends versioning of objects in the specified bucket. Existing object versions are retained.

Implementation

Future<UpdateBucketResult> updateBucket({
  required String bucketName,
  BucketAccessLogConfig? accessLogConfig,
  AccessRules? accessRules,
  BucketCorsConfig? cors,
  List<String>? readonlyAccessAccounts,
  String? versioning,
}) async {
  final headers = <String, String>{
    'Content-Type': 'application/x-amz-json-1.1',
    'X-Amz-Target': 'Lightsail_20161128.UpdateBucket'
  };
  final jsonResponse = await _protocol.send(
    method: 'POST',
    requestUri: '/',
    exceptionFnMap: _exceptionFns,
    // TODO queryParams
    headers: headers,
    payload: {
      'bucketName': bucketName,
      if (accessLogConfig != null) 'accessLogConfig': accessLogConfig,
      if (accessRules != null) 'accessRules': accessRules,
      if (cors != null) 'cors': cors,
      if (readonlyAccessAccounts != null)
        'readonlyAccessAccounts': readonlyAccessAccounts,
      if (versioning != null) 'versioning': versioning,
    },
  );

  return UpdateBucketResult.fromJson(jsonResponse.body);
}