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