442 442 | ///
|
443 443 | /// # Examples
|
444 444 | ///
|
445 445 | /// Disabling identity caching:
|
446 446 | /// ```no_run
|
447 447 | /// use pokemon_service_awsjson_client::config::IdentityCache;
|
448 448 | ///
|
449 449 | /// let config = pokemon_service_awsjson_client::Config::builder()
|
450 450 | /// .identity_cache(IdentityCache::no_cache())
|
451 451 | /// // ...
|
452 452 | /// .build();
|
453 453 | /// let client = pokemon_service_awsjson_client::Client::from_conf(config);
|
454 454 | /// ```
|
455 455 | ///
|
456 456 | /// Customizing lazy caching:
|
457 457 | /// ```no_run
|
458 458 | /// use pokemon_service_awsjson_client::config::IdentityCache;
|
459 459 | /// use std::time::Duration;
|
460 460 | ///
|
461 461 | /// let config = pokemon_service_awsjson_client::Config::builder()
|
462 462 | /// .identity_cache(
|
463 463 | /// IdentityCache::lazy()
|
464 464 | /// // change the load timeout to 10 seconds
|
465 465 | /// .load_timeout(Duration::from_secs(10))
|
466 466 | /// .build()
|
467 467 | /// )
|
468 468 | /// // ...
|
469 469 | /// .build();
|
470 470 | /// let client = pokemon_service_awsjson_client::Client::from_conf(config);
|
471 471 | /// ```
|
472 - |
|
472 + | ///
|
473 473 | pub fn identity_cache(mut self, identity_cache: impl crate::config::ResolveCachedIdentity + 'static) -> Self {
|
474 474 | self.set_identity_cache(identity_cache);
|
475 475 | self
|
476 476 | }
|
477 477 |
|
478 478 | /// Set the identity cache for auth.
|
479 479 | ///
|
480 480 | /// The identity cache defaults to a lazy caching implementation that will resolve
|
481 481 | /// an identity when it is requested, and place it in the cache thereafter. Subsequent
|
482 482 | /// requests will take the value from the cache while it is still valid. Once it expires,
|
483 483 | /// the next request will result in refreshing the identity.
|
484 484 | ///
|
485 485 | /// This configuration allows you to disable or change the default caching mechanism.
|
486 486 | /// To use a custom caching mechanism, implement the [`ResolveCachedIdentity`](crate::config::ResolveCachedIdentity)
|
487 487 | /// trait and pass that implementation into this function.
|
488 488 | ///
|
489 489 | /// # Examples
|
490 490 | ///
|
491 491 | /// Disabling identity caching:
|
492 492 | /// ```no_run
|
493 493 | /// use pokemon_service_awsjson_client::config::IdentityCache;
|
494 494 | ///
|
495 495 | /// let config = pokemon_service_awsjson_client::Config::builder()
|
496 496 | /// .identity_cache(IdentityCache::no_cache())
|
497 497 | /// // ...
|
498 498 | /// .build();
|
499 499 | /// let client = pokemon_service_awsjson_client::Client::from_conf(config);
|
500 500 | /// ```
|
501 501 | ///
|
502 502 | /// Customizing lazy caching:
|
503 503 | /// ```no_run
|
504 504 | /// use pokemon_service_awsjson_client::config::IdentityCache;
|
505 505 | /// use std::time::Duration;
|
506 506 | ///
|
507 507 | /// let config = pokemon_service_awsjson_client::Config::builder()
|
508 508 | /// .identity_cache(
|
509 509 | /// IdentityCache::lazy()
|
510 510 | /// // change the load timeout to 10 seconds
|
511 511 | /// .load_timeout(Duration::from_secs(10))
|
512 512 | /// .build()
|
513 513 | /// )
|
514 514 | /// // ...
|
515 515 | /// .build();
|
516 516 | /// let client = pokemon_service_awsjson_client::Client::from_conf(config);
|
517 517 | /// ```
|
518 - |
|
518 + | ///
|
519 519 | pub fn set_identity_cache(&mut self, identity_cache: impl crate::config::ResolveCachedIdentity + 'static) -> &mut Self {
|
520 520 | self.runtime_components.set_identity_cache(::std::option::Option::Some(identity_cache));
|
521 521 | self
|
522 522 | }
|
523 523 | /// Add an [interceptor](crate::config::Intercept) that runs at specific stages of the request execution pipeline.
|
524 524 | ///
|
525 525 | /// Interceptors targeted at a certain stage are executed according to the pre-defined priority.
|
526 526 | /// The SDK provides a default set of interceptors. An interceptor configured by this method
|
527 527 | /// will run after those default interceptors.
|
528 528 | ///
|
529 529 | /// # Examples
|
530 530 | /// ```no_run
|
531 531 | /// # #[cfg(test)]
|
532 532 | /// # mod tests {
|
533 533 | /// # #[test]
|
534 534 | /// # fn example() {
|
535 535 | /// use aws_smithy_runtime_api::client::interceptors::context::phase::BeforeTransmit;
|
536 536 | /// use aws_smithy_runtime_api::client::interceptors::{Interceptor, InterceptorContext};
|
537 537 | /// use aws_smithy_types::config_bag::ConfigBag;
|
538 538 | /// use pokemon_service_awsjson_client::config::Config;
|
539 539 | ///
|
540 540 | /// fn base_url() -> String {
|
541 541 | /// // ...
|
542 542 | /// # String::new()
|
543 543 | /// }
|
544 544 | ///
|
545 545 | /// #[derive(Debug)]
|
546 546 | /// pub struct UriModifierInterceptor;
|
547 547 | /// impl Intercept for UriModifierInterceptor {
|
548 548 | /// fn modify_before_signing(
|
834 834 | }
|
835 835 | /// Sets the [`behavior major version`](crate::config::BehaviorVersion).
|
836 836 | ///
|
837 837 | /// Over time, new best-practice behaviors are introduced. However, these behaviors might not be backwards
|
838 838 | /// compatible. For example, a change which introduces new default timeouts or a new retry-mode for
|
839 839 | /// all operations might be the ideal behavior but could break existing applications.
|
840 840 | ///
|
841 841 | /// # Examples
|
842 842 | ///
|
843 843 | /// Set the behavior major version to `latest`. This is equivalent to enabling the `behavior-version-latest` cargo feature.
|
844 844 | /// ```no_run
|
845 845 | /// use pokemon_service_awsjson_client::config::BehaviorVersion;
|
846 846 | ///
|
847 847 | /// let config = pokemon_service_awsjson_client::Config::builder()
|
848 848 | /// .behavior_version(BehaviorVersion::latest())
|
849 849 | /// // ...
|
850 850 | /// .build();
|
851 851 | /// let client = pokemon_service_awsjson_client::Client::from_conf(config);
|
852 852 | /// ```
|
853 853 | ///
|
854 854 | /// Customizing behavior major version:
|
855 855 | /// ```no_run
|
856 856 | /// use pokemon_service_awsjson_client::config::BehaviorVersion;
|
857 857 | ///
|
858 858 | /// let config = pokemon_service_awsjson_client::Config::builder()
|
859 859 | /// .behavior_version(BehaviorVersion::v2023_11_09())
|
860 860 | /// // ...
|
861 861 | /// .build();
|
862 862 | /// let client = pokemon_service_awsjson_client::Client::from_conf(config);
|
863 863 | /// ```
|
864 - |
|
864 + | ///
|
865 865 | pub fn behavior_version(mut self, behavior_version: crate::config::BehaviorVersion) -> Self {
|
866 866 | self.set_behavior_version(Some(behavior_version));
|
867 867 | self
|
868 868 | }
|
869 869 |
|
870 870 | /// Sets the [`behavior major version`](crate::config::BehaviorVersion).
|
871 871 | ///
|
872 872 | /// Over time, new best-practice behaviors are introduced. However, these behaviors might not be backwards
|
873 873 | /// compatible. For example, a change which introduces new default timeouts or a new retry-mode for
|
874 874 | /// all operations might be the ideal behavior but could break existing applications.
|
875 875 | ///
|
876 876 | /// # Examples
|
877 877 | ///
|
878 878 | /// Set the behavior major version to `latest`. This is equivalent to enabling the `behavior-version-latest` cargo feature.
|
879 879 | /// ```no_run
|
880 880 | /// use pokemon_service_awsjson_client::config::BehaviorVersion;
|
881 881 | ///
|
882 882 | /// let config = pokemon_service_awsjson_client::Config::builder()
|
883 883 | /// .behavior_version(BehaviorVersion::latest())
|
884 884 | /// // ...
|
885 885 | /// .build();
|
886 886 | /// let client = pokemon_service_awsjson_client::Client::from_conf(config);
|
887 887 | /// ```
|
888 888 | ///
|
889 889 | /// Customizing behavior major version:
|
890 890 | /// ```no_run
|
891 891 | /// use pokemon_service_awsjson_client::config::BehaviorVersion;
|
892 892 | ///
|
893 893 | /// let config = pokemon_service_awsjson_client::Config::builder()
|
894 894 | /// .behavior_version(BehaviorVersion::v2023_11_09())
|
895 895 | /// // ...
|
896 896 | /// .build();
|
897 897 | /// let client = pokemon_service_awsjson_client::Client::from_conf(config);
|
898 898 | /// ```
|
899 - |
|
899 + | ///
|
900 900 | pub fn set_behavior_version(&mut self, behavior_version: Option<crate::config::BehaviorVersion>) -> &mut Self {
|
901 901 | self.behavior_version = behavior_version;
|
902 902 | self
|
903 903 | }
|
904 904 |
|
905 905 | /// Convenience method to set the latest behavior major version
|
906 906 | ///
|
907 907 | /// This is equivalent to enabling the `behavior-version-latest` Cargo feature
|
908 908 | pub fn behavior_version_latest(mut self) -> Self {
|
909 909 | self.set_behavior_version(Some(crate::config::BehaviorVersion::latest()));
|
910 910 | self
|
911 911 | }
|
912 912 | /// Adds a runtime plugin to the config.
|
913 913 | pub fn runtime_plugin(mut self, plugin: impl crate::config::RuntimePlugin + 'static) -> Self {
|
914 914 | self.push_runtime_plugin(crate::config::SharedRuntimePlugin::new(plugin));
|
915 915 | self
|
916 916 | }
|
917 917 | /// Adds a runtime plugin to the config.
|
918 918 | pub fn push_runtime_plugin(&mut self, plugin: crate::config::SharedRuntimePlugin) -> &mut Self {
|
919 919 | self.runtime_plugins.push(plugin);
|
920 920 | self
|
921 921 | }
|
922 922 | #[cfg(any(feature = "test-util", test))]
|
923 923 | #[allow(unused_mut)]
|
924 924 | /// Apply test defaults to the builder
|
925 925 | pub fn apply_test_defaults(&mut self) -> &mut Self {
|
926 926 | self.set_time_source(::std::option::Option::Some(::aws_smithy_async::time::SharedTimeSource::new(
|
927 927 | ::aws_smithy_async::time::StaticTimeSource::new(::std::time::UNIX_EPOCH + ::std::time::Duration::from_secs(1234567890)),
|
928 928 | )));
|
929 929 | self.behavior_version = ::std::option::Option::Some(crate::config::BehaviorVersion::latest());
|
966 966 | let config = {
|
967 967 | let mut cfg = ::aws_smithy_types::config_bag::Layer::new("PokemonService");
|
968 968 | cfg.store_put(::aws_smithy_runtime::client::orchestrator::AuthSchemeAndEndpointOrchestrationV2);
|
969 969 | ::std::option::Option::Some(cfg.freeze())
|
970 970 | };
|
971 971 | let mut runtime_components = ::aws_smithy_runtime_api::client::runtime_components::RuntimeComponentsBuilder::new("ServiceRuntimePlugin");
|
972 972 | runtime_components.push_interceptor(::aws_smithy_runtime::client::http::connection_poisoning::ConnectionPoisoningInterceptor::new());
|
973 973 | runtime_components.push_retry_classifier(::aws_smithy_runtime::client::retries::classifiers::HttpStatusCodeClassifier::default());
|
974 974 | runtime_components.push_interceptor(crate::sdk_feature_tracker::retry_mode::RetryModeFeatureTrackerInterceptor::new());
|
975 975 | Self { config, runtime_components }
|
976 976 | }
|
977 977 | }
|
978 978 |
|
979 979 | impl ::aws_smithy_runtime_api::client::runtime_plugin::RuntimePlugin for ServiceRuntimePlugin {
|
980 980 | fn config(&self) -> ::std::option::Option<::aws_smithy_types::config_bag::FrozenLayer> {
|
981 981 | self.config.clone()
|
982 982 | }
|
983 983 |
|
984 984 | fn order(&self) -> ::aws_smithy_runtime_api::client::runtime_plugin::Order {
|
985 985 | ::aws_smithy_runtime_api::client::runtime_plugin::Order::Defaults
|
986 986 | }
|
987 987 |
|
988 988 | fn runtime_components(
|
989 989 | &self,
|
990 990 | _: &::aws_smithy_runtime_api::client::runtime_components::RuntimeComponentsBuilder,
|
991 991 | ) -> ::std::borrow::Cow<'_, ::aws_smithy_runtime_api::client::runtime_components::RuntimeComponentsBuilder> {
|
992 992 | ::std::borrow::Cow::Borrowed(&self.runtime_components)
|
993 993 | }
|
994 994 | }
|
995 995 |
|
996 - | /// Cross-operation shared-state singletons
|
996 + | // Cross-operation shared-state singletons
|
997 997 |
|
998 998 | /// A plugin that enables configuration for a single operation invocation
|
999 999 | ///
|
1000 1000 | /// The `config` method will return a `FrozenLayer` by storing values from `config_override`.
|
1001 1001 | /// In the case of default values requested, they will be obtained from `client_config`.
|
1002 1002 | #[derive(Debug)]
|
1003 1003 | pub(crate) struct ConfigOverrideRuntimePlugin {
|
1004 1004 | pub(crate) config: ::aws_smithy_types::config_bag::FrozenLayer,
|
1005 1005 | pub(crate) components: ::aws_smithy_runtime_api::client::runtime_components::RuntimeComponentsBuilder,
|
1006 1006 | }
|
1007 1007 |
|
1008 1008 | impl ConfigOverrideRuntimePlugin {
|
1009 1009 | #[allow(dead_code)] // unused when a service does not provide any operations
|
1010 1010 | pub(crate) fn new(
|
1011 1011 | config_override: Builder,
|
1012 1012 | initial_config: ::aws_smithy_types::config_bag::FrozenLayer,
|
1013 1013 | initial_components: &::aws_smithy_runtime_api::client::runtime_components::RuntimeComponentsBuilder,
|
1014 1014 | ) -> Self {
|
1015 1015 | let mut layer = config_override.config;
|
1016 1016 | let mut components = config_override.runtime_components;
|
1017 1017 | #[allow(unused_mut)]
|
1018 1018 | let mut resolver =
|
1019 1019 | ::aws_smithy_runtime::client::config_override::Resolver::overrid(initial_config, initial_components, &mut layer, &mut components);
|
1020 1020 |
|
1021 1021 | let _ = resolver;
|
1022 1022 | Self {
|
1023 1023 | config: ::aws_smithy_types::config_bag::Layer::from(layer)
|
1024 1024 | .with_name("pokemon_service_awsjson_client::config::ConfigOverrideRuntimePlugin")
|
1025 1025 | .freeze(),
|
1026 1026 | components,
|