aws_sdk_appsync/protocol_serde/
shape_list_channel_namespaces.rs1#[allow(clippy::unnecessary_wraps)]
3pub fn de_list_channel_namespaces_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::list_channel_namespaces::ListChannelNamespacesOutput,
9 crate::operation::list_channel_namespaces::ListChannelNamespacesError,
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::list_channel_namespaces::ListChannelNamespacesError::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 => return Err(crate::operation::list_channel_namespaces::ListChannelNamespacesError::unhandled(generic)),
19 };
20
21 let _error_message = generic.message().map(|msg| msg.to_owned());
22 Err(match error_code {
23 "BadRequestException" => crate::operation::list_channel_namespaces::ListChannelNamespacesError::BadRequestException({
24 #[allow(unused_mut)]
25 let mut tmp = {
26 #[allow(unused_mut)]
27 let mut output = crate::types::error::builders::BadRequestExceptionBuilder::default();
28 output = crate::protocol_serde::shape_bad_request_exception::de_bad_request_exception_json_err(_response_body, output)
29 .map_err(crate::operation::list_channel_namespaces::ListChannelNamespacesError::unhandled)?;
30 let output = output.meta(generic);
31 output.build()
32 };
33 if tmp.message.is_none() {
34 tmp.message = _error_message;
35 }
36 tmp
37 }),
38 "InternalFailureException" => crate::operation::list_channel_namespaces::ListChannelNamespacesError::InternalFailureException({
39 #[allow(unused_mut)]
40 let mut tmp = {
41 #[allow(unused_mut)]
42 let mut output = crate::types::error::builders::InternalFailureExceptionBuilder::default();
43 output = crate::protocol_serde::shape_internal_failure_exception::de_internal_failure_exception_json_err(_response_body, output)
44 .map_err(crate::operation::list_channel_namespaces::ListChannelNamespacesError::unhandled)?;
45 let output = output.meta(generic);
46 output.build()
47 };
48 if tmp.message.is_none() {
49 tmp.message = _error_message;
50 }
51 tmp
52 }),
53 "NotFoundException" => crate::operation::list_channel_namespaces::ListChannelNamespacesError::NotFoundException({
54 #[allow(unused_mut)]
55 let mut tmp = {
56 #[allow(unused_mut)]
57 let mut output = crate::types::error::builders::NotFoundExceptionBuilder::default();
58 output = crate::protocol_serde::shape_not_found_exception::de_not_found_exception_json_err(_response_body, output)
59 .map_err(crate::operation::list_channel_namespaces::ListChannelNamespacesError::unhandled)?;
60 let output = output.meta(generic);
61 output.build()
62 };
63 if tmp.message.is_none() {
64 tmp.message = _error_message;
65 }
66 tmp
67 }),
68 "UnauthorizedException" => crate::operation::list_channel_namespaces::ListChannelNamespacesError::UnauthorizedException({
69 #[allow(unused_mut)]
70 let mut tmp = {
71 #[allow(unused_mut)]
72 let mut output = crate::types::error::builders::UnauthorizedExceptionBuilder::default();
73 output = crate::protocol_serde::shape_unauthorized_exception::de_unauthorized_exception_json_err(_response_body, output)
74 .map_err(crate::operation::list_channel_namespaces::ListChannelNamespacesError::unhandled)?;
75 let output = output.meta(generic);
76 output.build()
77 };
78 if tmp.message.is_none() {
79 tmp.message = _error_message;
80 }
81 tmp
82 }),
83 _ => crate::operation::list_channel_namespaces::ListChannelNamespacesError::generic(generic),
84 })
85}
86
87#[allow(clippy::unnecessary_wraps)]
88pub fn de_list_channel_namespaces_http_response(
89 _response_status: u16,
90 _response_headers: &::aws_smithy_runtime_api::http::Headers,
91 _response_body: &[u8],
92) -> std::result::Result<
93 crate::operation::list_channel_namespaces::ListChannelNamespacesOutput,
94 crate::operation::list_channel_namespaces::ListChannelNamespacesError,
95> {
96 Ok({
97 #[allow(unused_mut)]
98 let mut output = crate::operation::list_channel_namespaces::builders::ListChannelNamespacesOutputBuilder::default();
99 output = crate::protocol_serde::shape_list_channel_namespaces::de_list_channel_namespaces(_response_body, output)
100 .map_err(crate::operation::list_channel_namespaces::ListChannelNamespacesError::unhandled)?;
101 output._set_request_id(::aws_types::request_id::RequestId::request_id(_response_headers).map(str::to_string));
102 output.build()
103 })
104}
105
106pub(crate) fn de_list_channel_namespaces(
107 value: &[u8],
108 mut builder: crate::operation::list_channel_namespaces::builders::ListChannelNamespacesOutputBuilder,
109) -> ::std::result::Result<
110 crate::operation::list_channel_namespaces::builders::ListChannelNamespacesOutputBuilder,
111 ::aws_smithy_json::deserialize::error::DeserializeError,
112> {
113 let mut tokens_owned = ::aws_smithy_json::deserialize::json_token_iter(crate::protocol_serde::or_empty_doc(value)).peekable();
114 let tokens = &mut tokens_owned;
115 ::aws_smithy_json::deserialize::token::expect_start_object(tokens.next())?;
116 loop {
117 match tokens.next().transpose()? {
118 Some(::aws_smithy_json::deserialize::Token::EndObject { .. }) => break,
119 Some(::aws_smithy_json::deserialize::Token::ObjectKey { key, .. }) => match key.to_unescaped()?.as_ref() {
120 "channelNamespaces" => {
121 builder = builder.set_channel_namespaces(crate::protocol_serde::shape_channel_namespaces::de_channel_namespaces(tokens)?);
122 }
123 "nextToken" => {
124 builder = builder.set_next_token(
125 ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
126 .map(|s| s.to_unescaped().map(|u| u.into_owned()))
127 .transpose()?,
128 );
129 }
130 _ => ::aws_smithy_json::deserialize::token::skip_value(tokens)?,
131 },
132 other => {
133 return Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(format!(
134 "expected object key or end object, found: {:?}",
135 other
136 )))
137 }
138 }
139 }
140 if tokens.next().is_some() {
141 return Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(
142 "found more JSON tokens after completing parsing",
143 ));
144 }
145 Ok(builder)
146}