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