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