aws_sdk_dynamodb/protocol_serde/
shape_create_global_table.rs1#[allow(clippy::unnecessary_wraps)]
3pub fn de_create_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::create_global_table::CreateGlobalTableOutput, crate::operation::create_global_table::CreateGlobalTableError>
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::create_global_table::CreateGlobalTableError::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::create_global_table::CreateGlobalTableError::unhandled(generic)),
17 };
18
19 let _error_message = generic.message().map(|msg| msg.to_owned());
20 Err(match error_code {
21 "GlobalTableAlreadyExistsException" => crate::operation::create_global_table::CreateGlobalTableError::GlobalTableAlreadyExistsException({
22 #[allow(unused_mut)]
23 let mut tmp = {
24 #[allow(unused_mut)]
25 let mut output = crate::types::error::builders::GlobalTableAlreadyExistsExceptionBuilder::default();
26 output = crate::protocol_serde::shape_global_table_already_exists_exception::de_global_table_already_exists_exception_json_err(
27 _response_body,
28 output,
29 )
30 .map_err(crate::operation::create_global_table::CreateGlobalTableError::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::create_global_table::CreateGlobalTableError::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::create_global_table::CreateGlobalTableError::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::create_global_table::CreateGlobalTableError::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::create_global_table::CreateGlobalTableError::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 "LimitExceededException" => crate::operation::create_global_table::CreateGlobalTableError::LimitExceededException({
70 #[allow(unused_mut)]
71 let mut tmp = {
72 #[allow(unused_mut)]
73 let mut output = crate::types::error::builders::LimitExceededExceptionBuilder::default();
74 output = crate::protocol_serde::shape_limit_exceeded_exception::de_limit_exceeded_exception_json_err(_response_body, output)
75 .map_err(crate::operation::create_global_table::CreateGlobalTableError::unhandled)?;
76 let output = output.meta(generic);
77 output.build()
78 };
79 if tmp.message.is_none() {
80 tmp.message = _error_message;
81 }
82 tmp
83 }),
84 "TableNotFoundException" => crate::operation::create_global_table::CreateGlobalTableError::TableNotFoundException({
85 #[allow(unused_mut)]
86 let mut tmp = {
87 #[allow(unused_mut)]
88 let mut output = crate::types::error::builders::TableNotFoundExceptionBuilder::default();
89 output = crate::protocol_serde::shape_table_not_found_exception::de_table_not_found_exception_json_err(_response_body, output)
90 .map_err(crate::operation::create_global_table::CreateGlobalTableError::unhandled)?;
91 let output = output.meta(generic);
92 output.build()
93 };
94 if tmp.message.is_none() {
95 tmp.message = _error_message;
96 }
97 tmp
98 }),
99 _ => crate::operation::create_global_table::CreateGlobalTableError::generic(generic),
100 })
101}
102
103#[allow(clippy::unnecessary_wraps)]
104pub fn de_create_global_table_http_response(
105 _response_status: u16,
106 _response_headers: &::aws_smithy_runtime_api::http::Headers,
107 _response_body: &[u8],
108) -> std::result::Result<crate::operation::create_global_table::CreateGlobalTableOutput, crate::operation::create_global_table::CreateGlobalTableError>
109{
110 Ok({
111 #[allow(unused_mut)]
112 let mut output = crate::operation::create_global_table::builders::CreateGlobalTableOutputBuilder::default();
113 output = crate::protocol_serde::shape_create_global_table::de_create_global_table(_response_body, output)
114 .map_err(crate::operation::create_global_table::CreateGlobalTableError::unhandled)?;
115 output._set_request_id(::aws_types::request_id::RequestId::request_id(_response_headers).map(str::to_string));
116 output.build()
117 })
118}
119
120pub fn ser_create_global_table_input(
121 input: &crate::operation::create_global_table::CreateGlobalTableInput,
122) -> ::std::result::Result<::aws_smithy_types::body::SdkBody, ::aws_smithy_types::error::operation::SerializationError> {
123 let mut out = String::new();
124 let mut object = ::aws_smithy_json::serialize::JsonObjectWriter::new(&mut out);
125 crate::protocol_serde::shape_create_global_table_input::ser_create_global_table_input_input(&mut object, input)?;
126 object.finish();
127 Ok(::aws_smithy_types::body::SdkBody::from(out))
128}
129
130pub(crate) fn de_create_global_table(
131 value: &[u8],
132 mut builder: crate::operation::create_global_table::builders::CreateGlobalTableOutputBuilder,
133) -> ::std::result::Result<
134 crate::operation::create_global_table::builders::CreateGlobalTableOutputBuilder,
135 ::aws_smithy_json::deserialize::error::DeserializeError,
136> {
137 let mut tokens_owned = ::aws_smithy_json::deserialize::json_token_iter(crate::protocol_serde::or_empty_doc(value)).peekable();
138 let tokens = &mut tokens_owned;
139 ::aws_smithy_json::deserialize::token::expect_start_object(tokens.next())?;
140 loop {
141 match tokens.next().transpose()? {
142 Some(::aws_smithy_json::deserialize::Token::EndObject { .. }) => break,
143 Some(::aws_smithy_json::deserialize::Token::ObjectKey { key, .. }) => match key.to_unescaped()?.as_ref() {
144 "GlobalTableDescription" => {
145 builder = builder.set_global_table_description(
146 crate::protocol_serde::shape_global_table_description::de_global_table_description(tokens)?,
147 );
148 }
149 _ => ::aws_smithy_json::deserialize::token::skip_value(tokens)?,
150 },
151 other => {
152 return Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(format!(
153 "expected object key or end object, found: {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}