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