aws_sdk_backup/protocol_serde/
shape_get_restore_testing_selection.rs1#[allow(clippy::unnecessary_wraps)]
3pub fn de_get_restore_testing_selection_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_restore_testing_selection::GetRestoreTestingSelectionOutput,
9 crate::operation::get_restore_testing_selection::GetRestoreTestingSelectionError,
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_restore_testing_selection::GetRestoreTestingSelectionError::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_restore_testing_selection::GetRestoreTestingSelectionError::unhandled(generic)),
19 };
20
21 let _error_message = generic.message().map(|msg| msg.to_owned());
22 Err(match error_code {
23 "ResourceNotFoundException" => crate::operation::get_restore_testing_selection::GetRestoreTestingSelectionError::ResourceNotFoundException({
24 #[allow(unused_mut)]
25 let mut tmp = {
26 #[allow(unused_mut)]
27 let mut output = crate::types::error::builders::ResourceNotFoundExceptionBuilder::default();
28 output = crate::protocol_serde::shape_resource_not_found_exception::de_resource_not_found_exception_json_err(_response_body, output)
29 .map_err(crate::operation::get_restore_testing_selection::GetRestoreTestingSelectionError::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 "ServiceUnavailableException" => {
39 crate::operation::get_restore_testing_selection::GetRestoreTestingSelectionError::ServiceUnavailableException({
40 #[allow(unused_mut)]
41 let mut tmp = {
42 #[allow(unused_mut)]
43 let mut output = crate::types::error::builders::ServiceUnavailableExceptionBuilder::default();
44 output =
45 crate::protocol_serde::shape_service_unavailable_exception::de_service_unavailable_exception_json_err(_response_body, output)
46 .map_err(crate::operation::get_restore_testing_selection::GetRestoreTestingSelectionError::unhandled)?;
47 let output = output.meta(generic);
48 output.build()
49 };
50 if tmp.message.is_none() {
51 tmp.message = _error_message;
52 }
53 tmp
54 })
55 }
56 _ => crate::operation::get_restore_testing_selection::GetRestoreTestingSelectionError::generic(generic),
57 })
58}
59
60#[allow(clippy::unnecessary_wraps)]
61pub fn de_get_restore_testing_selection_http_response(
62 _response_status: u16,
63 _response_headers: &::aws_smithy_runtime_api::http::Headers,
64 _response_body: &[u8],
65) -> std::result::Result<
66 crate::operation::get_restore_testing_selection::GetRestoreTestingSelectionOutput,
67 crate::operation::get_restore_testing_selection::GetRestoreTestingSelectionError,
68> {
69 Ok({
70 #[allow(unused_mut)]
71 let mut output = crate::operation::get_restore_testing_selection::builders::GetRestoreTestingSelectionOutputBuilder::default();
72 output = crate::protocol_serde::shape_get_restore_testing_selection::de_get_restore_testing_selection(_response_body, output)
73 .map_err(crate::operation::get_restore_testing_selection::GetRestoreTestingSelectionError::unhandled)?;
74 output._set_request_id(::aws_types::request_id::RequestId::request_id(_response_headers).map(str::to_string));
75 crate::serde_util::get_restore_testing_selection_output_output_correct_errors(output).build()
76 })
77}
78
79pub(crate) fn de_get_restore_testing_selection(
80 value: &[u8],
81 mut builder: crate::operation::get_restore_testing_selection::builders::GetRestoreTestingSelectionOutputBuilder,
82) -> ::std::result::Result<
83 crate::operation::get_restore_testing_selection::builders::GetRestoreTestingSelectionOutputBuilder,
84 ::aws_smithy_json::deserialize::error::DeserializeError,
85> {
86 let mut tokens_owned = ::aws_smithy_json::deserialize::json_token_iter(crate::protocol_serde::or_empty_doc(value)).peekable();
87 let tokens = &mut tokens_owned;
88 ::aws_smithy_json::deserialize::token::expect_start_object(tokens.next())?;
89 loop {
90 match tokens.next().transpose()? {
91 Some(::aws_smithy_json::deserialize::Token::EndObject { .. }) => break,
92 Some(::aws_smithy_json::deserialize::Token::ObjectKey { key, .. }) => match key.to_unescaped()?.as_ref() {
93 "RestoreTestingSelection" => {
94 builder = builder.set_restore_testing_selection(
95 crate::protocol_serde::shape_restore_testing_selection_for_get::de_restore_testing_selection_for_get(tokens)?,
96 );
97 }
98 _ => ::aws_smithy_json::deserialize::token::skip_value(tokens)?,
99 },
100 other => {
101 return Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(format!(
102 "expected object key or end object, found: {:?}",
103 other
104 )))
105 }
106 }
107 }
108 if tokens.next().is_some() {
109 return Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(
110 "found more JSON tokens after completing parsing",
111 ));
112 }
113 Ok(builder)
114}