getBucketNotificationConfiguration method

Future<NotificationConfiguration> getBucketNotificationConfiguration({
  1. required String bucket,
  2. String? expectedBucketOwner,
})

Returns the notification configuration of a bucket.

If notifications are not enabled on the bucket, the operation returns an empty NotificationConfiguration element.

By default, you must be the bucket owner to read the notification configuration of a bucket. However, the bucket owner can use a bucket policy to grant permission to other users to read this configuration with the s3:GetBucketNotification permission.

For more information about setting and reading the notification configuration on a bucket, see Setting Up Notification of Bucket Events. For more information about bucket policies, see Using Bucket Policies.

The following operation is related to GetBucketNotification:

Parameter bucket : The name of the bucket for which to get the notification configuration.

Parameter expectedBucketOwner : The account id of the expected bucket owner. If the bucket is owned by a different account, the request will fail with an HTTP 403 (Access Denied) error.

Implementation

Future<NotificationConfiguration> getBucketNotificationConfiguration({
  required String bucket,
  String? expectedBucketOwner,
}) async {
  ArgumentError.checkNotNull(bucket, 'bucket');
  final headers = <String, String>{
    if (expectedBucketOwner != null)
      'x-amz-expected-bucket-owner': expectedBucketOwner.toString(),
  };
  final $result = await _protocol.send(
    method: 'GET',
    requestUri: '/${Uri.encodeComponent(bucket)}?notification',
    headers: headers,
    exceptionFnMap: _exceptionFns,
  );
  return NotificationConfiguration.fromXml($result.body);
}