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