aws_sdk_customerprofiles/protocol_serde/
shape_batch_get_profile.rs1#[allow(clippy::unnecessary_wraps)]
3pub fn de_batch_get_profile_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::batch_get_profile::BatchGetProfileOutput, crate::operation::batch_get_profile::BatchGetProfileError> {
8 #[allow(unused_mut)]
9 let mut generic_builder = crate::protocol_serde::parse_http_error_metadata(_response_status, _response_headers, _response_body)
10 .map_err(crate::operation::batch_get_profile::BatchGetProfileError::unhandled)?;
11 generic_builder = ::aws_types::request_id::apply_request_id(generic_builder, _response_headers);
12 let generic = generic_builder.build();
13 let error_code = match generic.code() {
14 Some(code) => code,
15 None => return Err(crate::operation::batch_get_profile::BatchGetProfileError::unhandled(generic)),
16 };
17
18 let _error_message = generic.message().map(|msg| msg.to_owned());
19 Err(match error_code {
20 "AccessDeniedException" => crate::operation::batch_get_profile::BatchGetProfileError::AccessDeniedException({
21 #[allow(unused_mut)]
22 let mut tmp = {
23 #[allow(unused_mut)]
24 let mut output = crate::types::error::builders::AccessDeniedExceptionBuilder::default();
25 output = crate::protocol_serde::shape_access_denied_exception::de_access_denied_exception_json_err(_response_body, output)
26 .map_err(crate::operation::batch_get_profile::BatchGetProfileError::unhandled)?;
27 let output = output.meta(generic);
28 output.build()
29 };
30 if tmp.message.is_none() {
31 tmp.message = _error_message;
32 }
33 tmp
34 }),
35 "BadRequestException" => crate::operation::batch_get_profile::BatchGetProfileError::BadRequestException({
36 #[allow(unused_mut)]
37 let mut tmp = {
38 #[allow(unused_mut)]
39 let mut output = crate::types::error::builders::BadRequestExceptionBuilder::default();
40 output = crate::protocol_serde::shape_bad_request_exception::de_bad_request_exception_json_err(_response_body, output)
41 .map_err(crate::operation::batch_get_profile::BatchGetProfileError::unhandled)?;
42 let output = output.meta(generic);
43 output.build()
44 };
45 if tmp.message.is_none() {
46 tmp.message = _error_message;
47 }
48 tmp
49 }),
50 "InternalServerException" => crate::operation::batch_get_profile::BatchGetProfileError::InternalServerException({
51 #[allow(unused_mut)]
52 let mut tmp = {
53 #[allow(unused_mut)]
54 let mut output = crate::types::error::builders::InternalServerExceptionBuilder::default();
55 output = crate::protocol_serde::shape_internal_server_exception::de_internal_server_exception_json_err(_response_body, output)
56 .map_err(crate::operation::batch_get_profile::BatchGetProfileError::unhandled)?;
57 let output = output.meta(generic);
58 output.build()
59 };
60 if tmp.message.is_none() {
61 tmp.message = _error_message;
62 }
63 tmp
64 }),
65 "ResourceNotFoundException" => crate::operation::batch_get_profile::BatchGetProfileError::ResourceNotFoundException({
66 #[allow(unused_mut)]
67 let mut tmp = {
68 #[allow(unused_mut)]
69 let mut output = crate::types::error::builders::ResourceNotFoundExceptionBuilder::default();
70 output = crate::protocol_serde::shape_resource_not_found_exception::de_resource_not_found_exception_json_err(_response_body, output)
71 .map_err(crate::operation::batch_get_profile::BatchGetProfileError::unhandled)?;
72 let output = output.meta(generic);
73 output.build()
74 };
75 if tmp.message.is_none() {
76 tmp.message = _error_message;
77 }
78 tmp
79 }),
80 "ThrottlingException" => crate::operation::batch_get_profile::BatchGetProfileError::ThrottlingException({
81 #[allow(unused_mut)]
82 let mut tmp = {
83 #[allow(unused_mut)]
84 let mut output = crate::types::error::builders::ThrottlingExceptionBuilder::default();
85 output = crate::protocol_serde::shape_throttling_exception::de_throttling_exception_json_err(_response_body, output)
86 .map_err(crate::operation::batch_get_profile::BatchGetProfileError::unhandled)?;
87 let output = output.meta(generic);
88 output.build()
89 };
90 if tmp.message.is_none() {
91 tmp.message = _error_message;
92 }
93 tmp
94 }),
95 _ => crate::operation::batch_get_profile::BatchGetProfileError::generic(generic),
96 })
97}
98
99#[allow(clippy::unnecessary_wraps)]
100pub fn de_batch_get_profile_http_response(
101 _response_status: u16,
102 _response_headers: &::aws_smithy_runtime_api::http::Headers,
103 _response_body: &[u8],
104) -> std::result::Result<crate::operation::batch_get_profile::BatchGetProfileOutput, crate::operation::batch_get_profile::BatchGetProfileError> {
105 Ok({
106 #[allow(unused_mut)]
107 let mut output = crate::operation::batch_get_profile::builders::BatchGetProfileOutputBuilder::default();
108 output = crate::protocol_serde::shape_batch_get_profile::de_batch_get_profile(_response_body, output)
109 .map_err(crate::operation::batch_get_profile::BatchGetProfileError::unhandled)?;
110 output._set_request_id(::aws_types::request_id::RequestId::request_id(_response_headers).map(str::to_string));
111 output.build()
112 })
113}
114
115pub fn ser_batch_get_profile_input(
116 input: &crate::operation::batch_get_profile::BatchGetProfileInput,
117) -> ::std::result::Result<::aws_smithy_types::body::SdkBody, ::aws_smithy_types::error::operation::SerializationError> {
118 let mut out = String::new();
119 let mut object = ::aws_smithy_json::serialize::JsonObjectWriter::new(&mut out);
120 crate::protocol_serde::shape_batch_get_profile_input::ser_batch_get_profile_input_input(&mut object, input)?;
121 object.finish();
122 Ok(::aws_smithy_types::body::SdkBody::from(out))
123}
124
125pub(crate) fn de_batch_get_profile(
126 value: &[u8],
127 mut builder: crate::operation::batch_get_profile::builders::BatchGetProfileOutputBuilder,
128) -> ::std::result::Result<
129 crate::operation::batch_get_profile::builders::BatchGetProfileOutputBuilder,
130 ::aws_smithy_json::deserialize::error::DeserializeError,
131> {
132 let mut tokens_owned = ::aws_smithy_json::deserialize::json_token_iter(crate::protocol_serde::or_empty_doc(value)).peekable();
133 let tokens = &mut tokens_owned;
134 ::aws_smithy_json::deserialize::token::expect_start_object(tokens.next())?;
135 loop {
136 match tokens.next().transpose()? {
137 Some(::aws_smithy_json::deserialize::Token::EndObject { .. }) => break,
138 Some(::aws_smithy_json::deserialize::Token::ObjectKey { key, .. }) => match key.to_unescaped()?.as_ref() {
139 "Errors" => {
140 builder = builder.set_errors(crate::protocol_serde::shape_batch_get_profile_error_list::de_batch_get_profile_error_list(tokens)?);
141 }
142 "Profiles" => {
143 builder = builder.set_profiles(crate::protocol_serde::shape_profile_list::de_profile_list(tokens)?);
144 }
145 _ => ::aws_smithy_json::deserialize::token::skip_value(tokens)?,
146 },
147 other => {
148 return Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(format!(
149 "expected object key or end object, found: {:?}",
150 other
151 )))
152 }
153 }
154 }
155 if tokens.next().is_some() {
156 return Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(
157 "found more JSON tokens after completing parsing",
158 ));
159 }
160 Ok(builder)
161}