aws_sdk_databrew/protocol_serde/
shape_update_recipe.rs1#[allow(clippy::unnecessary_wraps)]
3pub fn de_update_recipe_http_error(
4 _response_status: u16,
5 _response_headers: &::aws_smithy_runtime_api::http::Headers,
6 _response_body: &[u8],
7) -> std::result::Result<crate::operation::update_recipe::UpdateRecipeOutput, crate::operation::update_recipe::UpdateRecipeError> {
8 #[allow(unused_mut)]
9 let mut generic_builder = crate::protocol_serde::parse_http_error_metadata(_response_status, _response_headers, _response_body)
10 .map_err(crate::operation::update_recipe::UpdateRecipeError::unhandled)?;
11 generic_builder = ::aws_types::request_id::apply_request_id(generic_builder, _response_headers);
12 let generic = generic_builder.build();
13 let error_code = match generic.code() {
14 Some(code) => code,
15 None => return Err(crate::operation::update_recipe::UpdateRecipeError::unhandled(generic)),
16 };
17
18 let _error_message = generic.message().map(|msg| msg.to_owned());
19 Err(match error_code {
20 "ResourceNotFoundException" => crate::operation::update_recipe::UpdateRecipeError::ResourceNotFoundException({
21 #[allow(unused_mut)]
22 let mut tmp = {
23 #[allow(unused_mut)]
24 let mut output = crate::types::error::builders::ResourceNotFoundExceptionBuilder::default();
25 output = crate::protocol_serde::shape_resource_not_found_exception::de_resource_not_found_exception_json_err(_response_body, output)
26 .map_err(crate::operation::update_recipe::UpdateRecipeError::unhandled)?;
27 let output = output.meta(generic);
28 output.build()
29 };
30 if tmp.message.is_none() {
31 tmp.message = _error_message;
32 }
33 tmp
34 }),
35 "ValidationException" => crate::operation::update_recipe::UpdateRecipeError::ValidationException({
36 #[allow(unused_mut)]
37 let mut tmp = {
38 #[allow(unused_mut)]
39 let mut output = crate::types::error::builders::ValidationExceptionBuilder::default();
40 output = crate::protocol_serde::shape_validation_exception::de_validation_exception_json_err(_response_body, output)
41 .map_err(crate::operation::update_recipe::UpdateRecipeError::unhandled)?;
42 let output = output.meta(generic);
43 output.build()
44 };
45 if tmp.message.is_none() {
46 tmp.message = _error_message;
47 }
48 tmp
49 }),
50 _ => crate::operation::update_recipe::UpdateRecipeError::generic(generic),
51 })
52}
53
54#[allow(clippy::unnecessary_wraps)]
55pub fn de_update_recipe_http_response(
56 _response_status: u16,
57 _response_headers: &::aws_smithy_runtime_api::http::Headers,
58 _response_body: &[u8],
59) -> std::result::Result<crate::operation::update_recipe::UpdateRecipeOutput, crate::operation::update_recipe::UpdateRecipeError> {
60 Ok({
61 #[allow(unused_mut)]
62 let mut output = crate::operation::update_recipe::builders::UpdateRecipeOutputBuilder::default();
63 output = crate::protocol_serde::shape_update_recipe::de_update_recipe(_response_body, output)
64 .map_err(crate::operation::update_recipe::UpdateRecipeError::unhandled)?;
65 output._set_request_id(::aws_types::request_id::RequestId::request_id(_response_headers).map(str::to_string));
66 crate::serde_util::update_recipe_output_output_correct_errors(output)
67 .build()
68 .map_err(crate::operation::update_recipe::UpdateRecipeError::unhandled)?
69 })
70}
71
72pub fn ser_update_recipe_input(
73 input: &crate::operation::update_recipe::UpdateRecipeInput,
74) -> ::std::result::Result<::aws_smithy_types::body::SdkBody, ::aws_smithy_types::error::operation::SerializationError> {
75 let mut out = String::new();
76 let mut object = ::aws_smithy_json::serialize::JsonObjectWriter::new(&mut out);
77 crate::protocol_serde::shape_update_recipe_input::ser_update_recipe_input_input(&mut object, input)?;
78 object.finish();
79 Ok(::aws_smithy_types::body::SdkBody::from(out))
80}
81
82pub(crate) fn de_update_recipe(
83 value: &[u8],
84 mut builder: crate::operation::update_recipe::builders::UpdateRecipeOutputBuilder,
85) -> ::std::result::Result<
86 crate::operation::update_recipe::builders::UpdateRecipeOutputBuilder,
87 ::aws_smithy_json::deserialize::error::DeserializeError,
88> {
89 let mut tokens_owned = ::aws_smithy_json::deserialize::json_token_iter(crate::protocol_serde::or_empty_doc(value)).peekable();
90 let tokens = &mut tokens_owned;
91 ::aws_smithy_json::deserialize::token::expect_start_object(tokens.next())?;
92 loop {
93 match tokens.next().transpose()? {
94 Some(::aws_smithy_json::deserialize::Token::EndObject { .. }) => break,
95 Some(::aws_smithy_json::deserialize::Token::ObjectKey { key, .. }) => match key.to_unescaped()?.as_ref() {
96 "Name" => {
97 builder = builder.set_name(
98 ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
99 .map(|s| s.to_unescaped().map(|u| u.into_owned()))
100 .transpose()?,
101 );
102 }
103 _ => ::aws_smithy_json::deserialize::token::skip_value(tokens)?,
104 },
105 other => {
106 return Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(format!(
107 "expected object key or end object, found: {:?}",
108 other
109 )))
110 }
111 }
112 }
113 if tokens.next().is_some() {
114 return Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(
115 "found more JSON tokens after completing parsing",
116 ));
117 }
118 Ok(builder)
119}