aws_sdk_dynamodb/protocol_serde/
shape_describe_global_table.rs

1// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
2#[allow(clippy::unnecessary_wraps)]
3pub fn de_describe_global_table_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::describe_global_table::DescribeGlobalTableOutput,
9    crate::operation::describe_global_table::DescribeGlobalTableError,
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::describe_global_table::DescribeGlobalTableError::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::describe_global_table::DescribeGlobalTableError::unhandled(generic)),
19    };
20
21    let _error_message = generic.message().map(|msg| msg.to_owned());
22    Err(match error_code {
23        "GlobalTableNotFoundException" => crate::operation::describe_global_table::DescribeGlobalTableError::GlobalTableNotFoundException({
24            #[allow(unused_mut)]
25            let mut tmp = {
26                #[allow(unused_mut)]
27                let mut output = crate::types::error::builders::GlobalTableNotFoundExceptionBuilder::default();
28                output = crate::protocol_serde::shape_global_table_not_found_exception::de_global_table_not_found_exception_json_err(
29                    _response_body,
30                    output,
31                )
32                .map_err(crate::operation::describe_global_table::DescribeGlobalTableError::unhandled)?;
33                let output = output.meta(generic);
34                output.build()
35            };
36            if tmp.message.is_none() {
37                tmp.message = _error_message;
38            }
39            tmp
40        }),
41        "InternalServerError" => crate::operation::describe_global_table::DescribeGlobalTableError::InternalServerError({
42            #[allow(unused_mut)]
43            let mut tmp = {
44                #[allow(unused_mut)]
45                let mut output = crate::types::error::builders::InternalServerErrorBuilder::default();
46                output = crate::protocol_serde::shape_internal_server_error::de_internal_server_error_json_err(_response_body, output)
47                    .map_err(crate::operation::describe_global_table::DescribeGlobalTableError::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        "InvalidEndpointException" => crate::operation::describe_global_table::DescribeGlobalTableError::InvalidEndpointException({
57            #[allow(unused_mut)]
58            let mut tmp = {
59                #[allow(unused_mut)]
60                let mut output = crate::types::error::builders::InvalidEndpointExceptionBuilder::default();
61                output = crate::protocol_serde::shape_invalid_endpoint_exception::de_invalid_endpoint_exception_json_err(_response_body, output)
62                    .map_err(crate::operation::describe_global_table::DescribeGlobalTableError::unhandled)?;
63                let output = output.meta(generic);
64                output.build()
65            };
66            if tmp.message.is_none() {
67                tmp.message = _error_message;
68            }
69            tmp
70        }),
71        _ => crate::operation::describe_global_table::DescribeGlobalTableError::generic(generic),
72    })
73}
74
75#[allow(clippy::unnecessary_wraps)]
76pub fn de_describe_global_table_http_response(
77    _response_status: u16,
78    _response_headers: &::aws_smithy_runtime_api::http::Headers,
79    _response_body: &[u8],
80) -> std::result::Result<
81    crate::operation::describe_global_table::DescribeGlobalTableOutput,
82    crate::operation::describe_global_table::DescribeGlobalTableError,
83> {
84    Ok({
85        #[allow(unused_mut)]
86        let mut output = crate::operation::describe_global_table::builders::DescribeGlobalTableOutputBuilder::default();
87        output = crate::protocol_serde::shape_describe_global_table::de_describe_global_table(_response_body, output)
88            .map_err(crate::operation::describe_global_table::DescribeGlobalTableError::unhandled)?;
89        output._set_request_id(::aws_types::request_id::RequestId::request_id(_response_headers).map(str::to_string));
90        output.build()
91    })
92}
93
94pub fn ser_describe_global_table_input(
95    input: &crate::operation::describe_global_table::DescribeGlobalTableInput,
96) -> ::std::result::Result<::aws_smithy_types::body::SdkBody, ::aws_smithy_types::error::operation::SerializationError> {
97    let mut out = String::new();
98    let mut object = ::aws_smithy_json::serialize::JsonObjectWriter::new(&mut out);
99    crate::protocol_serde::shape_describe_global_table_input::ser_describe_global_table_input_input(&mut object, input)?;
100    object.finish();
101    Ok(::aws_smithy_types::body::SdkBody::from(out))
102}
103
104pub(crate) fn de_describe_global_table(
105    value: &[u8],
106    mut builder: crate::operation::describe_global_table::builders::DescribeGlobalTableOutputBuilder,
107) -> ::std::result::Result<
108    crate::operation::describe_global_table::builders::DescribeGlobalTableOutputBuilder,
109    ::aws_smithy_json::deserialize::error::DeserializeError,
110> {
111    let mut tokens_owned = ::aws_smithy_json::deserialize::json_token_iter(crate::protocol_serde::or_empty_doc(value)).peekable();
112    let tokens = &mut tokens_owned;
113    ::aws_smithy_json::deserialize::token::expect_start_object(tokens.next())?;
114    loop {
115        match tokens.next().transpose()? {
116            Some(::aws_smithy_json::deserialize::Token::EndObject { .. }) => break,
117            Some(::aws_smithy_json::deserialize::Token::ObjectKey { key, .. }) => match key.to_unescaped()?.as_ref() {
118                "GlobalTableDescription" => {
119                    builder = builder.set_global_table_description(
120                        crate::protocol_serde::shape_global_table_description::de_global_table_description(tokens)?,
121                    );
122                }
123                _ => ::aws_smithy_json::deserialize::token::skip_value(tokens)?,
124            },
125            other => {
126                return Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(format!(
127                    "expected object key or end object, found: {:?}",
128                    other
129                )))
130            }
131        }
132    }
133    if tokens.next().is_some() {
134        return Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(
135            "found more JSON tokens after completing parsing",
136        ));
137    }
138    Ok(builder)
139}