aws_sdk_ssooidc/operation/
start_device_authorization.rs
1#[derive(::std::clone::Clone, ::std::default::Default, ::std::fmt::Debug)]
4#[non_exhaustive]
5pub struct StartDeviceAuthorization;
6impl StartDeviceAuthorization {
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::start_device_authorization::StartDeviceAuthorizationInput,
14 ) -> ::std::result::Result<
15 crate::operation::start_device_authorization::StartDeviceAuthorizationOutput,
16 ::aws_smithy_runtime_api::client::result::SdkError<
17 crate::operation::start_device_authorization::StartDeviceAuthorizationError,
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::start_device_authorization::StartDeviceAuthorizationError>()
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::start_device_authorization::StartDeviceAuthorizationOutput>()
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::start_device_authorization::StartDeviceAuthorizationInput,
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 ::aws_smithy_runtime::client::orchestrator::invoke_with_stop_point("ssooidc", "StartDeviceAuthorization", input, runtime_plugins, stop_point)
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 runtime_plugins = runtime_plugins.with_client_plugin(crate::auth_plugin::DefaultAuthOptionsPlugin::new(vec![
64 ::aws_smithy_runtime::client::auth::no_auth::NO_AUTH_SCHEME_ID,
65 ]));
66 if let ::std::option::Option::Some(config_override) = config_override {
67 for plugin in config_override.runtime_plugins.iter().cloned() {
68 runtime_plugins = runtime_plugins.with_operation_plugin(plugin);
69 }
70 runtime_plugins = runtime_plugins.with_operation_plugin(crate::config::ConfigOverrideRuntimePlugin::new(
71 config_override,
72 client_config.config.clone(),
73 &client_config.runtime_components,
74 ));
75 }
76 runtime_plugins
77 }
78}
79impl ::aws_smithy_runtime_api::client::runtime_plugin::RuntimePlugin for StartDeviceAuthorization {
80 fn config(&self) -> ::std::option::Option<::aws_smithy_types::config_bag::FrozenLayer> {
81 let mut cfg = ::aws_smithy_types::config_bag::Layer::new("StartDeviceAuthorization");
82
83 cfg.store_put(::aws_smithy_runtime_api::client::ser_de::SharedRequestSerializer::new(
84 StartDeviceAuthorizationRequestSerializer,
85 ));
86 cfg.store_put(::aws_smithy_runtime_api::client::ser_de::SharedResponseDeserializer::new(
87 StartDeviceAuthorizationResponseDeserializer,
88 ));
89
90 cfg.store_put(::aws_smithy_runtime_api::client::auth::AuthSchemeOptionResolverParams::new(
91 ::aws_smithy_runtime_api::client::auth::static_resolver::StaticAuthSchemeOptionResolverParams::new(),
92 ));
93
94 cfg.store_put(::aws_smithy_runtime_api::client::orchestrator::Metadata::new(
95 "StartDeviceAuthorization",
96 "ssooidc",
97 ));
98
99 ::std::option::Option::Some(cfg.freeze())
100 }
101
102 fn runtime_components(
103 &self,
104 _: &::aws_smithy_runtime_api::client::runtime_components::RuntimeComponentsBuilder,
105 ) -> ::std::borrow::Cow<'_, ::aws_smithy_runtime_api::client::runtime_components::RuntimeComponentsBuilder> {
106 #[allow(unused_mut)]
107 let mut rcb = ::aws_smithy_runtime_api::client::runtime_components::RuntimeComponentsBuilder::new("StartDeviceAuthorization")
108 .with_interceptor(::aws_smithy_runtime::client::stalled_stream_protection::StalledStreamProtectionInterceptor::default())
109 .with_interceptor(StartDeviceAuthorizationEndpointParamsInterceptor)
110 .with_retry_classifier(::aws_smithy_runtime::client::retries::classifiers::TransientErrorClassifier::<
111 crate::operation::start_device_authorization::StartDeviceAuthorizationError,
112 >::new())
113 .with_retry_classifier(::aws_smithy_runtime::client::retries::classifiers::ModeledAsRetryableClassifier::<
114 crate::operation::start_device_authorization::StartDeviceAuthorizationError,
115 >::new())
116 .with_retry_classifier(::aws_runtime::retries::classifiers::AwsErrorCodeClassifier::<
117 crate::operation::start_device_authorization::StartDeviceAuthorizationError,
118 >::new());
119
120 ::std::borrow::Cow::Owned(rcb)
121 }
122}
123
124#[derive(Debug)]
125struct StartDeviceAuthorizationResponseDeserializer;
126impl ::aws_smithy_runtime_api::client::ser_de::DeserializeResponse for StartDeviceAuthorizationResponseDeserializer {
127 fn deserialize_nonstreaming(
128 &self,
129 response: &::aws_smithy_runtime_api::client::orchestrator::HttpResponse,
130 ) -> ::aws_smithy_runtime_api::client::interceptors::context::OutputOrError {
131 let (success, status) = (response.status().is_success(), response.status().as_u16());
132 let headers = response.headers();
133 let body = response.body().bytes().expect("body loaded");
134 #[allow(unused_mut)]
135 let mut force_error = false;
136 ::tracing::debug!(request_id = ?::aws_types::request_id::RequestId::request_id(response));
137 let parse_result = if !success && status != 200 || force_error {
138 crate::protocol_serde::shape_start_device_authorization::de_start_device_authorization_http_error(status, headers, body)
139 } else {
140 crate::protocol_serde::shape_start_device_authorization::de_start_device_authorization_http_response(status, headers, body)
141 };
142 crate::protocol_serde::type_erase_result(parse_result)
143 }
144}
145#[derive(Debug)]
146struct StartDeviceAuthorizationRequestSerializer;
147impl ::aws_smithy_runtime_api::client::ser_de::SerializeRequest for StartDeviceAuthorizationRequestSerializer {
148 #[allow(unused_mut, clippy::let_and_return, clippy::needless_borrow, clippy::useless_conversion)]
149 fn serialize_input(
150 &self,
151 input: ::aws_smithy_runtime_api::client::interceptors::context::Input,
152 _cfg: &mut ::aws_smithy_types::config_bag::ConfigBag,
153 ) -> ::std::result::Result<::aws_smithy_runtime_api::client::orchestrator::HttpRequest, ::aws_smithy_runtime_api::box_error::BoxError> {
154 let input = input
155 .downcast::<crate::operation::start_device_authorization::StartDeviceAuthorizationInput>()
156 .expect("correct type");
157 let _header_serialization_settings = _cfg
158 .load::<crate::serialization_settings::HeaderSerializationSettings>()
159 .cloned()
160 .unwrap_or_default();
161 let mut request_builder = {
162 fn uri_base(
163 _input: &crate::operation::start_device_authorization::StartDeviceAuthorizationInput,
164 output: &mut ::std::string::String,
165 ) -> ::std::result::Result<(), ::aws_smithy_types::error::operation::BuildError> {
166 use ::std::fmt::Write as _;
167 ::std::write!(output, "/device_authorization").expect("formatting should succeed");
168 ::std::result::Result::Ok(())
169 }
170 #[allow(clippy::unnecessary_wraps)]
171 fn update_http_builder(
172 input: &crate::operation::start_device_authorization::StartDeviceAuthorizationInput,
173 builder: ::http::request::Builder,
174 ) -> ::std::result::Result<::http::request::Builder, ::aws_smithy_types::error::operation::BuildError> {
175 let mut uri = ::std::string::String::new();
176 uri_base(input, &mut uri)?;
177 ::std::result::Result::Ok(builder.method("POST").uri(uri))
178 }
179 let mut builder = update_http_builder(&input, ::http::request::Builder::new())?;
180 builder = _header_serialization_settings.set_default_header(builder, ::http::header::CONTENT_TYPE, "application/json");
181 builder
182 };
183 let body = ::aws_smithy_types::body::SdkBody::from(
184 crate::protocol_serde::shape_start_device_authorization::ser_start_device_authorization_input(&input)?,
185 );
186 if let Some(content_length) = body.content_length() {
187 let content_length = content_length.to_string();
188 request_builder = _header_serialization_settings.set_default_header(request_builder, ::http::header::CONTENT_LENGTH, &content_length);
189 }
190 ::std::result::Result::Ok(request_builder.body(body).expect("valid request").try_into().unwrap())
191 }
192}
193#[derive(Debug)]
194struct StartDeviceAuthorizationEndpointParamsInterceptor;
195
196impl ::aws_smithy_runtime_api::client::interceptors::Intercept for StartDeviceAuthorizationEndpointParamsInterceptor {
197 fn name(&self) -> &'static str {
198 "StartDeviceAuthorizationEndpointParamsInterceptor"
199 }
200
201 fn read_before_execution(
202 &self,
203 context: &::aws_smithy_runtime_api::client::interceptors::context::BeforeSerializationInterceptorContextRef<
204 '_,
205 ::aws_smithy_runtime_api::client::interceptors::context::Input,
206 ::aws_smithy_runtime_api::client::interceptors::context::Output,
207 ::aws_smithy_runtime_api::client::interceptors::context::Error,
208 >,
209 cfg: &mut ::aws_smithy_types::config_bag::ConfigBag,
210 ) -> ::std::result::Result<(), ::aws_smithy_runtime_api::box_error::BoxError> {
211 let _input = context
212 .input()
213 .downcast_ref::<StartDeviceAuthorizationInput>()
214 .ok_or("failed to downcast to StartDeviceAuthorizationInput")?;
215
216 let params = crate::config::endpoint::Params::builder()
217 .set_region(cfg.load::<::aws_types::region::Region>().map(|r| r.as_ref().to_owned()))
218 .set_use_dual_stack(cfg.load::<::aws_types::endpoint_config::UseDualStack>().map(|ty| ty.0))
219 .set_use_fips(cfg.load::<::aws_types::endpoint_config::UseFips>().map(|ty| ty.0))
220 .set_endpoint(cfg.load::<::aws_types::endpoint_config::EndpointUrl>().map(|ty| ty.0.clone()))
221 .build()
222 .map_err(|err| {
223 ::aws_smithy_runtime_api::client::interceptors::error::ContextAttachedError::new("endpoint params could not be built", err)
224 })?;
225 cfg.interceptor_state()
226 .store_put(::aws_smithy_runtime_api::client::endpoint::EndpointResolverParams::new(params));
227 ::std::result::Result::Ok(())
228 }
229}
230
231#[non_exhaustive]
236#[derive(::std::fmt::Debug)]
237pub enum StartDeviceAuthorizationError {
238 InternalServerException(crate::types::error::InternalServerException),
240 InvalidClientException(crate::types::error::InvalidClientException),
242 InvalidRequestException(crate::types::error::InvalidRequestException),
244 SlowDownException(crate::types::error::SlowDownException),
246 UnauthorizedClientException(crate::types::error::UnauthorizedClientException),
248 #[deprecated(note = "Matching `Unhandled` directly is not forwards compatible. Instead, match using a \
250 variable wildcard pattern and check `.code()`:
251 \
252 `err if err.code() == Some(\"SpecificExceptionCode\") => { /* handle the error */ }`
253 \
254 See [`ProvideErrorMetadata`](#impl-ProvideErrorMetadata-for-StartDeviceAuthorizationError) for what information is available for the error.")]
255 Unhandled(crate::error::sealed_unhandled::Unhandled),
256}
257impl StartDeviceAuthorizationError {
258 pub fn unhandled(
260 err: impl ::std::convert::Into<::std::boxed::Box<dyn ::std::error::Error + ::std::marker::Send + ::std::marker::Sync + 'static>>,
261 ) -> Self {
262 Self::Unhandled(crate::error::sealed_unhandled::Unhandled {
263 source: err.into(),
264 meta: ::std::default::Default::default(),
265 })
266 }
267
268 pub fn generic(err: ::aws_smithy_types::error::ErrorMetadata) -> Self {
270 Self::Unhandled(crate::error::sealed_unhandled::Unhandled {
271 source: err.clone().into(),
272 meta: err,
273 })
274 }
275 pub fn meta(&self) -> &::aws_smithy_types::error::ErrorMetadata {
280 match self {
281 Self::InternalServerException(e) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(e),
282 Self::InvalidClientException(e) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(e),
283 Self::InvalidRequestException(e) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(e),
284 Self::SlowDownException(e) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(e),
285 Self::UnauthorizedClientException(e) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(e),
286 Self::Unhandled(e) => &e.meta,
287 }
288 }
289 pub fn is_internal_server_exception(&self) -> bool {
291 matches!(self, Self::InternalServerException(_))
292 }
293 pub fn is_invalid_client_exception(&self) -> bool {
295 matches!(self, Self::InvalidClientException(_))
296 }
297 pub fn is_invalid_request_exception(&self) -> bool {
299 matches!(self, Self::InvalidRequestException(_))
300 }
301 pub fn is_slow_down_exception(&self) -> bool {
303 matches!(self, Self::SlowDownException(_))
304 }
305 pub fn is_unauthorized_client_exception(&self) -> bool {
307 matches!(self, Self::UnauthorizedClientException(_))
308 }
309}
310impl ::std::error::Error for StartDeviceAuthorizationError {
311 fn source(&self) -> ::std::option::Option<&(dyn ::std::error::Error + 'static)> {
312 match self {
313 Self::InternalServerException(_inner) => ::std::option::Option::Some(_inner),
314 Self::InvalidClientException(_inner) => ::std::option::Option::Some(_inner),
315 Self::InvalidRequestException(_inner) => ::std::option::Option::Some(_inner),
316 Self::SlowDownException(_inner) => ::std::option::Option::Some(_inner),
317 Self::UnauthorizedClientException(_inner) => ::std::option::Option::Some(_inner),
318 Self::Unhandled(_inner) => ::std::option::Option::Some(&*_inner.source),
319 }
320 }
321}
322impl ::std::fmt::Display for StartDeviceAuthorizationError {
323 fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
324 match self {
325 Self::InternalServerException(_inner) => _inner.fmt(f),
326 Self::InvalidClientException(_inner) => _inner.fmt(f),
327 Self::InvalidRequestException(_inner) => _inner.fmt(f),
328 Self::SlowDownException(_inner) => _inner.fmt(f),
329 Self::UnauthorizedClientException(_inner) => _inner.fmt(f),
330 Self::Unhandled(_inner) => {
331 if let ::std::option::Option::Some(code) = ::aws_smithy_types::error::metadata::ProvideErrorMetadata::code(self) {
332 write!(f, "unhandled error ({code})")
333 } else {
334 f.write_str("unhandled error")
335 }
336 }
337 }
338 }
339}
340impl ::aws_smithy_types::retry::ProvideErrorKind for StartDeviceAuthorizationError {
341 fn code(&self) -> ::std::option::Option<&str> {
342 ::aws_smithy_types::error::metadata::ProvideErrorMetadata::code(self)
343 }
344 fn retryable_error_kind(&self) -> ::std::option::Option<::aws_smithy_types::retry::ErrorKind> {
345 ::std::option::Option::None
346 }
347}
348impl ::aws_smithy_types::error::metadata::ProvideErrorMetadata for StartDeviceAuthorizationError {
349 fn meta(&self) -> &::aws_smithy_types::error::ErrorMetadata {
350 match self {
351 Self::InternalServerException(_inner) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(_inner),
352 Self::InvalidClientException(_inner) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(_inner),
353 Self::InvalidRequestException(_inner) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(_inner),
354 Self::SlowDownException(_inner) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(_inner),
355 Self::UnauthorizedClientException(_inner) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(_inner),
356 Self::Unhandled(_inner) => &_inner.meta,
357 }
358 }
359}
360impl ::aws_smithy_runtime_api::client::result::CreateUnhandledError for StartDeviceAuthorizationError {
361 fn create_unhandled_error(
362 source: ::std::boxed::Box<dyn ::std::error::Error + ::std::marker::Send + ::std::marker::Sync + 'static>,
363 meta: ::std::option::Option<::aws_smithy_types::error::ErrorMetadata>,
364 ) -> Self {
365 Self::Unhandled(crate::error::sealed_unhandled::Unhandled {
366 source,
367 meta: meta.unwrap_or_default(),
368 })
369 }
370}
371impl ::aws_types::request_id::RequestId for crate::operation::start_device_authorization::StartDeviceAuthorizationError {
372 fn request_id(&self) -> Option<&str> {
373 self.meta().request_id()
374 }
375}
376
377pub use crate::operation::start_device_authorization::_start_device_authorization_output::StartDeviceAuthorizationOutput;
378
379pub use crate::operation::start_device_authorization::_start_device_authorization_input::StartDeviceAuthorizationInput;
380
381mod _start_device_authorization_input;
382
383mod _start_device_authorization_output;
384
385pub mod builders;