aws_sdk_appsync/protocol_serde/
shape_get_schema_creation_status.rs

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