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