Class BucketNotificationConfiguration
- java.lang.Object
-
- com.amazonaws.services.s3.model.BucketNotificationConfiguration
-
- All Implemented Interfaces:
Serializable
public class BucketNotificationConfiguration extends Object implements Serializable
Represents a bucket's notification configuration. The notification configuration is used to control reception of notifications for specific events for Amazon S3 buckets.
Using SNS as the delivery service, the notification configuration of an Amazon S3 bucket provides near real-time notifications of events the user is interested in. Notification is turned on by enabling configuration on a bucket, specifying the events and the SNS topic. This configuration can only be turned on by the bucket owner.
If a notification configuration already exists for the specified bucket, the new notification configuration will replace the existing notification configuration. To remove a notification configuration, pass an an empty configuration directly to
AmazonS3.setBucketNotificationConfiguration(String,BucketNotificationConfiguration)
.Note: Currently buckets may only have a single event and topic configuration.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
BucketNotificationConfiguration.TopicConfiguration
Deprecated.UseTopicConfiguration
instead
-
Constructor Summary
Constructors Constructor Description BucketNotificationConfiguration()
Creates a new bucket notification configuration.BucketNotificationConfiguration(String name, NotificationConfiguration notificationConfiguration)
Creates a new bucket notification configuration with the given configuration.BucketNotificationConfiguration(Collection<BucketNotificationConfiguration.TopicConfiguration> topicConfigurations)
Deprecated.
-
Method Summary
-
-
-
Constructor Detail
-
BucketNotificationConfiguration
public BucketNotificationConfiguration()
Creates a new bucket notification configuration. By default, the newly created configuration is empty.
Passing the new configuration directly to
AmazonS3.setBucketNotificationConfiguration(String,BucketNotificationConfiguration)
will remove any existing bucket notification configuration.
-
BucketNotificationConfiguration
public BucketNotificationConfiguration(String name, NotificationConfiguration notificationConfiguration)
Creates a new bucket notification configuration with the given configuration.
- Parameters:
name
- the name for the configurationnotificationConfiguration
- the notification configuration for the Amazon S3 bucket.
-
BucketNotificationConfiguration
public BucketNotificationConfiguration(Collection<BucketNotificationConfiguration.TopicConfiguration> topicConfigurations)
Deprecated.Creates a new bucket notification configuration containing the specified
TopicConfigurations
.Passing the new configuration directly to
AmazonS3.setBucketNotificationConfiguration(String,BucketNotificationConfiguration)
will set the bucket's notification configuration and overwrite any existing configuration.
-
-
Method Detail
-
withNotificationConfiguration
public BucketNotificationConfiguration withNotificationConfiguration(Map<String,NotificationConfiguration> notificationConfiguration)
Sets the given notification configurations and returns this object.- Parameters:
notificationConfiguration
- the notification configurations to set- Returns:
- The updated
BucketNotificationConfiguration
object.
-
addConfiguration
public BucketNotificationConfiguration addConfiguration(String name, NotificationConfiguration notificationConfiguration)
Adds the given notification configuration to theBucketNotificationConfiguration
object- Parameters:
name
- the name of the configurationnotificationConfiguration
- the notification configuration for the Amazon S3 bucket.- Returns:
- The updated
BucketNotificationConfiguration
object.
-
getConfigurations
public Map<String,NotificationConfiguration> getConfigurations()
Returns all the notification configurations associated with the Amazon S3 bucket.
-
setConfigurations
public void setConfigurations(Map<String,NotificationConfiguration> configurations)
Sets the given notification configurations in thisBucketNotificationConfiguration
object.- Parameters:
configurations
- the notification configurations to set
-
getConfigurationByName
public NotificationConfiguration getConfigurationByName(String name)
Returns the notification configuration for the given name.- Parameters:
name
- the name of the notification configuration- Returns:
NotificationConfiguration
associated with the given name.
-
removeConfiguration
public NotificationConfiguration removeConfiguration(String name)
Removes the notification configuration for the given name in the
BucketNotificationConfiguration
object.Pass the updated
BucketNotificationConfiguration
toAmazonS3.setBucketNotificationConfiguration(String,BucketNotificationConfiguration)
to update the configuration in Amazon S3 for the bucket.- Parameters:
name
- the name of the notification configuration- Returns:
NotificationConfiguration
associated with the given name.
-
withTopicConfigurations
public BucketNotificationConfiguration withTopicConfigurations(BucketNotificationConfiguration.TopicConfiguration... topicConfigurations)
Deprecated.Sets the
BucketNotificationConfiguration.TopicConfiguration
TopicConfigurations
and returns this object, enabling additional method calls to be chained together.Calling this method will overwrite any previously set
TopicConfigurations
for this object.- Parameters:
topicConfigurations
- A set of topic configurations.- Returns:
- The updated
BucketNotificationConfiguration
object, enabling additional method calls to be chained together. - See Also:
withNotificationConfiguration(Map)
-
setTopicConfigurations
public void setTopicConfigurations(Collection<BucketNotificationConfiguration.TopicConfiguration> topicConfigurations)
Deprecated.Sets the
BucketNotificationConfiguration.TopicConfiguration
.Calling this method will overwrite any previously set
TopicConfigurations
for this object.- Parameters:
topicConfigurations
- A collection of topic configurations.- See Also:
setConfigurations(Map)
-
getTopicConfigurations
public List<BucketNotificationConfiguration.TopicConfiguration> getTopicConfigurations()
Deprecated.Gets the list of
BucketNotificationConfiguration.TopicConfiguration
objects contained in this object. This method may return an empty list if noTopicConfiguration
objects are present.This method is deprecated and will not return all the notification configuration associated with the Amazon S3 bucket. To retrieve all the configuration use @see BucketNotificationConfiguration#getConfigurations()
- Returns:
- The list of
TopicConfiguration
objects contained in this object. May return an empty list. - See Also:
getConfigurations()
-
-