aws_sdk_s3/operation/put_bucket_cors/
builders.rs

1// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
2pub use crate::operation::put_bucket_cors::_put_bucket_cors_output::PutBucketCorsOutputBuilder;
3
4pub use crate::operation::put_bucket_cors::_put_bucket_cors_input::PutBucketCorsInputBuilder;
5
6impl crate::operation::put_bucket_cors::builders::PutBucketCorsInputBuilder {
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_cors::PutBucketCorsOutput,
13        ::aws_smithy_runtime_api::client::result::SdkError<
14            crate::operation::put_bucket_cors::PutBucketCorsError,
15            ::aws_smithy_runtime_api::client::orchestrator::HttpResponse,
16        >,
17    > {
18        let mut fluent_builder = client.put_bucket_cors();
19        fluent_builder.inner = self;
20        fluent_builder.send().await
21    }
22}
23/// Fluent builder constructing a request to `PutBucketCors`.
24///
25/// <note>
26/// <p>This operation is not supported for directory buckets.</p>
27/// </note>
28/// <p>Sets the <code>cors</code> configuration for your bucket. If the configuration exists, Amazon S3 replaces it.</p>
29/// <p>To use this operation, you must be allowed to perform the <code>s3:PutBucketCORS</code> action. By default, the bucket owner has this permission and can grant it to others.</p>
30/// <p>You set this configuration on a bucket so that the bucket can service cross-origin requests. For example, you might want to enable a request whose origin is <code>http://www.example.com</code> to access your Amazon S3 bucket at <code>my.example.bucket.com</code> by using the browser's <code>XMLHttpRequest</code> capability.</p>
31/// <p>To enable cross-origin resource sharing (CORS) on a bucket, you add the <code>cors</code> subresource to the bucket. The <code>cors</code> subresource is an XML document in which you configure rules that identify origins and the HTTP methods that can be executed on your bucket. The document is limited to 64 KB in size.</p>
32/// <p>When Amazon S3 receives a cross-origin request (or a pre-flight OPTIONS request) against a bucket, it evaluates the <code>cors</code> configuration on the bucket and uses the first <code>CORSRule</code> rule that matches the incoming browser request to enable a cross-origin request. For a rule to match, the following conditions must be met:</p>
33/// <ul>
34/// <li>
35/// <p>The request's <code>Origin</code> header must match <code>AllowedOrigin</code> elements.</p></li>
36/// <li>
37/// <p>The request method (for example, GET, PUT, HEAD, and so on) or the <code>Access-Control-Request-Method</code> header in case of a pre-flight <code>OPTIONS</code> request must be one of the <code>AllowedMethod</code> elements.</p></li>
38/// <li>
39/// <p>Every header specified in the <code>Access-Control-Request-Headers</code> request header of a pre-flight request must match an <code>AllowedHeader</code> element.</p></li>
40/// </ul>
41/// <p>For more information about CORS, go to <a href="https://docs.aws.amazon.com/AmazonS3/latest/dev/cors.html">Enabling Cross-Origin Resource Sharing</a> in the <i>Amazon S3 User Guide</i>.</p>
42/// <p>The following operations are related to <code>PutBucketCors</code>:</p>
43/// <ul>
44/// <li>
45/// <p><a href="https://docs.aws.amazon.com/AmazonS3/latest/API/API_GetBucketCors.html">GetBucketCors</a></p></li>
46/// <li>
47/// <p><a href="https://docs.aws.amazon.com/AmazonS3/latest/API/API_DeleteBucketCors.html">DeleteBucketCors</a></p></li>
48/// <li>
49/// <p><a href="https://docs.aws.amazon.com/AmazonS3/latest/API/RESTOPTIONSobject.html">RESTOPTIONSobject</a></p></li>
50/// </ul><important>
51/// <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>
52/// </important>
53#[derive(::std::clone::Clone, ::std::fmt::Debug)]
54pub struct PutBucketCorsFluentBuilder {
55    handle: ::std::sync::Arc<crate::client::Handle>,
56    inner: crate::operation::put_bucket_cors::builders::PutBucketCorsInputBuilder,
57    config_override: ::std::option::Option<crate::config::Builder>,
58}
59impl
60    crate::client::customize::internal::CustomizableSend<
61        crate::operation::put_bucket_cors::PutBucketCorsOutput,
62        crate::operation::put_bucket_cors::PutBucketCorsError,
63    > for PutBucketCorsFluentBuilder
64{
65    fn send(
66        self,
67        config_override: crate::config::Builder,
68    ) -> crate::client::customize::internal::BoxFuture<
69        crate::client::customize::internal::SendResult<
70            crate::operation::put_bucket_cors::PutBucketCorsOutput,
71            crate::operation::put_bucket_cors::PutBucketCorsError,
72        >,
73    > {
74        ::std::boxed::Box::pin(async move { self.config_override(config_override).send().await })
75    }
76}
77impl PutBucketCorsFluentBuilder {
78    /// Creates a new `PutBucketCorsFluentBuilder`.
79    pub(crate) fn new(handle: ::std::sync::Arc<crate::client::Handle>) -> Self {
80        Self {
81            handle,
82            inner: ::std::default::Default::default(),
83            config_override: ::std::option::Option::None,
84        }
85    }
86    /// Access the PutBucketCors as a reference.
87    pub fn as_input(&self) -> &crate::operation::put_bucket_cors::builders::PutBucketCorsInputBuilder {
88        &self.inner
89    }
90    /// Sends the request and returns the response.
91    ///
92    /// If an error occurs, an `SdkError` will be returned with additional details that
93    /// can be matched against.
94    ///
95    /// By default, any retryable failures will be retried twice. Retry behavior
96    /// is configurable with the [RetryConfig](aws_smithy_types::retry::RetryConfig), which can be
97    /// set when configuring the client.
98    pub async fn send(
99        self,
100    ) -> ::std::result::Result<
101        crate::operation::put_bucket_cors::PutBucketCorsOutput,
102        ::aws_smithy_runtime_api::client::result::SdkError<
103            crate::operation::put_bucket_cors::PutBucketCorsError,
104            ::aws_smithy_runtime_api::client::orchestrator::HttpResponse,
105        >,
106    > {
107        let input = self
108            .inner
109            .build()
110            .map_err(::aws_smithy_runtime_api::client::result::SdkError::construction_failure)?;
111        let runtime_plugins = crate::operation::put_bucket_cors::PutBucketCors::operation_runtime_plugins(
112            self.handle.runtime_plugins.clone(),
113            &self.handle.conf,
114            self.config_override,
115        );
116        crate::operation::put_bucket_cors::PutBucketCors::orchestrate(&runtime_plugins, input).await
117    }
118
119    /// Consumes this builder, creating a customizable operation that can be modified before being sent.
120    pub fn customize(
121        self,
122    ) -> crate::client::customize::CustomizableOperation<
123        crate::operation::put_bucket_cors::PutBucketCorsOutput,
124        crate::operation::put_bucket_cors::PutBucketCorsError,
125        Self,
126    > {
127        crate::client::customize::CustomizableOperation::new(self)
128    }
129    pub(crate) fn config_override(mut self, config_override: impl ::std::convert::Into<crate::config::Builder>) -> Self {
130        self.set_config_override(::std::option::Option::Some(config_override.into()));
131        self
132    }
133
134    pub(crate) fn set_config_override(&mut self, config_override: ::std::option::Option<crate::config::Builder>) -> &mut Self {
135        self.config_override = config_override;
136        self
137    }
138    /// <p>Specifies the bucket impacted by the <code>cors</code>configuration.</p>
139    pub fn bucket(mut self, input: impl ::std::convert::Into<::std::string::String>) -> Self {
140        self.inner = self.inner.bucket(input.into());
141        self
142    }
143    /// <p>Specifies the bucket impacted by the <code>cors</code>configuration.</p>
144    pub fn set_bucket(mut self, input: ::std::option::Option<::std::string::String>) -> Self {
145        self.inner = self.inner.set_bucket(input);
146        self
147    }
148    /// <p>Specifies the bucket impacted by the <code>cors</code>configuration.</p>
149    pub fn get_bucket(&self) -> &::std::option::Option<::std::string::String> {
150        self.inner.get_bucket()
151    }
152    /// <p>Describes the cross-origin access configuration for objects in an Amazon S3 bucket. For more information, see <a href="https://docs.aws.amazon.com/AmazonS3/latest/dev/cors.html">Enabling Cross-Origin Resource Sharing</a> in the <i>Amazon S3 User Guide</i>.</p>
153    pub fn cors_configuration(mut self, input: crate::types::CorsConfiguration) -> Self {
154        self.inner = self.inner.cors_configuration(input);
155        self
156    }
157    /// <p>Describes the cross-origin access configuration for objects in an Amazon S3 bucket. For more information, see <a href="https://docs.aws.amazon.com/AmazonS3/latest/dev/cors.html">Enabling Cross-Origin Resource Sharing</a> in the <i>Amazon S3 User Guide</i>.</p>
158    pub fn set_cors_configuration(mut self, input: ::std::option::Option<crate::types::CorsConfiguration>) -> Self {
159        self.inner = self.inner.set_cors_configuration(input);
160        self
161    }
162    /// <p>Describes the cross-origin access configuration for objects in an Amazon S3 bucket. For more information, see <a href="https://docs.aws.amazon.com/AmazonS3/latest/dev/cors.html">Enabling Cross-Origin Resource Sharing</a> in the <i>Amazon S3 User Guide</i>.</p>
163    pub fn get_cors_configuration(&self) -> &::std::option::Option<crate::types::CorsConfiguration> {
164        self.inner.get_cors_configuration()
165    }
166    /// <p>The Base64 encoded 128-bit <code>MD5</code> digest of the data. This header must be used as a message integrity check to verify that the request body was not corrupted in transit. For more information, go to <a href="http://www.ietf.org/rfc/rfc1864.txt">RFC 1864.</a></p>
167    /// <p>For requests made using the Amazon Web Services Command Line Interface (CLI) or Amazon Web Services SDKs, this field is calculated automatically.</p>
168    pub fn content_md5(mut self, input: impl ::std::convert::Into<::std::string::String>) -> Self {
169        self.inner = self.inner.content_md5(input.into());
170        self
171    }
172    /// <p>The Base64 encoded 128-bit <code>MD5</code> digest of the data. This header must be used as a message integrity check to verify that the request body was not corrupted in transit. For more information, go to <a href="http://www.ietf.org/rfc/rfc1864.txt">RFC 1864.</a></p>
173    /// <p>For requests made using the Amazon Web Services Command Line Interface (CLI) or Amazon Web Services SDKs, this field is calculated automatically.</p>
174    pub fn set_content_md5(mut self, input: ::std::option::Option<::std::string::String>) -> Self {
175        self.inner = self.inner.set_content_md5(input);
176        self
177    }
178    /// <p>The Base64 encoded 128-bit <code>MD5</code> digest of the data. This header must be used as a message integrity check to verify that the request body was not corrupted in transit. For more information, go to <a href="http://www.ietf.org/rfc/rfc1864.txt">RFC 1864.</a></p>
179    /// <p>For requests made using the Amazon Web Services Command Line Interface (CLI) or Amazon Web Services SDKs, this field is calculated automatically.</p>
180    pub fn get_content_md5(&self) -> &::std::option::Option<::std::string::String> {
181        self.inner.get_content_md5()
182    }
183    /// <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>
184    /// <p>If you provide an individual checksum, Amazon S3 ignores any provided <code>ChecksumAlgorithm</code> parameter.</p>
185    pub fn checksum_algorithm(mut self, input: crate::types::ChecksumAlgorithm) -> Self {
186        self.inner = self.inner.checksum_algorithm(input);
187        self
188    }
189    /// <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>
190    /// <p>If you provide an individual checksum, Amazon S3 ignores any provided <code>ChecksumAlgorithm</code> parameter.</p>
191    pub fn set_checksum_algorithm(mut self, input: ::std::option::Option<crate::types::ChecksumAlgorithm>) -> Self {
192        self.inner = self.inner.set_checksum_algorithm(input);
193        self
194    }
195    /// <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>
196    /// <p>If you provide an individual checksum, Amazon S3 ignores any provided <code>ChecksumAlgorithm</code> parameter.</p>
197    pub fn get_checksum_algorithm(&self) -> &::std::option::Option<crate::types::ChecksumAlgorithm> {
198        self.inner.get_checksum_algorithm()
199    }
200    /// <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>
201    pub fn expected_bucket_owner(mut self, input: impl ::std::convert::Into<::std::string::String>) -> Self {
202        self.inner = self.inner.expected_bucket_owner(input.into());
203        self
204    }
205    /// <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>
206    pub fn set_expected_bucket_owner(mut self, input: ::std::option::Option<::std::string::String>) -> Self {
207        self.inner = self.inner.set_expected_bucket_owner(input);
208        self
209    }
210    /// <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>
211    pub fn get_expected_bucket_owner(&self) -> &::std::option::Option<::std::string::String> {
212        self.inner.get_expected_bucket_owner()
213    }
214}