aws_sdk_s3/operation/put_bucket_website/builders.rs
1// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
2pub use crate::operation::put_bucket_website::_put_bucket_website_output::PutBucketWebsiteOutputBuilder;
3
4pub use crate::operation::put_bucket_website::_put_bucket_website_input::PutBucketWebsiteInputBuilder;
5
6impl crate::operation::put_bucket_website::builders::PutBucketWebsiteInputBuilder {
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_website::PutBucketWebsiteOutput,
13 ::aws_smithy_runtime_api::client::result::SdkError<
14 crate::operation::put_bucket_website::PutBucketWebsiteError,
15 ::aws_smithy_runtime_api::client::orchestrator::HttpResponse,
16 >,
17 > {
18 let mut fluent_builder = client.put_bucket_website();
19 fluent_builder.inner = self;
20 fluent_builder.send().await
21 }
22}
23/// Fluent builder constructing a request to `PutBucketWebsite`.
24///
25/// <note>
26/// <p>This operation is not supported for directory buckets.</p>
27/// </note>
28/// <p>Sets the configuration of the website that is specified in the <code>website</code> subresource. To configure a bucket as a website, you can add this subresource on the bucket with website configuration information such as the file name of the index document and any redirect rules. For more information, see <a href="https://docs.aws.amazon.com/AmazonS3/latest/dev/WebsiteHosting.html">Hosting Websites on Amazon S3</a>.</p>
29/// <p>This PUT action requires the <code>S3:PutBucketWebsite</code> permission. By default, only the bucket owner can configure the website attached to a bucket; however, bucket owners can allow other users to set the website configuration by writing a bucket policy that grants them the <code>S3:PutBucketWebsite</code> permission.</p>
30/// <p>To redirect all website requests sent to the bucket's website endpoint, you add a website configuration with the following elements. Because all requests are sent to another website, you don't need to provide index document name for the bucket.</p>
31/// <ul>
32/// <li>
33/// <p><code>WebsiteConfiguration</code></p></li>
34/// <li>
35/// <p><code>RedirectAllRequestsTo</code></p></li>
36/// <li>
37/// <p><code>HostName</code></p></li>
38/// <li>
39/// <p><code>Protocol</code></p></li>
40/// </ul>
41/// <p>If you want granular control over redirects, you can use the following elements to add routing rules that describe conditions for redirecting requests and information about the redirect destination. In this case, the website configuration must provide an index document for the bucket, because some requests might not be redirected.</p>
42/// <ul>
43/// <li>
44/// <p><code>WebsiteConfiguration</code></p></li>
45/// <li>
46/// <p><code>IndexDocument</code></p></li>
47/// <li>
48/// <p><code>Suffix</code></p></li>
49/// <li>
50/// <p><code>ErrorDocument</code></p></li>
51/// <li>
52/// <p><code>Key</code></p></li>
53/// <li>
54/// <p><code>RoutingRules</code></p></li>
55/// <li>
56/// <p><code>RoutingRule</code></p></li>
57/// <li>
58/// <p><code>Condition</code></p></li>
59/// <li>
60/// <p><code>HttpErrorCodeReturnedEquals</code></p></li>
61/// <li>
62/// <p><code>KeyPrefixEquals</code></p></li>
63/// <li>
64/// <p><code>Redirect</code></p></li>
65/// <li>
66/// <p><code>Protocol</code></p></li>
67/// <li>
68/// <p><code>HostName</code></p></li>
69/// <li>
70/// <p><code>ReplaceKeyPrefixWith</code></p></li>
71/// <li>
72/// <p><code>ReplaceKeyWith</code></p></li>
73/// <li>
74/// <p><code>HttpRedirectCode</code></p></li>
75/// </ul>
76/// <p>Amazon S3 has a limitation of 50 routing rules per website configuration. If you require more than 50 routing rules, you can use object redirect. For more information, see <a href="https://docs.aws.amazon.com/AmazonS3/latest/dev/how-to-page-redirect.html">Configuring an Object Redirect</a> in the <i>Amazon S3 User Guide</i>.</p>
77/// <p>The maximum request length is limited to 128 KB.</p><important>
78/// <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>
79/// </important>
80#[derive(::std::clone::Clone, ::std::fmt::Debug)]
81pub struct PutBucketWebsiteFluentBuilder {
82 handle: ::std::sync::Arc<crate::client::Handle>,
83 inner: crate::operation::put_bucket_website::builders::PutBucketWebsiteInputBuilder,
84 config_override: ::std::option::Option<crate::config::Builder>,
85}
86impl
87 crate::client::customize::internal::CustomizableSend<
88 crate::operation::put_bucket_website::PutBucketWebsiteOutput,
89 crate::operation::put_bucket_website::PutBucketWebsiteError,
90 > for PutBucketWebsiteFluentBuilder
91{
92 fn send(
93 self,
94 config_override: crate::config::Builder,
95 ) -> crate::client::customize::internal::BoxFuture<
96 crate::client::customize::internal::SendResult<
97 crate::operation::put_bucket_website::PutBucketWebsiteOutput,
98 crate::operation::put_bucket_website::PutBucketWebsiteError,
99 >,
100 > {
101 ::std::boxed::Box::pin(async move { self.config_override(config_override).send().await })
102 }
103}
104impl PutBucketWebsiteFluentBuilder {
105 /// Creates a new `PutBucketWebsiteFluentBuilder`.
106 pub(crate) fn new(handle: ::std::sync::Arc<crate::client::Handle>) -> Self {
107 Self {
108 handle,
109 inner: ::std::default::Default::default(),
110 config_override: ::std::option::Option::None,
111 }
112 }
113 /// Access the PutBucketWebsite as a reference.
114 pub fn as_input(&self) -> &crate::operation::put_bucket_website::builders::PutBucketWebsiteInputBuilder {
115 &self.inner
116 }
117 /// Sends the request and returns the response.
118 ///
119 /// If an error occurs, an `SdkError` will be returned with additional details that
120 /// can be matched against.
121 ///
122 /// By default, any retryable failures will be retried twice. Retry behavior
123 /// is configurable with the [RetryConfig](aws_smithy_types::retry::RetryConfig), which can be
124 /// set when configuring the client.
125 pub async fn send(
126 self,
127 ) -> ::std::result::Result<
128 crate::operation::put_bucket_website::PutBucketWebsiteOutput,
129 ::aws_smithy_runtime_api::client::result::SdkError<
130 crate::operation::put_bucket_website::PutBucketWebsiteError,
131 ::aws_smithy_runtime_api::client::orchestrator::HttpResponse,
132 >,
133 > {
134 let input = self
135 .inner
136 .build()
137 .map_err(::aws_smithy_runtime_api::client::result::SdkError::construction_failure)?;
138 let runtime_plugins = crate::operation::put_bucket_website::PutBucketWebsite::operation_runtime_plugins(
139 self.handle.runtime_plugins.clone(),
140 &self.handle.conf,
141 self.config_override,
142 );
143 crate::operation::put_bucket_website::PutBucketWebsite::orchestrate(&runtime_plugins, input).await
144 }
145
146 /// Consumes this builder, creating a customizable operation that can be modified before being sent.
147 pub fn customize(
148 self,
149 ) -> crate::client::customize::CustomizableOperation<
150 crate::operation::put_bucket_website::PutBucketWebsiteOutput,
151 crate::operation::put_bucket_website::PutBucketWebsiteError,
152 Self,
153 > {
154 crate::client::customize::CustomizableOperation::new(self)
155 }
156 pub(crate) fn config_override(mut self, config_override: impl ::std::convert::Into<crate::config::Builder>) -> Self {
157 self.set_config_override(::std::option::Option::Some(config_override.into()));
158 self
159 }
160
161 pub(crate) fn set_config_override(&mut self, config_override: ::std::option::Option<crate::config::Builder>) -> &mut Self {
162 self.config_override = config_override;
163 self
164 }
165 /// <p>The bucket name.</p>
166 pub fn bucket(mut self, input: impl ::std::convert::Into<::std::string::String>) -> Self {
167 self.inner = self.inner.bucket(input.into());
168 self
169 }
170 /// <p>The bucket name.</p>
171 pub fn set_bucket(mut self, input: ::std::option::Option<::std::string::String>) -> Self {
172 self.inner = self.inner.set_bucket(input);
173 self
174 }
175 /// <p>The bucket name.</p>
176 pub fn get_bucket(&self) -> &::std::option::Option<::std::string::String> {
177 self.inner.get_bucket()
178 }
179 /// <p>The Base64 encoded 128-bit <code>MD5</code> digest of the data. You must use this header as a message integrity check to verify that the request body was not corrupted in transit. For more information, see <a href="http://www.ietf.org/rfc/rfc1864.txt">RFC 1864</a>.</p>
180 /// <p>For requests made using the Amazon Web Services Command Line Interface (CLI) or Amazon Web Services SDKs, this field is calculated automatically.</p>
181 pub fn content_md5(mut self, input: impl ::std::convert::Into<::std::string::String>) -> Self {
182 self.inner = self.inner.content_md5(input.into());
183 self
184 }
185 /// <p>The Base64 encoded 128-bit <code>MD5</code> digest of the data. You must use this header as a message integrity check to verify that the request body was not corrupted in transit. For more information, see <a href="http://www.ietf.org/rfc/rfc1864.txt">RFC 1864</a>.</p>
186 /// <p>For requests made using the Amazon Web Services Command Line Interface (CLI) or Amazon Web Services SDKs, this field is calculated automatically.</p>
187 pub fn set_content_md5(mut self, input: ::std::option::Option<::std::string::String>) -> Self {
188 self.inner = self.inner.set_content_md5(input);
189 self
190 }
191 /// <p>The Base64 encoded 128-bit <code>MD5</code> digest of the data. You must use this header as a message integrity check to verify that the request body was not corrupted in transit. For more information, see <a href="http://www.ietf.org/rfc/rfc1864.txt">RFC 1864</a>.</p>
192 /// <p>For requests made using the Amazon Web Services Command Line Interface (CLI) or Amazon Web Services SDKs, this field is calculated automatically.</p>
193 pub fn get_content_md5(&self) -> &::std::option::Option<::std::string::String> {
194 self.inner.get_content_md5()
195 }
196 /// <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>
197 /// <p>If you provide an individual checksum, Amazon S3 ignores any provided <code>ChecksumAlgorithm</code> parameter.</p>
198 pub fn checksum_algorithm(mut self, input: crate::types::ChecksumAlgorithm) -> Self {
199 self.inner = self.inner.checksum_algorithm(input);
200 self
201 }
202 /// <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>
203 /// <p>If you provide an individual checksum, Amazon S3 ignores any provided <code>ChecksumAlgorithm</code> parameter.</p>
204 pub fn set_checksum_algorithm(mut self, input: ::std::option::Option<crate::types::ChecksumAlgorithm>) -> Self {
205 self.inner = self.inner.set_checksum_algorithm(input);
206 self
207 }
208 /// <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>
209 /// <p>If you provide an individual checksum, Amazon S3 ignores any provided <code>ChecksumAlgorithm</code> parameter.</p>
210 pub fn get_checksum_algorithm(&self) -> &::std::option::Option<crate::types::ChecksumAlgorithm> {
211 self.inner.get_checksum_algorithm()
212 }
213 /// <p>Container for the request.</p>
214 pub fn website_configuration(mut self, input: crate::types::WebsiteConfiguration) -> Self {
215 self.inner = self.inner.website_configuration(input);
216 self
217 }
218 /// <p>Container for the request.</p>
219 pub fn set_website_configuration(mut self, input: ::std::option::Option<crate::types::WebsiteConfiguration>) -> Self {
220 self.inner = self.inner.set_website_configuration(input);
221 self
222 }
223 /// <p>Container for the request.</p>
224 pub fn get_website_configuration(&self) -> &::std::option::Option<crate::types::WebsiteConfiguration> {
225 self.inner.get_website_configuration()
226 }
227 /// <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>
228 pub fn expected_bucket_owner(mut self, input: impl ::std::convert::Into<::std::string::String>) -> Self {
229 self.inner = self.inner.expected_bucket_owner(input.into());
230 self
231 }
232 /// <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>
233 pub fn set_expected_bucket_owner(mut self, input: ::std::option::Option<::std::string::String>) -> Self {
234 self.inner = self.inner.set_expected_bucket_owner(input);
235 self
236 }
237 /// <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>
238 pub fn get_expected_bucket_owner(&self) -> &::std::option::Option<::std::string::String> {
239 self.inner.get_expected_bucket_owner()
240 }
241}