aws_sdk_ssooidc/operation/
start_device_authorization.rs1#[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]
233#[derive(::std::fmt::Debug)]
234pub enum StartDeviceAuthorizationError {
235 InternalServerException(crate::types::error::InternalServerException),
237 InvalidClientException(crate::types::error::InvalidClientException),
239 InvalidRequestException(crate::types::error::InvalidRequestException),
241 SlowDownException(crate::types::error::SlowDownException),
243 UnauthorizedClientException(crate::types::error::UnauthorizedClientException),
245 #[deprecated(note = "Matching `Unhandled` directly is not forwards compatible. Instead, match using a \
247 variable wildcard pattern and check `.code()`:
248 \
249 `err if err.code() == Some(\"SpecificExceptionCode\") => { /* handle the error */ }`
250 \
251 See [`ProvideErrorMetadata`](#impl-ProvideErrorMetadata-for-StartDeviceAuthorizationError) for what information is available for the error.")]
252 Unhandled(crate::error::sealed_unhandled::Unhandled),
253}
254impl StartDeviceAuthorizationError {
255 pub fn unhandled(
257 err: impl ::std::convert::Into<::std::boxed::Box<dyn ::std::error::Error + ::std::marker::Send + ::std::marker::Sync + 'static>>,
258 ) -> Self {
259 Self::Unhandled(crate::error::sealed_unhandled::Unhandled {
260 source: err.into(),
261 meta: ::std::default::Default::default(),
262 })
263 }
264
265 pub fn generic(err: ::aws_smithy_types::error::ErrorMetadata) -> Self {
267 Self::Unhandled(crate::error::sealed_unhandled::Unhandled {
268 source: err.clone().into(),
269 meta: err,
270 })
271 }
272 pub fn meta(&self) -> &::aws_smithy_types::error::ErrorMetadata {
277 match self {
278 Self::InternalServerException(e) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(e),
279 Self::InvalidClientException(e) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(e),
280 Self::InvalidRequestException(e) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(e),
281 Self::SlowDownException(e) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(e),
282 Self::UnauthorizedClientException(e) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(e),
283 Self::Unhandled(e) => &e.meta,
284 }
285 }
286 pub fn is_internal_server_exception(&self) -> bool {
288 matches!(self, Self::InternalServerException(_))
289 }
290 pub fn is_invalid_client_exception(&self) -> bool {
292 matches!(self, Self::InvalidClientException(_))
293 }
294 pub fn is_invalid_request_exception(&self) -> bool {
296 matches!(self, Self::InvalidRequestException(_))
297 }
298 pub fn is_slow_down_exception(&self) -> bool {
300 matches!(self, Self::SlowDownException(_))
301 }
302 pub fn is_unauthorized_client_exception(&self) -> bool {
304 matches!(self, Self::UnauthorizedClientException(_))
305 }
306}
307impl ::std::error::Error for StartDeviceAuthorizationError {
308 fn source(&self) -> ::std::option::Option<&(dyn ::std::error::Error + 'static)> {
309 match self {
310 Self::InternalServerException(_inner) => ::std::option::Option::Some(_inner),
311 Self::InvalidClientException(_inner) => ::std::option::Option::Some(_inner),
312 Self::InvalidRequestException(_inner) => ::std::option::Option::Some(_inner),
313 Self::SlowDownException(_inner) => ::std::option::Option::Some(_inner),
314 Self::UnauthorizedClientException(_inner) => ::std::option::Option::Some(_inner),
315 Self::Unhandled(_inner) => ::std::option::Option::Some(&*_inner.source),
316 }
317 }
318}
319impl ::std::fmt::Display for StartDeviceAuthorizationError {
320 fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
321 match self {
322 Self::InternalServerException(_inner) => _inner.fmt(f),
323 Self::InvalidClientException(_inner) => _inner.fmt(f),
324 Self::InvalidRequestException(_inner) => _inner.fmt(f),
325 Self::SlowDownException(_inner) => _inner.fmt(f),
326 Self::UnauthorizedClientException(_inner) => _inner.fmt(f),
327 Self::Unhandled(_inner) => {
328 if let ::std::option::Option::Some(code) = ::aws_smithy_types::error::metadata::ProvideErrorMetadata::code(self) {
329 write!(f, "unhandled error ({code})")
330 } else {
331 f.write_str("unhandled error")
332 }
333 }
334 }
335 }
336}
337impl ::aws_smithy_types::retry::ProvideErrorKind for StartDeviceAuthorizationError {
338 fn code(&self) -> ::std::option::Option<&str> {
339 ::aws_smithy_types::error::metadata::ProvideErrorMetadata::code(self)
340 }
341 fn retryable_error_kind(&self) -> ::std::option::Option<::aws_smithy_types::retry::ErrorKind> {
342 ::std::option::Option::None
343 }
344}
345impl ::aws_smithy_types::error::metadata::ProvideErrorMetadata for StartDeviceAuthorizationError {
346 fn meta(&self) -> &::aws_smithy_types::error::ErrorMetadata {
347 match self {
348 Self::InternalServerException(_inner) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(_inner),
349 Self::InvalidClientException(_inner) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(_inner),
350 Self::InvalidRequestException(_inner) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(_inner),
351 Self::SlowDownException(_inner) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(_inner),
352 Self::UnauthorizedClientException(_inner) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(_inner),
353 Self::Unhandled(_inner) => &_inner.meta,
354 }
355 }
356}
357impl ::aws_smithy_runtime_api::client::result::CreateUnhandledError for StartDeviceAuthorizationError {
358 fn create_unhandled_error(
359 source: ::std::boxed::Box<dyn ::std::error::Error + ::std::marker::Send + ::std::marker::Sync + 'static>,
360 meta: ::std::option::Option<::aws_smithy_types::error::ErrorMetadata>,
361 ) -> Self {
362 Self::Unhandled(crate::error::sealed_unhandled::Unhandled {
363 source,
364 meta: meta.unwrap_or_default(),
365 })
366 }
367}
368impl ::aws_types::request_id::RequestId for crate::operation::start_device_authorization::StartDeviceAuthorizationError {
369 fn request_id(&self) -> Option<&str> {
370 self.meta().request_id()
371 }
372}
373
374pub use crate::operation::start_device_authorization::_start_device_authorization_output::StartDeviceAuthorizationOutput;
375
376pub use crate::operation::start_device_authorization::_start_device_authorization_input::StartDeviceAuthorizationInput;
377
378mod _start_device_authorization_input;
379
380mod _start_device_authorization_output;
381
382pub mod builders;