aws_sdk_appsync/protocol_serde/
shape_get_graphql_api_environment_variables.rs

1// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
2#[allow(clippy::unnecessary_wraps)]
3pub fn de_get_graphql_api_environment_variables_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::get_graphql_api_environment_variables::GetGraphqlApiEnvironmentVariablesOutput,
9    crate::operation::get_graphql_api_environment_variables::GetGraphqlApiEnvironmentVariablesError,
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::get_graphql_api_environment_variables::GetGraphqlApiEnvironmentVariablesError::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::get_graphql_api_environment_variables::GetGraphqlApiEnvironmentVariablesError::unhandled(generic)),
19    };
20
21    let _error_message = generic.message().map(|msg| msg.to_owned());
22    Err(match error_code {
23        "AccessDeniedException" => {
24            crate::operation::get_graphql_api_environment_variables::GetGraphqlApiEnvironmentVariablesError::AccessDeniedException({
25                #[allow(unused_mut)]
26                let mut tmp = {
27                    #[allow(unused_mut)]
28                    let mut output = crate::types::error::builders::AccessDeniedExceptionBuilder::default();
29                    output = crate::protocol_serde::shape_access_denied_exception::de_access_denied_exception_json_err(_response_body, output)
30                        .map_err(crate::operation::get_graphql_api_environment_variables::GetGraphqlApiEnvironmentVariablesError::unhandled)?;
31                    let output = output.meta(generic);
32                    output.build()
33                };
34                if tmp.message.is_none() {
35                    tmp.message = _error_message;
36                }
37                tmp
38            })
39        }
40        "BadRequestException" => {
41            crate::operation::get_graphql_api_environment_variables::GetGraphqlApiEnvironmentVariablesError::BadRequestException({
42                #[allow(unused_mut)]
43                let mut tmp = {
44                    #[allow(unused_mut)]
45                    let mut output = crate::types::error::builders::BadRequestExceptionBuilder::default();
46                    output = crate::protocol_serde::shape_bad_request_exception::de_bad_request_exception_json_err(_response_body, output)
47                        .map_err(crate::operation::get_graphql_api_environment_variables::GetGraphqlApiEnvironmentVariablesError::unhandled)?;
48                    let output = output.meta(generic);
49                    output.build()
50                };
51                if tmp.message.is_none() {
52                    tmp.message = _error_message;
53                }
54                tmp
55            })
56        }
57        "InternalFailureException" => {
58            crate::operation::get_graphql_api_environment_variables::GetGraphqlApiEnvironmentVariablesError::InternalFailureException({
59                #[allow(unused_mut)]
60                let mut tmp = {
61                    #[allow(unused_mut)]
62                    let mut output = crate::types::error::builders::InternalFailureExceptionBuilder::default();
63                    output = crate::protocol_serde::shape_internal_failure_exception::de_internal_failure_exception_json_err(_response_body, output)
64                        .map_err(crate::operation::get_graphql_api_environment_variables::GetGraphqlApiEnvironmentVariablesError::unhandled)?;
65                    let output = output.meta(generic);
66                    output.build()
67                };
68                if tmp.message.is_none() {
69                    tmp.message = _error_message;
70                }
71                tmp
72            })
73        }
74        "NotFoundException" => crate::operation::get_graphql_api_environment_variables::GetGraphqlApiEnvironmentVariablesError::NotFoundException({
75            #[allow(unused_mut)]
76            let mut tmp = {
77                #[allow(unused_mut)]
78                let mut output = crate::types::error::builders::NotFoundExceptionBuilder::default();
79                output = crate::protocol_serde::shape_not_found_exception::de_not_found_exception_json_err(_response_body, output)
80                    .map_err(crate::operation::get_graphql_api_environment_variables::GetGraphqlApiEnvironmentVariablesError::unhandled)?;
81                let output = output.meta(generic);
82                output.build()
83            };
84            if tmp.message.is_none() {
85                tmp.message = _error_message;
86            }
87            tmp
88        }),
89        "UnauthorizedException" => {
90            crate::operation::get_graphql_api_environment_variables::GetGraphqlApiEnvironmentVariablesError::UnauthorizedException({
91                #[allow(unused_mut)]
92                let mut tmp = {
93                    #[allow(unused_mut)]
94                    let mut output = crate::types::error::builders::UnauthorizedExceptionBuilder::default();
95                    output = crate::protocol_serde::shape_unauthorized_exception::de_unauthorized_exception_json_err(_response_body, output)
96                        .map_err(crate::operation::get_graphql_api_environment_variables::GetGraphqlApiEnvironmentVariablesError::unhandled)?;
97                    let output = output.meta(generic);
98                    output.build()
99                };
100                if tmp.message.is_none() {
101                    tmp.message = _error_message;
102                }
103                tmp
104            })
105        }
106        _ => crate::operation::get_graphql_api_environment_variables::GetGraphqlApiEnvironmentVariablesError::generic(generic),
107    })
108}
109
110#[allow(clippy::unnecessary_wraps)]
111pub fn de_get_graphql_api_environment_variables_http_response(
112    _response_status: u16,
113    _response_headers: &::aws_smithy_runtime_api::http::Headers,
114    _response_body: &[u8],
115) -> std::result::Result<
116    crate::operation::get_graphql_api_environment_variables::GetGraphqlApiEnvironmentVariablesOutput,
117    crate::operation::get_graphql_api_environment_variables::GetGraphqlApiEnvironmentVariablesError,
118> {
119    Ok({
120        #[allow(unused_mut)]
121        let mut output = crate::operation::get_graphql_api_environment_variables::builders::GetGraphqlApiEnvironmentVariablesOutputBuilder::default();
122        output = crate::protocol_serde::shape_get_graphql_api_environment_variables::de_get_graphql_api_environment_variables(_response_body, output)
123            .map_err(crate::operation::get_graphql_api_environment_variables::GetGraphqlApiEnvironmentVariablesError::unhandled)?;
124        output._set_request_id(::aws_types::request_id::RequestId::request_id(_response_headers).map(str::to_string));
125        output.build()
126    })
127}
128
129pub(crate) fn de_get_graphql_api_environment_variables(
130    value: &[u8],
131    mut builder: crate::operation::get_graphql_api_environment_variables::builders::GetGraphqlApiEnvironmentVariablesOutputBuilder,
132) -> ::std::result::Result<
133    crate::operation::get_graphql_api_environment_variables::builders::GetGraphqlApiEnvironmentVariablesOutputBuilder,
134    ::aws_smithy_json::deserialize::error::DeserializeError,
135> {
136    let mut tokens_owned = ::aws_smithy_json::deserialize::json_token_iter(crate::protocol_serde::or_empty_doc(value)).peekable();
137    let tokens = &mut tokens_owned;
138    ::aws_smithy_json::deserialize::token::expect_start_object(tokens.next())?;
139    loop {
140        match tokens.next().transpose()? {
141            Some(::aws_smithy_json::deserialize::Token::EndObject { .. }) => break,
142            Some(::aws_smithy_json::deserialize::Token::ObjectKey { key, .. }) => match key.to_unescaped()?.as_ref() {
143                "environmentVariables" => {
144                    builder = builder.set_environment_variables(crate::protocol_serde::shape_environment_variable_map::de_environment_variable_map(
145                        tokens,
146                    )?);
147                }
148                _ => ::aws_smithy_json::deserialize::token::skip_value(tokens)?,
149            },
150            other => {
151                return Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(format!(
152                    "expected object key or end object, found: {:?}",
153                    other
154                )))
155            }
156        }
157    }
158    if tokens.next().is_some() {
159        return Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(
160            "found more JSON tokens after completing parsing",
161        ));
162    }
163    Ok(builder)
164}