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>
51#[derive(::std::clone::Clone, ::std::fmt::Debug)]
52pub struct PutBucketMetricsConfigurationFluentBuilder {
53    handle: ::std::sync::Arc<crate::client::Handle>,
54    inner: crate::operation::put_bucket_metrics_configuration::builders::PutBucketMetricsConfigurationInputBuilder,
55    config_override: ::std::option::Option<crate::config::Builder>,
56}
57impl
58    crate::client::customize::internal::CustomizableSend<
59        crate::operation::put_bucket_metrics_configuration::PutBucketMetricsConfigurationOutput,
60        crate::operation::put_bucket_metrics_configuration::PutBucketMetricsConfigurationError,
61    > for PutBucketMetricsConfigurationFluentBuilder
62{
63    fn send(
64        self,
65        config_override: crate::config::Builder,
66    ) -> crate::client::customize::internal::BoxFuture<
67        crate::client::customize::internal::SendResult<
68            crate::operation::put_bucket_metrics_configuration::PutBucketMetricsConfigurationOutput,
69            crate::operation::put_bucket_metrics_configuration::PutBucketMetricsConfigurationError,
70        >,
71    > {
72        ::std::boxed::Box::pin(async move { self.config_override(config_override).send().await })
73    }
74}
75impl PutBucketMetricsConfigurationFluentBuilder {
76    /// Creates a new `PutBucketMetricsConfigurationFluentBuilder`.
77    pub(crate) fn new(handle: ::std::sync::Arc<crate::client::Handle>) -> Self {
78        Self {
79            handle,
80            inner: ::std::default::Default::default(),
81            config_override: ::std::option::Option::None,
82        }
83    }
84    /// Access the PutBucketMetricsConfiguration as a reference.
85    pub fn as_input(&self) -> &crate::operation::put_bucket_metrics_configuration::builders::PutBucketMetricsConfigurationInputBuilder {
86        &self.inner
87    }
88    /// Sends the request and returns the response.
89    ///
90    /// If an error occurs, an `SdkError` will be returned with additional details that
91    /// can be matched against.
92    ///
93    /// By default, any retryable failures will be retried twice. Retry behavior
94    /// is configurable with the [RetryConfig](aws_smithy_types::retry::RetryConfig), which can be
95    /// set when configuring the client.
96    pub async fn send(
97        self,
98    ) -> ::std::result::Result<
99        crate::operation::put_bucket_metrics_configuration::PutBucketMetricsConfigurationOutput,
100        ::aws_smithy_runtime_api::client::result::SdkError<
101            crate::operation::put_bucket_metrics_configuration::PutBucketMetricsConfigurationError,
102            ::aws_smithy_runtime_api::client::orchestrator::HttpResponse,
103        >,
104    > {
105        let input = self
106            .inner
107            .build()
108            .map_err(::aws_smithy_runtime_api::client::result::SdkError::construction_failure)?;
109        let runtime_plugins = crate::operation::put_bucket_metrics_configuration::PutBucketMetricsConfiguration::operation_runtime_plugins(
110            self.handle.runtime_plugins.clone(),
111            &self.handle.conf,
112            self.config_override,
113        );
114        crate::operation::put_bucket_metrics_configuration::PutBucketMetricsConfiguration::orchestrate(&runtime_plugins, input).await
115    }
116
117    /// Consumes this builder, creating a customizable operation that can be modified before being sent.
118    pub fn customize(
119        self,
120    ) -> crate::client::customize::CustomizableOperation<
121        crate::operation::put_bucket_metrics_configuration::PutBucketMetricsConfigurationOutput,
122        crate::operation::put_bucket_metrics_configuration::PutBucketMetricsConfigurationError,
123        Self,
124    > {
125        crate::client::customize::CustomizableOperation::new(self)
126    }
127    pub(crate) fn config_override(mut self, config_override: impl ::std::convert::Into<crate::config::Builder>) -> Self {
128        self.set_config_override(::std::option::Option::Some(config_override.into()));
129        self
130    }
131
132    pub(crate) fn set_config_override(&mut self, config_override: ::std::option::Option<crate::config::Builder>) -> &mut Self {
133        self.config_override = config_override;
134        self
135    }
136    /// <p>The name of the bucket for which the metrics configuration is set.</p>
137    pub fn bucket(mut self, input: impl ::std::convert::Into<::std::string::String>) -> Self {
138        self.inner = self.inner.bucket(input.into());
139        self
140    }
141    /// <p>The name of the bucket for which the metrics configuration is set.</p>
142    pub fn set_bucket(mut self, input: ::std::option::Option<::std::string::String>) -> Self {
143        self.inner = self.inner.set_bucket(input);
144        self
145    }
146    /// <p>The name of the bucket for which the metrics configuration is set.</p>
147    pub fn get_bucket(&self) -> &::std::option::Option<::std::string::String> {
148        self.inner.get_bucket()
149    }
150    /// <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>
151    pub fn id(mut self, input: impl ::std::convert::Into<::std::string::String>) -> Self {
152        self.inner = self.inner.id(input.into());
153        self
154    }
155    /// <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>
156    pub fn set_id(mut self, input: ::std::option::Option<::std::string::String>) -> Self {
157        self.inner = self.inner.set_id(input);
158        self
159    }
160    /// <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>
161    pub fn get_id(&self) -> &::std::option::Option<::std::string::String> {
162        self.inner.get_id()
163    }
164    /// <p>Specifies the metrics configuration.</p>
165    pub fn metrics_configuration(mut self, input: crate::types::MetricsConfiguration) -> Self {
166        self.inner = self.inner.metrics_configuration(input);
167        self
168    }
169    /// <p>Specifies the metrics configuration.</p>
170    pub fn set_metrics_configuration(mut self, input: ::std::option::Option<crate::types::MetricsConfiguration>) -> Self {
171        self.inner = self.inner.set_metrics_configuration(input);
172        self
173    }
174    /// <p>Specifies the metrics configuration.</p>
175    pub fn get_metrics_configuration(&self) -> &::std::option::Option<crate::types::MetricsConfiguration> {
176        self.inner.get_metrics_configuration()
177    }
178    /// <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>
179    pub fn expected_bucket_owner(mut self, input: impl ::std::convert::Into<::std::string::String>) -> Self {
180        self.inner = self.inner.expected_bucket_owner(input.into());
181        self
182    }
183    /// <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>
184    pub fn set_expected_bucket_owner(mut self, input: ::std::option::Option<::std::string::String>) -> Self {
185        self.inner = self.inner.set_expected_bucket_owner(input);
186        self
187    }
188    /// <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>
189    pub fn get_expected_bucket_owner(&self) -> &::std::option::Option<::std::string::String> {
190        self.inner.get_expected_bucket_owner()
191    }
192}