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