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    ///
1053    /// fn base_url() -> String {
1054    ///     // ...
1055    ///     # String::new()
1056    /// }
1057    ///
1058    /// #[derive(Debug)]
1059    /// pub struct UriModifierInterceptor;
1060    /// impl Intercept for UriModifierInterceptor {
1061    ///     fn name(&self) -> &'static str {
1062    ///         "UriModifierInterceptor"
1063    ///     }
1064    ///     fn modify_before_signing(
1065    ///         &self,
1066    ///         context: &mut BeforeTransmitInterceptorContextMut<'_>,
1067    ///         _runtime_components: &RuntimeComponents,
1068    ///         _cfg: &mut ConfigBag,
1069    ///     ) -> Result<(), BoxError> {
1070    ///         let request = context.request_mut();
1071    ///         let uri = format!("{}{}", base_url(), request.uri());
1072    ///         request.set_uri(uri)?;
1073    ///
1074    ///         Ok(())
1075    ///     }
1076    /// }
1077    ///
1078    /// let config = Config::builder()
1079    ///     .interceptor(UriModifierInterceptor)
1080    ///     .build();
1081    /// # }
1082    /// ```
1083    pub fn interceptor(mut self, interceptor: impl crate::config::Intercept + 'static) -> Self {
1084        self.push_interceptor(crate::config::SharedInterceptor::new(interceptor));
1085        self
1086    }
1087
1088    /// Like [`Self::interceptor`], but takes a [`SharedInterceptor`](crate::config::SharedInterceptor).
1089    pub fn push_interceptor(&mut self, interceptor: crate::config::SharedInterceptor) -> &mut Self {
1090        self.runtime_components.push_interceptor(interceptor);
1091        self
1092    }
1093
1094    /// Set [`SharedInterceptor`](crate::config::SharedInterceptor)s for the builder.
1095    pub fn set_interceptors(&mut self, interceptors: impl IntoIterator<Item = crate::config::SharedInterceptor>) -> &mut Self {
1096        self.runtime_components.set_interceptors(interceptors.into_iter());
1097        self
1098    }
1099    /// Sets the time source used for this service
1100    pub fn time_source(mut self, time_source: impl ::aws_smithy_async::time::TimeSource + 'static) -> Self {
1101        self.set_time_source(::std::option::Option::Some(::aws_smithy_runtime_api::shared::IntoShared::into_shared(
1102            time_source,
1103        )));
1104        self
1105    }
1106    /// Sets the time source used for this service
1107    pub fn set_time_source(&mut self, time_source: ::std::option::Option<::aws_smithy_async::time::SharedTimeSource>) -> &mut Self {
1108        self.runtime_components.set_time_source(time_source);
1109        self
1110    }
1111    /// Add type implementing [`ClassifyRetry`](::aws_smithy_runtime_api::client::retries::classifiers::ClassifyRetry) that will be used by the
1112    /// [`RetryStrategy`](::aws_smithy_runtime_api::client::retries::RetryStrategy) to determine what responses should be retried.
1113    ///
1114    /// A retry classifier configured by this method will run according to its [priority](::aws_smithy_runtime_api::client::retries::classifiers::RetryClassifierPriority).
1115    ///
1116    /// # Examples
1117    /// ```no_run
1118    /// # fn example() {
1119    /// use aws_smithy_runtime_api::client::interceptors::context::InterceptorContext;
1120    /// use aws_smithy_runtime_api::client::orchestrator::OrchestratorError;
1121    /// use aws_smithy_runtime_api::client::retries::classifiers::{
1122    ///     ClassifyRetry, RetryAction, RetryClassifierPriority,
1123    /// };
1124    /// use aws_smithy_types::error::metadata::ProvideErrorMetadata;
1125    /// use aws_smithy_types::retry::ErrorKind;
1126    /// use std::error::Error as StdError;
1127    /// use std::marker::PhantomData;
1128    /// use std::fmt;
1129    /// use aws_sdk_s3::config::Config;
1130    /// # #[derive(Debug)]
1131    /// # struct SomeOperationError {}
1132    /// # impl StdError for SomeOperationError {}
1133    /// # impl fmt::Display for SomeOperationError {
1134    /// #    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { todo!() }
1135    /// # }
1136    /// # impl ProvideErrorMetadata for SomeOperationError {
1137    /// #    fn meta(&self) -> &aws_sdk_s3::error::ErrorMetadata { todo!() }
1138    /// # }
1139    ///
1140    /// const RETRYABLE_ERROR_CODES: &[&str] = &[
1141    ///     // List error codes to be retried here...
1142    /// ];
1143    ///
1144    /// // When classifying at an operation's error type, classifiers require a generic parameter.
1145    /// // When classifying the HTTP response alone, no generic is needed.
1146    /// #[derive(Debug, Default)]
1147    /// pub struct ExampleErrorCodeClassifier<E> {
1148    ///     _inner: PhantomData<E>,
1149    /// }
1150    ///
1151    /// impl<E> ExampleErrorCodeClassifier<E> {
1152    ///     pub fn new() -> Self {
1153    ///         Self {
1154    ///             _inner: PhantomData,
1155    ///         }
1156    ///     }
1157    /// }
1158    ///
1159    /// impl<E> ClassifyRetry for ExampleErrorCodeClassifier<E>
1160    /// where
1161    ///     // Adding a trait bound for ProvideErrorMetadata allows us to inspect the error code.
1162    ///     E: StdError + ProvideErrorMetadata + Send + Sync + 'static,
1163    /// {
1164    ///     fn classify_retry(&self, ctx: &InterceptorContext) -> RetryAction {
1165    ///         // Check for a result
1166    ///         let output_or_error = ctx.output_or_error();
1167    ///         // Check for an error
1168    ///         let error = match output_or_error {
1169    ///             Some(Ok(_)) | None => return RetryAction::NoActionIndicated,
1170    ///               Some(Err(err)) => err,
1171    ///         };
1172    ///
1173    ///         // Downcast the generic error and extract the code
1174    ///         let error_code = OrchestratorError::as_operation_error(error)
1175    ///             .and_then(|err| err.downcast_ref::<E>())
1176    ///             .and_then(|err| err.code());
1177    ///
1178    ///         // If this error's code is in our list, return an action that tells the RetryStrategy to retry this request.
1179    ///         if let Some(error_code) = error_code {
1180    ///             if RETRYABLE_ERROR_CODES.contains(&error_code) {
1181    ///                 return RetryAction::transient_error();
1182    ///             }
1183    ///         }
1184    ///
1185    ///         // Otherwise, return that no action is indicated i.e. that this classifier doesn't require a retry.
1186    ///         // Another classifier may still classify this response as retryable.
1187    ///         RetryAction::NoActionIndicated
1188    ///     }
1189    ///
1190    ///     fn name(&self) -> &'static str { "Example Error Code Classifier" }
1191    /// }
1192    ///
1193    /// let config = Config::builder()
1194    ///     .retry_classifier(ExampleErrorCodeClassifier::<SomeOperationError>::new())
1195    ///     .build();
1196    /// # }
1197    /// ```
1198    pub fn retry_classifier(
1199        mut self,
1200        retry_classifier: impl ::aws_smithy_runtime_api::client::retries::classifiers::ClassifyRetry + 'static,
1201    ) -> Self {
1202        self.push_retry_classifier(::aws_smithy_runtime_api::client::retries::classifiers::SharedRetryClassifier::new(
1203            retry_classifier,
1204        ));
1205        self
1206    }
1207
1208    /// Like [`Self::retry_classifier`], but takes a [`SharedRetryClassifier`](::aws_smithy_runtime_api::client::retries::classifiers::SharedRetryClassifier).
1209    pub fn push_retry_classifier(
1210        &mut self,
1211        retry_classifier: ::aws_smithy_runtime_api::client::retries::classifiers::SharedRetryClassifier,
1212    ) -> &mut Self {
1213        self.runtime_components.push_retry_classifier(retry_classifier);
1214        self
1215    }
1216
1217    /// Set [`SharedRetryClassifier`](::aws_smithy_runtime_api::client::retries::classifiers::SharedRetryClassifier)s for the builder, replacing any that
1218    /// were previously set.
1219    pub fn set_retry_classifiers(
1220        &mut self,
1221        retry_classifiers: impl IntoIterator<Item = ::aws_smithy_runtime_api::client::retries::classifiers::SharedRetryClassifier>,
1222    ) -> &mut Self {
1223        self.runtime_components.set_retry_classifiers(retry_classifiers.into_iter());
1224        self
1225    }
1226    /// Sets the name of the app that is using the client.
1227    ///
1228    /// This _optional_ name is used to identify the application in the user agent that
1229    /// gets sent along with requests.
1230    pub fn app_name(mut self, app_name: ::aws_types::app_name::AppName) -> Self {
1231        self.set_app_name(Some(app_name));
1232        self
1233    }
1234    /// Sets the name of the app that is using the client.
1235    ///
1236    /// This _optional_ name is used to identify the application in the user agent that
1237    /// gets sent along with requests.
1238    pub fn set_app_name(&mut self, app_name: ::std::option::Option<::aws_types::app_name::AppName>) -> &mut Self {
1239        self.config.store_or_unset(app_name);
1240        self
1241    }
1242    /// Appends framework metadata to the user agent.
1243    ///
1244    /// This _optional_ metadata identifies a software framework or third-party library
1245    /// that is being used with the client. It is rendered into the user agent string
1246    /// (as `lib/{name}/{version}`) so that libraries built on top of the AWS SDK can
1247    /// self-identify in the requests they make. Multiple entries may be added; each call
1248    /// appends another entry rather than replacing previous ones.
1249    ///
1250    /// Entries are de-duplicated on `(name, version)`, rendered in first-seen order, and
1251    /// the total number of unique entries included in the user agent is capped (currently
1252    /// at 10); additional entries beyond the cap are dropped with a warning.
1253    pub fn framework_metadata(mut self, framework_metadata: ::aws_types::sdk_ua_metadata::FrameworkMetadata) -> Self {
1254        self.push_framework_metadata(framework_metadata);
1255        self
1256    }
1257    /// Appends framework metadata to the user agent.
1258    ///
1259    /// This _optional_ metadata identifies a software framework or third-party library
1260    /// that is being used with the client. It is rendered into the user agent string
1261    /// (as `lib/{name}/{version}`) so that libraries built on top of the AWS SDK can
1262    /// self-identify in the requests they make. Multiple entries may be added; each call
1263    /// appends another entry rather than replacing previous ones.
1264    pub fn push_framework_metadata(&mut self, framework_metadata: ::aws_types::sdk_ua_metadata::FrameworkMetadata) -> &mut Self {
1265        self.config.store_append(framework_metadata);
1266        self
1267    }
1268    /// Sets the credentials provider for S3 Express One Zone
1269    pub fn express_credentials_provider(mut self, credentials_provider: impl crate::config::ProvideCredentials + 'static) -> Self {
1270        self.set_express_credentials_provider(::std::option::Option::Some(crate::config::SharedCredentialsProvider::new(
1271            credentials_provider,
1272        )));
1273        self
1274    }
1275    /// Sets the credentials provider for S3 Express One Zone
1276    pub fn set_express_credentials_provider(
1277        &mut self,
1278        credentials_provider: ::std::option::Option<crate::config::SharedCredentialsProvider>,
1279    ) -> &mut Self {
1280        if let ::std::option::Option::Some(credentials_provider) = credentials_provider {
1281            self.runtime_components
1282                .set_identity_resolver(crate::s3_express::auth::SCHEME_ID, credentials_provider);
1283        }
1284        self
1285    }
1286    /// Sets whether clock skew correction is disabled when making requests.
1287    pub fn disable_clock_skew_correction(mut self, disable_clock_skew_correction: impl ::std::convert::Into<::std::option::Option<bool>>) -> Self {
1288        self.set_disable_clock_skew_correction(disable_clock_skew_correction.into());
1289        self
1290    }
1291
1292    /// Sets whether clock skew correction is disabled when making requests.
1293    pub fn set_disable_clock_skew_correction(&mut self, disable_clock_skew_correction: ::std::option::Option<bool>) -> &mut Self {
1294        self.config
1295            .store_or_unset::<::aws_runtime::service_clock_skew::DisableClockSkewCorrection>(disable_clock_skew_correction.map(Into::into));
1296        self
1297    }
1298    /// Overrides the default invocation ID generator.
1299    ///
1300    /// 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.
1301    pub fn invocation_id_generator(mut self, gen: impl ::aws_runtime::invocation_id::InvocationIdGenerator + 'static) -> Self {
1302        self.set_invocation_id_generator(::std::option::Option::Some(
1303            ::aws_runtime::invocation_id::SharedInvocationIdGenerator::new(gen),
1304        ));
1305        self
1306    }
1307    /// Overrides the default invocation ID generator.
1308    ///
1309    /// 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.
1310    pub fn set_invocation_id_generator(
1311        &mut self,
1312        gen: ::std::option::Option<::aws_runtime::invocation_id::SharedInvocationIdGenerator>,
1313    ) -> &mut Self {
1314        self.config.store_or_unset(gen);
1315        self
1316    }
1317    /// Sets the endpoint URL used to communicate with this service.
1318    ///
1319    /// Note: this is used in combination with other endpoint rules, e.g. an API that applies a host-label prefix
1320    /// will be prefixed onto this URL. To fully override the endpoint resolver, use
1321    /// [`Builder::endpoint_resolver`].
1322    pub fn endpoint_url(mut self, endpoint_url: impl Into<::std::string::String>) -> Self {
1323        self.set_endpoint_url(Some(endpoint_url.into()));
1324        self
1325    }
1326    /// Sets the endpoint URL used to communicate with this service.
1327    ///
1328    /// Note: this is used in combination with other endpoint rules, e.g. an API that applies a host-label prefix
1329    /// will be prefixed onto this URL. To fully override the endpoint resolver, use
1330    /// [`Builder::endpoint_resolver`].
1331    pub fn set_endpoint_url(&mut self, endpoint_url: Option<::std::string::String>) -> &mut Self {
1332        self.config.store_or_unset(endpoint_url.map(::aws_types::endpoint_config::EndpointUrl));
1333        self
1334    }
1335    /// When true, use the dual-stack endpoint. If the configured endpoint does not support dual-stack, dispatching the request MAY return an error.
1336    pub fn use_dual_stack(mut self, use_dual_stack: impl Into<bool>) -> Self {
1337        self.set_use_dual_stack(Some(use_dual_stack.into()));
1338        self
1339    }
1340    /// When true, use the dual-stack endpoint. If the configured endpoint does not support dual-stack, dispatching the request MAY return an error.
1341    pub fn set_use_dual_stack(&mut self, use_dual_stack: Option<bool>) -> &mut Self {
1342        self.config.store_or_unset(use_dual_stack.map(::aws_types::endpoint_config::UseDualStack));
1343        self
1344    }
1345    /// 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.
1346    pub fn use_fips(mut self, use_fips: impl Into<bool>) -> Self {
1347        self.set_use_fips(Some(use_fips.into()));
1348        self
1349    }
1350    /// 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.
1351    pub fn set_use_fips(&mut self, use_fips: Option<bool>) -> &mut Self {
1352        self.config.store_or_unset(use_fips.map(::aws_types::endpoint_config::UseFips));
1353        self
1354    }
1355    /// Set the [`ResponseChecksumValidation`](crate::config::ResponseChecksumValidation)
1356    /// to determine when checksum validation will be performed on response payloads.
1357    pub fn response_checksum_validation(mut self, response_checksum_validation: crate::config::ResponseChecksumValidation) -> Self {
1358        self.set_response_checksum_validation(::std::option::Option::Some(response_checksum_validation));
1359        self
1360    }
1361    /// Set the [`ResponseChecksumValidation`](crate::config::ResponseChecksumValidation)
1362    /// to determine when checksum validation will be performed on response payloads.
1363    pub fn set_response_checksum_validation(
1364        &mut self,
1365        response_checksum_validation: ::std::option::Option<crate::config::ResponseChecksumValidation>,
1366    ) -> &mut Self {
1367        self.config.store_or_unset(response_checksum_validation);
1368        self
1369    }
1370    /// Set the [`RequestChecksumCalculation`](crate::config::RequestChecksumCalculation)
1371    /// to determine when a checksum will be calculated for request payloads.
1372    pub fn request_checksum_calculation(mut self, request_checksum_calculation: crate::config::RequestChecksumCalculation) -> Self {
1373        self.set_request_checksum_calculation(::std::option::Option::Some(request_checksum_calculation));
1374        self
1375    }
1376    /// Set the [`RequestChecksumCalculation`](crate::config::RequestChecksumCalculation)
1377    /// to determine when a checksum will be calculated for request payloads.
1378    pub fn set_request_checksum_calculation(
1379        &mut self,
1380        request_checksum_calculation: ::std::option::Option<crate::config::RequestChecksumCalculation>,
1381    ) -> &mut Self {
1382        self.config.store_or_unset(request_checksum_calculation);
1383        self
1384    }
1385    /// Sets the SigV4a signing region set.
1386    pub fn sigv4a_signing_region_set(mut self, v: impl Into<::aws_types::region::SigningRegionSet>) -> Self {
1387        self.set_sigv4a_signing_region_set(Some(v.into()));
1388        self
1389    }
1390
1391    /// Sets the SigV4a signing region set.
1392    pub fn set_sigv4a_signing_region_set(&mut self, v: Option<::aws_types::region::SigningRegionSet>) -> &mut Self {
1393        self.config.store_or_unset(v);
1394        self
1395    }
1396    /// Sets the AWS region to use when making requests.
1397    ///
1398    /// # Examples
1399    /// ```no_run
1400    /// use aws_types::region::Region;
1401    /// use aws_sdk_s3::config::{Builder, Config};
1402    ///
1403    /// let config = aws_sdk_s3::Config::builder()
1404    ///     .region(Region::new("us-east-1"))
1405    ///     .build();
1406    /// ```
1407    pub fn region(mut self, region: impl ::std::convert::Into<::std::option::Option<crate::config::Region>>) -> Self {
1408        self.set_region(region.into());
1409        self
1410    }
1411    /// Sets the AWS region to use when making requests.
1412    pub fn set_region(&mut self, region: ::std::option::Option<crate::config::Region>) -> &mut Self {
1413        self.config.store_or_unset(region);
1414        self
1415    }
1416    /// Sets the credentials provider for this service
1417    pub fn credentials_provider(mut self, credentials_provider: impl crate::config::ProvideCredentials + 'static) -> Self {
1418        self.set_credentials_provider(::std::option::Option::Some(crate::config::SharedCredentialsProvider::new(
1419            credentials_provider,
1420        )));
1421        self
1422    }
1423    /// Sets the credentials provider for this service
1424    pub fn set_credentials_provider(&mut self, credentials_provider: ::std::option::Option<crate::config::SharedCredentialsProvider>) -> &mut Self {
1425        if let Some(credentials_provider) = credentials_provider {
1426            #[cfg(feature = "sigv4a")]
1427            {
1428                self.runtime_components
1429                    .set_identity_resolver(::aws_runtime::auth::sigv4a::SCHEME_ID, credentials_provider.clone());
1430            }
1431            self.runtime_components
1432                .set_identity_resolver(::aws_runtime::auth::sigv4::SCHEME_ID, credentials_provider);
1433        }
1434        self
1435    }
1436    /// Sets the chunk size for [`aws-chunked encoding`].
1437    ///
1438    /// Pass `Some(size)` to use a specific chunk size (minimum 8 KiB).
1439    /// Pass `None` to use the content-length as chunk size (no chunking).
1440    ///
1441    /// The minimum chunk size of 8 KiB is validated when the request is sent.
1442    ///
1443    /// **Note:** This setting only applies to operations that support aws-chunked encoding
1444    /// and has no effect on other operations. If this method is not invoked, a default
1445    /// chunk size of 64 KiB is used.
1446    ///
1447    /// [`aws-chunked encoding`]: https://docs.aws.amazon.com/AmazonS3/latest/API/sigv4-streaming.html
1448    ///
1449    /// # Example - Custom chunk size
1450    /// ```no_run
1451    /// # use aws_sdk_s3::{Client, Config};
1452    /// # async fn example(client: Client) -> Result<(), Box<dyn std::error::Error>> {
1453    /// let config = Config::builder()
1454    ///     .aws_chunked_encoding_chunk_size(Some(10240)) // 10 KiB chunks
1455    ///     .build();
1456    /// let client = Client::from_conf(config);
1457    /// # Ok(())
1458    /// # }
1459    /// ```
1460    ///
1461    /// # Example - No chunking (buffers entire body in memory)
1462    /// ```no_run
1463    /// # use aws_sdk_s3::{Client, Config};
1464    /// # async fn example(client: Client) -> Result<(), Box<dyn std::error::Error>> {
1465    /// let config = Config::builder()
1466    ///     .aws_chunked_encoding_chunk_size(None) // Use entire content as one chunk
1467    ///     .build();
1468    /// let client = Client::from_conf(config);
1469    /// # Ok(())
1470    /// # }
1471    /// ```
1472    pub fn aws_chunked_encoding_chunk_size(mut self, chunk_size: ::std::option::Option<usize>) -> Self {
1473        self.set_aws_chunked_encoding_chunk_size(::std::option::Option::Some(chunk_size));
1474        self
1475    }
1476
1477    /// Sets the chunk size for aws-chunked encoding.
1478    pub fn set_aws_chunked_encoding_chunk_size(&mut self, chunk_size: ::std::option::Option<::std::option::Option<usize>>) -> &mut Self {
1479        if let ::std::option::Option::Some(chunk_size) = chunk_size {
1480            let chunk_size = match chunk_size {
1481                ::std::option::Option::Some(size) => crate::aws_chunked::ChunkSize::Configured(size),
1482                ::std::option::Option::None => crate::aws_chunked::ChunkSize::DisableChunking,
1483            };
1484            self.push_runtime_plugin(crate::aws_chunked::ChunkSizeRuntimePlugin::new(chunk_size).into_shared());
1485        }
1486        self
1487    }
1488    /// Sets the [`behavior major version`](crate::config::BehaviorVersion).
1489    ///
1490    /// Over time, new best-practice behaviors are introduced. However, these behaviors might not be backwards
1491    /// compatible. For example, a change which introduces new default timeouts or a new retry-mode for
1492    /// all operations might be the ideal behavior but could break existing applications.
1493    ///
1494    /// # Examples
1495    ///
1496    /// Set the behavior major version to `latest`. This is equivalent to enabling the `behavior-version-latest` cargo feature.
1497    /// ```no_run
1498    /// use aws_sdk_s3::config::BehaviorVersion;
1499    ///
1500    /// let config = aws_sdk_s3::Config::builder()
1501    ///     .behavior_version(BehaviorVersion::latest())
1502    ///     // ...
1503    ///     .build();
1504    /// let client = aws_sdk_s3::Client::from_conf(config);
1505    /// ```
1506    ///
1507    /// Customizing behavior major version:
1508    /// ```no_run
1509    /// use aws_sdk_s3::config::BehaviorVersion;
1510    ///
1511    /// let config = aws_sdk_s3::Config::builder()
1512    ///     .behavior_version(BehaviorVersion::v2023_11_09())
1513    ///     // ...
1514    ///     .build();
1515    /// let client = aws_sdk_s3::Client::from_conf(config);
1516    /// ```
1517    ///
1518    pub fn behavior_version(mut self, behavior_version: crate::config::BehaviorVersion) -> Self {
1519        self.set_behavior_version(Some(behavior_version));
1520        self
1521    }
1522
1523    /// Sets the [`behavior major version`](crate::config::BehaviorVersion).
1524    ///
1525    /// Over time, new best-practice behaviors are introduced. However, these behaviors might not be backwards
1526    /// compatible. For example, a change which introduces new default timeouts or a new retry-mode for
1527    /// all operations might be the ideal behavior but could break existing applications.
1528    ///
1529    /// # Examples
1530    ///
1531    /// Set the behavior major version to `latest`. This is equivalent to enabling the `behavior-version-latest` cargo feature.
1532    /// ```no_run
1533    /// use aws_sdk_s3::config::BehaviorVersion;
1534    ///
1535    /// let config = aws_sdk_s3::Config::builder()
1536    ///     .behavior_version(BehaviorVersion::latest())
1537    ///     // ...
1538    ///     .build();
1539    /// let client = aws_sdk_s3::Client::from_conf(config);
1540    /// ```
1541    ///
1542    /// Customizing behavior major version:
1543    /// ```no_run
1544    /// use aws_sdk_s3::config::BehaviorVersion;
1545    ///
1546    /// let config = aws_sdk_s3::Config::builder()
1547    ///     .behavior_version(BehaviorVersion::v2023_11_09())
1548    ///     // ...
1549    ///     .build();
1550    /// let client = aws_sdk_s3::Client::from_conf(config);
1551    /// ```
1552    ///
1553    pub fn set_behavior_version(&mut self, behavior_version: Option<crate::config::BehaviorVersion>) -> &mut Self {
1554        self.behavior_version = behavior_version;
1555        self
1556    }
1557
1558    /// Convenience method to set the latest behavior major version
1559    ///
1560    /// This is equivalent to enabling the `behavior-version-latest` Cargo feature
1561    pub fn behavior_version_latest(mut self) -> Self {
1562        self.set_behavior_version(Some(crate::config::BehaviorVersion::latest()));
1563        self
1564    }
1565    /// Adds a runtime plugin to the config.
1566    #[allow(unused)]
1567    pub(crate) fn runtime_plugin(mut self, plugin: impl crate::config::RuntimePlugin + 'static) -> Self {
1568        self.push_runtime_plugin(crate::config::SharedRuntimePlugin::new(plugin));
1569        self
1570    }
1571    /// Adds a runtime plugin to the config.
1572    #[allow(unused)]
1573    pub(crate) fn push_runtime_plugin(&mut self, plugin: crate::config::SharedRuntimePlugin) -> &mut Self {
1574        self.runtime_plugins.push(plugin);
1575        self
1576    }
1577    #[cfg(any(feature = "test-util", test))]
1578    #[allow(unused_mut)]
1579    /// Apply test defaults to the builder. NOTE: Consider migrating to use `apply_test_defaults_v2` instead.
1580    pub fn apply_test_defaults(&mut self) -> &mut Self {
1581        self.set_idempotency_token_provider(Some("00000000-0000-4000-8000-000000000000".into()));
1582
1583        self.set_time_source(::std::option::Option::Some(::aws_smithy_async::time::SharedTimeSource::new(
1584            ::aws_smithy_async::time::StaticTimeSource::new(::std::time::UNIX_EPOCH + ::std::time::Duration::from_secs(1234567890)),
1585        )));
1586        self.config.store_put(::aws_runtime::user_agent::AwsUserAgent::for_tests());
1587        self.set_credentials_provider(Some(crate::config::SharedCredentialsProvider::new(
1588            ::aws_credential_types::Credentials::for_tests(),
1589        )));
1590        self.behavior_version = ::std::option::Option::Some(crate::config::BehaviorVersion::latest());
1591        self
1592    }
1593    #[cfg(any(feature = "test-util", test))]
1594    #[allow(unused_mut)]
1595    /// Apply test defaults to the builder. NOTE: Consider migrating to use `with_test_defaults_v2` instead.
1596    pub fn with_test_defaults(mut self) -> Self {
1597        self.apply_test_defaults();
1598        self
1599    }
1600    #[cfg(any(feature = "test-util", test))]
1601    #[allow(unused_mut)]
1602    /// Apply test defaults to the builder. V2 of this function sets additional test defaults such as region configuration (if applicable).
1603    pub fn apply_test_defaults_v2(&mut self) -> &mut Self {
1604        self.apply_test_defaults();
1605
1606        if self.config.load::<crate::config::Region>().is_none() {
1607            self.set_region(::std::option::Option::Some(crate::config::Region::new("us-east-1")));
1608        }
1609        self
1610    }
1611    #[cfg(any(feature = "test-util", test))]
1612    #[allow(unused_mut)]
1613    /// Apply test defaults to the builder. V2 of this function sets additional test defaults such as region configuration (if applicable).
1614    pub fn with_test_defaults_v2(mut self) -> Self {
1615        self.apply_test_defaults_v2();
1616        self
1617    }
1618    /// Builds a [`Config`].
1619    #[allow(unused_mut)]
1620    pub fn build(mut self) -> Config {
1621        let mut layer = self.config;
1622
1623        if self.runtime_components.time_source().is_none() {
1624            self.runtime_components
1625                .set_time_source(::std::option::Option::Some(::std::default::Default::default()));
1626        }
1627        layer.store_put(crate::meta::API_METADATA.clone());
1628        layer.store_put(::aws_types::SigningName::from_static("s3"));
1629        layer
1630            .load::<::aws_types::region::Region>()
1631            .cloned()
1632            .map(|r| layer.store_put(::aws_types::region::SigningRegion::from(r)));
1633        Config {
1634            config: crate::config::Layer::from(layer.clone()).with_name("aws_sdk_s3::config::Config").freeze(),
1635            cloneable: layer,
1636            runtime_components: self.runtime_components,
1637            runtime_plugins: self.runtime_plugins,
1638            behavior_version: self.behavior_version,
1639        }
1640    }
1641}
1642#[derive(::std::fmt::Debug)]
1643pub(crate) struct ServiceRuntimePlugin {
1644    config: ::std::option::Option<::aws_smithy_types::config_bag::FrozenLayer>,
1645    runtime_components: ::aws_smithy_runtime_api::client::runtime_components::RuntimeComponentsBuilder,
1646}
1647
1648impl ServiceRuntimePlugin {
1649    pub fn new(_service_config: crate::config::Config) -> Self {
1650        let config = {
1651            let mut cfg = ::aws_smithy_types::config_bag::Layer::new("AmazonS3");
1652            cfg.store_put(crate::idempotency_token::default_provider());
1653            cfg.store_put(::aws_smithy_runtime::client::orchestrator::AuthSchemeAndEndpointOrchestrationV2);
1654            ::std::option::Option::Some(cfg.freeze())
1655        };
1656        let mut runtime_components = ::aws_smithy_runtime_api::client::runtime_components::RuntimeComponentsBuilder::new("ServiceRuntimePlugin");
1657        runtime_components.set_auth_scheme_option_resolver(::std::option::Option::Some({
1658            use crate::config::auth::ResolveAuthScheme;
1659            crate::config::auth::DefaultAuthSchemeResolver::default().into_shared_resolver()
1660        }));
1661        runtime_components.set_endpoint_resolver(::std::option::Option::Some({
1662            use crate::config::endpoint::ResolveEndpoint;
1663            crate::config::endpoint::DefaultResolver::new().into_shared_resolver()
1664        }));
1665        runtime_components.push_interceptor(::aws_smithy_runtime_api::client::interceptors::SharedInterceptor::permanent(
1666            ::aws_smithy_runtime::client::http::connection_poisoning::ConnectionPoisoningInterceptor::new(),
1667        ));
1668        runtime_components.push_retry_classifier(::aws_smithy_runtime::client::retries::classifiers::HttpStatusCodeClassifier::default());
1669        runtime_components.push_interceptor(::aws_smithy_runtime_api::client::interceptors::SharedInterceptor::permanent(
1670            crate::sdk_feature_tracker::retry_mode::RetryModeFeatureTrackerInterceptor::new(),
1671        ));
1672        runtime_components.push_interceptor(::aws_runtime::service_clock_skew::ServiceClockSkewInterceptor::new());
1673        runtime_components.push_interceptor(::aws_runtime::request_info::RequestInfoInterceptor::new());
1674        runtime_components.push_interceptor(::aws_runtime::user_agent::UserAgentInterceptor::new());
1675        runtime_components.push_auth_scheme(::aws_smithy_runtime_api::client::auth::SharedAuthScheme::new(
1676            crate::s3_express::auth::S3ExpressAuthScheme::new(),
1677        ));
1678        runtime_components.push_interceptor(::aws_runtime::invocation_id::InvocationIdInterceptor::new());
1679        runtime_components.push_interceptor(::aws_smithy_runtime_api::client::interceptors::SharedInterceptor::permanent(
1680            ::aws_runtime::recursion_detection::RecursionDetectionInterceptor::new(),
1681        ));
1682        runtime_components.push_auth_scheme(::aws_smithy_runtime_api::client::auth::SharedAuthScheme::new(
1683            ::aws_runtime::auth::sigv4::SigV4AuthScheme::new(),
1684        ));
1685        #[cfg(feature = "sigv4a")]
1686        {
1687            runtime_components.push_auth_scheme(::aws_smithy_runtime_api::client::auth::SharedAuthScheme::new(
1688                ::aws_runtime::auth::sigv4a::SigV4aAuthScheme::new(),
1689            ));
1690        }
1691        runtime_components.push_interceptor(::aws_smithy_runtime_api::client::interceptors::SharedInterceptor::permanent(
1692            crate::config::endpoint::EndpointOverrideFeatureTrackerInterceptor,
1693        ));
1694        runtime_components.push_interceptor(::aws_smithy_runtime_api::client::interceptors::SharedInterceptor::permanent(
1695            crate::observability_feature::ObservabilityFeatureTrackerInterceptor,
1696        ));
1697        Self { config, runtime_components }
1698    }
1699}
1700
1701impl ::aws_smithy_runtime_api::client::runtime_plugin::RuntimePlugin for ServiceRuntimePlugin {
1702    fn config(&self) -> ::std::option::Option<::aws_smithy_types::config_bag::FrozenLayer> {
1703        self.config.clone()
1704    }
1705
1706    fn order(&self) -> ::aws_smithy_runtime_api::client::runtime_plugin::Order {
1707        ::aws_smithy_runtime_api::client::runtime_plugin::Order::Defaults
1708    }
1709
1710    fn runtime_components(
1711        &self,
1712        _: &::aws_smithy_runtime_api::client::runtime_components::RuntimeComponentsBuilder,
1713    ) -> ::std::borrow::Cow<'_, ::aws_smithy_runtime_api::client::runtime_components::RuntimeComponentsBuilder> {
1714        ::std::borrow::Cow::Borrowed(&self.runtime_components)
1715    }
1716}
1717
1718// Cross-operation shared-state singletons
1719
1720/// A plugin that enables configuration for a single operation invocation
1721///
1722/// The `config` method will return a `FrozenLayer` by storing values from `config_override`.
1723/// In the case of default values requested, they will be obtained from `client_config`.
1724#[derive(Debug)]
1725pub(crate) struct ConfigOverrideRuntimePlugin {
1726    pub(crate) config: ::aws_smithy_types::config_bag::FrozenLayer,
1727    pub(crate) components: ::aws_smithy_runtime_api::client::runtime_components::RuntimeComponentsBuilder,
1728}
1729
1730impl ConfigOverrideRuntimePlugin {
1731    #[allow(dead_code)] // unused when a service does not provide any operations
1732    pub(crate) fn new(
1733        config_override: Builder,
1734        initial_config: ::aws_smithy_types::config_bag::FrozenLayer,
1735        initial_components: &::aws_smithy_runtime_api::client::runtime_components::RuntimeComponentsBuilder,
1736    ) -> Self {
1737        let mut layer = config_override.config;
1738        let mut components = config_override.runtime_components;
1739        #[allow(unused_mut)]
1740        let mut resolver =
1741            ::aws_smithy_runtime::client::config_override::Resolver::overrid(initial_config, initial_components, &mut layer, &mut components);
1742
1743        resolver
1744            .config_mut()
1745            .load::<::aws_types::region::Region>()
1746            .cloned()
1747            .map(|r| resolver.config_mut().store_put(::aws_types::region::SigningRegion::from(r)));
1748
1749        let _ = resolver;
1750
1751        // When the config override supplies an identity resolver for any auth scheme
1752        // known to the client or the override itself, we give this operation its own
1753        // short-lived identity cache so that new partitions don't accumulate in the
1754        // shared client cache. A lazy cache (not `no_cache`) is used so that resolved
1755        // identities are served from the short-lived identity cache on retries.
1756        //
1757        // This is skipped if the override already sets its own identity cache.
1758        if components.has_identity_resolvers() && components.identity_cache().is_none() {
1759            components.set_identity_cache(::std::option::Option::Some(
1760                ::aws_smithy_runtime::client::identity::IdentityCache::lazy().max_partitions(1).build(),
1761            ));
1762        }
1763
1764        Self {
1765            config: ::aws_smithy_types::config_bag::Layer::from(layer)
1766                .with_name("aws_sdk_s3::config::ConfigOverrideRuntimePlugin")
1767                .freeze(),
1768            components,
1769        }
1770    }
1771}
1772
1773impl ::aws_smithy_runtime_api::client::runtime_plugin::RuntimePlugin for ConfigOverrideRuntimePlugin {
1774    fn config(&self) -> ::std::option::Option<::aws_smithy_types::config_bag::FrozenLayer> {
1775        Some(self.config.clone())
1776    }
1777
1778    fn runtime_components(
1779        &self,
1780        _: &::aws_smithy_runtime_api::client::runtime_components::RuntimeComponentsBuilder,
1781    ) -> ::std::borrow::Cow<'_, ::aws_smithy_runtime_api::client::runtime_components::RuntimeComponentsBuilder> {
1782        ::std::borrow::Cow::Borrowed(&self.components)
1783    }
1784}
1785
1786pub use ::aws_smithy_runtime::client::identity::IdentityCache;
1787pub use ::aws_smithy_runtime_api::client::runtime_components::RuntimeComponents;
1788pub use ::aws_smithy_types::config_bag::ConfigBag;
1789
1790pub use ::aws_credential_types::Credentials;
1791
1792impl From<&::aws_types::sdk_config::SdkConfig> for Builder {
1793    fn from(input: &::aws_types::sdk_config::SdkConfig) -> Self {
1794        let mut builder = Builder::default();
1795        builder.set_credentials_provider(input.credentials_provider());
1796        builder = builder.region(input.region().cloned());
1797        builder.set_sigv4a_signing_region_set(input.sigv4a_signing_region_set().cloned());
1798        builder.set_request_checksum_calculation(input.request_checksum_calculation());
1799        builder.set_response_checksum_validation(input.response_checksum_validation());
1800        builder.set_use_fips(input.use_fips());
1801        builder.set_use_dual_stack(input.use_dual_stack());
1802        if input.get_origin("endpoint_url").is_client_config() {
1803            builder.set_endpoint_url(input.endpoint_url().map(|s| s.to_string()));
1804        } else {
1805            builder.set_endpoint_url(
1806                input
1807                    .service_config()
1808                    .and_then(|conf| {
1809                        conf.load_config(service_config_key("S3", "AWS_ENDPOINT_URL", "endpoint_url"))
1810                            .map(|it| it.parse().unwrap())
1811                    })
1812                    .or_else(|| input.endpoint_url().map(|s| s.to_string())),
1813            );
1814        }
1815        // resiliency
1816        builder.set_retry_config(input.retry_config().cloned());
1817        builder.set_timeout_config(input.timeout_config().cloned());
1818        builder.set_sleep_impl(input.sleep_impl());
1819
1820        builder.set_http_client(input.http_client());
1821        builder.set_time_source(input.time_source());
1822        builder.set_behavior_version(input.behavior_version());
1823        builder.set_auth_scheme_preference(input.auth_scheme_preference().cloned());
1824        // setting `None` here removes the default
1825        if let Some(config) = input.stalled_stream_protection() {
1826            builder.set_stalled_stream_protection(Some(config));
1827        }
1828
1829        if let Some(cache) = input.identity_cache() {
1830            builder.set_identity_cache(cache);
1831        }
1832        builder = builder.disable_clock_skew_correction(input.disable_clock_skew_correction());
1833        builder.set_disable_s3_express_session_auth(input.service_config().and_then(|conf| {
1834            let str_config = conf.load_config(service_config_key(
1835                "S3",
1836                "AWS_S3_DISABLE_EXPRESS_SESSION_AUTH",
1837                "s3_disable_express_session_auth",
1838            ));
1839            str_config.and_then(|it| it.parse::<bool>().ok())
1840        }));
1841        builder.set_app_name(input.app_name().cloned());
1842        for framework_metadata in input.framework_metadata() {
1843            builder.push_framework_metadata(framework_metadata.clone());
1844        }
1845
1846        builder
1847    }
1848}
1849
1850impl From<&::aws_types::sdk_config::SdkConfig> for Config {
1851    fn from(sdk_config: &::aws_types::sdk_config::SdkConfig) -> Self {
1852        Builder::from(sdk_config).build()
1853    }
1854}
1855
1856pub use ::aws_types::app_name::AppName;
1857pub use ::aws_types::sdk_ua_metadata::FrameworkMetadata;
1858
1859#[allow(dead_code)]
1860fn service_config_key<'a>(service_id: &'a str, env: &'a str, profile: &'a str) -> aws_types::service_config::ServiceConfigKey<'a> {
1861    ::aws_types::service_config::ServiceConfigKey::builder()
1862        .service_id(service_id)
1863        .env(env)
1864        .profile(profile)
1865        .build()
1866        .expect("all field sets explicitly, can't fail")
1867}
1868
1869pub use ::aws_smithy_async::rt::sleep::Sleep;
1870
1871pub(crate) fn base_client_runtime_plugins(mut config: crate::Config) -> ::aws_smithy_runtime_api::client::runtime_plugin::RuntimePlugins {
1872    let mut configured_plugins = ::std::vec::Vec::new();
1873    ::std::mem::swap(&mut config.runtime_plugins, &mut configured_plugins);
1874    #[cfg(feature = "behavior-version-latest")]
1875    {
1876        if config.behavior_version.is_none() {
1877            config.behavior_version = Some(::aws_smithy_runtime_api::client::behavior_version::BehaviorVersion::latest());
1878        }
1879    }
1880
1881    let default_retry_partition = "s3";
1882    let default_retry_partition = match config.region() {
1883        Some(region) => ::std::borrow::Cow::from(format!("{default_retry_partition}-{region}")),
1884        None => ::std::borrow::Cow::from(default_retry_partition),
1885    };
1886
1887    let scope = "aws-sdk-s3";
1888
1889    #[allow(deprecated)]
1890                    let mut plugins = ::aws_smithy_runtime_api::client::runtime_plugin::RuntimePlugins::new()
1891                        // defaults
1892                        .with_client_plugins(::aws_smithy_runtime::client::defaults::default_plugins(
1893                            ::aws_smithy_runtime::client::defaults::DefaultPluginParams::new()
1894                                .with_retry_partition_name(default_retry_partition)
1895                                .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."))
1896                                .with_is_aws_sdk(true)
1897                        ))
1898                        // user config
1899                        .with_client_plugin(
1900                            ::aws_smithy_runtime_api::client::runtime_plugin::StaticRuntimePlugin::new()
1901                                .with_config(config.config.clone())
1902                                .with_runtime_components(config.runtime_components.clone())
1903                        )
1904                        // codegen config
1905                        .with_client_plugin(crate::config::ServiceRuntimePlugin::new(config.clone()))
1906                        .with_client_plugin(::aws_smithy_runtime::client::auth::no_auth::NoAuthRuntimePlugin::new())
1907                        .with_client_plugin(
1908                            ::aws_smithy_runtime::client::metrics::MetricsRuntimePlugin::builder()
1909                                .with_scope(scope)
1910                                .with_time_source(config.runtime_components.time_source().unwrap_or_default())
1911                                .build()
1912                                .expect("All required fields have been set")
1913                        );
1914
1915    plugins = plugins.with_client_plugin(crate::s3_express::runtime_plugin::S3ExpressRuntimePlugin::new(config.clone()));
1916
1917    for plugin in configured_plugins {
1918        plugins = plugins.with_client_plugin(plugin);
1919    }
1920    plugins
1921}
1922
1923pub use ::aws_smithy_types::config_bag::FrozenLayer;
1924
1925pub use ::aws_smithy_runtime_api::client::runtime_components::RuntimeComponentsBuilder;
1926
1927pub use ::aws_smithy_runtime_api::client::runtime_plugin::SharedRuntimePlugin;
1928
1929pub use ::aws_smithy_runtime_api::client::behavior_version::BehaviorVersion;
1930
1931pub use ::aws_smithy_runtime_api::client::stalled_stream_protection::StalledStreamProtectionConfig;
1932
1933pub use ::aws_smithy_runtime_api::client::http::SharedHttpClient;
1934
1935pub use ::aws_smithy_async::rt::sleep::SharedAsyncSleep;
1936
1937pub use ::aws_smithy_runtime_api::client::identity::SharedIdentityCache;
1938
1939pub use ::aws_smithy_runtime_api::client::interceptors::SharedInterceptor;
1940
1941pub use ::aws_smithy_types::checksum_config::ResponseChecksumValidation;
1942
1943pub use ::aws_smithy_types::checksum_config::RequestChecksumCalculation;
1944
1945pub use ::aws_types::region::Region;
1946
1947pub use ::aws_credential_types::provider::SharedCredentialsProvider;
1948
1949#[derive(Debug, Clone)]
1950pub(crate) struct ForcePathStyle(pub(crate) bool);
1951impl ::aws_smithy_types::config_bag::Storable for ForcePathStyle {
1952    type Storer = ::aws_smithy_types::config_bag::StoreReplace<Self>;
1953}
1954
1955#[derive(Debug, Clone)]
1956pub(crate) struct UseArnRegion(pub(crate) bool);
1957impl ::aws_smithy_types::config_bag::Storable for UseArnRegion {
1958    type Storer = ::aws_smithy_types::config_bag::StoreReplace<Self>;
1959}
1960
1961#[derive(Debug, Clone)]
1962pub(crate) struct DisableMultiRegionAccessPoints(pub(crate) bool);
1963impl ::aws_smithy_types::config_bag::Storable for DisableMultiRegionAccessPoints {
1964    type Storer = ::aws_smithy_types::config_bag::StoreReplace<Self>;
1965}
1966
1967#[derive(Debug, Clone)]
1968pub(crate) struct Accelerate(pub(crate) bool);
1969impl ::aws_smithy_types::config_bag::Storable for Accelerate {
1970    type Storer = ::aws_smithy_types::config_bag::StoreReplace<Self>;
1971}
1972
1973#[derive(Debug, Clone)]
1974pub(crate) struct DisableS3ExpressSessionAuth(pub(crate) bool);
1975impl ::aws_smithy_types::config_bag::Storable for DisableS3ExpressSessionAuth {
1976    type Storer = ::aws_smithy_types::config_bag::StoreReplace<Self>;
1977}
1978
1979pub use ::aws_smithy_runtime_api::client::http::HttpClient;
1980
1981pub use ::aws_smithy_runtime_api::shared::IntoShared;
1982
1983pub use ::aws_smithy_async::rt::sleep::AsyncSleep;
1984
1985pub use ::aws_smithy_runtime_api::client::identity::ResolveCachedIdentity;
1986
1987pub use ::aws_smithy_runtime_api::client::interceptors::Intercept;
1988
1989pub use ::aws_credential_types::provider::ProvideCredentials;
1990
1991pub use ::aws_smithy_runtime_api::client::runtime_plugin::RuntimePlugin;
1992
1993pub use ::aws_smithy_types::config_bag::Layer;
1994
1995/// Types needed to configure endpoint resolution.
1996pub mod endpoint;
1997
1998/// HTTP request and response types.
1999pub mod http;
2000
2001/// Types needed to implement [`Intercept`](crate::config::Intercept).
2002pub mod interceptors;
2003
2004/// Retry configuration.
2005///
2006/// [`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).
2007pub mod retry;
2008
2009/// Timeout configuration.
2010pub mod timeout;
2011
2012/// Types needed to configure auth scheme resolution.
2013pub mod auth;