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>
51#[derive(::std::clone::Clone, ::std::fmt::Debug)]
52pub struct PutBucketCorsFluentBuilder {
53 handle: ::std::sync::Arc<crate::client::Handle>,
54 inner: crate::operation::put_bucket_cors::builders::PutBucketCorsInputBuilder,
55 config_override: ::std::option::Option<crate::config::Builder>,
56}
57impl
58 crate::client::customize::internal::CustomizableSend<
59 crate::operation::put_bucket_cors::PutBucketCorsOutput,
60 crate::operation::put_bucket_cors::PutBucketCorsError,
61 > for PutBucketCorsFluentBuilder
62{
63 fn send(
64 self,
65 config_override: crate::config::Builder,
66 ) -> crate::client::customize::internal::BoxFuture<
67 crate::client::customize::internal::SendResult<
68 crate::operation::put_bucket_cors::PutBucketCorsOutput,
69 crate::operation::put_bucket_cors::PutBucketCorsError,
70 >,
71 > {
72 ::std::boxed::Box::pin(async move { self.config_override(config_override).send().await })
73 }
74}
75impl PutBucketCorsFluentBuilder {
76 /// Creates a new `PutBucketCorsFluentBuilder`.
77 pub(crate) fn new(handle: ::std::sync::Arc<crate::client::Handle>) -> Self {
78 Self {
79 handle,
80 inner: ::std::default::Default::default(),
81 config_override: ::std::option::Option::None,
82 }
83 }
84 /// Access the PutBucketCors as a reference.
85 pub fn as_input(&self) -> &crate::operation::put_bucket_cors::builders::PutBucketCorsInputBuilder {
86 &self.inner
87 }
88 /// Sends the request and returns the response.
89 ///
90 /// If an error occurs, an `SdkError` will be returned with additional details that
91 /// can be matched against.
92 ///
93 /// By default, any retryable failures will be retried twice. Retry behavior
94 /// is configurable with the [RetryConfig](aws_smithy_types::retry::RetryConfig), which can be
95 /// set when configuring the client.
96 pub async fn send(
97 self,
98 ) -> ::std::result::Result<
99 crate::operation::put_bucket_cors::PutBucketCorsOutput,
100 ::aws_smithy_runtime_api::client::result::SdkError<
101 crate::operation::put_bucket_cors::PutBucketCorsError,
102 ::aws_smithy_runtime_api::client::orchestrator::HttpResponse,
103 >,
104 > {
105 let input = self
106 .inner
107 .build()
108 .map_err(::aws_smithy_runtime_api::client::result::SdkError::construction_failure)?;
109 let runtime_plugins = crate::operation::put_bucket_cors::PutBucketCors::operation_runtime_plugins(
110 self.handle.runtime_plugins.clone(),
111 &self.handle.conf,
112 self.config_override,
113 );
114 crate::operation::put_bucket_cors::PutBucketCors::orchestrate(&runtime_plugins, input).await
115 }
116
117 /// Consumes this builder, creating a customizable operation that can be modified before being sent.
118 pub fn customize(
119 self,
120 ) -> crate::client::customize::CustomizableOperation<
121 crate::operation::put_bucket_cors::PutBucketCorsOutput,
122 crate::operation::put_bucket_cors::PutBucketCorsError,
123 Self,
124 > {
125 crate::client::customize::CustomizableOperation::new(self)
126 }
127 pub(crate) fn config_override(mut self, config_override: impl ::std::convert::Into<crate::config::Builder>) -> Self {
128 self.set_config_override(::std::option::Option::Some(config_override.into()));
129 self
130 }
131
132 pub(crate) fn set_config_override(&mut self, config_override: ::std::option::Option<crate::config::Builder>) -> &mut Self {
133 self.config_override = config_override;
134 self
135 }
136 /// <p>Specifies the bucket impacted by the <code>cors</code>configuration.</p>
137 pub fn bucket(mut self, input: impl ::std::convert::Into<::std::string::String>) -> Self {
138 self.inner = self.inner.bucket(input.into());
139 self
140 }
141 /// <p>Specifies the bucket impacted by the <code>cors</code>configuration.</p>
142 pub fn set_bucket(mut self, input: ::std::option::Option<::std::string::String>) -> Self {
143 self.inner = self.inner.set_bucket(input);
144 self
145 }
146 /// <p>Specifies the bucket impacted by the <code>cors</code>configuration.</p>
147 pub fn get_bucket(&self) -> &::std::option::Option<::std::string::String> {
148 self.inner.get_bucket()
149 }
150 /// <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>
151 pub fn cors_configuration(mut self, input: crate::types::CorsConfiguration) -> Self {
152 self.inner = self.inner.cors_configuration(input);
153 self
154 }
155 /// <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>
156 pub fn set_cors_configuration(mut self, input: ::std::option::Option<crate::types::CorsConfiguration>) -> Self {
157 self.inner = self.inner.set_cors_configuration(input);
158 self
159 }
160 /// <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>
161 pub fn get_cors_configuration(&self) -> &::std::option::Option<crate::types::CorsConfiguration> {
162 self.inner.get_cors_configuration()
163 }
164 /// <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>
165 /// <p>For requests made using the Amazon Web Services Command Line Interface (CLI) or Amazon Web Services SDKs, this field is calculated automatically.</p>
166 pub fn content_md5(mut self, input: impl ::std::convert::Into<::std::string::String>) -> Self {
167 self.inner = self.inner.content_md5(input.into());
168 self
169 }
170 /// <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>
171 /// <p>For requests made using the Amazon Web Services Command Line Interface (CLI) or Amazon Web Services SDKs, this field is calculated automatically.</p>
172 pub fn set_content_md5(mut self, input: ::std::option::Option<::std::string::String>) -> Self {
173 self.inner = self.inner.set_content_md5(input);
174 self
175 }
176 /// <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>
177 /// <p>For requests made using the Amazon Web Services Command Line Interface (CLI) or Amazon Web Services SDKs, this field is calculated automatically.</p>
178 pub fn get_content_md5(&self) -> &::std::option::Option<::std::string::String> {
179 self.inner.get_content_md5()
180 }
181 /// <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>
182 /// <p>If you provide an individual checksum, Amazon S3 ignores any provided <code>ChecksumAlgorithm</code> parameter.</p>
183 pub fn checksum_algorithm(mut self, input: crate::types::ChecksumAlgorithm) -> Self {
184 self.inner = self.inner.checksum_algorithm(input);
185 self
186 }
187 /// <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>
188 /// <p>If you provide an individual checksum, Amazon S3 ignores any provided <code>ChecksumAlgorithm</code> parameter.</p>
189 pub fn set_checksum_algorithm(mut self, input: ::std::option::Option<crate::types::ChecksumAlgorithm>) -> Self {
190 self.inner = self.inner.set_checksum_algorithm(input);
191 self
192 }
193 /// <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>
194 /// <p>If you provide an individual checksum, Amazon S3 ignores any provided <code>ChecksumAlgorithm</code> parameter.</p>
195 pub fn get_checksum_algorithm(&self) -> &::std::option::Option<crate::types::ChecksumAlgorithm> {
196 self.inner.get_checksum_algorithm()
197 }
198 /// <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>
199 pub fn expected_bucket_owner(mut self, input: impl ::std::convert::Into<::std::string::String>) -> Self {
200 self.inner = self.inner.expected_bucket_owner(input.into());
201 self
202 }
203 /// <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>
204 pub fn set_expected_bucket_owner(mut self, input: ::std::option::Option<::std::string::String>) -> Self {
205 self.inner = self.inner.set_expected_bucket_owner(input);
206 self
207 }
208 /// <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>
209 pub fn get_expected_bucket_owner(&self) -> &::std::option::Option<::std::string::String> {
210 self.inner.get_expected_bucket_owner()
211 }
212}