23 23 | ///
|
24 24 | pub fn builder() -> Builder {
|
25 25 | Builder::default()
|
26 26 | }
|
27 27 | /// Converts this config back into a builder so that it can be tweaked.
|
28 28 | pub fn to_builder(&self) -> Builder {
|
29 29 | Builder {
|
30 30 | config: self.cloneable.clone(),
|
31 31 | runtime_components: self.runtime_components.clone(),
|
32 32 | runtime_plugins: self.runtime_plugins.clone(),
|
33 33 | behavior_version: self.behavior_version,
|
34 34 | }
|
35 35 | }
|
36 36 | /// Return a reference to the stalled stream protection configuration contained in this config, if any.
|
37 37 | pub fn stalled_stream_protection(&self) -> ::std::option::Option<&crate::config::StalledStreamProtectionConfig> {
|
38 38 | self.config.load::<crate::config::StalledStreamProtectionConfig>()
|
39 39 | }
|
40 40 | /// Return the [`SharedHttpClient`](crate::config::SharedHttpClient) to use when making requests, if any.
|
41 41 | pub fn http_client(&self) -> Option<crate::config::SharedHttpClient> {
|
42 42 | self.runtime_components.http_client()
|
43 43 | }
|
44 44 | /// Return the auth schemes configured on this service config
|
45 45 | pub fn auth_schemes(&self) -> impl Iterator<Item = ::aws_smithy_runtime_api::client::auth::SharedAuthScheme> + '_ {
|
46 46 | self.runtime_components.auth_schemes()
|
47 47 | }
|
48 48 |
|
49 49 | /// Return the auth scheme resolver configured on this service config
|
50 50 | pub fn auth_scheme_resolver(&self) -> ::std::option::Option<::aws_smithy_runtime_api::client::auth::SharedAuthSchemeOptionResolver> {
|
51 51 | self.runtime_components.auth_scheme_option_resolver()
|
52 52 | }
|
53 + | /// Returns the configured auth scheme preference
|
54 + | pub fn auth_scheme_preference(&self) -> ::std::option::Option<&::aws_smithy_runtime_api::client::auth::AuthSchemePreference> {
|
55 + | self.config.load::<::aws_smithy_runtime_api::client::auth::AuthSchemePreference>()
|
56 + | }
|
53 57 | /// Returns the endpoint resolver.
|
54 58 | pub fn endpoint_resolver(&self) -> ::aws_smithy_runtime_api::client::endpoint::SharedEndpointResolver {
|
55 59 | self.runtime_components.endpoint_resolver().expect("resolver defaulted if not set")
|
56 60 | }
|
57 61 | /// Return a reference to the retry configuration contained in this config, if any.
|
58 62 | pub fn retry_config(&self) -> ::std::option::Option<&::aws_smithy_types::retry::RetryConfig> {
|
59 63 | self.config.load::<::aws_smithy_types::retry::RetryConfig>()
|
60 64 | }
|
61 65 |
|
62 66 | /// Return a cloned shared async sleep implementation from this config, if any.
|
63 67 | pub fn sleep_impl(&self) -> ::std::option::Option<crate::config::SharedAsyncSleep> {
|
64 68 | self.runtime_components.sleep_impl()
|
65 69 | }
|
66 70 |
|
67 71 | /// Return a reference to the timeout configuration contained in this config, if any.
|
68 72 | pub fn timeout_config(&self) -> ::std::option::Option<&::aws_smithy_types::timeout::TimeoutConfig> {
|
69 73 | self.config.load::<::aws_smithy_types::timeout::TimeoutConfig>()
|
70 74 | }
|
71 75 |
|
72 76 | /// Returns a reference to the retry partition contained in this config, if any.
|
73 77 | ///
|
74 78 | /// WARNING: This method is unstable and may be removed at any time. Do not rely on this
|
75 79 | /// method for anything!
|
76 80 | pub fn retry_partition(&self) -> ::std::option::Option<&::aws_smithy_runtime::client::retries::RetryPartition> {
|
77 81 | self.config.load::<::aws_smithy_runtime::client::retries::RetryPartition>()
|
78 82 | }
|
79 83 | /// Returns the configured identity cache for auth.
|
80 84 | pub fn identity_cache(&self) -> ::std::option::Option<crate::config::SharedIdentityCache> {
|
81 85 | self.runtime_components.identity_cache()
|
82 86 | }
|
101 105 | pub(crate) runtime_plugins: ::std::vec::Vec<crate::config::SharedRuntimePlugin>,
|
102 106 | pub(crate) behavior_version: ::std::option::Option<crate::config::BehaviorVersion>,
|
103 107 | }
|
104 108 | impl ::std::default::Default for Builder {
|
105 109 | fn default() -> Self {
|
106 110 | Self {
|
107 111 | config: ::std::default::Default::default(),
|
108 112 | runtime_components: crate::config::RuntimeComponentsBuilder::new("service config"),
|
109 113 | runtime_plugins: ::std::default::Default::default(),
|
110 114 | behavior_version: ::std::default::Default::default(),
|
111 115 | }
|
112 116 | }
|
113 117 | }
|
114 118 | impl Builder {
|
115 119 | ///
|
116 120 | /// Constructs a config builder.
|
117 121 | /// <div class="warning">
|
118 122 | /// Note that a config created from this builder will not have the same safe defaults as one created by
|
119 123 | /// the <a href="https://crates.io/crates/aws-config" target="_blank">aws-config</a> crate.
|
120 124 | /// </div>
|
121 125 | ///
|
122 126 | pub fn new() -> Self {
|
123 127 | Self::default()
|
124 128 | }
|
125 129 | /// Constructs a config builder from the given `config_bag`, setting only fields stored in the config bag,
|
126 130 | /// but not those in runtime components.
|
127 131 | #[allow(unused)]
|
128 132 | pub(crate) fn from_config_bag(config_bag: &::aws_smithy_types::config_bag::ConfigBag) -> Self {
|
129 133 | let mut builder = Self::new();
|
130 134 | builder.set_stalled_stream_protection(config_bag.load::<crate::config::StalledStreamProtectionConfig>().cloned());
|
135 + | builder.set_auth_scheme_preference(config_bag.load::<::aws_smithy_runtime_api::client::auth::AuthSchemePreference>().cloned());
|
131 136 | builder.set_retry_config(config_bag.load::<::aws_smithy_types::retry::RetryConfig>().cloned());
|
132 137 | builder.set_timeout_config(config_bag.load::<::aws_smithy_types::timeout::TimeoutConfig>().cloned());
|
133 138 | builder.set_retry_partition(config_bag.load::<::aws_smithy_runtime::client::retries::RetryPartition>().cloned());
|
134 139 | builder
|
135 140 | }
|
136 141 | /// Set the [`StalledStreamProtectionConfig`](crate::config::StalledStreamProtectionConfig)
|
137 142 | /// to configure protection for stalled streams.
|
138 143 | pub fn stalled_stream_protection(mut self, stalled_stream_protection_config: crate::config::StalledStreamProtectionConfig) -> Self {
|
139 144 | self.set_stalled_stream_protection(::std::option::Option::Some(stalled_stream_protection_config));
|
140 145 | self
|
345 350 | /// fn resolve_auth_scheme<'a>(
|
346 351 | /// &'a self,
|
347 352 | /// _params: &'a rpcv2cbor_non_query_compatible::config::auth::Params,
|
348 353 | /// _cfg: &'a ConfigBag,
|
349 354 | /// _runtime_components: &'a RuntimeComponents,
|
350 355 | /// ) -> AuthSchemeOptionsFuture<'a> {
|
351 356 | /// // --snip--
|
352 357 | /// # todo!()
|
353 358 | /// }
|
354 359 | /// }
|
355 360 | ///
|
356 361 | /// let config = rpcv2cbor_non_query_compatible::Config::builder()
|
357 362 | /// .auth_scheme_resolver(CustomAuthSchemeResolver)
|
358 363 | /// // other configurations
|
359 364 | /// .build();
|
360 365 | /// ```
|
361 366 | pub fn auth_scheme_resolver(mut self, auth_scheme_resolver: impl crate::config::auth::ResolveAuthScheme + 'static) -> Self {
|
362 367 | self.set_auth_scheme_resolver(auth_scheme_resolver);
|
363 368 | self
|
364 369 | }
|
365 370 |
|
366 371 | /// Set the auth scheme resolver for the builder
|
367 372 | ///
|
368 373 | /// # Examples
|
369 374 | /// See an example for [`Self::auth_scheme_resolver`].
|
370 375 | pub fn set_auth_scheme_resolver(&mut self, auth_scheme_resolver: impl crate::config::auth::ResolveAuthScheme + 'static) -> &mut Self {
|
371 376 | self.runtime_components
|
372 377 | .set_auth_scheme_option_resolver(::std::option::Option::Some(auth_scheme_resolver.into_shared_resolver()));
|
373 378 | self
|
374 379 | }
|
380 + | /// Set the auth scheme preference for an auth scheme resolver
|
381 + | /// (typically the default auth scheme resolver).
|
382 + | ///
|
383 + | /// Each operation has a predefined order of auth schemes, as determined by the service,
|
384 + | /// for auth scheme resolution. By using the auth scheme preference, customers
|
385 + | /// can reorder the schemes resolved by the auth scheme resolver.
|
386 + | ///
|
387 + | /// The preference list is intended as a hint rather than a strict override.
|
388 + | /// Any schemes not present in the originally resolved auth schemes will be ignored.
|
389 + | ///
|
390 + | /// # Examples
|
391 + | ///
|
392 + | /// ```no_run
|
393 + | /// # use aws_smithy_runtime_api::client::auth::AuthSchemeId;
|
394 + | /// let config = rpcv2cbor_non_query_compatible::Config::builder()
|
395 + | /// .auth_scheme_preference([AuthSchemeId::from("scheme1"), AuthSchemeId::from("scheme2")])
|
396 + | /// // ...
|
397 + | /// .build();
|
398 + | /// let client = rpcv2cbor_non_query_compatible::Client::from_conf(config);
|
399 + | /// ```
|
400 + |
|
401 + | pub fn auth_scheme_preference(
|
402 + | mut self,
|
403 + | preference: impl ::std::convert::Into<::aws_smithy_runtime_api::client::auth::AuthSchemePreference>,
|
404 + | ) -> Self {
|
405 + | self.set_auth_scheme_preference(::std::option::Option::Some(preference.into()));
|
406 + | self
|
407 + | }
|
408 + |
|
409 + | /// Set the auth scheme preference for an auth scheme resolver
|
410 + | /// (typically the default auth scheme resolver).
|
411 + | ///
|
412 + | /// Each operation has a predefined order of auth schemes, as determined by the service,
|
413 + | /// for auth scheme resolution. By using the auth scheme preference, customers
|
414 + | /// can reorder the schemes resolved by the auth scheme resolver.
|
415 + | ///
|
416 + | /// The preference list is intended as a hint rather than a strict override.
|
417 + | /// Any schemes not present in the originally resolved auth schemes will be ignored.
|
418 + | ///
|
419 + | /// # Examples
|
420 + | ///
|
421 + | /// ```no_run
|
422 + | /// # use aws_smithy_runtime_api::client::auth::AuthSchemeId;
|
423 + | /// let config = rpcv2cbor_non_query_compatible::Config::builder()
|
424 + | /// .auth_scheme_preference([AuthSchemeId::from("scheme1"), AuthSchemeId::from("scheme2")])
|
425 + | /// // ...
|
426 + | /// .build();
|
427 + | /// let client = rpcv2cbor_non_query_compatible::Client::from_conf(config);
|
428 + | /// ```
|
429 + |
|
430 + | pub fn set_auth_scheme_preference(
|
431 + | &mut self,
|
432 + | preference: ::std::option::Option<::aws_smithy_runtime_api::client::auth::AuthSchemePreference>,
|
433 + | ) -> &mut Self {
|
434 + | self.config.store_or_unset(preference);
|
435 + | self
|
436 + | }
|
375 437 | /// Set the endpoint URL to use when making requests.
|
376 438 | ///
|
377 439 | /// Note: setting an endpoint URL will replace any endpoint resolver that has been set.
|
378 440 | ///
|
379 441 | /// # Panics
|
380 442 | /// Panics if an invalid URL is given.
|
381 443 | pub fn endpoint_url(mut self, endpoint_url: impl ::std::convert::Into<::std::string::String>) -> Self {
|
382 444 | self.set_endpoint_url(::std::option::Option::Some(endpoint_url.into()));
|
383 445 | self
|
384 446 | }
|
385 447 |
|
386 448 | /// Set the endpoint URL to use when making requests.
|
387 449 | ///
|
388 450 | /// Note: setting an endpoint URL will replace any endpoint resolver that has been set.
|
389 451 | ///
|
390 452 | /// # Panics
|
391 453 | /// Panics if an invalid URL is given.
|
392 454 | pub fn set_endpoint_url(&mut self, endpoint_url: ::std::option::Option<::std::string::String>) -> &mut Self {
|
393 455 | #[allow(deprecated)]
|
394 456 | self.set_endpoint_resolver(endpoint_url.map(|url| {
|
395 457 | ::aws_smithy_runtime_api::shared::IntoShared::into_shared(
|
396 458 | ::aws_smithy_runtime::client::orchestrator::endpoints::StaticUriEndpointResolver::uri(url),
|
397 459 | )
|
398 460 | }));
|
399 461 | self
|
400 462 | }
|
401 463 | /// Sets the endpoint resolver to use when making requests.
|
402 464 | ///
|
403 465 | /// This service does not define a default endpoint resolver.
|
404 466 | ///
|