aws_sdk_s3/operation/put_bucket_encryption/builders.rs
1// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
2pub use crate::operation::put_bucket_encryption::_put_bucket_encryption_output::PutBucketEncryptionOutputBuilder;
3
4pub use crate::operation::put_bucket_encryption::_put_bucket_encryption_input::PutBucketEncryptionInputBuilder;
5
6impl crate::operation::put_bucket_encryption::builders::PutBucketEncryptionInputBuilder {
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_encryption::PutBucketEncryptionOutput,
13 ::aws_smithy_runtime_api::client::result::SdkError<
14 crate::operation::put_bucket_encryption::PutBucketEncryptionError,
15 ::aws_smithy_runtime_api::client::orchestrator::HttpResponse,
16 >,
17 > {
18 let mut fluent_builder = client.put_bucket_encryption();
19 fluent_builder.inner = self;
20 fluent_builder.send().await
21 }
22}
23/// Fluent builder constructing a request to `PutBucketEncryption`.
24///
25/// <p>This operation configures default encryption and Amazon S3 Bucket Keys for an existing 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/// <p>By default, all buckets have a default encryption configuration that uses server-side encryption with Amazon S3 managed keys (SSE-S3).</p><note>
29/// <ul>
30/// <li>
31/// <p><b>General purpose buckets</b></p>
32/// <ul>
33/// <li>
34/// <p>You can optionally configure default encryption for a bucket by using server-side encryption with Key Management Service (KMS) keys (SSE-KMS) or dual-layer server-side encryption with Amazon Web Services KMS keys (DSSE-KMS). If you specify default encryption by using SSE-KMS, you can also configure <a href="https://docs.aws.amazon.com/AmazonS3/latest/dev/bucket-key.html">Amazon S3 Bucket Keys</a>. For information about the bucket default encryption feature, see <a href="https://docs.aws.amazon.com/AmazonS3/latest/dev/bucket-encryption.html">Amazon S3 Bucket Default Encryption</a> in the <i>Amazon S3 User Guide</i>.</p></li>
35/// <li>
36/// <p>If you use PutBucketEncryption to set your <a href="https://docs.aws.amazon.com/AmazonS3/latest/dev/bucket-encryption.html">default bucket encryption</a> to SSE-KMS, you should verify that your KMS key ID is correct. Amazon S3 doesn't validate the KMS key ID provided in PutBucketEncryption requests.</p></li>
37/// </ul></li>
38/// <li>
39/// <p><b>Directory buckets </b> - You can optionally configure default encryption for a bucket by using server-side encryption with Key Management Service (KMS) keys (SSE-KMS).</p>
40/// <ul>
41/// <li>
42/// <p>We recommend that the bucket's default encryption uses the desired encryption configuration and you don't override the bucket default encryption in your <code>CreateSession</code> requests or <code>PUT</code> object requests. Then, new objects are automatically encrypted with the desired encryption settings. For more information about the encryption overriding behaviors in directory buckets, see <a href="https://docs.aws.amazon.com/AmazonS3/latest/userguide/s3-express-specifying-kms-encryption.html">Specifying server-side encryption with KMS for new object uploads</a>.</p></li>
43/// <li>
44/// <p>Your SSE-KMS configuration can only support 1 <a href="https://docs.aws.amazon.com/kms/latest/developerguide/concepts.html#customer-cmk">customer managed key</a> per directory bucket's lifetime. The <a href="https://docs.aws.amazon.com/kms/latest/developerguide/concepts.html#aws-managed-cmk">Amazon Web Services managed key</a> (<code>aws/s3</code>) isn't supported.</p></li>
45/// <li>
46/// <p>S3 Bucket Keys are always enabled for <code>GET</code> and <code>PUT</code> operations in a directory bucket and can’t be disabled. S3 Bucket Keys aren't supported, when you copy SSE-KMS encrypted objects from general purpose buckets to directory buckets, from directory buckets to general purpose buckets, or between directory buckets, through <a href="https://docs.aws.amazon.com/AmazonS3/latest/API/API_CopyObject.html">CopyObject</a>, <a href="https://docs.aws.amazon.com/AmazonS3/latest/API/API_UploadPartCopy.html">UploadPartCopy</a>, <a href="https://docs.aws.amazon.com/AmazonS3/latest/userguide/directory-buckets-objects-Batch-Ops">the Copy operation in Batch Operations</a>, or <a href="https://docs.aws.amazon.com/AmazonS3/latest/userguide/create-import-job">the import jobs</a>. In this case, Amazon S3 makes a call to KMS every time a copy request is made for a KMS-encrypted object.</p></li>
47/// <li>
48/// <p>When you specify an <a href="https://docs.aws.amazon.com/kms/latest/developerguide/concepts.html#customer-cmk">KMS customer managed key</a> for encryption in your directory bucket, only use the key ID or key ARN. The key alias format of the KMS key isn't supported.</p></li>
49/// <li>
50/// <p>For directory buckets, if you use PutBucketEncryption to set your <a href="https://docs.aws.amazon.com/AmazonS3/latest/dev/bucket-encryption.html">default bucket encryption</a> to SSE-KMS, Amazon S3 validates the KMS key ID provided in PutBucketEncryption requests.</p></li>
51/// </ul></li>
52/// </ul>
53/// </note> <important>
54/// <p>If you're specifying a customer managed KMS key, we recommend using a fully qualified KMS key ARN. If you use a KMS key alias instead, then KMS resolves the key within the requester’s account. This behavior can result in data that's encrypted with a KMS key that belongs to the requester, and not the bucket owner.</p>
55/// <p>Also, this action requires Amazon Web Services Signature Version 4. For more information, see <a href="https://docs.aws.amazon.com/AmazonS3/latest/API/sig-v4-authenticating-requests.html"> Authenticating Requests (Amazon Web Services Signature Version 4)</a>.</p>
56/// </important>
57/// <dl>
58/// <dt>
59/// Permissions
60/// </dt>
61/// <dd>
62/// <ul>
63/// <li>
64/// <p><b>General purpose bucket permissions</b> - The <code>s3:PutEncryptionConfiguration</code> permission is required in a policy. 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 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> in the <i>Amazon S3 User Guide</i>.</p></li>
65/// <li>
66/// <p><b>Directory bucket permissions</b> - To grant access to this API operation, you must have the <code>s3express:PutEncryptionConfiguration</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>
67/// <p>To set a directory bucket default encryption with SSE-KMS, you must also have the <code>kms:GenerateDataKey</code> and the <code>kms:Decrypt</code> permissions in IAM identity-based policies and KMS key policies for the target KMS key.</p></li>
68/// </ul>
69/// </dd>
70/// <dt>
71/// HTTP Host header syntax
72/// </dt>
73/// <dd>
74/// <p><b>Directory buckets </b> - The HTTP Host header syntax is <code>s3express-control.<i>region-code</i>.amazonaws.com</code>.</p>
75/// </dd>
76/// </dl>
77/// <p>The following operations are related to <code>PutBucketEncryption</code>:</p>
78/// <ul>
79/// <li>
80/// <p><a href="https://docs.aws.amazon.com/AmazonS3/latest/API/API_GetBucketEncryption.html">GetBucketEncryption</a></p></li>
81/// <li>
82/// <p><a href="https://docs.aws.amazon.com/AmazonS3/latest/API/API_DeleteBucketEncryption.html">DeleteBucketEncryption</a></p></li>
83/// </ul><important>
84/// <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>
85/// </important>
86#[derive(::std::clone::Clone, ::std::fmt::Debug)]
87pub struct PutBucketEncryptionFluentBuilder {
88 handle: ::std::sync::Arc<crate::client::Handle>,
89 inner: crate::operation::put_bucket_encryption::builders::PutBucketEncryptionInputBuilder,
90 config_override: ::std::option::Option<crate::config::Builder>,
91}
92impl
93 crate::client::customize::internal::CustomizableSend<
94 crate::operation::put_bucket_encryption::PutBucketEncryptionOutput,
95 crate::operation::put_bucket_encryption::PutBucketEncryptionError,
96 > for PutBucketEncryptionFluentBuilder
97{
98 fn send(
99 self,
100 config_override: crate::config::Builder,
101 ) -> crate::client::customize::internal::BoxFuture<
102 crate::client::customize::internal::SendResult<
103 crate::operation::put_bucket_encryption::PutBucketEncryptionOutput,
104 crate::operation::put_bucket_encryption::PutBucketEncryptionError,
105 >,
106 > {
107 ::std::boxed::Box::pin(async move { self.config_override(config_override).send().await })
108 }
109}
110impl PutBucketEncryptionFluentBuilder {
111 /// Creates a new `PutBucketEncryptionFluentBuilder`.
112 pub(crate) fn new(handle: ::std::sync::Arc<crate::client::Handle>) -> Self {
113 Self {
114 handle,
115 inner: ::std::default::Default::default(),
116 config_override: ::std::option::Option::None,
117 }
118 }
119 /// Access the PutBucketEncryption as a reference.
120 pub fn as_input(&self) -> &crate::operation::put_bucket_encryption::builders::PutBucketEncryptionInputBuilder {
121 &self.inner
122 }
123 /// Sends the request and returns the response.
124 ///
125 /// If an error occurs, an `SdkError` will be returned with additional details that
126 /// can be matched against.
127 ///
128 /// By default, any retryable failures will be retried twice. Retry behavior
129 /// is configurable with the [RetryConfig](aws_smithy_types::retry::RetryConfig), which can be
130 /// set when configuring the client.
131 pub async fn send(
132 self,
133 ) -> ::std::result::Result<
134 crate::operation::put_bucket_encryption::PutBucketEncryptionOutput,
135 ::aws_smithy_runtime_api::client::result::SdkError<
136 crate::operation::put_bucket_encryption::PutBucketEncryptionError,
137 ::aws_smithy_runtime_api::client::orchestrator::HttpResponse,
138 >,
139 > {
140 let input = self
141 .inner
142 .build()
143 .map_err(::aws_smithy_runtime_api::client::result::SdkError::construction_failure)?;
144 let runtime_plugins = crate::operation::put_bucket_encryption::PutBucketEncryption::operation_runtime_plugins(
145 self.handle.runtime_plugins.clone(),
146 &self.handle.conf,
147 self.config_override,
148 );
149 crate::operation::put_bucket_encryption::PutBucketEncryption::orchestrate(&runtime_plugins, input).await
150 }
151
152 /// Consumes this builder, creating a customizable operation that can be modified before being sent.
153 pub fn customize(
154 self,
155 ) -> crate::client::customize::CustomizableOperation<
156 crate::operation::put_bucket_encryption::PutBucketEncryptionOutput,
157 crate::operation::put_bucket_encryption::PutBucketEncryptionError,
158 Self,
159 > {
160 crate::client::customize::CustomizableOperation::new(self)
161 }
162 pub(crate) fn config_override(mut self, config_override: impl ::std::convert::Into<crate::config::Builder>) -> Self {
163 self.set_config_override(::std::option::Option::Some(config_override.into()));
164 self
165 }
166
167 pub(crate) fn set_config_override(&mut self, config_override: ::std::option::Option<crate::config::Builder>) -> &mut Self {
168 self.config_override = config_override;
169 self
170 }
171 /// <p>Specifies default encryption for a bucket using server-side encryption with different key options.</p>
172 /// <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>
173 pub fn bucket(mut self, input: impl ::std::convert::Into<::std::string::String>) -> Self {
174 self.inner = self.inner.bucket(input.into());
175 self
176 }
177 /// <p>Specifies default encryption for a bucket using server-side encryption with different key options.</p>
178 /// <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>
179 pub fn set_bucket(mut self, input: ::std::option::Option<::std::string::String>) -> Self {
180 self.inner = self.inner.set_bucket(input);
181 self
182 }
183 /// <p>Specifies default encryption for a bucket using server-side encryption with different key options.</p>
184 /// <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>
185 pub fn get_bucket(&self) -> &::std::option::Option<::std::string::String> {
186 self.inner.get_bucket()
187 }
188 /// <p>The Base64 encoded 128-bit <code>MD5</code> digest of the server-side encryption configuration.</p>
189 /// <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>
190 /// <p>This functionality is not supported for directory buckets.</p>
191 /// </note>
192 pub fn content_md5(mut self, input: impl ::std::convert::Into<::std::string::String>) -> Self {
193 self.inner = self.inner.content_md5(input.into());
194 self
195 }
196 /// <p>The Base64 encoded 128-bit <code>MD5</code> digest of the server-side encryption configuration.</p>
197 /// <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>
198 /// <p>This functionality is not supported for directory buckets.</p>
199 /// </note>
200 pub fn set_content_md5(mut self, input: ::std::option::Option<::std::string::String>) -> Self {
201 self.inner = self.inner.set_content_md5(input);
202 self
203 }
204 /// <p>The Base64 encoded 128-bit <code>MD5</code> digest of the server-side encryption configuration.</p>
205 /// <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>
206 /// <p>This functionality is not supported for directory buckets.</p>
207 /// </note>
208 pub fn get_content_md5(&self) -> &::std::option::Option<::std::string::String> {
209 self.inner.get_content_md5()
210 }
211 /// <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</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>. 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>
212 /// <p>If you provide an individual checksum, Amazon S3 ignores any provided <code>ChecksumAlgorithm</code> parameter.</p><note>
213 /// <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>
214 /// </note>
215 pub fn checksum_algorithm(mut self, input: crate::types::ChecksumAlgorithm) -> Self {
216 self.inner = self.inner.checksum_algorithm(input);
217 self
218 }
219 /// <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</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>. 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>
220 /// <p>If you provide an individual checksum, Amazon S3 ignores any provided <code>ChecksumAlgorithm</code> parameter.</p><note>
221 /// <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>
222 /// </note>
223 pub fn set_checksum_algorithm(mut self, input: ::std::option::Option<crate::types::ChecksumAlgorithm>) -> Self {
224 self.inner = self.inner.set_checksum_algorithm(input);
225 self
226 }
227 /// <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</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>. 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>
228 /// <p>If you provide an individual checksum, Amazon S3 ignores any provided <code>ChecksumAlgorithm</code> parameter.</p><note>
229 /// <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>
230 /// </note>
231 pub fn get_checksum_algorithm(&self) -> &::std::option::Option<crate::types::ChecksumAlgorithm> {
232 self.inner.get_checksum_algorithm()
233 }
234 /// <p>Specifies the default server-side-encryption configuration.</p>
235 pub fn server_side_encryption_configuration(mut self, input: crate::types::ServerSideEncryptionConfiguration) -> Self {
236 self.inner = self.inner.server_side_encryption_configuration(input);
237 self
238 }
239 /// <p>Specifies the default server-side-encryption configuration.</p>
240 pub fn set_server_side_encryption_configuration(mut self, input: ::std::option::Option<crate::types::ServerSideEncryptionConfiguration>) -> Self {
241 self.inner = self.inner.set_server_side_encryption_configuration(input);
242 self
243 }
244 /// <p>Specifies the default server-side-encryption configuration.</p>
245 pub fn get_server_side_encryption_configuration(&self) -> &::std::option::Option<crate::types::ServerSideEncryptionConfiguration> {
246 self.inner.get_server_side_encryption_configuration()
247 }
248 /// <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>
249 /// <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>
250 /// </note>
251 pub fn expected_bucket_owner(mut self, input: impl ::std::convert::Into<::std::string::String>) -> Self {
252 self.inner = self.inner.expected_bucket_owner(input.into());
253 self
254 }
255 /// <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>
256 /// <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>
257 /// </note>
258 pub fn set_expected_bucket_owner(mut self, input: ::std::option::Option<::std::string::String>) -> Self {
259 self.inner = self.inner.set_expected_bucket_owner(input);
260 self
261 }
262 /// <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>
263 /// <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>
264 /// </note>
265 pub fn get_expected_bucket_owner(&self) -> &::std::option::Option<::std::string::String> {
266 self.inner.get_expected_bucket_owner()
267 }
268}