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