aws_sdk_backup/protocol_serde/
shape_update_restore_testing_selection.rs1#[allow(clippy::unnecessary_wraps)]
3pub fn de_update_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::update_restore_testing_selection::UpdateRestoreTestingSelectionOutput,
9 crate::operation::update_restore_testing_selection::UpdateRestoreTestingSelectionError,
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::update_restore_testing_selection::UpdateRestoreTestingSelectionError::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::update_restore_testing_selection::UpdateRestoreTestingSelectionError::unhandled(generic)),
19 };
20
21 let _error_message = generic.message().map(|msg| msg.to_owned());
22 Err(match error_code {
23 "ConflictException" => crate::operation::update_restore_testing_selection::UpdateRestoreTestingSelectionError::ConflictException({
24 #[allow(unused_mut)]
25 let mut tmp = {
26 #[allow(unused_mut)]
27 let mut output = crate::types::error::builders::ConflictExceptionBuilder::default();
28 output = crate::protocol_serde::shape_conflict_exception::de_conflict_exception_json_err(_response_body, output)
29 .map_err(crate::operation::update_restore_testing_selection::UpdateRestoreTestingSelectionError::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 "InvalidParameterValueException" => {
39 crate::operation::update_restore_testing_selection::UpdateRestoreTestingSelectionError::InvalidParameterValueException({
40 #[allow(unused_mut)]
41 let mut tmp = {
42 #[allow(unused_mut)]
43 let mut output = crate::types::error::builders::InvalidParameterValueExceptionBuilder::default();
44 output = crate::protocol_serde::shape_invalid_parameter_value_exception::de_invalid_parameter_value_exception_json_err(
45 _response_body,
46 output,
47 )
48 .map_err(crate::operation::update_restore_testing_selection::UpdateRestoreTestingSelectionError::unhandled)?;
49 let output = output.meta(generic);
50 output.build()
51 };
52 if tmp.message.is_none() {
53 tmp.message = _error_message;
54 }
55 tmp
56 })
57 }
58 "MissingParameterValueException" => {
59 crate::operation::update_restore_testing_selection::UpdateRestoreTestingSelectionError::MissingParameterValueException({
60 #[allow(unused_mut)]
61 let mut tmp = {
62 #[allow(unused_mut)]
63 let mut output = crate::types::error::builders::MissingParameterValueExceptionBuilder::default();
64 output = crate::protocol_serde::shape_missing_parameter_value_exception::de_missing_parameter_value_exception_json_err(
65 _response_body,
66 output,
67 )
68 .map_err(crate::operation::update_restore_testing_selection::UpdateRestoreTestingSelectionError::unhandled)?;
69 let output = output.meta(generic);
70 output.build()
71 };
72 if tmp.message.is_none() {
73 tmp.message = _error_message;
74 }
75 tmp
76 })
77 }
78 "ResourceNotFoundException" => {
79 crate::operation::update_restore_testing_selection::UpdateRestoreTestingSelectionError::ResourceNotFoundException({
80 #[allow(unused_mut)]
81 let mut tmp = {
82 #[allow(unused_mut)]
83 let mut output = crate::types::error::builders::ResourceNotFoundExceptionBuilder::default();
84 output =
85 crate::protocol_serde::shape_resource_not_found_exception::de_resource_not_found_exception_json_err(_response_body, output)
86 .map_err(crate::operation::update_restore_testing_selection::UpdateRestoreTestingSelectionError::unhandled)?;
87 let output = output.meta(generic);
88 output.build()
89 };
90 if tmp.message.is_none() {
91 tmp.message = _error_message;
92 }
93 tmp
94 })
95 }
96 "ServiceUnavailableException" => {
97 crate::operation::update_restore_testing_selection::UpdateRestoreTestingSelectionError::ServiceUnavailableException({
98 #[allow(unused_mut)]
99 let mut tmp = {
100 #[allow(unused_mut)]
101 let mut output = crate::types::error::builders::ServiceUnavailableExceptionBuilder::default();
102 output =
103 crate::protocol_serde::shape_service_unavailable_exception::de_service_unavailable_exception_json_err(_response_body, output)
104 .map_err(crate::operation::update_restore_testing_selection::UpdateRestoreTestingSelectionError::unhandled)?;
105 let output = output.meta(generic);
106 output.build()
107 };
108 if tmp.message.is_none() {
109 tmp.message = _error_message;
110 }
111 tmp
112 })
113 }
114 _ => crate::operation::update_restore_testing_selection::UpdateRestoreTestingSelectionError::generic(generic),
115 })
116}
117
118#[allow(clippy::unnecessary_wraps)]
119pub fn de_update_restore_testing_selection_http_response(
120 _response_status: u16,
121 _response_headers: &::aws_smithy_runtime_api::http::Headers,
122 _response_body: &[u8],
123) -> std::result::Result<
124 crate::operation::update_restore_testing_selection::UpdateRestoreTestingSelectionOutput,
125 crate::operation::update_restore_testing_selection::UpdateRestoreTestingSelectionError,
126> {
127 Ok({
128 #[allow(unused_mut)]
129 let mut output = crate::operation::update_restore_testing_selection::builders::UpdateRestoreTestingSelectionOutputBuilder::default();
130 output = crate::protocol_serde::shape_update_restore_testing_selection::de_update_restore_testing_selection(_response_body, output)
131 .map_err(crate::operation::update_restore_testing_selection::UpdateRestoreTestingSelectionError::unhandled)?;
132 output._set_request_id(::aws_types::request_id::RequestId::request_id(_response_headers).map(str::to_string));
133 crate::serde_util::update_restore_testing_selection_output_output_correct_errors(output)
134 .build()
135 .map_err(crate::operation::update_restore_testing_selection::UpdateRestoreTestingSelectionError::unhandled)?
136 })
137}
138
139pub fn ser_update_restore_testing_selection_input(
140 input: &crate::operation::update_restore_testing_selection::UpdateRestoreTestingSelectionInput,
141) -> ::std::result::Result<::aws_smithy_types::body::SdkBody, ::aws_smithy_types::error::operation::SerializationError> {
142 let mut out = String::new();
143 let mut object = ::aws_smithy_json::serialize::JsonObjectWriter::new(&mut out);
144 crate::protocol_serde::shape_update_restore_testing_selection_input::ser_update_restore_testing_selection_input_input(&mut object, input)?;
145 object.finish();
146 Ok(::aws_smithy_types::body::SdkBody::from(out))
147}
148
149pub(crate) fn de_update_restore_testing_selection(
150 value: &[u8],
151 mut builder: crate::operation::update_restore_testing_selection::builders::UpdateRestoreTestingSelectionOutputBuilder,
152) -> ::std::result::Result<
153 crate::operation::update_restore_testing_selection::builders::UpdateRestoreTestingSelectionOutputBuilder,
154 ::aws_smithy_json::deserialize::error::DeserializeError,
155> {
156 let mut tokens_owned = ::aws_smithy_json::deserialize::json_token_iter(crate::protocol_serde::or_empty_doc(value)).peekable();
157 let tokens = &mut tokens_owned;
158 ::aws_smithy_json::deserialize::token::expect_start_object(tokens.next())?;
159 loop {
160 match tokens.next().transpose()? {
161 Some(::aws_smithy_json::deserialize::Token::EndObject { .. }) => break,
162 Some(::aws_smithy_json::deserialize::Token::ObjectKey { key, .. }) => match key.to_unescaped()?.as_ref() {
163 "CreationTime" => {
164 builder = builder.set_creation_time(::aws_smithy_json::deserialize::token::expect_timestamp_or_null(
165 tokens.next(),
166 ::aws_smithy_types::date_time::Format::EpochSeconds,
167 )?);
168 }
169 "RestoreTestingPlanArn" => {
170 builder = builder.set_restore_testing_plan_arn(
171 ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
172 .map(|s| s.to_unescaped().map(|u| u.into_owned()))
173 .transpose()?,
174 );
175 }
176 "RestoreTestingPlanName" => {
177 builder = builder.set_restore_testing_plan_name(
178 ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
179 .map(|s| s.to_unescaped().map(|u| u.into_owned()))
180 .transpose()?,
181 );
182 }
183 "RestoreTestingSelectionName" => {
184 builder = builder.set_restore_testing_selection_name(
185 ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
186 .map(|s| s.to_unescaped().map(|u| u.into_owned()))
187 .transpose()?,
188 );
189 }
190 "UpdateTime" => {
191 builder = builder.set_update_time(::aws_smithy_json::deserialize::token::expect_timestamp_or_null(
192 tokens.next(),
193 ::aws_smithy_types::date_time::Format::EpochSeconds,
194 )?);
195 }
196 _ => ::aws_smithy_json::deserialize::token::skip_value(tokens)?,
197 },
198 other => {
199 return Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(format!(
200 "expected object key or end object, found: {:?}",
201 other
202 )))
203 }
204 }
205 }
206 if tokens.next().is_some() {
207 return Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(
208 "found more JSON tokens after completing parsing",
209 ));
210 }
211 Ok(builder)
212}