Skip to main content

aws_sdk_s3/operation/put_bucket_inventory_configuration/
builders.rs

1// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
2pub use crate::operation::put_bucket_inventory_configuration::_put_bucket_inventory_configuration_input::PutBucketInventoryConfigurationInputBuilder;
3
4pub use crate::operation::put_bucket_inventory_configuration::_put_bucket_inventory_configuration_output::PutBucketInventoryConfigurationOutputBuilder;
5
6impl crate::operation::put_bucket_inventory_configuration::builders::PutBucketInventoryConfigurationInputBuilder {
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_inventory_configuration::PutBucketInventoryConfigurationOutput,
13        ::aws_smithy_runtime_api::client::result::SdkError<
14            crate::operation::put_bucket_inventory_configuration::PutBucketInventoryConfigurationError,
15            ::aws_smithy_runtime_api::client::orchestrator::HttpResponse,
16        >,
17    > {
18        let mut fluent_builder = client.put_bucket_inventory_configuration();
19        fluent_builder.inner = self;
20        fluent_builder.send().await
21    }
22}
23/// Fluent builder constructing a request to `PutBucketInventoryConfiguration`.
24///
25/// <p>This implementation of the <code>PUT</code> action adds an S3 Inventory configuration (identified by the inventory ID) to the bucket. You can have up to 1,000 inventory configurations per bucket.</p>
26/// <p>Amazon S3 inventory generates inventories of the objects in the bucket on a daily or weekly basis, and the results are published to a flat file. The bucket that is inventoried is called the <i>source</i> bucket, and the bucket where the inventory flat file is stored is called the <i>destination</i> bucket. The <i>destination</i> bucket must be in the same Amazon Web Services Region as the <i>source</i> bucket.</p>
27/// <p>When you configure an inventory for a <i>source</i> bucket, you specify the <i>destination</i> bucket where you want the inventory to be stored, and whether to generate the inventory daily or weekly. You can also configure what object metadata to include and whether to inventory all object versions or only current versions. For more information, see <a href="https://docs.aws.amazon.com/AmazonS3/latest/dev/storage-inventory.html">Amazon S3 Inventory</a> in the Amazon S3 User Guide.</p><important>
28/// <p>You must create a bucket policy on the <i>destination</i> bucket to grant permissions to Amazon S3 to write objects to the bucket in the defined location. For an example policy, see <a href="https://docs.aws.amazon.com/AmazonS3/latest/dev/example-bucket-policies.html#example-bucket-policies-use-case-9"> Granting Permissions for Amazon S3 Inventory and Storage Class Analysis</a>.</p>
29/// </important> <note>
30/// <p><b>Directory buckets </b> - For directory buckets, you must make requests for this API operation to the Regional endpoint. These endpoints support path-style requests in the format <code>https://s3express-control.<i>region-code</i>.amazonaws.com/<i>bucket-name</i> </code>. Virtual-hosted-style requests aren't supported. For more information about endpoints in Availability Zones, see <a href="https://docs.aws.amazon.com/AmazonS3/latest/userguide/endpoint-directory-buckets-AZ.html">Regional and Zonal endpoints for directory buckets in Availability Zones</a> in the <i>Amazon S3 User Guide</i>. For more information about endpoints in Local Zones, see <a href="https://docs.aws.amazon.com/AmazonS3/latest/userguide/s3-lzs-for-directory-buckets.html">Concepts for directory buckets in Local Zones</a> in the <i>Amazon S3 User Guide</i>.</p>
31/// </note>
32/// <dl>
33/// <dt>
34/// Permissions
35/// </dt>
36/// <dd>
37/// <p>To use this operation, you must have permission to perform the <code>s3:PutInventoryConfiguration</code> action. The bucket owner has this permission by default and can grant this permission to others.</p>
38/// <p>The <code>s3:PutInventoryConfiguration</code> permission allows a user to create an <a href="https://docs.aws.amazon.com/AmazonS3/latest/userguide/storage-inventory.html">S3 Inventory</a> report that includes all object metadata fields available and to specify the destination bucket to store the inventory. A user with read access to objects in the destination bucket can also access all object metadata fields that are available in the inventory report.</p>
39/// <ul>
40/// <li>
41/// <p><b>General purpose bucket permissions</b> - The <code>s3:PutInventoryConfiguration</code> permission is required in a policy. For more information about general purpose buckets permissions, see <a href="https://docs.aws.amazon.com/AmazonS3/latest/dev/using-iam-policies.html">Using Bucket Policies and User Policies</a> in the <i>Amazon S3 User Guide</i>.</p></li>
42/// <li>
43/// <p><b>Directory bucket permissions</b> - To grant access to this API operation, you must have the <code>s3express:PutInventoryConfiguration</code> permission in an IAM identity-based policy instead of a bucket policy. For more information about directory bucket policies and permissions, see <a href="https://docs.aws.amazon.com/AmazonS3/latest/userguide/s3-express-security-iam.html">Amazon Web Services Identity and Access Management (IAM) for S3 Express One Zone</a> in the <i>Amazon S3 User Guide</i>.</p></li>
44/// </ul>
45/// <p>To restrict access to an inventory report, see <a href="https://docs.aws.amazon.com/AmazonS3/latest/userguide/example-bucket-policies.html#example-bucket-policies-s3-inventory">Restricting access to an Amazon S3 Inventory report</a> in the <i>Amazon S3 User Guide</i>. For more information about the metadata fields available in S3 Inventory, see <a href="https://docs.aws.amazon.com/AmazonS3/latest/userguide/storage-inventory.html#storage-inventory-contents">Amazon S3 Inventory lists</a> in the <i>Amazon S3 User Guide</i>. 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">Identity and access management in Amazon S3</a> in the <i>Amazon S3 User Guide</i>.</p>
46/// </dd>
47/// <dt>
48/// HTTP Host header syntax
49/// </dt>
50/// <dd>
51/// <p><b>Directory buckets </b> - The HTTP Host header syntax is <code>s3express-control.<i>region-code</i>.amazonaws.com</code>.</p>
52/// </dd>
53/// </dl>
54/// <p><code>PutBucketInventoryConfiguration</code> has the following special errors:</p>
55/// <dl>
56/// <dt>
57/// HTTP 400 Bad Request Error
58/// </dt>
59/// <dd>
60/// <p><i>Code:</i> InvalidArgument</p>
61/// <p><i>Cause:</i> Invalid Argument</p>
62/// </dd>
63/// <dt>
64/// HTTP 400 Bad Request Error
65/// </dt>
66/// <dd>
67/// <p><i>Code:</i> TooManyConfigurations</p>
68/// <p><i>Cause:</i> You are attempting to create a new configuration but have already reached the 1,000-configuration limit.</p>
69/// </dd>
70/// <dt>
71/// HTTP 403 Forbidden Error
72/// </dt>
73/// <dd>
74/// <p><i>Cause:</i> You are not the owner of the specified bucket, or you do not have the <code>s3:PutInventoryConfiguration</code> bucket permission to set the configuration on the bucket.</p>
75/// </dd>
76/// </dl>
77/// <p>The following operations are related to <code>PutBucketInventoryConfiguration</code>:</p>
78/// <ul>
79/// <li>
80/// <p><a href="https://docs.aws.amazon.com/AmazonS3/latest/API/API_GetBucketInventoryConfiguration.html">GetBucketInventoryConfiguration</a></p></li>
81/// <li>
82/// <p><a href="https://docs.aws.amazon.com/AmazonS3/latest/API/API_DeleteBucketInventoryConfiguration.html">DeleteBucketInventoryConfiguration</a></p></li>
83/// <li>
84/// <p><a href="https://docs.aws.amazon.com/AmazonS3/latest/API/API_ListBucketInventoryConfigurations.html">ListBucketInventoryConfigurations</a></p></li>
85/// </ul><important>
86/// <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>
87/// </important>
88#[derive(::std::clone::Clone, ::std::fmt::Debug)]
89pub struct PutBucketInventoryConfigurationFluentBuilder {
90    handle: ::std::sync::Arc<crate::client::Handle>,
91    inner: crate::operation::put_bucket_inventory_configuration::builders::PutBucketInventoryConfigurationInputBuilder,
92    config_override: ::std::option::Option<crate::config::Builder>,
93}
94impl
95    crate::client::customize::internal::CustomizableSend<
96        crate::operation::put_bucket_inventory_configuration::PutBucketInventoryConfigurationOutput,
97        crate::operation::put_bucket_inventory_configuration::PutBucketInventoryConfigurationError,
98    > for PutBucketInventoryConfigurationFluentBuilder
99{
100    fn send(
101        self,
102        config_override: crate::config::Builder,
103    ) -> crate::client::customize::internal::BoxFuture<
104        crate::client::customize::internal::SendResult<
105            crate::operation::put_bucket_inventory_configuration::PutBucketInventoryConfigurationOutput,
106            crate::operation::put_bucket_inventory_configuration::PutBucketInventoryConfigurationError,
107        >,
108    > {
109        ::std::boxed::Box::pin(async move { self.config_override(config_override).send().await })
110    }
111}
112impl PutBucketInventoryConfigurationFluentBuilder {
113    /// Creates a new `PutBucketInventoryConfigurationFluentBuilder`.
114    pub(crate) fn new(handle: ::std::sync::Arc<crate::client::Handle>) -> Self {
115        Self {
116            handle,
117            inner: ::std::default::Default::default(),
118            config_override: ::std::option::Option::None,
119        }
120    }
121    /// Access the PutBucketInventoryConfiguration as a reference.
122    pub fn as_input(&self) -> &crate::operation::put_bucket_inventory_configuration::builders::PutBucketInventoryConfigurationInputBuilder {
123        &self.inner
124    }
125    /// Sends the request and returns the response.
126    ///
127    /// If an error occurs, an `SdkError` will be returned with additional details that
128    /// can be matched against.
129    ///
130    /// By default, any retryable failures will be retried twice. Retry behavior
131    /// is configurable with the [RetryConfig](aws_smithy_types::retry::RetryConfig), which can be
132    /// set when configuring the client.
133    pub async fn send(
134        self,
135    ) -> ::std::result::Result<
136        crate::operation::put_bucket_inventory_configuration::PutBucketInventoryConfigurationOutput,
137        ::aws_smithy_runtime_api::client::result::SdkError<
138            crate::operation::put_bucket_inventory_configuration::PutBucketInventoryConfigurationError,
139            ::aws_smithy_runtime_api::client::orchestrator::HttpResponse,
140        >,
141    > {
142        let input = self
143            .inner
144            .build()
145            .map_err(::aws_smithy_runtime_api::client::result::SdkError::construction_failure)?;
146        let runtime_plugins = crate::operation::put_bucket_inventory_configuration::PutBucketInventoryConfiguration::operation_runtime_plugins(
147            self.handle.runtime_plugins.clone(),
148            &self.handle.conf,
149            self.config_override,
150        );
151        crate::operation::put_bucket_inventory_configuration::PutBucketInventoryConfiguration::orchestrate(&runtime_plugins, input).await
152    }
153
154    /// Consumes this builder, creating a customizable operation that can be modified before being sent.
155    pub fn customize(
156        self,
157    ) -> crate::client::customize::CustomizableOperation<
158        crate::operation::put_bucket_inventory_configuration::PutBucketInventoryConfigurationOutput,
159        crate::operation::put_bucket_inventory_configuration::PutBucketInventoryConfigurationError,
160        Self,
161    > {
162        crate::client::customize::CustomizableOperation::new(self)
163    }
164    pub(crate) fn config_override(mut self, config_override: impl ::std::convert::Into<crate::config::Builder>) -> Self {
165        self.set_config_override(::std::option::Option::Some(config_override.into()));
166        self
167    }
168
169    pub(crate) fn set_config_override(&mut self, config_override: ::std::option::Option<crate::config::Builder>) -> &mut Self {
170        self.config_override = config_override;
171        self
172    }
173    /// <p>The name of the bucket where the inventory configuration will be stored.</p>
174    /// <p><b>Directory buckets </b> - When you use this operation with a directory bucket, you must use path-style requests in the format <code>https://s3express-control.<i>region-code</i>.amazonaws.com/<i>bucket-name</i> </code>. Virtual-hosted-style requests aren't supported. Directory bucket names must be unique in the chosen Zone (Availability Zone or Local Zone). Bucket names must also follow the format <code> <i>bucket-base-name</i>--<i>zone-id</i>--x-s3</code> (for example, <code> <i>DOC-EXAMPLE-BUCKET</i>--<i>usw2-az1</i>--x-s3</code>). For information about bucket naming restrictions, see <a href="https://docs.aws.amazon.com/AmazonS3/latest/userguide/directory-bucket-naming-rules.html">Directory bucket naming rules</a> in the <i>Amazon S3 User Guide</i></p>
175    pub fn bucket(mut self, input: impl ::std::convert::Into<::std::string::String>) -> Self {
176        self.inner = self.inner.bucket(input.into());
177        self
178    }
179    /// <p>The name of the bucket where the inventory configuration will be stored.</p>
180    /// <p><b>Directory buckets </b> - When you use this operation with a directory bucket, you must use path-style requests in the format <code>https://s3express-control.<i>region-code</i>.amazonaws.com/<i>bucket-name</i> </code>. Virtual-hosted-style requests aren't supported. Directory bucket names must be unique in the chosen Zone (Availability Zone or Local Zone). Bucket names must also follow the format <code> <i>bucket-base-name</i>--<i>zone-id</i>--x-s3</code> (for example, <code> <i>DOC-EXAMPLE-BUCKET</i>--<i>usw2-az1</i>--x-s3</code>). For information about bucket naming restrictions, see <a href="https://docs.aws.amazon.com/AmazonS3/latest/userguide/directory-bucket-naming-rules.html">Directory bucket naming rules</a> in the <i>Amazon S3 User Guide</i></p>
181    pub fn set_bucket(mut self, input: ::std::option::Option<::std::string::String>) -> Self {
182        self.inner = self.inner.set_bucket(input);
183        self
184    }
185    /// <p>The name of the bucket where the inventory configuration will be stored.</p>
186    /// <p><b>Directory buckets </b> - When you use this operation with a directory bucket, you must use path-style requests in the format <code>https://s3express-control.<i>region-code</i>.amazonaws.com/<i>bucket-name</i> </code>. Virtual-hosted-style requests aren't supported. Directory bucket names must be unique in the chosen Zone (Availability Zone or Local Zone). Bucket names must also follow the format <code> <i>bucket-base-name</i>--<i>zone-id</i>--x-s3</code> (for example, <code> <i>DOC-EXAMPLE-BUCKET</i>--<i>usw2-az1</i>--x-s3</code>). For information about bucket naming restrictions, see <a href="https://docs.aws.amazon.com/AmazonS3/latest/userguide/directory-bucket-naming-rules.html">Directory bucket naming rules</a> in the <i>Amazon S3 User Guide</i></p>
187    pub fn get_bucket(&self) -> &::std::option::Option<::std::string::String> {
188        self.inner.get_bucket()
189    }
190    /// <p>The ID used to identify the inventory configuration.</p>
191    pub fn id(mut self, input: impl ::std::convert::Into<::std::string::String>) -> Self {
192        self.inner = self.inner.id(input.into());
193        self
194    }
195    /// <p>The ID used to identify the inventory configuration.</p>
196    pub fn set_id(mut self, input: ::std::option::Option<::std::string::String>) -> Self {
197        self.inner = self.inner.set_id(input);
198        self
199    }
200    /// <p>The ID used to identify the inventory configuration.</p>
201    pub fn get_id(&self) -> &::std::option::Option<::std::string::String> {
202        self.inner.get_id()
203    }
204    /// <p>Specifies the inventory configuration.</p>
205    pub fn inventory_configuration(mut self, input: crate::types::InventoryConfiguration) -> Self {
206        self.inner = self.inner.inventory_configuration(input);
207        self
208    }
209    /// <p>Specifies the inventory configuration.</p>
210    pub fn set_inventory_configuration(mut self, input: ::std::option::Option<crate::types::InventoryConfiguration>) -> Self {
211        self.inner = self.inner.set_inventory_configuration(input);
212        self
213    }
214    /// <p>Specifies the inventory configuration.</p>
215    pub fn get_inventory_configuration(&self) -> &::std::option::Option<crate::types::InventoryConfiguration> {
216        self.inner.get_inventory_configuration()
217    }
218    /// <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><note>
219    /// <p>For directory buckets, this header is not supported in this API operation. If you specify this header, the request fails with the HTTP status code <code>501 Not Implemented</code>.</p>
220    /// </note>
221    pub fn expected_bucket_owner(mut self, input: impl ::std::convert::Into<::std::string::String>) -> Self {
222        self.inner = self.inner.expected_bucket_owner(input.into());
223        self
224    }
225    /// <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><note>
226    /// <p>For directory buckets, this header is not supported in this API operation. If you specify this header, the request fails with the HTTP status code <code>501 Not Implemented</code>.</p>
227    /// </note>
228    pub fn set_expected_bucket_owner(mut self, input: ::std::option::Option<::std::string::String>) -> Self {
229        self.inner = self.inner.set_expected_bucket_owner(input);
230        self
231    }
232    /// <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><note>
233    /// <p>For directory buckets, this header is not supported in this API operation. If you specify this header, the request fails with the HTTP status code <code>501 Not Implemented</code>.</p>
234    /// </note>
235    pub fn get_expected_bucket_owner(&self) -> &::std::option::Option<::std::string::String> {
236        self.inner.get_expected_bucket_owner()
237    }
238}