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