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, see <a href="https://docs.aws.amazon.com/AmazonS3/latest/userguide/s3-express-Regions-and-Zones.html">Regional and Zonal endpoints</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</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 Availability Zone. Bucket names must also follow the format <code> <i>bucket_base_name</i>--<i>az_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 Availability Zone. Bucket names must also follow the format <code> <i>bucket_base_name</i>--<i>az_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 Availability Zone. Bucket names must also follow the format <code> <i>bucket_base_name</i>--<i>az_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 object 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>CRC32</p></li>
195 /// <li>
196 /// <p>CRC32C</p></li>
197 /// <li>
198 /// <p>SHA1</p></li>
199 /// <li>
200 /// <p>SHA256</p></li>
201 /// </ul>
202 /// <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>
203 /// <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 ignores any provided <code>ChecksumAlgorithm</code> parameter and uses the checksum algorithm that matches the provided value in <code>x-amz-checksum-<i>algorithm</i> </code>.</p><note>
204 /// <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>
205 /// </note>
206 pub fn checksum_algorithm(mut self, input: crate::types::ChecksumAlgorithm) -> Self {
207 self.inner = self.inner.checksum_algorithm(input);
208 self
209 }
210 /// <p>Indicates the algorithm used to create the checksum for the object 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>
211 /// <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>
212 /// <ul>
213 /// <li>
214 /// <p>CRC32</p></li>
215 /// <li>
216 /// <p>CRC32C</p></li>
217 /// <li>
218 /// <p>SHA1</p></li>
219 /// <li>
220 /// <p>SHA256</p></li>
221 /// </ul>
222 /// <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>
223 /// <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 ignores any provided <code>ChecksumAlgorithm</code> parameter and uses the checksum algorithm that matches the provided value in <code>x-amz-checksum-<i>algorithm</i> </code>.</p><note>
224 /// <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>
225 /// </note>
226 pub fn set_checksum_algorithm(mut self, input: ::std::option::Option<crate::types::ChecksumAlgorithm>) -> Self {
227 self.inner = self.inner.set_checksum_algorithm(input);
228 self
229 }
230 /// <p>Indicates the algorithm used to create the checksum for the object 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>
231 /// <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>
232 /// <ul>
233 /// <li>
234 /// <p>CRC32</p></li>
235 /// <li>
236 /// <p>CRC32C</p></li>
237 /// <li>
238 /// <p>SHA1</p></li>
239 /// <li>
240 /// <p>SHA256</p></li>
241 /// </ul>
242 /// <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>
243 /// <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 ignores any provided <code>ChecksumAlgorithm</code> parameter and uses the checksum algorithm that matches the provided value in <code>x-amz-checksum-<i>algorithm</i> </code>.</p><note>
244 /// <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>
245 /// </note>
246 pub fn get_checksum_algorithm(&self) -> &::std::option::Option<crate::types::ChecksumAlgorithm> {
247 self.inner.get_checksum_algorithm()
248 }
249 /// <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>
250 /// <p>This functionality is not supported for directory buckets.</p>
251 /// </note>
252 pub fn confirm_remove_self_bucket_access(mut self, input: bool) -> Self {
253 self.inner = self.inner.confirm_remove_self_bucket_access(input);
254 self
255 }
256 /// <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>
257 /// <p>This functionality is not supported for directory buckets.</p>
258 /// </note>
259 pub fn set_confirm_remove_self_bucket_access(mut self, input: ::std::option::Option<bool>) -> Self {
260 self.inner = self.inner.set_confirm_remove_self_bucket_access(input);
261 self
262 }
263 /// <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>
264 /// <p>This functionality is not supported for directory buckets.</p>
265 /// </note>
266 pub fn get_confirm_remove_self_bucket_access(&self) -> &::std::option::Option<bool> {
267 self.inner.get_confirm_remove_self_bucket_access()
268 }
269 /// <p>The bucket policy as a JSON document.</p>
270 /// <p>For directory buckets, the only IAM action supported in the bucket policy is <code>s3express:CreateSession</code>.</p>
271 pub fn policy(mut self, input: impl ::std::convert::Into<::std::string::String>) -> Self {
272 self.inner = self.inner.policy(input.into());
273 self
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 set_policy(mut self, input: ::std::option::Option<::std::string::String>) -> Self {
278 self.inner = self.inner.set_policy(input);
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 get_policy(&self) -> &::std::option::Option<::std::string::String> {
284 self.inner.get_policy()
285 }
286 /// <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>
287 /// <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>
288 /// </note>
289 pub fn expected_bucket_owner(mut self, input: impl ::std::convert::Into<::std::string::String>) -> Self {
290 self.inner = self.inner.expected_bucket_owner(input.into());
291 self
292 }
293 /// <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>
294 /// <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>
295 /// </note>
296 pub fn set_expected_bucket_owner(mut self, input: ::std::option::Option<::std::string::String>) -> Self {
297 self.inner = self.inner.set_expected_bucket_owner(input);
298 self
299 }
300 /// <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>
301 /// <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>
302 /// </note>
303 pub fn get_expected_bucket_owner(&self) -> &::std::option::Option<::std::string::String> {
304 self.inner.get_expected_bucket_owner()
305 }
306}