getBucketNotificationConfiguration method
If notifications are not enabled on the bucket, the action 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.
When you use this API operation with an access point, provide the alias of the access point in place of the bucket name.
When you use this API operation with an Object Lambda access point,
provide the alias of the Object Lambda access point in place of the bucket
name. If the Object Lambda access point alias in a request is not valid,
the error code InvalidAccessPointAliasError is returned. For
more information about InvalidAccessPointAliasError, see List
of Error Codes.
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 action is related to GetBucketNotification:
Parameter bucket :
The name of the bucket for which to get the notification configuration.
When you use this API operation with an access point, provide the alias of the access point in place of the bucket name.
When you use this API operation with an Object Lambda access point,
provide the alias of the Object Lambda access point in place of the bucket
name. If the Object Lambda access point alias in a request is not valid,
the error code InvalidAccessPointAliasError is returned. For
more information about InvalidAccessPointAliasError, see List
of Error Codes.
Parameter expectedBucketOwner :
The account ID of the expected bucket owner. If the account ID that you
provide does not match the actual owner of the bucket, the request fails
with the HTTP status code 403 Forbidden (access denied).
Implementation
Future<NotificationConfiguration> getBucketNotificationConfiguration({
required String bucket,
String? expectedBucketOwner,
}) async {
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);
}