aws_sdk_datazone/
config.rs

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