aws_sdk_s3/operation/put_bucket_policy/
builders.rs

1// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
2pub use crate::operation::put_bucket_policy::_put_bucket_policy_output::PutBucketPolicyOutputBuilder;
3
4pub use crate::operation::put_bucket_policy::_put_bucket_policy_input::PutBucketPolicyInputBuilder;
5
6impl crate::operation::put_bucket_policy::builders::PutBucketPolicyInputBuilder {
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_policy::PutBucketPolicyOutput,
13        ::aws_smithy_runtime_api::client::result::SdkError<
14            crate::operation::put_bucket_policy::PutBucketPolicyError,
15            ::aws_smithy_runtime_api::client::orchestrator::HttpResponse,
16        >,
17    > {
18        let mut fluent_builder = client.put_bucket_policy();
19        fluent_builder.inner = self;
20        fluent_builder.send().await
21    }
22}
23/// Fluent builder constructing a request to `PutBucketPolicy`.
24///
25/// <p>Applies an Amazon S3 bucket policy to an Amazon S3 bucket.</p><note>
26/// <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>
27/// </note>
28/// <dl>
29/// <dt>
30/// Permissions
31/// </dt>
32/// <dd>
33/// <p>If you are using an identity other than the root user of the Amazon Web Services account that owns the bucket, the calling identity must both have the <code>PutBucketPolicy</code> permissions on the specified bucket and belong to the bucket owner's account in order to use this operation.</p>
34/// <p>If you don't have <code>PutBucketPolicy</code> permissions, Amazon S3 returns a <code>403 Access Denied</code> error. If you have the correct permissions, but you're not using an identity that belongs to the bucket owner's account, Amazon S3 returns a <code>405 Method Not Allowed</code> error.</p><important>
35/// <p>To ensure that bucket owners don't inadvertently lock themselves out of their own buckets, the root principal in a bucket owner's Amazon Web Services account can perform the <code>GetBucketPolicy</code>, <code>PutBucketPolicy</code>, and <code>DeleteBucketPolicy</code> API actions, even if their bucket policy explicitly denies the root principal's access. Bucket owner root principals can only be blocked from performing these API actions by VPC endpoint policies and Amazon Web Services Organizations policies.</p>
36/// </important>
37/// <ul>
38/// <li>
39/// <p><b>General purpose bucket permissions</b> - The <code>s3:PutBucketPolicy</code> permission is required in a policy. For more information about general purpose buckets bucket policies, 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>
40/// <li>
41/// <p><b>Directory bucket permissions</b> - To grant access to this API operation, you must have the <code>s3express:PutBucketPolicy</code> permission in an IAM identity-based policy instead of a bucket policy. Cross-account access to this API operation isn't supported. This operation can only be performed by the Amazon Web Services account that owns the resource. 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>
42/// </ul>
43/// </dd>
44/// <dt>
45/// Example bucket policies
46/// </dt>
47/// <dd>
48/// <p><b>General purpose buckets example bucket policies</b> - See <a href="https://docs.aws.amazon.com/AmazonS3/latest/userguide/example-bucket-policies.html">Bucket policy examples</a> in the <i>Amazon S3 User Guide</i>.</p>
49/// <p><b>Directory bucket example bucket policies</b> - See <a href="https://docs.aws.amazon.com/AmazonS3/latest/userguide/s3-express-security-iam-example-bucket-policies.html">Example bucket policies for S3 Express One Zone</a> in the <i>Amazon S3 User Guide</i>.</p>
50/// </dd>
51/// <dt>
52/// HTTP Host header syntax
53/// </dt>
54/// <dd>
55/// <p><b>Directory buckets </b> - The HTTP Host header syntax is <code>s3express-control.<i>region-code</i>.amazonaws.com</code>.</p>
56/// </dd>
57/// </dl>
58/// <p>The following operations are related to <code>PutBucketPolicy</code>:</p>
59/// <ul>
60/// <li>
61/// <p><a href="https://docs.aws.amazon.com/AmazonS3/latest/API/API_CreateBucket.html">CreateBucket</a></p></li>
62/// <li>
63/// <p><a href="https://docs.aws.amazon.com/AmazonS3/latest/API/API_DeleteBucket.html">DeleteBucket</a></p></li>
64/// </ul>
65#[derive(::std::clone::Clone, ::std::fmt::Debug)]
66pub struct PutBucketPolicyFluentBuilder {
67    handle: ::std::sync::Arc<crate::client::Handle>,
68    inner: crate::operation::put_bucket_policy::builders::PutBucketPolicyInputBuilder,
69    config_override: ::std::option::Option<crate::config::Builder>,
70}
71impl
72    crate::client::customize::internal::CustomizableSend<
73        crate::operation::put_bucket_policy::PutBucketPolicyOutput,
74        crate::operation::put_bucket_policy::PutBucketPolicyError,
75    > for PutBucketPolicyFluentBuilder
76{
77    fn send(
78        self,
79        config_override: crate::config::Builder,
80    ) -> crate::client::customize::internal::BoxFuture<
81        crate::client::customize::internal::SendResult<
82            crate::operation::put_bucket_policy::PutBucketPolicyOutput,
83            crate::operation::put_bucket_policy::PutBucketPolicyError,
84        >,
85    > {
86        ::std::boxed::Box::pin(async move { self.config_override(config_override).send().await })
87    }
88}
89impl PutBucketPolicyFluentBuilder {
90    /// Creates a new `PutBucketPolicyFluentBuilder`.
91    pub(crate) fn new(handle: ::std::sync::Arc<crate::client::Handle>) -> Self {
92        Self {
93            handle,
94            inner: ::std::default::Default::default(),
95            config_override: ::std::option::Option::None,
96        }
97    }
98    /// Access the PutBucketPolicy as a reference.
99    pub fn as_input(&self) -> &crate::operation::put_bucket_policy::builders::PutBucketPolicyInputBuilder {
100        &self.inner
101    }
102    /// Sends the request and returns the response.
103    ///
104    /// If an error occurs, an `SdkError` will be returned with additional details that
105    /// can be matched against.
106    ///
107    /// By default, any retryable failures will be retried twice. Retry behavior
108    /// is configurable with the [RetryConfig](aws_smithy_types::retry::RetryConfig), which can be
109    /// set when configuring the client.
110    pub async fn send(
111        self,
112    ) -> ::std::result::Result<
113        crate::operation::put_bucket_policy::PutBucketPolicyOutput,
114        ::aws_smithy_runtime_api::client::result::SdkError<
115            crate::operation::put_bucket_policy::PutBucketPolicyError,
116            ::aws_smithy_runtime_api::client::orchestrator::HttpResponse,
117        >,
118    > {
119        let input = self
120            .inner
121            .build()
122            .map_err(::aws_smithy_runtime_api::client::result::SdkError::construction_failure)?;
123        let runtime_plugins = crate::operation::put_bucket_policy::PutBucketPolicy::operation_runtime_plugins(
124            self.handle.runtime_plugins.clone(),
125            &self.handle.conf,
126            self.config_override,
127        );
128        crate::operation::put_bucket_policy::PutBucketPolicy::orchestrate(&runtime_plugins, input).await
129    }
130
131    /// Consumes this builder, creating a customizable operation that can be modified before being sent.
132    pub fn customize(
133        self,
134    ) -> crate::client::customize::CustomizableOperation<
135        crate::operation::put_bucket_policy::PutBucketPolicyOutput,
136        crate::operation::put_bucket_policy::PutBucketPolicyError,
137        Self,
138    > {
139        crate::client::customize::CustomizableOperation::new(self)
140    }
141    pub(crate) fn config_override(mut self, config_override: impl ::std::convert::Into<crate::config::Builder>) -> Self {
142        self.set_config_override(::std::option::Option::Some(config_override.into()));
143        self
144    }
145
146    pub(crate) fn set_config_override(&mut self, config_override: ::std::option::Option<crate::config::Builder>) -> &mut Self {
147        self.config_override = config_override;
148        self
149    }
150    /// <p>The name of the bucket.</p>
151    /// <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>
152    pub fn bucket(mut self, input: impl ::std::convert::Into<::std::string::String>) -> Self {
153        self.inner = self.inner.bucket(input.into());
154        self
155    }
156    /// <p>The name of the bucket.</p>
157    /// <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>
158    pub fn set_bucket(mut self, input: ::std::option::Option<::std::string::String>) -> Self {
159        self.inner = self.inner.set_bucket(input);
160        self
161    }
162    /// <p>The name of the bucket.</p>
163    /// <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>
164    pub fn get_bucket(&self) -> &::std::option::Option<::std::string::String> {
165        self.inner.get_bucket()
166    }
167    /// <p>The MD5 hash of the request body.</p>
168    /// <p>For requests made using the Amazon Web Services Command Line Interface (CLI) or Amazon Web Services SDKs, this field is calculated automatically.</p><note>
169    /// <p>This functionality is not supported for directory buckets.</p>
170    /// </note>
171    pub fn content_md5(mut self, input: impl ::std::convert::Into<::std::string::String>) -> Self {
172        self.inner = self.inner.content_md5(input.into());
173        self
174    }
175    /// <p>The MD5 hash of the request body.</p>
176    /// <p>For requests made using the Amazon Web Services Command Line Interface (CLI) or Amazon Web Services SDKs, this field is calculated automatically.</p><note>
177    /// <p>This functionality is not supported for directory buckets.</p>
178    /// </note>
179    pub fn set_content_md5(mut self, input: ::std::option::Option<::std::string::String>) -> Self {
180        self.inner = self.inner.set_content_md5(input);
181        self
182    }
183    /// <p>The MD5 hash of the request body.</p>
184    /// <p>For requests made using the Amazon Web Services Command Line Interface (CLI) or Amazon Web Services SDKs, this field is calculated automatically.</p><note>
185    /// <p>This functionality is not supported for directory buckets.</p>
186    /// </note>
187    pub fn get_content_md5(&self) -> &::std::option::Option<::std::string::String> {
188        self.inner.get_content_md5()
189    }
190    /// <p>Indicates the algorithm used to create the checksum for the request when you use the SDK. This header will not provide any additional functionality if you don't use the SDK. When you send this header, there must be a corresponding <code>x-amz-checksum-<i>algorithm</i> </code> or <code>x-amz-trailer</code> header sent. Otherwise, Amazon S3 fails the request with the HTTP status code <code>400 Bad Request</code>.</p>
191    /// <p>For the <code>x-amz-checksum-<i>algorithm</i> </code> header, replace <code> <i>algorithm</i> </code> with the supported algorithm from the following list:</p>
192    /// <ul>
193    /// <li>
194    /// <p><code>CRC-32</code></p></li>
195    /// <li>
196    /// <p><code>CRC-32C</code></p></li>
197    /// <li>
198    /// <p><code>CRC-64NVME</code></p></li>
199    /// <li>
200    /// <p><code>SHA-1</code></p></li>
201    /// <li>
202    /// <p><code>SHA-256</code></p></li>
203    /// </ul>
204    /// <p>For more information, see <a href="https://docs.aws.amazon.com/AmazonS3/latest/userguide/checking-object-integrity.html">Checking object integrity</a> in the <i>Amazon S3 User Guide</i>.</p>
205    /// <p>If the individual checksum value you provide through <code>x-amz-checksum-<i>algorithm</i> </code> doesn't match the checksum algorithm you set through <code>x-amz-sdk-checksum-algorithm</code>, Amazon S3 fails the request with a <code>BadDigest</code> error.</p><note>
206    /// <p>For directory buckets, when you use Amazon Web Services SDKs, <code>CRC32</code> is the default checksum algorithm that's used for performance.</p>
207    /// </note>
208    pub fn checksum_algorithm(mut self, input: crate::types::ChecksumAlgorithm) -> Self {
209        self.inner = self.inner.checksum_algorithm(input);
210        self
211    }
212    /// <p>Indicates the algorithm used to create the checksum for the request when you use the SDK. This header will not provide any additional functionality if you don't use the SDK. When you send this header, there must be a corresponding <code>x-amz-checksum-<i>algorithm</i> </code> or <code>x-amz-trailer</code> header sent. Otherwise, Amazon S3 fails the request with the HTTP status code <code>400 Bad Request</code>.</p>
213    /// <p>For the <code>x-amz-checksum-<i>algorithm</i> </code> header, replace <code> <i>algorithm</i> </code> with the supported algorithm from the following list:</p>
214    /// <ul>
215    /// <li>
216    /// <p><code>CRC-32</code></p></li>
217    /// <li>
218    /// <p><code>CRC-32C</code></p></li>
219    /// <li>
220    /// <p><code>CRC-64NVME</code></p></li>
221    /// <li>
222    /// <p><code>SHA-1</code></p></li>
223    /// <li>
224    /// <p><code>SHA-256</code></p></li>
225    /// </ul>
226    /// <p>For more information, see <a href="https://docs.aws.amazon.com/AmazonS3/latest/userguide/checking-object-integrity.html">Checking object integrity</a> in the <i>Amazon S3 User Guide</i>.</p>
227    /// <p>If the individual checksum value you provide through <code>x-amz-checksum-<i>algorithm</i> </code> doesn't match the checksum algorithm you set through <code>x-amz-sdk-checksum-algorithm</code>, Amazon S3 fails the request with a <code>BadDigest</code> error.</p><note>
228    /// <p>For directory buckets, when you use Amazon Web Services SDKs, <code>CRC32</code> is the default checksum algorithm that's used for performance.</p>
229    /// </note>
230    pub fn set_checksum_algorithm(mut self, input: ::std::option::Option<crate::types::ChecksumAlgorithm>) -> Self {
231        self.inner = self.inner.set_checksum_algorithm(input);
232        self
233    }
234    /// <p>Indicates the algorithm used to create the checksum for the request when you use the SDK. This header will not provide any additional functionality if you don't use the SDK. When you send this header, there must be a corresponding <code>x-amz-checksum-<i>algorithm</i> </code> or <code>x-amz-trailer</code> header sent. Otherwise, Amazon S3 fails the request with the HTTP status code <code>400 Bad Request</code>.</p>
235    /// <p>For the <code>x-amz-checksum-<i>algorithm</i> </code> header, replace <code> <i>algorithm</i> </code> with the supported algorithm from the following list:</p>
236    /// <ul>
237    /// <li>
238    /// <p><code>CRC-32</code></p></li>
239    /// <li>
240    /// <p><code>CRC-32C</code></p></li>
241    /// <li>
242    /// <p><code>CRC-64NVME</code></p></li>
243    /// <li>
244    /// <p><code>SHA-1</code></p></li>
245    /// <li>
246    /// <p><code>SHA-256</code></p></li>
247    /// </ul>
248    /// <p>For more information, see <a href="https://docs.aws.amazon.com/AmazonS3/latest/userguide/checking-object-integrity.html">Checking object integrity</a> in the <i>Amazon S3 User Guide</i>.</p>
249    /// <p>If the individual checksum value you provide through <code>x-amz-checksum-<i>algorithm</i> </code> doesn't match the checksum algorithm you set through <code>x-amz-sdk-checksum-algorithm</code>, Amazon S3 fails the request with a <code>BadDigest</code> error.</p><note>
250    /// <p>For directory buckets, when you use Amazon Web Services SDKs, <code>CRC32</code> is the default checksum algorithm that's used for performance.</p>
251    /// </note>
252    pub fn get_checksum_algorithm(&self) -> &::std::option::Option<crate::types::ChecksumAlgorithm> {
253        self.inner.get_checksum_algorithm()
254    }
255    /// <p>Set this parameter to true to confirm that you want to remove your permissions to change this bucket policy in the future.</p><note>
256    /// <p>This functionality is not supported for directory buckets.</p>
257    /// </note>
258    pub fn confirm_remove_self_bucket_access(mut self, input: bool) -> Self {
259        self.inner = self.inner.confirm_remove_self_bucket_access(input);
260        self
261    }
262    /// <p>Set this parameter to true to confirm that you want to remove your permissions to change this bucket policy in the future.</p><note>
263    /// <p>This functionality is not supported for directory buckets.</p>
264    /// </note>
265    pub fn set_confirm_remove_self_bucket_access(mut self, input: ::std::option::Option<bool>) -> Self {
266        self.inner = self.inner.set_confirm_remove_self_bucket_access(input);
267        self
268    }
269    /// <p>Set this parameter to true to confirm that you want to remove your permissions to change this bucket policy in the future.</p><note>
270    /// <p>This functionality is not supported for directory buckets.</p>
271    /// </note>
272    pub fn get_confirm_remove_self_bucket_access(&self) -> &::std::option::Option<bool> {
273        self.inner.get_confirm_remove_self_bucket_access()
274    }
275    /// <p>The bucket policy as a JSON document.</p>
276    /// <p>For directory buckets, the only IAM action supported in the bucket policy is <code>s3express:CreateSession</code>.</p>
277    pub fn policy(mut self, input: impl ::std::convert::Into<::std::string::String>) -> Self {
278        self.inner = self.inner.policy(input.into());
279        self
280    }
281    /// <p>The bucket policy as a JSON document.</p>
282    /// <p>For directory buckets, the only IAM action supported in the bucket policy is <code>s3express:CreateSession</code>.</p>
283    pub fn set_policy(mut self, input: ::std::option::Option<::std::string::String>) -> Self {
284        self.inner = self.inner.set_policy(input);
285        self
286    }
287    /// <p>The bucket policy as a JSON document.</p>
288    /// <p>For directory buckets, the only IAM action supported in the bucket policy is <code>s3express:CreateSession</code>.</p>
289    pub fn get_policy(&self) -> &::std::option::Option<::std::string::String> {
290        self.inner.get_policy()
291    }
292    /// <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>
293    /// <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>
294    /// </note>
295    pub fn expected_bucket_owner(mut self, input: impl ::std::convert::Into<::std::string::String>) -> Self {
296        self.inner = self.inner.expected_bucket_owner(input.into());
297        self
298    }
299    /// <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>
300    /// <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>
301    /// </note>
302    pub fn set_expected_bucket_owner(mut self, input: ::std::option::Option<::std::string::String>) -> Self {
303        self.inner = self.inner.set_expected_bucket_owner(input);
304        self
305    }
306    /// <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>
307    /// <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>
308    /// </note>
309    pub fn get_expected_bucket_owner(&self) -> &::std::option::Option<::std::string::String> {
310        self.inner.get_expected_bucket_owner()
311    }
312}