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