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