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>
84#[derive(::std::clone::Clone, ::std::fmt::Debug)]
85pub struct PutBucketEncryptionFluentBuilder {
86    handle: ::std::sync::Arc<crate::client::Handle>,
87    inner: crate::operation::put_bucket_encryption::builders::PutBucketEncryptionInputBuilder,
88    config_override: ::std::option::Option<crate::config::Builder>,
89}
90impl
91    crate::client::customize::internal::CustomizableSend<
92        crate::operation::put_bucket_encryption::PutBucketEncryptionOutput,
93        crate::operation::put_bucket_encryption::PutBucketEncryptionError,
94    > for PutBucketEncryptionFluentBuilder
95{
96    fn send(
97        self,
98        config_override: crate::config::Builder,
99    ) -> crate::client::customize::internal::BoxFuture<
100        crate::client::customize::internal::SendResult<
101            crate::operation::put_bucket_encryption::PutBucketEncryptionOutput,
102            crate::operation::put_bucket_encryption::PutBucketEncryptionError,
103        >,
104    > {
105        ::std::boxed::Box::pin(async move { self.config_override(config_override).send().await })
106    }
107}
108impl PutBucketEncryptionFluentBuilder {
109    /// Creates a new `PutBucketEncryptionFluentBuilder`.
110    pub(crate) fn new(handle: ::std::sync::Arc<crate::client::Handle>) -> Self {
111        Self {
112            handle,
113            inner: ::std::default::Default::default(),
114            config_override: ::std::option::Option::None,
115        }
116    }
117    /// Access the PutBucketEncryption as a reference.
118    pub fn as_input(&self) -> &crate::operation::put_bucket_encryption::builders::PutBucketEncryptionInputBuilder {
119        &self.inner
120    }
121    /// Sends the request and returns the response.
122    ///
123    /// If an error occurs, an `SdkError` will be returned with additional details that
124    /// can be matched against.
125    ///
126    /// By default, any retryable failures will be retried twice. Retry behavior
127    /// is configurable with the [RetryConfig](aws_smithy_types::retry::RetryConfig), which can be
128    /// set when configuring the client.
129    pub async fn send(
130        self,
131    ) -> ::std::result::Result<
132        crate::operation::put_bucket_encryption::PutBucketEncryptionOutput,
133        ::aws_smithy_runtime_api::client::result::SdkError<
134            crate::operation::put_bucket_encryption::PutBucketEncryptionError,
135            ::aws_smithy_runtime_api::client::orchestrator::HttpResponse,
136        >,
137    > {
138        let input = self
139            .inner
140            .build()
141            .map_err(::aws_smithy_runtime_api::client::result::SdkError::construction_failure)?;
142        let runtime_plugins = crate::operation::put_bucket_encryption::PutBucketEncryption::operation_runtime_plugins(
143            self.handle.runtime_plugins.clone(),
144            &self.handle.conf,
145            self.config_override,
146        );
147        crate::operation::put_bucket_encryption::PutBucketEncryption::orchestrate(&runtime_plugins, input).await
148    }
149
150    /// Consumes this builder, creating a customizable operation that can be modified before being sent.
151    pub fn customize(
152        self,
153    ) -> crate::client::customize::CustomizableOperation<
154        crate::operation::put_bucket_encryption::PutBucketEncryptionOutput,
155        crate::operation::put_bucket_encryption::PutBucketEncryptionError,
156        Self,
157    > {
158        crate::client::customize::CustomizableOperation::new(self)
159    }
160    pub(crate) fn config_override(mut self, config_override: impl ::std::convert::Into<crate::config::Builder>) -> Self {
161        self.set_config_override(::std::option::Option::Some(config_override.into()));
162        self
163    }
164
165    pub(crate) fn set_config_override(&mut self, config_override: ::std::option::Option<crate::config::Builder>) -> &mut Self {
166        self.config_override = config_override;
167        self
168    }
169    /// <p>Specifies default encryption for a bucket using server-side encryption with different key options.</p>
170    /// <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>
171    pub fn bucket(mut self, input: impl ::std::convert::Into<::std::string::String>) -> Self {
172        self.inner = self.inner.bucket(input.into());
173        self
174    }
175    /// <p>Specifies default encryption for a bucket using server-side encryption with different key options.</p>
176    /// <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>
177    pub fn set_bucket(mut self, input: ::std::option::Option<::std::string::String>) -> Self {
178        self.inner = self.inner.set_bucket(input);
179        self
180    }
181    /// <p>Specifies default encryption for a bucket using server-side encryption with different key options.</p>
182    /// <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>
183    pub fn get_bucket(&self) -> &::std::option::Option<::std::string::String> {
184        self.inner.get_bucket()
185    }
186    /// <p>The Base64 encoded 128-bit <code>MD5</code> digest of the server-side encryption configuration.</p>
187    /// <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>
188    /// <p>This functionality is not supported for directory buckets.</p>
189    /// </note>
190    pub fn content_md5(mut self, input: impl ::std::convert::Into<::std::string::String>) -> Self {
191        self.inner = self.inner.content_md5(input.into());
192        self
193    }
194    /// <p>The Base64 encoded 128-bit <code>MD5</code> digest of the server-side encryption configuration.</p>
195    /// <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>
196    /// <p>This functionality is not supported for directory buckets.</p>
197    /// </note>
198    pub fn set_content_md5(mut self, input: ::std::option::Option<::std::string::String>) -> Self {
199        self.inner = self.inner.set_content_md5(input);
200        self
201    }
202    /// <p>The Base64 encoded 128-bit <code>MD5</code> digest of the server-side encryption configuration.</p>
203    /// <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>
204    /// <p>This functionality is not supported for directory buckets.</p>
205    /// </note>
206    pub fn get_content_md5(&self) -> &::std::option::Option<::std::string::String> {
207        self.inner.get_content_md5()
208    }
209    /// <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>
210    /// <p>If you provide an individual checksum, Amazon S3 ignores any provided <code>ChecksumAlgorithm</code> parameter.</p><note>
211    /// <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>
212    /// </note>
213    pub fn checksum_algorithm(mut self, input: crate::types::ChecksumAlgorithm) -> Self {
214        self.inner = self.inner.checksum_algorithm(input);
215        self
216    }
217    /// <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>
218    /// <p>If you provide an individual checksum, Amazon S3 ignores any provided <code>ChecksumAlgorithm</code> parameter.</p><note>
219    /// <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>
220    /// </note>
221    pub fn set_checksum_algorithm(mut self, input: ::std::option::Option<crate::types::ChecksumAlgorithm>) -> Self {
222        self.inner = self.inner.set_checksum_algorithm(input);
223        self
224    }
225    /// <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>
226    /// <p>If you provide an individual checksum, Amazon S3 ignores any provided <code>ChecksumAlgorithm</code> parameter.</p><note>
227    /// <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>
228    /// </note>
229    pub fn get_checksum_algorithm(&self) -> &::std::option::Option<crate::types::ChecksumAlgorithm> {
230        self.inner.get_checksum_algorithm()
231    }
232    /// <p>Specifies the default server-side-encryption configuration.</p>
233    pub fn server_side_encryption_configuration(mut self, input: crate::types::ServerSideEncryptionConfiguration) -> Self {
234        self.inner = self.inner.server_side_encryption_configuration(input);
235        self
236    }
237    /// <p>Specifies the default server-side-encryption configuration.</p>
238    pub fn set_server_side_encryption_configuration(mut self, input: ::std::option::Option<crate::types::ServerSideEncryptionConfiguration>) -> Self {
239        self.inner = self.inner.set_server_side_encryption_configuration(input);
240        self
241    }
242    /// <p>Specifies the default server-side-encryption configuration.</p>
243    pub fn get_server_side_encryption_configuration(&self) -> &::std::option::Option<crate::types::ServerSideEncryptionConfiguration> {
244        self.inner.get_server_side_encryption_configuration()
245    }
246    /// <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>
247    /// <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>
248    /// </note>
249    pub fn expected_bucket_owner(mut self, input: impl ::std::convert::Into<::std::string::String>) -> Self {
250        self.inner = self.inner.expected_bucket_owner(input.into());
251        self
252    }
253    /// <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>
254    /// <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>
255    /// </note>
256    pub fn set_expected_bucket_owner(mut self, input: ::std::option::Option<::std::string::String>) -> Self {
257        self.inner = self.inner.set_expected_bucket_owner(input);
258        self
259    }
260    /// <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>
261    /// <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>
262    /// </note>
263    pub fn get_expected_bucket_owner(&self) -> &::std::option::Option<::std::string::String> {
264        self.inner.get_expected_bucket_owner()
265    }
266}