aws_sdk_s3/
config.rs

1// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
2#![allow(clippy::empty_line_after_doc_comments)]
3/// Configuration for a aws_sdk_s3 service client.
4///
5
6/// Service configuration allows for customization of endpoints, region, credentials providers,
7/// and retry configuration. Generally, it is constructed automatically for you from a shared
8/// configuration loaded by the `aws-config` crate. For example:
9///
10/// ```ignore
11/// // Load a shared config from the environment
12/// let shared_config = aws_config::from_env().load().await;
13/// // The client constructor automatically converts the shared config into the service config
14/// let client = Client::new(&shared_config);
15/// ```
16///
17/// The service config can also be constructed manually using its builder.
18///
19#[derive(::std::clone::Clone, ::std::fmt::Debug)]
20pub struct Config {
21    // Both `config` and `cloneable` are the same config, but the cloneable one
22    // is kept around so that it is possible to convert back into a builder. This can be
23    // optimized in the future.
24    pub(crate) config: crate::config::FrozenLayer,
25    cloneable: ::aws_smithy_types::config_bag::CloneableLayer,
26    pub(crate) runtime_components: crate::config::RuntimeComponentsBuilder,
27    pub(crate) runtime_plugins: ::std::vec::Vec<crate::config::SharedRuntimePlugin>,
28    pub(crate) behavior_version: ::std::option::Option<crate::config::BehaviorVersion>,
29}
30impl Config {
31    ///
32    /// Constructs a config builder.
33    /// <div class="warning">
34    /// Note that a config created from this builder will not have the same safe defaults as one created by
35    /// the <a href="https://crates.io/crates/aws-config" target="_blank">aws-config</a> crate.
36    /// </div>
37    ///
38    pub fn builder() -> Builder {
39        Builder::default()
40    }
41    /// Converts this config back into a builder so that it can be tweaked.
42    pub fn to_builder(&self) -> Builder {
43        Builder {
44            config: self.cloneable.clone(),
45            runtime_components: self.runtime_components.clone(),
46            runtime_plugins: self.runtime_plugins.clone(),
47            behavior_version: self.behavior_version,
48        }
49    }
50    /// Return a reference to the stalled stream protection configuration contained in this config, if any.
51    pub fn stalled_stream_protection(&self) -> ::std::option::Option<&crate::config::StalledStreamProtectionConfig> {
52        self.config.load::<crate::config::StalledStreamProtectionConfig>()
53    }
54    /// Return the [`SharedHttpClient`](crate::config::SharedHttpClient) to use when making requests, if any.
55    pub fn http_client(&self) -> Option<crate::config::SharedHttpClient> {
56        self.runtime_components.http_client()
57    }
58
59    /// Returns the endpoint resolver.
60    pub fn endpoint_resolver(&self) -> ::aws_smithy_runtime_api::client::endpoint::SharedEndpointResolver {
61        self.runtime_components.endpoint_resolver().expect("resolver defaulted if not set")
62    }
63    /// Return a reference to the retry configuration contained in this config, if any.
64    pub fn retry_config(&self) -> ::std::option::Option<&::aws_smithy_types::retry::RetryConfig> {
65        self.config.load::<::aws_smithy_types::retry::RetryConfig>()
66    }
67
68    /// Return a cloned shared async sleep implementation from this config, if any.
69    pub fn sleep_impl(&self) -> ::std::option::Option<crate::config::SharedAsyncSleep> {
70        self.runtime_components.sleep_impl()
71    }
72
73    /// Return a reference to the timeout configuration contained in this config, if any.
74    pub fn timeout_config(&self) -> ::std::option::Option<&::aws_smithy_types::timeout::TimeoutConfig> {
75        self.config.load::<::aws_smithy_types::timeout::TimeoutConfig>()
76    }
77
78    /// Returns a reference to the retry partition contained in this config, if any.
79    ///
80    /// WARNING: This method is unstable and may be removed at any time. Do not rely on this
81    /// method for anything!
82    pub fn retry_partition(&self) -> ::std::option::Option<&::aws_smithy_runtime::client::retries::RetryPartition> {
83        self.config.load::<::aws_smithy_runtime::client::retries::RetryPartition>()
84    }
85    /// Returns the configured identity cache for auth.
86    pub fn identity_cache(&self) -> ::std::option::Option<crate::config::SharedIdentityCache> {
87        self.runtime_components.identity_cache()
88    }
89    /// Returns interceptors currently registered by the user.
90    pub fn interceptors(&self) -> impl Iterator<Item = crate::config::SharedInterceptor> + '_ {
91        self.runtime_components.interceptors()
92    }
93    /// Return time source used for this service.
94    pub fn time_source(&self) -> ::std::option::Option<::aws_smithy_async::time::SharedTimeSource> {
95        self.runtime_components.time_source()
96    }
97    /// Returns retry classifiers currently registered by the user.
98    pub fn retry_classifiers(&self) -> impl Iterator<Item = ::aws_smithy_runtime_api::client::retries::classifiers::SharedRetryClassifier> + '_ {
99        self.runtime_components.retry_classifiers()
100    }
101    /// Returns the name of the app that is using the client, if it was provided.
102    ///
103    /// This _optional_ name is used to identify the application in the user agent that
104    /// gets sent along with requests.
105    pub fn app_name(&self) -> ::std::option::Option<&::aws_types::app_name::AppName> {
106        self.config.load::<::aws_types::app_name::AppName>()
107    }
108    /// Returns the invocation ID generator if one was given in config.
109    ///
110    /// The invocation ID generator generates ID values for the `amz-sdk-invocation-id` header. By default, this will be a random UUID. Overriding it may be useful in tests that examine the HTTP request and need to be deterministic.
111    pub fn invocation_id_generator(&self) -> ::std::option::Option<::aws_runtime::invocation_id::SharedInvocationIdGenerator> {
112        self.config.load::<::aws_runtime::invocation_id::SharedInvocationIdGenerator>().cloned()
113    }
114    /// Creates a new [service config](crate::Config) from a [shared `config`](::aws_types::sdk_config::SdkConfig).
115    pub fn new(config: &::aws_types::sdk_config::SdkConfig) -> Self {
116        Builder::from(config).build()
117    }
118    /// Return a reference to the response_checksum_validation value contained in this config, if any.
119    pub fn response_checksum_validation(&self) -> ::std::option::Option<&crate::config::ResponseChecksumValidation> {
120        self.config.load::<crate::config::ResponseChecksumValidation>()
121    }
122    /// Return a reference to the request_checksum_calculation value contained in this config, if any.
123    pub fn request_checksum_calculation(&self) -> ::std::option::Option<&crate::config::RequestChecksumCalculation> {
124        self.config.load::<crate::config::RequestChecksumCalculation>()
125    }
126    /// The signature version 4 service signing name to use in the credential scope when signing requests.
127    ///
128    /// The signing service may be overridden by the `Endpoint`, or by specifying a custom
129    /// [`SigningName`](aws_types::SigningName) during operation construction
130    pub fn signing_name(&self) -> &'static str {
131        "s3"
132    }
133    /// Returns the AWS region, if it was provided.
134    pub fn region(&self) -> ::std::option::Option<&crate::config::Region> {
135        self.config.load::<crate::config::Region>()
136    }
137    /// This function was intended to be removed, and has been broken since release-2023-11-15 as it always returns a `None`. Do not use.
138    #[deprecated(
139        note = "This function was intended to be removed, and has been broken since release-2023-11-15 as it always returns a `None`. Do not use."
140    )]
141    pub fn credentials_provider(&self) -> Option<crate::config::SharedCredentialsProvider> {
142        ::std::option::Option::None
143    }
144}
145/// Builder for creating a `Config`.
146#[derive(::std::clone::Clone, ::std::fmt::Debug)]
147pub struct Builder {
148    pub(crate) config: ::aws_smithy_types::config_bag::CloneableLayer,
149    pub(crate) runtime_components: crate::config::RuntimeComponentsBuilder,
150    pub(crate) runtime_plugins: ::std::vec::Vec<crate::config::SharedRuntimePlugin>,
151    pub(crate) behavior_version: ::std::option::Option<crate::config::BehaviorVersion>,
152}
153impl ::std::default::Default for Builder {
154    fn default() -> Self {
155        Self {
156            config: ::std::default::Default::default(),
157            runtime_components: crate::config::RuntimeComponentsBuilder::new("service config"),
158            runtime_plugins: ::std::default::Default::default(),
159            behavior_version: ::std::default::Default::default(),
160        }
161    }
162}
163impl Builder {
164    ///
165    /// Constructs a config builder.
166    /// <div class="warning">
167    /// Note that a config created from this builder will not have the same safe defaults as one created by
168    /// the <a href="https://crates.io/crates/aws-config" target="_blank">aws-config</a> crate.
169    /// </div>
170    ///
171    pub fn new() -> Self {
172        Self::default()
173    }
174    /// Constructs a config builder from the given `config_bag`, setting only fields stored in the config bag,
175    /// but not those in runtime components.
176    #[allow(unused)]
177    pub(crate) fn from_config_bag(config_bag: &::aws_smithy_types::config_bag::ConfigBag) -> Self {
178        let mut builder = Self::new();
179        builder.set_stalled_stream_protection(config_bag.load::<crate::config::StalledStreamProtectionConfig>().cloned());
180        builder.set_force_path_style(config_bag.load::<crate::config::ForcePathStyle>().map(|ty| ty.0));
181
182        builder.set_use_arn_region(config_bag.load::<crate::config::UseArnRegion>().map(|ty| ty.0));
183
184        builder.set_disable_multi_region_access_points(config_bag.load::<crate::config::DisableMultiRegionAccessPoints>().map(|ty| ty.0));
185
186        builder.set_accelerate(config_bag.load::<crate::config::Accelerate>().map(|ty| ty.0));
187
188        builder.set_disable_s3_express_session_auth(config_bag.load::<crate::config::DisableS3ExpressSessionAuth>().map(|ty| ty.0));
189        builder.set_retry_config(config_bag.load::<::aws_smithy_types::retry::RetryConfig>().cloned());
190        builder.set_timeout_config(config_bag.load::<::aws_smithy_types::timeout::TimeoutConfig>().cloned());
191        builder.set_retry_partition(config_bag.load::<::aws_smithy_runtime::client::retries::RetryPartition>().cloned());
192        builder.set_app_name(config_bag.load::<::aws_types::app_name::AppName>().cloned());
193        builder.set_endpoint_url(config_bag.load::<::aws_types::endpoint_config::EndpointUrl>().map(|ty| ty.0.clone()));
194        builder.set_use_dual_stack(config_bag.load::<::aws_types::endpoint_config::UseDualStack>().map(|ty| ty.0));
195        builder.set_use_fips(config_bag.load::<::aws_types::endpoint_config::UseFips>().map(|ty| ty.0));
196        builder.set_response_checksum_validation(config_bag.load::<crate::config::ResponseChecksumValidation>().cloned());
197        builder.set_request_checksum_calculation(config_bag.load::<crate::config::RequestChecksumCalculation>().cloned());
198        builder.set_region(config_bag.load::<crate::config::Region>().cloned());
199        builder
200    }
201    /// Set the [`StalledStreamProtectionConfig`](crate::config::StalledStreamProtectionConfig)
202    /// to configure protection for stalled streams.
203    pub fn stalled_stream_protection(mut self, stalled_stream_protection_config: crate::config::StalledStreamProtectionConfig) -> Self {
204        self.set_stalled_stream_protection(::std::option::Option::Some(stalled_stream_protection_config));
205        self
206    }
207    /// Set the [`StalledStreamProtectionConfig`](crate::config::StalledStreamProtectionConfig)
208    /// to configure protection for stalled streams.
209    pub fn set_stalled_stream_protection(
210        &mut self,
211        stalled_stream_protection_config: ::std::option::Option<crate::config::StalledStreamProtectionConfig>,
212    ) -> &mut Self {
213        self.config.store_or_unset(stalled_stream_protection_config);
214        self
215    }
216    /// Sets the HTTP client to use when making requests.
217    ///
218    /// # Examples
219    /// ```no_run
220    /// # #[cfg(test)]
221    /// # mod tests {
222    /// # #[test]
223    /// # fn example() {
224    /// use std::time::Duration;
225    /// use aws_sdk_s3::config::Config;
226    /// use aws_smithy_runtime::client::http::hyper_014::HyperClientBuilder;
227    ///
228    /// let https_connector = hyper_rustls::HttpsConnectorBuilder::new()
229    ///     .with_webpki_roots()
230    ///     .https_only()
231    ///     .enable_http1()
232    ///     .enable_http2()
233    ///     .build();
234    /// let hyper_client = HyperClientBuilder::new().build(https_connector);
235    ///
236    /// // This connector can then be given to a generated service Config
237    /// let config = my_service_client::Config::builder()
238    ///     .endpoint_url("https://example.com")
239    ///     .http_client(hyper_client)
240    ///     .build();
241    /// let client = my_service_client::Client::from_conf(config);
242    /// # }
243    /// # }
244    /// ```
245    pub fn http_client(mut self, http_client: impl crate::config::HttpClient + 'static) -> Self {
246        self.set_http_client(::std::option::Option::Some(crate::config::IntoShared::into_shared(http_client)));
247        self
248    }
249
250    /// Sets the HTTP client to use when making requests.
251    ///
252    /// # Examples
253    /// ```no_run
254    /// # #[cfg(test)]
255    /// # mod tests {
256    /// # #[test]
257    /// # fn example() {
258    /// use std::time::Duration;
259    /// use aws_sdk_s3::config::{Builder, Config};
260    /// use aws_smithy_runtime::client::http::hyper_014::HyperClientBuilder;
261    ///
262    /// fn override_http_client(builder: &mut Builder) {
263    ///     let https_connector = hyper_rustls::HttpsConnectorBuilder::new()
264    ///         .with_webpki_roots()
265    ///         .https_only()
266    ///         .enable_http1()
267    ///         .enable_http2()
268    ///         .build();
269    ///     let hyper_client = HyperClientBuilder::new().build(https_connector);
270    ///     builder.set_http_client(Some(hyper_client));
271    /// }
272    ///
273    /// let mut builder = aws_sdk_s3::Config::builder();
274    /// override_http_client(&mut builder);
275    /// let config = builder.build();
276    /// # }
277    /// # }
278    /// ```
279    pub fn set_http_client(&mut self, http_client: Option<crate::config::SharedHttpClient>) -> &mut Self {
280        self.runtime_components.set_http_client(http_client);
281        self
282    }
283    /// Forces this client to use path-style addressing for buckets.
284    pub fn force_path_style(mut self, force_path_style: impl Into<bool>) -> Self {
285        self.set_force_path_style(Some(force_path_style.into()));
286        self
287    }
288    /// Forces this client to use path-style addressing for buckets.
289    pub fn set_force_path_style(&mut self, force_path_style: Option<bool>) -> &mut Self {
290        self.config.store_or_unset(force_path_style.map(crate::config::ForcePathStyle));
291        self
292    }
293
294    /// Enables this client to use an ARN's region when constructing an endpoint instead of the client's configured region.
295    pub fn use_arn_region(mut self, use_arn_region: impl Into<bool>) -> Self {
296        self.set_use_arn_region(Some(use_arn_region.into()));
297        self
298    }
299    /// Enables this client to use an ARN's region when constructing an endpoint instead of the client's configured region.
300    pub fn set_use_arn_region(&mut self, use_arn_region: Option<bool>) -> &mut Self {
301        self.config.store_or_unset(use_arn_region.map(crate::config::UseArnRegion));
302        self
303    }
304
305    /// Disables this client's usage of Multi-Region Access Points.
306    pub fn disable_multi_region_access_points(mut self, disable_multi_region_access_points: impl Into<bool>) -> Self {
307        self.set_disable_multi_region_access_points(Some(disable_multi_region_access_points.into()));
308        self
309    }
310    /// Disables this client's usage of Multi-Region Access Points.
311    pub fn set_disable_multi_region_access_points(&mut self, disable_multi_region_access_points: Option<bool>) -> &mut Self {
312        self.config
313            .store_or_unset(disable_multi_region_access_points.map(crate::config::DisableMultiRegionAccessPoints));
314        self
315    }
316
317    /// Enables this client to use S3 Transfer Acceleration endpoints.
318    pub fn accelerate(mut self, accelerate: impl Into<bool>) -> Self {
319        self.set_accelerate(Some(accelerate.into()));
320        self
321    }
322    /// Enables this client to use S3 Transfer Acceleration endpoints.
323    pub fn set_accelerate(&mut self, accelerate: Option<bool>) -> &mut Self {
324        self.config.store_or_unset(accelerate.map(crate::config::Accelerate));
325        self
326    }
327
328    /// Disables this client's usage of Session Auth for S3Express       buckets and reverts to using conventional SigV4 for those.
329    pub fn disable_s3_express_session_auth(mut self, disable_s3_express_session_auth: impl Into<bool>) -> Self {
330        self.set_disable_s3_express_session_auth(Some(disable_s3_express_session_auth.into()));
331        self
332    }
333    /// Disables this client's usage of Session Auth for S3Express       buckets and reverts to using conventional SigV4 for those.
334    pub fn set_disable_s3_express_session_auth(&mut self, disable_s3_express_session_auth: Option<bool>) -> &mut Self {
335        self.config
336            .store_or_unset(disable_s3_express_session_auth.map(crate::config::DisableS3ExpressSessionAuth));
337        self
338    }
339    /// Sets the endpoint resolver to use when making requests.
340    ///
341    ///
342    /// When unset, the client will used a generated endpoint resolver based on the endpoint resolution
343    /// rules for `aws_sdk_s3`.
344    ///
345    ///
346    /// Note: setting an endpoint resolver will replace any endpoint URL that has been set.
347    /// This method accepts an endpoint resolver [specific to this service](crate::config::endpoint::ResolveEndpoint). If you want to
348    /// provide a shared endpoint resolver, use [`Self::set_endpoint_resolver`].
349    ///
350    /// # Examples
351    /// Create a custom endpoint resolver that resolves a different endpoing per-stage, e.g. staging vs. production.
352    /// ```no_run
353    /// use aws_sdk_s3::config::endpoint::{ResolveEndpoint, EndpointFuture, Params, Endpoint};
354    /// #[derive(Debug)]
355    /// struct StageResolver { stage: String }
356    /// impl ResolveEndpoint for StageResolver {
357    ///     fn resolve_endpoint(&self, params: &Params) -> EndpointFuture<'_> {
358    ///         let stage = &self.stage;
359    ///         EndpointFuture::ready(Ok(Endpoint::builder().url(format!("{stage}.myservice.com")).build()))
360    ///     }
361    /// }
362    /// let resolver = StageResolver { stage: std::env::var("STAGE").unwrap() };
363    /// let config = aws_sdk_s3::Config::builder().endpoint_resolver(resolver).build();
364    /// let client = aws_sdk_s3::Client::from_conf(config);
365    /// ```
366    pub fn endpoint_resolver(mut self, endpoint_resolver: impl crate::config::endpoint::ResolveEndpoint + 'static) -> Self {
367        self.set_endpoint_resolver(::std::option::Option::Some(endpoint_resolver.into_shared_resolver()));
368        self
369    }
370
371    /// Sets the endpoint resolver to use when making requests.
372    ///
373    ///
374    /// When unset, the client will used a generated endpoint resolver based on the endpoint resolution
375    /// rules for `aws_sdk_s3`.
376    ///
377    pub fn set_endpoint_resolver(
378        &mut self,
379        endpoint_resolver: ::std::option::Option<::aws_smithy_runtime_api::client::endpoint::SharedEndpointResolver>,
380    ) -> &mut Self {
381        self.runtime_components.set_endpoint_resolver(endpoint_resolver);
382        self
383    }
384    /// Set the retry_config for the builder
385    ///
386    /// # Examples
387    /// ```no_run
388    /// use aws_sdk_s3::config::Config;
389    /// use aws_sdk_s3::config::retry::RetryConfig;
390    ///
391    /// let retry_config = RetryConfig::standard().with_max_attempts(5);
392    /// let config = Config::builder().retry_config(retry_config).build();
393    /// ```
394    pub fn retry_config(mut self, retry_config: ::aws_smithy_types::retry::RetryConfig) -> Self {
395        self.set_retry_config(Some(retry_config));
396        self
397    }
398
399    /// Set the retry_config for the builder
400    ///
401    /// # Examples
402    /// ```no_run
403    /// use aws_sdk_s3::config::{Builder, Config};
404    /// use aws_sdk_s3::config::retry::RetryConfig;
405    ///
406    /// fn disable_retries(builder: &mut Builder) {
407    ///     let retry_config = RetryConfig::standard().with_max_attempts(1);
408    ///     builder.set_retry_config(Some(retry_config));
409    /// }
410    ///
411    /// let mut builder = Config::builder();
412    /// disable_retries(&mut builder);
413    /// let config = builder.build();
414    /// ```
415    pub fn set_retry_config(&mut self, retry_config: ::std::option::Option<::aws_smithy_types::retry::RetryConfig>) -> &mut Self {
416        retry_config.map(|r| self.config.store_put(r));
417        self
418    }
419    /// Set the sleep_impl for the builder
420    ///
421    /// # Examples
422    ///
423    /// ```no_run
424    /// use aws_sdk_s3::config::{AsyncSleep, Config, SharedAsyncSleep, Sleep};
425    ///
426    /// #[derive(Debug)]
427    /// pub struct ForeverSleep;
428    ///
429    /// impl AsyncSleep for ForeverSleep {
430    ///     fn sleep(&self, duration: std::time::Duration) -> Sleep {
431    ///         Sleep::new(std::future::pending())
432    ///     }
433    /// }
434    ///
435    /// let sleep_impl = SharedAsyncSleep::new(ForeverSleep);
436    /// let config = Config::builder().sleep_impl(sleep_impl).build();
437    /// ```
438    pub fn sleep_impl(mut self, sleep_impl: impl crate::config::AsyncSleep + 'static) -> Self {
439        self.set_sleep_impl(Some(::aws_smithy_runtime_api::shared::IntoShared::into_shared(sleep_impl)));
440        self
441    }
442
443    /// Set the sleep_impl for the builder
444    ///
445    /// # Examples
446    ///
447    /// ```no_run
448    /// use aws_sdk_s3::config::{AsyncSleep, Builder, Config, SharedAsyncSleep, Sleep};
449    ///
450    /// #[derive(Debug)]
451    /// pub struct ForeverSleep;
452    ///
453    /// impl AsyncSleep for ForeverSleep {
454    ///     fn sleep(&self, duration: std::time::Duration) -> Sleep {
455    ///         Sleep::new(std::future::pending())
456    ///     }
457    /// }
458    ///
459    /// fn set_never_ending_sleep_impl(builder: &mut Builder) {
460    ///     let sleep_impl = SharedAsyncSleep::new(ForeverSleep);
461    ///     builder.set_sleep_impl(Some(sleep_impl));
462    /// }
463    ///
464    /// let mut builder = Config::builder();
465    /// set_never_ending_sleep_impl(&mut builder);
466    /// let config = builder.build();
467    /// ```
468    pub fn set_sleep_impl(&mut self, sleep_impl: ::std::option::Option<crate::config::SharedAsyncSleep>) -> &mut Self {
469        self.runtime_components.set_sleep_impl(sleep_impl);
470        self
471    }
472    /// Set the timeout_config for the builder
473    ///
474    /// # Examples
475    ///
476    /// ```no_run
477    /// # use std::time::Duration;
478    /// use aws_sdk_s3::config::Config;
479    /// use aws_sdk_s3::config::timeout::TimeoutConfig;
480    ///
481    /// let timeout_config = TimeoutConfig::builder()
482    ///     .operation_attempt_timeout(Duration::from_secs(1))
483    ///     .build();
484    /// let config = Config::builder().timeout_config(timeout_config).build();
485    /// ```
486    pub fn timeout_config(mut self, timeout_config: ::aws_smithy_types::timeout::TimeoutConfig) -> Self {
487        self.set_timeout_config(Some(timeout_config));
488        self
489    }
490
491    /// Set the timeout_config for the builder.
492    ///
493    /// Setting this to `None` has no effect if another source of configuration has set timeouts. If you
494    /// are attempting to disable timeouts, use [`TimeoutConfig::disabled`](::aws_smithy_types::timeout::TimeoutConfig::disabled)
495    ///
496    ///
497    /// # Examples
498    ///
499    /// ```no_run
500    /// # use std::time::Duration;
501    /// use aws_sdk_s3::config::{Builder, Config};
502    /// use aws_sdk_s3::config::timeout::TimeoutConfig;
503    ///
504    /// fn set_request_timeout(builder: &mut Builder) {
505    ///     let timeout_config = TimeoutConfig::builder()
506    ///         .operation_attempt_timeout(Duration::from_secs(1))
507    ///         .build();
508    ///     builder.set_timeout_config(Some(timeout_config));
509    /// }
510    ///
511    /// let mut builder = Config::builder();
512    /// set_request_timeout(&mut builder);
513    /// let config = builder.build();
514    /// ```
515    pub fn set_timeout_config(&mut self, timeout_config: ::std::option::Option<::aws_smithy_types::timeout::TimeoutConfig>) -> &mut Self {
516        // passing None has no impact.
517        let Some(mut timeout_config) = timeout_config else { return self };
518
519        if let Some(base) = self.config.load::<::aws_smithy_types::timeout::TimeoutConfig>() {
520            timeout_config.take_defaults_from(base);
521        }
522        self.config.store_put(timeout_config);
523        self
524    }
525    /// Set the partition for retry-related state. When clients share a retry partition, they will
526    /// also share things like token buckets and client rate limiters. By default, all clients
527    /// for the same service will share a partition.
528    pub fn retry_partition(mut self, retry_partition: ::aws_smithy_runtime::client::retries::RetryPartition) -> Self {
529        self.set_retry_partition(Some(retry_partition));
530        self
531    }
532    /// Set the partition for retry-related state. When clients share a retry partition, they will
533    /// also share things like token buckets and client rate limiters. By default, all clients
534    /// for the same service will share a partition.
535    pub fn set_retry_partition(
536        &mut self,
537        retry_partition: ::std::option::Option<::aws_smithy_runtime::client::retries::RetryPartition>,
538    ) -> &mut Self {
539        retry_partition.map(|r| self.config.store_put(r));
540        self
541    }
542    /// Set the identity cache for auth.
543    ///
544    /// The identity cache defaults to a lazy caching implementation that will resolve
545    /// an identity when it is requested, and place it in the cache thereafter. Subsequent
546    /// requests will take the value from the cache while it is still valid. Once it expires,
547    /// the next request will result in refreshing the identity.
548    ///
549    /// This configuration allows you to disable or change the default caching mechanism.
550    /// To use a custom caching mechanism, implement the [`ResolveCachedIdentity`](crate::config::ResolveCachedIdentity)
551    /// trait and pass that implementation into this function.
552    ///
553    /// # Examples
554    ///
555    /// Disabling identity caching:
556    /// ```no_run
557    /// use aws_sdk_s3::config::IdentityCache;
558    ///
559    /// let config = aws_sdk_s3::Config::builder()
560    ///     .identity_cache(IdentityCache::no_cache())
561    ///     // ...
562    ///     .build();
563    /// let client = aws_sdk_s3::Client::from_conf(config);
564    /// ```
565    ///
566    /// Customizing lazy caching:
567    /// ```no_run
568    /// use aws_sdk_s3::config::IdentityCache;
569    /// use std::time::Duration;
570    ///
571    /// let config = aws_sdk_s3::Config::builder()
572    ///     .identity_cache(
573    ///         IdentityCache::lazy()
574    ///             // change the load timeout to 10 seconds
575    ///             .load_timeout(Duration::from_secs(10))
576    ///             .build()
577    ///     )
578    ///     // ...
579    ///     .build();
580    /// let client = aws_sdk_s3::Client::from_conf(config);
581    /// ```
582    ///
583    pub fn identity_cache(mut self, identity_cache: impl crate::config::ResolveCachedIdentity + 'static) -> Self {
584        self.set_identity_cache(identity_cache);
585        self
586    }
587
588    /// Set the identity cache for auth.
589    ///
590    /// The identity cache defaults to a lazy caching implementation that will resolve
591    /// an identity when it is requested, and place it in the cache thereafter. Subsequent
592    /// requests will take the value from the cache while it is still valid. Once it expires,
593    /// the next request will result in refreshing the identity.
594    ///
595    /// This configuration allows you to disable or change the default caching mechanism.
596    /// To use a custom caching mechanism, implement the [`ResolveCachedIdentity`](crate::config::ResolveCachedIdentity)
597    /// trait and pass that implementation into this function.
598    ///
599    /// # Examples
600    ///
601    /// Disabling identity caching:
602    /// ```no_run
603    /// use aws_sdk_s3::config::IdentityCache;
604    ///
605    /// let config = aws_sdk_s3::Config::builder()
606    ///     .identity_cache(IdentityCache::no_cache())
607    ///     // ...
608    ///     .build();
609    /// let client = aws_sdk_s3::Client::from_conf(config);
610    /// ```
611    ///
612    /// Customizing lazy caching:
613    /// ```no_run
614    /// use aws_sdk_s3::config::IdentityCache;
615    /// use std::time::Duration;
616    ///
617    /// let config = aws_sdk_s3::Config::builder()
618    ///     .identity_cache(
619    ///         IdentityCache::lazy()
620    ///             // change the load timeout to 10 seconds
621    ///             .load_timeout(Duration::from_secs(10))
622    ///             .build()
623    ///     )
624    ///     // ...
625    ///     .build();
626    /// let client = aws_sdk_s3::Client::from_conf(config);
627    /// ```
628    ///
629    pub fn set_identity_cache(&mut self, identity_cache: impl crate::config::ResolveCachedIdentity + 'static) -> &mut Self {
630        self.runtime_components.set_identity_cache(::std::option::Option::Some(identity_cache));
631        self
632    }
633    /// Add an [interceptor](crate::config::Intercept) that runs at specific stages of the request execution pipeline.
634    ///
635    /// Interceptors targeted at a certain stage are executed according to the pre-defined priority.
636    /// The SDK provides a default set of interceptors. An interceptor configured by this method
637    /// will run after those default interceptors.
638    ///
639    /// # Examples
640    /// ```no_run
641    /// # #[cfg(test)]
642    /// # mod tests {
643    /// # #[test]
644    /// # fn example() {
645    /// use aws_smithy_runtime_api::client::interceptors::context::phase::BeforeTransmit;
646    /// use aws_smithy_runtime_api::client::interceptors::{Interceptor, InterceptorContext};
647    /// use aws_smithy_types::config_bag::ConfigBag;
648    /// use aws_sdk_s3::config::Config;
649    ///
650    /// fn base_url() -> String {
651    ///     // ...
652    ///     # String::new()
653    /// }
654    ///
655    /// #[derive(Debug)]
656    /// pub struct UriModifierInterceptor;
657    /// impl Intercept for UriModifierInterceptor {
658    ///     fn modify_before_signing(
659    ///         &self,
660    ///         context: &mut InterceptorContext<BeforeTransmit>,
661    ///         _cfg: &mut ConfigBag,
662    ///     ) -> Result<(), aws_smithy_runtime_api::client::interceptors::BoxError> {
663    ///         let request = context.request_mut();
664    ///         let uri = format!("{}{}", base_url(), request.uri().path());
665    ///         *request.uri_mut() = uri.parse()?;
666    ///
667    ///         Ok(())
668    ///     }
669    /// }
670    ///
671    /// let config = Config::builder()
672    ///     .interceptor(UriModifierInterceptor)
673    ///     .build();
674    /// # }
675    /// # }
676    /// ```
677    pub fn interceptor(mut self, interceptor: impl crate::config::Intercept + 'static) -> Self {
678        self.push_interceptor(crate::config::SharedInterceptor::new(interceptor));
679        self
680    }
681
682    /// Add a [`SharedInterceptor`](crate::config::SharedInterceptor) that runs at specific stages of the request execution pipeline.
683    ///
684    /// Interceptors targeted at a certain stage are executed according to the pre-defined priority.
685    /// The SDK provides a default set of interceptors. An interceptor configured by this method
686    /// will run after those default interceptors.
687    ///
688    /// # Examples
689    /// ```no_run
690    /// # #[cfg(test)]
691    /// # mod tests {
692    /// # #[test]
693    /// # fn example() {
694    /// use aws_smithy_runtime_api::client::interceptors::context::phase::BeforeTransmit;
695    /// use aws_smithy_runtime_api::client::interceptors::{Interceptor, InterceptorContext, SharedInterceptor};
696    /// use aws_smithy_types::config_bag::ConfigBag;
697    /// use aws_sdk_s3::config::{Builder, Config};
698    ///
699    /// fn base_url() -> String {
700    ///     // ...
701    ///     # String::new()
702    /// }
703    ///
704    /// fn modify_request_uri(builder: &mut Builder) {
705    ///     #[derive(Debug)]
706    ///     pub struct UriModifierInterceptor;
707    ///     impl Intercept for UriModifierInterceptor {
708    ///         fn modify_before_signing(
709    ///             &self,
710    ///             context: &mut InterceptorContext<BeforeTransmit>,
711    ///             _cfg: &mut ConfigBag,
712    ///         ) -> Result<(), aws_smithy_runtime_api::client::interceptors::BoxError> {
713    ///             let request = context.request_mut();
714    ///             let uri = format!("{}{}", base_url(), request.uri().path());
715    ///             *request.uri_mut() = uri.parse()?;
716    ///
717    ///             Ok(())
718    ///         }
719    ///     }
720    ///     builder.push_interceptor(SharedInterceptor::new(UriModifierInterceptor));
721    /// }
722    ///
723    /// let mut builder = Config::builder();
724    /// modify_request_uri(&mut builder);
725    /// let config = builder.build();
726    /// # }
727    /// # }
728    /// ```
729    pub fn push_interceptor(&mut self, interceptor: crate::config::SharedInterceptor) -> &mut Self {
730        self.runtime_components.push_interceptor(interceptor);
731        self
732    }
733
734    /// Set [`SharedInterceptor`](crate::config::SharedInterceptor)s for the builder.
735    pub fn set_interceptors(&mut self, interceptors: impl IntoIterator<Item = crate::config::SharedInterceptor>) -> &mut Self {
736        self.runtime_components.set_interceptors(interceptors.into_iter());
737        self
738    }
739    /// Sets the time source used for this service
740    pub fn time_source(mut self, time_source: impl ::aws_smithy_async::time::TimeSource + 'static) -> Self {
741        self.set_time_source(::std::option::Option::Some(::aws_smithy_runtime_api::shared::IntoShared::into_shared(
742            time_source,
743        )));
744        self
745    }
746    /// Sets the time source used for this service
747    pub fn set_time_source(&mut self, time_source: ::std::option::Option<::aws_smithy_async::time::SharedTimeSource>) -> &mut Self {
748        self.runtime_components.set_time_source(time_source);
749        self
750    }
751    /// Add type implementing [`ClassifyRetry`](::aws_smithy_runtime_api::client::retries::classifiers::ClassifyRetry) that will be used by the
752    /// [`RetryStrategy`](::aws_smithy_runtime_api::client::retries::RetryStrategy) to determine what responses should be retried.
753    ///
754    /// A retry classifier configured by this method will run according to its [priority](::aws_smithy_runtime_api::client::retries::classifiers::RetryClassifierPriority).
755    ///
756    /// # Examples
757    /// ```no_run
758    /// # #[cfg(test)]
759    /// # mod tests {
760    /// # #[test]
761    /// # fn example() {
762    /// use aws_smithy_runtime_api::client::interceptors::context::InterceptorContext;
763    /// use aws_smithy_runtime_api::client::orchestrator::OrchestratorError;
764    /// use aws_smithy_runtime_api::client::retries::classifiers::{
765    ///     ClassifyRetry, RetryAction, RetryClassifierPriority,
766    /// };
767    /// use aws_smithy_types::error::metadata::ProvideErrorMetadata;
768    /// use aws_smithy_types::retry::ErrorKind;
769    /// use std::error::Error as StdError;
770    /// use std::marker::PhantomData;
771    /// use aws_sdk_s3::config::Config;
772    /// # struct SomeOperationError {}
773    ///
774    /// const RETRYABLE_ERROR_CODES: &[&str] = [
775    ///     // List error codes to be retried here...
776    /// ];
777    ///
778    /// // When classifying at an operation's error type, classifiers require a generic parameter.
779    /// // When classifying the HTTP response alone, no generic is needed.
780    /// #[derive(Debug, Default)]
781    /// pub struct ErrorCodeClassifier<E> {
782    ///     _inner: PhantomData<E>,
783    /// }
784    ///
785    /// impl<E> ExampleErrorCodeClassifier<E> {
786    ///     pub fn new() -> Self {
787    ///         Self {
788    ///             _inner: PhantomData,
789    ///         }
790    ///     }
791    /// }
792    ///
793    /// impl<E> ClassifyRetry for ExampleErrorCodeClassifier<E>
794    /// where
795    ///     // Adding a trait bound for ProvideErrorMetadata allows us to inspect the error code.
796    ///     E: StdError + ProvideErrorMetadata + Send + Sync + 'static,
797    /// {
798    ///     fn classify_retry(&self, ctx: &InterceptorContext) -> RetryAction {
799    ///         // Check for a result
800    ///         let output_or_error = ctx.output_or_error();
801    ///         // Check for an error
802    ///         let error = match output_or_error {
803    ///             Some(Ok(_)) | None => return RetryAction::NoActionIndicated,
804    ///               Some(Err(err)) => err,
805    ///         };
806    ///
807    ///         // Downcast the generic error and extract the code
808    ///         let error_code = OrchestratorError::as_operation_error(error)
809    ///             .and_then(|err| err.downcast_ref::<E>())
810    ///             .and_then(|err| err.code());
811    ///
812    ///         // If this error's code is in our list, return an action that tells the RetryStrategy to retry this request.
813    ///         if let Some(error_code) = error_code {
814    ///             if RETRYABLE_ERROR_CODES.contains(&error_code) {
815    ///                 return RetryAction::transient_error();
816    ///             }
817    ///         }
818    ///
819    ///         // Otherwise, return that no action is indicated i.e. that this classifier doesn't require a retry.
820    ///         // Another classifier may still classify this response as retryable.
821    ///         RetryAction::NoActionIndicated
822    ///     }
823    ///
824    ///     fn name(&self) -> &'static str { "Example Error Code Classifier" }
825    /// }
826    ///
827    /// let config = Config::builder()
828    ///     .retry_classifier(ExampleErrorCodeClassifier::<SomeOperationError>::new())
829    ///     .build();
830    /// # }
831    /// # }
832    /// ```
833    pub fn retry_classifier(
834        mut self,
835        retry_classifier: impl ::aws_smithy_runtime_api::client::retries::classifiers::ClassifyRetry + 'static,
836    ) -> Self {
837        self.push_retry_classifier(::aws_smithy_runtime_api::client::retries::classifiers::SharedRetryClassifier::new(
838            retry_classifier,
839        ));
840        self
841    }
842
843    /// Add a [`SharedRetryClassifier`](::aws_smithy_runtime_api::client::retries::classifiers::SharedRetryClassifier) that will be used by the
844    /// [`RetryStrategy`](::aws_smithy_runtime_api::client::retries::RetryStrategy) to determine what responses should be retried.
845    ///
846    /// A retry classifier configured by this method will run according to its priority.
847    ///
848    /// # Examples
849    /// ```no_run
850    /// # #[cfg(test)]
851    /// # mod tests {
852    /// # #[test]
853    /// # fn example() {
854    /// use aws_smithy_runtime_api::client::interceptors::context::InterceptorContext;
855    /// use aws_smithy_runtime_api::client::orchestrator::OrchestratorError;
856    /// use aws_smithy_runtime_api::client::retries::classifiers::{
857    ///     ClassifyRetry, RetryAction, RetryClassifierPriority,
858    /// };
859    /// use aws_smithy_types::error::metadata::ProvideErrorMetadata;
860    /// use aws_smithy_types::retry::ErrorKind;
861    /// use std::error::Error as StdError;
862    /// use std::marker::PhantomData;
863    /// use aws_sdk_s3::config::{Builder, Config};
864    /// # struct SomeOperationError {}
865    ///
866    /// const RETRYABLE_ERROR_CODES: &[&str] = [
867    ///     // List error codes to be retried here...
868    /// ];
869    /// fn set_example_error_code_classifier(builder: &mut Builder) {
870    ///     // When classifying at an operation's error type, classifiers require a generic parameter.
871    ///     // When classifying the HTTP response alone, no generic is needed.
872    ///     #[derive(Debug, Default)]
873    ///     pub struct ExampleErrorCodeClassifier<E> {
874    ///         _inner: PhantomData<E>,
875    ///     }
876    ///
877    ///     impl<E> ExampleErrorCodeClassifier<E> {
878    ///         pub fn new() -> Self {
879    ///             Self {
880    ///                 _inner: PhantomData,
881    ///             }
882    ///         }
883    ///     }
884    ///
885    ///     impl<E> ClassifyRetry for ExampleErrorCodeClassifier<E>
886    ///     where
887    ///         // Adding a trait bound for ProvideErrorMetadata allows us to inspect the error code.
888    ///         E: StdError + ProvideErrorMetadata + Send + Sync + 'static,
889    ///     {
890    ///         fn classify_retry(&self, ctx: &InterceptorContext) -> RetryAction {
891    ///             // Check for a result
892    ///             let output_or_error = ctx.output_or_error();
893    ///             // Check for an error
894    ///             let error = match output_or_error {
895    ///                 Some(Ok(_)) | None => return RetryAction::NoActionIndicated,
896    ///                   Some(Err(err)) => err,
897    ///             };
898    ///
899    ///             // Downcast the generic error and extract the code
900    ///             let error_code = OrchestratorError::as_operation_error(error)
901    ///                 .and_then(|err| err.downcast_ref::<E>())
902    ///                 .and_then(|err| err.code());
903    ///
904    ///             // If this error's code is in our list, return an action that tells the RetryStrategy to retry this request.
905    ///             if let Some(error_code) = error_code {
906    ///                 if RETRYABLE_ERROR_CODES.contains(&error_code) {
907    ///                     return RetryAction::transient_error();
908    ///                 }
909    ///             }
910    ///
911    ///             // Otherwise, return that no action is indicated i.e. that this classifier doesn't require a retry.
912    ///             // Another classifier may still classify this response as retryable.
913    ///             RetryAction::NoActionIndicated
914    ///         }
915    ///
916    ///         fn name(&self) -> &'static str { "Example Error Code Classifier" }
917    ///     }
918    ///
919    ///     builder.push_retry_classifier(ExampleErrorCodeClassifier::<SomeOperationError>::new())
920    /// }
921    ///
922    /// let mut builder = Config::builder();
923    /// set_example_error_code_classifier(&mut builder);
924    /// let config = builder.build();
925    /// # }
926    /// # }
927    /// ```
928    pub fn push_retry_classifier(
929        &mut self,
930        retry_classifier: ::aws_smithy_runtime_api::client::retries::classifiers::SharedRetryClassifier,
931    ) -> &mut Self {
932        self.runtime_components.push_retry_classifier(retry_classifier);
933        self
934    }
935
936    /// Set [`SharedRetryClassifier`](::aws_smithy_runtime_api::client::retries::classifiers::SharedRetryClassifier)s for the builder, replacing any that
937    /// were previously set.
938    pub fn set_retry_classifiers(
939        &mut self,
940        retry_classifiers: impl IntoIterator<Item = ::aws_smithy_runtime_api::client::retries::classifiers::SharedRetryClassifier>,
941    ) -> &mut Self {
942        self.runtime_components.set_retry_classifiers(retry_classifiers.into_iter());
943        self
944    }
945    /// Sets the name of the app that is using the client.
946    ///
947    /// This _optional_ name is used to identify the application in the user agent that
948    /// gets sent along with requests.
949    pub fn app_name(mut self, app_name: ::aws_types::app_name::AppName) -> Self {
950        self.set_app_name(Some(app_name));
951        self
952    }
953    /// Sets the name of the app that is using the client.
954    ///
955    /// This _optional_ name is used to identify the application in the user agent that
956    /// gets sent along with requests.
957    pub fn set_app_name(&mut self, app_name: ::std::option::Option<::aws_types::app_name::AppName>) -> &mut Self {
958        self.config.store_or_unset(app_name);
959        self
960    }
961    /// Overrides the default invocation ID generator.
962    ///
963    /// The invocation ID generator generates ID values for the `amz-sdk-invocation-id` header. By default, this will be a random UUID. Overriding it may be useful in tests that examine the HTTP request and need to be deterministic.
964    pub fn invocation_id_generator(mut self, gen: impl ::aws_runtime::invocation_id::InvocationIdGenerator + 'static) -> Self {
965        self.set_invocation_id_generator(::std::option::Option::Some(
966            ::aws_runtime::invocation_id::SharedInvocationIdGenerator::new(gen),
967        ));
968        self
969    }
970    /// Overrides the default invocation ID generator.
971    ///
972    /// The invocation ID generator generates ID values for the `amz-sdk-invocation-id` header. By default, this will be a random UUID. Overriding it may be useful in tests that examine the HTTP request and need to be deterministic.
973    pub fn set_invocation_id_generator(
974        &mut self,
975        gen: ::std::option::Option<::aws_runtime::invocation_id::SharedInvocationIdGenerator>,
976    ) -> &mut Self {
977        self.config.store_or_unset(gen);
978        self
979    }
980    /// Sets the endpoint URL used to communicate with this service.
981    ///
982    /// Note: this is used in combination with other endpoint rules, e.g. an API that applies a host-label prefix
983    /// will be prefixed onto this URL. To fully override the endpoint resolver, use
984    /// [`Builder::endpoint_resolver`].
985    pub fn endpoint_url(mut self, endpoint_url: impl Into<::std::string::String>) -> Self {
986        self.set_endpoint_url(Some(endpoint_url.into()));
987        self
988    }
989    /// Sets the endpoint URL used to communicate with this service.
990    ///
991    /// Note: this is used in combination with other endpoint rules, e.g. an API that applies a host-label prefix
992    /// will be prefixed onto this URL. To fully override the endpoint resolver, use
993    /// [`Builder::endpoint_resolver`].
994    pub fn set_endpoint_url(&mut self, endpoint_url: Option<::std::string::String>) -> &mut Self {
995        self.config.store_or_unset(endpoint_url.map(::aws_types::endpoint_config::EndpointUrl));
996        self
997    }
998    /// When true, use the dual-stack endpoint. If the configured endpoint does not support dual-stack, dispatching the request MAY return an error.
999    pub fn use_dual_stack(mut self, use_dual_stack: impl Into<bool>) -> Self {
1000        self.set_use_dual_stack(Some(use_dual_stack.into()));
1001        self
1002    }
1003    /// When true, use the dual-stack endpoint. If the configured endpoint does not support dual-stack, dispatching the request MAY return an error.
1004    pub fn set_use_dual_stack(&mut self, use_dual_stack: Option<bool>) -> &mut Self {
1005        self.config.store_or_unset(use_dual_stack.map(::aws_types::endpoint_config::UseDualStack));
1006        self
1007    }
1008    /// When true, send this request to the FIPS-compliant regional endpoint. If the configured endpoint does not have a FIPS compliant endpoint, dispatching the request will return an error.
1009    pub fn use_fips(mut self, use_fips: impl Into<bool>) -> Self {
1010        self.set_use_fips(Some(use_fips.into()));
1011        self
1012    }
1013    /// When true, send this request to the FIPS-compliant regional endpoint. If the configured endpoint does not have a FIPS compliant endpoint, dispatching the request will return an error.
1014    pub fn set_use_fips(&mut self, use_fips: Option<bool>) -> &mut Self {
1015        self.config.store_or_unset(use_fips.map(::aws_types::endpoint_config::UseFips));
1016        self
1017    }
1018    /// Set the [`ResponseChecksumValidation`](crate::config::ResponseChecksumValidation)
1019    /// to determine when checksum validation will be performed on response payloads.
1020    pub fn response_checksum_validation(mut self, response_checksum_validation: crate::config::ResponseChecksumValidation) -> Self {
1021        self.set_response_checksum_validation(::std::option::Option::Some(response_checksum_validation));
1022        self
1023    }
1024    /// Set the [`ResponseChecksumValidation`](crate::config::ResponseChecksumValidation)
1025    /// to determine when checksum validation will be performed on response payloads.
1026    pub fn set_response_checksum_validation(
1027        &mut self,
1028        response_checksum_validation: ::std::option::Option<crate::config::ResponseChecksumValidation>,
1029    ) -> &mut Self {
1030        self.config.store_or_unset(response_checksum_validation);
1031        self
1032    }
1033    /// Set the [`RequestChecksumCalculation`](crate::config::RequestChecksumCalculation)
1034    /// to determine when a checksum will be calculated for request payloads.
1035    pub fn request_checksum_calculation(mut self, request_checksum_calculation: crate::config::RequestChecksumCalculation) -> Self {
1036        self.set_request_checksum_calculation(::std::option::Option::Some(request_checksum_calculation));
1037        self
1038    }
1039    /// Set the [`RequestChecksumCalculation`](crate::config::RequestChecksumCalculation)
1040    /// to determine when a checksum will be calculated for request payloads.
1041    pub fn set_request_checksum_calculation(
1042        &mut self,
1043        request_checksum_calculation: ::std::option::Option<crate::config::RequestChecksumCalculation>,
1044    ) -> &mut Self {
1045        self.config.store_or_unset(request_checksum_calculation);
1046        self
1047    }
1048    /// Sets the AWS region to use when making requests.
1049    ///
1050    /// # Examples
1051    /// ```no_run
1052    /// use aws_types::region::Region;
1053    /// use aws_sdk_s3::config::{Builder, Config};
1054    ///
1055    /// let config = aws_sdk_s3::Config::builder()
1056    ///     .region(Region::new("us-east-1"))
1057    ///     .build();
1058    /// ```
1059    pub fn region(mut self, region: impl ::std::convert::Into<::std::option::Option<crate::config::Region>>) -> Self {
1060        self.set_region(region.into());
1061        self
1062    }
1063    /// Sets the AWS region to use when making requests.
1064    pub fn set_region(&mut self, region: ::std::option::Option<crate::config::Region>) -> &mut Self {
1065        self.config.store_or_unset(region);
1066        self
1067    }
1068    /// Sets the credentials provider for this service
1069    pub fn credentials_provider(mut self, credentials_provider: impl crate::config::ProvideCredentials + 'static) -> Self {
1070        self.set_credentials_provider(::std::option::Option::Some(crate::config::SharedCredentialsProvider::new(
1071            credentials_provider,
1072        )));
1073        self
1074    }
1075    /// Sets the credentials provider for this service
1076    pub fn set_credentials_provider(&mut self, credentials_provider: ::std::option::Option<crate::config::SharedCredentialsProvider>) -> &mut Self {
1077        if let Some(credentials_provider) = credentials_provider {
1078            #[cfg(feature = "sigv4a")]
1079            {
1080                self.runtime_components
1081                    .set_identity_resolver(::aws_runtime::auth::sigv4a::SCHEME_ID, credentials_provider.clone());
1082            }
1083            self.runtime_components
1084                .set_identity_resolver(::aws_runtime::auth::sigv4::SCHEME_ID, credentials_provider);
1085        }
1086        self
1087    }
1088    /// Sets the credentials provider for S3 Express One Zone
1089    pub fn express_credentials_provider(mut self, credentials_provider: impl crate::config::ProvideCredentials + 'static) -> Self {
1090        self.set_express_credentials_provider(::std::option::Option::Some(crate::config::SharedCredentialsProvider::new(
1091            credentials_provider,
1092        )));
1093        self
1094    }
1095    /// Sets the credentials provider for S3 Express One Zone
1096    pub fn set_express_credentials_provider(
1097        &mut self,
1098        credentials_provider: ::std::option::Option<crate::config::SharedCredentialsProvider>,
1099    ) -> &mut Self {
1100        if let ::std::option::Option::Some(credentials_provider) = credentials_provider {
1101            self.runtime_components
1102                .set_identity_resolver(crate::s3_express::auth::SCHEME_ID, credentials_provider);
1103        }
1104        self
1105    }
1106    /// Sets the [`behavior major version`](crate::config::BehaviorVersion).
1107    ///
1108    /// Over time, new best-practice behaviors are introduced. However, these behaviors might not be backwards
1109    /// compatible. For example, a change which introduces new default timeouts or a new retry-mode for
1110    /// all operations might be the ideal behavior but could break existing applications.
1111    ///
1112    /// # Examples
1113    ///
1114    /// Set the behavior major version to `latest`. This is equivalent to enabling the `behavior-version-latest` cargo feature.
1115    /// ```no_run
1116    /// use aws_sdk_s3::config::BehaviorVersion;
1117    ///
1118    /// let config = aws_sdk_s3::Config::builder()
1119    ///     .behavior_version(BehaviorVersion::latest())
1120    ///     // ...
1121    ///     .build();
1122    /// let client = aws_sdk_s3::Client::from_conf(config);
1123    /// ```
1124    ///
1125    /// Customizing behavior major version:
1126    /// ```no_run
1127    /// use aws_sdk_s3::config::BehaviorVersion;
1128    ///
1129    /// let config = aws_sdk_s3::Config::builder()
1130    ///     .behavior_version(BehaviorVersion::v2023_11_09())
1131    ///     // ...
1132    ///     .build();
1133    /// let client = aws_sdk_s3::Client::from_conf(config);
1134    /// ```
1135    ///
1136    pub fn behavior_version(mut self, behavior_version: crate::config::BehaviorVersion) -> Self {
1137        self.set_behavior_version(Some(behavior_version));
1138        self
1139    }
1140
1141    /// Sets the [`behavior major version`](crate::config::BehaviorVersion).
1142    ///
1143    /// Over time, new best-practice behaviors are introduced. However, these behaviors might not be backwards
1144    /// compatible. For example, a change which introduces new default timeouts or a new retry-mode for
1145    /// all operations might be the ideal behavior but could break existing applications.
1146    ///
1147    /// # Examples
1148    ///
1149    /// Set the behavior major version to `latest`. This is equivalent to enabling the `behavior-version-latest` cargo feature.
1150    /// ```no_run
1151    /// use aws_sdk_s3::config::BehaviorVersion;
1152    ///
1153    /// let config = aws_sdk_s3::Config::builder()
1154    ///     .behavior_version(BehaviorVersion::latest())
1155    ///     // ...
1156    ///     .build();
1157    /// let client = aws_sdk_s3::Client::from_conf(config);
1158    /// ```
1159    ///
1160    /// Customizing behavior major version:
1161    /// ```no_run
1162    /// use aws_sdk_s3::config::BehaviorVersion;
1163    ///
1164    /// let config = aws_sdk_s3::Config::builder()
1165    ///     .behavior_version(BehaviorVersion::v2023_11_09())
1166    ///     // ...
1167    ///     .build();
1168    /// let client = aws_sdk_s3::Client::from_conf(config);
1169    /// ```
1170    ///
1171    pub fn set_behavior_version(&mut self, behavior_version: Option<crate::config::BehaviorVersion>) -> &mut Self {
1172        self.behavior_version = behavior_version;
1173        self
1174    }
1175
1176    /// Convenience method to set the latest behavior major version
1177    ///
1178    /// This is equivalent to enabling the `behavior-version-latest` Cargo feature
1179    pub fn behavior_version_latest(mut self) -> Self {
1180        self.set_behavior_version(Some(crate::config::BehaviorVersion::latest()));
1181        self
1182    }
1183    /// Adds a runtime plugin to the config.
1184    #[allow(unused)]
1185    pub(crate) fn runtime_plugin(mut self, plugin: impl crate::config::RuntimePlugin + 'static) -> Self {
1186        self.push_runtime_plugin(crate::config::SharedRuntimePlugin::new(plugin));
1187        self
1188    }
1189    /// Adds a runtime plugin to the config.
1190    #[allow(unused)]
1191    pub(crate) fn push_runtime_plugin(&mut self, plugin: crate::config::SharedRuntimePlugin) -> &mut Self {
1192        self.runtime_plugins.push(plugin);
1193        self
1194    }
1195    #[cfg(any(feature = "test-util", test))]
1196    #[allow(unused_mut)]
1197    /// Apply test defaults to the builder
1198    pub fn apply_test_defaults(&mut self) -> &mut Self {
1199        self.set_time_source(::std::option::Option::Some(::aws_smithy_async::time::SharedTimeSource::new(
1200            ::aws_smithy_async::time::StaticTimeSource::new(::std::time::UNIX_EPOCH + ::std::time::Duration::from_secs(1234567890)),
1201        )));
1202        self.config.store_put(::aws_runtime::user_agent::AwsUserAgent::for_tests());
1203        self.set_credentials_provider(Some(crate::config::SharedCredentialsProvider::new(
1204            ::aws_credential_types::Credentials::for_tests(),
1205        )));
1206        self.behavior_version = ::std::option::Option::Some(crate::config::BehaviorVersion::latest());
1207        self
1208    }
1209    #[cfg(any(feature = "test-util", test))]
1210    #[allow(unused_mut)]
1211    /// Apply test defaults to the builder
1212    pub fn with_test_defaults(mut self) -> Self {
1213        self.apply_test_defaults();
1214        self
1215    }
1216    /// Builds a [`Config`].
1217    #[allow(unused_mut)]
1218    pub fn build(mut self) -> Config {
1219        let mut layer = self.config;
1220
1221        if self.runtime_components.time_source().is_none() {
1222            self.runtime_components
1223                .set_time_source(::std::option::Option::Some(::std::default::Default::default()));
1224        }
1225        layer.store_put(crate::meta::API_METADATA.clone());
1226        layer.store_put(::aws_types::SigningName::from_static("s3"));
1227        layer
1228            .load::<::aws_types::region::Region>()
1229            .cloned()
1230            .map(|r| layer.store_put(::aws_types::region::SigningRegion::from(r)));
1231        Config {
1232            config: crate::config::Layer::from(layer.clone()).with_name("aws_sdk_s3::config::Config").freeze(),
1233            cloneable: layer,
1234            runtime_components: self.runtime_components,
1235            runtime_plugins: self.runtime_plugins,
1236            behavior_version: self.behavior_version,
1237        }
1238    }
1239}
1240#[derive(::std::fmt::Debug)]
1241pub(crate) struct ServiceRuntimePlugin {
1242    config: ::std::option::Option<::aws_smithy_types::config_bag::FrozenLayer>,
1243    runtime_components: ::aws_smithy_runtime_api::client::runtime_components::RuntimeComponentsBuilder,
1244}
1245
1246impl ServiceRuntimePlugin {
1247    pub fn new(_service_config: crate::config::Config) -> Self {
1248        let config = {
1249            let mut cfg = ::aws_smithy_types::config_bag::Layer::new("AmazonS3");
1250            cfg.store_put(::aws_smithy_runtime::client::orchestrator::AuthSchemeAndEndpointOrchestrationV2);
1251            ::std::option::Option::Some(cfg.freeze())
1252        };
1253        let mut runtime_components = ::aws_smithy_runtime_api::client::runtime_components::RuntimeComponentsBuilder::new("ServiceRuntimePlugin");
1254        runtime_components.set_endpoint_resolver(Some({
1255            use crate::config::endpoint::ResolveEndpoint;
1256            crate::config::endpoint::DefaultResolver::new().into_shared_resolver()
1257        }));
1258        runtime_components.push_interceptor(::aws_smithy_runtime::client::http::connection_poisoning::ConnectionPoisoningInterceptor::new());
1259        runtime_components.push_retry_classifier(::aws_smithy_runtime::client::retries::classifiers::HttpStatusCodeClassifier::default());
1260        runtime_components.push_interceptor(crate::sdk_feature_tracker::retry_mode::RetryModeFeatureTrackerInterceptor::new());
1261        runtime_components.push_interceptor(::aws_runtime::service_clock_skew::ServiceClockSkewInterceptor::new());
1262        runtime_components.push_interceptor(::aws_runtime::request_info::RequestInfoInterceptor::new());
1263        runtime_components.push_interceptor(::aws_runtime::user_agent::UserAgentInterceptor::new());
1264        runtime_components.push_interceptor(::aws_runtime::invocation_id::InvocationIdInterceptor::new());
1265        runtime_components.push_interceptor(::aws_runtime::recursion_detection::RecursionDetectionInterceptor::new());
1266        runtime_components.push_auth_scheme(::aws_smithy_runtime_api::client::auth::SharedAuthScheme::new(
1267            ::aws_runtime::auth::sigv4::SigV4AuthScheme::new(),
1268        ));
1269        #[cfg(feature = "sigv4a")]
1270        {
1271            runtime_components.push_auth_scheme(::aws_smithy_runtime_api::client::auth::SharedAuthScheme::new(
1272                ::aws_runtime::auth::sigv4a::SigV4aAuthScheme::new(),
1273            ));
1274        }
1275        runtime_components.push_auth_scheme(::aws_smithy_runtime_api::client::auth::SharedAuthScheme::new(
1276            crate::s3_express::auth::S3ExpressAuthScheme::new(),
1277        ));
1278        Self { config, runtime_components }
1279    }
1280}
1281
1282impl ::aws_smithy_runtime_api::client::runtime_plugin::RuntimePlugin for ServiceRuntimePlugin {
1283    fn config(&self) -> ::std::option::Option<::aws_smithy_types::config_bag::FrozenLayer> {
1284        self.config.clone()
1285    }
1286
1287    fn order(&self) -> ::aws_smithy_runtime_api::client::runtime_plugin::Order {
1288        ::aws_smithy_runtime_api::client::runtime_plugin::Order::Defaults
1289    }
1290
1291    fn runtime_components(
1292        &self,
1293        _: &::aws_smithy_runtime_api::client::runtime_components::RuntimeComponentsBuilder,
1294    ) -> ::std::borrow::Cow<'_, ::aws_smithy_runtime_api::client::runtime_components::RuntimeComponentsBuilder> {
1295        ::std::borrow::Cow::Borrowed(&self.runtime_components)
1296    }
1297}
1298
1299// Cross-operation shared-state singletons
1300
1301/// A plugin that enables configuration for a single operation invocation
1302///
1303/// The `config` method will return a `FrozenLayer` by storing values from `config_override`.
1304/// In the case of default values requested, they will be obtained from `client_config`.
1305#[derive(Debug)]
1306pub(crate) struct ConfigOverrideRuntimePlugin {
1307    pub(crate) config: ::aws_smithy_types::config_bag::FrozenLayer,
1308    pub(crate) components: ::aws_smithy_runtime_api::client::runtime_components::RuntimeComponentsBuilder,
1309}
1310
1311impl ConfigOverrideRuntimePlugin {
1312    #[allow(dead_code)] // unused when a service does not provide any operations
1313    pub(crate) fn new(
1314        config_override: Builder,
1315        initial_config: ::aws_smithy_types::config_bag::FrozenLayer,
1316        initial_components: &::aws_smithy_runtime_api::client::runtime_components::RuntimeComponentsBuilder,
1317    ) -> Self {
1318        let mut layer = config_override.config;
1319        let mut components = config_override.runtime_components;
1320        #[allow(unused_mut)]
1321        let mut resolver =
1322            ::aws_smithy_runtime::client::config_override::Resolver::overrid(initial_config, initial_components, &mut layer, &mut components);
1323
1324        resolver
1325            .config_mut()
1326            .load::<::aws_types::region::Region>()
1327            .cloned()
1328            .map(|r| resolver.config_mut().store_put(::aws_types::region::SigningRegion::from(r)));
1329
1330        let _ = resolver;
1331        Self {
1332            config: ::aws_smithy_types::config_bag::Layer::from(layer)
1333                .with_name("aws_sdk_s3::config::ConfigOverrideRuntimePlugin")
1334                .freeze(),
1335            components,
1336        }
1337    }
1338}
1339
1340impl ::aws_smithy_runtime_api::client::runtime_plugin::RuntimePlugin for ConfigOverrideRuntimePlugin {
1341    fn config(&self) -> ::std::option::Option<::aws_smithy_types::config_bag::FrozenLayer> {
1342        Some(self.config.clone())
1343    }
1344
1345    fn runtime_components(
1346        &self,
1347        _: &::aws_smithy_runtime_api::client::runtime_components::RuntimeComponentsBuilder,
1348    ) -> ::std::borrow::Cow<'_, ::aws_smithy_runtime_api::client::runtime_components::RuntimeComponentsBuilder> {
1349        ::std::borrow::Cow::Borrowed(&self.components)
1350    }
1351}
1352
1353pub use ::aws_smithy_runtime::client::identity::IdentityCache;
1354pub use ::aws_smithy_runtime_api::client::runtime_components::RuntimeComponents;
1355pub use ::aws_smithy_types::config_bag::ConfigBag;
1356
1357pub use ::aws_credential_types::Credentials;
1358
1359impl From<&::aws_types::sdk_config::SdkConfig> for Builder {
1360    fn from(input: &::aws_types::sdk_config::SdkConfig) -> Self {
1361        let mut builder = Builder::default();
1362        builder.set_disable_s3_express_session_auth(input.service_config().and_then(|conf| {
1363            let str_config = conf.load_config(service_config_key(
1364                "AWS_S3_DISABLE_EXPRESS_SESSION_AUTH",
1365                "s3_disable_express_session_auth",
1366            ));
1367            str_config.and_then(|it| it.parse::<bool>().ok())
1368        }));
1369        builder.set_credentials_provider(input.credentials_provider());
1370        builder = builder.region(input.region().cloned());
1371        builder.set_request_checksum_calculation(input.request_checksum_calculation());
1372        builder.set_response_checksum_validation(input.response_checksum_validation());
1373        builder.set_use_fips(input.use_fips());
1374        builder.set_use_dual_stack(input.use_dual_stack());
1375        if input.get_origin("endpoint_url").is_client_config() {
1376            builder.set_endpoint_url(input.endpoint_url().map(|s| s.to_string()));
1377        } else {
1378            builder.set_endpoint_url(
1379                input
1380                    .service_config()
1381                    .and_then(|conf| {
1382                        conf.load_config(service_config_key("AWS_ENDPOINT_URL", "endpoint_url"))
1383                            .map(|it| it.parse().unwrap())
1384                    })
1385                    .or_else(|| input.endpoint_url().map(|s| s.to_string())),
1386            );
1387        }
1388        // resiliency
1389        builder.set_retry_config(input.retry_config().cloned());
1390        builder.set_timeout_config(input.timeout_config().cloned());
1391        builder.set_sleep_impl(input.sleep_impl());
1392
1393        builder.set_http_client(input.http_client());
1394        builder.set_time_source(input.time_source());
1395        builder.set_behavior_version(input.behavior_version());
1396        // setting `None` here removes the default
1397        if let Some(config) = input.stalled_stream_protection() {
1398            builder.set_stalled_stream_protection(Some(config));
1399        }
1400
1401        if let Some(cache) = input.identity_cache() {
1402            builder.set_identity_cache(cache);
1403        }
1404        builder.set_app_name(input.app_name().cloned());
1405
1406        builder
1407    }
1408}
1409
1410impl From<&::aws_types::sdk_config::SdkConfig> for Config {
1411    fn from(sdk_config: &::aws_types::sdk_config::SdkConfig) -> Self {
1412        Builder::from(sdk_config).build()
1413    }
1414}
1415
1416pub use ::aws_types::app_name::AppName;
1417
1418#[allow(dead_code)]
1419fn service_config_key<'a>(env: &'a str, profile: &'a str) -> aws_types::service_config::ServiceConfigKey<'a> {
1420    ::aws_types::service_config::ServiceConfigKey::builder()
1421        .service_id("S3")
1422        .env(env)
1423        .profile(profile)
1424        .build()
1425        .expect("all field sets explicitly, can't fail")
1426}
1427
1428pub use ::aws_smithy_async::rt::sleep::Sleep;
1429
1430pub(crate) fn base_client_runtime_plugins(mut config: crate::Config) -> ::aws_smithy_runtime_api::client::runtime_plugin::RuntimePlugins {
1431    let mut configured_plugins = ::std::vec::Vec::new();
1432    ::std::mem::swap(&mut config.runtime_plugins, &mut configured_plugins);
1433    #[cfg(feature = "behavior-version-latest")]
1434    {
1435        if config.behavior_version.is_none() {
1436            config.behavior_version = Some(::aws_smithy_runtime_api::client::behavior_version::BehaviorVersion::latest());
1437        }
1438    }
1439
1440    let default_retry_partition = "s3";
1441    let default_retry_partition = match config.region() {
1442        Some(region) => ::std::borrow::Cow::from(format!("{default_retry_partition}-{}", region)),
1443        None => ::std::borrow::Cow::from(default_retry_partition),
1444    };
1445
1446    let scope = "aws-sdk-s3";
1447
1448    let mut plugins = ::aws_smithy_runtime_api::client::runtime_plugin::RuntimePlugins::new()
1449                        // defaults
1450                        .with_client_plugins(::aws_smithy_runtime::client::defaults::default_plugins(
1451                            ::aws_smithy_runtime::client::defaults::DefaultPluginParams::new()
1452                                .with_retry_partition_name(default_retry_partition)
1453                                .with_behavior_version(config.behavior_version.expect("Invalid client configuration: A behavior major version must be set when sending a request or constructing a client. You must set it during client construction or by enabling the `behavior-version-latest` cargo feature."))
1454                        ))
1455                        // user config
1456                        .with_client_plugin(
1457                            ::aws_smithy_runtime_api::client::runtime_plugin::StaticRuntimePlugin::new()
1458                                .with_config(config.config.clone())
1459                                .with_runtime_components(config.runtime_components.clone())
1460                        )
1461                        // codegen config
1462                        .with_client_plugin(crate::config::ServiceRuntimePlugin::new(config.clone()))
1463                        .with_client_plugin(::aws_smithy_runtime::client::auth::no_auth::NoAuthRuntimePlugin::new())
1464                        .with_client_plugin(
1465                            ::aws_smithy_runtime::client::metrics::MetricsRuntimePlugin::builder()
1466                                .with_scope(scope)
1467                                .with_time_source(config.runtime_components.time_source().unwrap_or_default())
1468                                .build()
1469                                .expect("All required fields have been set")
1470                        );
1471
1472    plugins = plugins.with_client_plugin(crate::s3_express::runtime_plugin::S3ExpressRuntimePlugin::new(config.clone()));
1473
1474    for plugin in configured_plugins {
1475        plugins = plugins.with_client_plugin(plugin);
1476    }
1477    plugins
1478}
1479
1480pub use ::aws_smithy_types::config_bag::FrozenLayer;
1481
1482pub use ::aws_smithy_runtime_api::client::runtime_components::RuntimeComponentsBuilder;
1483
1484pub use ::aws_smithy_runtime_api::client::runtime_plugin::SharedRuntimePlugin;
1485
1486pub use ::aws_smithy_runtime_api::client::behavior_version::BehaviorVersion;
1487
1488pub use ::aws_smithy_runtime_api::client::stalled_stream_protection::StalledStreamProtectionConfig;
1489
1490pub use ::aws_smithy_runtime_api::client::http::SharedHttpClient;
1491
1492pub use ::aws_smithy_async::rt::sleep::SharedAsyncSleep;
1493
1494pub use ::aws_smithy_runtime_api::client::identity::SharedIdentityCache;
1495
1496pub use ::aws_smithy_runtime_api::client::interceptors::SharedInterceptor;
1497
1498pub use ::aws_smithy_types::checksum_config::ResponseChecksumValidation;
1499
1500pub use ::aws_smithy_types::checksum_config::RequestChecksumCalculation;
1501
1502pub use ::aws_types::region::Region;
1503
1504pub use ::aws_credential_types::provider::SharedCredentialsProvider;
1505
1506#[derive(Debug, Clone)]
1507pub(crate) struct ForcePathStyle(pub(crate) bool);
1508impl ::aws_smithy_types::config_bag::Storable for ForcePathStyle {
1509    type Storer = ::aws_smithy_types::config_bag::StoreReplace<Self>;
1510}
1511
1512#[derive(Debug, Clone)]
1513pub(crate) struct UseArnRegion(pub(crate) bool);
1514impl ::aws_smithy_types::config_bag::Storable for UseArnRegion {
1515    type Storer = ::aws_smithy_types::config_bag::StoreReplace<Self>;
1516}
1517
1518#[derive(Debug, Clone)]
1519pub(crate) struct DisableMultiRegionAccessPoints(pub(crate) bool);
1520impl ::aws_smithy_types::config_bag::Storable for DisableMultiRegionAccessPoints {
1521    type Storer = ::aws_smithy_types::config_bag::StoreReplace<Self>;
1522}
1523
1524#[derive(Debug, Clone)]
1525pub(crate) struct Accelerate(pub(crate) bool);
1526impl ::aws_smithy_types::config_bag::Storable for Accelerate {
1527    type Storer = ::aws_smithy_types::config_bag::StoreReplace<Self>;
1528}
1529
1530#[derive(Debug, Clone)]
1531pub(crate) struct DisableS3ExpressSessionAuth(pub(crate) bool);
1532impl ::aws_smithy_types::config_bag::Storable for DisableS3ExpressSessionAuth {
1533    type Storer = ::aws_smithy_types::config_bag::StoreReplace<Self>;
1534}
1535
1536pub use ::aws_smithy_runtime_api::client::http::HttpClient;
1537
1538pub use ::aws_smithy_runtime_api::shared::IntoShared;
1539
1540pub use ::aws_smithy_async::rt::sleep::AsyncSleep;
1541
1542pub use ::aws_smithy_runtime_api::client::identity::ResolveCachedIdentity;
1543
1544pub use ::aws_smithy_runtime_api::client::interceptors::Intercept;
1545
1546pub use ::aws_credential_types::provider::ProvideCredentials;
1547
1548pub use ::aws_smithy_runtime_api::client::runtime_plugin::RuntimePlugin;
1549
1550pub use ::aws_smithy_types::config_bag::Layer;
1551
1552/// Types needed to configure endpoint resolution.
1553pub mod endpoint;
1554
1555/// HTTP request and response types.
1556pub mod http;
1557
1558/// Types needed to implement [`Intercept`](crate::config::Intercept).
1559pub mod interceptors;
1560
1561/// Retry configuration.
1562pub mod retry;
1563
1564/// Timeout configuration.
1565pub mod timeout;