aws_sdk_signin/operation/
create_o_auth2_token.rs1#[derive(::std::clone::Clone, ::std::default::Default, ::std::fmt::Debug)]
4#[non_exhaustive]
5pub struct CreateOAuth2Token;
6impl CreateOAuth2Token {
7 pub fn new() -> Self {
9 Self
10 }
11 pub const INPUT_SCHEMA: &'static ::aws_smithy_schema::Schema = crate::operation::create_o_auth2_token::CreateOAuth2TokenInput::SCHEMA;
13 pub const OUTPUT_SCHEMA: &'static ::aws_smithy_schema::Schema = crate::operation::create_o_auth2_token::CreateOAuth2TokenOutput::SCHEMA;
15 pub(crate) async fn orchestrate(
16 runtime_plugins: &::aws_smithy_runtime_api::client::runtime_plugin::RuntimePlugins,
17 input: crate::operation::create_o_auth2_token::CreateOAuth2TokenInput,
18 ) -> ::std::result::Result<crate::operation::create_o_auth2_token::CreateOAuth2TokenOutput, ::aws_smithy_runtime_api::client::result::SdkError<crate::operation::create_o_auth2_token::CreateOAuth2TokenError, ::aws_smithy_runtime_api::client::orchestrator::HttpResponse>> {
19 let map_err = |err: ::aws_smithy_runtime_api::client::result::SdkError<::aws_smithy_runtime_api::client::interceptors::context::Error, ::aws_smithy_runtime_api::client::orchestrator::HttpResponse>| {
20 err.map_service_error(|err| {
21 err.downcast::<crate::operation::create_o_auth2_token::CreateOAuth2TokenError>().expect("correct error type")
22 })
23 };
24 let context = Self::orchestrate_with_stop_point(runtime_plugins, input, ::aws_smithy_runtime::client::orchestrator::StopPoint::None)
25 .await
26 .map_err(map_err)?;
27 let output = context.finalize().map_err(map_err)?;
28 ::std::result::Result::Ok(output.downcast::<crate::operation::create_o_auth2_token::CreateOAuth2TokenOutput>().expect("correct output type"))
29 }
30
31 pub(crate) async fn orchestrate_with_stop_point(
32 runtime_plugins: &::aws_smithy_runtime_api::client::runtime_plugin::RuntimePlugins,
33 input: crate::operation::create_o_auth2_token::CreateOAuth2TokenInput,
34 stop_point: ::aws_smithy_runtime::client::orchestrator::StopPoint,
35 ) -> ::std::result::Result<::aws_smithy_runtime_api::client::interceptors::context::InterceptorContext, ::aws_smithy_runtime_api::client::result::SdkError<::aws_smithy_runtime_api::client::interceptors::context::Error, ::aws_smithy_runtime_api::client::orchestrator::HttpResponse>> {
36 let input = ::aws_smithy_runtime_api::client::interceptors::context::Input::erase(input);
37 use ::tracing::Instrument;
38 ::aws_smithy_runtime::client::orchestrator::invoke_with_stop_point(
39 "Signin",
40 "CreateOAuth2Token",
41 input,
42 runtime_plugins,
43 stop_point
44 )
45 .instrument(::tracing::debug_span!(
48 "Signin.CreateOAuth2Token",
49 "rpc.service" = "Signin",
50 "rpc.method" = "CreateOAuth2Token",
51 "sdk_invocation_id" = ::fastrand::u32(1_000_000..10_000_000),
52 "rpc.system" = "aws-api",
53 ))
54 .await
55 }
56
57 pub(crate) fn operation_runtime_plugins(
58 client_runtime_plugins: ::aws_smithy_runtime_api::client::runtime_plugin::RuntimePlugins,
59 client_config: &crate::config::Config,
60 config_override: ::std::option::Option<crate::config::Builder>,
61 ) -> ::aws_smithy_runtime_api::client::runtime_plugin::RuntimePlugins {
62 let mut runtime_plugins = client_runtime_plugins.with_operation_plugin(Self::new());
63
64 if let ::std::option::Option::Some(config_override) = config_override {
65 for plugin in config_override.runtime_plugins.iter().cloned() {
66 runtime_plugins = runtime_plugins.with_operation_plugin(plugin);
67 }
68 runtime_plugins = runtime_plugins.with_operation_plugin(
69 crate::config::ConfigOverrideRuntimePlugin::new(config_override, client_config.config.clone(), &client_config.runtime_components)
70 );
71 }
72 runtime_plugins
73 }
74}
75impl ::aws_smithy_runtime_api::client::runtime_plugin::RuntimePlugin for CreateOAuth2Token {
76 fn config(&self) -> ::std::option::Option<::aws_smithy_types::config_bag::FrozenLayer> {
77 let mut cfg = ::aws_smithy_types::config_bag::Layer::new("CreateOAuth2Token");
78
79 cfg.store_put(::aws_smithy_runtime_api::client::ser_de::SharedRequestSerializer::new(CreateOAuth2TokenRequestSerializer));
80 cfg.store_put(::aws_smithy_runtime_api::client::ser_de::SharedResponseDeserializer::new(CreateOAuth2TokenResponseDeserializer));
81
82 cfg.store_put(::aws_smithy_runtime_api::client::auth::AuthSchemeOptionResolverParams::new(
83 crate::config::auth::Params::builder()
84 .operation_name("CreateOAuth2Token")
85 .build()
86 .expect("required fields set")
87 ));
88
89 cfg.store_put(::aws_smithy_runtime_api::client::orchestrator::SensitiveOutput);
90cfg.store_put(::aws_smithy_runtime_api::client::orchestrator::Metadata::new(
91 "CreateOAuth2Token",
92 "Signin",
93 ));
94
95 ::std::option::Option::Some(cfg.freeze())
96 }
97
98 fn runtime_components(&self, _: &::aws_smithy_runtime_api::client::runtime_components::RuntimeComponentsBuilder) -> ::std::borrow::Cow<'_, ::aws_smithy_runtime_api::client::runtime_components::RuntimeComponentsBuilder> {
99 #[allow(unused_mut)]
100 let mut rcb = ::aws_smithy_runtime_api::client::runtime_components::RuntimeComponentsBuilder::new("CreateOAuth2Token")
101 .with_interceptor(::aws_smithy_runtime::client::stalled_stream_protection::StalledStreamProtectionInterceptor::default())
102.with_interceptor(CreateOAuth2TokenEndpointParamsInterceptor)
103 .with_retry_classifier(::aws_smithy_runtime::client::retries::classifiers::TransientErrorClassifier::<crate::operation::create_o_auth2_token::CreateOAuth2TokenError>::new())
104.with_retry_classifier(::aws_smithy_runtime::client::retries::classifiers::ModeledAsRetryableClassifier::<crate::operation::create_o_auth2_token::CreateOAuth2TokenError>::new())
105.with_retry_classifier(::aws_runtime::retries::classifiers::AwsErrorCodeClassifier::<crate::operation::create_o_auth2_token::CreateOAuth2TokenError>::new());
106
107 ::std::borrow::Cow::Owned(rcb)
108 }
109 }
110
111
112#[derive(Debug)]
113 struct CreateOAuth2TokenResponseDeserializer;
114 impl ::aws_smithy_runtime_api::client::ser_de::DeserializeResponse for CreateOAuth2TokenResponseDeserializer {
115
116
117 fn deserialize_nonstreaming_with_config(&self, response: &::aws_smithy_runtime_api::client::orchestrator::HttpResponse, _cfg: &::aws_smithy_types::config_bag::ConfigBag) -> ::aws_smithy_runtime_api::client::interceptors::context::OutputOrError {
118 let (success, status) = (response.status().is_success(), response.status().as_u16());
119 #[allow(unused_mut)]
120 let mut force_error = false;
121 ::tracing::debug!(request_id = ?::aws_types::request_id::RequestId::request_id(response));
122 if !success && status != 200 || force_error {
123 let headers = response.headers();
124 let body = response.body().bytes().expect("body loaded");
125#[allow(unused_mut)]
126 let mut generic_builder = crate::protocol_serde::parse_http_error_metadata(status, headers, body)
127 .map_err(|e| ::aws_smithy_runtime_api::client::orchestrator::OrchestratorError::other(::aws_smithy_runtime_api::box_error::BoxError::from(e)))?;
128 generic_builder = ::aws_types::request_id::apply_request_id(generic_builder, headers);
129 let generic = generic_builder.build();
130let error_code = match generic.code() {
131 ::std::option::Option::Some(code) => code,
132 ::std::option::Option::None => return ::std::result::Result::Err(::aws_smithy_runtime_api::client::orchestrator::OrchestratorError::other(::aws_smithy_runtime_api::box_error::BoxError::from(crate::operation::create_o_auth2_token::CreateOAuth2TokenError::unhandled(generic)))),
133 };
134 let _error_message = generic.message().map(|msg| msg.to_owned());
135 let protocol = _cfg.load::<::aws_smithy_schema::protocol::SharedClientProtocol>()
136 .expect("a SharedClientProtocol is required");
137let err = match error_code {
138"AccessDeniedException" => crate::operation::create_o_auth2_token::CreateOAuth2TokenError::AccessDeniedException({
139let mut tmp = match protocol.deserialize_response(response, crate::types::error::AccessDeniedException::SCHEMA, _cfg)
140 .and_then(|mut deser| crate::types::error::AccessDeniedException::deserialize_with_response(&mut *deser, response.headers(), response.status().into(), body))
141 {
142 ::std::result::Result::Ok(val) => val,
143 ::std::result::Result::Err(e) => return ::std::result::Result::Err(::aws_smithy_runtime_api::client::orchestrator::OrchestratorError::other(::aws_smithy_runtime_api::box_error::BoxError::from(e))),
144 };
145 tmp.meta = generic;
146tmp
147}),
148"InternalServerException" => crate::operation::create_o_auth2_token::CreateOAuth2TokenError::InternalServerException({
149let mut tmp = match protocol.deserialize_response(response, crate::types::error::InternalServerException::SCHEMA, _cfg)
150 .and_then(|mut deser| crate::types::error::InternalServerException::deserialize_with_response(&mut *deser, response.headers(), response.status().into(), body))
151 {
152 ::std::result::Result::Ok(val) => val,
153 ::std::result::Result::Err(e) => return ::std::result::Result::Err(::aws_smithy_runtime_api::client::orchestrator::OrchestratorError::other(::aws_smithy_runtime_api::box_error::BoxError::from(e))),
154 };
155 tmp.meta = generic;
156tmp
157}),
158"TooManyRequestsError" => crate::operation::create_o_auth2_token::CreateOAuth2TokenError::TooManyRequestsError({
159let mut tmp = match protocol.deserialize_response(response, crate::types::error::TooManyRequestsError::SCHEMA, _cfg)
160 .and_then(|mut deser| crate::types::error::TooManyRequestsError::deserialize_with_response(&mut *deser, response.headers(), response.status().into(), body))
161 {
162 ::std::result::Result::Ok(val) => val,
163 ::std::result::Result::Err(e) => return ::std::result::Result::Err(::aws_smithy_runtime_api::client::orchestrator::OrchestratorError::other(::aws_smithy_runtime_api::box_error::BoxError::from(e))),
164 };
165 tmp.meta = generic;
166tmp
167}),
168"ValidationException" => crate::operation::create_o_auth2_token::CreateOAuth2TokenError::ValidationException({
169let mut tmp = match protocol.deserialize_response(response, crate::types::error::ValidationException::SCHEMA, _cfg)
170 .and_then(|mut deser| crate::types::error::ValidationException::deserialize_with_response(&mut *deser, response.headers(), response.status().into(), body))
171 {
172 ::std::result::Result::Ok(val) => val,
173 ::std::result::Result::Err(e) => return ::std::result::Result::Err(::aws_smithy_runtime_api::client::orchestrator::OrchestratorError::other(::aws_smithy_runtime_api::box_error::BoxError::from(e))),
174 };
175 tmp.meta = generic;
176tmp
177}),
178_ => crate::operation::create_o_auth2_token::CreateOAuth2TokenError::generic(generic)
179};
180 ::std::result::Result::Err(::aws_smithy_runtime_api::client::orchestrator::OrchestratorError::operation(::aws_smithy_runtime_api::client::interceptors::context::Error::erase(err)))
181} else {
182 let protocol = _cfg.load::<::aws_smithy_schema::protocol::SharedClientProtocol>()
183 .expect("a SharedClientProtocol is required");
184 let mut deser = protocol.deserialize_response(response, CreateOAuth2Token::OUTPUT_SCHEMA, _cfg)
185 .map_err(|e| ::aws_smithy_runtime_api::client::orchestrator::OrchestratorError::other(::aws_smithy_runtime_api::box_error::BoxError::from(e)))?;
186 let body = response.body().bytes().expect("body loaded");
187 let output = crate::operation::create_o_auth2_token::CreateOAuth2TokenOutput::deserialize_with_response(
188 &mut *deser,
189 response.headers(),
190 response.status().into(),
191 body,
192 ).map_err(|e| ::aws_smithy_runtime_api::client::orchestrator::OrchestratorError::other(::aws_smithy_runtime_api::box_error::BoxError::from(e)))?;
193 ::std::result::Result::Ok(::aws_smithy_runtime_api::client::interceptors::context::Output::erase(output))
194 }
195 }
196 }
197#[derive(Debug)]
198 struct CreateOAuth2TokenRequestSerializer;
199 impl ::aws_smithy_runtime_api::client::ser_de::SerializeRequest for CreateOAuth2TokenRequestSerializer {
200 #[allow(unused_mut, clippy::let_and_return, clippy::needless_borrow, clippy::useless_conversion)]
201 fn serialize_input(&self, input: ::aws_smithy_runtime_api::client::interceptors::context::Input, _cfg: &mut ::aws_smithy_types::config_bag::ConfigBag) -> ::std::result::Result<::aws_smithy_runtime_api::client::orchestrator::HttpRequest, ::aws_smithy_runtime_api::box_error::BoxError> {
202 let input = input.downcast::<crate::operation::create_o_auth2_token::CreateOAuth2TokenInput>().expect("correct type");
203 let protocol = _cfg.load::<::aws_smithy_schema::protocol::SharedClientProtocol>()
204 .expect("a SharedClientProtocol is required");
205 let mut request = protocol.serialize_request(
206 &input, CreateOAuth2Token::INPUT_SCHEMA, "", _cfg,
207 ).map_err(::aws_smithy_runtime_api::box_error::BoxError::from)?;
208
209 return ::std::result::Result::Ok(request);
210 }
211 }
212#[derive(Debug)]
213 struct CreateOAuth2TokenEndpointParamsInterceptor;
214
215 impl ::aws_smithy_runtime_api::client::interceptors::Intercept for CreateOAuth2TokenEndpointParamsInterceptor {
216 fn name(&self) -> &'static str {
217 "CreateOAuth2TokenEndpointParamsInterceptor"
218 }
219
220 fn read_before_execution(
221 &self,
222 context: &::aws_smithy_runtime_api::client::interceptors::context::BeforeSerializationInterceptorContextRef<'_, ::aws_smithy_runtime_api::client::interceptors::context::Input, ::aws_smithy_runtime_api::client::interceptors::context::Output, ::aws_smithy_runtime_api::client::interceptors::context::Error>,
223 cfg: &mut ::aws_smithy_types::config_bag::ConfigBag,
224 ) -> ::std::result::Result<(), ::aws_smithy_runtime_api::box_error::BoxError> {
225 let _input = context.input()
226 .downcast_ref::<CreateOAuth2TokenInput>()
227 .ok_or("failed to downcast to CreateOAuth2TokenInput")?;
228
229
230
231 let params = crate::config::endpoint::Params::builder()
232 .set_use_dual_stack(cfg.load::<::aws_types::endpoint_config::UseDualStack>().map(|ty| ty.0))
233.set_use_fips(cfg.load::<::aws_types::endpoint_config::UseFips>().map(|ty| ty.0))
234.set_endpoint(cfg.load::<::aws_types::endpoint_config::EndpointUrl>().map(|ty| ty.0.clone()))
235.set_region(cfg.load::<::aws_types::region::Region>().map(|r|r.as_ref().to_owned()))
236 .build()
237 .map_err(|err| ::aws_smithy_runtime_api::client::interceptors::error::ContextAttachedError::new("endpoint params could not be built", err))?;
238 cfg.interceptor_state().store_put(::aws_smithy_runtime_api::client::endpoint::EndpointResolverParams::new(params));
239 ::std::result::Result::Ok(())
240 }
241 }
242
243 #[non_exhaustive]
250#[derive(::std::fmt::Debug)]
251pub enum CreateOAuth2TokenError {
252 AccessDeniedException(crate::types::error::AccessDeniedException),
254 InternalServerException(crate::types::error::InternalServerException),
256 TooManyRequestsError(crate::types::error::TooManyRequestsError),
258 ValidationException(crate::types::error::ValidationException),
260 #[deprecated(note = "Matching `Unhandled` directly is not forwards compatible. Instead, match using a \
262 variable wildcard pattern and check `.code()`:
263 \
264 `err if err.code() == Some(\"SpecificExceptionCode\") => { /* handle the error */ }`
265 \
266 See [`ProvideErrorMetadata`](#impl-ProvideErrorMetadata-for-CreateOAuth2TokenError) for what information is available for the error.")]
267 Unhandled(crate::error::sealed_unhandled::Unhandled),
268}
269impl CreateOAuth2TokenError {
270 pub fn unhandled(err: impl ::std::convert::Into<::std::boxed::Box<dyn ::std::error::Error + ::std::marker::Send + ::std::marker::Sync + 'static>>) -> Self {
272 Self::Unhandled(crate::error::sealed_unhandled::Unhandled { source: err.into(), meta: ::std::default::Default::default() })
273 }
274
275 pub fn generic(err: ::aws_smithy_types::error::ErrorMetadata) -> Self {
277 Self::Unhandled(crate::error::sealed_unhandled::Unhandled { source: err.clone().into(), meta: err })
278 }
279 pub fn meta(&self) -> &::aws_smithy_types::error::ErrorMetadata {
284 match self {
285 Self::AccessDeniedException(e) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(e),
286 Self::InternalServerException(e) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(e),
287 Self::TooManyRequestsError(e) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(e),
288 Self::ValidationException(e) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(e),
289 Self::Unhandled(e) => &e.meta,
290 }
291 }
292 pub fn is_access_denied_exception(&self) -> bool {
294 matches!(self, Self::AccessDeniedException(_))
295 }
296 pub fn is_internal_server_exception(&self) -> bool {
298 matches!(self, Self::InternalServerException(_))
299 }
300 pub fn is_too_many_requests_error(&self) -> bool {
302 matches!(self, Self::TooManyRequestsError(_))
303 }
304 pub fn is_validation_exception(&self) -> bool {
306 matches!(self, Self::ValidationException(_))
307 }
308}
309impl ::std::error::Error for CreateOAuth2TokenError {
310 fn source(&self) -> ::std::option::Option<&(dyn ::std::error::Error + 'static)> {
311 match self {
312 Self::AccessDeniedException(_inner) =>
313 ::std::option::Option::Some(_inner)
314 ,
315 Self::InternalServerException(_inner) =>
316 ::std::option::Option::Some(_inner)
317 ,
318 Self::TooManyRequestsError(_inner) =>
319 ::std::option::Option::Some(_inner)
320 ,
321 Self::ValidationException(_inner) =>
322 ::std::option::Option::Some(_inner)
323 ,
324 Self::Unhandled(_inner) => {
325 ::std::option::Option::Some(&*_inner.source)
326 }
327 }
328 }
329}
330impl ::std::fmt::Display for CreateOAuth2TokenError {
331 fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
332 match self {
333 Self::AccessDeniedException(_inner) =>
334 _inner.fmt(f)
335 ,
336 Self::InternalServerException(_inner) =>
337 _inner.fmt(f)
338 ,
339 Self::TooManyRequestsError(_inner) =>
340 _inner.fmt(f)
341 ,
342 Self::ValidationException(_inner) =>
343 _inner.fmt(f)
344 ,
345 Self::Unhandled(_inner) => {
346 if let ::std::option::Option::Some(code) = ::aws_smithy_types::error::metadata::ProvideErrorMetadata::code(self) {
347 write!(f, "unhandled error ({code})")
348 } else {
349 f.write_str("unhandled error")
350 }
351 }
352 }
353 }
354}
355impl ::aws_smithy_types::retry::ProvideErrorKind for CreateOAuth2TokenError {
356 fn code(&self) -> ::std::option::Option<&str> {
357 ::aws_smithy_types::error::metadata::ProvideErrorMetadata::code(self)
358 }
359 fn retryable_error_kind(&self) -> ::std::option::Option<::aws_smithy_types::retry::ErrorKind> {
360 ::std::option::Option::None
361 }
362}
363impl ::aws_smithy_types::error::metadata::ProvideErrorMetadata for CreateOAuth2TokenError {
364 fn meta(&self) -> &::aws_smithy_types::error::ErrorMetadata {
365 match self {
366 Self::AccessDeniedException(_inner) =>
367 ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(_inner)
368 ,
369 Self::InternalServerException(_inner) =>
370 ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(_inner)
371 ,
372 Self::TooManyRequestsError(_inner) =>
373 ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(_inner)
374 ,
375 Self::ValidationException(_inner) =>
376 ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(_inner)
377 ,
378 Self::Unhandled(_inner) => {
379 &_inner.meta
380 }
381 }
382 }
383}
384impl ::aws_smithy_runtime_api::client::result::CreateUnhandledError for CreateOAuth2TokenError {
385 fn create_unhandled_error(
386 source: ::std::boxed::Box<dyn ::std::error::Error + ::std::marker::Send + ::std::marker::Sync + 'static>,
387 meta: ::std::option::Option<::aws_smithy_types::error::ErrorMetadata>
388 ) -> Self {
389 Self::Unhandled(crate::error::sealed_unhandled::Unhandled { source, meta: meta.unwrap_or_default() })
390 }
391}
392impl ::aws_types::request_id::RequestId for crate::operation::create_o_auth2_token::CreateOAuth2TokenError {
393 fn request_id(&self) -> Option<&str> {
394 self.meta().request_id()
395 }
396 }
397
398pub use crate::operation::create_o_auth2_token::_create_o_auth2_token_input::CreateOAuth2TokenInput;
399
400pub use crate::operation::create_o_auth2_token::_create_o_auth2_token_output::CreateOAuth2TokenOutput;
401
402mod _create_o_auth2_token_input;
403
404mod _create_o_auth2_token_output;
405
406pub mod builders;
408