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