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