aws_sdk_appsync/protocol_serde/
shape_get_function.rs1#[allow(clippy::unnecessary_wraps)]
3pub fn de_get_function_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::get_function::GetFunctionOutput, crate::operation::get_function::GetFunctionError> {
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::get_function::GetFunctionError::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::get_function::GetFunctionError::unhandled(generic)),
16 };
17
18 let _error_message = generic.message().map(|msg| msg.to_owned());
19 Err(match error_code {
20 "ConcurrentModificationException" => crate::operation::get_function::GetFunctionError::ConcurrentModificationException({
21 #[allow(unused_mut)]
22 let mut tmp = {
23 #[allow(unused_mut)]
24 let mut output = crate::types::error::builders::ConcurrentModificationExceptionBuilder::default();
25 output = crate::protocol_serde::shape_concurrent_modification_exception::de_concurrent_modification_exception_json_err(
26 _response_body,
27 output,
28 )
29 .map_err(crate::operation::get_function::GetFunctionError::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 "NotFoundException" => crate::operation::get_function::GetFunctionError::NotFoundException({
39 #[allow(unused_mut)]
40 let mut tmp = {
41 #[allow(unused_mut)]
42 let mut output = crate::types::error::builders::NotFoundExceptionBuilder::default();
43 output = crate::protocol_serde::shape_not_found_exception::de_not_found_exception_json_err(_response_body, output)
44 .map_err(crate::operation::get_function::GetFunctionError::unhandled)?;
45 let output = output.meta(generic);
46 output.build()
47 };
48 if tmp.message.is_none() {
49 tmp.message = _error_message;
50 }
51 tmp
52 }),
53 "UnauthorizedException" => crate::operation::get_function::GetFunctionError::UnauthorizedException({
54 #[allow(unused_mut)]
55 let mut tmp = {
56 #[allow(unused_mut)]
57 let mut output = crate::types::error::builders::UnauthorizedExceptionBuilder::default();
58 output = crate::protocol_serde::shape_unauthorized_exception::de_unauthorized_exception_json_err(_response_body, output)
59 .map_err(crate::operation::get_function::GetFunctionError::unhandled)?;
60 let output = output.meta(generic);
61 output.build()
62 };
63 if tmp.message.is_none() {
64 tmp.message = _error_message;
65 }
66 tmp
67 }),
68 _ => crate::operation::get_function::GetFunctionError::generic(generic),
69 })
70}
71
72#[allow(clippy::unnecessary_wraps)]
73pub fn de_get_function_http_response(
74 _response_status: u16,
75 _response_headers: &::aws_smithy_runtime_api::http::Headers,
76 _response_body: &[u8],
77) -> std::result::Result<crate::operation::get_function::GetFunctionOutput, crate::operation::get_function::GetFunctionError> {
78 Ok({
79 #[allow(unused_mut)]
80 let mut output = crate::operation::get_function::builders::GetFunctionOutputBuilder::default();
81 output = crate::protocol_serde::shape_get_function::de_get_function(_response_body, output)
82 .map_err(crate::operation::get_function::GetFunctionError::unhandled)?;
83 output._set_request_id(::aws_types::request_id::RequestId::request_id(_response_headers).map(str::to_string));
84 output.build()
85 })
86}
87
88pub(crate) fn de_get_function(
89 value: &[u8],
90 mut builder: crate::operation::get_function::builders::GetFunctionOutputBuilder,
91) -> ::std::result::Result<crate::operation::get_function::builders::GetFunctionOutputBuilder, ::aws_smithy_json::deserialize::error::DeserializeError>
92{
93 let mut tokens_owned = ::aws_smithy_json::deserialize::json_token_iter(crate::protocol_serde::or_empty_doc(value)).peekable();
94 let tokens = &mut tokens_owned;
95 ::aws_smithy_json::deserialize::token::expect_start_object(tokens.next())?;
96 loop {
97 match tokens.next().transpose()? {
98 Some(::aws_smithy_json::deserialize::Token::EndObject { .. }) => break,
99 Some(::aws_smithy_json::deserialize::Token::ObjectKey { key, .. }) => match key.to_unescaped()?.as_ref() {
100 "functionConfiguration" => {
101 builder =
102 builder.set_function_configuration(crate::protocol_serde::shape_function_configuration::de_function_configuration(tokens)?);
103 }
104 _ => ::aws_smithy_json::deserialize::token::skip_value(tokens)?,
105 },
106 other => {
107 return Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(format!(
108 "expected object key or end object, found: {:?}",
109 other
110 )))
111 }
112 }
113 }
114 if tokens.next().is_some() {
115 return Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(
116 "found more JSON tokens after completing parsing",
117 ));
118 }
119 Ok(builder)
120}