1 - | // Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
|
2 - | #[allow(clippy::unnecessary_wraps)]
|
3 - | pub fn de_start_device_authorization_http_error(
|
4 - | _response_status: u16,
|
5 - | _response_headers: &::aws_smithy_runtime_api::http::Headers,
|
6 - | _response_body: &[u8],
|
7 - | ) -> std::result::Result<
|
8 - | crate::operation::start_device_authorization::StartDeviceAuthorizationOutput,
|
9 - | crate::operation::start_device_authorization::StartDeviceAuthorizationError,
|
10 - | > {
|
11 - | #[allow(unused_mut)]
|
12 - | let mut generic_builder = crate::protocol_serde::parse_http_error_metadata(_response_status, _response_headers, _response_body)
|
13 - | .map_err(crate::operation::start_device_authorization::StartDeviceAuthorizationError::unhandled)?;
|
14 - | generic_builder = ::aws_types::request_id::apply_request_id(generic_builder, _response_headers);
|
15 - | let generic = generic_builder.build();
|
16 - | let error_code = match generic.code() {
|
17 - | Some(code) => code,
|
18 - | None => {
|
19 - | return Err(crate::operation::start_device_authorization::StartDeviceAuthorizationError::unhandled(
|
20 - | generic,
|
21 - | ))
|
22 - | }
|
23 - | };
|
24 - |
|
25 - | let _error_message = generic.message().map(|msg| msg.to_owned());
|
26 - | Err(match error_code {
|
27 - | "InternalServerException" => crate::operation::start_device_authorization::StartDeviceAuthorizationError::InternalServerException({
|
28 - | #[allow(unused_mut)]
|
29 - | let mut tmp = {
|
30 - | #[allow(unused_mut)]
|
31 - | let mut output = crate::types::error::builders::InternalServerExceptionBuilder::default();
|
32 - | output = crate::protocol_serde::shape_internal_server_exception::de_internal_server_exception_json_err(_response_body, output)
|
33 - | .map_err(crate::operation::start_device_authorization::StartDeviceAuthorizationError::unhandled)?;
|
34 - | let output = output.meta(generic);
|
35 - | output.build()
|
36 - | };
|
37 - | if tmp.message.is_none() {
|
38 - | tmp.message = _error_message;
|
39 - | }
|
40 - | tmp
|
41 - | }),
|
42 - | "InvalidClientException" => crate::operation::start_device_authorization::StartDeviceAuthorizationError::InvalidClientException({
|
43 - | #[allow(unused_mut)]
|
44 - | let mut tmp = {
|
45 - | #[allow(unused_mut)]
|
46 - | let mut output = crate::types::error::builders::InvalidClientExceptionBuilder::default();
|
47 - | output = crate::protocol_serde::shape_invalid_client_exception::de_invalid_client_exception_json_err(_response_body, output)
|
48 - | .map_err(crate::operation::start_device_authorization::StartDeviceAuthorizationError::unhandled)?;
|
49 - | let output = output.meta(generic);
|
50 - | output.build()
|
51 - | };
|
52 - | if tmp.message.is_none() {
|
53 - | tmp.message = _error_message;
|
54 - | }
|
55 - | tmp
|
56 - | }),
|
57 - | "InvalidRequestException" => crate::operation::start_device_authorization::StartDeviceAuthorizationError::InvalidRequestException({
|
58 - | #[allow(unused_mut)]
|
59 - | let mut tmp = {
|
60 - | #[allow(unused_mut)]
|
61 - | let mut output = crate::types::error::builders::InvalidRequestExceptionBuilder::default();
|
62 - | output = crate::protocol_serde::shape_invalid_request_exception::de_invalid_request_exception_json_err(_response_body, output)
|
63 - | .map_err(crate::operation::start_device_authorization::StartDeviceAuthorizationError::unhandled)?;
|
64 - | let output = output.meta(generic);
|
65 - | output.build()
|
66 - | };
|
67 - | if tmp.message.is_none() {
|
68 - | tmp.message = _error_message;
|
69 - | }
|
70 - | tmp
|
71 - | }),
|
72 - | "SlowDownException" => crate::operation::start_device_authorization::StartDeviceAuthorizationError::SlowDownException({
|
73 - | #[allow(unused_mut)]
|
74 - | let mut tmp = {
|
75 - | #[allow(unused_mut)]
|
76 - | let mut output = crate::types::error::builders::SlowDownExceptionBuilder::default();
|
77 - | output = crate::protocol_serde::shape_slow_down_exception::de_slow_down_exception_json_err(_response_body, output)
|
78 - | .map_err(crate::operation::start_device_authorization::StartDeviceAuthorizationError::unhandled)?;
|
79 - | let output = output.meta(generic);
|
80 - | output.build()
|
81 - | };
|
82 - | if tmp.message.is_none() {
|
83 - | tmp.message = _error_message;
|
84 - | }
|
85 - | tmp
|
86 - | }),
|
87 - | "UnauthorizedClientException" => crate::operation::start_device_authorization::StartDeviceAuthorizationError::UnauthorizedClientException({
|
88 - | #[allow(unused_mut)]
|
89 - | let mut tmp = {
|
90 - | #[allow(unused_mut)]
|
91 - | let mut output = crate::types::error::builders::UnauthorizedClientExceptionBuilder::default();
|
92 - | output =
|
93 - | crate::protocol_serde::shape_unauthorized_client_exception::de_unauthorized_client_exception_json_err(_response_body, output)
|
94 - | .map_err(crate::operation::start_device_authorization::StartDeviceAuthorizationError::unhandled)?;
|
95 - | let output = output.meta(generic);
|
96 - | output.build()
|
97 - | };
|
98 - | if tmp.message.is_none() {
|
99 - | tmp.message = _error_message;
|
100 - | }
|
101 - | tmp
|
102 - | }),
|
103 - | _ => crate::operation::start_device_authorization::StartDeviceAuthorizationError::generic(generic),
|
104 - | })
|
105 - | }
|
106 - |
|
107 - | #[allow(clippy::unnecessary_wraps)]
|
108 - | pub fn de_start_device_authorization_http_response(
|
109 - | _response_status: u16,
|
110 - | _response_headers: &::aws_smithy_runtime_api::http::Headers,
|
111 - | _response_body: &[u8],
|
112 - | ) -> std::result::Result<
|
113 - | crate::operation::start_device_authorization::StartDeviceAuthorizationOutput,
|
114 - | crate::operation::start_device_authorization::StartDeviceAuthorizationError,
|
115 - | > {
|
116 - | Ok({
|
117 - | #[allow(unused_mut)]
|
118 - | let mut output = crate::operation::start_device_authorization::builders::StartDeviceAuthorizationOutputBuilder::default();
|
119 - | output = crate::protocol_serde::shape_start_device_authorization::de_start_device_authorization(_response_body, output)
|
120 - | .map_err(crate::operation::start_device_authorization::StartDeviceAuthorizationError::unhandled)?;
|
121 - | output._set_request_id(::aws_types::request_id::RequestId::request_id(_response_headers).map(str::to_string));
|
122 - | output.build()
|
123 - | })
|
124 - | }
|
125 - |
|
126 - | pub fn ser_start_device_authorization_input(
|
127 - | input: &crate::operation::start_device_authorization::StartDeviceAuthorizationInput,
|
128 - | ) -> ::std::result::Result<::aws_smithy_types::body::SdkBody, ::aws_smithy_types::error::operation::SerializationError> {
|
129 - | let mut out = String::new();
|
130 - | let mut object = ::aws_smithy_json::serialize::JsonObjectWriter::new(&mut out);
|
131 - | crate::protocol_serde::shape_start_device_authorization_input::ser_start_device_authorization_input_input(&mut object, input)?;
|
132 - | object.finish();
|
133 - | Ok(::aws_smithy_types::body::SdkBody::from(out))
|
134 - | }
|
135 - |
|
136 - | pub(crate) fn de_start_device_authorization(
|
137 - | _value: &[u8],
|
138 - | mut builder: crate::operation::start_device_authorization::builders::StartDeviceAuthorizationOutputBuilder,
|
139 - | ) -> ::std::result::Result<
|
140 - | crate::operation::start_device_authorization::builders::StartDeviceAuthorizationOutputBuilder,
|
141 - | ::aws_smithy_json::deserialize::error::DeserializeError,
|
142 - | > {
|
143 - | let mut tokens_owned = ::aws_smithy_json::deserialize::json_token_iter(crate::protocol_serde::or_empty_doc(_value)).peekable();
|
144 - | let tokens = &mut tokens_owned;
|
145 - | ::aws_smithy_json::deserialize::token::expect_start_object(tokens.next())?;
|
146 - | loop {
|
147 - | match tokens.next().transpose()? {
|
148 - | Some(::aws_smithy_json::deserialize::Token::EndObject { .. }) => break,
|
149 - | Some(::aws_smithy_json::deserialize::Token::ObjectKey { key, .. }) => match key.to_unescaped()?.as_ref() {
|
150 - | "deviceCode" => {
|
151 - | builder = builder.set_device_code(
|
152 - | ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
|
153 - | .map(|s| s.to_unescaped().map(|u| u.into_owned()))
|
154 - | .transpose()?,
|
155 - | );
|
156 - | }
|
157 - | "expiresIn" => {
|
158 - | builder = builder.set_expires_in(
|
159 - | ::aws_smithy_json::deserialize::token::expect_number_or_null(tokens.next())?
|
160 - | .map(i32::try_from)
|
161 - | .transpose()?,
|
162 - | );
|
163 - | }
|
164 - | "interval" => {
|
165 - | builder = builder.set_interval(
|
166 - | ::aws_smithy_json::deserialize::token::expect_number_or_null(tokens.next())?
|
167 - | .map(i32::try_from)
|
168 - | .transpose()?,
|
169 - | );
|
170 - | }
|
171 - | "userCode" => {
|
172 - | builder = builder.set_user_code(
|
173 - | ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
|
174 - | .map(|s| s.to_unescaped().map(|u| u.into_owned()))
|
175 - | .transpose()?,
|
176 - | );
|
177 - | }
|
178 - | "verificationUri" => {
|
179 - | builder = builder.set_verification_uri(
|
180 - | ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
|
181 - | .map(|s| s.to_unescaped().map(|u| u.into_owned()))
|
182 - | .transpose()?,
|
183 - | );
|
184 - | }
|
185 - | "verificationUriComplete" => {
|
186 - | builder = builder.set_verification_uri_complete(
|
187 - | ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
|
188 - | .map(|s| s.to_unescaped().map(|u| u.into_owned()))
|
189 - | .transpose()?,
|
190 - | );
|
191 - | }
|
192 - | _ => ::aws_smithy_json::deserialize::token::skip_value(tokens)?,
|
193 - | },
|
194 - | other => {
|
195 - | return Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(format!(
|
196 - | "expected object key or end object, found: {other:?}"
|
197 - | )))
|
198 - | }
|
199 - | }
|
200 - | }
|
201 - | if tokens.next().is_some() {
|
202 - | return Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(
|
203 - | "found more JSON tokens after completing parsing",
|
204 - | ));
|
205 - | }
|
206 - | Ok(builder)
|
207 - | }
|