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