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