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