aws_sdk_sso/
config.rs

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