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