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