1 - | // Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
|
2 - | #[allow(clippy::unnecessary_wraps)]
|
3 - | pub fn de_encrypt_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::encrypt::EncryptOutput, crate::operation::encrypt::EncryptError> {
|
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::encrypt::EncryptError::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::encrypt::EncryptError::unhandled(generic)),
|
16 - | };
|
17 - |
|
18 - | let _error_message = generic.message().map(|msg| msg.to_owned());
|
19 - | Err(match error_code {
|
20 - | "DependencyTimeoutException" => crate::operation::encrypt::EncryptError::DependencyTimeoutException({
|
21 - | #[allow(unused_mut)]
|
22 - | let mut tmp = {
|
23 - | #[allow(unused_mut)]
|
24 - | let mut output = crate::types::error::builders::DependencyTimeoutExceptionBuilder::default();
|
25 - | output = crate::protocol_serde::shape_dependency_timeout_exception::de_dependency_timeout_exception_json_err(_response_body, output)
|
26 - | .map_err(crate::operation::encrypt::EncryptError::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 - | "DisabledException" => crate::operation::encrypt::EncryptError::DisabledException({
|
36 - | #[allow(unused_mut)]
|
37 - | let mut tmp = {
|
38 - | #[allow(unused_mut)]
|
39 - | let mut output = crate::types::error::builders::DisabledExceptionBuilder::default();
|
40 - | output = crate::protocol_serde::shape_disabled_exception::de_disabled_exception_json_err(_response_body, output)
|
41 - | .map_err(crate::operation::encrypt::EncryptError::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 - | "DryRunOperationException" => crate::operation::encrypt::EncryptError::DryRunOperationException({
|
51 - | #[allow(unused_mut)]
|
52 - | let mut tmp = {
|
53 - | #[allow(unused_mut)]
|
54 - | let mut output = crate::types::error::builders::DryRunOperationExceptionBuilder::default();
|
55 - | output = crate::protocol_serde::shape_dry_run_operation_exception::de_dry_run_operation_exception_json_err(_response_body, output)
|
56 - | .map_err(crate::operation::encrypt::EncryptError::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 - | "InvalidGrantTokenException" => crate::operation::encrypt::EncryptError::InvalidGrantTokenException({
|
66 - | #[allow(unused_mut)]
|
67 - | let mut tmp = {
|
68 - | #[allow(unused_mut)]
|
69 - | let mut output = crate::types::error::builders::InvalidGrantTokenExceptionBuilder::default();
|
70 - | output =
|
71 - | crate::protocol_serde::shape_invalid_grant_token_exception::de_invalid_grant_token_exception_json_err(_response_body, output)
|
72 - | .map_err(crate::operation::encrypt::EncryptError::unhandled)?;
|
73 - | let output = output.meta(generic);
|
74 - | output.build()
|
75 - | };
|
76 - | if tmp.message.is_none() {
|
77 - | tmp.message = _error_message;
|
78 - | }
|
79 - | tmp
|
80 - | }),
|
81 - | "InvalidKeyUsageException" => crate::operation::encrypt::EncryptError::InvalidKeyUsageException({
|
82 - | #[allow(unused_mut)]
|
83 - | let mut tmp = {
|
84 - | #[allow(unused_mut)]
|
85 - | let mut output = crate::types::error::builders::InvalidKeyUsageExceptionBuilder::default();
|
86 - | output = crate::protocol_serde::shape_invalid_key_usage_exception::de_invalid_key_usage_exception_json_err(_response_body, output)
|
87 - | .map_err(crate::operation::encrypt::EncryptError::unhandled)?;
|
88 - | let output = output.meta(generic);
|
89 - | output.build()
|
90 - | };
|
91 - | if tmp.message.is_none() {
|
92 - | tmp.message = _error_message;
|
93 - | }
|
94 - | tmp
|
95 - | }),
|
96 - | "KeyUnavailableException" => crate::operation::encrypt::EncryptError::KeyUnavailableException({
|
97 - | #[allow(unused_mut)]
|
98 - | let mut tmp = {
|
99 - | #[allow(unused_mut)]
|
100 - | let mut output = crate::types::error::builders::KeyUnavailableExceptionBuilder::default();
|
101 - | output = crate::protocol_serde::shape_key_unavailable_exception::de_key_unavailable_exception_json_err(_response_body, output)
|
102 - | .map_err(crate::operation::encrypt::EncryptError::unhandled)?;
|
103 - | let output = output.meta(generic);
|
104 - | output.build()
|
105 - | };
|
106 - | if tmp.message.is_none() {
|
107 - | tmp.message = _error_message;
|
108 - | }
|
109 - | tmp
|
110 - | }),
|
111 - | "KMSInternalException" => crate::operation::encrypt::EncryptError::KmsInternalException({
|
112 - | #[allow(unused_mut)]
|
113 - | let mut tmp = {
|
114 - | #[allow(unused_mut)]
|
115 - | let mut output = crate::types::error::builders::KmsInternalExceptionBuilder::default();
|
116 - | output = crate::protocol_serde::shape_kms_internal_exception::de_kms_internal_exception_json_err(_response_body, output)
|
117 - | .map_err(crate::operation::encrypt::EncryptError::unhandled)?;
|
118 - | let output = output.meta(generic);
|
119 - | output.build()
|
120 - | };
|
121 - | if tmp.message.is_none() {
|
122 - | tmp.message = _error_message;
|
123 - | }
|
124 - | tmp
|
125 - | }),
|
126 - | "KMSInvalidStateException" => crate::operation::encrypt::EncryptError::KmsInvalidStateException({
|
127 - | #[allow(unused_mut)]
|
128 - | let mut tmp = {
|
129 - | #[allow(unused_mut)]
|
130 - | let mut output = crate::types::error::builders::KmsInvalidStateExceptionBuilder::default();
|
131 - | output = crate::protocol_serde::shape_kms_invalid_state_exception::de_kms_invalid_state_exception_json_err(_response_body, output)
|
132 - | .map_err(crate::operation::encrypt::EncryptError::unhandled)?;
|
133 - | let output = output.meta(generic);
|
134 - | output.build()
|
135 - | };
|
136 - | if tmp.message.is_none() {
|
137 - | tmp.message = _error_message;
|
138 - | }
|
139 - | tmp
|
140 - | }),
|
141 - | "NotFoundException" => crate::operation::encrypt::EncryptError::NotFoundException({
|
142 - | #[allow(unused_mut)]
|
143 - | let mut tmp = {
|
144 - | #[allow(unused_mut)]
|
145 - | let mut output = crate::types::error::builders::NotFoundExceptionBuilder::default();
|
146 - | output = crate::protocol_serde::shape_not_found_exception::de_not_found_exception_json_err(_response_body, output)
|
147 - | .map_err(crate::operation::encrypt::EncryptError::unhandled)?;
|
148 - | let output = output.meta(generic);
|
149 - | output.build()
|
150 - | };
|
151 - | if tmp.message.is_none() {
|
152 - | tmp.message = _error_message;
|
153 - | }
|
154 - | tmp
|
155 - | }),
|
156 - | _ => crate::operation::encrypt::EncryptError::generic(generic),
|
157 - | })
|
158 - | }
|
159 - |
|
160 - | #[allow(clippy::unnecessary_wraps)]
|
161 - | pub fn de_encrypt_http_response(
|
162 - | _response_status: u16,
|
163 - | _response_headers: &::aws_smithy_runtime_api::http::Headers,
|
164 - | _response_body: &[u8],
|
165 - | ) -> std::result::Result<crate::operation::encrypt::EncryptOutput, crate::operation::encrypt::EncryptError> {
|
166 - | Ok({
|
167 - | #[allow(unused_mut)]
|
168 - | let mut output = crate::operation::encrypt::builders::EncryptOutputBuilder::default();
|
169 - | output =
|
170 - | crate::protocol_serde::shape_encrypt::de_encrypt(_response_body, output).map_err(crate::operation::encrypt::EncryptError::unhandled)?;
|
171 - | output._set_request_id(::aws_types::request_id::RequestId::request_id(_response_headers).map(str::to_string));
|
172 - | output.build()
|
173 - | })
|
174 - | }
|
175 - |
|
176 - | pub fn ser_encrypt_input(
|
177 - | input: &crate::operation::encrypt::EncryptInput,
|
178 - | ) -> ::std::result::Result<::aws_smithy_types::body::SdkBody, ::aws_smithy_types::error::operation::SerializationError> {
|
179 - | let mut out = String::new();
|
180 - | let mut object = ::aws_smithy_json::serialize::JsonObjectWriter::new(&mut out);
|
181 - | crate::protocol_serde::shape_encrypt_input::ser_encrypt_input_input(&mut object, input)?;
|
182 - | object.finish();
|
183 - | Ok(::aws_smithy_types::body::SdkBody::from(out))
|
184 - | }
|
185 - |
|
186 - | pub(crate) fn de_encrypt(
|
187 - | _value: &[u8],
|
188 - | mut builder: crate::operation::encrypt::builders::EncryptOutputBuilder,
|
189 - | ) -> ::std::result::Result<crate::operation::encrypt::builders::EncryptOutputBuilder, ::aws_smithy_json::deserialize::error::DeserializeError> {
|
190 - | let mut tokens_owned = ::aws_smithy_json::deserialize::json_token_iter(crate::protocol_serde::or_empty_doc(_value)).peekable();
|
191 - | let tokens = &mut tokens_owned;
|
192 - | ::aws_smithy_json::deserialize::token::expect_start_object(tokens.next())?;
|
193 - | loop {
|
194 - | match tokens.next().transpose()? {
|
195 - | Some(::aws_smithy_json::deserialize::Token::EndObject { .. }) => break,
|
196 - | Some(::aws_smithy_json::deserialize::Token::ObjectKey { key, .. }) => match key.to_unescaped()?.as_ref() {
|
197 - | "CiphertextBlob" => {
|
198 - | builder = builder.set_ciphertext_blob(::aws_smithy_json::deserialize::token::expect_blob_or_null(tokens.next())?);
|
199 - | }
|
200 - | "KeyId" => {
|
201 - | builder = builder.set_key_id(
|
202 - | ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
|
203 - | .map(|s| s.to_unescaped().map(|u| u.into_owned()))
|
204 - | .transpose()?,
|
205 - | );
|
206 - | }
|
207 - | "EncryptionAlgorithm" => {
|
208 - | builder = builder.set_encryption_algorithm(
|
209 - | ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
|
210 - | .map(|s| s.to_unescaped().map(|u| crate::types::EncryptionAlgorithmSpec::from(u.as_ref())))
|
211 - | .transpose()?,
|
212 - | );
|
213 - | }
|
214 - | _ => ::aws_smithy_json::deserialize::token::skip_value(tokens)?,
|
215 - | },
|
216 - | other => {
|
217 - | return Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(format!(
|
218 - | "expected object key or end object, found: {other:?}"
|
219 - | )))
|
220 - | }
|
221 - | }
|
222 - | }
|
223 - | if tokens.next().is_some() {
|
224 - | return Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(
|
225 - | "found more JSON tokens after completing parsing",
|
226 - | ));
|
227 - | }
|
228 - | Ok(builder)
|
229 - | }
|