aws_sdk_s3/operation/put_bucket_notification_configuration/
builders.rs

1// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
2pub use crate::operation::put_bucket_notification_configuration::_put_bucket_notification_configuration_output::PutBucketNotificationConfigurationOutputBuilder;
3
4pub use crate::operation::put_bucket_notification_configuration::_put_bucket_notification_configuration_input::PutBucketNotificationConfigurationInputBuilder;
5
6impl crate::operation::put_bucket_notification_configuration::builders::PutBucketNotificationConfigurationInputBuilder {
7    /// Sends a request with this input using the given client.
8    pub async fn send_with(
9        self,
10        client: &crate::Client,
11    ) -> ::std::result::Result<
12        crate::operation::put_bucket_notification_configuration::PutBucketNotificationConfigurationOutput,
13        ::aws_smithy_runtime_api::client::result::SdkError<
14            crate::operation::put_bucket_notification_configuration::PutBucketNotificationConfigurationError,
15            ::aws_smithy_runtime_api::client::orchestrator::HttpResponse,
16        >,
17    > {
18        let mut fluent_builder = client.put_bucket_notification_configuration();
19        fluent_builder.inner = self;
20        fluent_builder.send().await
21    }
22}
23/// Fluent builder constructing a request to `PutBucketNotificationConfiguration`.
24///
25/// <note>
26/// <p>This operation is not supported for directory buckets.</p>
27/// </note>
28/// <p>Enables notifications of specified events for a bucket. For more information about event notifications, see <a href="https://docs.aws.amazon.com/AmazonS3/latest/dev/NotificationHowTo.html">Configuring Event Notifications</a>.</p>
29/// <p>Using this API, you can replace an existing notification configuration. The configuration is an XML file that defines the event types that you want Amazon S3 to publish and the destination where you want Amazon S3 to publish an event notification when it detects an event of the specified type.</p>
30/// <p>By default, your bucket has no event notifications configured. That is, the notification configuration will be an empty <code>NotificationConfiguration</code>.</p>
31/// <p><code><notificationconfiguration></notificationconfiguration></code></p>
32/// <p><code></code></p>
33/// <p>This action replaces the existing notification configuration with the configuration you include in the request body.</p>
34/// <p>After Amazon S3 receives this request, it first verifies that any Amazon Simple Notification Service (Amazon SNS) or Amazon Simple Queue Service (Amazon SQS) destination exists, and that the bucket owner has permission to publish to it by sending a test notification. In the case of Lambda destinations, Amazon S3 verifies that the Lambda function permissions grant Amazon S3 permission to invoke the function from the Amazon S3 bucket. For more information, see <a href="https://docs.aws.amazon.com/AmazonS3/latest/dev/NotificationHowTo.html">Configuring Notifications for Amazon S3 Events</a>.</p>
35/// <p>You can disable notifications by adding the empty NotificationConfiguration element.</p>
36/// <p>For more information about the number of event notification configurations that you can create per bucket, see <a href="https://docs.aws.amazon.com/general/latest/gr/s3.html#limits_s3">Amazon S3 service quotas</a> in <i>Amazon Web Services General Reference</i>.</p>
37/// <p>By default, only the bucket owner can configure notifications on a bucket. However, bucket owners can use a bucket policy to grant permission to other users to set this configuration with the required <code>s3:PutBucketNotification</code> permission.</p><note>
38/// <p>The PUT notification is an atomic operation. For example, suppose your notification configuration includes SNS topic, SQS queue, and Lambda function configurations. When you send a PUT request with this configuration, Amazon S3 sends test messages to your SNS topic. If the message fails, the entire PUT action will fail, and Amazon S3 will not add the configuration to your bucket.</p>
39/// </note>
40/// <p>If the configuration in the request body includes only one <code>TopicConfiguration</code> specifying only the <code>s3:ReducedRedundancyLostObject</code> event type, the response will also include the <code>x-amz-sns-test-message-id</code> header containing the message ID of the test notification sent to the topic.</p>
41/// <p>The following action is related to <code>PutBucketNotificationConfiguration</code>:</p>
42/// <ul>
43/// <li>
44/// <p><a href="https://docs.aws.amazon.com/AmazonS3/latest/API/API_GetBucketNotificationConfiguration.html">GetBucketNotificationConfiguration</a></p></li>
45/// </ul><important>
46/// <p>You must URL encode any signed header values that contain spaces. For example, if your header value is <code>my file.txt</code>, containing two spaces after <code>my</code>, you must URL encode this value to <code>my%20%20file.txt</code>.</p>
47/// </important>
48#[derive(::std::clone::Clone, ::std::fmt::Debug)]
49pub struct PutBucketNotificationConfigurationFluentBuilder {
50    handle: ::std::sync::Arc<crate::client::Handle>,
51    inner: crate::operation::put_bucket_notification_configuration::builders::PutBucketNotificationConfigurationInputBuilder,
52    config_override: ::std::option::Option<crate::config::Builder>,
53}
54impl
55    crate::client::customize::internal::CustomizableSend<
56        crate::operation::put_bucket_notification_configuration::PutBucketNotificationConfigurationOutput,
57        crate::operation::put_bucket_notification_configuration::PutBucketNotificationConfigurationError,
58    > for PutBucketNotificationConfigurationFluentBuilder
59{
60    fn send(
61        self,
62        config_override: crate::config::Builder,
63    ) -> crate::client::customize::internal::BoxFuture<
64        crate::client::customize::internal::SendResult<
65            crate::operation::put_bucket_notification_configuration::PutBucketNotificationConfigurationOutput,
66            crate::operation::put_bucket_notification_configuration::PutBucketNotificationConfigurationError,
67        >,
68    > {
69        ::std::boxed::Box::pin(async move { self.config_override(config_override).send().await })
70    }
71}
72impl PutBucketNotificationConfigurationFluentBuilder {
73    /// Creates a new `PutBucketNotificationConfigurationFluentBuilder`.
74    pub(crate) fn new(handle: ::std::sync::Arc<crate::client::Handle>) -> Self {
75        Self {
76            handle,
77            inner: ::std::default::Default::default(),
78            config_override: ::std::option::Option::None,
79        }
80    }
81    /// Access the PutBucketNotificationConfiguration as a reference.
82    pub fn as_input(&self) -> &crate::operation::put_bucket_notification_configuration::builders::PutBucketNotificationConfigurationInputBuilder {
83        &self.inner
84    }
85    /// Sends the request and returns the response.
86    ///
87    /// If an error occurs, an `SdkError` will be returned with additional details that
88    /// can be matched against.
89    ///
90    /// By default, any retryable failures will be retried twice. Retry behavior
91    /// is configurable with the [RetryConfig](aws_smithy_types::retry::RetryConfig), which can be
92    /// set when configuring the client.
93    pub async fn send(
94        self,
95    ) -> ::std::result::Result<
96        crate::operation::put_bucket_notification_configuration::PutBucketNotificationConfigurationOutput,
97        ::aws_smithy_runtime_api::client::result::SdkError<
98            crate::operation::put_bucket_notification_configuration::PutBucketNotificationConfigurationError,
99            ::aws_smithy_runtime_api::client::orchestrator::HttpResponse,
100        >,
101    > {
102        let input = self
103            .inner
104            .build()
105            .map_err(::aws_smithy_runtime_api::client::result::SdkError::construction_failure)?;
106        let runtime_plugins = crate::operation::put_bucket_notification_configuration::PutBucketNotificationConfiguration::operation_runtime_plugins(
107            self.handle.runtime_plugins.clone(),
108            &self.handle.conf,
109            self.config_override,
110        );
111        crate::operation::put_bucket_notification_configuration::PutBucketNotificationConfiguration::orchestrate(&runtime_plugins, input).await
112    }
113
114    /// Consumes this builder, creating a customizable operation that can be modified before being sent.
115    pub fn customize(
116        self,
117    ) -> crate::client::customize::CustomizableOperation<
118        crate::operation::put_bucket_notification_configuration::PutBucketNotificationConfigurationOutput,
119        crate::operation::put_bucket_notification_configuration::PutBucketNotificationConfigurationError,
120        Self,
121    > {
122        crate::client::customize::CustomizableOperation::new(self)
123    }
124    pub(crate) fn config_override(mut self, config_override: impl ::std::convert::Into<crate::config::Builder>) -> Self {
125        self.set_config_override(::std::option::Option::Some(config_override.into()));
126        self
127    }
128
129    pub(crate) fn set_config_override(&mut self, config_override: ::std::option::Option<crate::config::Builder>) -> &mut Self {
130        self.config_override = config_override;
131        self
132    }
133    /// <p>The name of the bucket.</p>
134    pub fn bucket(mut self, input: impl ::std::convert::Into<::std::string::String>) -> Self {
135        self.inner = self.inner.bucket(input.into());
136        self
137    }
138    /// <p>The name of the bucket.</p>
139    pub fn set_bucket(mut self, input: ::std::option::Option<::std::string::String>) -> Self {
140        self.inner = self.inner.set_bucket(input);
141        self
142    }
143    /// <p>The name of the bucket.</p>
144    pub fn get_bucket(&self) -> &::std::option::Option<::std::string::String> {
145        self.inner.get_bucket()
146    }
147    /// <p>A container for specifying the notification configuration of the bucket. If this element is empty, notifications are turned off for the bucket.</p>
148    pub fn notification_configuration(mut self, input: crate::types::NotificationConfiguration) -> Self {
149        self.inner = self.inner.notification_configuration(input);
150        self
151    }
152    /// <p>A container for specifying the notification configuration of the bucket. If this element is empty, notifications are turned off for the bucket.</p>
153    pub fn set_notification_configuration(mut self, input: ::std::option::Option<crate::types::NotificationConfiguration>) -> Self {
154        self.inner = self.inner.set_notification_configuration(input);
155        self
156    }
157    /// <p>A container for specifying the notification configuration of the bucket. If this element is empty, notifications are turned off for the bucket.</p>
158    pub fn get_notification_configuration(&self) -> &::std::option::Option<crate::types::NotificationConfiguration> {
159        self.inner.get_notification_configuration()
160    }
161    /// <p>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 <code>403 Forbidden</code> (access denied).</p>
162    pub fn expected_bucket_owner(mut self, input: impl ::std::convert::Into<::std::string::String>) -> Self {
163        self.inner = self.inner.expected_bucket_owner(input.into());
164        self
165    }
166    /// <p>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 <code>403 Forbidden</code> (access denied).</p>
167    pub fn set_expected_bucket_owner(mut self, input: ::std::option::Option<::std::string::String>) -> Self {
168        self.inner = self.inner.set_expected_bucket_owner(input);
169        self
170    }
171    /// <p>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 <code>403 Forbidden</code> (access denied).</p>
172    pub fn get_expected_bucket_owner(&self) -> &::std::option::Option<::std::string::String> {
173        self.inner.get_expected_bucket_owner()
174    }
175    /// <p>Skips validation of Amazon SQS, Amazon SNS, and Lambda destinations. True or false value.</p>
176    pub fn skip_destination_validation(mut self, input: bool) -> Self {
177        self.inner = self.inner.skip_destination_validation(input);
178        self
179    }
180    /// <p>Skips validation of Amazon SQS, Amazon SNS, and Lambda destinations. True or false value.</p>
181    pub fn set_skip_destination_validation(mut self, input: ::std::option::Option<bool>) -> Self {
182        self.inner = self.inner.set_skip_destination_validation(input);
183        self
184    }
185    /// <p>Skips validation of Amazon SQS, Amazon SNS, and Lambda destinations. True or false value.</p>
186    pub fn get_skip_destination_validation(&self) -> &::std::option::Option<bool> {
187        self.inner.get_skip_destination_validation()
188    }
189}