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><important>
65/// <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>
66/// </important>
67#[derive(::std::clone::Clone, ::std::fmt::Debug)]
68pub struct PutBucketPolicyFluentBuilder {
69    handle: ::std::sync::Arc<crate::client::Handle>,
70    inner: crate::operation::put_bucket_policy::builders::PutBucketPolicyInputBuilder,
71    config_override: ::std::option::Option<crate::config::Builder>,
72}
73impl
74    crate::client::customize::internal::CustomizableSend<
75        crate::operation::put_bucket_policy::PutBucketPolicyOutput,
76        crate::operation::put_bucket_policy::PutBucketPolicyError,
77    > for PutBucketPolicyFluentBuilder
78{
79    fn send(
80        self,
81        config_override: crate::config::Builder,
82    ) -> crate::client::customize::internal::BoxFuture<
83        crate::client::customize::internal::SendResult<
84            crate::operation::put_bucket_policy::PutBucketPolicyOutput,
85            crate::operation::put_bucket_policy::PutBucketPolicyError,
86        >,
87    > {
88        ::std::boxed::Box::pin(async move { self.config_override(config_override).send().await })
89    }
90}
91impl PutBucketPolicyFluentBuilder {
92    /// Creates a new `PutBucketPolicyFluentBuilder`.
93    pub(crate) fn new(handle: ::std::sync::Arc<crate::client::Handle>) -> Self {
94        Self {
95            handle,
96            inner: ::std::default::Default::default(),
97            config_override: ::std::option::Option::None,
98        }
99    }
100    /// Access the PutBucketPolicy as a reference.
101    pub fn as_input(&self) -> &crate::operation::put_bucket_policy::builders::PutBucketPolicyInputBuilder {
102        &self.inner
103    }
104    /// Sends the request and returns the response.
105    ///
106    /// If an error occurs, an `SdkError` will be returned with additional details that
107    /// can be matched against.
108    ///
109    /// By default, any retryable failures will be retried twice. Retry behavior
110    /// is configurable with the [RetryConfig](aws_smithy_types::retry::RetryConfig), which can be
111    /// set when configuring the client.
112    pub async fn send(
113        self,
114    ) -> ::std::result::Result<
115        crate::operation::put_bucket_policy::PutBucketPolicyOutput,
116        ::aws_smithy_runtime_api::client::result::SdkError<
117            crate::operation::put_bucket_policy::PutBucketPolicyError,
118            ::aws_smithy_runtime_api::client::orchestrator::HttpResponse,
119        >,
120    > {
121        let input = self
122            .inner
123            .build()
124            .map_err(::aws_smithy_runtime_api::client::result::SdkError::construction_failure)?;
125        let runtime_plugins = crate::operation::put_bucket_policy::PutBucketPolicy::operation_runtime_plugins(
126            self.handle.runtime_plugins.clone(),
127            &self.handle.conf,
128            self.config_override,
129        );
130        crate::operation::put_bucket_policy::PutBucketPolicy::orchestrate(&runtime_plugins, input).await
131    }
132
133    /// Consumes this builder, creating a customizable operation that can be modified before being sent.
134    pub fn customize(
135        self,
136    ) -> crate::client::customize::CustomizableOperation<
137        crate::operation::put_bucket_policy::PutBucketPolicyOutput,
138        crate::operation::put_bucket_policy::PutBucketPolicyError,
139        Self,
140    > {
141        crate::client::customize::CustomizableOperation::new(self)
142    }
143    pub(crate) fn config_override(mut self, config_override: impl ::std::convert::Into<crate::config::Builder>) -> Self {
144        self.set_config_override(::std::option::Option::Some(config_override.into()));
145        self
146    }
147
148    pub(crate) fn set_config_override(&mut self, config_override: ::std::option::Option<crate::config::Builder>) -> &mut Self {
149        self.config_override = config_override;
150        self
151    }
152    /// <p>The name of the bucket.</p>
153    /// <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>
154    pub fn bucket(mut self, input: impl ::std::convert::Into<::std::string::String>) -> Self {
155        self.inner = self.inner.bucket(input.into());
156        self
157    }
158    /// <p>The name of the bucket.</p>
159    /// <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>
160    pub fn set_bucket(mut self, input: ::std::option::Option<::std::string::String>) -> Self {
161        self.inner = self.inner.set_bucket(input);
162        self
163    }
164    /// <p>The name of the bucket.</p>
165    /// <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>
166    pub fn get_bucket(&self) -> &::std::option::Option<::std::string::String> {
167        self.inner.get_bucket()
168    }
169    /// <p>The MD5 hash of the request body.</p>
170    /// <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>
171    /// <p>This functionality is not supported for directory buckets.</p>
172    /// </note>
173    pub fn content_md5(mut self, input: impl ::std::convert::Into<::std::string::String>) -> Self {
174        self.inner = self.inner.content_md5(input.into());
175        self
176    }
177    /// <p>The MD5 hash of the request body.</p>
178    /// <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>
179    /// <p>This functionality is not supported for directory buckets.</p>
180    /// </note>
181    pub fn set_content_md5(mut self, input: ::std::option::Option<::std::string::String>) -> Self {
182        self.inner = self.inner.set_content_md5(input);
183        self
184    }
185    /// <p>The MD5 hash of the request body.</p>
186    /// <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>
187    /// <p>This functionality is not supported for directory buckets.</p>
188    /// </note>
189    pub fn get_content_md5(&self) -> &::std::option::Option<::std::string::String> {
190        self.inner.get_content_md5()
191    }
192    /// <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>
193    /// <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>
194    /// <ul>
195    /// <li>
196    /// <p><code>CRC32</code></p></li>
197    /// <li>
198    /// <p><code>CRC32C</code></p></li>
199    /// <li>
200    /// <p><code>CRC64NVME</code></p></li>
201    /// <li>
202    /// <p><code>SHA1</code></p></li>
203    /// <li>
204    /// <p><code>SHA256</code></p></li>
205    /// </ul>
206    /// <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>
207    /// <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>
208    /// <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>
209    /// </note>
210    pub fn checksum_algorithm(mut self, input: crate::types::ChecksumAlgorithm) -> Self {
211        self.inner = self.inner.checksum_algorithm(input);
212        self
213    }
214    /// <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>
215    /// <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>
216    /// <ul>
217    /// <li>
218    /// <p><code>CRC32</code></p></li>
219    /// <li>
220    /// <p><code>CRC32C</code></p></li>
221    /// <li>
222    /// <p><code>CRC64NVME</code></p></li>
223    /// <li>
224    /// <p><code>SHA1</code></p></li>
225    /// <li>
226    /// <p><code>SHA256</code></p></li>
227    /// </ul>
228    /// <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>
229    /// <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>
230    /// <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>
231    /// </note>
232    pub fn set_checksum_algorithm(mut self, input: ::std::option::Option<crate::types::ChecksumAlgorithm>) -> Self {
233        self.inner = self.inner.set_checksum_algorithm(input);
234        self
235    }
236    /// <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>
237    /// <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>
238    /// <ul>
239    /// <li>
240    /// <p><code>CRC32</code></p></li>
241    /// <li>
242    /// <p><code>CRC32C</code></p></li>
243    /// <li>
244    /// <p><code>CRC64NVME</code></p></li>
245    /// <li>
246    /// <p><code>SHA1</code></p></li>
247    /// <li>
248    /// <p><code>SHA256</code></p></li>
249    /// </ul>
250    /// <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>
251    /// <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>
252    /// <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>
253    /// </note>
254    pub fn get_checksum_algorithm(&self) -> &::std::option::Option<crate::types::ChecksumAlgorithm> {
255        self.inner.get_checksum_algorithm()
256    }
257    /// <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>
258    /// <p>This functionality is not supported for directory buckets.</p>
259    /// </note>
260    pub fn confirm_remove_self_bucket_access(mut self, input: bool) -> Self {
261        self.inner = self.inner.confirm_remove_self_bucket_access(input);
262        self
263    }
264    /// <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>
265    /// <p>This functionality is not supported for directory buckets.</p>
266    /// </note>
267    pub fn set_confirm_remove_self_bucket_access(mut self, input: ::std::option::Option<bool>) -> Self {
268        self.inner = self.inner.set_confirm_remove_self_bucket_access(input);
269        self
270    }
271    /// <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>
272    /// <p>This functionality is not supported for directory buckets.</p>
273    /// </note>
274    pub fn get_confirm_remove_self_bucket_access(&self) -> &::std::option::Option<bool> {
275        self.inner.get_confirm_remove_self_bucket_access()
276    }
277    /// <p>The bucket policy as a JSON document.</p>
278    /// <p>For directory buckets, the only IAM action supported in the bucket policy is <code>s3express:CreateSession</code>.</p>
279    pub fn policy(mut self, input: impl ::std::convert::Into<::std::string::String>) -> Self {
280        self.inner = self.inner.policy(input.into());
281        self
282    }
283    /// <p>The bucket policy as a JSON document.</p>
284    /// <p>For directory buckets, the only IAM action supported in the bucket policy is <code>s3express:CreateSession</code>.</p>
285    pub fn set_policy(mut self, input: ::std::option::Option<::std::string::String>) -> Self {
286        self.inner = self.inner.set_policy(input);
287        self
288    }
289    /// <p>The bucket policy as a JSON document.</p>
290    /// <p>For directory buckets, the only IAM action supported in the bucket policy is <code>s3express:CreateSession</code>.</p>
291    pub fn get_policy(&self) -> &::std::option::Option<::std::string::String> {
292        self.inner.get_policy()
293    }
294    /// <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>
295    /// <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>
296    /// </note>
297    pub fn expected_bucket_owner(mut self, input: impl ::std::convert::Into<::std::string::String>) -> Self {
298        self.inner = self.inner.expected_bucket_owner(input.into());
299        self
300    }
301    /// <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>
302    /// <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>
303    /// </note>
304    pub fn set_expected_bucket_owner(mut self, input: ::std::option::Option<::std::string::String>) -> Self {
305        self.inner = self.inner.set_expected_bucket_owner(input);
306        self
307    }
308    /// <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>
309    /// <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>
310    /// </note>
311    pub fn get_expected_bucket_owner(&self) -> &::std::option::Option<::std::string::String> {
312        self.inner.get_expected_bucket_owner()
313    }
314}