Skip to main content

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
471    /// Enable no authentication regardless of what authentication mechanisms operations support
472    ///
473    /// This adds [NoAuthScheme](aws_smithy_runtime::client::auth::no_auth::NoAuthScheme) as a fallback
474    /// and the auth scheme resolver will use it when no other auth schemes are applicable.
475    pub fn allow_no_auth(mut self) -> Self {
476        self.set_allow_no_auth();
477        self
478    }
479
480    /// Enable no authentication regardless of what authentication mechanisms operations support
481    ///
482    /// This adds [NoAuthScheme](aws_smithy_runtime::client::auth::no_auth::NoAuthScheme) as a fallback
483    /// and the auth scheme resolver will use it when no other auth schemes are applicable.
484    pub fn set_allow_no_auth(&mut self) -> &mut Self {
485        self.push_runtime_plugin(::aws_smithy_runtime::client::auth::no_auth::NoAuthRuntimePluginV2::new().into_shared());
486        self
487    }
488    /// Set the auth scheme preference for an auth scheme resolver
489    /// (typically the default auth scheme resolver).
490    ///
491    /// Each operation has a predefined order of auth schemes, as determined by the service,
492    /// for auth scheme resolution. By using the auth scheme preference, customers
493    /// can reorder the schemes resolved by the auth scheme resolver.
494    ///
495    /// The preference list is intended as a hint rather than a strict override.
496    /// Any schemes not present in the originally resolved auth schemes will be ignored.
497    ///
498    /// # Examples
499    ///
500    /// ```no_run
501    /// # use aws_smithy_runtime_api::client::auth::AuthSchemeId;
502    /// let config = aws_sdk_s3::Config::builder()
503    ///     .auth_scheme_preference([AuthSchemeId::from("scheme1"), AuthSchemeId::from("scheme2")])
504    ///     // ...
505    ///     .build();
506    /// let client = aws_sdk_s3::Client::from_conf(config);
507    /// ```
508
509    pub fn auth_scheme_preference(
510        mut self,
511        preference: impl ::std::convert::Into<::aws_smithy_runtime_api::client::auth::AuthSchemePreference>,
512    ) -> Self {
513        self.set_auth_scheme_preference(::std::option::Option::Some(preference.into()));
514        self
515    }
516
517    /// Set the auth scheme preference for an auth scheme resolver
518    /// (typically the default auth scheme resolver).
519    ///
520    /// Each operation has a predefined order of auth schemes, as determined by the service,
521    /// for auth scheme resolution. By using the auth scheme preference, customers
522    /// can reorder the schemes resolved by the auth scheme resolver.
523    ///
524    /// The preference list is intended as a hint rather than a strict override.
525    /// Any schemes not present in the originally resolved auth schemes will be ignored.
526    ///
527    /// # Examples
528    ///
529    /// ```no_run
530    /// # use aws_smithy_runtime_api::client::auth::AuthSchemeId;
531    /// let config = aws_sdk_s3::Config::builder()
532    ///     .auth_scheme_preference([AuthSchemeId::from("scheme1"), AuthSchemeId::from("scheme2")])
533    ///     // ...
534    ///     .build();
535    /// let client = aws_sdk_s3::Client::from_conf(config);
536    /// ```
537
538    pub fn set_auth_scheme_preference(
539        &mut self,
540        preference: ::std::option::Option<::aws_smithy_runtime_api::client::auth::AuthSchemePreference>,
541    ) -> &mut Self {
542        self.config.store_or_unset(preference);
543        self
544    }
545    /// Forces this client to use path-style addressing for buckets.
546    pub fn force_path_style(mut self, force_path_style: impl Into<bool>) -> Self {
547        self.set_force_path_style(Some(force_path_style.into()));
548        self
549    }
550    /// Forces this client to use path-style addressing for buckets.
551    pub fn set_force_path_style(&mut self, force_path_style: Option<bool>) -> &mut Self {
552        self.config.store_or_unset(force_path_style.map(crate::config::ForcePathStyle));
553        self
554    }
555
556    /// Enables this client to use an ARN's region when constructing an endpoint instead of the client's configured region.
557    pub fn use_arn_region(mut self, use_arn_region: impl Into<bool>) -> Self {
558        self.set_use_arn_region(Some(use_arn_region.into()));
559        self
560    }
561    /// Enables this client to use an ARN's region when constructing an endpoint instead of the client's configured region.
562    pub fn set_use_arn_region(&mut self, use_arn_region: Option<bool>) -> &mut Self {
563        self.config.store_or_unset(use_arn_region.map(crate::config::UseArnRegion));
564        self
565    }
566
567    /// Disables this client's usage of Multi-Region Access Points.
568    pub fn disable_multi_region_access_points(mut self, disable_multi_region_access_points: impl Into<bool>) -> Self {
569        self.set_disable_multi_region_access_points(Some(disable_multi_region_access_points.into()));
570        self
571    }
572    /// Disables this client's usage of Multi-Region Access Points.
573    pub fn set_disable_multi_region_access_points(&mut self, disable_multi_region_access_points: Option<bool>) -> &mut Self {
574        self.config
575            .store_or_unset(disable_multi_region_access_points.map(crate::config::DisableMultiRegionAccessPoints));
576        self
577    }
578
579    /// Enables this client to use S3 Transfer Acceleration endpoints.
580    pub fn accelerate(mut self, accelerate: impl Into<bool>) -> Self {
581        self.set_accelerate(Some(accelerate.into()));
582        self
583    }
584    /// Enables this client to use S3 Transfer Acceleration endpoints.
585    pub fn set_accelerate(&mut self, accelerate: Option<bool>) -> &mut Self {
586        self.config.store_or_unset(accelerate.map(crate::config::Accelerate));
587        self
588    }
589
590    /// Disables this client's usage of Session Auth for S3Express       buckets and reverts to using conventional SigV4 for those.
591    pub fn disable_s3_express_session_auth(mut self, disable_s3_express_session_auth: impl Into<bool>) -> Self {
592        self.set_disable_s3_express_session_auth(Some(disable_s3_express_session_auth.into()));
593        self
594    }
595    /// Disables this client's usage of Session Auth for S3Express       buckets and reverts to using conventional SigV4 for those.
596    pub fn set_disable_s3_express_session_auth(&mut self, disable_s3_express_session_auth: Option<bool>) -> &mut Self {
597        self.config
598            .store_or_unset(disable_s3_express_session_auth.map(crate::config::DisableS3ExpressSessionAuth));
599        self
600    }
601    /// Sets the endpoint resolver to use when making requests.
602    ///
603    ///
604    /// When unset, the client will used a generated endpoint resolver based on the endpoint resolution
605    /// rules for `aws_sdk_s3`.
606    ///
607    ///
608    /// Note: setting an endpoint resolver will replace any endpoint URL that has been set.
609    /// This method accepts an endpoint resolver [specific to this service](crate::config::endpoint::ResolveEndpoint). If you want to
610    /// provide a shared endpoint resolver, use [`Self::set_endpoint_resolver`].
611    ///
612    /// # Examples
613    /// Create a custom endpoint resolver that resolves a different endpoing per-stage, e.g. staging vs. production.
614    /// ```no_run
615    /// use aws_sdk_s3::config::endpoint::{ResolveEndpoint, EndpointFuture, Params, Endpoint};
616    /// #[derive(Debug)]
617    /// struct StageResolver { stage: String }
618    /// impl ResolveEndpoint for StageResolver {
619    ///     fn resolve_endpoint(&self, params: &Params) -> EndpointFuture<'_> {
620    ///         let stage = &self.stage;
621    ///         EndpointFuture::ready(Ok(Endpoint::builder().url(format!("{stage}.myservice.com")).build()))
622    ///     }
623    /// }
624    /// let resolver = StageResolver { stage: std::env::var("STAGE").unwrap() };
625    /// let config = aws_sdk_s3::Config::builder().endpoint_resolver(resolver).build();
626    /// let client = aws_sdk_s3::Client::from_conf(config);
627    /// ```
628    pub fn endpoint_resolver(mut self, endpoint_resolver: impl crate::config::endpoint::ResolveEndpoint + 'static) -> Self {
629        self.set_endpoint_resolver(::std::option::Option::Some(endpoint_resolver.into_shared_resolver()));
630        self
631    }
632
633    /// Sets the endpoint resolver to use when making requests.
634    ///
635    ///
636    /// When unset, the client will used a generated endpoint resolver based on the endpoint resolution
637    /// rules for `aws_sdk_s3`.
638    ///
639    pub fn set_endpoint_resolver(
640        &mut self,
641        endpoint_resolver: ::std::option::Option<::aws_smithy_runtime_api::client::endpoint::SharedEndpointResolver>,
642    ) -> &mut Self {
643        self.runtime_components.set_endpoint_resolver(endpoint_resolver);
644        self
645    }
646    /// Set the retry_config for the builder
647    ///
648    /// # Examples
649    /// ```no_run
650    /// use aws_sdk_s3::config::Config;
651    /// use aws_sdk_s3::config::retry::RetryConfig;
652    ///
653    /// let retry_config = RetryConfig::standard().with_max_attempts(5);
654    /// let config = Config::builder().retry_config(retry_config).build();
655    /// ```
656    pub fn retry_config(mut self, retry_config: ::aws_smithy_types::retry::RetryConfig) -> Self {
657        self.set_retry_config(Some(retry_config));
658        self
659    }
660
661    /// Set the retry_config for the builder
662    ///
663    /// # Examples
664    /// ```no_run
665    /// use aws_sdk_s3::config::{Builder, Config};
666    /// use aws_sdk_s3::config::retry::RetryConfig;
667    ///
668    /// fn disable_retries(builder: &mut Builder) {
669    ///     let retry_config = RetryConfig::standard().with_max_attempts(1);
670    ///     builder.set_retry_config(Some(retry_config));
671    /// }
672    ///
673    /// let mut builder = Config::builder();
674    /// disable_retries(&mut builder);
675    /// let config = builder.build();
676    /// ```
677    pub fn set_retry_config(&mut self, retry_config: ::std::option::Option<::aws_smithy_types::retry::RetryConfig>) -> &mut Self {
678        retry_config.map(|r| self.config.store_put(r));
679        self
680    }
681    /// Set the sleep_impl for the builder
682    ///
683    /// # Examples
684    ///
685    /// ```no_run
686    /// use aws_sdk_s3::config::{AsyncSleep, Config, SharedAsyncSleep, Sleep};
687    ///
688    /// #[derive(Debug)]
689    /// pub struct ForeverSleep;
690    ///
691    /// impl AsyncSleep for ForeverSleep {
692    ///     fn sleep(&self, duration: std::time::Duration) -> Sleep {
693    ///         Sleep::new(std::future::pending())
694    ///     }
695    /// }
696    ///
697    /// let sleep_impl = SharedAsyncSleep::new(ForeverSleep);
698    /// let config = Config::builder().sleep_impl(sleep_impl).build();
699    /// ```
700    pub fn sleep_impl(mut self, sleep_impl: impl crate::config::AsyncSleep + 'static) -> Self {
701        self.set_sleep_impl(Some(::aws_smithy_runtime_api::shared::IntoShared::into_shared(sleep_impl)));
702        self
703    }
704
705    /// Set the sleep_impl for the builder
706    ///
707    /// # Examples
708    ///
709    /// ```no_run
710    /// use aws_sdk_s3::config::{AsyncSleep, Builder, Config, SharedAsyncSleep, Sleep};
711    ///
712    /// #[derive(Debug)]
713    /// pub struct ForeverSleep;
714    ///
715    /// impl AsyncSleep for ForeverSleep {
716    ///     fn sleep(&self, duration: std::time::Duration) -> Sleep {
717    ///         Sleep::new(std::future::pending())
718    ///     }
719    /// }
720    ///
721    /// fn set_never_ending_sleep_impl(builder: &mut Builder) {
722    ///     let sleep_impl = SharedAsyncSleep::new(ForeverSleep);
723    ///     builder.set_sleep_impl(Some(sleep_impl));
724    /// }
725    ///
726    /// let mut builder = Config::builder();
727    /// set_never_ending_sleep_impl(&mut builder);
728    /// let config = builder.build();
729    /// ```
730    pub fn set_sleep_impl(&mut self, sleep_impl: ::std::option::Option<crate::config::SharedAsyncSleep>) -> &mut Self {
731        self.runtime_components.set_sleep_impl(sleep_impl);
732        self
733    }
734    /// Set the timeout_config for the builder
735    ///
736    /// # Examples
737    ///
738    /// ```no_run
739    /// # use std::time::Duration;
740    /// use aws_sdk_s3::config::Config;
741    /// use aws_sdk_s3::config::timeout::TimeoutConfig;
742    ///
743    /// let timeout_config = TimeoutConfig::builder()
744    ///     .operation_attempt_timeout(Duration::from_secs(1))
745    ///     .build();
746    /// let config = Config::builder().timeout_config(timeout_config).build();
747    /// ```
748    pub fn timeout_config(mut self, timeout_config: ::aws_smithy_types::timeout::TimeoutConfig) -> Self {
749        self.set_timeout_config(Some(timeout_config));
750        self
751    }
752
753    /// Set the timeout_config for the builder.
754    ///
755    /// Setting this to `None` has no effect if another source of configuration has set timeouts. If you
756    /// are attempting to disable timeouts, use [`TimeoutConfig::disabled`](::aws_smithy_types::timeout::TimeoutConfig::disabled)
757    ///
758    ///
759    /// # Examples
760    ///
761    /// ```no_run
762    /// # use std::time::Duration;
763    /// use aws_sdk_s3::config::{Builder, Config};
764    /// use aws_sdk_s3::config::timeout::TimeoutConfig;
765    ///
766    /// fn set_request_timeout(builder: &mut Builder) {
767    ///     let timeout_config = TimeoutConfig::builder()
768    ///         .operation_attempt_timeout(Duration::from_secs(1))
769    ///         .build();
770    ///     builder.set_timeout_config(Some(timeout_config));
771    /// }
772    ///
773    /// let mut builder = Config::builder();
774    /// set_request_timeout(&mut builder);
775    /// let config = builder.build();
776    /// ```
777    pub fn set_timeout_config(&mut self, timeout_config: ::std::option::Option<::aws_smithy_types::timeout::TimeoutConfig>) -> &mut Self {
778        // passing None has no impact.
779        let Some(mut timeout_config) = timeout_config else { return self };
780
781        if let Some(base) = self.config.load::<::aws_smithy_types::timeout::TimeoutConfig>() {
782            timeout_config.take_defaults_from(base);
783        }
784        self.config.store_put(timeout_config);
785        self
786    }
787    /// Set the partition for retry-related state. When clients share a retry partition, they will
788    /// also share components such as token buckets and client rate limiters.
789    /// See the [`RetryPartition`](::aws_smithy_runtime::client::retries::RetryPartition) documentation for more details.
790    ///
791    /// # Default Behavior
792    ///
793    /// When no retry partition is explicitly set, the SDK automatically creates a default retry partition named `s3`
794    /// (or `s3-<region>` if a region is configured).
795    /// All S3 clients without an explicit retry partition will share this default partition.
796    ///
797    /// # Notes
798    ///
799    /// - This is an advanced setting — most users won't need to modify it.
800    /// - A configured client rate limiter has no effect unless [`RetryConfig::adaptive`](::aws_smithy_types::retry::RetryConfig::adaptive) is used.
801    ///
802    /// # Examples
803    ///
804    /// Creating a custom retry partition with a token bucket:
805    /// ```no_run
806    /// use aws_sdk_s3::config::Config;
807    /// use aws_sdk_s3::config::retry::{RetryPartition, TokenBucket};
808    ///
809    /// let token_bucket = TokenBucket::new(10);
810    /// let config = Config::builder()
811    ///     .retry_partition(RetryPartition::custom("custom")
812    ///         .token_bucket(token_bucket)
813    ///         .build()
814    ///     )
815    ///     .build();
816    /// ```
817    ///
818    /// Configuring a client rate limiter with adaptive retry mode:
819    /// ```no_run
820    /// use aws_sdk_s3::config::Config;
821    /// use aws_sdk_s3::config::retry::{ClientRateLimiter, RetryConfig, RetryPartition};
822    ///
823    /// let client_rate_limiter = ClientRateLimiter::new(10.0);
824    /// let config = Config::builder()
825    ///     .retry_partition(RetryPartition::custom("custom")
826    ///         .client_rate_limiter(client_rate_limiter)
827    ///         .build()
828    ///     )
829    ///     .retry_config(RetryConfig::adaptive())
830    ///     .build();
831    /// ```
832    pub fn retry_partition(mut self, retry_partition: ::aws_smithy_runtime::client::retries::RetryPartition) -> Self {
833        self.set_retry_partition(Some(retry_partition));
834        self
835    }
836    /// Like [`Self::retry_partition`], but takes a mutable reference to the builder and an optional `RetryPartition`
837    pub fn set_retry_partition(
838        &mut self,
839        retry_partition: ::std::option::Option<::aws_smithy_runtime::client::retries::RetryPartition>,
840    ) -> &mut Self {
841        retry_partition.map(|r| self.config.store_put(r));
842        self
843    }
844    /// Set the identity cache for auth.
845    ///
846    /// The identity cache defaults to a lazy caching implementation that will resolve
847    /// an identity when it is requested, and place it in the cache thereafter. Subsequent
848    /// requests will take the value from the cache while it is still valid. Once it expires,
849    /// the next request will result in refreshing the identity.
850    ///
851    /// This configuration allows you to disable or change the default caching mechanism.
852    /// To use a custom caching mechanism, implement the [`ResolveCachedIdentity`](crate::config::ResolveCachedIdentity)
853    /// trait and pass that implementation into this function.
854    ///
855    /// # Examples
856    ///
857    /// Disabling identity caching:
858    /// ```no_run
859    /// use aws_sdk_s3::config::IdentityCache;
860    ///
861    /// let config = aws_sdk_s3::Config::builder()
862    ///     .identity_cache(IdentityCache::no_cache())
863    ///     // ...
864    ///     .build();
865    /// let client = aws_sdk_s3::Client::from_conf(config);
866    /// ```
867    ///
868    /// Customizing lazy caching:
869    /// ```no_run
870    /// use aws_sdk_s3::config::IdentityCache;
871    /// use std::time::Duration;
872    ///
873    /// let config = aws_sdk_s3::Config::builder()
874    ///     .identity_cache(
875    ///         IdentityCache::lazy()
876    ///             // change the load timeout to 10 seconds
877    ///             .load_timeout(Duration::from_secs(10))
878    ///             .build()
879    ///     )
880    ///     // ...
881    ///     .build();
882    /// let client = aws_sdk_s3::Client::from_conf(config);
883    /// ```
884    ///
885    pub fn identity_cache(mut self, identity_cache: impl crate::config::ResolveCachedIdentity + 'static) -> Self {
886        self.set_identity_cache(identity_cache);
887        self
888    }
889
890    /// Set the identity cache for auth.
891    ///
892    /// The identity cache defaults to a lazy caching implementation that will resolve
893    /// an identity when it is requested, and place it in the cache thereafter. Subsequent
894    /// requests will take the value from the cache while it is still valid. Once it expires,
895    /// the next request will result in refreshing the identity.
896    ///
897    /// This configuration allows you to disable or change the default caching mechanism.
898    /// To use a custom caching mechanism, implement the [`ResolveCachedIdentity`](crate::config::ResolveCachedIdentity)
899    /// trait and pass that implementation into this function.
900    ///
901    /// # Examples
902    ///
903    /// Disabling identity caching:
904    /// ```no_run
905    /// use aws_sdk_s3::config::IdentityCache;
906    ///
907    /// let config = aws_sdk_s3::Config::builder()
908    ///     .identity_cache(IdentityCache::no_cache())
909    ///     // ...
910    ///     .build();
911    /// let client = aws_sdk_s3::Client::from_conf(config);
912    /// ```
913    ///
914    /// Customizing lazy caching:
915    /// ```no_run
916    /// use aws_sdk_s3::config::IdentityCache;
917    /// use std::time::Duration;
918    ///
919    /// let config = aws_sdk_s3::Config::builder()
920    ///     .identity_cache(
921    ///         IdentityCache::lazy()
922    ///             // change the load timeout to 10 seconds
923    ///             .load_timeout(Duration::from_secs(10))
924    ///             .build()
925    ///     )
926    ///     // ...
927    ///     .build();
928    /// let client = aws_sdk_s3::Client::from_conf(config);
929    /// ```
930    ///
931    pub fn set_identity_cache(&mut self, identity_cache: impl crate::config::ResolveCachedIdentity + 'static) -> &mut Self {
932        self.runtime_components.set_identity_cache(::std::option::Option::Some(identity_cache));
933        self
934    }
935    /// Add an [interceptor](crate::config::Intercept) that runs at specific stages of the request execution pipeline.
936    ///
937    /// Interceptors targeted at a certain stage are executed according to the pre-defined priority.
938    /// The SDK provides a default set of interceptors. An interceptor configured by this method
939    /// will run after those default interceptors.
940    ///
941    /// # Examples
942    /// ```no_run
943    /// # fn example() {
944    /// use aws_smithy_runtime_api::box_error::BoxError;
945    /// use aws_smithy_runtime_api::client::interceptors::context::BeforeTransmitInterceptorContextMut;
946    /// use aws_smithy_runtime_api::client::interceptors::Intercept;
947    /// use aws_smithy_runtime_api::client::runtime_components::RuntimeComponents;
948    /// use aws_smithy_types::config_bag::ConfigBag;
949    /// use aws_sdk_s3::config::Config;
950    /// use ::http::uri::Uri;
951    ///
952    /// fn base_url() -> String {
953    ///     // ...
954    ///     # String::new()
955    /// }
956    ///
957    /// #[derive(Debug)]
958    /// pub struct UriModifierInterceptor;
959    /// impl Intercept for UriModifierInterceptor {
960    ///     fn name(&self) -> &'static str {
961    ///         "UriModifierInterceptor"
962    ///     }
963    ///     fn modify_before_signing(
964    ///         &self,
965    ///         context: &mut BeforeTransmitInterceptorContextMut<'_>,
966    ///         _runtime_components: &RuntimeComponents,
967    ///         _cfg: &mut ConfigBag,
968    ///     ) -> Result<(), BoxError> {
969    ///         let request = context.request_mut();
970    ///         let uri = format!("{}{}", base_url(), request.uri());
971    ///         *request.uri_mut() = uri.parse::<Uri>()?.into();
972    ///
973    ///         Ok(())
974    ///     }
975    /// }
976    ///
977    /// let config = Config::builder()
978    ///     .interceptor(UriModifierInterceptor)
979    ///     .build();
980    /// # }
981    /// ```
982    pub fn interceptor(mut self, interceptor: impl crate::config::Intercept + 'static) -> Self {
983        self.push_interceptor(crate::config::SharedInterceptor::new(interceptor));
984        self
985    }
986
987    /// Like [`Self::interceptor`], but takes a [`SharedInterceptor`](crate::config::SharedInterceptor).
988    pub fn push_interceptor(&mut self, interceptor: crate::config::SharedInterceptor) -> &mut Self {
989        self.runtime_components.push_interceptor(interceptor);
990        self
991    }
992
993    /// Set [`SharedInterceptor`](crate::config::SharedInterceptor)s for the builder.
994    pub fn set_interceptors(&mut self, interceptors: impl IntoIterator<Item = crate::config::SharedInterceptor>) -> &mut Self {
995        self.runtime_components.set_interceptors(interceptors.into_iter());
996        self
997    }
998    /// Sets the time source used for this service
999    pub fn time_source(mut self, time_source: impl ::aws_smithy_async::time::TimeSource + 'static) -> Self {
1000        self.set_time_source(::std::option::Option::Some(::aws_smithy_runtime_api::shared::IntoShared::into_shared(
1001            time_source,
1002        )));
1003        self
1004    }
1005    /// Sets the time source used for this service
1006    pub fn set_time_source(&mut self, time_source: ::std::option::Option<::aws_smithy_async::time::SharedTimeSource>) -> &mut Self {
1007        self.runtime_components.set_time_source(time_source);
1008        self
1009    }
1010    /// Add type implementing [`ClassifyRetry`](::aws_smithy_runtime_api::client::retries::classifiers::ClassifyRetry) that will be used by the
1011    /// [`RetryStrategy`](::aws_smithy_runtime_api::client::retries::RetryStrategy) to determine what responses should be retried.
1012    ///
1013    /// A retry classifier configured by this method will run according to its [priority](::aws_smithy_runtime_api::client::retries::classifiers::RetryClassifierPriority).
1014    ///
1015    /// # Examples
1016    /// ```no_run
1017    /// # fn example() {
1018    /// use aws_smithy_runtime_api::client::interceptors::context::InterceptorContext;
1019    /// use aws_smithy_runtime_api::client::orchestrator::OrchestratorError;
1020    /// use aws_smithy_runtime_api::client::retries::classifiers::{
1021    ///     ClassifyRetry, RetryAction, RetryClassifierPriority,
1022    /// };
1023    /// use aws_smithy_types::error::metadata::ProvideErrorMetadata;
1024    /// use aws_smithy_types::retry::ErrorKind;
1025    /// use std::error::Error as StdError;
1026    /// use std::marker::PhantomData;
1027    /// use std::fmt;
1028    /// use aws_sdk_s3::config::Config;
1029    /// # #[derive(Debug)]
1030    /// # struct SomeOperationError {}
1031    /// # impl StdError for SomeOperationError {}
1032    /// # impl fmt::Display for SomeOperationError {
1033    /// #    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { todo!() }
1034    /// # }
1035    /// # impl ProvideErrorMetadata for SomeOperationError {
1036    /// #    fn meta(&self) -> &aws_sdk_s3::error::ErrorMetadata { todo!() }
1037    /// # }
1038    ///
1039    /// const RETRYABLE_ERROR_CODES: &[&str] = &[
1040    ///     // List error codes to be retried here...
1041    /// ];
1042    ///
1043    /// // When classifying at an operation's error type, classifiers require a generic parameter.
1044    /// // When classifying the HTTP response alone, no generic is needed.
1045    /// #[derive(Debug, Default)]
1046    /// pub struct ExampleErrorCodeClassifier<E> {
1047    ///     _inner: PhantomData<E>,
1048    /// }
1049    ///
1050    /// impl<E> ExampleErrorCodeClassifier<E> {
1051    ///     pub fn new() -> Self {
1052    ///         Self {
1053    ///             _inner: PhantomData,
1054    ///         }
1055    ///     }
1056    /// }
1057    ///
1058    /// impl<E> ClassifyRetry for ExampleErrorCodeClassifier<E>
1059    /// where
1060    ///     // Adding a trait bound for ProvideErrorMetadata allows us to inspect the error code.
1061    ///     E: StdError + ProvideErrorMetadata + Send + Sync + 'static,
1062    /// {
1063    ///     fn classify_retry(&self, ctx: &InterceptorContext) -> RetryAction {
1064    ///         // Check for a result
1065    ///         let output_or_error = ctx.output_or_error();
1066    ///         // Check for an error
1067    ///         let error = match output_or_error {
1068    ///             Some(Ok(_)) | None => return RetryAction::NoActionIndicated,
1069    ///               Some(Err(err)) => err,
1070    ///         };
1071    ///
1072    ///         // Downcast the generic error and extract the code
1073    ///         let error_code = OrchestratorError::as_operation_error(error)
1074    ///             .and_then(|err| err.downcast_ref::<E>())
1075    ///             .and_then(|err| err.code());
1076    ///
1077    ///         // If this error's code is in our list, return an action that tells the RetryStrategy to retry this request.
1078    ///         if let Some(error_code) = error_code {
1079    ///             if RETRYABLE_ERROR_CODES.contains(&error_code) {
1080    ///                 return RetryAction::transient_error();
1081    ///             }
1082    ///         }
1083    ///
1084    ///         // Otherwise, return that no action is indicated i.e. that this classifier doesn't require a retry.
1085    ///         // Another classifier may still classify this response as retryable.
1086    ///         RetryAction::NoActionIndicated
1087    ///     }
1088    ///
1089    ///     fn name(&self) -> &'static str { "Example Error Code Classifier" }
1090    /// }
1091    ///
1092    /// let config = Config::builder()
1093    ///     .retry_classifier(ExampleErrorCodeClassifier::<SomeOperationError>::new())
1094    ///     .build();
1095    /// # }
1096    /// ```
1097    pub fn retry_classifier(
1098        mut self,
1099        retry_classifier: impl ::aws_smithy_runtime_api::client::retries::classifiers::ClassifyRetry + 'static,
1100    ) -> Self {
1101        self.push_retry_classifier(::aws_smithy_runtime_api::client::retries::classifiers::SharedRetryClassifier::new(
1102            retry_classifier,
1103        ));
1104        self
1105    }
1106
1107    /// Like [`Self::retry_classifier`], but takes a [`SharedRetryClassifier`](::aws_smithy_runtime_api::client::retries::classifiers::SharedRetryClassifier).
1108    pub fn push_retry_classifier(
1109        &mut self,
1110        retry_classifier: ::aws_smithy_runtime_api::client::retries::classifiers::SharedRetryClassifier,
1111    ) -> &mut Self {
1112        self.runtime_components.push_retry_classifier(retry_classifier);
1113        self
1114    }
1115
1116    /// Set [`SharedRetryClassifier`](::aws_smithy_runtime_api::client::retries::classifiers::SharedRetryClassifier)s for the builder, replacing any that
1117    /// were previously set.
1118    pub fn set_retry_classifiers(
1119        &mut self,
1120        retry_classifiers: impl IntoIterator<Item = ::aws_smithy_runtime_api::client::retries::classifiers::SharedRetryClassifier>,
1121    ) -> &mut Self {
1122        self.runtime_components.set_retry_classifiers(retry_classifiers.into_iter());
1123        self
1124    }
1125    /// Sets the name of the app that is using the client.
1126    ///
1127    /// This _optional_ name is used to identify the application in the user agent that
1128    /// gets sent along with requests.
1129    pub fn app_name(mut self, app_name: ::aws_types::app_name::AppName) -> Self {
1130        self.set_app_name(Some(app_name));
1131        self
1132    }
1133    /// Sets the name of the app that is using the client.
1134    ///
1135    /// This _optional_ name is used to identify the application in the user agent that
1136    /// gets sent along with requests.
1137    pub fn set_app_name(&mut self, app_name: ::std::option::Option<::aws_types::app_name::AppName>) -> &mut Self {
1138        self.config.store_or_unset(app_name);
1139        self
1140    }
1141    /// Sets the credentials provider for S3 Express One Zone
1142    pub fn express_credentials_provider(mut self, credentials_provider: impl crate::config::ProvideCredentials + 'static) -> Self {
1143        self.set_express_credentials_provider(::std::option::Option::Some(crate::config::SharedCredentialsProvider::new(
1144            credentials_provider,
1145        )));
1146        self
1147    }
1148    /// Sets the credentials provider for S3 Express One Zone
1149    pub fn set_express_credentials_provider(
1150        &mut self,
1151        credentials_provider: ::std::option::Option<crate::config::SharedCredentialsProvider>,
1152    ) -> &mut Self {
1153        if let ::std::option::Option::Some(credentials_provider) = credentials_provider {
1154            self.runtime_components
1155                .set_identity_resolver(crate::s3_express::auth::SCHEME_ID, credentials_provider);
1156        }
1157        self
1158    }
1159    /// Overrides the default invocation ID generator.
1160    ///
1161    /// 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.
1162    pub fn invocation_id_generator(mut self, gen: impl ::aws_runtime::invocation_id::InvocationIdGenerator + 'static) -> Self {
1163        self.set_invocation_id_generator(::std::option::Option::Some(
1164            ::aws_runtime::invocation_id::SharedInvocationIdGenerator::new(gen),
1165        ));
1166        self
1167    }
1168    /// Overrides the default invocation ID generator.
1169    ///
1170    /// 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.
1171    pub fn set_invocation_id_generator(
1172        &mut self,
1173        gen: ::std::option::Option<::aws_runtime::invocation_id::SharedInvocationIdGenerator>,
1174    ) -> &mut Self {
1175        self.config.store_or_unset(gen);
1176        self
1177    }
1178    /// Sets the endpoint URL used to communicate with this service.
1179    ///
1180    /// Note: this is used in combination with other endpoint rules, e.g. an API that applies a host-label prefix
1181    /// will be prefixed onto this URL. To fully override the endpoint resolver, use
1182    /// [`Builder::endpoint_resolver`].
1183    pub fn endpoint_url(mut self, endpoint_url: impl Into<::std::string::String>) -> Self {
1184        self.set_endpoint_url(Some(endpoint_url.into()));
1185        self
1186    }
1187    /// Sets the endpoint URL used to communicate with this service.
1188    ///
1189    /// Note: this is used in combination with other endpoint rules, e.g. an API that applies a host-label prefix
1190    /// will be prefixed onto this URL. To fully override the endpoint resolver, use
1191    /// [`Builder::endpoint_resolver`].
1192    pub fn set_endpoint_url(&mut self, endpoint_url: Option<::std::string::String>) -> &mut Self {
1193        self.config.store_or_unset(endpoint_url.map(::aws_types::endpoint_config::EndpointUrl));
1194        self
1195    }
1196    /// When true, use the dual-stack endpoint. If the configured endpoint does not support dual-stack, dispatching the request MAY return an error.
1197    pub fn use_dual_stack(mut self, use_dual_stack: impl Into<bool>) -> Self {
1198        self.set_use_dual_stack(Some(use_dual_stack.into()));
1199        self
1200    }
1201    /// When true, use the dual-stack endpoint. If the configured endpoint does not support dual-stack, dispatching the request MAY return an error.
1202    pub fn set_use_dual_stack(&mut self, use_dual_stack: Option<bool>) -> &mut Self {
1203        self.config.store_or_unset(use_dual_stack.map(::aws_types::endpoint_config::UseDualStack));
1204        self
1205    }
1206    /// 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.
1207    pub fn use_fips(mut self, use_fips: impl Into<bool>) -> Self {
1208        self.set_use_fips(Some(use_fips.into()));
1209        self
1210    }
1211    /// 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.
1212    pub fn set_use_fips(&mut self, use_fips: Option<bool>) -> &mut Self {
1213        self.config.store_or_unset(use_fips.map(::aws_types::endpoint_config::UseFips));
1214        self
1215    }
1216    /// Set the [`ResponseChecksumValidation`](crate::config::ResponseChecksumValidation)
1217    /// to determine when checksum validation will be performed on response payloads.
1218    pub fn response_checksum_validation(mut self, response_checksum_validation: crate::config::ResponseChecksumValidation) -> Self {
1219        self.set_response_checksum_validation(::std::option::Option::Some(response_checksum_validation));
1220        self
1221    }
1222    /// Set the [`ResponseChecksumValidation`](crate::config::ResponseChecksumValidation)
1223    /// to determine when checksum validation will be performed on response payloads.
1224    pub fn set_response_checksum_validation(
1225        &mut self,
1226        response_checksum_validation: ::std::option::Option<crate::config::ResponseChecksumValidation>,
1227    ) -> &mut Self {
1228        self.config.store_or_unset(response_checksum_validation);
1229        self
1230    }
1231    /// Set the [`RequestChecksumCalculation`](crate::config::RequestChecksumCalculation)
1232    /// to determine when a checksum will be calculated for request payloads.
1233    pub fn request_checksum_calculation(mut self, request_checksum_calculation: crate::config::RequestChecksumCalculation) -> Self {
1234        self.set_request_checksum_calculation(::std::option::Option::Some(request_checksum_calculation));
1235        self
1236    }
1237    /// Set the [`RequestChecksumCalculation`](crate::config::RequestChecksumCalculation)
1238    /// to determine when a checksum will be calculated for request payloads.
1239    pub fn set_request_checksum_calculation(
1240        &mut self,
1241        request_checksum_calculation: ::std::option::Option<crate::config::RequestChecksumCalculation>,
1242    ) -> &mut Self {
1243        self.config.store_or_unset(request_checksum_calculation);
1244        self
1245    }
1246    /// Sets the AWS region to use when making requests.
1247    ///
1248    /// # Examples
1249    /// ```no_run
1250    /// use aws_types::region::Region;
1251    /// use aws_sdk_s3::config::{Builder, Config};
1252    ///
1253    /// let config = aws_sdk_s3::Config::builder()
1254    ///     .region(Region::new("us-east-1"))
1255    ///     .build();
1256    /// ```
1257    pub fn region(mut self, region: impl ::std::convert::Into<::std::option::Option<crate::config::Region>>) -> Self {
1258        self.set_region(region.into());
1259        self
1260    }
1261    /// Sets the AWS region to use when making requests.
1262    pub fn set_region(&mut self, region: ::std::option::Option<crate::config::Region>) -> &mut Self {
1263        self.config.store_or_unset(region);
1264        self
1265    }
1266    /// Sets the credentials provider for this service
1267    pub fn credentials_provider(mut self, credentials_provider: impl crate::config::ProvideCredentials + 'static) -> Self {
1268        self.set_credentials_provider(::std::option::Option::Some(crate::config::SharedCredentialsProvider::new(
1269            credentials_provider,
1270        )));
1271        self
1272    }
1273    /// Sets the credentials provider for this service
1274    pub fn set_credentials_provider(&mut self, credentials_provider: ::std::option::Option<crate::config::SharedCredentialsProvider>) -> &mut Self {
1275        if let Some(credentials_provider) = credentials_provider {
1276            #[cfg(feature = "sigv4a")]
1277            {
1278                self.runtime_components
1279                    .set_identity_resolver(::aws_runtime::auth::sigv4a::SCHEME_ID, credentials_provider.clone());
1280            }
1281            self.runtime_components
1282                .set_identity_resolver(::aws_runtime::auth::sigv4::SCHEME_ID, credentials_provider);
1283        }
1284        self
1285    }
1286    /// Sets the [`behavior major version`](crate::config::BehaviorVersion).
1287    ///
1288    /// Over time, new best-practice behaviors are introduced. However, these behaviors might not be backwards
1289    /// compatible. For example, a change which introduces new default timeouts or a new retry-mode for
1290    /// all operations might be the ideal behavior but could break existing applications.
1291    ///
1292    /// # Examples
1293    ///
1294    /// Set the behavior major version to `latest`. This is equivalent to enabling the `behavior-version-latest` cargo feature.
1295    /// ```no_run
1296    /// use aws_sdk_s3::config::BehaviorVersion;
1297    ///
1298    /// let config = aws_sdk_s3::Config::builder()
1299    ///     .behavior_version(BehaviorVersion::latest())
1300    ///     // ...
1301    ///     .build();
1302    /// let client = aws_sdk_s3::Client::from_conf(config);
1303    /// ```
1304    ///
1305    /// Customizing behavior major version:
1306    /// ```no_run
1307    /// use aws_sdk_s3::config::BehaviorVersion;
1308    ///
1309    /// let config = aws_sdk_s3::Config::builder()
1310    ///     .behavior_version(BehaviorVersion::v2023_11_09())
1311    ///     // ...
1312    ///     .build();
1313    /// let client = aws_sdk_s3::Client::from_conf(config);
1314    /// ```
1315    ///
1316    pub fn behavior_version(mut self, behavior_version: crate::config::BehaviorVersion) -> Self {
1317        self.set_behavior_version(Some(behavior_version));
1318        self
1319    }
1320
1321    /// Sets the [`behavior major version`](crate::config::BehaviorVersion).
1322    ///
1323    /// Over time, new best-practice behaviors are introduced. However, these behaviors might not be backwards
1324    /// compatible. For example, a change which introduces new default timeouts or a new retry-mode for
1325    /// all operations might be the ideal behavior but could break existing applications.
1326    ///
1327    /// # Examples
1328    ///
1329    /// Set the behavior major version to `latest`. This is equivalent to enabling the `behavior-version-latest` cargo feature.
1330    /// ```no_run
1331    /// use aws_sdk_s3::config::BehaviorVersion;
1332    ///
1333    /// let config = aws_sdk_s3::Config::builder()
1334    ///     .behavior_version(BehaviorVersion::latest())
1335    ///     // ...
1336    ///     .build();
1337    /// let client = aws_sdk_s3::Client::from_conf(config);
1338    /// ```
1339    ///
1340    /// Customizing behavior major version:
1341    /// ```no_run
1342    /// use aws_sdk_s3::config::BehaviorVersion;
1343    ///
1344    /// let config = aws_sdk_s3::Config::builder()
1345    ///     .behavior_version(BehaviorVersion::v2023_11_09())
1346    ///     // ...
1347    ///     .build();
1348    /// let client = aws_sdk_s3::Client::from_conf(config);
1349    /// ```
1350    ///
1351    pub fn set_behavior_version(&mut self, behavior_version: Option<crate::config::BehaviorVersion>) -> &mut Self {
1352        self.behavior_version = behavior_version;
1353        self
1354    }
1355
1356    /// Convenience method to set the latest behavior major version
1357    ///
1358    /// This is equivalent to enabling the `behavior-version-latest` Cargo feature
1359    pub fn behavior_version_latest(mut self) -> Self {
1360        self.set_behavior_version(Some(crate::config::BehaviorVersion::latest()));
1361        self
1362    }
1363    /// Adds a runtime plugin to the config.
1364    #[allow(unused)]
1365    pub(crate) fn runtime_plugin(mut self, plugin: impl crate::config::RuntimePlugin + 'static) -> Self {
1366        self.push_runtime_plugin(crate::config::SharedRuntimePlugin::new(plugin));
1367        self
1368    }
1369    /// Adds a runtime plugin to the config.
1370    #[allow(unused)]
1371    pub(crate) fn push_runtime_plugin(&mut self, plugin: crate::config::SharedRuntimePlugin) -> &mut Self {
1372        self.runtime_plugins.push(plugin);
1373        self
1374    }
1375    #[cfg(any(feature = "test-util", test))]
1376    #[allow(unused_mut)]
1377    /// Apply test defaults to the builder. NOTE: Consider migrating to use `apply_test_defaults_v2` instead.
1378    pub fn apply_test_defaults(&mut self) -> &mut Self {
1379        self.set_idempotency_token_provider(Some("00000000-0000-4000-8000-000000000000".into()));
1380
1381        self.set_time_source(::std::option::Option::Some(::aws_smithy_async::time::SharedTimeSource::new(
1382            ::aws_smithy_async::time::StaticTimeSource::new(::std::time::UNIX_EPOCH + ::std::time::Duration::from_secs(1234567890)),
1383        )));
1384        self.config.store_put(::aws_runtime::user_agent::AwsUserAgent::for_tests());
1385        self.set_credentials_provider(Some(crate::config::SharedCredentialsProvider::new(
1386            ::aws_credential_types::Credentials::for_tests(),
1387        )));
1388        self.behavior_version = ::std::option::Option::Some(crate::config::BehaviorVersion::latest());
1389        self
1390    }
1391    #[cfg(any(feature = "test-util", test))]
1392    #[allow(unused_mut)]
1393    /// Apply test defaults to the builder. NOTE: Consider migrating to use `with_test_defaults_v2` instead.
1394    pub fn with_test_defaults(mut self) -> Self {
1395        self.apply_test_defaults();
1396        self
1397    }
1398    #[cfg(any(feature = "test-util", test))]
1399    #[allow(unused_mut)]
1400    /// Apply test defaults to the builder. V2 of this function sets additional test defaults such as region configuration (if applicable).
1401    pub fn apply_test_defaults_v2(&mut self) -> &mut Self {
1402        self.apply_test_defaults();
1403
1404        if self.config.load::<crate::config::Region>().is_none() {
1405            self.set_region(::std::option::Option::Some(crate::config::Region::new("us-east-1")));
1406        }
1407        self
1408    }
1409    #[cfg(any(feature = "test-util", test))]
1410    #[allow(unused_mut)]
1411    /// Apply test defaults to the builder. V2 of this function sets additional test defaults such as region configuration (if applicable).
1412    pub fn with_test_defaults_v2(mut self) -> Self {
1413        self.apply_test_defaults_v2();
1414        self
1415    }
1416    /// Builds a [`Config`].
1417    #[allow(unused_mut)]
1418    pub fn build(mut self) -> Config {
1419        let mut layer = self.config;
1420
1421        if self.runtime_components.time_source().is_none() {
1422            self.runtime_components
1423                .set_time_source(::std::option::Option::Some(::std::default::Default::default()));
1424        }
1425        layer.store_put(crate::meta::API_METADATA.clone());
1426        layer.store_put(::aws_types::SigningName::from_static("s3"));
1427        layer
1428            .load::<::aws_types::region::Region>()
1429            .cloned()
1430            .map(|r| layer.store_put(::aws_types::region::SigningRegion::from(r)));
1431        Config {
1432            config: crate::config::Layer::from(layer.clone()).with_name("aws_sdk_s3::config::Config").freeze(),
1433            cloneable: layer,
1434            runtime_components: self.runtime_components,
1435            runtime_plugins: self.runtime_plugins,
1436            behavior_version: self.behavior_version,
1437        }
1438    }
1439}
1440#[derive(::std::fmt::Debug)]
1441pub(crate) struct ServiceRuntimePlugin {
1442    config: ::std::option::Option<::aws_smithy_types::config_bag::FrozenLayer>,
1443    runtime_components: ::aws_smithy_runtime_api::client::runtime_components::RuntimeComponentsBuilder,
1444}
1445
1446impl ServiceRuntimePlugin {
1447    pub fn new(_service_config: crate::config::Config) -> Self {
1448        let config = {
1449            let mut cfg = ::aws_smithy_types::config_bag::Layer::new("AmazonS3");
1450            cfg.store_put(crate::idempotency_token::default_provider());
1451            cfg.store_put(::aws_smithy_runtime::client::orchestrator::AuthSchemeAndEndpointOrchestrationV2);
1452            ::std::option::Option::Some(cfg.freeze())
1453        };
1454        let mut runtime_components = ::aws_smithy_runtime_api::client::runtime_components::RuntimeComponentsBuilder::new("ServiceRuntimePlugin");
1455        runtime_components.set_auth_scheme_option_resolver(::std::option::Option::Some({
1456            use crate::config::auth::ResolveAuthScheme;
1457            crate::config::auth::DefaultAuthSchemeResolver::default().into_shared_resolver()
1458        }));
1459        runtime_components.set_endpoint_resolver(::std::option::Option::Some({
1460            use crate::config::endpoint::ResolveEndpoint;
1461            crate::config::endpoint::DefaultResolver::new().into_shared_resolver()
1462        }));
1463        runtime_components.push_interceptor(::aws_smithy_runtime::client::http::connection_poisoning::ConnectionPoisoningInterceptor::new());
1464        runtime_components.push_retry_classifier(::aws_smithy_runtime::client::retries::classifiers::HttpStatusCodeClassifier::default());
1465        runtime_components.push_interceptor(crate::sdk_feature_tracker::retry_mode::RetryModeFeatureTrackerInterceptor::new());
1466        runtime_components.push_interceptor(::aws_runtime::service_clock_skew::ServiceClockSkewInterceptor::new());
1467        runtime_components.push_interceptor(::aws_runtime::request_info::RequestInfoInterceptor::new());
1468        runtime_components.push_interceptor(::aws_runtime::user_agent::UserAgentInterceptor::new());
1469        runtime_components.push_auth_scheme(::aws_smithy_runtime_api::client::auth::SharedAuthScheme::new(
1470            crate::s3_express::auth::S3ExpressAuthScheme::new(),
1471        ));
1472        runtime_components.push_interceptor(::aws_runtime::invocation_id::InvocationIdInterceptor::new());
1473        runtime_components.push_interceptor(::aws_runtime::recursion_detection::RecursionDetectionInterceptor::new());
1474        runtime_components.push_auth_scheme(::aws_smithy_runtime_api::client::auth::SharedAuthScheme::new(
1475            ::aws_runtime::auth::sigv4::SigV4AuthScheme::new(),
1476        ));
1477        #[cfg(feature = "sigv4a")]
1478        {
1479            runtime_components.push_auth_scheme(::aws_smithy_runtime_api::client::auth::SharedAuthScheme::new(
1480                ::aws_runtime::auth::sigv4a::SigV4aAuthScheme::new(),
1481            ));
1482        }
1483        runtime_components.push_interceptor(crate::config::endpoint::EndpointOverrideFeatureTrackerInterceptor);
1484        runtime_components.push_interceptor(crate::observability_feature::ObservabilityFeatureTrackerInterceptor);
1485        Self { config, runtime_components }
1486    }
1487}
1488
1489impl ::aws_smithy_runtime_api::client::runtime_plugin::RuntimePlugin for ServiceRuntimePlugin {
1490    fn config(&self) -> ::std::option::Option<::aws_smithy_types::config_bag::FrozenLayer> {
1491        self.config.clone()
1492    }
1493
1494    fn order(&self) -> ::aws_smithy_runtime_api::client::runtime_plugin::Order {
1495        ::aws_smithy_runtime_api::client::runtime_plugin::Order::Defaults
1496    }
1497
1498    fn runtime_components(
1499        &self,
1500        _: &::aws_smithy_runtime_api::client::runtime_components::RuntimeComponentsBuilder,
1501    ) -> ::std::borrow::Cow<'_, ::aws_smithy_runtime_api::client::runtime_components::RuntimeComponentsBuilder> {
1502        ::std::borrow::Cow::Borrowed(&self.runtime_components)
1503    }
1504}
1505
1506// Cross-operation shared-state singletons
1507
1508/// A plugin that enables configuration for a single operation invocation
1509///
1510/// The `config` method will return a `FrozenLayer` by storing values from `config_override`.
1511/// In the case of default values requested, they will be obtained from `client_config`.
1512#[derive(Debug)]
1513pub(crate) struct ConfigOverrideRuntimePlugin {
1514    pub(crate) config: ::aws_smithy_types::config_bag::FrozenLayer,
1515    pub(crate) components: ::aws_smithy_runtime_api::client::runtime_components::RuntimeComponentsBuilder,
1516}
1517
1518impl ConfigOverrideRuntimePlugin {
1519    #[allow(dead_code)] // unused when a service does not provide any operations
1520    pub(crate) fn new(
1521        config_override: Builder,
1522        initial_config: ::aws_smithy_types::config_bag::FrozenLayer,
1523        initial_components: &::aws_smithy_runtime_api::client::runtime_components::RuntimeComponentsBuilder,
1524    ) -> Self {
1525        let mut layer = config_override.config;
1526        let mut components = config_override.runtime_components;
1527        #[allow(unused_mut)]
1528        let mut resolver =
1529            ::aws_smithy_runtime::client::config_override::Resolver::overrid(initial_config, initial_components, &mut layer, &mut components);
1530
1531        resolver
1532            .config_mut()
1533            .load::<::aws_types::region::Region>()
1534            .cloned()
1535            .map(|r| resolver.config_mut().store_put(::aws_types::region::SigningRegion::from(r)));
1536
1537        let _ = resolver;
1538        Self {
1539            config: ::aws_smithy_types::config_bag::Layer::from(layer)
1540                .with_name("aws_sdk_s3::config::ConfigOverrideRuntimePlugin")
1541                .freeze(),
1542            components,
1543        }
1544    }
1545}
1546
1547impl ::aws_smithy_runtime_api::client::runtime_plugin::RuntimePlugin for ConfigOverrideRuntimePlugin {
1548    fn config(&self) -> ::std::option::Option<::aws_smithy_types::config_bag::FrozenLayer> {
1549        Some(self.config.clone())
1550    }
1551
1552    fn runtime_components(
1553        &self,
1554        _: &::aws_smithy_runtime_api::client::runtime_components::RuntimeComponentsBuilder,
1555    ) -> ::std::borrow::Cow<'_, ::aws_smithy_runtime_api::client::runtime_components::RuntimeComponentsBuilder> {
1556        ::std::borrow::Cow::Borrowed(&self.components)
1557    }
1558}
1559
1560pub use ::aws_smithy_runtime::client::identity::IdentityCache;
1561pub use ::aws_smithy_runtime_api::client::runtime_components::RuntimeComponents;
1562pub use ::aws_smithy_types::config_bag::ConfigBag;
1563
1564pub use ::aws_credential_types::Credentials;
1565
1566impl From<&::aws_types::sdk_config::SdkConfig> for Builder {
1567    fn from(input: &::aws_types::sdk_config::SdkConfig) -> Self {
1568        let mut builder = Builder::default();
1569        builder.set_credentials_provider(input.credentials_provider());
1570        builder = builder.region(input.region().cloned());
1571        builder.set_request_checksum_calculation(input.request_checksum_calculation());
1572        builder.set_response_checksum_validation(input.response_checksum_validation());
1573        builder.set_use_fips(input.use_fips());
1574        builder.set_use_dual_stack(input.use_dual_stack());
1575        if input.get_origin("endpoint_url").is_client_config() {
1576            builder.set_endpoint_url(input.endpoint_url().map(|s| s.to_string()));
1577        } else {
1578            builder.set_endpoint_url(
1579                input
1580                    .service_config()
1581                    .and_then(|conf| {
1582                        conf.load_config(service_config_key("S3", "AWS_ENDPOINT_URL", "endpoint_url"))
1583                            .map(|it| it.parse().unwrap())
1584                    })
1585                    .or_else(|| input.endpoint_url().map(|s| s.to_string())),
1586            );
1587        }
1588        // resiliency
1589        builder.set_retry_config(input.retry_config().cloned());
1590        builder.set_timeout_config(input.timeout_config().cloned());
1591        builder.set_sleep_impl(input.sleep_impl());
1592
1593        builder.set_http_client(input.http_client());
1594        builder.set_time_source(input.time_source());
1595        builder.set_behavior_version(input.behavior_version());
1596        builder.set_auth_scheme_preference(input.auth_scheme_preference().cloned());
1597        // setting `None` here removes the default
1598        if let Some(config) = input.stalled_stream_protection() {
1599            builder.set_stalled_stream_protection(Some(config));
1600        }
1601
1602        if let Some(cache) = input.identity_cache() {
1603            builder.set_identity_cache(cache);
1604        }
1605        builder.set_disable_s3_express_session_auth(input.service_config().and_then(|conf| {
1606            let str_config = conf.load_config(service_config_key(
1607                "S3",
1608                "AWS_S3_DISABLE_EXPRESS_SESSION_AUTH",
1609                "s3_disable_express_session_auth",
1610            ));
1611            str_config.and_then(|it| it.parse::<bool>().ok())
1612        }));
1613        builder.set_app_name(input.app_name().cloned());
1614
1615        builder
1616    }
1617}
1618
1619impl From<&::aws_types::sdk_config::SdkConfig> for Config {
1620    fn from(sdk_config: &::aws_types::sdk_config::SdkConfig) -> Self {
1621        Builder::from(sdk_config).build()
1622    }
1623}
1624
1625pub use ::aws_types::app_name::AppName;
1626
1627#[allow(dead_code)]
1628fn service_config_key<'a>(service_id: &'a str, env: &'a str, profile: &'a str) -> aws_types::service_config::ServiceConfigKey<'a> {
1629    ::aws_types::service_config::ServiceConfigKey::builder()
1630        .service_id(service_id)
1631        .env(env)
1632        .profile(profile)
1633        .build()
1634        .expect("all field sets explicitly, can't fail")
1635}
1636
1637pub use ::aws_smithy_async::rt::sleep::Sleep;
1638
1639pub(crate) fn base_client_runtime_plugins(mut config: crate::Config) -> ::aws_smithy_runtime_api::client::runtime_plugin::RuntimePlugins {
1640    let mut configured_plugins = ::std::vec::Vec::new();
1641    ::std::mem::swap(&mut config.runtime_plugins, &mut configured_plugins);
1642    #[cfg(feature = "behavior-version-latest")]
1643    {
1644        if config.behavior_version.is_none() {
1645            config.behavior_version = Some(::aws_smithy_runtime_api::client::behavior_version::BehaviorVersion::latest());
1646        }
1647    }
1648
1649    let default_retry_partition = "s3";
1650    let default_retry_partition = match config.region() {
1651        Some(region) => ::std::borrow::Cow::from(format!("{default_retry_partition}-{region}")),
1652        None => ::std::borrow::Cow::from(default_retry_partition),
1653    };
1654
1655    let scope = "aws-sdk-s3";
1656
1657    #[allow(deprecated)]
1658                    let mut plugins = ::aws_smithy_runtime_api::client::runtime_plugin::RuntimePlugins::new()
1659                        // defaults
1660                        .with_client_plugins(::aws_smithy_runtime::client::defaults::default_plugins(
1661                            ::aws_smithy_runtime::client::defaults::DefaultPluginParams::new()
1662                                .with_retry_partition_name(default_retry_partition)
1663                                .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."))
1664                                .with_is_aws_sdk(true)
1665                        ))
1666                        // user config
1667                        .with_client_plugin(
1668                            ::aws_smithy_runtime_api::client::runtime_plugin::StaticRuntimePlugin::new()
1669                                .with_config(config.config.clone())
1670                                .with_runtime_components(config.runtime_components.clone())
1671                        )
1672                        // codegen config
1673                        .with_client_plugin(crate::config::ServiceRuntimePlugin::new(config.clone()))
1674                        .with_client_plugin(::aws_smithy_runtime::client::auth::no_auth::NoAuthRuntimePlugin::new())
1675                        .with_client_plugin(
1676                            ::aws_smithy_runtime::client::metrics::MetricsRuntimePlugin::builder()
1677                                .with_scope(scope)
1678                                .with_time_source(config.runtime_components.time_source().unwrap_or_default())
1679                                .build()
1680                                .expect("All required fields have been set")
1681                        );
1682
1683    plugins = plugins.with_client_plugin(crate::s3_express::runtime_plugin::S3ExpressRuntimePlugin::new(config.clone()));
1684
1685    for plugin in configured_plugins {
1686        plugins = plugins.with_client_plugin(plugin);
1687    }
1688    plugins
1689}
1690
1691pub use ::aws_smithy_types::config_bag::FrozenLayer;
1692
1693pub use ::aws_smithy_runtime_api::client::runtime_components::RuntimeComponentsBuilder;
1694
1695pub use ::aws_smithy_runtime_api::client::runtime_plugin::SharedRuntimePlugin;
1696
1697pub use ::aws_smithy_runtime_api::client::behavior_version::BehaviorVersion;
1698
1699pub use ::aws_smithy_runtime_api::client::stalled_stream_protection::StalledStreamProtectionConfig;
1700
1701pub use ::aws_smithy_runtime_api::client::http::SharedHttpClient;
1702
1703pub use ::aws_smithy_async::rt::sleep::SharedAsyncSleep;
1704
1705pub use ::aws_smithy_runtime_api::client::identity::SharedIdentityCache;
1706
1707pub use ::aws_smithy_runtime_api::client::interceptors::SharedInterceptor;
1708
1709pub use ::aws_smithy_types::checksum_config::ResponseChecksumValidation;
1710
1711pub use ::aws_smithy_types::checksum_config::RequestChecksumCalculation;
1712
1713pub use ::aws_types::region::Region;
1714
1715pub use ::aws_credential_types::provider::SharedCredentialsProvider;
1716
1717#[derive(Debug, Clone)]
1718pub(crate) struct ForcePathStyle(pub(crate) bool);
1719impl ::aws_smithy_types::config_bag::Storable for ForcePathStyle {
1720    type Storer = ::aws_smithy_types::config_bag::StoreReplace<Self>;
1721}
1722
1723#[derive(Debug, Clone)]
1724pub(crate) struct UseArnRegion(pub(crate) bool);
1725impl ::aws_smithy_types::config_bag::Storable for UseArnRegion {
1726    type Storer = ::aws_smithy_types::config_bag::StoreReplace<Self>;
1727}
1728
1729#[derive(Debug, Clone)]
1730pub(crate) struct DisableMultiRegionAccessPoints(pub(crate) bool);
1731impl ::aws_smithy_types::config_bag::Storable for DisableMultiRegionAccessPoints {
1732    type Storer = ::aws_smithy_types::config_bag::StoreReplace<Self>;
1733}
1734
1735#[derive(Debug, Clone)]
1736pub(crate) struct Accelerate(pub(crate) bool);
1737impl ::aws_smithy_types::config_bag::Storable for Accelerate {
1738    type Storer = ::aws_smithy_types::config_bag::StoreReplace<Self>;
1739}
1740
1741#[derive(Debug, Clone)]
1742pub(crate) struct DisableS3ExpressSessionAuth(pub(crate) bool);
1743impl ::aws_smithy_types::config_bag::Storable for DisableS3ExpressSessionAuth {
1744    type Storer = ::aws_smithy_types::config_bag::StoreReplace<Self>;
1745}
1746
1747pub use ::aws_smithy_runtime_api::client::http::HttpClient;
1748
1749pub use ::aws_smithy_runtime_api::shared::IntoShared;
1750
1751pub use ::aws_smithy_async::rt::sleep::AsyncSleep;
1752
1753pub use ::aws_smithy_runtime_api::client::identity::ResolveCachedIdentity;
1754
1755pub use ::aws_smithy_runtime_api::client::interceptors::Intercept;
1756
1757pub use ::aws_credential_types::provider::ProvideCredentials;
1758
1759pub use ::aws_smithy_runtime_api::client::runtime_plugin::RuntimePlugin;
1760
1761pub use ::aws_smithy_types::config_bag::Layer;
1762
1763/// Types needed to configure endpoint resolution.
1764pub mod endpoint;
1765
1766/// HTTP request and response types.
1767pub mod http;
1768
1769/// Types needed to implement [`Intercept`](crate::config::Intercept).
1770pub mod interceptors;
1771
1772/// Retry configuration.
1773pub mod retry;
1774
1775/// Timeout configuration.
1776pub mod timeout;
1777
1778/// Types needed to configure auth scheme resolution.
1779pub mod auth;