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