aws_sdk_appmesh/
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_appmesh 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    /// Return the [`SharedHttpClient`](crate::config::SharedHttpClient) to use when making requests, if any.
54    pub fn http_client(&self) -> Option<crate::config::SharedHttpClient> {
55        self.runtime_components.http_client()
56    }
57    /// Return the auth schemes configured on this service config
58    pub fn auth_schemes(&self) -> impl Iterator<Item = ::aws_smithy_runtime_api::client::auth::SharedAuthScheme> + '_ {
59        self.runtime_components.auth_schemes()
60    }
61
62    /// Return the auth scheme resolver configured on this service config
63    pub fn auth_scheme_resolver(&self) -> ::std::option::Option<::aws_smithy_runtime_api::client::auth::SharedAuthSchemeOptionResolver> {
64        self.runtime_components.auth_scheme_option_resolver()
65    }
66    /// Returns the endpoint resolver.
67    pub fn endpoint_resolver(&self) -> ::aws_smithy_runtime_api::client::endpoint::SharedEndpointResolver {
68        self.runtime_components.endpoint_resolver().expect("resolver defaulted if not set")
69    }
70    /// Return a reference to the retry configuration contained in this config, if any.
71    pub fn retry_config(&self) -> ::std::option::Option<&::aws_smithy_types::retry::RetryConfig> {
72        self.config.load::<::aws_smithy_types::retry::RetryConfig>()
73    }
74
75    /// Return a cloned shared async sleep implementation from this config, if any.
76    pub fn sleep_impl(&self) -> ::std::option::Option<crate::config::SharedAsyncSleep> {
77        self.runtime_components.sleep_impl()
78    }
79
80    /// Return a reference to the timeout configuration contained in this config, if any.
81    pub fn timeout_config(&self) -> ::std::option::Option<&::aws_smithy_types::timeout::TimeoutConfig> {
82        self.config.load::<::aws_smithy_types::timeout::TimeoutConfig>()
83    }
84
85    /// Returns a reference to the retry partition contained in this config, if any.
86    ///
87    /// WARNING: This method is unstable and may be removed at any time. Do not rely on this
88    /// method for anything!
89    pub fn retry_partition(&self) -> ::std::option::Option<&::aws_smithy_runtime::client::retries::RetryPartition> {
90        self.config.load::<::aws_smithy_runtime::client::retries::RetryPartition>()
91    }
92    /// Returns the configured identity cache for auth.
93    pub fn identity_cache(&self) -> ::std::option::Option<crate::config::SharedIdentityCache> {
94        self.runtime_components.identity_cache()
95    }
96    /// Returns interceptors currently registered by the user.
97    pub fn interceptors(&self) -> impl Iterator<Item = crate::config::SharedInterceptor> + '_ {
98        self.runtime_components.interceptors()
99    }
100    /// Return time source used for this service.
101    pub fn time_source(&self) -> ::std::option::Option<::aws_smithy_async::time::SharedTimeSource> {
102        self.runtime_components.time_source()
103    }
104    /// Returns retry classifiers currently registered by the user.
105    pub fn retry_classifiers(&self) -> impl Iterator<Item = ::aws_smithy_runtime_api::client::retries::classifiers::SharedRetryClassifier> + '_ {
106        self.runtime_components.retry_classifiers()
107    }
108    /// Returns the name of the app that is using the client, if it was provided.
109    ///
110    /// This _optional_ name is used to identify the application in the user agent that
111    /// gets sent along with requests.
112    pub fn app_name(&self) -> ::std::option::Option<&::aws_types::app_name::AppName> {
113        self.config.load::<::aws_types::app_name::AppName>()
114    }
115    /// Returns the invocation ID generator if one was given in config.
116    ///
117    /// 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.
118    pub fn invocation_id_generator(&self) -> ::std::option::Option<::aws_runtime::invocation_id::SharedInvocationIdGenerator> {
119        self.config.load::<::aws_runtime::invocation_id::SharedInvocationIdGenerator>().cloned()
120    }
121    /// Creates a new [service config](crate::Config) from a [shared `config`](::aws_types::sdk_config::SdkConfig).
122    pub fn new(config: &::aws_types::sdk_config::SdkConfig) -> Self {
123        Builder::from(config).build()
124    }
125    /// The signature version 4 service signing name to use in the credential scope when signing requests.
126    ///
127    /// The signing service may be overridden by the `Endpoint`, or by specifying a custom
128    /// [`SigningName`](aws_types::SigningName) during operation construction
129    pub fn signing_name(&self) -> &'static str {
130        "appmesh"
131    }
132    /// Returns the AWS region, if it was provided.
133    pub fn region(&self) -> ::std::option::Option<&crate::config::Region> {
134        self.config.load::<crate::config::Region>()
135    }
136    /// 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.
137    #[deprecated(
138        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."
139    )]
140    pub fn credentials_provider(&self) -> Option<crate::config::SharedCredentialsProvider> {
141        ::std::option::Option::None
142    }
143}
144/// Builder for creating a `Config`.
145#[derive(::std::clone::Clone, ::std::fmt::Debug)]
146pub struct Builder {
147    pub(crate) config: ::aws_smithy_types::config_bag::CloneableLayer,
148    pub(crate) runtime_components: crate::config::RuntimeComponentsBuilder,
149    pub(crate) runtime_plugins: ::std::vec::Vec<crate::config::SharedRuntimePlugin>,
150    pub(crate) behavior_version: ::std::option::Option<crate::config::BehaviorVersion>,
151}
152impl ::std::default::Default for Builder {
153    fn default() -> Self {
154        Self {
155            config: ::std::default::Default::default(),
156            runtime_components: crate::config::RuntimeComponentsBuilder::new("service config"),
157            runtime_plugins: ::std::default::Default::default(),
158            behavior_version: ::std::default::Default::default(),
159        }
160    }
161}
162impl Builder {
163    ///
164    /// Constructs a config builder.
165    /// <div class="warning">
166    /// Note that a config created from this builder will not have the same safe defaults as one created by
167    /// the <a href="https://crates.io/crates/aws-config" target="_blank">aws-config</a> crate.
168    /// </div>
169    ///
170    pub fn new() -> Self {
171        Self::default()
172    }
173    /// Constructs a config builder from the given `config_bag`, setting only fields stored in the config bag,
174    /// but not those in runtime components.
175    #[allow(unused)]
176    pub(crate) fn from_config_bag(config_bag: &::aws_smithy_types::config_bag::ConfigBag) -> Self {
177        let mut builder = Self::new();
178        builder.set_stalled_stream_protection(config_bag.load::<crate::config::StalledStreamProtectionConfig>().cloned());
179        builder.set_retry_config(config_bag.load::<::aws_smithy_types::retry::RetryConfig>().cloned());
180        builder.set_timeout_config(config_bag.load::<::aws_smithy_types::timeout::TimeoutConfig>().cloned());
181        builder.set_retry_partition(config_bag.load::<::aws_smithy_runtime::client::retries::RetryPartition>().cloned());
182        builder.set_app_name(config_bag.load::<::aws_types::app_name::AppName>().cloned());
183        builder.set_endpoint_url(config_bag.load::<::aws_types::endpoint_config::EndpointUrl>().map(|ty| ty.0.clone()));
184        builder.set_use_dual_stack(config_bag.load::<::aws_types::endpoint_config::UseDualStack>().map(|ty| ty.0));
185        builder.set_use_fips(config_bag.load::<::aws_types::endpoint_config::UseFips>().map(|ty| ty.0));
186        builder.set_region(config_bag.load::<crate::config::Region>().cloned());
187        builder
188    }
189    /// Set the [`StalledStreamProtectionConfig`](crate::config::StalledStreamProtectionConfig)
190    /// to configure protection for stalled streams.
191    pub fn stalled_stream_protection(mut self, stalled_stream_protection_config: crate::config::StalledStreamProtectionConfig) -> Self {
192        self.set_stalled_stream_protection(::std::option::Option::Some(stalled_stream_protection_config));
193        self
194    }
195    /// Set the [`StalledStreamProtectionConfig`](crate::config::StalledStreamProtectionConfig)
196    /// to configure protection for stalled streams.
197    pub fn set_stalled_stream_protection(
198        &mut self,
199        stalled_stream_protection_config: ::std::option::Option<crate::config::StalledStreamProtectionConfig>,
200    ) -> &mut Self {
201        self.config.store_or_unset(stalled_stream_protection_config);
202        self
203    }
204    /// Sets the idempotency token provider to use for service calls that require tokens.
205    pub fn idempotency_token_provider(
206        mut self,
207        idempotency_token_provider: impl ::std::convert::Into<crate::idempotency_token::IdempotencyTokenProvider>,
208    ) -> Self {
209        self.set_idempotency_token_provider(::std::option::Option::Some(idempotency_token_provider.into()));
210        self
211    }
212    /// Sets the idempotency token provider to use for service calls that require tokens.
213    pub fn set_idempotency_token_provider(
214        &mut self,
215        idempotency_token_provider: ::std::option::Option<crate::idempotency_token::IdempotencyTokenProvider>,
216    ) -> &mut Self {
217        self.config.store_or_unset(idempotency_token_provider);
218        self
219    }
220    /// Sets the HTTP client to use when making requests.
221    ///
222    /// # Examples
223    /// ```no_run
224    /// # #[cfg(test)]
225    /// # mod tests {
226    /// # #[test]
227    /// # fn example() {
228    /// use std::time::Duration;
229    /// use aws_sdk_appmesh::config::Config;
230    /// use aws_smithy_runtime::client::http::hyper_014::HyperClientBuilder;
231    ///
232    /// let https_connector = hyper_rustls::HttpsConnectorBuilder::new()
233    ///     .with_webpki_roots()
234    ///     .https_only()
235    ///     .enable_http1()
236    ///     .enable_http2()
237    ///     .build();
238    /// let hyper_client = HyperClientBuilder::new().build(https_connector);
239    ///
240    /// // This connector can then be given to a generated service Config
241    /// let config = my_service_client::Config::builder()
242    ///     .endpoint_url("https://example.com")
243    ///     .http_client(hyper_client)
244    ///     .build();
245    /// let client = my_service_client::Client::from_conf(config);
246    /// # }
247    /// # }
248    /// ```
249    pub fn http_client(mut self, http_client: impl crate::config::HttpClient + 'static) -> Self {
250        self.set_http_client(::std::option::Option::Some(crate::config::IntoShared::into_shared(http_client)));
251        self
252    }
253
254    /// Sets the HTTP client to use when making requests.
255    ///
256    /// # Examples
257    /// ```no_run
258    /// # #[cfg(test)]
259    /// # mod tests {
260    /// # #[test]
261    /// # fn example() {
262    /// use std::time::Duration;
263    /// use aws_sdk_appmesh::config::{Builder, Config};
264    /// use aws_smithy_runtime::client::http::hyper_014::HyperClientBuilder;
265    ///
266    /// fn override_http_client(builder: &mut Builder) {
267    ///     let https_connector = hyper_rustls::HttpsConnectorBuilder::new()
268    ///         .with_webpki_roots()
269    ///         .https_only()
270    ///         .enable_http1()
271    ///         .enable_http2()
272    ///         .build();
273    ///     let hyper_client = HyperClientBuilder::new().build(https_connector);
274    ///     builder.set_http_client(Some(hyper_client));
275    /// }
276    ///
277    /// let mut builder = aws_sdk_appmesh::Config::builder();
278    /// override_http_client(&mut builder);
279    /// let config = builder.build();
280    /// # }
281    /// # }
282    /// ```
283    pub fn set_http_client(&mut self, http_client: Option<crate::config::SharedHttpClient>) -> &mut Self {
284        self.runtime_components.set_http_client(http_client);
285        self
286    }
287    /// Adds an auth scheme to the builder
288    ///
289    /// If `auth_scheme` has an existing [AuthSchemeId](aws_smithy_runtime_api::client::auth::AuthSchemeId) in the runtime, the current identity
290    /// resolver and signer for that scheme will be replaced by those from `auth_scheme`.
291    ///
292    /// _Important:_ When introducing a custom auth scheme, ensure you override either
293    /// [`Self::auth_scheme_resolver`] or [`Self::set_auth_scheme_resolver`]
294    /// so that the custom auth scheme is included in the list of resolved auth scheme options.
295    /// [The default auth scheme resolver](crate::config::auth::DefaultAuthSchemeResolver) will not recognize your custom auth scheme.
296    ///
297    /// # Examples
298    /// ```no_run
299    /// # use aws_smithy_runtime_api::{
300    /// #     box_error::BoxError,
301    /// #     client::{
302    /// #         auth::{
303    /// #             AuthScheme, AuthSchemeEndpointConfig, AuthSchemeId, AuthSchemeOption,
304    /// #             AuthSchemeOptionsFuture, Sign,
305    /// #         },
306    /// #         identity::{Identity, IdentityFuture, ResolveIdentity, SharedIdentityResolver},
307    /// #         orchestrator::HttpRequest,
308    /// #         runtime_components::{GetIdentityResolver, RuntimeComponents},
309    /// #   },
310    /// #   shared::IntoShared,
311    /// # };
312    /// # use aws_smithy_types::config_bag::ConfigBag;
313    /// // Auth scheme with customer identity resolver and signer
314    /// #[derive(Debug)]
315    /// struct CustomAuthScheme {
316    ///     id: AuthSchemeId,
317    ///     identity_resolver: SharedIdentityResolver,
318    ///     signer: CustomSigner,
319    /// }
320    /// impl Default for CustomAuthScheme {
321    ///     fn default() -> Self {
322    ///         Self {
323    ///             id: AuthSchemeId::new("custom"),
324    ///             identity_resolver: CustomIdentityResolver.into_shared(),
325    ///             signer: CustomSigner,
326    ///         }
327    ///     }
328    /// }
329    /// impl AuthScheme for CustomAuthScheme {
330    ///     fn scheme_id(&self) -> AuthSchemeId {
331    ///         self.id.clone()
332    ///     }
333    ///     fn identity_resolver(
334    ///         &self,
335    ///         _identity_resolvers: &dyn GetIdentityResolver,
336    ///     ) -> Option<SharedIdentityResolver> {
337    ///         Some(self.identity_resolver.clone())
338    ///     }
339    ///     fn signer(&self) -> &dyn Sign {
340    ///         &self.signer
341    ///     }
342    /// }
343    ///
344    /// #[derive(Debug, Default)]
345    /// struct CustomSigner;
346    /// impl Sign for CustomSigner {
347    ///     fn sign_http_request(
348    ///         &self,
349    ///         _request: &mut HttpRequest,
350    ///         _identity: &Identity,
351    ///         _auth_scheme_endpoint_config: AuthSchemeEndpointConfig<'_>,
352    ///         _runtime_components: &RuntimeComponents,
353    ///         _config_bag: &ConfigBag,
354    ///     ) -> Result<(), BoxError> {
355    ///         // --snip--
356    /// #      todo!()
357    ///     }
358    /// }
359    ///
360    /// #[derive(Debug)]
361    /// struct CustomIdentityResolver;
362    /// impl ResolveIdentity for CustomIdentityResolver {
363    ///     fn resolve_identity<'a>(
364    ///         &'a self,
365    ///         _runtime_components: &'a RuntimeComponents,
366    ///         _config_bag: &'a ConfigBag,
367    ///     ) -> IdentityFuture<'a> {
368    ///         // --snip--
369    /// #      todo!()
370    ///     }
371    /// }
372    ///
373    /// // Auth scheme resolver that favors `CustomAuthScheme`
374    /// #[derive(Debug)]
375    /// struct CustomAuthSchemeResolver;
376    /// impl aws_sdk_appmesh::config::auth::ResolveAuthScheme for CustomAuthSchemeResolver {
377    ///     fn resolve_auth_scheme<'a>(
378    ///         &'a self,
379    ///         _params: &'a aws_sdk_appmesh::config::auth::Params,
380    ///         _cfg: &'a ConfigBag,
381    ///         _runtime_components: &'a RuntimeComponents,
382    ///     ) -> AuthSchemeOptionsFuture<'a> {
383    ///         AuthSchemeOptionsFuture::ready(Ok(vec![AuthSchemeOption::from(AuthSchemeId::new(
384    ///             "custom",
385    ///         ))]))
386    ///     }
387    /// }
388    ///
389    /// let config = aws_sdk_appmesh::Config::builder()
390    ///     .push_auth_scheme(CustomAuthScheme::default())
391    ///     .auth_scheme_resolver(CustomAuthSchemeResolver)
392    ///     // other configurations
393    ///     .build();
394    /// ```
395    pub fn push_auth_scheme(mut self, auth_scheme: impl ::aws_smithy_runtime_api::client::auth::AuthScheme + 'static) -> Self {
396        self.runtime_components.push_auth_scheme(auth_scheme);
397        self
398    }
399
400    /// Set the auth scheme resolver for the builder
401    ///
402    /// # Examples
403    /// ```no_run
404    /// # use aws_smithy_runtime_api::{
405    /// #     client::{
406    /// #         auth::AuthSchemeOptionsFuture,
407    /// #         runtime_components::RuntimeComponents,
408    /// #   },
409    /// # };
410    /// # use aws_smithy_types::config_bag::ConfigBag;
411    /// #[derive(Debug)]
412    /// struct CustomAuthSchemeResolver;
413    /// impl aws_sdk_appmesh::config::auth::ResolveAuthScheme for CustomAuthSchemeResolver {
414    ///     fn resolve_auth_scheme<'a>(
415    ///         &'a self,
416    ///         _params: &'a aws_sdk_appmesh::config::auth::Params,
417    ///         _cfg: &'a ConfigBag,
418    ///         _runtime_components: &'a RuntimeComponents,
419    ///     ) -> AuthSchemeOptionsFuture<'a> {
420    ///         // --snip--
421    /// #      todo!()
422    ///     }
423    /// }
424    ///
425    /// let config = aws_sdk_appmesh::Config::builder()
426    ///     .auth_scheme_resolver(CustomAuthSchemeResolver)
427    ///     // other configurations
428    ///     .build();
429    /// ```
430    pub fn auth_scheme_resolver(mut self, auth_scheme_resolver: impl crate::config::auth::ResolveAuthScheme + 'static) -> Self {
431        self.set_auth_scheme_resolver(auth_scheme_resolver);
432        self
433    }
434
435    /// Set the auth scheme resolver for the builder
436    ///
437    /// # Examples
438    /// See an example for [`Self::auth_scheme_resolver`].
439    pub fn set_auth_scheme_resolver(&mut self, auth_scheme_resolver: impl crate::config::auth::ResolveAuthScheme + 'static) -> &mut Self {
440        self.runtime_components
441            .set_auth_scheme_option_resolver(::std::option::Option::Some(auth_scheme_resolver.into_shared_resolver()));
442        self
443    }
444    /// Sets the endpoint resolver to use when making requests.
445    ///
446    ///
447    /// When unset, the client will used a generated endpoint resolver based on the endpoint resolution
448    /// rules for `aws_sdk_appmesh`.
449    ///
450    ///
451    /// Note: setting an endpoint resolver will replace any endpoint URL that has been set.
452    /// This method accepts an endpoint resolver [specific to this service](crate::config::endpoint::ResolveEndpoint). If you want to
453    /// provide a shared endpoint resolver, use [`Self::set_endpoint_resolver`].
454    ///
455    /// # Examples
456    /// Create a custom endpoint resolver that resolves a different endpoing per-stage, e.g. staging vs. production.
457    /// ```no_run
458    /// use aws_sdk_appmesh::config::endpoint::{ResolveEndpoint, EndpointFuture, Params, Endpoint};
459    /// #[derive(Debug)]
460    /// struct StageResolver { stage: String }
461    /// impl ResolveEndpoint for StageResolver {
462    ///     fn resolve_endpoint(&self, params: &Params) -> EndpointFuture<'_> {
463    ///         let stage = &self.stage;
464    ///         EndpointFuture::ready(Ok(Endpoint::builder().url(format!("{stage}.myservice.com")).build()))
465    ///     }
466    /// }
467    /// let resolver = StageResolver { stage: std::env::var("STAGE").unwrap() };
468    /// let config = aws_sdk_appmesh::Config::builder().endpoint_resolver(resolver).build();
469    /// let client = aws_sdk_appmesh::Client::from_conf(config);
470    /// ```
471    pub fn endpoint_resolver(mut self, endpoint_resolver: impl crate::config::endpoint::ResolveEndpoint + 'static) -> Self {
472        self.set_endpoint_resolver(::std::option::Option::Some(endpoint_resolver.into_shared_resolver()));
473        self
474    }
475
476    /// Sets the endpoint resolver to use when making requests.
477    ///
478    ///
479    /// When unset, the client will used a generated endpoint resolver based on the endpoint resolution
480    /// rules for `aws_sdk_appmesh`.
481    ///
482    pub fn set_endpoint_resolver(
483        &mut self,
484        endpoint_resolver: ::std::option::Option<::aws_smithy_runtime_api::client::endpoint::SharedEndpointResolver>,
485    ) -> &mut Self {
486        self.runtime_components.set_endpoint_resolver(endpoint_resolver);
487        self
488    }
489    /// Set the retry_config for the builder
490    ///
491    /// # Examples
492    /// ```no_run
493    /// use aws_sdk_appmesh::config::Config;
494    /// use aws_sdk_appmesh::config::retry::RetryConfig;
495    ///
496    /// let retry_config = RetryConfig::standard().with_max_attempts(5);
497    /// let config = Config::builder().retry_config(retry_config).build();
498    /// ```
499    pub fn retry_config(mut self, retry_config: ::aws_smithy_types::retry::RetryConfig) -> Self {
500        self.set_retry_config(Some(retry_config));
501        self
502    }
503
504    /// Set the retry_config for the builder
505    ///
506    /// # Examples
507    /// ```no_run
508    /// use aws_sdk_appmesh::config::{Builder, Config};
509    /// use aws_sdk_appmesh::config::retry::RetryConfig;
510    ///
511    /// fn disable_retries(builder: &mut Builder) {
512    ///     let retry_config = RetryConfig::standard().with_max_attempts(1);
513    ///     builder.set_retry_config(Some(retry_config));
514    /// }
515    ///
516    /// let mut builder = Config::builder();
517    /// disable_retries(&mut builder);
518    /// let config = builder.build();
519    /// ```
520    pub fn set_retry_config(&mut self, retry_config: ::std::option::Option<::aws_smithy_types::retry::RetryConfig>) -> &mut Self {
521        retry_config.map(|r| self.config.store_put(r));
522        self
523    }
524    /// Set the sleep_impl for the builder
525    ///
526    /// # Examples
527    ///
528    /// ```no_run
529    /// use aws_sdk_appmesh::config::{AsyncSleep, Config, SharedAsyncSleep, Sleep};
530    ///
531    /// #[derive(Debug)]
532    /// pub struct ForeverSleep;
533    ///
534    /// impl AsyncSleep for ForeverSleep {
535    ///     fn sleep(&self, duration: std::time::Duration) -> Sleep {
536    ///         Sleep::new(std::future::pending())
537    ///     }
538    /// }
539    ///
540    /// let sleep_impl = SharedAsyncSleep::new(ForeverSleep);
541    /// let config = Config::builder().sleep_impl(sleep_impl).build();
542    /// ```
543    pub fn sleep_impl(mut self, sleep_impl: impl crate::config::AsyncSleep + 'static) -> Self {
544        self.set_sleep_impl(Some(::aws_smithy_runtime_api::shared::IntoShared::into_shared(sleep_impl)));
545        self
546    }
547
548    /// Set the sleep_impl for the builder
549    ///
550    /// # Examples
551    ///
552    /// ```no_run
553    /// use aws_sdk_appmesh::config::{AsyncSleep, Builder, Config, SharedAsyncSleep, Sleep};
554    ///
555    /// #[derive(Debug)]
556    /// pub struct ForeverSleep;
557    ///
558    /// impl AsyncSleep for ForeverSleep {
559    ///     fn sleep(&self, duration: std::time::Duration) -> Sleep {
560    ///         Sleep::new(std::future::pending())
561    ///     }
562    /// }
563    ///
564    /// fn set_never_ending_sleep_impl(builder: &mut Builder) {
565    ///     let sleep_impl = SharedAsyncSleep::new(ForeverSleep);
566    ///     builder.set_sleep_impl(Some(sleep_impl));
567    /// }
568    ///
569    /// let mut builder = Config::builder();
570    /// set_never_ending_sleep_impl(&mut builder);
571    /// let config = builder.build();
572    /// ```
573    pub fn set_sleep_impl(&mut self, sleep_impl: ::std::option::Option<crate::config::SharedAsyncSleep>) -> &mut Self {
574        self.runtime_components.set_sleep_impl(sleep_impl);
575        self
576    }
577    /// Set the timeout_config for the builder
578    ///
579    /// # Examples
580    ///
581    /// ```no_run
582    /// # use std::time::Duration;
583    /// use aws_sdk_appmesh::config::Config;
584    /// use aws_sdk_appmesh::config::timeout::TimeoutConfig;
585    ///
586    /// let timeout_config = TimeoutConfig::builder()
587    ///     .operation_attempt_timeout(Duration::from_secs(1))
588    ///     .build();
589    /// let config = Config::builder().timeout_config(timeout_config).build();
590    /// ```
591    pub fn timeout_config(mut self, timeout_config: ::aws_smithy_types::timeout::TimeoutConfig) -> Self {
592        self.set_timeout_config(Some(timeout_config));
593        self
594    }
595
596    /// Set the timeout_config for the builder.
597    ///
598    /// Setting this to `None` has no effect if another source of configuration has set timeouts. If you
599    /// are attempting to disable timeouts, use [`TimeoutConfig::disabled`](::aws_smithy_types::timeout::TimeoutConfig::disabled)
600    ///
601    ///
602    /// # Examples
603    ///
604    /// ```no_run
605    /// # use std::time::Duration;
606    /// use aws_sdk_appmesh::config::{Builder, Config};
607    /// use aws_sdk_appmesh::config::timeout::TimeoutConfig;
608    ///
609    /// fn set_request_timeout(builder: &mut Builder) {
610    ///     let timeout_config = TimeoutConfig::builder()
611    ///         .operation_attempt_timeout(Duration::from_secs(1))
612    ///         .build();
613    ///     builder.set_timeout_config(Some(timeout_config));
614    /// }
615    ///
616    /// let mut builder = Config::builder();
617    /// set_request_timeout(&mut builder);
618    /// let config = builder.build();
619    /// ```
620    pub fn set_timeout_config(&mut self, timeout_config: ::std::option::Option<::aws_smithy_types::timeout::TimeoutConfig>) -> &mut Self {
621        // passing None has no impact.
622        let Some(mut timeout_config) = timeout_config else { return self };
623
624        if let Some(base) = self.config.load::<::aws_smithy_types::timeout::TimeoutConfig>() {
625            timeout_config.take_defaults_from(base);
626        }
627        self.config.store_put(timeout_config);
628        self
629    }
630    /// Set the partition for retry-related state. When clients share a retry partition, they will
631    /// also share things like token buckets and client rate limiters. By default, all clients
632    /// for the same service will share a partition.
633    pub fn retry_partition(mut self, retry_partition: ::aws_smithy_runtime::client::retries::RetryPartition) -> Self {
634        self.set_retry_partition(Some(retry_partition));
635        self
636    }
637    /// Set the partition for retry-related state. When clients share a retry partition, they will
638    /// also share things like token buckets and client rate limiters. By default, all clients
639    /// for the same service will share a partition.
640    pub fn set_retry_partition(
641        &mut self,
642        retry_partition: ::std::option::Option<::aws_smithy_runtime::client::retries::RetryPartition>,
643    ) -> &mut Self {
644        retry_partition.map(|r| self.config.store_put(r));
645        self
646    }
647    /// Set the identity cache for auth.
648    ///
649    /// The identity cache defaults to a lazy caching implementation that will resolve
650    /// an identity when it is requested, and place it in the cache thereafter. Subsequent
651    /// requests will take the value from the cache while it is still valid. Once it expires,
652    /// the next request will result in refreshing the identity.
653    ///
654    /// This configuration allows you to disable or change the default caching mechanism.
655    /// To use a custom caching mechanism, implement the [`ResolveCachedIdentity`](crate::config::ResolveCachedIdentity)
656    /// trait and pass that implementation into this function.
657    ///
658    /// # Examples
659    ///
660    /// Disabling identity caching:
661    /// ```no_run
662    /// use aws_sdk_appmesh::config::IdentityCache;
663    ///
664    /// let config = aws_sdk_appmesh::Config::builder()
665    ///     .identity_cache(IdentityCache::no_cache())
666    ///     // ...
667    ///     .build();
668    /// let client = aws_sdk_appmesh::Client::from_conf(config);
669    /// ```
670    ///
671    /// Customizing lazy caching:
672    /// ```no_run
673    /// use aws_sdk_appmesh::config::IdentityCache;
674    /// use std::time::Duration;
675    ///
676    /// let config = aws_sdk_appmesh::Config::builder()
677    ///     .identity_cache(
678    ///         IdentityCache::lazy()
679    ///             // change the load timeout to 10 seconds
680    ///             .load_timeout(Duration::from_secs(10))
681    ///             .build()
682    ///     )
683    ///     // ...
684    ///     .build();
685    /// let client = aws_sdk_appmesh::Client::from_conf(config);
686    /// ```
687    ///
688    pub fn identity_cache(mut self, identity_cache: impl crate::config::ResolveCachedIdentity + 'static) -> Self {
689        self.set_identity_cache(identity_cache);
690        self
691    }
692
693    /// Set the identity cache for auth.
694    ///
695    /// The identity cache defaults to a lazy caching implementation that will resolve
696    /// an identity when it is requested, and place it in the cache thereafter. Subsequent
697    /// requests will take the value from the cache while it is still valid. Once it expires,
698    /// the next request will result in refreshing the identity.
699    ///
700    /// This configuration allows you to disable or change the default caching mechanism.
701    /// To use a custom caching mechanism, implement the [`ResolveCachedIdentity`](crate::config::ResolveCachedIdentity)
702    /// trait and pass that implementation into this function.
703    ///
704    /// # Examples
705    ///
706    /// Disabling identity caching:
707    /// ```no_run
708    /// use aws_sdk_appmesh::config::IdentityCache;
709    ///
710    /// let config = aws_sdk_appmesh::Config::builder()
711    ///     .identity_cache(IdentityCache::no_cache())
712    ///     // ...
713    ///     .build();
714    /// let client = aws_sdk_appmesh::Client::from_conf(config);
715    /// ```
716    ///
717    /// Customizing lazy caching:
718    /// ```no_run
719    /// use aws_sdk_appmesh::config::IdentityCache;
720    /// use std::time::Duration;
721    ///
722    /// let config = aws_sdk_appmesh::Config::builder()
723    ///     .identity_cache(
724    ///         IdentityCache::lazy()
725    ///             // change the load timeout to 10 seconds
726    ///             .load_timeout(Duration::from_secs(10))
727    ///             .build()
728    ///     )
729    ///     // ...
730    ///     .build();
731    /// let client = aws_sdk_appmesh::Client::from_conf(config);
732    /// ```
733    ///
734    pub fn set_identity_cache(&mut self, identity_cache: impl crate::config::ResolveCachedIdentity + 'static) -> &mut Self {
735        self.runtime_components.set_identity_cache(::std::option::Option::Some(identity_cache));
736        self
737    }
738    /// Add an [interceptor](crate::config::Intercept) that runs at specific stages of the request execution pipeline.
739    ///
740    /// Interceptors targeted at a certain stage are executed according to the pre-defined priority.
741    /// The SDK provides a default set of interceptors. An interceptor configured by this method
742    /// will run after those default interceptors.
743    ///
744    /// # Examples
745    /// ```no_run
746    /// # fn example() {
747    /// use aws_smithy_runtime_api::box_error::BoxError;
748    /// use aws_smithy_runtime_api::client::interceptors::context::BeforeTransmitInterceptorContextMut;
749    /// use aws_smithy_runtime_api::client::interceptors::Intercept;
750    /// use aws_smithy_runtime_api::client::runtime_components::RuntimeComponents;
751    /// use aws_smithy_types::config_bag::ConfigBag;
752    /// use aws_sdk_appmesh::config::Config;
753    /// use ::http::uri::Uri;
754    ///
755    /// fn base_url() -> String {
756    ///     // ...
757    ///     # String::new()
758    /// }
759    ///
760    /// #[derive(Debug)]
761    /// pub struct UriModifierInterceptor;
762    /// impl Intercept for UriModifierInterceptor {
763    ///     fn name(&self) -> &'static str {
764    ///         "UriModifierInterceptor"
765    ///     }
766    ///     fn modify_before_signing(
767    ///         &self,
768    ///         context: &mut BeforeTransmitInterceptorContextMut<'_>,
769    ///         _runtime_components: &RuntimeComponents,
770    ///         _cfg: &mut ConfigBag,
771    ///     ) -> Result<(), BoxError> {
772    ///         let request = context.request_mut();
773    ///         let uri = format!("{}{}", base_url(), request.uri());
774    ///         *request.uri_mut() = uri.parse::<Uri>()?.into();
775    ///
776    ///         Ok(())
777    ///     }
778    /// }
779    ///
780    /// let config = Config::builder()
781    ///     .interceptor(UriModifierInterceptor)
782    ///     .build();
783    /// # }
784    /// ```
785    pub fn interceptor(mut self, interceptor: impl crate::config::Intercept + 'static) -> Self {
786        self.push_interceptor(crate::config::SharedInterceptor::new(interceptor));
787        self
788    }
789
790    /// Like [`Self::interceptor`], but takes a [`SharedInterceptor`](crate::config::SharedInterceptor).
791    pub fn push_interceptor(&mut self, interceptor: crate::config::SharedInterceptor) -> &mut Self {
792        self.runtime_components.push_interceptor(interceptor);
793        self
794    }
795
796    /// Set [`SharedInterceptor`](crate::config::SharedInterceptor)s for the builder.
797    pub fn set_interceptors(&mut self, interceptors: impl IntoIterator<Item = crate::config::SharedInterceptor>) -> &mut Self {
798        self.runtime_components.set_interceptors(interceptors.into_iter());
799        self
800    }
801    /// Sets the time source used for this service
802    pub fn time_source(mut self, time_source: impl ::aws_smithy_async::time::TimeSource + 'static) -> Self {
803        self.set_time_source(::std::option::Option::Some(::aws_smithy_runtime_api::shared::IntoShared::into_shared(
804            time_source,
805        )));
806        self
807    }
808    /// Sets the time source used for this service
809    pub fn set_time_source(&mut self, time_source: ::std::option::Option<::aws_smithy_async::time::SharedTimeSource>) -> &mut Self {
810        self.runtime_components.set_time_source(time_source);
811        self
812    }
813    /// Add type implementing [`ClassifyRetry`](::aws_smithy_runtime_api::client::retries::classifiers::ClassifyRetry) that will be used by the
814    /// [`RetryStrategy`](::aws_smithy_runtime_api::client::retries::RetryStrategy) to determine what responses should be retried.
815    ///
816    /// A retry classifier configured by this method will run according to its [priority](::aws_smithy_runtime_api::client::retries::classifiers::RetryClassifierPriority).
817    ///
818    /// # Examples
819    /// ```no_run
820    /// # fn example() {
821    /// use aws_smithy_runtime_api::client::interceptors::context::InterceptorContext;
822    /// use aws_smithy_runtime_api::client::orchestrator::OrchestratorError;
823    /// use aws_smithy_runtime_api::client::retries::classifiers::{
824    ///     ClassifyRetry, RetryAction, RetryClassifierPriority,
825    /// };
826    /// use aws_smithy_types::error::metadata::ProvideErrorMetadata;
827    /// use aws_smithy_types::retry::ErrorKind;
828    /// use std::error::Error as StdError;
829    /// use std::marker::PhantomData;
830    /// use std::fmt;
831    /// use aws_sdk_appmesh::config::Config;
832    /// # #[derive(Debug)]
833    /// # struct SomeOperationError {}
834    /// # impl StdError for SomeOperationError {}
835    /// # impl fmt::Display for SomeOperationError {
836    /// #    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { todo!() }
837    /// # }
838    /// # impl ProvideErrorMetadata for SomeOperationError {
839    /// #    fn meta(&self) -> &aws_sdk_appmesh::error::ErrorMetadata { todo!() }
840    /// # }
841    ///
842    /// const RETRYABLE_ERROR_CODES: &[&str] = &[
843    ///     // List error codes to be retried here...
844    /// ];
845    ///
846    /// // When classifying at an operation's error type, classifiers require a generic parameter.
847    /// // When classifying the HTTP response alone, no generic is needed.
848    /// #[derive(Debug, Default)]
849    /// pub struct ExampleErrorCodeClassifier<E> {
850    ///     _inner: PhantomData<E>,
851    /// }
852    ///
853    /// impl<E> ExampleErrorCodeClassifier<E> {
854    ///     pub fn new() -> Self {
855    ///         Self {
856    ///             _inner: PhantomData,
857    ///         }
858    ///     }
859    /// }
860    ///
861    /// impl<E> ClassifyRetry for ExampleErrorCodeClassifier<E>
862    /// where
863    ///     // Adding a trait bound for ProvideErrorMetadata allows us to inspect the error code.
864    ///     E: StdError + ProvideErrorMetadata + Send + Sync + 'static,
865    /// {
866    ///     fn classify_retry(&self, ctx: &InterceptorContext) -> RetryAction {
867    ///         // Check for a result
868    ///         let output_or_error = ctx.output_or_error();
869    ///         // Check for an error
870    ///         let error = match output_or_error {
871    ///             Some(Ok(_)) | None => return RetryAction::NoActionIndicated,
872    ///               Some(Err(err)) => err,
873    ///         };
874    ///
875    ///         // Downcast the generic error and extract the code
876    ///         let error_code = OrchestratorError::as_operation_error(error)
877    ///             .and_then(|err| err.downcast_ref::<E>())
878    ///             .and_then(|err| err.code());
879    ///
880    ///         // If this error's code is in our list, return an action that tells the RetryStrategy to retry this request.
881    ///         if let Some(error_code) = error_code {
882    ///             if RETRYABLE_ERROR_CODES.contains(&error_code) {
883    ///                 return RetryAction::transient_error();
884    ///             }
885    ///         }
886    ///
887    ///         // Otherwise, return that no action is indicated i.e. that this classifier doesn't require a retry.
888    ///         // Another classifier may still classify this response as retryable.
889    ///         RetryAction::NoActionIndicated
890    ///     }
891    ///
892    ///     fn name(&self) -> &'static str { "Example Error Code Classifier" }
893    /// }
894    ///
895    /// let config = Config::builder()
896    ///     .retry_classifier(ExampleErrorCodeClassifier::<SomeOperationError>::new())
897    ///     .build();
898    /// # }
899    /// ```
900    pub fn retry_classifier(
901        mut self,
902        retry_classifier: impl ::aws_smithy_runtime_api::client::retries::classifiers::ClassifyRetry + 'static,
903    ) -> Self {
904        self.push_retry_classifier(::aws_smithy_runtime_api::client::retries::classifiers::SharedRetryClassifier::new(
905            retry_classifier,
906        ));
907        self
908    }
909
910    /// Like [`Self::retry_classifier`], but takes a [`SharedRetryClassifier`](::aws_smithy_runtime_api::client::retries::classifiers::SharedRetryClassifier).
911    pub fn push_retry_classifier(
912        &mut self,
913        retry_classifier: ::aws_smithy_runtime_api::client::retries::classifiers::SharedRetryClassifier,
914    ) -> &mut Self {
915        self.runtime_components.push_retry_classifier(retry_classifier);
916        self
917    }
918
919    /// Set [`SharedRetryClassifier`](::aws_smithy_runtime_api::client::retries::classifiers::SharedRetryClassifier)s for the builder, replacing any that
920    /// were previously set.
921    pub fn set_retry_classifiers(
922        &mut self,
923        retry_classifiers: impl IntoIterator<Item = ::aws_smithy_runtime_api::client::retries::classifiers::SharedRetryClassifier>,
924    ) -> &mut Self {
925        self.runtime_components.set_retry_classifiers(retry_classifiers.into_iter());
926        self
927    }
928    /// Sets the name of the app that is using the client.
929    ///
930    /// This _optional_ name is used to identify the application in the user agent that
931    /// gets sent along with requests.
932    pub fn app_name(mut self, app_name: ::aws_types::app_name::AppName) -> Self {
933        self.set_app_name(Some(app_name));
934        self
935    }
936    /// Sets the name of the app that is using the client.
937    ///
938    /// This _optional_ name is used to identify the application in the user agent that
939    /// gets sent along with requests.
940    pub fn set_app_name(&mut self, app_name: ::std::option::Option<::aws_types::app_name::AppName>) -> &mut Self {
941        self.config.store_or_unset(app_name);
942        self
943    }
944    /// Overrides the default invocation ID generator.
945    ///
946    /// 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.
947    pub fn invocation_id_generator(mut self, gen: impl ::aws_runtime::invocation_id::InvocationIdGenerator + 'static) -> Self {
948        self.set_invocation_id_generator(::std::option::Option::Some(
949            ::aws_runtime::invocation_id::SharedInvocationIdGenerator::new(gen),
950        ));
951        self
952    }
953    /// Overrides the default invocation ID generator.
954    ///
955    /// 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.
956    pub fn set_invocation_id_generator(
957        &mut self,
958        gen: ::std::option::Option<::aws_runtime::invocation_id::SharedInvocationIdGenerator>,
959    ) -> &mut Self {
960        self.config.store_or_unset(gen);
961        self
962    }
963    /// Sets the endpoint URL used to communicate with this service.
964    ///
965    /// Note: this is used in combination with other endpoint rules, e.g. an API that applies a host-label prefix
966    /// will be prefixed onto this URL. To fully override the endpoint resolver, use
967    /// [`Builder::endpoint_resolver`].
968    pub fn endpoint_url(mut self, endpoint_url: impl Into<::std::string::String>) -> Self {
969        self.set_endpoint_url(Some(endpoint_url.into()));
970        self
971    }
972    /// Sets the endpoint URL used to communicate with this service.
973    ///
974    /// Note: this is used in combination with other endpoint rules, e.g. an API that applies a host-label prefix
975    /// will be prefixed onto this URL. To fully override the endpoint resolver, use
976    /// [`Builder::endpoint_resolver`].
977    pub fn set_endpoint_url(&mut self, endpoint_url: Option<::std::string::String>) -> &mut Self {
978        self.config.store_or_unset(endpoint_url.map(::aws_types::endpoint_config::EndpointUrl));
979        self
980    }
981    /// When true, use the dual-stack endpoint. If the configured endpoint does not support dual-stack, dispatching the request MAY return an error.
982    pub fn use_dual_stack(mut self, use_dual_stack: impl Into<bool>) -> Self {
983        self.set_use_dual_stack(Some(use_dual_stack.into()));
984        self
985    }
986    /// When true, use the dual-stack endpoint. If the configured endpoint does not support dual-stack, dispatching the request MAY return an error.
987    pub fn set_use_dual_stack(&mut self, use_dual_stack: Option<bool>) -> &mut Self {
988        self.config.store_or_unset(use_dual_stack.map(::aws_types::endpoint_config::UseDualStack));
989        self
990    }
991    /// 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.
992    pub fn use_fips(mut self, use_fips: impl Into<bool>) -> Self {
993        self.set_use_fips(Some(use_fips.into()));
994        self
995    }
996    /// 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.
997    pub fn set_use_fips(&mut self, use_fips: Option<bool>) -> &mut Self {
998        self.config.store_or_unset(use_fips.map(::aws_types::endpoint_config::UseFips));
999        self
1000    }
1001    /// Sets the AWS region to use when making requests.
1002    ///
1003    /// # Examples
1004    /// ```no_run
1005    /// use aws_types::region::Region;
1006    /// use aws_sdk_appmesh::config::{Builder, Config};
1007    ///
1008    /// let config = aws_sdk_appmesh::Config::builder()
1009    ///     .region(Region::new("us-east-1"))
1010    ///     .build();
1011    /// ```
1012    pub fn region(mut self, region: impl ::std::convert::Into<::std::option::Option<crate::config::Region>>) -> Self {
1013        self.set_region(region.into());
1014        self
1015    }
1016    /// Sets the AWS region to use when making requests.
1017    pub fn set_region(&mut self, region: ::std::option::Option<crate::config::Region>) -> &mut Self {
1018        self.config.store_or_unset(region);
1019        self
1020    }
1021    /// Sets the credentials provider for this service
1022    pub fn credentials_provider(mut self, credentials_provider: impl crate::config::ProvideCredentials + 'static) -> Self {
1023        self.set_credentials_provider(::std::option::Option::Some(crate::config::SharedCredentialsProvider::new(
1024            credentials_provider,
1025        )));
1026        self
1027    }
1028    /// Sets the credentials provider for this service
1029    pub fn set_credentials_provider(&mut self, credentials_provider: ::std::option::Option<crate::config::SharedCredentialsProvider>) -> &mut Self {
1030        if let Some(credentials_provider) = credentials_provider {
1031            self.runtime_components
1032                .set_identity_resolver(::aws_runtime::auth::sigv4::SCHEME_ID, credentials_provider);
1033        }
1034        self
1035    }
1036    /// Sets the [`behavior major version`](crate::config::BehaviorVersion).
1037    ///
1038    /// Over time, new best-practice behaviors are introduced. However, these behaviors might not be backwards
1039    /// compatible. For example, a change which introduces new default timeouts or a new retry-mode for
1040    /// all operations might be the ideal behavior but could break existing applications.
1041    ///
1042    /// # Examples
1043    ///
1044    /// Set the behavior major version to `latest`. This is equivalent to enabling the `behavior-version-latest` cargo feature.
1045    /// ```no_run
1046    /// use aws_sdk_appmesh::config::BehaviorVersion;
1047    ///
1048    /// let config = aws_sdk_appmesh::Config::builder()
1049    ///     .behavior_version(BehaviorVersion::latest())
1050    ///     // ...
1051    ///     .build();
1052    /// let client = aws_sdk_appmesh::Client::from_conf(config);
1053    /// ```
1054    ///
1055    /// Customizing behavior major version:
1056    /// ```no_run
1057    /// use aws_sdk_appmesh::config::BehaviorVersion;
1058    ///
1059    /// let config = aws_sdk_appmesh::Config::builder()
1060    ///     .behavior_version(BehaviorVersion::v2023_11_09())
1061    ///     // ...
1062    ///     .build();
1063    /// let client = aws_sdk_appmesh::Client::from_conf(config);
1064    /// ```
1065    ///
1066    pub fn behavior_version(mut self, behavior_version: crate::config::BehaviorVersion) -> Self {
1067        self.set_behavior_version(Some(behavior_version));
1068        self
1069    }
1070
1071    /// Sets the [`behavior major version`](crate::config::BehaviorVersion).
1072    ///
1073    /// Over time, new best-practice behaviors are introduced. However, these behaviors might not be backwards
1074    /// compatible. For example, a change which introduces new default timeouts or a new retry-mode for
1075    /// all operations might be the ideal behavior but could break existing applications.
1076    ///
1077    /// # Examples
1078    ///
1079    /// Set the behavior major version to `latest`. This is equivalent to enabling the `behavior-version-latest` cargo feature.
1080    /// ```no_run
1081    /// use aws_sdk_appmesh::config::BehaviorVersion;
1082    ///
1083    /// let config = aws_sdk_appmesh::Config::builder()
1084    ///     .behavior_version(BehaviorVersion::latest())
1085    ///     // ...
1086    ///     .build();
1087    /// let client = aws_sdk_appmesh::Client::from_conf(config);
1088    /// ```
1089    ///
1090    /// Customizing behavior major version:
1091    /// ```no_run
1092    /// use aws_sdk_appmesh::config::BehaviorVersion;
1093    ///
1094    /// let config = aws_sdk_appmesh::Config::builder()
1095    ///     .behavior_version(BehaviorVersion::v2023_11_09())
1096    ///     // ...
1097    ///     .build();
1098    /// let client = aws_sdk_appmesh::Client::from_conf(config);
1099    /// ```
1100    ///
1101    pub fn set_behavior_version(&mut self, behavior_version: Option<crate::config::BehaviorVersion>) -> &mut Self {
1102        self.behavior_version = behavior_version;
1103        self
1104    }
1105
1106    /// Convenience method to set the latest behavior major version
1107    ///
1108    /// This is equivalent to enabling the `behavior-version-latest` Cargo feature
1109    pub fn behavior_version_latest(mut self) -> Self {
1110        self.set_behavior_version(Some(crate::config::BehaviorVersion::latest()));
1111        self
1112    }
1113    /// Adds a runtime plugin to the config.
1114    #[allow(unused)]
1115    pub(crate) fn runtime_plugin(mut self, plugin: impl crate::config::RuntimePlugin + 'static) -> Self {
1116        self.push_runtime_plugin(crate::config::SharedRuntimePlugin::new(plugin));
1117        self
1118    }
1119    /// Adds a runtime plugin to the config.
1120    #[allow(unused)]
1121    pub(crate) fn push_runtime_plugin(&mut self, plugin: crate::config::SharedRuntimePlugin) -> &mut Self {
1122        self.runtime_plugins.push(plugin);
1123        self
1124    }
1125    #[cfg(any(feature = "test-util", test))]
1126    #[allow(unused_mut)]
1127    /// Apply test defaults to the builder
1128    pub fn apply_test_defaults(&mut self) -> &mut Self {
1129        self.set_idempotency_token_provider(Some("00000000-0000-4000-8000-000000000000".into()));
1130        self.set_time_source(::std::option::Option::Some(::aws_smithy_async::time::SharedTimeSource::new(
1131            ::aws_smithy_async::time::StaticTimeSource::new(::std::time::UNIX_EPOCH + ::std::time::Duration::from_secs(1234567890)),
1132        )));
1133        self.config.store_put(::aws_runtime::user_agent::AwsUserAgent::for_tests());
1134        self.set_credentials_provider(Some(crate::config::SharedCredentialsProvider::new(
1135            ::aws_credential_types::Credentials::for_tests(),
1136        )));
1137        self.behavior_version = ::std::option::Option::Some(crate::config::BehaviorVersion::latest());
1138        self
1139    }
1140    #[cfg(any(feature = "test-util", test))]
1141    #[allow(unused_mut)]
1142    /// Apply test defaults to the builder
1143    pub fn with_test_defaults(mut self) -> Self {
1144        self.apply_test_defaults();
1145        self
1146    }
1147    /// Builds a [`Config`].
1148    #[allow(unused_mut)]
1149    pub fn build(mut self) -> Config {
1150        let mut layer = self.config;
1151        if self.runtime_components.time_source().is_none() {
1152            self.runtime_components
1153                .set_time_source(::std::option::Option::Some(::std::default::Default::default()));
1154        }
1155        layer.store_put(crate::meta::API_METADATA.clone());
1156        layer.store_put(::aws_types::SigningName::from_static("appmesh"));
1157        layer
1158            .load::<::aws_types::region::Region>()
1159            .cloned()
1160            .map(|r| layer.store_put(::aws_types::region::SigningRegion::from(r)));
1161        Config {
1162            config: crate::config::Layer::from(layer.clone())
1163                .with_name("aws_sdk_appmesh::config::Config")
1164                .freeze(),
1165            cloneable: layer,
1166            runtime_components: self.runtime_components,
1167            runtime_plugins: self.runtime_plugins,
1168            behavior_version: self.behavior_version,
1169        }
1170    }
1171}
1172#[derive(::std::fmt::Debug)]
1173pub(crate) struct ServiceRuntimePlugin {
1174    config: ::std::option::Option<::aws_smithy_types::config_bag::FrozenLayer>,
1175    runtime_components: ::aws_smithy_runtime_api::client::runtime_components::RuntimeComponentsBuilder,
1176}
1177
1178impl ServiceRuntimePlugin {
1179    pub fn new(_service_config: crate::config::Config) -> Self {
1180        let config = {
1181            let mut cfg = ::aws_smithy_types::config_bag::Layer::new("AppMesh");
1182            cfg.store_put(crate::idempotency_token::default_provider());
1183            cfg.store_put(::aws_smithy_runtime::client::orchestrator::AuthSchemeAndEndpointOrchestrationV2);
1184            ::std::option::Option::Some(cfg.freeze())
1185        };
1186        let mut runtime_components = ::aws_smithy_runtime_api::client::runtime_components::RuntimeComponentsBuilder::new("ServiceRuntimePlugin");
1187        runtime_components.set_auth_scheme_option_resolver(::std::option::Option::Some({
1188            use crate::config::auth::ResolveAuthScheme;
1189            crate::config::auth::DefaultAuthSchemeResolver::default().into_shared_resolver()
1190        }));
1191        runtime_components.set_endpoint_resolver(::std::option::Option::Some({
1192            use crate::config::endpoint::ResolveEndpoint;
1193            crate::config::endpoint::DefaultResolver::new().into_shared_resolver()
1194        }));
1195        runtime_components.push_interceptor(::aws_smithy_runtime::client::http::connection_poisoning::ConnectionPoisoningInterceptor::new());
1196        runtime_components.push_retry_classifier(::aws_smithy_runtime::client::retries::classifiers::HttpStatusCodeClassifier::default());
1197        runtime_components.push_interceptor(crate::sdk_feature_tracker::retry_mode::RetryModeFeatureTrackerInterceptor::new());
1198        runtime_components.push_interceptor(::aws_runtime::service_clock_skew::ServiceClockSkewInterceptor::new());
1199        runtime_components.push_interceptor(::aws_runtime::request_info::RequestInfoInterceptor::new());
1200        runtime_components.push_interceptor(::aws_runtime::user_agent::UserAgentInterceptor::new());
1201        runtime_components.push_interceptor(::aws_runtime::invocation_id::InvocationIdInterceptor::new());
1202        runtime_components.push_interceptor(::aws_runtime::recursion_detection::RecursionDetectionInterceptor::new());
1203        runtime_components.push_auth_scheme(::aws_smithy_runtime_api::client::auth::SharedAuthScheme::new(
1204            ::aws_runtime::auth::sigv4::SigV4AuthScheme::new(),
1205        ));
1206        Self { config, runtime_components }
1207    }
1208}
1209
1210impl ::aws_smithy_runtime_api::client::runtime_plugin::RuntimePlugin for ServiceRuntimePlugin {
1211    fn config(&self) -> ::std::option::Option<::aws_smithy_types::config_bag::FrozenLayer> {
1212        self.config.clone()
1213    }
1214
1215    fn order(&self) -> ::aws_smithy_runtime_api::client::runtime_plugin::Order {
1216        ::aws_smithy_runtime_api::client::runtime_plugin::Order::Defaults
1217    }
1218
1219    fn runtime_components(
1220        &self,
1221        _: &::aws_smithy_runtime_api::client::runtime_components::RuntimeComponentsBuilder,
1222    ) -> ::std::borrow::Cow<'_, ::aws_smithy_runtime_api::client::runtime_components::RuntimeComponentsBuilder> {
1223        ::std::borrow::Cow::Borrowed(&self.runtime_components)
1224    }
1225}
1226
1227// Cross-operation shared-state singletons
1228
1229/// A plugin that enables configuration for a single operation invocation
1230///
1231/// The `config` method will return a `FrozenLayer` by storing values from `config_override`.
1232/// In the case of default values requested, they will be obtained from `client_config`.
1233#[derive(Debug)]
1234pub(crate) struct ConfigOverrideRuntimePlugin {
1235    pub(crate) config: ::aws_smithy_types::config_bag::FrozenLayer,
1236    pub(crate) components: ::aws_smithy_runtime_api::client::runtime_components::RuntimeComponentsBuilder,
1237}
1238
1239impl ConfigOverrideRuntimePlugin {
1240    #[allow(dead_code)] // unused when a service does not provide any operations
1241    pub(crate) fn new(
1242        config_override: Builder,
1243        initial_config: ::aws_smithy_types::config_bag::FrozenLayer,
1244        initial_components: &::aws_smithy_runtime_api::client::runtime_components::RuntimeComponentsBuilder,
1245    ) -> Self {
1246        let mut layer = config_override.config;
1247        let mut components = config_override.runtime_components;
1248        #[allow(unused_mut)]
1249        let mut resolver =
1250            ::aws_smithy_runtime::client::config_override::Resolver::overrid(initial_config, initial_components, &mut layer, &mut components);
1251
1252        resolver
1253            .config_mut()
1254            .load::<::aws_types::region::Region>()
1255            .cloned()
1256            .map(|r| resolver.config_mut().store_put(::aws_types::region::SigningRegion::from(r)));
1257
1258        let _ = resolver;
1259        Self {
1260            config: ::aws_smithy_types::config_bag::Layer::from(layer)
1261                .with_name("aws_sdk_appmesh::config::ConfigOverrideRuntimePlugin")
1262                .freeze(),
1263            components,
1264        }
1265    }
1266}
1267
1268impl ::aws_smithy_runtime_api::client::runtime_plugin::RuntimePlugin for ConfigOverrideRuntimePlugin {
1269    fn config(&self) -> ::std::option::Option<::aws_smithy_types::config_bag::FrozenLayer> {
1270        Some(self.config.clone())
1271    }
1272
1273    fn runtime_components(
1274        &self,
1275        _: &::aws_smithy_runtime_api::client::runtime_components::RuntimeComponentsBuilder,
1276    ) -> ::std::borrow::Cow<'_, ::aws_smithy_runtime_api::client::runtime_components::RuntimeComponentsBuilder> {
1277        ::std::borrow::Cow::Borrowed(&self.components)
1278    }
1279}
1280
1281pub use ::aws_smithy_runtime::client::identity::IdentityCache;
1282pub use ::aws_smithy_runtime_api::client::runtime_components::RuntimeComponents;
1283pub use ::aws_smithy_types::config_bag::ConfigBag;
1284
1285pub use ::aws_credential_types::Credentials;
1286
1287impl From<&::aws_types::sdk_config::SdkConfig> for Builder {
1288    fn from(input: &::aws_types::sdk_config::SdkConfig) -> Self {
1289        let mut builder = Builder::default();
1290        builder.set_credentials_provider(input.credentials_provider());
1291        builder = builder.region(input.region().cloned());
1292        builder.set_use_fips(input.use_fips());
1293        builder.set_use_dual_stack(input.use_dual_stack());
1294        if input.get_origin("endpoint_url").is_client_config() {
1295            builder.set_endpoint_url(input.endpoint_url().map(|s| s.to_string()));
1296        } else {
1297            builder.set_endpoint_url(
1298                input
1299                    .service_config()
1300                    .and_then(|conf| {
1301                        conf.load_config(service_config_key("AWS_ENDPOINT_URL", "endpoint_url"))
1302                            .map(|it| it.parse().unwrap())
1303                    })
1304                    .or_else(|| input.endpoint_url().map(|s| s.to_string())),
1305            );
1306        }
1307        // resiliency
1308        builder.set_retry_config(input.retry_config().cloned());
1309        builder.set_timeout_config(input.timeout_config().cloned());
1310        builder.set_sleep_impl(input.sleep_impl());
1311
1312        builder.set_http_client(input.http_client());
1313        builder.set_time_source(input.time_source());
1314        builder.set_behavior_version(input.behavior_version());
1315        // setting `None` here removes the default
1316        if let Some(config) = input.stalled_stream_protection() {
1317            builder.set_stalled_stream_protection(Some(config));
1318        }
1319
1320        if let Some(cache) = input.identity_cache() {
1321            builder.set_identity_cache(cache);
1322        }
1323        builder.set_app_name(input.app_name().cloned());
1324
1325        builder
1326    }
1327}
1328
1329impl From<&::aws_types::sdk_config::SdkConfig> for Config {
1330    fn from(sdk_config: &::aws_types::sdk_config::SdkConfig) -> Self {
1331        Builder::from(sdk_config).build()
1332    }
1333}
1334
1335pub use ::aws_types::app_name::AppName;
1336
1337#[allow(dead_code)]
1338fn service_config_key<'a>(env: &'a str, profile: &'a str) -> aws_types::service_config::ServiceConfigKey<'a> {
1339    ::aws_types::service_config::ServiceConfigKey::builder()
1340        .service_id("App Mesh")
1341        .env(env)
1342        .profile(profile)
1343        .build()
1344        .expect("all field sets explicitly, can't fail")
1345}
1346
1347pub use ::aws_smithy_async::rt::sleep::Sleep;
1348
1349pub(crate) fn base_client_runtime_plugins(mut config: crate::Config) -> ::aws_smithy_runtime_api::client::runtime_plugin::RuntimePlugins {
1350    let mut configured_plugins = ::std::vec::Vec::new();
1351    ::std::mem::swap(&mut config.runtime_plugins, &mut configured_plugins);
1352    #[cfg(feature = "behavior-version-latest")]
1353    {
1354        if config.behavior_version.is_none() {
1355            config.behavior_version = Some(::aws_smithy_runtime_api::client::behavior_version::BehaviorVersion::latest());
1356        }
1357    }
1358
1359    let default_retry_partition = "appmesh";
1360    let default_retry_partition = match config.region() {
1361        Some(region) => ::std::borrow::Cow::from(format!("{default_retry_partition}-{}", region)),
1362        None => ::std::borrow::Cow::from(default_retry_partition),
1363    };
1364
1365    let scope = "aws-sdk-appmesh";
1366
1367    let mut plugins = ::aws_smithy_runtime_api::client::runtime_plugin::RuntimePlugins::new()
1368                        // defaults
1369                        .with_client_plugins(::aws_smithy_runtime::client::defaults::default_plugins(
1370                            ::aws_smithy_runtime::client::defaults::DefaultPluginParams::new()
1371                                .with_retry_partition_name(default_retry_partition)
1372                                .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."))
1373                        ))
1374                        // user config
1375                        .with_client_plugin(
1376                            ::aws_smithy_runtime_api::client::runtime_plugin::StaticRuntimePlugin::new()
1377                                .with_config(config.config.clone())
1378                                .with_runtime_components(config.runtime_components.clone())
1379                        )
1380                        // codegen config
1381                        .with_client_plugin(crate::config::ServiceRuntimePlugin::new(config.clone()))
1382                        .with_client_plugin(::aws_smithy_runtime::client::auth::no_auth::NoAuthRuntimePlugin::new())
1383                        .with_client_plugin(
1384                            ::aws_smithy_runtime::client::metrics::MetricsRuntimePlugin::builder()
1385                                .with_scope(scope)
1386                                .with_time_source(config.runtime_components.time_source().unwrap_or_default())
1387                                .build()
1388                                .expect("All required fields have been set")
1389                        );
1390
1391    for plugin in configured_plugins {
1392        plugins = plugins.with_client_plugin(plugin);
1393    }
1394    plugins
1395}
1396
1397pub use ::aws_smithy_types::config_bag::FrozenLayer;
1398
1399pub use ::aws_smithy_runtime_api::client::runtime_components::RuntimeComponentsBuilder;
1400
1401pub use ::aws_smithy_runtime_api::client::runtime_plugin::SharedRuntimePlugin;
1402
1403pub use ::aws_smithy_runtime_api::client::behavior_version::BehaviorVersion;
1404
1405pub use ::aws_smithy_runtime_api::client::stalled_stream_protection::StalledStreamProtectionConfig;
1406
1407pub use ::aws_smithy_runtime_api::client::http::SharedHttpClient;
1408
1409pub use ::aws_smithy_async::rt::sleep::SharedAsyncSleep;
1410
1411pub use ::aws_smithy_runtime_api::client::identity::SharedIdentityCache;
1412
1413pub use ::aws_smithy_runtime_api::client::interceptors::SharedInterceptor;
1414
1415pub use ::aws_types::region::Region;
1416
1417pub use ::aws_credential_types::provider::SharedCredentialsProvider;
1418
1419pub use ::aws_smithy_runtime_api::client::http::HttpClient;
1420
1421pub use ::aws_smithy_runtime_api::shared::IntoShared;
1422
1423pub use ::aws_smithy_async::rt::sleep::AsyncSleep;
1424
1425pub use ::aws_smithy_runtime_api::client::identity::ResolveCachedIdentity;
1426
1427pub use ::aws_smithy_runtime_api::client::interceptors::Intercept;
1428
1429pub use ::aws_credential_types::provider::ProvideCredentials;
1430
1431pub use ::aws_smithy_runtime_api::client::runtime_plugin::RuntimePlugin;
1432
1433pub use ::aws_smithy_types::config_bag::Layer;
1434
1435/// Types needed to configure endpoint resolution.
1436pub mod endpoint;
1437
1438/// HTTP request and response types.
1439pub mod http;
1440
1441/// Types needed to implement [`Intercept`](crate::config::Intercept).
1442pub mod interceptors;
1443
1444/// Retry configuration.
1445pub mod retry;
1446
1447/// Timeout configuration.
1448pub mod timeout;
1449
1450/// Types needed to configure auth scheme resolution.
1451pub mod auth;