130 136 | crate::operation::case_insensitive_error_operation::CaseInsensitiveErrorOperationError,
|
131 137 | >::new());
|
132 138 |
|
133 139 | ::std::borrow::Cow::Owned(rcb)
|
134 140 | }
|
135 141 | }
|
136 142 |
|
137 143 | #[derive(Debug)]
|
138 144 | struct CaseInsensitiveErrorOperationResponseDeserializer;
|
139 145 | impl ::aws_smithy_runtime_api::client::ser_de::DeserializeResponse for CaseInsensitiveErrorOperationResponseDeserializer {
|
140 - | fn deserialize_nonstreaming(
|
146 + | fn deserialize_nonstreaming_with_config(
|
141 147 | &self,
|
142 148 | response: &::aws_smithy_runtime_api::client::orchestrator::HttpResponse,
|
149 + | _cfg: &::aws_smithy_types::config_bag::ConfigBag,
|
143 150 | ) -> ::aws_smithy_runtime_api::client::interceptors::context::OutputOrError {
|
144 151 | let (success, status) = (response.status().is_success(), response.status().as_u16());
|
152 + | #[allow(unused_mut)]
|
153 + | let mut force_error = false;
|
154 + |
|
155 + | if !success && status != 200 || force_error {
|
145 156 | let headers = response.headers();
|
146 157 | let body = response.body().bytes().expect("body loaded");
|
147 158 | #[allow(unused_mut)]
|
148 - | let mut force_error = false;
|
159 + | let mut generic_builder = crate::protocol_serde::parse_http_error_metadata(status, headers, body).map_err(|e| {
|
160 + | ::aws_smithy_runtime_api::client::orchestrator::OrchestratorError::other(::aws_smithy_runtime_api::box_error::BoxError::from(e))
|
161 + | })?;
|
149 162 |
|
150 - | let parse_result = if !success && status != 200 || force_error {
|
151 - | crate::protocol_serde::shape_case_insensitive_error_operation::de_case_insensitive_error_operation_http_error(status, headers, body)
|
152 - | } else {
|
153 - | crate::protocol_serde::shape_case_insensitive_error_operation::de_case_insensitive_error_operation_http_response(status, headers, body)
|
163 + | let generic = generic_builder.build();
|
164 + | let error_code = match generic.code() {
|
165 + | ::std::option::Option::Some(code) => code,
|
166 + | ::std::option::Option::None => {
|
167 + | return ::std::result::Result::Err(::aws_smithy_runtime_api::client::orchestrator::OrchestratorError::other(
|
168 + | ::aws_smithy_runtime_api::box_error::BoxError::from(
|
169 + | crate::operation::case_insensitive_error_operation::CaseInsensitiveErrorOperationError::unhandled(generic),
|
170 + | ),
|
171 + | ))
|
172 + | }
|
173 + | };
|
174 + | let _error_message = generic.message().map(|msg| msg.to_owned());
|
175 + | let protocol = _cfg
|
176 + | .load::<::aws_smithy_schema::protocol::SharedClientProtocol>()
|
177 + | .expect("a SharedClientProtocol is required");
|
178 + | let err = match error_code {
|
179 + | "CaseInsensitiveError" => {
|
180 + | crate::operation::case_insensitive_error_operation::CaseInsensitiveErrorOperationError::CaseInsensitiveError({
|
181 + | let mut tmp = match protocol
|
182 + | .deserialize_response(response, crate::types::error::CaseInsensitiveError::SCHEMA, _cfg)
|
183 + | .and_then(|mut deser| {
|
184 + | crate::types::error::CaseInsensitiveError::deserialize_with_response(
|
185 + | &mut *deser,
|
186 + | response.headers(),
|
187 + | response.status().into(),
|
188 + | body,
|
189 + | )
|
190 + | }) {
|
191 + | ::std::result::Result::Ok(val) => val,
|
192 + | ::std::result::Result::Err(e) => {
|
193 + | return ::std::result::Result::Err(::aws_smithy_runtime_api::client::orchestrator::OrchestratorError::other(
|
194 + | ::aws_smithy_runtime_api::box_error::BoxError::from(e),
|
195 + | ))
|
196 + | }
|
197 + | };
|
198 + | tmp.meta = generic;
|
199 + | if tmp.message.is_none() {
|
200 + | tmp.message = _error_message;
|
201 + | }
|
202 + | tmp
|
203 + | })
|
204 + | }
|
205 + | "ExtraError" => crate::operation::case_insensitive_error_operation::CaseInsensitiveErrorOperationError::ExtraError({
|
206 + | let mut tmp = match protocol
|
207 + | .deserialize_response(response, crate::types::error::ExtraError::SCHEMA, _cfg)
|
208 + | .and_then(|mut deser| {
|
209 + | crate::types::error::ExtraError::deserialize_with_response(
|
210 + | &mut *deser,
|
211 + | response.headers(),
|
212 + | response.status().into(),
|
213 + | body,
|
214 + | )
|
215 + | }) {
|
216 + | ::std::result::Result::Ok(val) => val,
|
217 + | ::std::result::Result::Err(e) => {
|
218 + | return ::std::result::Result::Err(::aws_smithy_runtime_api::client::orchestrator::OrchestratorError::other(
|
219 + | ::aws_smithy_runtime_api::box_error::BoxError::from(e),
|
220 + | ))
|
221 + | }
|
154 222 | };
|
155 - | crate::protocol_serde::type_erase_result(parse_result)
|
223 + | tmp.meta = generic;
|
224 + | if tmp.message.is_none() {
|
225 + | tmp.message = _error_message;
|
226 + | }
|
227 + | tmp
|
228 + | }),
|
229 + | _ => crate::operation::case_insensitive_error_operation::CaseInsensitiveErrorOperationError::generic(generic),
|
230 + | };
|
231 + | ::std::result::Result::Err(::aws_smithy_runtime_api::client::orchestrator::OrchestratorError::operation(
|
232 + | ::aws_smithy_runtime_api::client::interceptors::context::Error::erase(err),
|
233 + | ))
|
234 + | } else {
|
235 + | let protocol = _cfg
|
236 + | .load::<::aws_smithy_schema::protocol::SharedClientProtocol>()
|
237 + | .expect("a SharedClientProtocol is required");
|
238 + | let mut deser = protocol
|
239 + | .deserialize_response(response, CaseInsensitiveErrorOperation::OUTPUT_SCHEMA, _cfg)
|
240 + | .map_err(|e| {
|
241 + | ::aws_smithy_runtime_api::client::orchestrator::OrchestratorError::other(::aws_smithy_runtime_api::box_error::BoxError::from(e))
|
242 + | })?;
|
243 + | let body = response.body().bytes().expect("body loaded");
|
244 + | let output = crate::operation::case_insensitive_error_operation::CaseInsensitiveErrorOperationOutput::deserialize_with_response(
|
245 + | &mut *deser,
|
246 + | response.headers(),
|
247 + | response.status().into(),
|
248 + | body,
|
249 + | )
|
250 + | .map_err(|e| {
|
251 + | ::aws_smithy_runtime_api::client::orchestrator::OrchestratorError::other(::aws_smithy_runtime_api::box_error::BoxError::from(e))
|
252 + | })?;
|
253 + | ::std::result::Result::Ok(::aws_smithy_runtime_api::client::interceptors::context::Output::erase(output))
|
254 + | }
|
156 255 | }
|
157 256 | }
|
158 257 | #[derive(Debug)]
|
159 258 | struct CaseInsensitiveErrorOperationRequestSerializer;
|
160 259 | impl ::aws_smithy_runtime_api::client::ser_de::SerializeRequest for CaseInsensitiveErrorOperationRequestSerializer {
|
161 260 | #[allow(unused_mut, clippy::let_and_return, clippy::needless_borrow, clippy::useless_conversion)]
|
162 261 | fn serialize_input(
|
163 262 | &self,
|
164 263 | input: ::aws_smithy_runtime_api::client::interceptors::context::Input,
|
165 264 | _cfg: &mut ::aws_smithy_types::config_bag::ConfigBag,
|
166 265 | ) -> ::std::result::Result<::aws_smithy_runtime_api::client::orchestrator::HttpRequest, ::aws_smithy_runtime_api::box_error::BoxError> {
|
167 266 | let input = input
|
168 267 | .downcast::<crate::operation::case_insensitive_error_operation::CaseInsensitiveErrorOperationInput>()
|
169 268 | .expect("correct type");
|
170 - | let _header_serialization_settings = _cfg
|
171 - | .load::<crate::serialization_settings::HeaderSerializationSettings>()
|
172 - | .cloned()
|
173 - | .unwrap_or_default();
|
174 - | let mut request_builder = {
|
175 - | #[allow(clippy::uninlined_format_args)]
|
176 - | fn uri_base(
|
177 - | _input: &crate::operation::case_insensitive_error_operation::CaseInsensitiveErrorOperationInput,
|
178 - | output: &mut ::std::string::String,
|
179 - | ) -> ::std::result::Result<(), ::aws_smithy_types::error::operation::BuildError> {
|
180 - | use ::std::fmt::Write as _;
|
181 - | ::std::write!(output, "/error-sensitive").expect("formatting should succeed");
|
182 - | ::std::result::Result::Ok(())
|
183 - | }
|
184 - | #[allow(clippy::unnecessary_wraps)]
|
185 - | fn update_http_builder(
|
186 - | input: &crate::operation::case_insensitive_error_operation::CaseInsensitiveErrorOperationInput,
|
187 - | builder: ::http_1x::request::Builder,
|
188 - | ) -> ::std::result::Result<::http_1x::request::Builder, ::aws_smithy_types::error::operation::BuildError> {
|
189 - | let mut uri = ::std::string::String::new();
|
190 - | uri_base(input, &mut uri)?;
|
191 - | ::std::result::Result::Ok(builder.method("POST").uri(uri))
|
192 - | }
|
193 - | let mut builder = update_http_builder(&input, ::http_1x::request::Builder::new())?;
|
194 - | builder
|
195 - | };
|
196 - | let body = ::aws_smithy_types::body::SdkBody::from("");
|
269 + | let protocol = _cfg
|
270 + | .load::<::aws_smithy_schema::protocol::SharedClientProtocol>()
|
271 + | .expect("a SharedClientProtocol is required");
|
272 + | let mut request = protocol
|
273 + | .serialize_request(&input, CaseInsensitiveErrorOperation::INPUT_SCHEMA, "", _cfg)
|
274 + | .map_err(::aws_smithy_runtime_api::box_error::BoxError::from)?;
|
197 275 |
|
198 - | ::std::result::Result::Ok(request_builder.body(body).expect("valid request").try_into().unwrap())
|
276 + | return ::std::result::Result::Ok(request);
|
199 277 | }
|
200 278 | }
|
201 279 | #[derive(Debug)]
|
202 280 | struct CaseInsensitiveErrorOperationEndpointParamsInterceptor;
|
203 281 |
|
204 282 | impl ::aws_smithy_runtime_api::client::interceptors::Intercept for CaseInsensitiveErrorOperationEndpointParamsInterceptor {
|
205 283 | fn name(&self) -> &'static str {
|
206 284 | "CaseInsensitiveErrorOperationEndpointParamsInterceptor"
|
207 285 | }
|
208 286 |
|
263 341 | .expect("the config must have a deserializer");
|
264 342 |
|
265 343 | let parsed = de.deserialize_streaming(&mut http_response);
|
266 344 | let parsed = parsed.unwrap_or_else(|| {
|
267 345 | let http_response = http_response.map(|body| {
|
268 346 | ::aws_smithy_types::body::SdkBody::from(::bytes::Bytes::copy_from_slice(&::aws_smithy_protocol_test::decode_body_data(
|
269 347 | body.bytes().unwrap(),
|
270 348 | ::aws_smithy_protocol_test::MediaType::from("unknown"),
|
271 349 | )))
|
272 350 | });
|
273 - | de.deserialize_nonstreaming(&http_response)
|
351 + | // Build a config bag with the protocol for schema-based deserialization
|
352 + | #[allow(unused_mut)]
|
353 + | let mut test_cfg = ::aws_smithy_types::config_bag::ConfigBag::base();
|
354 + | {
|
355 + | let mut layer = ::aws_smithy_types::config_bag::Layer::new("test_protocol");
|
356 + | layer.store_put(::aws_smithy_schema::protocol::SharedClientProtocol::new(
|
357 + | ::aws_smithy_json::protocol::aws_rest_json_1::AwsRestJsonProtocol::new(),
|
358 + | ));
|
359 + | test_cfg.push_shared_layer(layer.freeze());
|
360 + | }
|
361 + | de.deserialize_nonstreaming_with_config(&http_response, &test_cfg)
|
274 362 | });
|
275 363 | let parsed = parsed.expect_err("should be error response");
|
276 364 | let parsed: &crate::operation::case_insensitive_error_operation::CaseInsensitiveErrorOperationError =
|
277 365 | parsed.as_operation_error().expect("operation error").downcast_ref().unwrap();
|
278 366 | if let crate::operation::case_insensitive_error_operation::CaseInsensitiveErrorOperationError::CaseInsensitiveError(parsed) = parsed {
|
279 367 | ::pretty_assertions::assert_eq!(parsed.message, expected_output.message, "Unexpected value for `message`");
|
280 368 | } else {
|
281 369 | panic!("wrong variant: Got: {:?}. Expected: {:?}", parsed, expected_output);
|
282 370 | }
|
283 371 | }
|
284 372 |
|
285 373 | /// Upper case error modeled lower case
|
286 374 | /// Test ID: ServiceLevelErrorClient
|
287 375 | #[::tokio::test]
|
288 376 | #[::tracing_test::traced_test]
|
289 377 | async fn service_level_error_client_response() {
|
290 378 | let expected_output = crate::types::error::ExtraError::builder().build();
|
291 379 | let mut http_response = ::aws_smithy_runtime_api::http::Response::try_from(
|
292 380 | ::http_1x::response::Builder::new()
|
293 381 | .header("X-Amzn-Errortype", "ExtraError")
|
294 382 | .status(500)
|
295 383 | .body(::aws_smithy_types::body::SdkBody::from(""))
|
296 384 | .unwrap(),
|
297 385 | )
|
298 386 | .unwrap();
|
299 387 | use ::aws_smithy_runtime_api::client::runtime_plugin::RuntimePlugin;
|
300 388 | use ::aws_smithy_runtime_api::client::ser_de::DeserializeResponse;
|
301 389 |
|
302 390 | let op = crate::operation::case_insensitive_error_operation::CaseInsensitiveErrorOperation::new();
|
303 391 | let config = op.config().expect("the operation has config");
|
304 392 | let de = config
|
305 393 | .load::<::aws_smithy_runtime_api::client::ser_de::SharedResponseDeserializer>()
|
306 394 | .expect("the config must have a deserializer");
|
307 395 |
|
308 396 | let parsed = de.deserialize_streaming(&mut http_response);
|
309 397 | let parsed = parsed.unwrap_or_else(|| {
|
310 398 | let http_response = http_response.map(|body| {
|
311 399 | ::aws_smithy_types::body::SdkBody::from(::bytes::Bytes::copy_from_slice(&::aws_smithy_protocol_test::decode_body_data(
|
312 400 | body.bytes().unwrap(),
|
313 401 | ::aws_smithy_protocol_test::MediaType::from("unknown"),
|
314 402 | )))
|
315 403 | });
|
316 - | de.deserialize_nonstreaming(&http_response)
|
404 + | // Build a config bag with the protocol for schema-based deserialization
|
405 + | #[allow(unused_mut)]
|
406 + | let mut test_cfg = ::aws_smithy_types::config_bag::ConfigBag::base();
|
407 + | {
|
408 + | let mut layer = ::aws_smithy_types::config_bag::Layer::new("test_protocol");
|
409 + | layer.store_put(::aws_smithy_schema::protocol::SharedClientProtocol::new(
|
410 + | ::aws_smithy_json::protocol::aws_rest_json_1::AwsRestJsonProtocol::new(),
|
411 + | ));
|
412 + | test_cfg.push_shared_layer(layer.freeze());
|
413 + | }
|
414 + | de.deserialize_nonstreaming_with_config(&http_response, &test_cfg)
|
317 415 | });
|
318 416 | let parsed = parsed.expect_err("should be error response");
|
319 417 | let parsed: &crate::operation::case_insensitive_error_operation::CaseInsensitiveErrorOperationError =
|
320 418 | parsed.as_operation_error().expect("operation error").downcast_ref().unwrap();
|
321 419 | if let crate::operation::case_insensitive_error_operation::CaseInsensitiveErrorOperationError::ExtraError(parsed) = parsed {
|
322 420 | ::pretty_assertions::assert_eq!(parsed.message, expected_output.message, "Unexpected value for `message`");
|
323 421 | } else {
|
324 422 | panic!("wrong variant: Got: {:?}. Expected: {:?}", parsed, expected_output);
|
325 423 | }
|
326 424 | }
|