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>
78#[derive(::std::clone::Clone, ::std::fmt::Debug)]
79pub struct PutBucketWebsiteFluentBuilder {
80    handle: ::std::sync::Arc<crate::client::Handle>,
81    inner: crate::operation::put_bucket_website::builders::PutBucketWebsiteInputBuilder,
82    config_override: ::std::option::Option<crate::config::Builder>,
83}
84impl
85    crate::client::customize::internal::CustomizableSend<
86        crate::operation::put_bucket_website::PutBucketWebsiteOutput,
87        crate::operation::put_bucket_website::PutBucketWebsiteError,
88    > for PutBucketWebsiteFluentBuilder
89{
90    fn send(
91        self,
92        config_override: crate::config::Builder,
93    ) -> crate::client::customize::internal::BoxFuture<
94        crate::client::customize::internal::SendResult<
95            crate::operation::put_bucket_website::PutBucketWebsiteOutput,
96            crate::operation::put_bucket_website::PutBucketWebsiteError,
97        >,
98    > {
99        ::std::boxed::Box::pin(async move { self.config_override(config_override).send().await })
100    }
101}
102impl PutBucketWebsiteFluentBuilder {
103    /// Creates a new `PutBucketWebsiteFluentBuilder`.
104    pub(crate) fn new(handle: ::std::sync::Arc<crate::client::Handle>) -> Self {
105        Self {
106            handle,
107            inner: ::std::default::Default::default(),
108            config_override: ::std::option::Option::None,
109        }
110    }
111    /// Access the PutBucketWebsite as a reference.
112    pub fn as_input(&self) -> &crate::operation::put_bucket_website::builders::PutBucketWebsiteInputBuilder {
113        &self.inner
114    }
115    /// Sends the request and returns the response.
116    ///
117    /// If an error occurs, an `SdkError` will be returned with additional details that
118    /// can be matched against.
119    ///
120    /// By default, any retryable failures will be retried twice. Retry behavior
121    /// is configurable with the [RetryConfig](aws_smithy_types::retry::RetryConfig), which can be
122    /// set when configuring the client.
123    pub async fn send(
124        self,
125    ) -> ::std::result::Result<
126        crate::operation::put_bucket_website::PutBucketWebsiteOutput,
127        ::aws_smithy_runtime_api::client::result::SdkError<
128            crate::operation::put_bucket_website::PutBucketWebsiteError,
129            ::aws_smithy_runtime_api::client::orchestrator::HttpResponse,
130        >,
131    > {
132        let input = self
133            .inner
134            .build()
135            .map_err(::aws_smithy_runtime_api::client::result::SdkError::construction_failure)?;
136        let runtime_plugins = crate::operation::put_bucket_website::PutBucketWebsite::operation_runtime_plugins(
137            self.handle.runtime_plugins.clone(),
138            &self.handle.conf,
139            self.config_override,
140        );
141        crate::operation::put_bucket_website::PutBucketWebsite::orchestrate(&runtime_plugins, input).await
142    }
143
144    /// Consumes this builder, creating a customizable operation that can be modified before being sent.
145    pub fn customize(
146        self,
147    ) -> crate::client::customize::CustomizableOperation<
148        crate::operation::put_bucket_website::PutBucketWebsiteOutput,
149        crate::operation::put_bucket_website::PutBucketWebsiteError,
150        Self,
151    > {
152        crate::client::customize::CustomizableOperation::new(self)
153    }
154    pub(crate) fn config_override(mut self, config_override: impl ::std::convert::Into<crate::config::Builder>) -> Self {
155        self.set_config_override(::std::option::Option::Some(config_override.into()));
156        self
157    }
158
159    pub(crate) fn set_config_override(&mut self, config_override: ::std::option::Option<crate::config::Builder>) -> &mut Self {
160        self.config_override = config_override;
161        self
162    }
163    /// <p>The bucket name.</p>
164    pub fn bucket(mut self, input: impl ::std::convert::Into<::std::string::String>) -> Self {
165        self.inner = self.inner.bucket(input.into());
166        self
167    }
168    /// <p>The bucket name.</p>
169    pub fn set_bucket(mut self, input: ::std::option::Option<::std::string::String>) -> Self {
170        self.inner = self.inner.set_bucket(input);
171        self
172    }
173    /// <p>The bucket name.</p>
174    pub fn get_bucket(&self) -> &::std::option::Option<::std::string::String> {
175        self.inner.get_bucket()
176    }
177    /// <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>
178    /// <p>For requests made using the Amazon Web Services Command Line Interface (CLI) or Amazon Web Services SDKs, this field is calculated automatically.</p>
179    pub fn content_md5(mut self, input: impl ::std::convert::Into<::std::string::String>) -> Self {
180        self.inner = self.inner.content_md5(input.into());
181        self
182    }
183    /// <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>
184    /// <p>For requests made using the Amazon Web Services Command Line Interface (CLI) or Amazon Web Services SDKs, this field is calculated automatically.</p>
185    pub fn set_content_md5(mut self, input: ::std::option::Option<::std::string::String>) -> Self {
186        self.inner = self.inner.set_content_md5(input);
187        self
188    }
189    /// <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>
190    /// <p>For requests made using the Amazon Web Services Command Line Interface (CLI) or Amazon Web Services SDKs, this field is calculated automatically.</p>
191    pub fn get_content_md5(&self) -> &::std::option::Option<::std::string::String> {
192        self.inner.get_content_md5()
193    }
194    /// <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>
195    /// <p>If you provide an individual checksum, Amazon S3 ignores any provided <code>ChecksumAlgorithm</code> parameter.</p>
196    pub fn checksum_algorithm(mut self, input: crate::types::ChecksumAlgorithm) -> Self {
197        self.inner = self.inner.checksum_algorithm(input);
198        self
199    }
200    /// <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>
201    /// <p>If you provide an individual checksum, Amazon S3 ignores any provided <code>ChecksumAlgorithm</code> parameter.</p>
202    pub fn set_checksum_algorithm(mut self, input: ::std::option::Option<crate::types::ChecksumAlgorithm>) -> Self {
203        self.inner = self.inner.set_checksum_algorithm(input);
204        self
205    }
206    /// <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>
207    /// <p>If you provide an individual checksum, Amazon S3 ignores any provided <code>ChecksumAlgorithm</code> parameter.</p>
208    pub fn get_checksum_algorithm(&self) -> &::std::option::Option<crate::types::ChecksumAlgorithm> {
209        self.inner.get_checksum_algorithm()
210    }
211    /// <p>Container for the request.</p>
212    pub fn website_configuration(mut self, input: crate::types::WebsiteConfiguration) -> Self {
213        self.inner = self.inner.website_configuration(input);
214        self
215    }
216    /// <p>Container for the request.</p>
217    pub fn set_website_configuration(mut self, input: ::std::option::Option<crate::types::WebsiteConfiguration>) -> Self {
218        self.inner = self.inner.set_website_configuration(input);
219        self
220    }
221    /// <p>Container for the request.</p>
222    pub fn get_website_configuration(&self) -> &::std::option::Option<crate::types::WebsiteConfiguration> {
223        self.inner.get_website_configuration()
224    }
225    /// <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>
226    pub fn expected_bucket_owner(mut self, input: impl ::std::convert::Into<::std::string::String>) -> Self {
227        self.inner = self.inner.expected_bucket_owner(input.into());
228        self
229    }
230    /// <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>
231    pub fn set_expected_bucket_owner(mut self, input: ::std::option::Option<::std::string::String>) -> Self {
232        self.inner = self.inner.set_expected_bucket_owner(input);
233        self
234    }
235    /// <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>
236    pub fn get_expected_bucket_owner(&self) -> &::std::option::Option<::std::string::String> {
237        self.inner.get_expected_bucket_owner()
238    }
239}