aws_sdk_appsync/protocol_serde/
shape_get_graphql_api.rs1#[allow(clippy::unnecessary_wraps)]
3pub fn de_get_graphql_api_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_graphql_api::GetGraphqlApiOutput, crate::operation::get_graphql_api::GetGraphqlApiError> {
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_graphql_api::GetGraphqlApiError::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_graphql_api::GetGraphqlApiError::unhandled(generic)),
16 };
17
18 let _error_message = generic.message().map(|msg| msg.to_owned());
19 Err(match error_code {
20 "AccessDeniedException" => crate::operation::get_graphql_api::GetGraphqlApiError::AccessDeniedException({
21 #[allow(unused_mut)]
22 let mut tmp = {
23 #[allow(unused_mut)]
24 let mut output = crate::types::error::builders::AccessDeniedExceptionBuilder::default();
25 output = crate::protocol_serde::shape_access_denied_exception::de_access_denied_exception_json_err(_response_body, output)
26 .map_err(crate::operation::get_graphql_api::GetGraphqlApiError::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 "BadRequestException" => crate::operation::get_graphql_api::GetGraphqlApiError::BadRequestException({
36 #[allow(unused_mut)]
37 let mut tmp = {
38 #[allow(unused_mut)]
39 let mut output = crate::types::error::builders::BadRequestExceptionBuilder::default();
40 output = crate::protocol_serde::shape_bad_request_exception::de_bad_request_exception_json_err(_response_body, output)
41 .map_err(crate::operation::get_graphql_api::GetGraphqlApiError::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 "InternalFailureException" => crate::operation::get_graphql_api::GetGraphqlApiError::InternalFailureException({
51 #[allow(unused_mut)]
52 let mut tmp = {
53 #[allow(unused_mut)]
54 let mut output = crate::types::error::builders::InternalFailureExceptionBuilder::default();
55 output = crate::protocol_serde::shape_internal_failure_exception::de_internal_failure_exception_json_err(_response_body, output)
56 .map_err(crate::operation::get_graphql_api::GetGraphqlApiError::unhandled)?;
57 let output = output.meta(generic);
58 output.build()
59 };
60 if tmp.message.is_none() {
61 tmp.message = _error_message;
62 }
63 tmp
64 }),
65 "NotFoundException" => crate::operation::get_graphql_api::GetGraphqlApiError::NotFoundException({
66 #[allow(unused_mut)]
67 let mut tmp = {
68 #[allow(unused_mut)]
69 let mut output = crate::types::error::builders::NotFoundExceptionBuilder::default();
70 output = crate::protocol_serde::shape_not_found_exception::de_not_found_exception_json_err(_response_body, output)
71 .map_err(crate::operation::get_graphql_api::GetGraphqlApiError::unhandled)?;
72 let output = output.meta(generic);
73 output.build()
74 };
75 if tmp.message.is_none() {
76 tmp.message = _error_message;
77 }
78 tmp
79 }),
80 "UnauthorizedException" => crate::operation::get_graphql_api::GetGraphqlApiError::UnauthorizedException({
81 #[allow(unused_mut)]
82 let mut tmp = {
83 #[allow(unused_mut)]
84 let mut output = crate::types::error::builders::UnauthorizedExceptionBuilder::default();
85 output = crate::protocol_serde::shape_unauthorized_exception::de_unauthorized_exception_json_err(_response_body, output)
86 .map_err(crate::operation::get_graphql_api::GetGraphqlApiError::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 _ => crate::operation::get_graphql_api::GetGraphqlApiError::generic(generic),
96 })
97}
98
99#[allow(clippy::unnecessary_wraps)]
100pub fn de_get_graphql_api_http_response(
101 _response_status: u16,
102 _response_headers: &::aws_smithy_runtime_api::http::Headers,
103 _response_body: &[u8],
104) -> std::result::Result<crate::operation::get_graphql_api::GetGraphqlApiOutput, crate::operation::get_graphql_api::GetGraphqlApiError> {
105 Ok({
106 #[allow(unused_mut)]
107 let mut output = crate::operation::get_graphql_api::builders::GetGraphqlApiOutputBuilder::default();
108 output = crate::protocol_serde::shape_get_graphql_api::de_get_graphql_api(_response_body, output)
109 .map_err(crate::operation::get_graphql_api::GetGraphqlApiError::unhandled)?;
110 output._set_request_id(::aws_types::request_id::RequestId::request_id(_response_headers).map(str::to_string));
111 output.build()
112 })
113}
114
115pub(crate) fn de_get_graphql_api(
116 value: &[u8],
117 mut builder: crate::operation::get_graphql_api::builders::GetGraphqlApiOutputBuilder,
118) -> ::std::result::Result<
119 crate::operation::get_graphql_api::builders::GetGraphqlApiOutputBuilder,
120 ::aws_smithy_json::deserialize::error::DeserializeError,
121> {
122 let mut tokens_owned = ::aws_smithy_json::deserialize::json_token_iter(crate::protocol_serde::or_empty_doc(value)).peekable();
123 let tokens = &mut tokens_owned;
124 ::aws_smithy_json::deserialize::token::expect_start_object(tokens.next())?;
125 loop {
126 match tokens.next().transpose()? {
127 Some(::aws_smithy_json::deserialize::Token::EndObject { .. }) => break,
128 Some(::aws_smithy_json::deserialize::Token::ObjectKey { key, .. }) => match key.to_unescaped()?.as_ref() {
129 "graphqlApi" => {
130 builder = builder.set_graphql_api(crate::protocol_serde::shape_graphql_api::de_graphql_api(tokens)?);
131 }
132 _ => ::aws_smithy_json::deserialize::token::skip_value(tokens)?,
133 },
134 other => {
135 return Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(format!(
136 "expected object key or end object, found: {:?}",
137 other
138 )))
139 }
140 }
141 }
142 if tokens.next().is_some() {
143 return Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(
144 "found more JSON tokens after completing parsing",
145 ));
146 }
147 Ok(builder)
148}