aws_sdk_imagebuilder/protocol_serde/
shape_get_infrastructure_configuration.rs1#[allow(clippy::unnecessary_wraps)]
3pub fn de_get_infrastructure_configuration_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::get_infrastructure_configuration::GetInfrastructureConfigurationOutput,
9 crate::operation::get_infrastructure_configuration::GetInfrastructureConfigurationError,
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::get_infrastructure_configuration::GetInfrastructureConfigurationError::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::get_infrastructure_configuration::GetInfrastructureConfigurationError::unhandled(generic)),
19 };
20
21 let _error_message = generic.message().map(|msg| msg.to_owned());
22 Err(match error_code {
23 "CallRateLimitExceededException" => {
24 crate::operation::get_infrastructure_configuration::GetInfrastructureConfigurationError::CallRateLimitExceededException({
25 #[allow(unused_mut)]
26 let mut tmp = {
27 #[allow(unused_mut)]
28 let mut output = crate::types::error::builders::CallRateLimitExceededExceptionBuilder::default();
29 output = crate::protocol_serde::shape_call_rate_limit_exceeded_exception::de_call_rate_limit_exceeded_exception_json_err(
30 _response_body,
31 output,
32 )
33 .map_err(crate::operation::get_infrastructure_configuration::GetInfrastructureConfigurationError::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 }
43 "ClientException" => crate::operation::get_infrastructure_configuration::GetInfrastructureConfigurationError::ClientException({
44 #[allow(unused_mut)]
45 let mut tmp = {
46 #[allow(unused_mut)]
47 let mut output = crate::types::error::builders::ClientExceptionBuilder::default();
48 output = crate::protocol_serde::shape_client_exception::de_client_exception_json_err(_response_body, output)
49 .map_err(crate::operation::get_infrastructure_configuration::GetInfrastructureConfigurationError::unhandled)?;
50 let output = output.meta(generic);
51 output.build()
52 };
53 if tmp.message.is_none() {
54 tmp.message = _error_message;
55 }
56 tmp
57 }),
58 "ForbiddenException" => crate::operation::get_infrastructure_configuration::GetInfrastructureConfigurationError::ForbiddenException({
59 #[allow(unused_mut)]
60 let mut tmp = {
61 #[allow(unused_mut)]
62 let mut output = crate::types::error::builders::ForbiddenExceptionBuilder::default();
63 output = crate::protocol_serde::shape_forbidden_exception::de_forbidden_exception_json_err(_response_body, output)
64 .map_err(crate::operation::get_infrastructure_configuration::GetInfrastructureConfigurationError::unhandled)?;
65 let output = output.meta(generic);
66 output.build()
67 };
68 if tmp.message.is_none() {
69 tmp.message = _error_message;
70 }
71 tmp
72 }),
73 "InvalidRequestException" => {
74 crate::operation::get_infrastructure_configuration::GetInfrastructureConfigurationError::InvalidRequestException({
75 #[allow(unused_mut)]
76 let mut tmp = {
77 #[allow(unused_mut)]
78 let mut output = crate::types::error::builders::InvalidRequestExceptionBuilder::default();
79 output = crate::protocol_serde::shape_invalid_request_exception::de_invalid_request_exception_json_err(_response_body, output)
80 .map_err(crate::operation::get_infrastructure_configuration::GetInfrastructureConfigurationError::unhandled)?;
81 let output = output.meta(generic);
82 output.build()
83 };
84 if tmp.message.is_none() {
85 tmp.message = _error_message;
86 }
87 tmp
88 })
89 }
90 "ServiceException" => crate::operation::get_infrastructure_configuration::GetInfrastructureConfigurationError::ServiceException({
91 #[allow(unused_mut)]
92 let mut tmp = {
93 #[allow(unused_mut)]
94 let mut output = crate::types::error::builders::ServiceExceptionBuilder::default();
95 output = crate::protocol_serde::shape_service_exception::de_service_exception_json_err(_response_body, output)
96 .map_err(crate::operation::get_infrastructure_configuration::GetInfrastructureConfigurationError::unhandled)?;
97 let output = output.meta(generic);
98 output.build()
99 };
100 if tmp.message.is_none() {
101 tmp.message = _error_message;
102 }
103 tmp
104 }),
105 "ServiceUnavailableException" => {
106 crate::operation::get_infrastructure_configuration::GetInfrastructureConfigurationError::ServiceUnavailableException({
107 #[allow(unused_mut)]
108 let mut tmp = {
109 #[allow(unused_mut)]
110 let mut output = crate::types::error::builders::ServiceUnavailableExceptionBuilder::default();
111 output =
112 crate::protocol_serde::shape_service_unavailable_exception::de_service_unavailable_exception_json_err(_response_body, output)
113 .map_err(crate::operation::get_infrastructure_configuration::GetInfrastructureConfigurationError::unhandled)?;
114 let output = output.meta(generic);
115 output.build()
116 };
117 if tmp.message.is_none() {
118 tmp.message = _error_message;
119 }
120 tmp
121 })
122 }
123 _ => crate::operation::get_infrastructure_configuration::GetInfrastructureConfigurationError::generic(generic),
124 })
125}
126
127#[allow(clippy::unnecessary_wraps)]
128pub fn de_get_infrastructure_configuration_http_response(
129 _response_status: u16,
130 _response_headers: &::aws_smithy_runtime_api::http::Headers,
131 _response_body: &[u8],
132) -> std::result::Result<
133 crate::operation::get_infrastructure_configuration::GetInfrastructureConfigurationOutput,
134 crate::operation::get_infrastructure_configuration::GetInfrastructureConfigurationError,
135> {
136 Ok({
137 #[allow(unused_mut)]
138 let mut output = crate::operation::get_infrastructure_configuration::builders::GetInfrastructureConfigurationOutputBuilder::default();
139 output = crate::protocol_serde::shape_get_infrastructure_configuration::de_get_infrastructure_configuration(_response_body, output)
140 .map_err(crate::operation::get_infrastructure_configuration::GetInfrastructureConfigurationError::unhandled)?;
141 output._set_request_id(::aws_types::request_id::RequestId::request_id(_response_headers).map(str::to_string));
142 output.build()
143 })
144}
145
146pub(crate) fn de_get_infrastructure_configuration(
147 value: &[u8],
148 mut builder: crate::operation::get_infrastructure_configuration::builders::GetInfrastructureConfigurationOutputBuilder,
149) -> ::std::result::Result<
150 crate::operation::get_infrastructure_configuration::builders::GetInfrastructureConfigurationOutputBuilder,
151 ::aws_smithy_json::deserialize::error::DeserializeError,
152> {
153 let mut tokens_owned = ::aws_smithy_json::deserialize::json_token_iter(crate::protocol_serde::or_empty_doc(value)).peekable();
154 let tokens = &mut tokens_owned;
155 ::aws_smithy_json::deserialize::token::expect_start_object(tokens.next())?;
156 loop {
157 match tokens.next().transpose()? {
158 Some(::aws_smithy_json::deserialize::Token::EndObject { .. }) => break,
159 Some(::aws_smithy_json::deserialize::Token::ObjectKey { key, .. }) => match key.to_unescaped()?.as_ref() {
160 "infrastructureConfiguration" => {
161 builder = builder.set_infrastructure_configuration(
162 crate::protocol_serde::shape_infrastructure_configuration::de_infrastructure_configuration(tokens)?,
163 );
164 }
165 "requestId" => {
166 builder = builder.set_request_id(
167 ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
168 .map(|s| s.to_unescaped().map(|u| u.into_owned()))
169 .transpose()?,
170 );
171 }
172 _ => ::aws_smithy_json::deserialize::token::skip_value(tokens)?,
173 },
174 other => {
175 return Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(format!(
176 "expected object key or end object, found: {:?}",
177 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}