1 1 | // Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
|
2 2 | /// Orchestration and serialization glue logic for `GreetingWithErrors`.
|
3 3 | #[derive(::std::clone::Clone, ::std::default::Default, ::std::fmt::Debug)]
|
4 4 | #[non_exhaustive]
|
5 5 | pub struct GreetingWithErrors;
|
6 6 | impl GreetingWithErrors {
|
7 7 | /// Creates a new `GreetingWithErrors`
|
8 8 | pub fn new() -> Self {
|
9 9 | Self
|
10 10 | }
|
11 + | /// The schema for this operation's input shape.
|
12 + | pub const INPUT_SCHEMA: &'static ::aws_smithy_schema::Schema = crate::operation::greeting_with_errors::GreetingWithErrorsInput::SCHEMA;
|
13 + | /// The schema for this operation's output shape.
|
14 + | pub const OUTPUT_SCHEMA: &'static ::aws_smithy_schema::Schema = crate::operation::greeting_with_errors::GreetingWithErrorsOutput::SCHEMA;
|
11 15 | pub(crate) async fn orchestrate(
|
12 16 | runtime_plugins: &::aws_smithy_runtime_api::client::runtime_plugin::RuntimePlugins,
|
13 17 | input: crate::operation::greeting_with_errors::GreetingWithErrorsInput,
|
14 18 | ) -> ::std::result::Result<
|
15 19 | crate::operation::greeting_with_errors::GreetingWithErrorsOutput,
|
16 20 | ::aws_smithy_runtime_api::client::result::SdkError<
|
17 21 | crate::operation::greeting_with_errors::GreetingWithErrorsError,
|
18 22 | ::aws_smithy_runtime_api::client::orchestrator::HttpResponse,
|
19 23 | >,
|
20 24 | > {
|
124 128 | crate::operation::greeting_with_errors::GreetingWithErrorsError,
|
125 129 | >::new());
|
126 130 |
|
127 131 | ::std::borrow::Cow::Owned(rcb)
|
128 132 | }
|
129 133 | }
|
130 134 |
|
131 135 | #[derive(Debug)]
|
132 136 | struct GreetingWithErrorsResponseDeserializer;
|
133 137 | impl ::aws_smithy_runtime_api::client::ser_de::DeserializeResponse for GreetingWithErrorsResponseDeserializer {
|
134 - | fn deserialize_nonstreaming(
|
138 + | fn deserialize_nonstreaming_with_config(
|
135 139 | &self,
|
136 140 | response: &::aws_smithy_runtime_api::client::orchestrator::HttpResponse,
|
141 + | _cfg: &::aws_smithy_types::config_bag::ConfigBag,
|
137 142 | ) -> ::aws_smithy_runtime_api::client::interceptors::context::OutputOrError {
|
138 143 | let (success, status) = (response.status().is_success(), response.status().as_u16());
|
139 144 | let headers = response.headers();
|
140 145 | let body = response.body().bytes().expect("body loaded");
|
141 146 | #[allow(unused_mut)]
|
142 147 | let mut force_error = false;
|
143 148 |
|
144 149 | let parse_result = if !success && status != 200 || force_error {
|
145 150 | crate::protocol_serde::shape_greeting_with_errors::de_greeting_with_errors_http_error(status, headers, body)
|
146 151 | } else {
|
259 264 | .expect("the config must have a deserializer");
|
260 265 |
|
261 266 | let parsed = de.deserialize_streaming(&mut http_response);
|
262 267 | let parsed = parsed.unwrap_or_else(|| {
|
263 268 | let http_response = http_response.map(|body| {
|
264 269 | ::aws_smithy_types::body::SdkBody::from(::bytes::Bytes::copy_from_slice(&::aws_smithy_protocol_test::decode_body_data(
|
265 270 | body.bytes().unwrap(),
|
266 271 | ::aws_smithy_protocol_test::MediaType::from("application/xml"),
|
267 272 | )))
|
268 273 | });
|
269 - | de.deserialize_nonstreaming(&http_response)
|
274 + | // Build a config bag with the protocol for schema-based deserialization
|
275 + | #[allow(unused_mut)]
|
276 + | let mut test_cfg = ::aws_smithy_types::config_bag::ConfigBag::base();
|
277 + |
|
278 + | de.deserialize_nonstreaming_with_config(&http_response, &test_cfg)
|
270 279 | });
|
271 280 | let parsed = parsed
|
272 281 | .expect("should be successful response")
|
273 282 | .downcast::<crate::operation::greeting_with_errors::GreetingWithErrorsOutput>()
|
274 283 | .unwrap();
|
275 284 | ::pretty_assertions::assert_eq!(parsed.greeting, expected_output.greeting, "Unexpected value for `greeting`");
|
276 285 | }
|
277 286 |
|
278 287 | /// Parses simple XML errors
|
279 288 | /// Test ID: Ec2InvalidGreetingError
|
280 289 | #[::tokio::test]
|
281 290 | #[::tracing_test::traced_test]
|
282 291 | async fn ec2_invalid_greeting_error_response() {
|
283 292 | let expected_output = crate::types::error::InvalidGreeting::builder()
|
284 293 | .set_message(::std::option::Option::Some("Hi".to_owned()))
|
285 294 | .build();
|
286 295 | let mut http_response = ::aws_smithy_runtime_api::http::Response::try_from(::http_1x::response::Builder::new()
|
287 296 | .header("Content-Type", "text/xml;charset=UTF-8")
|
288 297 | .status(400)
|
289 298 | .body(::aws_smithy_types::body::SdkBody::from("<Response>\n <Errors>\n <Error>\n <Code>InvalidGreeting</Code>\n <Message>Hi</Message>\n </Error>\n </Errors>\n <RequestID>foo-id</RequestID>\n</Response>\n"))
|
290 299 | .unwrap()
|
291 300 | ).unwrap();
|
292 301 | use ::aws_smithy_runtime_api::client::runtime_plugin::RuntimePlugin;
|
293 302 | use ::aws_smithy_runtime_api::client::ser_de::DeserializeResponse;
|
294 303 |
|
295 304 | let op = crate::operation::greeting_with_errors::GreetingWithErrors::new();
|
296 305 | let config = op.config().expect("the operation has config");
|
297 306 | let de = config
|
298 307 | .load::<::aws_smithy_runtime_api::client::ser_de::SharedResponseDeserializer>()
|
299 308 | .expect("the config must have a deserializer");
|
300 309 |
|
301 310 | let parsed = de.deserialize_streaming(&mut http_response);
|
302 311 | let parsed = parsed.unwrap_or_else(|| {
|
303 312 | let http_response = http_response.map(|body| {
|
304 313 | ::aws_smithy_types::body::SdkBody::from(::bytes::Bytes::copy_from_slice(&::aws_smithy_protocol_test::decode_body_data(
|
305 314 | body.bytes().unwrap(),
|
306 315 | ::aws_smithy_protocol_test::MediaType::from("application/xml"),
|
307 316 | )))
|
308 317 | });
|
309 - | de.deserialize_nonstreaming(&http_response)
|
318 + | // Build a config bag with the protocol for schema-based deserialization
|
319 + | #[allow(unused_mut)]
|
320 + | let mut test_cfg = ::aws_smithy_types::config_bag::ConfigBag::base();
|
321 + |
|
322 + | de.deserialize_nonstreaming_with_config(&http_response, &test_cfg)
|
310 323 | });
|
311 324 | let parsed = parsed.expect_err("should be error response");
|
312 325 | let parsed: &crate::operation::greeting_with_errors::GreetingWithErrorsError =
|
313 326 | parsed.as_operation_error().expect("operation error").downcast_ref().unwrap();
|
314 327 | if let crate::operation::greeting_with_errors::GreetingWithErrorsError::InvalidGreeting(parsed) = parsed {
|
315 328 | ::pretty_assertions::assert_eq!(parsed.message, expected_output.message, "Unexpected value for `message`");
|
316 329 | } else {
|
317 330 | panic!("wrong variant: Got: {:?}. Expected: {:?}", parsed, expected_output);
|
318 331 | }
|
319 332 | }
|
320 333 | /// Test ID: Ec2ComplexError
|
321 334 | #[::tokio::test]
|
322 335 | #[::tracing_test::traced_test]
|
323 336 | async fn ec2_complex_error_response() {
|
324 337 | let expected_output = crate::types::error::ComplexError::builder()
|
325 338 | .set_top_level(::std::option::Option::Some("Top level".to_owned()))
|
326 339 | .set_nested(::std::option::Option::Some(
|
327 340 | crate::types::ComplexNestedErrorData::builder()
|
328 341 | .set_foo(::std::option::Option::Some("bar".to_owned()))
|
329 342 | .build(),
|
330 343 | ))
|
331 344 | .build();
|
332 345 | let mut http_response = ::aws_smithy_runtime_api::http::Response::try_from(::http_1x::response::Builder::new()
|
333 346 | .header("Content-Type", "text/xml;charset=UTF-8")
|
334 347 | .status(400)
|
335 348 | .body(::aws_smithy_types::body::SdkBody::from("<Response>\n <Errors>\n <Error>\n <Code>ComplexError</Code>\n <Message>Hi</Message>\n <TopLevel>Top level</TopLevel>\n <Nested>\n <Foo>bar</Foo>\n </Nested>\n </Error>\n </Errors>\n <RequestID>foo-id</RequestID>\n</Response>\n"))
|
336 349 | .unwrap()
|
337 350 | ).unwrap();
|
338 351 | use ::aws_smithy_runtime_api::client::runtime_plugin::RuntimePlugin;
|
339 352 | use ::aws_smithy_runtime_api::client::ser_de::DeserializeResponse;
|
340 353 |
|
341 354 | let op = crate::operation::greeting_with_errors::GreetingWithErrors::new();
|
342 355 | let config = op.config().expect("the operation has config");
|
343 356 | let de = config
|
344 357 | .load::<::aws_smithy_runtime_api::client::ser_de::SharedResponseDeserializer>()
|
345 358 | .expect("the config must have a deserializer");
|
346 359 |
|
347 360 | let parsed = de.deserialize_streaming(&mut http_response);
|
348 361 | let parsed = parsed.unwrap_or_else(|| {
|
349 362 | let http_response = http_response.map(|body| {
|
350 363 | ::aws_smithy_types::body::SdkBody::from(::bytes::Bytes::copy_from_slice(&::aws_smithy_protocol_test::decode_body_data(
|
351 364 | body.bytes().unwrap(),
|
352 365 | ::aws_smithy_protocol_test::MediaType::from("application/xml"),
|
353 366 | )))
|
354 367 | });
|
355 - | de.deserialize_nonstreaming(&http_response)
|
368 + | // Build a config bag with the protocol for schema-based deserialization
|
369 + | #[allow(unused_mut)]
|
370 + | let mut test_cfg = ::aws_smithy_types::config_bag::ConfigBag::base();
|
371 + |
|
372 + | de.deserialize_nonstreaming_with_config(&http_response, &test_cfg)
|
356 373 | });
|
357 374 | let parsed = parsed.expect_err("should be error response");
|
358 375 | let parsed: &crate::operation::greeting_with_errors::GreetingWithErrorsError =
|
359 376 | parsed.as_operation_error().expect("operation error").downcast_ref().unwrap();
|
360 377 | if let crate::operation::greeting_with_errors::GreetingWithErrorsError::ComplexError(parsed) = parsed {
|
361 378 | ::pretty_assertions::assert_eq!(parsed.top_level, expected_output.top_level, "Unexpected value for `top_level`");
|
362 379 | ::pretty_assertions::assert_eq!(parsed.nested, expected_output.nested, "Unexpected value for `nested`");
|
363 380 | } else {
|
364 381 | panic!("wrong variant: Got: {:?}. Expected: {:?}", parsed, expected_output);
|
365 382 | }
|