aws_sdk_s3/
config.rs

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