aws_sdk_secretsmanager/
config.rs

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