Skip to main content

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