aws_sdk_chimesdkvoice/protocol_serde/
shape_list_proxy_sessions.rs1#[allow(clippy::unnecessary_wraps)]
3pub fn de_list_proxy_sessions_http_error(
4 _response_status: u16,
5 _response_headers: &::aws_smithy_runtime_api::http::Headers,
6 _response_body: &[u8],
7) -> std::result::Result<crate::operation::list_proxy_sessions::ListProxySessionsOutput, crate::operation::list_proxy_sessions::ListProxySessionsError>
8{
9 #[allow(unused_mut)]
10 let mut generic_builder = crate::protocol_serde::parse_http_error_metadata(_response_status, _response_headers, _response_body)
11 .map_err(crate::operation::list_proxy_sessions::ListProxySessionsError::unhandled)?;
12 generic_builder = ::aws_types::request_id::apply_request_id(generic_builder, _response_headers);
13 let generic = generic_builder.build();
14 let error_code = match generic.code() {
15 Some(code) => code,
16 None => return Err(crate::operation::list_proxy_sessions::ListProxySessionsError::unhandled(generic)),
17 };
18
19 let _error_message = generic.message().map(|msg| msg.to_owned());
20 Err(match error_code {
21 "BadRequestException" => crate::operation::list_proxy_sessions::ListProxySessionsError::BadRequestException({
22 #[allow(unused_mut)]
23 let mut tmp = {
24 #[allow(unused_mut)]
25 let mut output = crate::types::error::builders::BadRequestExceptionBuilder::default();
26 output = crate::protocol_serde::shape_bad_request_exception::de_bad_request_exception_json_err(_response_body, output)
27 .map_err(crate::operation::list_proxy_sessions::ListProxySessionsError::unhandled)?;
28 let output = output.meta(generic);
29 output.build()
30 };
31 if tmp.message.is_none() {
32 tmp.message = _error_message;
33 }
34 tmp
35 }),
36 "ForbiddenException" => crate::operation::list_proxy_sessions::ListProxySessionsError::ForbiddenException({
37 #[allow(unused_mut)]
38 let mut tmp = {
39 #[allow(unused_mut)]
40 let mut output = crate::types::error::builders::ForbiddenExceptionBuilder::default();
41 output = crate::protocol_serde::shape_forbidden_exception::de_forbidden_exception_json_err(_response_body, output)
42 .map_err(crate::operation::list_proxy_sessions::ListProxySessionsError::unhandled)?;
43 let output = output.meta(generic);
44 output.build()
45 };
46 if tmp.message.is_none() {
47 tmp.message = _error_message;
48 }
49 tmp
50 }),
51 "NotFoundException" => crate::operation::list_proxy_sessions::ListProxySessionsError::NotFoundException({
52 #[allow(unused_mut)]
53 let mut tmp = {
54 #[allow(unused_mut)]
55 let mut output = crate::types::error::builders::NotFoundExceptionBuilder::default();
56 output = crate::protocol_serde::shape_not_found_exception::de_not_found_exception_json_err(_response_body, output)
57 .map_err(crate::operation::list_proxy_sessions::ListProxySessionsError::unhandled)?;
58 let output = output.meta(generic);
59 output.build()
60 };
61 if tmp.message.is_none() {
62 tmp.message = _error_message;
63 }
64 tmp
65 }),
66 "ServiceFailureException" => crate::operation::list_proxy_sessions::ListProxySessionsError::ServiceFailureException({
67 #[allow(unused_mut)]
68 let mut tmp = {
69 #[allow(unused_mut)]
70 let mut output = crate::types::error::builders::ServiceFailureExceptionBuilder::default();
71 output = crate::protocol_serde::shape_service_failure_exception::de_service_failure_exception_json_err(_response_body, output)
72 .map_err(crate::operation::list_proxy_sessions::ListProxySessionsError::unhandled)?;
73 let output = output.meta(generic);
74 output.build()
75 };
76 if tmp.message.is_none() {
77 tmp.message = _error_message;
78 }
79 tmp
80 }),
81 "ServiceUnavailableException" => crate::operation::list_proxy_sessions::ListProxySessionsError::ServiceUnavailableException({
82 #[allow(unused_mut)]
83 let mut tmp = {
84 #[allow(unused_mut)]
85 let mut output = crate::types::error::builders::ServiceUnavailableExceptionBuilder::default();
86 output =
87 crate::protocol_serde::shape_service_unavailable_exception::de_service_unavailable_exception_json_err(_response_body, output)
88 .map_err(crate::operation::list_proxy_sessions::ListProxySessionsError::unhandled)?;
89 let output = output.meta(generic);
90 output.build()
91 };
92 if tmp.message.is_none() {
93 tmp.message = _error_message;
94 }
95 tmp
96 }),
97 "ThrottledClientException" => crate::operation::list_proxy_sessions::ListProxySessionsError::ThrottledClientException({
98 #[allow(unused_mut)]
99 let mut tmp = {
100 #[allow(unused_mut)]
101 let mut output = crate::types::error::builders::ThrottledClientExceptionBuilder::default();
102 output = crate::protocol_serde::shape_throttled_client_exception::de_throttled_client_exception_json_err(_response_body, output)
103 .map_err(crate::operation::list_proxy_sessions::ListProxySessionsError::unhandled)?;
104 let output = output.meta(generic);
105 output.build()
106 };
107 if tmp.message.is_none() {
108 tmp.message = _error_message;
109 }
110 tmp
111 }),
112 "UnauthorizedClientException" => crate::operation::list_proxy_sessions::ListProxySessionsError::UnauthorizedClientException({
113 #[allow(unused_mut)]
114 let mut tmp = {
115 #[allow(unused_mut)]
116 let mut output = crate::types::error::builders::UnauthorizedClientExceptionBuilder::default();
117 output =
118 crate::protocol_serde::shape_unauthorized_client_exception::de_unauthorized_client_exception_json_err(_response_body, output)
119 .map_err(crate::operation::list_proxy_sessions::ListProxySessionsError::unhandled)?;
120 let output = output.meta(generic);
121 output.build()
122 };
123 if tmp.message.is_none() {
124 tmp.message = _error_message;
125 }
126 tmp
127 }),
128 _ => crate::operation::list_proxy_sessions::ListProxySessionsError::generic(generic),
129 })
130}
131
132#[allow(clippy::unnecessary_wraps)]
133pub fn de_list_proxy_sessions_http_response(
134 _response_status: u16,
135 _response_headers: &::aws_smithy_runtime_api::http::Headers,
136 _response_body: &[u8],
137) -> std::result::Result<crate::operation::list_proxy_sessions::ListProxySessionsOutput, crate::operation::list_proxy_sessions::ListProxySessionsError>
138{
139 Ok({
140 #[allow(unused_mut)]
141 let mut output = crate::operation::list_proxy_sessions::builders::ListProxySessionsOutputBuilder::default();
142 output = crate::protocol_serde::shape_list_proxy_sessions::de_list_proxy_sessions(_response_body, output)
143 .map_err(crate::operation::list_proxy_sessions::ListProxySessionsError::unhandled)?;
144 output._set_request_id(::aws_types::request_id::RequestId::request_id(_response_headers).map(str::to_string));
145 output.build()
146 })
147}
148
149pub(crate) fn de_list_proxy_sessions(
150 value: &[u8],
151 mut builder: crate::operation::list_proxy_sessions::builders::ListProxySessionsOutputBuilder,
152) -> ::std::result::Result<
153 crate::operation::list_proxy_sessions::builders::ListProxySessionsOutputBuilder,
154 ::aws_smithy_json::deserialize::error::DeserializeError,
155> {
156 let mut tokens_owned = ::aws_smithy_json::deserialize::json_token_iter(crate::protocol_serde::or_empty_doc(value)).peekable();
157 let tokens = &mut tokens_owned;
158 ::aws_smithy_json::deserialize::token::expect_start_object(tokens.next())?;
159 loop {
160 match tokens.next().transpose()? {
161 Some(::aws_smithy_json::deserialize::Token::EndObject { .. }) => break,
162 Some(::aws_smithy_json::deserialize::Token::ObjectKey { key, .. }) => match key.to_unescaped()?.as_ref() {
163 "NextToken" => {
164 builder = builder.set_next_token(
165 ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
166 .map(|s| s.to_unescaped().map(|u| u.into_owned()))
167 .transpose()?,
168 );
169 }
170 "ProxySessions" => {
171 builder = builder.set_proxy_sessions(crate::protocol_serde::shape_proxy_sessions::de_proxy_sessions(tokens)?);
172 }
173 _ => ::aws_smithy_json::deserialize::token::skip_value(tokens)?,
174 },
175 other => {
176 return Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(format!(
177 "expected object key or end object, found: {other:?}"
178 )))
179 }
180 }
181 }
182 if tokens.next().is_some() {
183 return Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(
184 "found more JSON tokens after completing parsing",
185 ));
186 }
187 Ok(builder)
188}