1 - | // Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
|
2 - | #[allow(clippy::unnecessary_wraps)]
|
3 - | pub fn de_create_key_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_key::CreateKeyOutput, crate::operation::create_key::CreateKeyError> {
|
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::create_key::CreateKeyError::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::create_key::CreateKeyError::unhandled(generic)),
|
16 - | };
|
17 - |
|
18 - | let _error_message = generic.message().map(|msg| msg.to_owned());
|
19 - | Err(match error_code {
|
20 - | "CloudHsmClusterInvalidConfigurationException" => {
|
21 - | crate::operation::create_key::CreateKeyError::CloudHsmClusterInvalidConfigurationException({
|
22 - | #[allow(unused_mut)]
|
23 - | let mut tmp = {
|
24 - | #[allow(unused_mut)]
|
25 - | let mut output = crate::types::error::builders::CloudHsmClusterInvalidConfigurationExceptionBuilder::default();
|
26 - | output = crate::protocol_serde::shape_cloud_hsm_cluster_invalid_configuration_exception::de_cloud_hsm_cluster_invalid_configuration_exception_json_err(_response_body, output).map_err(crate::operation::create_key::CreateKeyError::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 - | }
|
36 - | "CustomKeyStoreInvalidStateException" => crate::operation::create_key::CreateKeyError::CustomKeyStoreInvalidStateException({
|
37 - | #[allow(unused_mut)]
|
38 - | let mut tmp = {
|
39 - | #[allow(unused_mut)]
|
40 - | let mut output = crate::types::error::builders::CustomKeyStoreInvalidStateExceptionBuilder::default();
|
41 - | output = crate::protocol_serde::shape_custom_key_store_invalid_state_exception::de_custom_key_store_invalid_state_exception_json_err(
|
42 - | _response_body,
|
43 - | output,
|
44 - | )
|
45 - | .map_err(crate::operation::create_key::CreateKeyError::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 - | "CustomKeyStoreNotFoundException" => crate::operation::create_key::CreateKeyError::CustomKeyStoreNotFoundException({
|
55 - | #[allow(unused_mut)]
|
56 - | let mut tmp = {
|
57 - | #[allow(unused_mut)]
|
58 - | let mut output = crate::types::error::builders::CustomKeyStoreNotFoundExceptionBuilder::default();
|
59 - | output = crate::protocol_serde::shape_custom_key_store_not_found_exception::de_custom_key_store_not_found_exception_json_err(
|
60 - | _response_body,
|
61 - | output,
|
62 - | )
|
63 - | .map_err(crate::operation::create_key::CreateKeyError::unhandled)?;
|
64 - | let output = output.meta(generic);
|
65 - | output.build()
|
66 - | };
|
67 - | if tmp.message.is_none() {
|
68 - | tmp.message = _error_message;
|
69 - | }
|
70 - | tmp
|
71 - | }),
|
72 - | "DependencyTimeoutException" => crate::operation::create_key::CreateKeyError::DependencyTimeoutException({
|
73 - | #[allow(unused_mut)]
|
74 - | let mut tmp = {
|
75 - | #[allow(unused_mut)]
|
76 - | let mut output = crate::types::error::builders::DependencyTimeoutExceptionBuilder::default();
|
77 - | output = crate::protocol_serde::shape_dependency_timeout_exception::de_dependency_timeout_exception_json_err(_response_body, output)
|
78 - | .map_err(crate::operation::create_key::CreateKeyError::unhandled)?;
|
79 - | let output = output.meta(generic);
|
80 - | output.build()
|
81 - | };
|
82 - | if tmp.message.is_none() {
|
83 - | tmp.message = _error_message;
|
84 - | }
|
85 - | tmp
|
86 - | }),
|
87 - | "InvalidArnException" => crate::operation::create_key::CreateKeyError::InvalidArnException({
|
88 - | #[allow(unused_mut)]
|
89 - | let mut tmp = {
|
90 - | #[allow(unused_mut)]
|
91 - | let mut output = crate::types::error::builders::InvalidArnExceptionBuilder::default();
|
92 - | output = crate::protocol_serde::shape_invalid_arn_exception::de_invalid_arn_exception_json_err(_response_body, output)
|
93 - | .map_err(crate::operation::create_key::CreateKeyError::unhandled)?;
|
94 - | let output = output.meta(generic);
|
95 - | output.build()
|
96 - | };
|
97 - | if tmp.message.is_none() {
|
98 - | tmp.message = _error_message;
|
99 - | }
|
100 - | tmp
|
101 - | }),
|
102 - | "KMSInternalException" => crate::operation::create_key::CreateKeyError::KmsInternalException({
|
103 - | #[allow(unused_mut)]
|
104 - | let mut tmp = {
|
105 - | #[allow(unused_mut)]
|
106 - | let mut output = crate::types::error::builders::KmsInternalExceptionBuilder::default();
|
107 - | output = crate::protocol_serde::shape_kms_internal_exception::de_kms_internal_exception_json_err(_response_body, output)
|
108 - | .map_err(crate::operation::create_key::CreateKeyError::unhandled)?;
|
109 - | let output = output.meta(generic);
|
110 - | output.build()
|
111 - | };
|
112 - | if tmp.message.is_none() {
|
113 - | tmp.message = _error_message;
|
114 - | }
|
115 - | tmp
|
116 - | }),
|
117 - | "LimitExceededException" => crate::operation::create_key::CreateKeyError::LimitExceededException({
|
118 - | #[allow(unused_mut)]
|
119 - | let mut tmp = {
|
120 - | #[allow(unused_mut)]
|
121 - | let mut output = crate::types::error::builders::LimitExceededExceptionBuilder::default();
|
122 - | output = crate::protocol_serde::shape_limit_exceeded_exception::de_limit_exceeded_exception_json_err(_response_body, output)
|
123 - | .map_err(crate::operation::create_key::CreateKeyError::unhandled)?;
|
124 - | let output = output.meta(generic);
|
125 - | output.build()
|
126 - | };
|
127 - | if tmp.message.is_none() {
|
128 - | tmp.message = _error_message;
|
129 - | }
|
130 - | tmp
|
131 - | }),
|
132 - | "MalformedPolicyDocumentException" => crate::operation::create_key::CreateKeyError::MalformedPolicyDocumentException({
|
133 - | #[allow(unused_mut)]
|
134 - | let mut tmp = {
|
135 - | #[allow(unused_mut)]
|
136 - | let mut output = crate::types::error::builders::MalformedPolicyDocumentExceptionBuilder::default();
|
137 - | output = crate::protocol_serde::shape_malformed_policy_document_exception::de_malformed_policy_document_exception_json_err(
|
138 - | _response_body,
|
139 - | output,
|
140 - | )
|
141 - | .map_err(crate::operation::create_key::CreateKeyError::unhandled)?;
|
142 - | let output = output.meta(generic);
|
143 - | output.build()
|
144 - | };
|
145 - | if tmp.message.is_none() {
|
146 - | tmp.message = _error_message;
|
147 - | }
|
148 - | tmp
|
149 - | }),
|
150 - | "TagException" => crate::operation::create_key::CreateKeyError::TagException({
|
151 - | #[allow(unused_mut)]
|
152 - | let mut tmp = {
|
153 - | #[allow(unused_mut)]
|
154 - | let mut output = crate::types::error::builders::TagExceptionBuilder::default();
|
155 - | output = crate::protocol_serde::shape_tag_exception::de_tag_exception_json_err(_response_body, output)
|
156 - | .map_err(crate::operation::create_key::CreateKeyError::unhandled)?;
|
157 - | let output = output.meta(generic);
|
158 - | output.build()
|
159 - | };
|
160 - | if tmp.message.is_none() {
|
161 - | tmp.message = _error_message;
|
162 - | }
|
163 - | tmp
|
164 - | }),
|
165 - | "UnsupportedOperationException" => crate::operation::create_key::CreateKeyError::UnsupportedOperationException({
|
166 - | #[allow(unused_mut)]
|
167 - | let mut tmp = {
|
168 - | #[allow(unused_mut)]
|
169 - | let mut output = crate::types::error::builders::UnsupportedOperationExceptionBuilder::default();
|
170 - | output =
|
171 - | crate::protocol_serde::shape_unsupported_operation_exception::de_unsupported_operation_exception_json_err(_response_body, output)
|
172 - | .map_err(crate::operation::create_key::CreateKeyError::unhandled)?;
|
173 - | let output = output.meta(generic);
|
174 - | output.build()
|
175 - | };
|
176 - | if tmp.message.is_none() {
|
177 - | tmp.message = _error_message;
|
178 - | }
|
179 - | tmp
|
180 - | }),
|
181 - | "XksKeyAlreadyInUseException" => crate::operation::create_key::CreateKeyError::XksKeyAlreadyInUseException({
|
182 - | #[allow(unused_mut)]
|
183 - | let mut tmp = {
|
184 - | #[allow(unused_mut)]
|
185 - | let mut output = crate::types::error::builders::XksKeyAlreadyInUseExceptionBuilder::default();
|
186 - | output = crate::protocol_serde::shape_xks_key_already_in_use_exception::de_xks_key_already_in_use_exception_json_err(
|
187 - | _response_body,
|
188 - | output,
|
189 - | )
|
190 - | .map_err(crate::operation::create_key::CreateKeyError::unhandled)?;
|
191 - | let output = output.meta(generic);
|
192 - | output.build()
|
193 - | };
|
194 - | if tmp.message.is_none() {
|
195 - | tmp.message = _error_message;
|
196 - | }
|
197 - | tmp
|
198 - | }),
|
199 - | "XksKeyInvalidConfigurationException" => crate::operation::create_key::CreateKeyError::XksKeyInvalidConfigurationException({
|
200 - | #[allow(unused_mut)]
|
201 - | let mut tmp = {
|
202 - | #[allow(unused_mut)]
|
203 - | let mut output = crate::types::error::builders::XksKeyInvalidConfigurationExceptionBuilder::default();
|
204 - | output = crate::protocol_serde::shape_xks_key_invalid_configuration_exception::de_xks_key_invalid_configuration_exception_json_err(
|
205 - | _response_body,
|
206 - | output,
|
207 - | )
|
208 - | .map_err(crate::operation::create_key::CreateKeyError::unhandled)?;
|
209 - | let output = output.meta(generic);
|
210 - | output.build()
|
211 - | };
|
212 - | if tmp.message.is_none() {
|
213 - | tmp.message = _error_message;
|
214 - | }
|
215 - | tmp
|
216 - | }),
|
217 - | "XksKeyNotFoundException" => crate::operation::create_key::CreateKeyError::XksKeyNotFoundException({
|
218 - | #[allow(unused_mut)]
|
219 - | let mut tmp = {
|
220 - | #[allow(unused_mut)]
|
221 - | let mut output = crate::types::error::builders::XksKeyNotFoundExceptionBuilder::default();
|
222 - | output = crate::protocol_serde::shape_xks_key_not_found_exception::de_xks_key_not_found_exception_json_err(_response_body, output)
|
223 - | .map_err(crate::operation::create_key::CreateKeyError::unhandled)?;
|
224 - | let output = output.meta(generic);
|
225 - | output.build()
|
226 - | };
|
227 - | if tmp.message.is_none() {
|
228 - | tmp.message = _error_message;
|
229 - | }
|
230 - | tmp
|
231 - | }),
|
232 - | _ => crate::operation::create_key::CreateKeyError::generic(generic),
|
233 - | })
|
234 - | }
|
235 - |
|
236 - | #[allow(clippy::unnecessary_wraps)]
|
237 - | pub fn de_create_key_http_response(
|
238 - | _response_status: u16,
|
239 - | _response_headers: &::aws_smithy_runtime_api::http::Headers,
|
240 - | _response_body: &[u8],
|
241 - | ) -> std::result::Result<crate::operation::create_key::CreateKeyOutput, crate::operation::create_key::CreateKeyError> {
|
242 - | Ok({
|
243 - | #[allow(unused_mut)]
|
244 - | let mut output = crate::operation::create_key::builders::CreateKeyOutputBuilder::default();
|
245 - | output = crate::protocol_serde::shape_create_key::de_create_key(_response_body, output)
|
246 - | .map_err(crate::operation::create_key::CreateKeyError::unhandled)?;
|
247 - | output._set_request_id(::aws_types::request_id::RequestId::request_id(_response_headers).map(str::to_string));
|
248 - | output.build()
|
249 - | })
|
250 - | }
|
251 - |
|
252 - | pub fn ser_create_key_input(
|
253 - | input: &crate::operation::create_key::CreateKeyInput,
|
254 - | ) -> ::std::result::Result<::aws_smithy_types::body::SdkBody, ::aws_smithy_types::error::operation::SerializationError> {
|
255 - | let mut out = String::new();
|
256 - | let mut object = ::aws_smithy_json::serialize::JsonObjectWriter::new(&mut out);
|
257 - | crate::protocol_serde::shape_create_key_input::ser_create_key_input_input(&mut object, input)?;
|
258 - | object.finish();
|
259 - | Ok(::aws_smithy_types::body::SdkBody::from(out))
|
260 - | }
|
261 - |
|
262 - | pub(crate) fn de_create_key(
|
263 - | _value: &[u8],
|
264 - | mut builder: crate::operation::create_key::builders::CreateKeyOutputBuilder,
|
265 - | ) -> ::std::result::Result<crate::operation::create_key::builders::CreateKeyOutputBuilder, ::aws_smithy_json::deserialize::error::DeserializeError> {
|
266 - | let mut tokens_owned = ::aws_smithy_json::deserialize::json_token_iter(crate::protocol_serde::or_empty_doc(_value)).peekable();
|
267 - | let tokens = &mut tokens_owned;
|
268 - | ::aws_smithy_json::deserialize::token::expect_start_object(tokens.next())?;
|
269 - | loop {
|
270 - | match tokens.next().transpose()? {
|
271 - | Some(::aws_smithy_json::deserialize::Token::EndObject { .. }) => break,
|
272 - | Some(::aws_smithy_json::deserialize::Token::ObjectKey { key, .. }) => match key.to_unescaped()?.as_ref() {
|
273 - | "KeyMetadata" => {
|
274 - | builder = builder.set_key_metadata(crate::protocol_serde::shape_key_metadata::de_key_metadata(tokens, _value)?);
|
275 - | }
|
276 - | _ => ::aws_smithy_json::deserialize::token::skip_value(tokens)?,
|
277 - | },
|
278 - | other => {
|
279 - | return Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(format!(
|
280 - | "expected object key or end object, found: {other:?}"
|
281 - | )))
|
282 - | }
|
283 - | }
|
284 - | }
|
285 - | if tokens.next().is_some() {
|
286 - | return Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(
|
287 - | "found more JSON tokens after completing parsing",
|
288 - | ));
|
289 - | }
|
290 - | Ok(builder)
|
291 - | }
|