aws_sdk_sesv2/config/
auth.rs1pub trait ResolveAuthScheme: ::std::marker::Send + ::std::marker::Sync + ::std::fmt::Debug {
4 fn resolve_auth_scheme<'a>(
6 &'a self,
7 params: &'a crate::config::auth::Params,
8 cfg: &'a ::aws_smithy_types::config_bag::ConfigBag,
9 runtime_components: &'a ::aws_smithy_runtime_api::client::runtime_components::RuntimeComponents,
10 ) -> ::aws_smithy_runtime_api::client::auth::AuthSchemeOptionsFuture<'a>;
11
12 fn into_shared_resolver(self) -> ::aws_smithy_runtime_api::client::auth::SharedAuthSchemeOptionResolver
14 where
15 Self: ::std::marker::Sized + 'static,
16 {
17 ::aws_smithy_runtime_api::client::auth::SharedAuthSchemeOptionResolver::new(DowncastParams(self))
18 }
19}
20
21#[derive(Debug)]
22struct DowncastParams<T>(T);
23impl<T> ::aws_smithy_runtime_api::client::auth::ResolveAuthSchemeOptions for DowncastParams<T>
24where
25 T: ResolveAuthScheme,
26{
27 fn resolve_auth_scheme_options_v2<'a>(
28 &'a self,
29 params: &'a ::aws_smithy_runtime_api::client::auth::AuthSchemeOptionResolverParams,
30 cfg: &'a ::aws_smithy_types::config_bag::ConfigBag,
31 runtime_components: &'a ::aws_smithy_runtime_api::client::runtime_components::RuntimeComponents,
32 ) -> ::aws_smithy_runtime_api::client::auth::AuthSchemeOptionsFuture<'a> {
33 match params.get::<crate::config::auth::Params>() {
34 ::std::option::Option::Some(concrete_params) => self.0.resolve_auth_scheme(concrete_params, cfg, runtime_components),
35 ::std::option::Option::None => ::aws_smithy_runtime_api::client::auth::AuthSchemeOptionsFuture::ready(::std::result::Result::Err(
36 "params of expected type was not present".into(),
37 )),
38 }
39 }
40}
41
42#[derive(Debug)]
44#[allow(dead_code)]
45pub struct DefaultAuthSchemeResolver {
46 service_defaults: Vec<::aws_smithy_runtime_api::client::auth::AuthSchemeOption>,
47 operation_overrides: ::std::collections::HashMap<&'static str, Vec<::aws_smithy_runtime_api::client::auth::AuthSchemeOption>>,
48}
49
50#[allow(clippy::derivable_impls)]
55impl Default for DefaultAuthSchemeResolver {
56 fn default() -> Self {
57 Self {
58 service_defaults: vec![
59 ::aws_smithy_runtime_api::client::auth::AuthSchemeOption::builder()
60 .scheme_id(::aws_runtime::auth::sigv4::SCHEME_ID)
61 .build()
62 .expect("required fields set"),
63 #[cfg(feature = "sigv4a")]
64 {
65 ::aws_smithy_runtime_api::client::auth::AuthSchemeOption::builder()
66 .scheme_id(::aws_runtime::auth::sigv4a::SCHEME_ID)
67 .build()
68 .expect("required fields set")
69 },
70 ],
71 operation_overrides: ::std::collections::HashMap::new(),
72 }
73 }
74}
75
76impl crate::config::auth::ResolveAuthScheme for DefaultAuthSchemeResolver {
77 fn resolve_auth_scheme<'a>(
78 &'a self,
79 params: &'a crate::config::auth::Params,
80 _cfg: &'a ::aws_smithy_types::config_bag::ConfigBag,
81 _runtime_components: &'a ::aws_smithy_runtime_api::client::runtime_components::RuntimeComponents,
82 ) -> ::aws_smithy_runtime_api::client::auth::AuthSchemeOptionsFuture<'a> {
83 let operation_name = params.operation_name();
84
85 let modeled_auth_options = match self.operation_overrides.get(operation_name) {
86 Some(overrides) => overrides,
87 None => &self.service_defaults,
88 };
89
90 let _fut = ::aws_smithy_runtime_api::client::auth::AuthSchemeOptionsFuture::ready(Ok(modeled_auth_options.clone()));
91
92 let _fut = ::aws_smithy_runtime_api::client::auth::AuthSchemeOptionsFuture::new(async move {
93 crate::endpoint_auth::resolve_endpoint_based_auth_scheme_options(modeled_auth_options, _cfg, _runtime_components).await
94 });
95
96 _fut
97 }
98}
99
100#[derive(::std::clone::Clone, ::std::cmp::PartialEq, ::std::fmt::Debug)]
102pub struct Params {
103 operation_name: ::std::borrow::Cow<'static, str>,
104}
105impl Params {
106 pub fn builder() -> crate::config::auth::ParamsBuilder {
108 crate::config::auth::ParamsBuilder::default()
109 }
110
111 pub fn operation_name(&self) -> &str {
113 self.operation_name.as_ref()
114 }
115}
116
117#[derive(::std::clone::Clone, ::std::cmp::PartialEq, ::std::default::Default, ::std::fmt::Debug)]
118pub struct ParamsBuilder {
120 operation_name: ::std::option::Option<::std::borrow::Cow<'static, str>>,
121}
122impl ParamsBuilder {
123 pub fn operation_name(self, operation_name: impl Into<::std::borrow::Cow<'static, str>>) -> Self {
125 self.set_operation_name(::std::option::Option::Some(operation_name.into()))
126 }
127
128 pub fn set_operation_name(mut self, operation_name: ::std::option::Option<::std::borrow::Cow<'static, str>>) -> Self {
130 self.operation_name = operation_name;
131 self
132 }
133 pub fn build(self) -> ::std::result::Result<crate::config::auth::Params, crate::config::auth::BuildError> {
138 ::std::result::Result::Ok(crate::config::auth::Params {
139 operation_name: self.operation_name.ok_or_else(|| BuildError::missing("operation_name"))?,
140 })
141 }
142}
143
144#[derive(Debug)]
146pub struct BuildError {
147 field: ::std::borrow::Cow<'static, str>,
148}
149
150impl BuildError {
151 fn missing(field: &'static str) -> Self {
152 Self { field: field.into() }
153 }
154}
155
156impl std::fmt::Display for BuildError {
157 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
158 write!(f, "a required field was missing: `{}`", self.field)
159 }
160}
161
162impl std::error::Error for BuildError {}