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