aws_sdk_dynamodb/
config.rs

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