aws_sdk_kms/protocol_serde/
shape_list_retirable_grants.rs
1#[allow(clippy::unnecessary_wraps)]
3pub fn de_list_retirable_grants_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::list_retirable_grants::ListRetirableGrantsOutput,
9 crate::operation::list_retirable_grants::ListRetirableGrantsError,
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::list_retirable_grants::ListRetirableGrantsError::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::list_retirable_grants::ListRetirableGrantsError::unhandled(generic)),
19 };
20
21 let _error_message = generic.message().map(|msg| msg.to_owned());
22 Err(match error_code {
23 "DependencyTimeoutException" => crate::operation::list_retirable_grants::ListRetirableGrantsError::DependencyTimeoutException({
24 #[allow(unused_mut)]
25 let mut tmp = {
26 #[allow(unused_mut)]
27 let mut output = crate::types::error::builders::DependencyTimeoutExceptionBuilder::default();
28 output = crate::protocol_serde::shape_dependency_timeout_exception::de_dependency_timeout_exception_json_err(_response_body, output)
29 .map_err(crate::operation::list_retirable_grants::ListRetirableGrantsError::unhandled)?;
30 let output = output.meta(generic);
31 output.build()
32 };
33 if tmp.message.is_none() {
34 tmp.message = _error_message;
35 }
36 tmp
37 }),
38 "InvalidArnException" => crate::operation::list_retirable_grants::ListRetirableGrantsError::InvalidArnException({
39 #[allow(unused_mut)]
40 let mut tmp = {
41 #[allow(unused_mut)]
42 let mut output = crate::types::error::builders::InvalidArnExceptionBuilder::default();
43 output = crate::protocol_serde::shape_invalid_arn_exception::de_invalid_arn_exception_json_err(_response_body, output)
44 .map_err(crate::operation::list_retirable_grants::ListRetirableGrantsError::unhandled)?;
45 let output = output.meta(generic);
46 output.build()
47 };
48 if tmp.message.is_none() {
49 tmp.message = _error_message;
50 }
51 tmp
52 }),
53 "InvalidMarkerException" => crate::operation::list_retirable_grants::ListRetirableGrantsError::InvalidMarkerException({
54 #[allow(unused_mut)]
55 let mut tmp = {
56 #[allow(unused_mut)]
57 let mut output = crate::types::error::builders::InvalidMarkerExceptionBuilder::default();
58 output = crate::protocol_serde::shape_invalid_marker_exception::de_invalid_marker_exception_json_err(_response_body, output)
59 .map_err(crate::operation::list_retirable_grants::ListRetirableGrantsError::unhandled)?;
60 let output = output.meta(generic);
61 output.build()
62 };
63 if tmp.message.is_none() {
64 tmp.message = _error_message;
65 }
66 tmp
67 }),
68 "KMSInternalException" => crate::operation::list_retirable_grants::ListRetirableGrantsError::KmsInternalException({
69 #[allow(unused_mut)]
70 let mut tmp = {
71 #[allow(unused_mut)]
72 let mut output = crate::types::error::builders::KmsInternalExceptionBuilder::default();
73 output = crate::protocol_serde::shape_kms_internal_exception::de_kms_internal_exception_json_err(_response_body, output)
74 .map_err(crate::operation::list_retirable_grants::ListRetirableGrantsError::unhandled)?;
75 let output = output.meta(generic);
76 output.build()
77 };
78 if tmp.message.is_none() {
79 tmp.message = _error_message;
80 }
81 tmp
82 }),
83 "NotFoundException" => crate::operation::list_retirable_grants::ListRetirableGrantsError::NotFoundException({
84 #[allow(unused_mut)]
85 let mut tmp = {
86 #[allow(unused_mut)]
87 let mut output = crate::types::error::builders::NotFoundExceptionBuilder::default();
88 output = crate::protocol_serde::shape_not_found_exception::de_not_found_exception_json_err(_response_body, output)
89 .map_err(crate::operation::list_retirable_grants::ListRetirableGrantsError::unhandled)?;
90 let output = output.meta(generic);
91 output.build()
92 };
93 if tmp.message.is_none() {
94 tmp.message = _error_message;
95 }
96 tmp
97 }),
98 _ => crate::operation::list_retirable_grants::ListRetirableGrantsError::generic(generic),
99 })
100}
101
102#[allow(clippy::unnecessary_wraps)]
103pub fn de_list_retirable_grants_http_response(
104 _response_status: u16,
105 _response_headers: &::aws_smithy_runtime_api::http::Headers,
106 _response_body: &[u8],
107) -> std::result::Result<
108 crate::operation::list_retirable_grants::ListRetirableGrantsOutput,
109 crate::operation::list_retirable_grants::ListRetirableGrantsError,
110> {
111 Ok({
112 #[allow(unused_mut)]
113 let mut output = crate::operation::list_retirable_grants::builders::ListRetirableGrantsOutputBuilder::default();
114 output = crate::protocol_serde::shape_list_retirable_grants::de_list_retirable_grants(_response_body, output)
115 .map_err(crate::operation::list_retirable_grants::ListRetirableGrantsError::unhandled)?;
116 output._set_request_id(::aws_types::request_id::RequestId::request_id(_response_headers).map(str::to_string));
117 output.build()
118 })
119}
120
121pub fn ser_list_retirable_grants_input(
122 input: &crate::operation::list_retirable_grants::ListRetirableGrantsInput,
123) -> Result<::aws_smithy_types::body::SdkBody, ::aws_smithy_types::error::operation::SerializationError> {
124 let mut out = String::new();
125 let mut object = ::aws_smithy_json::serialize::JsonObjectWriter::new(&mut out);
126 crate::protocol_serde::shape_list_retirable_grants_input::ser_list_retirable_grants_input_input(&mut object, input)?;
127 object.finish();
128 Ok(::aws_smithy_types::body::SdkBody::from(out))
129}
130
131pub(crate) fn de_list_retirable_grants(
132 value: &[u8],
133 mut builder: crate::operation::list_retirable_grants::builders::ListRetirableGrantsOutputBuilder,
134) -> Result<
135 crate::operation::list_retirable_grants::builders::ListRetirableGrantsOutputBuilder,
136 ::aws_smithy_json::deserialize::error::DeserializeError,
137> {
138 let mut tokens_owned = ::aws_smithy_json::deserialize::json_token_iter(crate::protocol_serde::or_empty_doc(value)).peekable();
139 let tokens = &mut tokens_owned;
140 ::aws_smithy_json::deserialize::token::expect_start_object(tokens.next())?;
141 loop {
142 match tokens.next().transpose()? {
143 Some(::aws_smithy_json::deserialize::Token::EndObject { .. }) => break,
144 Some(::aws_smithy_json::deserialize::Token::ObjectKey { key, .. }) => match key.to_unescaped()?.as_ref() {
145 "Grants" => {
146 builder = builder.set_grants(crate::protocol_serde::shape_grant_list::de_grant_list(tokens)?);
147 }
148 "NextMarker" => {
149 builder = builder.set_next_marker(
150 ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
151 .map(|s| s.to_unescaped().map(|u| u.into_owned()))
152 .transpose()?,
153 );
154 }
155 "Truncated" => {
156 builder = builder.set_truncated(::aws_smithy_json::deserialize::token::expect_bool_or_null(tokens.next())?);
157 }
158 _ => ::aws_smithy_json::deserialize::token::skip_value(tokens)?,
159 },
160 other => {
161 return Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(format!(
162 "expected object key or end object, found: {:?}",
163 other
164 )))
165 }
166 }
167 }
168 if tokens.next().is_some() {
169 return Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(
170 "found more JSON tokens after completing parsing",
171 ));
172 }
173 Ok(builder)
174}