1#[derive(::std::clone::Clone, ::std::default::Default, ::std::fmt::Debug)]
4#[non_exhaustive]
5pub struct CreateToken;
6impl CreateToken {
7 pub fn new() -> Self {
9 Self
10 }
11 pub(crate) async fn orchestrate(
12 runtime_plugins: &::aws_smithy_runtime_api::client::runtime_plugin::RuntimePlugins,
13 input: crate::operation::create_token::CreateTokenInput,
14 ) -> ::std::result::Result<
15 crate::operation::create_token::CreateTokenOutput,
16 ::aws_smithy_runtime_api::client::result::SdkError<
17 crate::operation::create_token::CreateTokenError,
18 ::aws_smithy_runtime_api::client::orchestrator::HttpResponse,
19 >,
20 > {
21 let map_err = |err: ::aws_smithy_runtime_api::client::result::SdkError<
22 ::aws_smithy_runtime_api::client::interceptors::context::Error,
23 ::aws_smithy_runtime_api::client::orchestrator::HttpResponse,
24 >| {
25 err.map_service_error(|err| {
26 err.downcast::<crate::operation::create_token::CreateTokenError>()
27 .expect("correct error type")
28 })
29 };
30 let context = Self::orchestrate_with_stop_point(runtime_plugins, input, ::aws_smithy_runtime::client::orchestrator::StopPoint::None)
31 .await
32 .map_err(map_err)?;
33 let output = context.finalize().map_err(map_err)?;
34 ::std::result::Result::Ok(
35 output
36 .downcast::<crate::operation::create_token::CreateTokenOutput>()
37 .expect("correct output type"),
38 )
39 }
40
41 pub(crate) async fn orchestrate_with_stop_point(
42 runtime_plugins: &::aws_smithy_runtime_api::client::runtime_plugin::RuntimePlugins,
43 input: crate::operation::create_token::CreateTokenInput,
44 stop_point: ::aws_smithy_runtime::client::orchestrator::StopPoint,
45 ) -> ::std::result::Result<
46 ::aws_smithy_runtime_api::client::interceptors::context::InterceptorContext,
47 ::aws_smithy_runtime_api::client::result::SdkError<
48 ::aws_smithy_runtime_api::client::interceptors::context::Error,
49 ::aws_smithy_runtime_api::client::orchestrator::HttpResponse,
50 >,
51 > {
52 let input = ::aws_smithy_runtime_api::client::interceptors::context::Input::erase(input);
53 use ::tracing::Instrument;
54 ::aws_smithy_runtime::client::orchestrator::invoke_with_stop_point("SSO OIDC", "CreateToken", input, runtime_plugins, stop_point)
55 .instrument(::tracing::debug_span!(
58 "SSO OIDC.CreateToken",
59 "rpc.service" = "SSO OIDC",
60 "rpc.method" = "CreateToken",
61 "sdk_invocation_id" = ::fastrand::u32(1_000_000..10_000_000),
62 "rpc.system" = "aws-api",
63 ))
64 .await
65 }
66
67 pub(crate) fn operation_runtime_plugins(
68 client_runtime_plugins: ::aws_smithy_runtime_api::client::runtime_plugin::RuntimePlugins,
69 client_config: &crate::config::Config,
70 config_override: ::std::option::Option<crate::config::Builder>,
71 ) -> ::aws_smithy_runtime_api::client::runtime_plugin::RuntimePlugins {
72 let mut runtime_plugins = client_runtime_plugins.with_operation_plugin(Self::new());
73 runtime_plugins = runtime_plugins.with_client_plugin(crate::auth_plugin::DefaultAuthOptionsPlugin::new(vec![
74 ::aws_smithy_runtime::client::auth::no_auth::NO_AUTH_SCHEME_ID,
75 ]));
76 if let ::std::option::Option::Some(config_override) = config_override {
77 for plugin in config_override.runtime_plugins.iter().cloned() {
78 runtime_plugins = runtime_plugins.with_operation_plugin(plugin);
79 }
80 runtime_plugins = runtime_plugins.with_operation_plugin(crate::config::ConfigOverrideRuntimePlugin::new(
81 config_override,
82 client_config.config.clone(),
83 &client_config.runtime_components,
84 ));
85 }
86 runtime_plugins
87 }
88}
89impl ::aws_smithy_runtime_api::client::runtime_plugin::RuntimePlugin for CreateToken {
90 fn config(&self) -> ::std::option::Option<::aws_smithy_types::config_bag::FrozenLayer> {
91 let mut cfg = ::aws_smithy_types::config_bag::Layer::new("CreateToken");
92
93 cfg.store_put(::aws_smithy_runtime_api::client::ser_de::SharedRequestSerializer::new(
94 CreateTokenRequestSerializer,
95 ));
96 cfg.store_put(::aws_smithy_runtime_api::client::ser_de::SharedResponseDeserializer::new(
97 CreateTokenResponseDeserializer,
98 ));
99
100 cfg.store_put(::aws_smithy_runtime_api::client::auth::AuthSchemeOptionResolverParams::new(
101 ::aws_smithy_runtime_api::client::auth::static_resolver::StaticAuthSchemeOptionResolverParams::new(),
102 ));
103
104 cfg.store_put(::aws_smithy_runtime_api::client::orchestrator::SensitiveOutput);
105 cfg.store_put(::aws_smithy_runtime_api::client::orchestrator::Metadata::new("CreateToken", "SSO OIDC"));
106
107 ::std::option::Option::Some(cfg.freeze())
108 }
109
110 fn runtime_components(
111 &self,
112 _: &::aws_smithy_runtime_api::client::runtime_components::RuntimeComponentsBuilder,
113 ) -> ::std::borrow::Cow<'_, ::aws_smithy_runtime_api::client::runtime_components::RuntimeComponentsBuilder> {
114 #[allow(unused_mut)]
115 let mut rcb = ::aws_smithy_runtime_api::client::runtime_components::RuntimeComponentsBuilder::new("CreateToken")
116 .with_interceptor(::aws_smithy_runtime::client::stalled_stream_protection::StalledStreamProtectionInterceptor::default())
117 .with_interceptor(CreateTokenEndpointParamsInterceptor)
118 .with_retry_classifier(::aws_smithy_runtime::client::retries::classifiers::TransientErrorClassifier::<
119 crate::operation::create_token::CreateTokenError,
120 >::new())
121 .with_retry_classifier(::aws_smithy_runtime::client::retries::classifiers::ModeledAsRetryableClassifier::<
122 crate::operation::create_token::CreateTokenError,
123 >::new())
124 .with_retry_classifier(::aws_runtime::retries::classifiers::AwsErrorCodeClassifier::<
125 crate::operation::create_token::CreateTokenError,
126 >::new());
127
128 ::std::borrow::Cow::Owned(rcb)
129 }
130}
131
132#[derive(Debug)]
133struct CreateTokenResponseDeserializer;
134impl ::aws_smithy_runtime_api::client::ser_de::DeserializeResponse for CreateTokenResponseDeserializer {
135 fn deserialize_nonstreaming(
136 &self,
137 response: &::aws_smithy_runtime_api::client::orchestrator::HttpResponse,
138 ) -> ::aws_smithy_runtime_api::client::interceptors::context::OutputOrError {
139 let (success, status) = (response.status().is_success(), response.status().as_u16());
140 let headers = response.headers();
141 let body = response.body().bytes().expect("body loaded");
142 #[allow(unused_mut)]
143 let mut force_error = false;
144 ::tracing::debug!(request_id = ?::aws_types::request_id::RequestId::request_id(response));
145 let parse_result = if !success && status != 200 || force_error {
146 crate::protocol_serde::shape_create_token::de_create_token_http_error(status, headers, body)
147 } else {
148 crate::protocol_serde::shape_create_token::de_create_token_http_response(status, headers, body)
149 };
150 crate::protocol_serde::type_erase_result(parse_result)
151 }
152}
153#[derive(Debug)]
154struct CreateTokenRequestSerializer;
155impl ::aws_smithy_runtime_api::client::ser_de::SerializeRequest for CreateTokenRequestSerializer {
156 #[allow(unused_mut, clippy::let_and_return, clippy::needless_borrow, clippy::useless_conversion)]
157 fn serialize_input(
158 &self,
159 input: ::aws_smithy_runtime_api::client::interceptors::context::Input,
160 _cfg: &mut ::aws_smithy_types::config_bag::ConfigBag,
161 ) -> ::std::result::Result<::aws_smithy_runtime_api::client::orchestrator::HttpRequest, ::aws_smithy_runtime_api::box_error::BoxError> {
162 let input = input
163 .downcast::<crate::operation::create_token::CreateTokenInput>()
164 .expect("correct type");
165 let _header_serialization_settings = _cfg
166 .load::<crate::serialization_settings::HeaderSerializationSettings>()
167 .cloned()
168 .unwrap_or_default();
169 let mut request_builder = {
170 fn uri_base(
171 _input: &crate::operation::create_token::CreateTokenInput,
172 output: &mut ::std::string::String,
173 ) -> ::std::result::Result<(), ::aws_smithy_types::error::operation::BuildError> {
174 use ::std::fmt::Write as _;
175 ::std::write!(output, "/token").expect("formatting should succeed");
176 ::std::result::Result::Ok(())
177 }
178 #[allow(clippy::unnecessary_wraps)]
179 fn update_http_builder(
180 input: &crate::operation::create_token::CreateTokenInput,
181 builder: ::http::request::Builder,
182 ) -> ::std::result::Result<::http::request::Builder, ::aws_smithy_types::error::operation::BuildError> {
183 let mut uri = ::std::string::String::new();
184 uri_base(input, &mut uri)?;
185 ::std::result::Result::Ok(builder.method("POST").uri(uri))
186 }
187 let mut builder = update_http_builder(&input, ::http::request::Builder::new())?;
188 builder = _header_serialization_settings.set_default_header(builder, ::http::header::CONTENT_TYPE, "application/json");
189 builder
190 };
191 let body = ::aws_smithy_types::body::SdkBody::from(crate::protocol_serde::shape_create_token::ser_create_token_input(&input)?);
192 if let Some(content_length) = body.content_length() {
193 let content_length = content_length.to_string();
194 request_builder = _header_serialization_settings.set_default_header(request_builder, ::http::header::CONTENT_LENGTH, &content_length);
195 }
196 ::std::result::Result::Ok(request_builder.body(body).expect("valid request").try_into().unwrap())
197 }
198}
199#[derive(Debug)]
200struct CreateTokenEndpointParamsInterceptor;
201
202impl ::aws_smithy_runtime_api::client::interceptors::Intercept for CreateTokenEndpointParamsInterceptor {
203 fn name(&self) -> &'static str {
204 "CreateTokenEndpointParamsInterceptor"
205 }
206
207 fn read_before_execution(
208 &self,
209 context: &::aws_smithy_runtime_api::client::interceptors::context::BeforeSerializationInterceptorContextRef<
210 '_,
211 ::aws_smithy_runtime_api::client::interceptors::context::Input,
212 ::aws_smithy_runtime_api::client::interceptors::context::Output,
213 ::aws_smithy_runtime_api::client::interceptors::context::Error,
214 >,
215 cfg: &mut ::aws_smithy_types::config_bag::ConfigBag,
216 ) -> ::std::result::Result<(), ::aws_smithy_runtime_api::box_error::BoxError> {
217 let _input = context
218 .input()
219 .downcast_ref::<CreateTokenInput>()
220 .ok_or("failed to downcast to CreateTokenInput")?;
221
222 let params = crate::config::endpoint::Params::builder()
223 .set_region(cfg.load::<::aws_types::region::Region>().map(|r| r.as_ref().to_owned()))
224 .set_use_dual_stack(cfg.load::<::aws_types::endpoint_config::UseDualStack>().map(|ty| ty.0))
225 .set_use_fips(cfg.load::<::aws_types::endpoint_config::UseFips>().map(|ty| ty.0))
226 .set_endpoint(cfg.load::<::aws_types::endpoint_config::EndpointUrl>().map(|ty| ty.0.clone()))
227 .build()
228 .map_err(|err| {
229 ::aws_smithy_runtime_api::client::interceptors::error::ContextAttachedError::new("endpoint params could not be built", err)
230 })?;
231 cfg.interceptor_state()
232 .store_put(::aws_smithy_runtime_api::client::endpoint::EndpointResolverParams::new(params));
233 ::std::result::Result::Ok(())
234 }
235}
236
237#[non_exhaustive]
242#[derive(::std::fmt::Debug)]
243pub enum CreateTokenError {
244 AccessDeniedException(crate::types::error::AccessDeniedException),
246 AuthorizationPendingException(crate::types::error::AuthorizationPendingException),
248 ExpiredTokenException(crate::types::error::ExpiredTokenException),
250 InternalServerException(crate::types::error::InternalServerException),
252 InvalidClientException(crate::types::error::InvalidClientException),
254 InvalidGrantException(crate::types::error::InvalidGrantException),
256 InvalidRequestException(crate::types::error::InvalidRequestException),
258 InvalidScopeException(crate::types::error::InvalidScopeException),
260 SlowDownException(crate::types::error::SlowDownException),
262 UnauthorizedClientException(crate::types::error::UnauthorizedClientException),
264 UnsupportedGrantTypeException(crate::types::error::UnsupportedGrantTypeException),
266 #[deprecated(note = "Matching `Unhandled` directly is not forwards compatible. Instead, match using a \
268 variable wildcard pattern and check `.code()`:
269 \
270 `err if err.code() == Some(\"SpecificExceptionCode\") => { /* handle the error */ }`
271 \
272 See [`ProvideErrorMetadata`](#impl-ProvideErrorMetadata-for-CreateTokenError) for what information is available for the error.")]
273 Unhandled(crate::error::sealed_unhandled::Unhandled),
274}
275impl CreateTokenError {
276 pub fn unhandled(
278 err: impl ::std::convert::Into<::std::boxed::Box<dyn ::std::error::Error + ::std::marker::Send + ::std::marker::Sync + 'static>>,
279 ) -> Self {
280 Self::Unhandled(crate::error::sealed_unhandled::Unhandled {
281 source: err.into(),
282 meta: ::std::default::Default::default(),
283 })
284 }
285
286 pub fn generic(err: ::aws_smithy_types::error::ErrorMetadata) -> Self {
288 Self::Unhandled(crate::error::sealed_unhandled::Unhandled {
289 source: err.clone().into(),
290 meta: err,
291 })
292 }
293 pub fn meta(&self) -> &::aws_smithy_types::error::ErrorMetadata {
298 match self {
299 Self::AccessDeniedException(e) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(e),
300 Self::AuthorizationPendingException(e) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(e),
301 Self::ExpiredTokenException(e) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(e),
302 Self::InternalServerException(e) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(e),
303 Self::InvalidClientException(e) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(e),
304 Self::InvalidGrantException(e) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(e),
305 Self::InvalidRequestException(e) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(e),
306 Self::InvalidScopeException(e) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(e),
307 Self::SlowDownException(e) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(e),
308 Self::UnauthorizedClientException(e) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(e),
309 Self::UnsupportedGrantTypeException(e) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(e),
310 Self::Unhandled(e) => &e.meta,
311 }
312 }
313 pub fn is_access_denied_exception(&self) -> bool {
315 matches!(self, Self::AccessDeniedException(_))
316 }
317 pub fn is_authorization_pending_exception(&self) -> bool {
319 matches!(self, Self::AuthorizationPendingException(_))
320 }
321 pub fn is_expired_token_exception(&self) -> bool {
323 matches!(self, Self::ExpiredTokenException(_))
324 }
325 pub fn is_internal_server_exception(&self) -> bool {
327 matches!(self, Self::InternalServerException(_))
328 }
329 pub fn is_invalid_client_exception(&self) -> bool {
331 matches!(self, Self::InvalidClientException(_))
332 }
333 pub fn is_invalid_grant_exception(&self) -> bool {
335 matches!(self, Self::InvalidGrantException(_))
336 }
337 pub fn is_invalid_request_exception(&self) -> bool {
339 matches!(self, Self::InvalidRequestException(_))
340 }
341 pub fn is_invalid_scope_exception(&self) -> bool {
343 matches!(self, Self::InvalidScopeException(_))
344 }
345 pub fn is_slow_down_exception(&self) -> bool {
347 matches!(self, Self::SlowDownException(_))
348 }
349 pub fn is_unauthorized_client_exception(&self) -> bool {
351 matches!(self, Self::UnauthorizedClientException(_))
352 }
353 pub fn is_unsupported_grant_type_exception(&self) -> bool {
355 matches!(self, Self::UnsupportedGrantTypeException(_))
356 }
357}
358impl ::std::error::Error for CreateTokenError {
359 fn source(&self) -> ::std::option::Option<&(dyn ::std::error::Error + 'static)> {
360 match self {
361 Self::AccessDeniedException(_inner) => ::std::option::Option::Some(_inner),
362 Self::AuthorizationPendingException(_inner) => ::std::option::Option::Some(_inner),
363 Self::ExpiredTokenException(_inner) => ::std::option::Option::Some(_inner),
364 Self::InternalServerException(_inner) => ::std::option::Option::Some(_inner),
365 Self::InvalidClientException(_inner) => ::std::option::Option::Some(_inner),
366 Self::InvalidGrantException(_inner) => ::std::option::Option::Some(_inner),
367 Self::InvalidRequestException(_inner) => ::std::option::Option::Some(_inner),
368 Self::InvalidScopeException(_inner) => ::std::option::Option::Some(_inner),
369 Self::SlowDownException(_inner) => ::std::option::Option::Some(_inner),
370 Self::UnauthorizedClientException(_inner) => ::std::option::Option::Some(_inner),
371 Self::UnsupportedGrantTypeException(_inner) => ::std::option::Option::Some(_inner),
372 Self::Unhandled(_inner) => ::std::option::Option::Some(&*_inner.source),
373 }
374 }
375}
376impl ::std::fmt::Display for CreateTokenError {
377 fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
378 match self {
379 Self::AccessDeniedException(_inner) => _inner.fmt(f),
380 Self::AuthorizationPendingException(_inner) => _inner.fmt(f),
381 Self::ExpiredTokenException(_inner) => _inner.fmt(f),
382 Self::InternalServerException(_inner) => _inner.fmt(f),
383 Self::InvalidClientException(_inner) => _inner.fmt(f),
384 Self::InvalidGrantException(_inner) => _inner.fmt(f),
385 Self::InvalidRequestException(_inner) => _inner.fmt(f),
386 Self::InvalidScopeException(_inner) => _inner.fmt(f),
387 Self::SlowDownException(_inner) => _inner.fmt(f),
388 Self::UnauthorizedClientException(_inner) => _inner.fmt(f),
389 Self::UnsupportedGrantTypeException(_inner) => _inner.fmt(f),
390 Self::Unhandled(_inner) => {
391 if let ::std::option::Option::Some(code) = ::aws_smithy_types::error::metadata::ProvideErrorMetadata::code(self) {
392 write!(f, "unhandled error ({code})")
393 } else {
394 f.write_str("unhandled error")
395 }
396 }
397 }
398 }
399}
400impl ::aws_smithy_types::retry::ProvideErrorKind for CreateTokenError {
401 fn code(&self) -> ::std::option::Option<&str> {
402 ::aws_smithy_types::error::metadata::ProvideErrorMetadata::code(self)
403 }
404 fn retryable_error_kind(&self) -> ::std::option::Option<::aws_smithy_types::retry::ErrorKind> {
405 ::std::option::Option::None
406 }
407}
408impl ::aws_smithy_types::error::metadata::ProvideErrorMetadata for CreateTokenError {
409 fn meta(&self) -> &::aws_smithy_types::error::ErrorMetadata {
410 match self {
411 Self::AccessDeniedException(_inner) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(_inner),
412 Self::AuthorizationPendingException(_inner) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(_inner),
413 Self::ExpiredTokenException(_inner) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(_inner),
414 Self::InternalServerException(_inner) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(_inner),
415 Self::InvalidClientException(_inner) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(_inner),
416 Self::InvalidGrantException(_inner) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(_inner),
417 Self::InvalidRequestException(_inner) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(_inner),
418 Self::InvalidScopeException(_inner) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(_inner),
419 Self::SlowDownException(_inner) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(_inner),
420 Self::UnauthorizedClientException(_inner) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(_inner),
421 Self::UnsupportedGrantTypeException(_inner) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(_inner),
422 Self::Unhandled(_inner) => &_inner.meta,
423 }
424 }
425}
426impl ::aws_smithy_runtime_api::client::result::CreateUnhandledError for CreateTokenError {
427 fn create_unhandled_error(
428 source: ::std::boxed::Box<dyn ::std::error::Error + ::std::marker::Send + ::std::marker::Sync + 'static>,
429 meta: ::std::option::Option<::aws_smithy_types::error::ErrorMetadata>,
430 ) -> Self {
431 Self::Unhandled(crate::error::sealed_unhandled::Unhandled {
432 source,
433 meta: meta.unwrap_or_default(),
434 })
435 }
436}
437impl ::aws_types::request_id::RequestId for crate::operation::create_token::CreateTokenError {
438 fn request_id(&self) -> Option<&str> {
439 self.meta().request_id()
440 }
441}
442
443pub use crate::operation::create_token::_create_token_output::CreateTokenOutput;
444
445pub use crate::operation::create_token::_create_token_input::CreateTokenInput;
446
447mod _create_token_input;
448
449mod _create_token_output;
450
451pub mod builders;