aws_sdk_s3/operation/put_bucket_metrics_configuration/
builders.rs

1// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
2pub use crate::operation::put_bucket_metrics_configuration::_put_bucket_metrics_configuration_output::PutBucketMetricsConfigurationOutputBuilder;
3
4pub use crate::operation::put_bucket_metrics_configuration::_put_bucket_metrics_configuration_input::PutBucketMetricsConfigurationInputBuilder;
5
6impl crate::operation::put_bucket_metrics_configuration::builders::PutBucketMetricsConfigurationInputBuilder {
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_metrics_configuration::PutBucketMetricsConfigurationOutput,
13        ::aws_smithy_runtime_api::client::result::SdkError<
14            crate::operation::put_bucket_metrics_configuration::PutBucketMetricsConfigurationError,
15            ::aws_smithy_runtime_api::client::orchestrator::HttpResponse,
16        >,
17    > {
18        let mut fluent_builder = client.put_bucket_metrics_configuration();
19        fluent_builder.inner = self;
20        fluent_builder.send().await
21    }
22}
23/// Fluent builder constructing a request to `PutBucketMetricsConfiguration`.
24///
25/// <note>
26/// <p>This operation is not supported for directory buckets.</p>
27/// </note>
28/// <p>Sets a metrics configuration (specified by the metrics configuration ID) for the bucket. You can have up to 1,000 metrics configurations per bucket. If you're updating an existing metrics configuration, note that this is a full replacement of the existing metrics configuration. If you don't include the elements you want to keep, they are erased.</p>
29/// <p>To use this operation, you must have permissions to perform the <code>s3:PutMetricsConfiguration</code> action. The bucket owner has this permission by default. The bucket owner can grant this permission to others. For more information about permissions, see <a href="https://docs.aws.amazon.com/AmazonS3/latest/userguide/using-with-s3-actions.html#using-with-s3-actions-related-to-bucket-subresources">Permissions Related to Bucket Subresource Operations</a> and <a href="https://docs.aws.amazon.com/AmazonS3/latest/userguide/s3-access-control.html">Managing Access Permissions to Your Amazon S3 Resources</a>.</p>
30/// <p>For information about CloudWatch request metrics for Amazon S3, see <a href="https://docs.aws.amazon.com/AmazonS3/latest/dev/cloudwatch-monitoring.html">Monitoring Metrics with Amazon CloudWatch</a>.</p>
31/// <p>The following operations are related to <code>PutBucketMetricsConfiguration</code>:</p>
32/// <ul>
33/// <li>
34/// <p><a href="https://docs.aws.amazon.com/AmazonS3/latest/API/API_DeleteBucketMetricsConfiguration.html">DeleteBucketMetricsConfiguration</a></p></li>
35/// <li>
36/// <p><a href="https://docs.aws.amazon.com/AmazonS3/latest/API/API_GetBucketMetricsConfiguration.html">GetBucketMetricsConfiguration</a></p></li>
37/// <li>
38/// <p><a href="https://docs.aws.amazon.com/AmazonS3/latest/API/API_ListBucketMetricsConfigurations.html">ListBucketMetricsConfigurations</a></p></li>
39/// </ul>
40/// <p><code>PutBucketMetricsConfiguration</code> has the following special error:</p>
41/// <ul>
42/// <li>
43/// <p>Error code: <code>TooManyConfigurations</code></p>
44/// <ul>
45/// <li>
46/// <p>Description: You are attempting to create a new configuration but have already reached the 1,000-configuration limit.</p></li>
47/// <li>
48/// <p>HTTP Status Code: HTTP 400 Bad Request</p></li>
49/// </ul></li>
50/// </ul><important>
51/// <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>
52/// </important>
53#[derive(::std::clone::Clone, ::std::fmt::Debug)]
54pub struct PutBucketMetricsConfigurationFluentBuilder {
55    handle: ::std::sync::Arc<crate::client::Handle>,
56    inner: crate::operation::put_bucket_metrics_configuration::builders::PutBucketMetricsConfigurationInputBuilder,
57    config_override: ::std::option::Option<crate::config::Builder>,
58}
59impl
60    crate::client::customize::internal::CustomizableSend<
61        crate::operation::put_bucket_metrics_configuration::PutBucketMetricsConfigurationOutput,
62        crate::operation::put_bucket_metrics_configuration::PutBucketMetricsConfigurationError,
63    > for PutBucketMetricsConfigurationFluentBuilder
64{
65    fn send(
66        self,
67        config_override: crate::config::Builder,
68    ) -> crate::client::customize::internal::BoxFuture<
69        crate::client::customize::internal::SendResult<
70            crate::operation::put_bucket_metrics_configuration::PutBucketMetricsConfigurationOutput,
71            crate::operation::put_bucket_metrics_configuration::PutBucketMetricsConfigurationError,
72        >,
73    > {
74        ::std::boxed::Box::pin(async move { self.config_override(config_override).send().await })
75    }
76}
77impl PutBucketMetricsConfigurationFluentBuilder {
78    /// Creates a new `PutBucketMetricsConfigurationFluentBuilder`.
79    pub(crate) fn new(handle: ::std::sync::Arc<crate::client::Handle>) -> Self {
80        Self {
81            handle,
82            inner: ::std::default::Default::default(),
83            config_override: ::std::option::Option::None,
84        }
85    }
86    /// Access the PutBucketMetricsConfiguration as a reference.
87    pub fn as_input(&self) -> &crate::operation::put_bucket_metrics_configuration::builders::PutBucketMetricsConfigurationInputBuilder {
88        &self.inner
89    }
90    /// Sends the request and returns the response.
91    ///
92    /// If an error occurs, an `SdkError` will be returned with additional details that
93    /// can be matched against.
94    ///
95    /// By default, any retryable failures will be retried twice. Retry behavior
96    /// is configurable with the [RetryConfig](aws_smithy_types::retry::RetryConfig), which can be
97    /// set when configuring the client.
98    pub async fn send(
99        self,
100    ) -> ::std::result::Result<
101        crate::operation::put_bucket_metrics_configuration::PutBucketMetricsConfigurationOutput,
102        ::aws_smithy_runtime_api::client::result::SdkError<
103            crate::operation::put_bucket_metrics_configuration::PutBucketMetricsConfigurationError,
104            ::aws_smithy_runtime_api::client::orchestrator::HttpResponse,
105        >,
106    > {
107        let input = self
108            .inner
109            .build()
110            .map_err(::aws_smithy_runtime_api::client::result::SdkError::construction_failure)?;
111        let runtime_plugins = crate::operation::put_bucket_metrics_configuration::PutBucketMetricsConfiguration::operation_runtime_plugins(
112            self.handle.runtime_plugins.clone(),
113            &self.handle.conf,
114            self.config_override,
115        );
116        crate::operation::put_bucket_metrics_configuration::PutBucketMetricsConfiguration::orchestrate(&runtime_plugins, input).await
117    }
118
119    /// Consumes this builder, creating a customizable operation that can be modified before being sent.
120    pub fn customize(
121        self,
122    ) -> crate::client::customize::CustomizableOperation<
123        crate::operation::put_bucket_metrics_configuration::PutBucketMetricsConfigurationOutput,
124        crate::operation::put_bucket_metrics_configuration::PutBucketMetricsConfigurationError,
125        Self,
126    > {
127        crate::client::customize::CustomizableOperation::new(self)
128    }
129    pub(crate) fn config_override(mut self, config_override: impl ::std::convert::Into<crate::config::Builder>) -> Self {
130        self.set_config_override(::std::option::Option::Some(config_override.into()));
131        self
132    }
133
134    pub(crate) fn set_config_override(&mut self, config_override: ::std::option::Option<crate::config::Builder>) -> &mut Self {
135        self.config_override = config_override;
136        self
137    }
138    /// <p>The name of the bucket for which the metrics configuration is set.</p>
139    pub fn bucket(mut self, input: impl ::std::convert::Into<::std::string::String>) -> Self {
140        self.inner = self.inner.bucket(input.into());
141        self
142    }
143    /// <p>The name of the bucket for which the metrics configuration is set.</p>
144    pub fn set_bucket(mut self, input: ::std::option::Option<::std::string::String>) -> Self {
145        self.inner = self.inner.set_bucket(input);
146        self
147    }
148    /// <p>The name of the bucket for which the metrics configuration is set.</p>
149    pub fn get_bucket(&self) -> &::std::option::Option<::std::string::String> {
150        self.inner.get_bucket()
151    }
152    /// <p>The ID used to identify the metrics configuration. The ID has a 64 character limit and can only contain letters, numbers, periods, dashes, and underscores.</p>
153    pub fn id(mut self, input: impl ::std::convert::Into<::std::string::String>) -> Self {
154        self.inner = self.inner.id(input.into());
155        self
156    }
157    /// <p>The ID used to identify the metrics configuration. The ID has a 64 character limit and can only contain letters, numbers, periods, dashes, and underscores.</p>
158    pub fn set_id(mut self, input: ::std::option::Option<::std::string::String>) -> Self {
159        self.inner = self.inner.set_id(input);
160        self
161    }
162    /// <p>The ID used to identify the metrics configuration. The ID has a 64 character limit and can only contain letters, numbers, periods, dashes, and underscores.</p>
163    pub fn get_id(&self) -> &::std::option::Option<::std::string::String> {
164        self.inner.get_id()
165    }
166    /// <p>Specifies the metrics configuration.</p>
167    pub fn metrics_configuration(mut self, input: crate::types::MetricsConfiguration) -> Self {
168        self.inner = self.inner.metrics_configuration(input);
169        self
170    }
171    /// <p>Specifies the metrics configuration.</p>
172    pub fn set_metrics_configuration(mut self, input: ::std::option::Option<crate::types::MetricsConfiguration>) -> Self {
173        self.inner = self.inner.set_metrics_configuration(input);
174        self
175    }
176    /// <p>Specifies the metrics configuration.</p>
177    pub fn get_metrics_configuration(&self) -> &::std::option::Option<crate::types::MetricsConfiguration> {
178        self.inner.get_metrics_configuration()
179    }
180    /// <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>
181    pub fn expected_bucket_owner(mut self, input: impl ::std::convert::Into<::std::string::String>) -> Self {
182        self.inner = self.inner.expected_bucket_owner(input.into());
183        self
184    }
185    /// <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>
186    pub fn set_expected_bucket_owner(mut self, input: ::std::option::Option<::std::string::String>) -> Self {
187        self.inner = self.inner.set_expected_bucket_owner(input);
188        self
189    }
190    /// <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>
191    pub fn get_expected_bucket_owner(&self) -> &::std::option::Option<::std::string::String> {
192        self.inner.get_expected_bucket_owner()
193    }
194}