aws_sdk_dynamodb/protocol_serde/
shape_update_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_update_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<crate::operation::update_global_table::UpdateGlobalTableOutput, crate::operation::update_global_table::UpdateGlobalTableError>
8{
9    #[allow(unused_mut)]
10    let mut generic_builder = crate::protocol_serde::parse_http_error_metadata(_response_status, _response_headers, _response_body)
11        .map_err(crate::operation::update_global_table::UpdateGlobalTableError::unhandled)?;
12    generic_builder = ::aws_types::request_id::apply_request_id(generic_builder, _response_headers);
13    let generic = generic_builder.build();
14    let error_code = match generic.code() {
15        Some(code) => code,
16        None => return Err(crate::operation::update_global_table::UpdateGlobalTableError::unhandled(generic)),
17    };
18
19    let _error_message = generic.message().map(|msg| msg.to_owned());
20    Err(match error_code {
21        "GlobalTableNotFoundException" => crate::operation::update_global_table::UpdateGlobalTableError::GlobalTableNotFoundException({
22            #[allow(unused_mut)]
23            let mut tmp = {
24                #[allow(unused_mut)]
25                let mut output = crate::types::error::builders::GlobalTableNotFoundExceptionBuilder::default();
26                output = crate::protocol_serde::shape_global_table_not_found_exception::de_global_table_not_found_exception_json_err(
27                    _response_body,
28                    output,
29                )
30                .map_err(crate::operation::update_global_table::UpdateGlobalTableError::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        "InternalServerError" => crate::operation::update_global_table::UpdateGlobalTableError::InternalServerError({
40            #[allow(unused_mut)]
41            let mut tmp = {
42                #[allow(unused_mut)]
43                let mut output = crate::types::error::builders::InternalServerErrorBuilder::default();
44                output = crate::protocol_serde::shape_internal_server_error::de_internal_server_error_json_err(_response_body, output)
45                    .map_err(crate::operation::update_global_table::UpdateGlobalTableError::unhandled)?;
46                let output = output.meta(generic);
47                output.build()
48            };
49            if tmp.message.is_none() {
50                tmp.message = _error_message;
51            }
52            tmp
53        }),
54        "InvalidEndpointException" => crate::operation::update_global_table::UpdateGlobalTableError::InvalidEndpointException({
55            #[allow(unused_mut)]
56            let mut tmp = {
57                #[allow(unused_mut)]
58                let mut output = crate::types::error::builders::InvalidEndpointExceptionBuilder::default();
59                output = crate::protocol_serde::shape_invalid_endpoint_exception::de_invalid_endpoint_exception_json_err(_response_body, output)
60                    .map_err(crate::operation::update_global_table::UpdateGlobalTableError::unhandled)?;
61                let output = output.meta(generic);
62                output.build()
63            };
64            if tmp.message.is_none() {
65                tmp.message = _error_message;
66            }
67            tmp
68        }),
69        "ReplicaAlreadyExistsException" => crate::operation::update_global_table::UpdateGlobalTableError::ReplicaAlreadyExistsException({
70            #[allow(unused_mut)]
71            let mut tmp = {
72                #[allow(unused_mut)]
73                let mut output = crate::types::error::builders::ReplicaAlreadyExistsExceptionBuilder::default();
74                output = crate::protocol_serde::shape_replica_already_exists_exception::de_replica_already_exists_exception_json_err(
75                    _response_body,
76                    output,
77                )
78                .map_err(crate::operation::update_global_table::UpdateGlobalTableError::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        "ReplicaNotFoundException" => crate::operation::update_global_table::UpdateGlobalTableError::ReplicaNotFoundException({
88            #[allow(unused_mut)]
89            let mut tmp = {
90                #[allow(unused_mut)]
91                let mut output = crate::types::error::builders::ReplicaNotFoundExceptionBuilder::default();
92                output = crate::protocol_serde::shape_replica_not_found_exception::de_replica_not_found_exception_json_err(_response_body, output)
93                    .map_err(crate::operation::update_global_table::UpdateGlobalTableError::unhandled)?;
94                let output = output.meta(generic);
95                output.build()
96            };
97            if tmp.message.is_none() {
98                tmp.message = _error_message;
99            }
100            tmp
101        }),
102        "TableNotFoundException" => crate::operation::update_global_table::UpdateGlobalTableError::TableNotFoundException({
103            #[allow(unused_mut)]
104            let mut tmp = {
105                #[allow(unused_mut)]
106                let mut output = crate::types::error::builders::TableNotFoundExceptionBuilder::default();
107                output = crate::protocol_serde::shape_table_not_found_exception::de_table_not_found_exception_json_err(_response_body, output)
108                    .map_err(crate::operation::update_global_table::UpdateGlobalTableError::unhandled)?;
109                let output = output.meta(generic);
110                output.build()
111            };
112            if tmp.message.is_none() {
113                tmp.message = _error_message;
114            }
115            tmp
116        }),
117        _ => crate::operation::update_global_table::UpdateGlobalTableError::generic(generic),
118    })
119}
120
121#[allow(clippy::unnecessary_wraps)]
122pub fn de_update_global_table_http_response(
123    _response_status: u16,
124    _response_headers: &::aws_smithy_runtime_api::http::Headers,
125    _response_body: &[u8],
126) -> std::result::Result<crate::operation::update_global_table::UpdateGlobalTableOutput, crate::operation::update_global_table::UpdateGlobalTableError>
127{
128    Ok({
129        #[allow(unused_mut)]
130        let mut output = crate::operation::update_global_table::builders::UpdateGlobalTableOutputBuilder::default();
131        output = crate::protocol_serde::shape_update_global_table::de_update_global_table(_response_body, output)
132            .map_err(crate::operation::update_global_table::UpdateGlobalTableError::unhandled)?;
133        output._set_request_id(::aws_types::request_id::RequestId::request_id(_response_headers).map(str::to_string));
134        output.build()
135    })
136}
137
138pub fn ser_update_global_table_input(
139    input: &crate::operation::update_global_table::UpdateGlobalTableInput,
140) -> ::std::result::Result<::aws_smithy_types::body::SdkBody, ::aws_smithy_types::error::operation::SerializationError> {
141    let mut out = String::new();
142    let mut object = ::aws_smithy_json::serialize::JsonObjectWriter::new(&mut out);
143    crate::protocol_serde::shape_update_global_table_input::ser_update_global_table_input_input(&mut object, input)?;
144    object.finish();
145    Ok(::aws_smithy_types::body::SdkBody::from(out))
146}
147
148pub(crate) fn de_update_global_table(
149    value: &[u8],
150    mut builder: crate::operation::update_global_table::builders::UpdateGlobalTableOutputBuilder,
151) -> ::std::result::Result<
152    crate::operation::update_global_table::builders::UpdateGlobalTableOutputBuilder,
153    ::aws_smithy_json::deserialize::error::DeserializeError,
154> {
155    let mut tokens_owned = ::aws_smithy_json::deserialize::json_token_iter(crate::protocol_serde::or_empty_doc(value)).peekable();
156    let tokens = &mut tokens_owned;
157    ::aws_smithy_json::deserialize::token::expect_start_object(tokens.next())?;
158    loop {
159        match tokens.next().transpose()? {
160            Some(::aws_smithy_json::deserialize::Token::EndObject { .. }) => break,
161            Some(::aws_smithy_json::deserialize::Token::ObjectKey { key, .. }) => match key.to_unescaped()?.as_ref() {
162                "GlobalTableDescription" => {
163                    builder = builder.set_global_table_description(
164                        crate::protocol_serde::shape_global_table_description::de_global_table_description(tokens)?,
165                    );
166                }
167                _ => ::aws_smithy_json::deserialize::token::skip_value(tokens)?,
168            },
169            other => {
170                return Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(format!(
171                    "expected object key or end object, found: {:?}",
172                    other
173                )))
174            }
175        }
176    }
177    if tokens.next().is_some() {
178        return Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(
179            "found more JSON tokens after completing parsing",
180        ));
181    }
182    Ok(builder)
183}