36 36 | ///
|
37 37 | pub fn builder() -> Builder {
|
38 38 | Builder::default()
|
39 39 | }
|
40 40 | /// Converts this config back into a builder so that it can be tweaked.
|
41 41 | pub fn to_builder(&self) -> Builder {
|
42 42 | Builder {
|
43 43 | config: self.cloneable.clone(),
|
44 44 | runtime_components: self.runtime_components.clone(),
|
45 45 | runtime_plugins: self.runtime_plugins.clone(),
|
46 46 | behavior_version: self.behavior_version,
|
47 47 | }
|
48 48 | }
|
49 49 | /// Return a reference to the stalled stream protection configuration contained in this config, if any.
|
50 50 | pub fn stalled_stream_protection(&self) -> ::std::option::Option<&crate::config::StalledStreamProtectionConfig> {
|
51 51 | self.config.load::<crate::config::StalledStreamProtectionConfig>()
|
52 52 | }
|
53 53 | /// Return the [`SharedHttpClient`](crate::config::SharedHttpClient) to use when making requests, if any.
|
54 54 | pub fn http_client(&self) -> Option<crate::config::SharedHttpClient> {
|
55 55 | self.runtime_components.http_client()
|
56 56 | }
|
57 57 | /// Return the auth schemes configured on this service config
|
58 58 | pub fn auth_schemes(&self) -> impl Iterator<Item = ::aws_smithy_runtime_api::client::auth::SharedAuthScheme> + '_ {
|
59 59 | self.runtime_components.auth_schemes()
|
60 60 | }
|
61 61 |
|
62 62 | /// Return the auth scheme resolver configured on this service config
|
63 63 | pub fn auth_scheme_resolver(&self) -> ::std::option::Option<::aws_smithy_runtime_api::client::auth::SharedAuthSchemeOptionResolver> {
|
64 64 | self.runtime_components.auth_scheme_option_resolver()
|
65 65 | }
|
66 + | /// Returns the configured auth scheme preference
|
67 + | pub fn auth_scheme_preference(&self) -> ::std::option::Option<&::aws_smithy_runtime_api::client::auth::AuthSchemePreference> {
|
68 + | self.config.load::<::aws_smithy_runtime_api::client::auth::AuthSchemePreference>()
|
69 + | }
|
66 70 | /// Returns the endpoint resolver.
|
67 71 | pub fn endpoint_resolver(&self) -> ::aws_smithy_runtime_api::client::endpoint::SharedEndpointResolver {
|
68 72 | self.runtime_components.endpoint_resolver().expect("resolver defaulted if not set")
|
69 73 | }
|
70 74 | /// Return a reference to the retry configuration contained in this config, if any.
|
71 75 | pub fn retry_config(&self) -> ::std::option::Option<&::aws_smithy_types::retry::RetryConfig> {
|
72 76 | self.config.load::<::aws_smithy_types::retry::RetryConfig>()
|
73 77 | }
|
74 78 |
|
75 79 | /// Return a cloned shared async sleep implementation from this config, if any.
|
76 80 | pub fn sleep_impl(&self) -> ::std::option::Option<crate::config::SharedAsyncSleep> {
|
77 81 | self.runtime_components.sleep_impl()
|
78 82 | }
|
79 83 |
|
80 84 | /// Return a reference to the timeout configuration contained in this config, if any.
|
81 85 | pub fn timeout_config(&self) -> ::std::option::Option<&::aws_smithy_types::timeout::TimeoutConfig> {
|
82 86 | self.config.load::<::aws_smithy_types::timeout::TimeoutConfig>()
|
83 87 | }
|
84 88 |
|
85 89 | /// Returns a reference to the retry partition contained in this config, if any.
|
86 90 | ///
|
87 91 | /// WARNING: This method is unstable and may be removed at any time. Do not rely on this
|
88 92 | /// method for anything!
|
89 93 | pub fn retry_partition(&self) -> ::std::option::Option<&::aws_smithy_runtime::client::retries::RetryPartition> {
|
90 94 | self.config.load::<::aws_smithy_runtime::client::retries::RetryPartition>()
|
91 95 | }
|
92 96 | /// Returns the configured identity cache for auth.
|
93 97 | pub fn identity_cache(&self) -> ::std::option::Option<crate::config::SharedIdentityCache> {
|
94 98 | self.runtime_components.identity_cache()
|
95 99 | }
|
149 153 | pub(crate) runtime_plugins: ::std::vec::Vec<crate::config::SharedRuntimePlugin>,
|
150 154 | pub(crate) behavior_version: ::std::option::Option<crate::config::BehaviorVersion>,
|
151 155 | }
|
152 156 | impl ::std::default::Default for Builder {
|
153 157 | fn default() -> Self {
|
154 158 | Self {
|
155 159 | config: ::std::default::Default::default(),
|
156 160 | runtime_components: crate::config::RuntimeComponentsBuilder::new("service config"),
|
157 161 | runtime_plugins: ::std::default::Default::default(),
|
158 162 | behavior_version: ::std::default::Default::default(),
|
159 163 | }
|
160 164 | }
|
161 165 | }
|
162 166 | impl Builder {
|
163 167 | ///
|
164 168 | /// Constructs a config builder.
|
165 169 | /// <div class="warning">
|
166 170 | /// Note that a config created from this builder will not have the same safe defaults as one created by
|
167 171 | /// the <a href="https://crates.io/crates/aws-config" target="_blank">aws-config</a> crate.
|
168 172 | /// </div>
|
169 173 | ///
|
170 174 | pub fn new() -> Self {
|
171 175 | Self::default()
|
172 176 | }
|
173 177 | /// Constructs a config builder from the given `config_bag`, setting only fields stored in the config bag,
|
174 178 | /// but not those in runtime components.
|
175 179 | #[allow(unused)]
|
176 180 | pub(crate) fn from_config_bag(config_bag: &::aws_smithy_types::config_bag::ConfigBag) -> Self {
|
177 181 | let mut builder = Self::new();
|
178 182 | builder.set_stalled_stream_protection(config_bag.load::<crate::config::StalledStreamProtectionConfig>().cloned());
|
183 + | builder.set_auth_scheme_preference(config_bag.load::<::aws_smithy_runtime_api::client::auth::AuthSchemePreference>().cloned());
|
179 184 | builder.set_retry_config(config_bag.load::<::aws_smithy_types::retry::RetryConfig>().cloned());
|
180 185 | builder.set_timeout_config(config_bag.load::<::aws_smithy_types::timeout::TimeoutConfig>().cloned());
|
181 186 | builder.set_retry_partition(config_bag.load::<::aws_smithy_runtime::client::retries::RetryPartition>().cloned());
|
182 187 | builder.set_app_name(config_bag.load::<::aws_types::app_name::AppName>().cloned());
|
183 188 | builder.set_account_id_endpoint_mode(config_bag.load::<::aws_types::endpoint_config::AccountIdEndpointMode>().cloned());
|
184 189 | builder.set_endpoint_url(config_bag.load::<::aws_types::endpoint_config::EndpointUrl>().map(|ty| ty.0.clone()));
|
185 190 | builder.set_use_dual_stack(config_bag.load::<::aws_types::endpoint_config::UseDualStack>().map(|ty| ty.0));
|
186 191 | builder.set_use_fips(config_bag.load::<::aws_types::endpoint_config::UseFips>().map(|ty| ty.0));
|
187 192 | builder.set_region(config_bag.load::<crate::config::Region>().cloned());
|
188 193 | builder
|
189 194 | }
|
190 195 | /// Set the [`StalledStreamProtectionConfig`](crate::config::StalledStreamProtectionConfig)
|
191 196 | /// to configure protection for stalled streams.
|
192 197 | pub fn stalled_stream_protection(mut self, stalled_stream_protection_config: crate::config::StalledStreamProtectionConfig) -> Self {
|
193 198 | self.set_stalled_stream_protection(::std::option::Option::Some(stalled_stream_protection_config));
|
194 199 | self
|
195 200 | }
|
196 201 | /// Set the [`StalledStreamProtectionConfig`](crate::config::StalledStreamProtectionConfig)
|
197 202 | /// to configure protection for stalled streams.
|
198 203 | pub fn set_stalled_stream_protection(
|
199 204 | &mut self,
|
200 205 | stalled_stream_protection_config: ::std::option::Option<crate::config::StalledStreamProtectionConfig>,
|
201 206 | ) -> &mut Self {
|
202 207 | self.config.store_or_unset(stalled_stream_protection_config);
|
203 208 | self
|
204 209 | }
|
205 210 | /// Sets the idempotency token provider to use for service calls that require tokens.
|
206 211 | pub fn idempotency_token_provider(
|
207 212 | mut self,
|
208 213 | idempotency_token_provider: impl ::std::convert::Into<crate::idempotency_token::IdempotencyTokenProvider>,
|
415 420 | /// fn resolve_auth_scheme<'a>(
|
416 421 | /// &'a self,
|
417 422 | /// _params: &'a aws_sdk_dynamodb::config::auth::Params,
|
418 423 | /// _cfg: &'a ConfigBag,
|
419 424 | /// _runtime_components: &'a RuntimeComponents,
|
420 425 | /// ) -> AuthSchemeOptionsFuture<'a> {
|
421 426 | /// // --snip--
|
422 427 | /// # todo!()
|
423 428 | /// }
|
424 429 | /// }
|
425 430 | ///
|
426 431 | /// let config = aws_sdk_dynamodb::Config::builder()
|
427 432 | /// .auth_scheme_resolver(CustomAuthSchemeResolver)
|
428 433 | /// // other configurations
|
429 434 | /// .build();
|
430 435 | /// ```
|
431 436 | pub fn auth_scheme_resolver(mut self, auth_scheme_resolver: impl crate::config::auth::ResolveAuthScheme + 'static) -> Self {
|
432 437 | self.set_auth_scheme_resolver(auth_scheme_resolver);
|
433 438 | self
|
434 439 | }
|
435 440 |
|
436 441 | /// Set the auth scheme resolver for the builder
|
437 442 | ///
|
438 443 | /// # Examples
|
439 444 | /// See an example for [`Self::auth_scheme_resolver`].
|
440 445 | pub fn set_auth_scheme_resolver(&mut self, auth_scheme_resolver: impl crate::config::auth::ResolveAuthScheme + 'static) -> &mut Self {
|
441 446 | self.runtime_components
|
442 447 | .set_auth_scheme_option_resolver(::std::option::Option::Some(auth_scheme_resolver.into_shared_resolver()));
|
443 448 | self
|
444 449 | }
|
450 + | /// Set the auth scheme preference for an auth scheme resolver
|
451 + | /// (typically the default auth scheme resolver).
|
452 + | ///
|
453 + | /// Each operation has a predefined order of auth schemes, as determined by the service,
|
454 + | /// for auth scheme resolution. By using the auth scheme preference, customers
|
455 + | /// can reorder the schemes resolved by the auth scheme resolver.
|
456 + | ///
|
457 + | /// The preference list is intended as a hint rather than a strict override.
|
458 + | /// Any schemes not present in the originally resolved auth schemes will be ignored.
|
459 + | ///
|
460 + | /// # Examples
|
461 + | ///
|
462 + | /// ```no_run
|
463 + | /// # use aws_smithy_runtime_api::client::auth::AuthSchemeId;
|
464 + | /// let config = aws_sdk_dynamodb::Config::builder()
|
465 + | /// .auth_scheme_preference([AuthSchemeId::from("scheme1"), AuthSchemeId::from("scheme2")])
|
466 + | /// // ...
|
467 + | /// .build();
|
468 + | /// let client = aws_sdk_dynamodb::Client::from_conf(config);
|
469 + | /// ```
|
470 + |
|
471 + | pub fn auth_scheme_preference(
|
472 + | mut self,
|
473 + | preference: impl ::std::convert::Into<::aws_smithy_runtime_api::client::auth::AuthSchemePreference>,
|
474 + | ) -> Self {
|
475 + | self.set_auth_scheme_preference(::std::option::Option::Some(preference.into()));
|
476 + | self
|
477 + | }
|
478 + |
|
479 + | /// Set the auth scheme preference for an auth scheme resolver
|
480 + | /// (typically the default auth scheme resolver).
|
481 + | ///
|
482 + | /// Each operation has a predefined order of auth schemes, as determined by the service,
|
483 + | /// for auth scheme resolution. By using the auth scheme preference, customers
|
484 + | /// can reorder the schemes resolved by the auth scheme resolver.
|
485 + | ///
|
486 + | /// The preference list is intended as a hint rather than a strict override.
|
487 + | /// Any schemes not present in the originally resolved auth schemes will be ignored.
|
488 + | ///
|
489 + | /// # Examples
|
490 + | ///
|
491 + | /// ```no_run
|
492 + | /// # use aws_smithy_runtime_api::client::auth::AuthSchemeId;
|
493 + | /// let config = aws_sdk_dynamodb::Config::builder()
|
494 + | /// .auth_scheme_preference([AuthSchemeId::from("scheme1"), AuthSchemeId::from("scheme2")])
|
495 + | /// // ...
|
496 + | /// .build();
|
497 + | /// let client = aws_sdk_dynamodb::Client::from_conf(config);
|
498 + | /// ```
|
499 + |
|
500 + | pub fn set_auth_scheme_preference(
|
501 + | &mut self,
|
502 + | preference: ::std::option::Option<::aws_smithy_runtime_api::client::auth::AuthSchemePreference>,
|
503 + | ) -> &mut Self {
|
504 + | self.config.store_or_unset(preference);
|
505 + | self
|
506 + | }
|
445 507 | /// Sets the endpoint resolver to use when making requests.
|
446 508 | ///
|
447 509 | ///
|
448 510 | /// When unset, the client will used a generated endpoint resolver based on the endpoint resolution
|
449 511 | /// rules for `aws_sdk_dynamodb`.
|
450 512 | ///
|
451 513 | ///
|
452 514 | /// Note: setting an endpoint resolver will replace any endpoint URL that has been set.
|
453 515 | /// This method accepts an endpoint resolver [specific to this service](crate::config::endpoint::ResolveEndpoint). If you want to
|
454 516 | /// provide a shared endpoint resolver, use [`Self::set_endpoint_resolver`].
|
455 517 | ///
|
456 518 | /// # Examples
|
457 519 | /// Create a custom endpoint resolver that resolves a different endpoing per-stage, e.g. staging vs. production.
|
458 520 | /// ```no_run
|
459 521 | /// use aws_sdk_dynamodb::config::endpoint::{ResolveEndpoint, EndpointFuture, Params, Endpoint};
|
460 522 | /// #[derive(Debug)]
|
461 523 | /// struct StageResolver { stage: String }
|
462 524 | /// impl ResolveEndpoint for StageResolver {
|
463 525 | /// fn resolve_endpoint(&self, params: &Params) -> EndpointFuture<'_> {
|
464 526 | /// let stage = &self.stage;
|
465 527 | /// EndpointFuture::ready(Ok(Endpoint::builder().url(format!("{stage}.myservice.com")).build()))
|
466 528 | /// }
|
467 529 | /// }
|
468 530 | /// let resolver = StageResolver { stage: std::env::var("STAGE").unwrap() };
|
469 531 | /// let config = aws_sdk_dynamodb::Config::builder().endpoint_resolver(resolver).build();
|
470 532 | /// let client = aws_sdk_dynamodb::Client::from_conf(config);
|
471 533 | /// ```
|
472 534 | pub fn endpoint_resolver(mut self, endpoint_resolver: impl crate::config::endpoint::ResolveEndpoint + 'static) -> Self {
|
473 535 | self.set_endpoint_resolver(::std::option::Option::Some(endpoint_resolver.into_shared_resolver()));
|
474 536 | self
|
1422 1484 |
|
1423 1485 | impl From<&::aws_types::sdk_config::SdkConfig> for Builder {
|
1424 1486 | fn from(input: &::aws_types::sdk_config::SdkConfig) -> Self {
|
1425 1487 | let mut builder = Builder::default();
|
1426 1488 | builder.set_credentials_provider(input.credentials_provider());
|
1427 1489 | builder = builder.region(input.region().cloned());
|
1428 1490 | builder.set_use_fips(input.use_fips());
|
1429 1491 | builder.set_use_dual_stack(input.use_dual_stack());
|
1430 1492 | if input.get_origin("endpoint_url").is_client_config() {
|
1431 1493 | builder.set_endpoint_url(input.endpoint_url().map(|s| s.to_string()));
|
1432 1494 | } else {
|
1433 1495 | builder.set_endpoint_url(
|
1434 1496 | input
|
1435 1497 | .service_config()
|
1436 1498 | .and_then(|conf| {
|
1437 1499 | conf.load_config(service_config_key("AWS_ENDPOINT_URL", "endpoint_url"))
|
1438 1500 | .map(|it| it.parse().unwrap())
|
1439 1501 | })
|
1440 1502 | .or_else(|| input.endpoint_url().map(|s| s.to_string())),
|
1441 1503 | );
|
1442 1504 | }
|
1443 1505 | builder.set_account_id_endpoint_mode(input.account_id_endpoint_mode().cloned());
|
1444 1506 | // resiliency
|
1445 1507 | builder.set_retry_config(input.retry_config().cloned());
|
1446 1508 | builder.set_timeout_config(input.timeout_config().cloned());
|
1447 1509 | builder.set_sleep_impl(input.sleep_impl());
|
1448 1510 |
|
1449 1511 | builder.set_http_client(input.http_client());
|
1450 1512 | builder.set_time_source(input.time_source());
|
1451 1513 | builder.set_behavior_version(input.behavior_version());
|
1514 + | builder.set_auth_scheme_preference(input.auth_scheme_preference().cloned());
|
1452 1515 | // setting `None` here removes the default
|
1453 1516 | if let Some(config) = input.stalled_stream_protection() {
|
1454 1517 | builder.set_stalled_stream_protection(Some(config));
|
1455 1518 | }
|
1456 1519 |
|
1457 1520 | if let Some(cache) = input.identity_cache() {
|
1458 1521 | builder.set_identity_cache(cache);
|
1459 1522 | }
|
1460 1523 | builder.set_app_name(input.app_name().cloned());
|
1461 1524 |
|