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 | }
|
135 139 | pub(crate) runtime_plugins: ::std::vec::Vec<crate::config::SharedRuntimePlugin>,
|
136 140 | pub(crate) behavior_version: ::std::option::Option<crate::config::BehaviorVersion>,
|
137 141 | }
|
138 142 | impl ::std::default::Default for Builder {
|
139 143 | fn default() -> Self {
|
140 144 | Self {
|
141 145 | config: ::std::default::Default::default(),
|
142 146 | runtime_components: crate::config::RuntimeComponentsBuilder::new("service config"),
|
143 147 | runtime_plugins: ::std::default::Default::default(),
|
144 148 | behavior_version: ::std::default::Default::default(),
|
145 149 | }
|
146 150 | }
|
147 151 | }
|
148 152 | impl Builder {
|
149 153 | ///
|
150 154 | /// Constructs a config builder.
|
151 155 | /// <div class="warning">
|
152 156 | /// Note that a config created from this builder will not have the same safe defaults as one created by
|
153 157 | /// the <a href="https://crates.io/crates/aws-config" target="_blank">aws-config</a> crate.
|
154 158 | /// </div>
|
155 159 | ///
|
156 160 | pub fn new() -> Self {
|
157 161 | Self::default()
|
158 162 | }
|
159 163 | /// Constructs a config builder from the given `config_bag`, setting only fields stored in the config bag,
|
160 164 | /// but not those in runtime components.
|
161 165 | #[allow(unused)]
|
162 166 | pub(crate) fn from_config_bag(config_bag: &::aws_smithy_types::config_bag::ConfigBag) -> Self {
|
163 167 | let mut builder = Self::new();
|
164 168 | builder.set_stalled_stream_protection(config_bag.load::<crate::config::StalledStreamProtectionConfig>().cloned());
|
169 + | builder.set_auth_scheme_preference(config_bag.load::<::aws_smithy_runtime_api::client::auth::AuthSchemePreference>().cloned());
|
165 170 | builder.set_retry_config(config_bag.load::<::aws_smithy_types::retry::RetryConfig>().cloned());
|
166 171 | builder.set_timeout_config(config_bag.load::<::aws_smithy_types::timeout::TimeoutConfig>().cloned());
|
167 172 | builder.set_retry_partition(config_bag.load::<::aws_smithy_runtime::client::retries::RetryPartition>().cloned());
|
168 173 | builder.set_app_name(config_bag.load::<::aws_types::app_name::AppName>().cloned());
|
169 174 | builder.set_endpoint_url(config_bag.load::<::aws_types::endpoint_config::EndpointUrl>().map(|ty| ty.0.clone()));
|
170 175 | builder.set_use_fips(config_bag.load::<::aws_types::endpoint_config::UseFips>().map(|ty| ty.0));
|
171 176 | builder.set_region(config_bag.load::<crate::config::Region>().cloned());
|
172 177 | builder
|
173 178 | }
|
174 179 | /// Set the [`StalledStreamProtectionConfig`](crate::config::StalledStreamProtectionConfig)
|
175 180 | /// to configure protection for stalled streams.
|
176 181 | pub fn stalled_stream_protection(mut self, stalled_stream_protection_config: crate::config::StalledStreamProtectionConfig) -> Self {
|
177 182 | self.set_stalled_stream_protection(::std::option::Option::Some(stalled_stream_protection_config));
|
178 183 | self
|
179 184 | }
|
180 185 | /// Set the [`StalledStreamProtectionConfig`](crate::config::StalledStreamProtectionConfig)
|
181 186 | /// to configure protection for stalled streams.
|
182 187 | pub fn set_stalled_stream_protection(
|
183 188 | &mut self,
|
184 189 | stalled_stream_protection_config: ::std::option::Option<crate::config::StalledStreamProtectionConfig>,
|
185 190 | ) -> &mut Self {
|
186 191 | self.config.store_or_unset(stalled_stream_protection_config);
|
187 192 | self
|
188 193 | }
|
189 194 | /// Sets the idempotency token provider to use for service calls that require tokens.
|
190 195 | pub fn idempotency_token_provider(
|
191 196 | mut self,
|
192 197 | idempotency_token_provider: impl ::std::convert::Into<crate::idempotency_token::IdempotencyTokenProvider>,
|
193 198 | ) -> Self {
|
194 199 | self.set_idempotency_token_provider(::std::option::Option::Some(idempotency_token_provider.into()));
|
414 419 | /// fn resolve_auth_scheme<'a>(
|
415 420 | /// &'a self,
|
416 421 | /// _params: &'a aws_sdk_codecatalyst::config::auth::Params,
|
417 422 | /// _cfg: &'a ConfigBag,
|
418 423 | /// _runtime_components: &'a RuntimeComponents,
|
419 424 | /// ) -> AuthSchemeOptionsFuture<'a> {
|
420 425 | /// // --snip--
|
421 426 | /// # todo!()
|
422 427 | /// }
|
423 428 | /// }
|
424 429 | ///
|
425 430 | /// let config = aws_sdk_codecatalyst::Config::builder()
|
426 431 | /// .auth_scheme_resolver(CustomAuthSchemeResolver)
|
427 432 | /// // other configurations
|
428 433 | /// .build();
|
429 434 | /// ```
|
430 435 | pub fn auth_scheme_resolver(mut self, auth_scheme_resolver: impl crate::config::auth::ResolveAuthScheme + 'static) -> Self {
|
431 436 | self.set_auth_scheme_resolver(auth_scheme_resolver);
|
432 437 | self
|
433 438 | }
|
434 439 |
|
435 440 | /// Set the auth scheme resolver for the builder
|
436 441 | ///
|
437 442 | /// # Examples
|
438 443 | /// See an example for [`Self::auth_scheme_resolver`].
|
439 444 | pub fn set_auth_scheme_resolver(&mut self, auth_scheme_resolver: impl crate::config::auth::ResolveAuthScheme + 'static) -> &mut Self {
|
440 445 | self.runtime_components
|
441 446 | .set_auth_scheme_option_resolver(::std::option::Option::Some(auth_scheme_resolver.into_shared_resolver()));
|
442 447 | self
|
443 448 | }
|
449 + | /// Set the auth scheme preference for an auth scheme resolver
|
450 + | /// (typically the default auth scheme resolver).
|
451 + | ///
|
452 + | /// Each operation has a predefined order of auth schemes, as determined by the service,
|
453 + | /// for auth scheme resolution. By using the auth scheme preference, customers
|
454 + | /// can reorder the schemes resolved by the auth scheme resolver.
|
455 + | ///
|
456 + | /// The preference list is intended as a hint rather than a strict override.
|
457 + | /// Any schemes not present in the originally resolved auth schemes will be ignored.
|
458 + | ///
|
459 + | /// # Examples
|
460 + | ///
|
461 + | /// ```no_run
|
462 + | /// # use aws_smithy_runtime_api::client::auth::AuthSchemeId;
|
463 + | /// let config = aws_sdk_codecatalyst::Config::builder()
|
464 + | /// .auth_scheme_preference([AuthSchemeId::from("scheme1"), AuthSchemeId::from("scheme2")])
|
465 + | /// // ...
|
466 + | /// .build();
|
467 + | /// let client = aws_sdk_codecatalyst::Client::from_conf(config);
|
468 + | /// ```
|
469 + |
|
470 + | pub fn auth_scheme_preference(
|
471 + | mut self,
|
472 + | preference: impl ::std::convert::Into<::aws_smithy_runtime_api::client::auth::AuthSchemePreference>,
|
473 + | ) -> Self {
|
474 + | self.set_auth_scheme_preference(::std::option::Option::Some(preference.into()));
|
475 + | self
|
476 + | }
|
477 + |
|
478 + | /// Set the auth scheme preference for an auth scheme resolver
|
479 + | /// (typically the default auth scheme resolver).
|
480 + | ///
|
481 + | /// Each operation has a predefined order of auth schemes, as determined by the service,
|
482 + | /// for auth scheme resolution. By using the auth scheme preference, customers
|
483 + | /// can reorder the schemes resolved by the auth scheme resolver.
|
484 + | ///
|
485 + | /// The preference list is intended as a hint rather than a strict override.
|
486 + | /// Any schemes not present in the originally resolved auth schemes will be ignored.
|
487 + | ///
|
488 + | /// # Examples
|
489 + | ///
|
490 + | /// ```no_run
|
491 + | /// # use aws_smithy_runtime_api::client::auth::AuthSchemeId;
|
492 + | /// let config = aws_sdk_codecatalyst::Config::builder()
|
493 + | /// .auth_scheme_preference([AuthSchemeId::from("scheme1"), AuthSchemeId::from("scheme2")])
|
494 + | /// // ...
|
495 + | /// .build();
|
496 + | /// let client = aws_sdk_codecatalyst::Client::from_conf(config);
|
497 + | /// ```
|
498 + |
|
499 + | pub fn set_auth_scheme_preference(
|
500 + | &mut self,
|
501 + | preference: ::std::option::Option<::aws_smithy_runtime_api::client::auth::AuthSchemePreference>,
|
502 + | ) -> &mut Self {
|
503 + | self.config.store_or_unset(preference);
|
504 + | self
|
505 + | }
|
444 506 | /// Sets the endpoint resolver to use when making requests.
|
445 507 | ///
|
446 508 | ///
|
447 509 | /// When unset, the client will used a generated endpoint resolver based on the endpoint resolution
|
448 510 | /// rules for `aws_sdk_codecatalyst`.
|
449 511 | ///
|
450 512 | ///
|
451 513 | /// Note: setting an endpoint resolver will replace any endpoint URL that has been set.
|
452 514 | /// This method accepts an endpoint resolver [specific to this service](crate::config::endpoint::ResolveEndpoint). If you want to
|
453 515 | /// provide a shared endpoint resolver, use [`Self::set_endpoint_resolver`].
|
454 516 | ///
|
455 517 | /// # Examples
|
456 518 | /// Create a custom endpoint resolver that resolves a different endpoing per-stage, e.g. staging vs. production.
|
457 519 | /// ```no_run
|
458 520 | /// use aws_sdk_codecatalyst::config::endpoint::{ResolveEndpoint, EndpointFuture, Params, Endpoint};
|
459 521 | /// #[derive(Debug)]
|
460 522 | /// struct StageResolver { stage: String }
|
461 523 | /// impl ResolveEndpoint for StageResolver {
|
462 524 | /// fn resolve_endpoint(&self, params: &Params) -> EndpointFuture<'_> {
|
463 525 | /// let stage = &self.stage;
|
464 526 | /// EndpointFuture::ready(Ok(Endpoint::builder().url(format!("{stage}.myservice.com")).build()))
|
465 527 | /// }
|
466 528 | /// }
|
467 529 | /// let resolver = StageResolver { stage: std::env::var("STAGE").unwrap() };
|
468 530 | /// let config = aws_sdk_codecatalyst::Config::builder().endpoint_resolver(resolver).build();
|
469 531 | /// let client = aws_sdk_codecatalyst::Client::from_conf(config);
|
470 532 | /// ```
|
471 533 | pub fn endpoint_resolver(mut self, endpoint_resolver: impl crate::config::endpoint::ResolveEndpoint + 'static) -> Self {
|
472 534 | self.set_endpoint_resolver(::std::option::Option::Some(endpoint_resolver.into_shared_resolver()));
|
473 535 | self
|
1395 1457 | pub use ::aws_smithy_runtime::client::identity::IdentityCache;
|
1396 1458 | pub use ::aws_smithy_runtime_api::client::runtime_components::RuntimeComponents;
|
1397 1459 | pub use ::aws_smithy_types::config_bag::ConfigBag;
|
1398 1460 |
|
1399 1461 | impl From<&::aws_types::sdk_config::SdkConfig> for Builder {
|
1400 1462 | fn from(input: &::aws_types::sdk_config::SdkConfig) -> Self {
|
1401 1463 | let mut builder = Builder::default();
|
1402 1464 | builder = builder.region(input.region().cloned());
|
1403 1465 | builder.set_use_fips(input.use_fips());
|
1404 1466 | if input.get_origin("endpoint_url").is_client_config() {
|
1405 1467 | builder.set_endpoint_url(input.endpoint_url().map(|s| s.to_string()));
|
1406 1468 | } else {
|
1407 1469 | builder.set_endpoint_url(
|
1408 1470 | input
|
1409 1471 | .service_config()
|
1410 1472 | .and_then(|conf| {
|
1411 1473 | conf.load_config(service_config_key("AWS_ENDPOINT_URL", "endpoint_url"))
|
1412 1474 | .map(|it| it.parse().unwrap())
|
1413 1475 | })
|
1414 1476 | .or_else(|| input.endpoint_url().map(|s| s.to_string())),
|
1415 1477 | );
|
1416 1478 | }
|
1417 1479 | // resiliency
|
1418 1480 | builder.set_retry_config(input.retry_config().cloned());
|
1419 1481 | builder.set_timeout_config(input.timeout_config().cloned());
|
1420 1482 | builder.set_sleep_impl(input.sleep_impl());
|
1421 1483 |
|
1422 1484 | builder.set_http_client(input.http_client());
|
1423 1485 | builder.set_time_source(input.time_source());
|
1424 1486 | builder.set_behavior_version(input.behavior_version());
|
1487 + | builder.set_auth_scheme_preference(input.auth_scheme_preference().cloned());
|
1425 1488 | // setting `None` here removes the default
|
1426 1489 | if let Some(config) = input.stalled_stream_protection() {
|
1427 1490 | builder.set_stalled_stream_protection(Some(config));
|
1428 1491 | }
|
1429 1492 |
|
1430 1493 | if let Some(cache) = input.identity_cache() {
|
1431 1494 | builder.set_identity_cache(cache);
|
1432 1495 | }
|
1433 1496 | builder.set_token_provider(input.token_provider());
|
1434 1497 | builder.set_app_name(input.app_name().cloned());
|