aws_sdk_iot/protocol_serde/
shape_describe_index.rs1#[allow(clippy::unnecessary_wraps)]
3pub fn de_describe_index_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::describe_index::DescribeIndexOutput, crate::operation::describe_index::DescribeIndexError> {
8 #[allow(unused_mut)]
9 let mut generic_builder = crate::protocol_serde::parse_http_error_metadata(_response_status, _response_headers, _response_body)
10 .map_err(crate::operation::describe_index::DescribeIndexError::unhandled)?;
11 generic_builder = ::aws_types::request_id::apply_request_id(generic_builder, _response_headers);
12 let generic = generic_builder.build();
13 let error_code = match generic.code() {
14 Some(code) => code,
15 None => return Err(crate::operation::describe_index::DescribeIndexError::unhandled(generic)),
16 };
17
18 let _error_message = generic.message().map(|msg| msg.to_owned());
19 Err(match error_code {
20 "InternalFailureException" => crate::operation::describe_index::DescribeIndexError::InternalFailureException({
21 #[allow(unused_mut)]
22 let mut tmp = {
23 #[allow(unused_mut)]
24 let mut output = crate::types::error::builders::InternalFailureExceptionBuilder::default();
25 output = crate::protocol_serde::shape_internal_failure_exception::de_internal_failure_exception_json_err(_response_body, output)
26 .map_err(crate::operation::describe_index::DescribeIndexError::unhandled)?;
27 let output = output.meta(generic);
28 output.build()
29 };
30 if tmp.message.is_none() {
31 tmp.message = _error_message;
32 }
33 tmp
34 }),
35 "InvalidRequestException" => crate::operation::describe_index::DescribeIndexError::InvalidRequestException({
36 #[allow(unused_mut)]
37 let mut tmp = {
38 #[allow(unused_mut)]
39 let mut output = crate::types::error::builders::InvalidRequestExceptionBuilder::default();
40 output = crate::protocol_serde::shape_invalid_request_exception::de_invalid_request_exception_json_err(_response_body, output)
41 .map_err(crate::operation::describe_index::DescribeIndexError::unhandled)?;
42 let output = output.meta(generic);
43 output.build()
44 };
45 if tmp.message.is_none() {
46 tmp.message = _error_message;
47 }
48 tmp
49 }),
50 "ResourceNotFoundException" => crate::operation::describe_index::DescribeIndexError::ResourceNotFoundException({
51 #[allow(unused_mut)]
52 let mut tmp = {
53 #[allow(unused_mut)]
54 let mut output = crate::types::error::builders::ResourceNotFoundExceptionBuilder::default();
55 output = crate::protocol_serde::shape_resource_not_found_exception::de_resource_not_found_exception_json_err(_response_body, output)
56 .map_err(crate::operation::describe_index::DescribeIndexError::unhandled)?;
57 let output = output.meta(generic);
58 output.build()
59 };
60 if tmp.message.is_none() {
61 tmp.message = _error_message;
62 }
63 tmp
64 }),
65 "ServiceUnavailableException" => crate::operation::describe_index::DescribeIndexError::ServiceUnavailableException({
66 #[allow(unused_mut)]
67 let mut tmp = {
68 #[allow(unused_mut)]
69 let mut output = crate::types::error::builders::ServiceUnavailableExceptionBuilder::default();
70 output =
71 crate::protocol_serde::shape_service_unavailable_exception::de_service_unavailable_exception_json_err(_response_body, output)
72 .map_err(crate::operation::describe_index::DescribeIndexError::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 "ThrottlingException" => crate::operation::describe_index::DescribeIndexError::ThrottlingException({
82 #[allow(unused_mut)]
83 let mut tmp = {
84 #[allow(unused_mut)]
85 let mut output = crate::types::error::builders::ThrottlingExceptionBuilder::default();
86 output = crate::protocol_serde::shape_throttling_exception::de_throttling_exception_json_err(_response_body, output)
87 .map_err(crate::operation::describe_index::DescribeIndexError::unhandled)?;
88 let output = output.meta(generic);
89 output.build()
90 };
91 if tmp.message.is_none() {
92 tmp.message = _error_message;
93 }
94 tmp
95 }),
96 "UnauthorizedException" => crate::operation::describe_index::DescribeIndexError::UnauthorizedException({
97 #[allow(unused_mut)]
98 let mut tmp = {
99 #[allow(unused_mut)]
100 let mut output = crate::types::error::builders::UnauthorizedExceptionBuilder::default();
101 output = crate::protocol_serde::shape_unauthorized_exception::de_unauthorized_exception_json_err(_response_body, output)
102 .map_err(crate::operation::describe_index::DescribeIndexError::unhandled)?;
103 let output = output.meta(generic);
104 output.build()
105 };
106 if tmp.message.is_none() {
107 tmp.message = _error_message;
108 }
109 tmp
110 }),
111 _ => crate::operation::describe_index::DescribeIndexError::generic(generic),
112 })
113}
114
115#[allow(clippy::unnecessary_wraps)]
116pub fn de_describe_index_http_response(
117 _response_status: u16,
118 _response_headers: &::aws_smithy_runtime_api::http::Headers,
119 _response_body: &[u8],
120) -> std::result::Result<crate::operation::describe_index::DescribeIndexOutput, crate::operation::describe_index::DescribeIndexError> {
121 Ok({
122 #[allow(unused_mut)]
123 let mut output = crate::operation::describe_index::builders::DescribeIndexOutputBuilder::default();
124 output = crate::protocol_serde::shape_describe_index::de_describe_index(_response_body, output)
125 .map_err(crate::operation::describe_index::DescribeIndexError::unhandled)?;
126 output._set_request_id(::aws_types::request_id::RequestId::request_id(_response_headers).map(str::to_string));
127 output.build()
128 })
129}
130
131pub(crate) fn de_describe_index(
132 value: &[u8],
133 mut builder: crate::operation::describe_index::builders::DescribeIndexOutputBuilder,
134) -> ::std::result::Result<
135 crate::operation::describe_index::builders::DescribeIndexOutputBuilder,
136 ::aws_smithy_json::deserialize::error::DeserializeError,
137> {
138 let mut tokens_owned = ::aws_smithy_json::deserialize::json_token_iter(crate::protocol_serde::or_empty_doc(value)).peekable();
139 let tokens = &mut tokens_owned;
140 ::aws_smithy_json::deserialize::token::expect_start_object(tokens.next())?;
141 loop {
142 match tokens.next().transpose()? {
143 Some(::aws_smithy_json::deserialize::Token::EndObject { .. }) => break,
144 Some(::aws_smithy_json::deserialize::Token::ObjectKey { key, .. }) => match key.to_unescaped()?.as_ref() {
145 "indexName" => {
146 builder = builder.set_index_name(
147 ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
148 .map(|s| s.to_unescaped().map(|u| u.into_owned()))
149 .transpose()?,
150 );
151 }
152 "indexStatus" => {
153 builder = builder.set_index_status(
154 ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
155 .map(|s| s.to_unescaped().map(|u| crate::types::IndexStatus::from(u.as_ref())))
156 .transpose()?,
157 );
158 }
159 "schema" => {
160 builder = builder.set_schema(
161 ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
162 .map(|s| s.to_unescaped().map(|u| u.into_owned()))
163 .transpose()?,
164 );
165 }
166 _ => ::aws_smithy_json::deserialize::token::skip_value(tokens)?,
167 },
168 other => {
169 return Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(format!(
170 "expected object key or end object, found: {other:?}"
171 )))
172 }
173 }
174 }
175 if tokens.next().is_some() {
176 return Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(
177 "found more JSON tokens after completing parsing",
178 ));
179 }
180 Ok(builder)
181}