Client Test

Client Test

rev. a562638cb954071808c8908a73292885a41137c0 (ignoring whitespace)

Files changed:

tmp-codegen-diff/codegen-client-test/rpcv2cbor_query_compatible/rust-client-codegen/src/config.rs

@@ -23,23 +82,86 @@
   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.
@@ -101,105 +160,165 @@
  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 +404,466 @@
  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_query_compatible::Config::builder()
         395  +
    ///     .auth_scheme_preference([AuthSchemeId::from("scheme1"), AuthSchemeId::from("scheme2")])
         396  +
    ///     // ...
         397  +
    ///     .build();
         398  +
    /// let client = rpcv2cbor_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_query_compatible::Config::builder()
         424  +
    ///     .auth_scheme_preference([AuthSchemeId::from("scheme1"), AuthSchemeId::from("scheme2")])
         425  +
    ///     // ...
         426  +
    ///     .build();
         427  +
    /// let client = rpcv2cbor_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   
    }
@@ -1111,1173 +1171,1243 @@
 1131   1193   
    pub fn new(_service_config: crate::config::Config) -> Self {
 1132   1194   
        let config = {
 1133   1195   
            let mut cfg = ::aws_smithy_types::config_bag::Layer::new("QueryCompatibleRpcV2Protocol");
 1134   1196   
            cfg.store_put(::aws_smithy_runtime::client::orchestrator::AuthSchemeAndEndpointOrchestrationV2);
 1135   1197   
            ::std::option::Option::Some(cfg.freeze())
 1136   1198   
        };
 1137   1199   
        let mut runtime_components = ::aws_smithy_runtime_api::client::runtime_components::RuntimeComponentsBuilder::new("ServiceRuntimePlugin");
 1138   1200   
        runtime_components.push_interceptor(crate::sdk_feature_tracker::rpc_v2_cbor::RpcV2CborFeatureTrackerInterceptor::new());
 1139   1201   
        runtime_components.set_auth_scheme_option_resolver(::std::option::Option::Some({
 1140   1202   
            use crate::config::auth::ResolveAuthScheme;
        1203  +
            if let Some(preference) = _service_config
        1204  +
                .config
        1205  +
                .load::<::aws_smithy_runtime_api::client::auth::AuthSchemePreference>()
        1206  +
                .cloned()
        1207  +
            {
        1208  +
                crate::config::auth::DefaultAuthSchemeResolver::default()
        1209  +
                    .with_auth_scheme_preference(preference)
        1210  +
                    .into_shared_resolver()
        1211  +
            } else {
 1141   1212   
                crate::config::auth::DefaultAuthSchemeResolver::default().into_shared_resolver()
        1213  +
            }
 1142   1214   
        }));
 1143   1215   
        runtime_components.push_interceptor(::aws_smithy_runtime::client::http::connection_poisoning::ConnectionPoisoningInterceptor::new());
 1144   1216   
        runtime_components.push_retry_classifier(::aws_smithy_runtime::client::retries::classifiers::HttpStatusCodeClassifier::default());
 1145   1217   
        runtime_components.push_interceptor(crate::sdk_feature_tracker::retry_mode::RetryModeFeatureTrackerInterceptor::new());
 1146   1218   
        Self { config, runtime_components }
 1147   1219   
    }
 1148   1220   
}
 1149   1221   
 1150   1222   
impl ::aws_smithy_runtime_api::client::runtime_plugin::RuntimePlugin for ServiceRuntimePlugin {
 1151   1223   
    fn config(&self) -> ::std::option::Option<::aws_smithy_types::config_bag::FrozenLayer> {

tmp-codegen-diff/codegen-client-test/rpcv2cbor_query_compatible/rust-client-codegen/src/config/auth.rs

@@ -18,18 +110,140 @@
   38     38   
        }
   39     39   
    }
   40     40   
}
   41     41   
   42     42   
/// The default auth scheme resolver
   43     43   
#[derive(Debug)]
   44     44   
#[allow(dead_code)]
   45     45   
pub struct DefaultAuthSchemeResolver {
   46     46   
    service_defaults: Vec<::aws_smithy_runtime_api::client::auth::AuthSchemeOption>,
   47     47   
    operation_overrides: ::std::collections::HashMap<&'static str, Vec<::aws_smithy_runtime_api::client::auth::AuthSchemeOption>>,
          48  +
    preference: ::std::option::Option<::aws_smithy_runtime_api::client::auth::AuthSchemePreference>,
   48     49   
}
   49     50   
   50     51   
// TODO(https://github.com/smithy-lang/smithy-rs/issues/4177): Remove `allow(...)` once the issue is addressed.
   51     52   
// When generating code for tests (e.g., `codegen-client-test`), this manual implementation
   52     53   
// of the `Default` trait may appear as if it could be derived automatically.
   53     54   
// However, that is not the case in production.
   54     55   
#[allow(clippy::derivable_impls)]
   55     56   
impl Default for DefaultAuthSchemeResolver {
   56     57   
    fn default() -> Self {
   57     58   
        Self {
   58     59   
            service_defaults: vec![],
   59     60   
            operation_overrides: ::std::collections::HashMap::new(),
          61  +
            preference: ::std::option::Option::None,
   60     62   
        }
   61     63   
    }
   62     64   
}
   63     65   
   64     66   
impl crate::config::auth::ResolveAuthScheme for DefaultAuthSchemeResolver {
   65     67   
    fn resolve_auth_scheme<'a>(
   66     68   
        &'a self,
   67     69   
        params: &'a crate::config::auth::Params,
   68     70   
        _cfg: &'a ::aws_smithy_types::config_bag::ConfigBag,
   69     71   
        _runtime_components: &'a ::aws_smithy_runtime_api::client::runtime_components::RuntimeComponents,
   70     72   
    ) -> ::aws_smithy_runtime_api::client::auth::AuthSchemeOptionsFuture<'a> {
   71     73   
        let operation_name = params.operation_name();
   72     74   
   73     75   
        let modeled_auth_options = match self.operation_overrides.get(operation_name) {
   74     76   
            Some(overrides) => overrides,
   75     77   
            None => &self.service_defaults,
   76     78   
        };
   77     79   
   78     80   
        let _fut = ::aws_smithy_runtime_api::client::auth::AuthSchemeOptionsFuture::ready(Ok(modeled_auth_options.clone()));
   79     81   
   80         -
        _fut
          82  +
        match &self.preference {
          83  +
            ::std::option::Option::Some(preference) => {
          84  +
                _fut.map_ok({
          85  +
                    // maps auth scheme ID to the index in the preference list
          86  +
                    let preference_map: ::std::collections::HashMap<_, _> = preference.clone().into_iter().enumerate().map(|(i, s)| (s, i)).collect();
          87  +
                    move |auth_scheme_options| {
          88  +
                        let (mut preferred, non_preferred): (::std::vec::Vec<_>, ::std::vec::Vec<_>) = auth_scheme_options
          89  +
                            .into_iter()
          90  +
                            .partition(|auth_scheme_option| preference_map.contains_key(auth_scheme_option.scheme_id()));
          91  +
          92  +
                        preferred.sort_by_key(|opt| preference_map.get(opt.scheme_id()).expect("guaranteed by `partition`"));
          93  +
                        preferred.extend(non_preferred);
          94  +
                        preferred
          95  +
                    }
          96  +
                })
          97  +
            }
          98  +
            ::std::option::Option::None => _fut,
          99  +
        }
         100  +
    }
         101  +
}
         102  +
         103  +
impl DefaultAuthSchemeResolver {
         104  +
    /// Set auth scheme preference to the default auth scheme resolver
         105  +
    pub fn with_auth_scheme_preference(
         106  +
        mut self,
         107  +
        preference: impl ::std::convert::Into<::aws_smithy_runtime_api::client::auth::AuthSchemePreference>,
         108  +
    ) -> Self {
         109  +
        self.preference = ::std::option::Option::Some(preference.into());
         110  +
        self
   81    111   
    }
   82    112   
}
   83    113   
   84    114   
/// Configuration parameters for resolving the correct auth scheme
   85    115   
#[derive(::std::clone::Clone, ::std::cmp::PartialEq, ::std::fmt::Debug)]
   86    116   
pub struct Params {
   87    117   
    operation_name: ::std::borrow::Cow<'static, str>,
   88    118   
}
   89    119   
impl Params {
   90    120   
    /// Create a builder for [`Params`]

tmp-codegen-diff/codegen-client-test/simple/rust-client-codegen/src/config.rs

@@ -23,23 +82,86 @@
   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.
@@ -101,105 +160,165 @@
  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 +404,466 @@
  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 = simple::Config::builder()
         395  +
    ///     .auth_scheme_preference([AuthSchemeId::from("scheme1"), AuthSchemeId::from("scheme2")])
         396  +
    ///     // ...
         397  +
    ///     .build();
         398  +
    /// let client = simple::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 = simple::Config::builder()
         424  +
    ///     .auth_scheme_preference([AuthSchemeId::from("scheme1"), AuthSchemeId::from("scheme2")])
         425  +
    ///     // ...
         426  +
    ///     .build();
         427  +
    /// let client = simple::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   
    }
@@ -1108,1170 +1168,1240 @@
 1128   1190   
impl ServiceRuntimePlugin {
 1129   1191   
    pub fn new(_service_config: crate::config::Config) -> Self {
 1130   1192   
        let config = {
 1131   1193   
            let mut cfg = ::aws_smithy_types::config_bag::Layer::new("SimpleService");
 1132   1194   
            cfg.store_put(::aws_smithy_runtime::client::orchestrator::AuthSchemeAndEndpointOrchestrationV2);
 1133   1195   
            ::std::option::Option::Some(cfg.freeze())
 1134   1196   
        };
 1135   1197   
        let mut runtime_components = ::aws_smithy_runtime_api::client::runtime_components::RuntimeComponentsBuilder::new("ServiceRuntimePlugin");
 1136   1198   
        runtime_components.set_auth_scheme_option_resolver(::std::option::Option::Some({
 1137   1199   
            use crate::config::auth::ResolveAuthScheme;
        1200  +
            if let Some(preference) = _service_config
        1201  +
                .config
        1202  +
                .load::<::aws_smithy_runtime_api::client::auth::AuthSchemePreference>()
        1203  +
                .cloned()
        1204  +
            {
        1205  +
                crate::config::auth::DefaultAuthSchemeResolver::default()
        1206  +
                    .with_auth_scheme_preference(preference)
        1207  +
                    .into_shared_resolver()
        1208  +
            } else {
 1138   1209   
                crate::config::auth::DefaultAuthSchemeResolver::default().into_shared_resolver()
        1210  +
            }
 1139   1211   
        }));
 1140   1212   
        runtime_components.push_interceptor(::aws_smithy_runtime::client::http::connection_poisoning::ConnectionPoisoningInterceptor::new());
 1141   1213   
        runtime_components.push_retry_classifier(::aws_smithy_runtime::client::retries::classifiers::HttpStatusCodeClassifier::default());
 1142   1214   
        runtime_components.push_interceptor(crate::sdk_feature_tracker::retry_mode::RetryModeFeatureTrackerInterceptor::new());
 1143   1215   
        Self { config, runtime_components }
 1144   1216   
    }
 1145   1217   
}
 1146   1218   
 1147   1219   
impl ::aws_smithy_runtime_api::client::runtime_plugin::RuntimePlugin for ServiceRuntimePlugin {
 1148   1220   
    fn config(&self) -> ::std::option::Option<::aws_smithy_types::config_bag::FrozenLayer> {

tmp-codegen-diff/codegen-client-test/simple/rust-client-codegen/src/config/auth.rs

@@ -18,18 +112,142 @@
   38     38   
        }
   39     39   
    }
   40     40   
}
   41     41   
   42     42   
/// The default auth scheme resolver
   43     43   
#[derive(Debug)]
   44     44   
#[allow(dead_code)]
   45     45   
pub struct DefaultAuthSchemeResolver {
   46     46   
    service_defaults: Vec<::aws_smithy_runtime_api::client::auth::AuthSchemeOption>,
   47     47   
    operation_overrides: ::std::collections::HashMap<&'static str, Vec<::aws_smithy_runtime_api::client::auth::AuthSchemeOption>>,
          48  +
    preference: ::std::option::Option<::aws_smithy_runtime_api::client::auth::AuthSchemePreference>,
   48     49   
}
   49     50   
   50     51   
// TODO(https://github.com/smithy-lang/smithy-rs/issues/4177): Remove `allow(...)` once the issue is addressed.
   51     52   
// When generating code for tests (e.g., `codegen-client-test`), this manual implementation
   52     53   
// of the `Default` trait may appear as if it could be derived automatically.
   53     54   
// However, that is not the case in production.
   54     55   
#[allow(clippy::derivable_impls)]
   55     56   
impl Default for DefaultAuthSchemeResolver {
   56     57   
    fn default() -> Self {
   57     58   
        Self {
   58     59   
            service_defaults: vec![::aws_smithy_runtime_api::client::auth::AuthSchemeOption::from(
   59     60   
                ::aws_smithy_runtime::client::auth::no_auth::NO_AUTH_SCHEME_ID,
   60     61   
            )],
   61     62   
            operation_overrides: ::std::collections::HashMap::new(),
          63  +
            preference: ::std::option::Option::None,
   62     64   
        }
   63     65   
    }
   64     66   
}
   65     67   
   66     68   
impl crate::config::auth::ResolveAuthScheme for DefaultAuthSchemeResolver {
   67     69   
    fn resolve_auth_scheme<'a>(
   68     70   
        &'a self,
   69     71   
        params: &'a crate::config::auth::Params,
   70     72   
        _cfg: &'a ::aws_smithy_types::config_bag::ConfigBag,
   71     73   
        _runtime_components: &'a ::aws_smithy_runtime_api::client::runtime_components::RuntimeComponents,
   72     74   
    ) -> ::aws_smithy_runtime_api::client::auth::AuthSchemeOptionsFuture<'a> {
   73     75   
        let operation_name = params.operation_name();
   74     76   
   75     77   
        let modeled_auth_options = match self.operation_overrides.get(operation_name) {
   76     78   
            Some(overrides) => overrides,
   77     79   
            None => &self.service_defaults,
   78     80   
        };
   79     81   
   80     82   
        let _fut = ::aws_smithy_runtime_api::client::auth::AuthSchemeOptionsFuture::ready(Ok(modeled_auth_options.clone()));
   81     83   
   82         -
        _fut
          84  +
        match &self.preference {
          85  +
            ::std::option::Option::Some(preference) => {
          86  +
                _fut.map_ok({
          87  +
                    // maps auth scheme ID to the index in the preference list
          88  +
                    let preference_map: ::std::collections::HashMap<_, _> = preference.clone().into_iter().enumerate().map(|(i, s)| (s, i)).collect();
          89  +
                    move |auth_scheme_options| {
          90  +
                        let (mut preferred, non_preferred): (::std::vec::Vec<_>, ::std::vec::Vec<_>) = auth_scheme_options
          91  +
                            .into_iter()
          92  +
                            .partition(|auth_scheme_option| preference_map.contains_key(auth_scheme_option.scheme_id()));
          93  +
          94  +
                        preferred.sort_by_key(|opt| preference_map.get(opt.scheme_id()).expect("guaranteed by `partition`"));
          95  +
                        preferred.extend(non_preferred);
          96  +
                        preferred
          97  +
                    }
          98  +
                })
          99  +
            }
         100  +
            ::std::option::Option::None => _fut,
         101  +
        }
         102  +
    }
         103  +
}
         104  +
         105  +
impl DefaultAuthSchemeResolver {
         106  +
    /// Set auth scheme preference to the default auth scheme resolver
         107  +
    pub fn with_auth_scheme_preference(
         108  +
        mut self,
         109  +
        preference: impl ::std::convert::Into<::aws_smithy_runtime_api::client::auth::AuthSchemePreference>,
         110  +
    ) -> Self {
         111  +
        self.preference = ::std::option::Option::Some(preference.into());
         112  +
        self
   83    113   
    }
   84    114   
}
   85    115   
   86    116   
/// Configuration parameters for resolving the correct auth scheme
   87    117   
#[derive(::std::clone::Clone, ::std::cmp::PartialEq, ::std::fmt::Debug)]
   88    118   
pub struct Params {
   89    119   
    operation_name: ::std::borrow::Cow<'static, str>,
   90    120   
}
   91    121   
impl Params {
   92    122   
    /// Create a builder for [`Params`]