aws_sdk_networkmanager/protocol_serde/
shape_reject_attachment.rs1#[allow(clippy::unnecessary_wraps)]
3pub fn de_reject_attachment_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::reject_attachment::RejectAttachmentOutput, crate::operation::reject_attachment::RejectAttachmentError> {
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::reject_attachment::RejectAttachmentError::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::reject_attachment::RejectAttachmentError::unhandled(generic)),
16 };
17
18 let _error_message = generic.message().map(|msg| msg.to_owned());
19 Err(match error_code {
20 "AccessDeniedException" => crate::operation::reject_attachment::RejectAttachmentError::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::reject_attachment::RejectAttachmentError::unhandled)?;
27 let output = output.meta(generic);
28 crate::serde_util::access_denied_exception_correct_errors(output)
29 .build()
30 .map_err(crate::operation::reject_attachment::RejectAttachmentError::unhandled)?
31 };
32 tmp
33 }),
34 "ConflictException" => crate::operation::reject_attachment::RejectAttachmentError::ConflictException({
35 #[allow(unused_mut)]
36 let mut tmp = {
37 #[allow(unused_mut)]
38 let mut output = crate::types::error::builders::ConflictExceptionBuilder::default();
39 output = crate::protocol_serde::shape_conflict_exception::de_conflict_exception_json_err(_response_body, output)
40 .map_err(crate::operation::reject_attachment::RejectAttachmentError::unhandled)?;
41 let output = output.meta(generic);
42 crate::serde_util::conflict_exception_correct_errors(output)
43 .build()
44 .map_err(crate::operation::reject_attachment::RejectAttachmentError::unhandled)?
45 };
46 tmp
47 }),
48 "InternalServerException" => crate::operation::reject_attachment::RejectAttachmentError::InternalServerException({
49 #[allow(unused_mut)]
50 let mut tmp = {
51 #[allow(unused_mut)]
52 let mut output = crate::types::error::builders::InternalServerExceptionBuilder::default();
53 output = crate::protocol_serde::shape_internal_server_exception::de_internal_server_exception_json_err(_response_body, output)
54 .map_err(crate::operation::reject_attachment::RejectAttachmentError::unhandled)?;
55 output = output.set_retry_after_seconds(
56 crate::protocol_serde::shape_internal_server_exception::de_retry_after_seconds_header(_response_headers).map_err(|_| {
57 crate::operation::reject_attachment::RejectAttachmentError::unhandled(
58 "Failed to parse RetryAfterSeconds from header `Retry-After",
59 )
60 })?,
61 );
62 let output = output.meta(generic);
63 crate::serde_util::internal_server_exception_correct_errors(output)
64 .build()
65 .map_err(crate::operation::reject_attachment::RejectAttachmentError::unhandled)?
66 };
67 tmp
68 }),
69 "ResourceNotFoundException" => crate::operation::reject_attachment::RejectAttachmentError::ResourceNotFoundException({
70 #[allow(unused_mut)]
71 let mut tmp = {
72 #[allow(unused_mut)]
73 let mut output = crate::types::error::builders::ResourceNotFoundExceptionBuilder::default();
74 output = crate::protocol_serde::shape_resource_not_found_exception::de_resource_not_found_exception_json_err(_response_body, output)
75 .map_err(crate::operation::reject_attachment::RejectAttachmentError::unhandled)?;
76 let output = output.meta(generic);
77 crate::serde_util::resource_not_found_exception_correct_errors(output)
78 .build()
79 .map_err(crate::operation::reject_attachment::RejectAttachmentError::unhandled)?
80 };
81 tmp
82 }),
83 "ThrottlingException" => crate::operation::reject_attachment::RejectAttachmentError::ThrottlingException({
84 #[allow(unused_mut)]
85 let mut tmp = {
86 #[allow(unused_mut)]
87 let mut output = crate::types::error::builders::ThrottlingExceptionBuilder::default();
88 output = crate::protocol_serde::shape_throttling_exception::de_throttling_exception_json_err(_response_body, output)
89 .map_err(crate::operation::reject_attachment::RejectAttachmentError::unhandled)?;
90 output = output.set_retry_after_seconds(
91 crate::protocol_serde::shape_throttling_exception::de_retry_after_seconds_header(_response_headers).map_err(|_| {
92 crate::operation::reject_attachment::RejectAttachmentError::unhandled(
93 "Failed to parse RetryAfterSeconds from header `Retry-After",
94 )
95 })?,
96 );
97 let output = output.meta(generic);
98 crate::serde_util::throttling_exception_correct_errors(output)
99 .build()
100 .map_err(crate::operation::reject_attachment::RejectAttachmentError::unhandled)?
101 };
102 tmp
103 }),
104 "ValidationException" => crate::operation::reject_attachment::RejectAttachmentError::ValidationException({
105 #[allow(unused_mut)]
106 let mut tmp = {
107 #[allow(unused_mut)]
108 let mut output = crate::types::error::builders::ValidationExceptionBuilder::default();
109 output = crate::protocol_serde::shape_validation_exception::de_validation_exception_json_err(_response_body, output)
110 .map_err(crate::operation::reject_attachment::RejectAttachmentError::unhandled)?;
111 let output = output.meta(generic);
112 crate::serde_util::validation_exception_correct_errors(output)
113 .build()
114 .map_err(crate::operation::reject_attachment::RejectAttachmentError::unhandled)?
115 };
116 tmp
117 }),
118 _ => crate::operation::reject_attachment::RejectAttachmentError::generic(generic),
119 })
120}
121
122#[allow(clippy::unnecessary_wraps)]
123pub fn de_reject_attachment_http_response(
124 _response_status: u16,
125 _response_headers: &::aws_smithy_runtime_api::http::Headers,
126 _response_body: &[u8],
127) -> std::result::Result<crate::operation::reject_attachment::RejectAttachmentOutput, crate::operation::reject_attachment::RejectAttachmentError> {
128 Ok({
129 #[allow(unused_mut)]
130 let mut output = crate::operation::reject_attachment::builders::RejectAttachmentOutputBuilder::default();
131 output = crate::protocol_serde::shape_reject_attachment::de_reject_attachment(_response_body, output)
132 .map_err(crate::operation::reject_attachment::RejectAttachmentError::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(crate) fn de_reject_attachment(
139 value: &[u8],
140 mut builder: crate::operation::reject_attachment::builders::RejectAttachmentOutputBuilder,
141) -> ::std::result::Result<
142 crate::operation::reject_attachment::builders::RejectAttachmentOutputBuilder,
143 ::aws_smithy_json::deserialize::error::DeserializeError,
144> {
145 let mut tokens_owned = ::aws_smithy_json::deserialize::json_token_iter(crate::protocol_serde::or_empty_doc(value)).peekable();
146 let tokens = &mut tokens_owned;
147 ::aws_smithy_json::deserialize::token::expect_start_object(tokens.next())?;
148 loop {
149 match tokens.next().transpose()? {
150 Some(::aws_smithy_json::deserialize::Token::EndObject { .. }) => break,
151 Some(::aws_smithy_json::deserialize::Token::ObjectKey { key, .. }) => match key.to_unescaped()?.as_ref() {
152 "Attachment" => {
153 builder = builder.set_attachment(crate::protocol_serde::shape_attachment::de_attachment(tokens)?);
154 }
155 _ => ::aws_smithy_json::deserialize::token::skip_value(tokens)?,
156 },
157 other => {
158 return Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(format!(
159 "expected object key or end object, found: {other:?}"
160 )))
161 }
162 }
163 }
164 if tokens.next().is_some() {
165 return Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(
166 "found more JSON tokens after completing parsing",
167 ));
168 }
169 Ok(builder)
170}