138 142 | ::std::borrow::Cow::Owned(rcb)
|
139 143 | }
|
140 144 | }
|
141 145 |
|
142 146 | #[derive(Debug)]
|
143 147 | struct PutKeyPolicyResponseDeserializer;
|
144 148 | impl ::aws_smithy_runtime_api::client::ser_de::DeserializeResponse for PutKeyPolicyResponseDeserializer {
|
145 149 | fn deserialize_nonstreaming(
|
146 150 | &self,
|
147 151 | response: &::aws_smithy_runtime_api::client::orchestrator::HttpResponse,
|
152 + | _cfg: &::aws_smithy_types::config_bag::ConfigBag,
|
148 153 | ) -> ::aws_smithy_runtime_api::client::interceptors::context::OutputOrError {
|
149 154 | let (success, status) = (response.status().is_success(), response.status().as_u16());
|
150 - | let headers = response.headers();
|
151 - | let body = response.body().bytes().expect("body loaded");
|
152 155 | #[allow(unused_mut)]
|
153 156 | let mut force_error = false;
|
154 157 | ::tracing::debug!(request_id = ?::aws_types::request_id::RequestId::request_id(response));
|
155 - | let parse_result = if !success && status != 200 || force_error {
|
156 - | crate::protocol_serde::shape_put_key_policy::de_put_key_policy_http_error(status, headers, body)
|
157 - | } else {
|
158 - | crate::protocol_serde::shape_put_key_policy::de_put_key_policy_http_response(status, headers, body)
|
158 + | if !success && status != 200 || force_error {
|
159 + | let headers = response.headers();
|
160 + | let body = response.body().bytes().expect("body loaded");
|
161 + | #[allow(unused_mut)]
|
162 + | let mut generic_builder = crate::protocol_serde::parse_http_error_metadata(status, headers, body).map_err(|e| {
|
163 + | ::aws_smithy_runtime_api::client::orchestrator::OrchestratorError::other(::aws_smithy_runtime_api::box_error::BoxError::from(e))
|
164 + | })?;
|
165 + | generic_builder = ::aws_types::request_id::apply_request_id(generic_builder, headers);
|
166 + | let generic = generic_builder.build();
|
167 + | let error_code = match generic.code() {
|
168 + | ::std::option::Option::Some(code) => code,
|
169 + | ::std::option::Option::None => {
|
170 + | return ::std::result::Result::Err(::aws_smithy_runtime_api::client::orchestrator::OrchestratorError::other(
|
171 + | ::aws_smithy_runtime_api::box_error::BoxError::from(crate::operation::put_key_policy::PutKeyPolicyError::unhandled(generic)),
|
172 + | ))
|
173 + | }
|
174 + | };
|
175 + | let _error_message = generic.message().map(|msg| msg.to_owned());
|
176 + | let protocol = _cfg
|
177 + | .load::<::aws_smithy_schema::protocol::SharedClientProtocol>()
|
178 + | .expect("a SharedClientProtocol is required");
|
179 + | let err = match error_code {
|
180 + | "DependencyTimeoutException" => crate::operation::put_key_policy::PutKeyPolicyError::DependencyTimeoutException({
|
181 + | let mut tmp = match protocol
|
182 + | .deserialize_response(response, crate::types::error::DependencyTimeoutException::SCHEMA, _cfg)
|
183 + | .and_then(|mut deser| {
|
184 + | crate::types::error::DependencyTimeoutException::deserialize_with_response(
|
185 + | &mut *deser,
|
186 + | response.headers(),
|
187 + | response.status().into(),
|
188 + | body,
|
189 + | )
|
190 + | }) {
|
191 + | ::std::result::Result::Ok(val) => val,
|
192 + | ::std::result::Result::Err(e) => {
|
193 + | return ::std::result::Result::Err(::aws_smithy_runtime_api::client::orchestrator::OrchestratorError::other(
|
194 + | ::aws_smithy_runtime_api::box_error::BoxError::from(e),
|
195 + | ))
|
196 + | }
|
197 + | };
|
198 + | tmp.meta = generic;
|
199 + | if tmp.message.is_none() {
|
200 + | tmp.message = _error_message;
|
201 + | }
|
202 + | tmp
|
203 + | }),
|
204 + | "InvalidArnException" => crate::operation::put_key_policy::PutKeyPolicyError::InvalidArnException({
|
205 + | let mut tmp = match protocol
|
206 + | .deserialize_response(response, crate::types::error::InvalidArnException::SCHEMA, _cfg)
|
207 + | .and_then(|mut deser| {
|
208 + | crate::types::error::InvalidArnException::deserialize_with_response(
|
209 + | &mut *deser,
|
210 + | response.headers(),
|
211 + | response.status().into(),
|
212 + | body,
|
213 + | )
|
214 + | }) {
|
215 + | ::std::result::Result::Ok(val) => val,
|
216 + | ::std::result::Result::Err(e) => {
|
217 + | return ::std::result::Result::Err(::aws_smithy_runtime_api::client::orchestrator::OrchestratorError::other(
|
218 + | ::aws_smithy_runtime_api::box_error::BoxError::from(e),
|
219 + | ))
|
220 + | }
|
221 + | };
|
222 + | tmp.meta = generic;
|
223 + | if tmp.message.is_none() {
|
224 + | tmp.message = _error_message;
|
225 + | }
|
226 + | tmp
|
227 + | }),
|
228 + | "KMSInternalException" => crate::operation::put_key_policy::PutKeyPolicyError::KmsInternalException({
|
229 + | let mut tmp = match protocol
|
230 + | .deserialize_response(response, crate::types::error::KmsInternalException::SCHEMA, _cfg)
|
231 + | .and_then(|mut deser| {
|
232 + | crate::types::error::KmsInternalException::deserialize_with_response(
|
233 + | &mut *deser,
|
234 + | response.headers(),
|
235 + | response.status().into(),
|
236 + | body,
|
237 + | )
|
238 + | }) {
|
239 + | ::std::result::Result::Ok(val) => val,
|
240 + | ::std::result::Result::Err(e) => {
|
241 + | return ::std::result::Result::Err(::aws_smithy_runtime_api::client::orchestrator::OrchestratorError::other(
|
242 + | ::aws_smithy_runtime_api::box_error::BoxError::from(e),
|
243 + | ))
|
244 + | }
|
159 245 | };
|
160 - | crate::protocol_serde::type_erase_result(parse_result)
|
246 + | tmp.meta = generic;
|
247 + | if tmp.message.is_none() {
|
248 + | tmp.message = _error_message;
|
249 + | }
|
250 + | tmp
|
251 + | }),
|
252 + | "KMSInvalidStateException" => crate::operation::put_key_policy::PutKeyPolicyError::KmsInvalidStateException({
|
253 + | let mut tmp = match protocol
|
254 + | .deserialize_response(response, crate::types::error::KmsInvalidStateException::SCHEMA, _cfg)
|
255 + | .and_then(|mut deser| {
|
256 + | crate::types::error::KmsInvalidStateException::deserialize_with_response(
|
257 + | &mut *deser,
|
258 + | response.headers(),
|
259 + | response.status().into(),
|
260 + | body,
|
261 + | )
|
262 + | }) {
|
263 + | ::std::result::Result::Ok(val) => val,
|
264 + | ::std::result::Result::Err(e) => {
|
265 + | return ::std::result::Result::Err(::aws_smithy_runtime_api::client::orchestrator::OrchestratorError::other(
|
266 + | ::aws_smithy_runtime_api::box_error::BoxError::from(e),
|
267 + | ))
|
268 + | }
|
269 + | };
|
270 + | tmp.meta = generic;
|
271 + | if tmp.message.is_none() {
|
272 + | tmp.message = _error_message;
|
273 + | }
|
274 + | tmp
|
275 + | }),
|
276 + | "LimitExceededException" => crate::operation::put_key_policy::PutKeyPolicyError::LimitExceededException({
|
277 + | let mut tmp = match protocol
|
278 + | .deserialize_response(response, crate::types::error::LimitExceededException::SCHEMA, _cfg)
|
279 + | .and_then(|mut deser| {
|
280 + | crate::types::error::LimitExceededException::deserialize_with_response(
|
281 + | &mut *deser,
|
282 + | response.headers(),
|
283 + | response.status().into(),
|
284 + | body,
|
285 + | )
|
286 + | }) {
|
287 + | ::std::result::Result::Ok(val) => val,
|
288 + | ::std::result::Result::Err(e) => {
|
289 + | return ::std::result::Result::Err(::aws_smithy_runtime_api::client::orchestrator::OrchestratorError::other(
|
290 + | ::aws_smithy_runtime_api::box_error::BoxError::from(e),
|
291 + | ))
|
292 + | }
|
293 + | };
|
294 + | tmp.meta = generic;
|
295 + | if tmp.message.is_none() {
|
296 + | tmp.message = _error_message;
|
297 + | }
|
298 + | tmp
|
299 + | }),
|
300 + | "MalformedPolicyDocumentException" => crate::operation::put_key_policy::PutKeyPolicyError::MalformedPolicyDocumentException({
|
301 + | let mut tmp = match protocol
|
302 + | .deserialize_response(response, crate::types::error::MalformedPolicyDocumentException::SCHEMA, _cfg)
|
303 + | .and_then(|mut deser| {
|
304 + | crate::types::error::MalformedPolicyDocumentException::deserialize_with_response(
|
305 + | &mut *deser,
|
306 + | response.headers(),
|
307 + | response.status().into(),
|
308 + | body,
|
309 + | )
|
310 + | }) {
|
311 + | ::std::result::Result::Ok(val) => val,
|
312 + | ::std::result::Result::Err(e) => {
|
313 + | return ::std::result::Result::Err(::aws_smithy_runtime_api::client::orchestrator::OrchestratorError::other(
|
314 + | ::aws_smithy_runtime_api::box_error::BoxError::from(e),
|
315 + | ))
|
316 + | }
|
317 + | };
|
318 + | tmp.meta = generic;
|
319 + | if tmp.message.is_none() {
|
320 + | tmp.message = _error_message;
|
321 + | }
|
322 + | tmp
|
323 + | }),
|
324 + | "NotFoundException" => crate::operation::put_key_policy::PutKeyPolicyError::NotFoundException({
|
325 + | let mut tmp = match protocol
|
326 + | .deserialize_response(response, crate::types::error::NotFoundException::SCHEMA, _cfg)
|
327 + | .and_then(|mut deser| {
|
328 + | crate::types::error::NotFoundException::deserialize_with_response(
|
329 + | &mut *deser,
|
330 + | response.headers(),
|
331 + | response.status().into(),
|
332 + | body,
|
333 + | )
|
334 + | }) {
|
335 + | ::std::result::Result::Ok(val) => val,
|
336 + | ::std::result::Result::Err(e) => {
|
337 + | return ::std::result::Result::Err(::aws_smithy_runtime_api::client::orchestrator::OrchestratorError::other(
|
338 + | ::aws_smithy_runtime_api::box_error::BoxError::from(e),
|
339 + | ))
|
340 + | }
|
341 + | };
|
342 + | tmp.meta = generic;
|
343 + | if tmp.message.is_none() {
|
344 + | tmp.message = _error_message;
|
345 + | }
|
346 + | tmp
|
347 + | }),
|
348 + | "UnsupportedOperationException" => crate::operation::put_key_policy::PutKeyPolicyError::UnsupportedOperationException({
|
349 + | let mut tmp = match protocol
|
350 + | .deserialize_response(response, crate::types::error::UnsupportedOperationException::SCHEMA, _cfg)
|
351 + | .and_then(|mut deser| {
|
352 + | crate::types::error::UnsupportedOperationException::deserialize_with_response(
|
353 + | &mut *deser,
|
354 + | response.headers(),
|
355 + | response.status().into(),
|
356 + | body,
|
357 + | )
|
358 + | }) {
|
359 + | ::std::result::Result::Ok(val) => val,
|
360 + | ::std::result::Result::Err(e) => {
|
361 + | return ::std::result::Result::Err(::aws_smithy_runtime_api::client::orchestrator::OrchestratorError::other(
|
362 + | ::aws_smithy_runtime_api::box_error::BoxError::from(e),
|
363 + | ))
|
364 + | }
|
365 + | };
|
366 + | tmp.meta = generic;
|
367 + | if tmp.message.is_none() {
|
368 + | tmp.message = _error_message;
|
369 + | }
|
370 + | tmp
|
371 + | }),
|
372 + | _ => crate::operation::put_key_policy::PutKeyPolicyError::generic(generic),
|
373 + | };
|
374 + | ::std::result::Result::Err(::aws_smithy_runtime_api::client::orchestrator::OrchestratorError::operation(
|
375 + | ::aws_smithy_runtime_api::client::interceptors::context::Error::erase(err),
|
376 + | ))
|
377 + | } else {
|
378 + | let protocol = _cfg
|
379 + | .load::<::aws_smithy_schema::protocol::SharedClientProtocol>()
|
380 + | .expect("a SharedClientProtocol is required");
|
381 + | let mut deser = protocol.deserialize_response(response, PutKeyPolicy::OUTPUT_SCHEMA, _cfg).map_err(|e| {
|
382 + | ::aws_smithy_runtime_api::client::orchestrator::OrchestratorError::other(::aws_smithy_runtime_api::box_error::BoxError::from(e))
|
383 + | })?;
|
384 + | let body = response.body().bytes().expect("body loaded");
|
385 + | let output = crate::operation::put_key_policy::PutKeyPolicyOutput::deserialize_with_response(
|
386 + | &mut *deser,
|
387 + | response.headers(),
|
388 + | response.status().into(),
|
389 + | body,
|
390 + | )
|
391 + | .map_err(|e| {
|
392 + | ::aws_smithy_runtime_api::client::orchestrator::OrchestratorError::other(::aws_smithy_runtime_api::box_error::BoxError::from(e))
|
393 + | })?;
|
394 + | ::std::result::Result::Ok(::aws_smithy_runtime_api::client::interceptors::context::Output::erase(output))
|
395 + | }
|
161 396 | }
|
162 397 | }
|
163 398 | #[derive(Debug)]
|
164 399 | struct PutKeyPolicyRequestSerializer;
|
165 400 | impl ::aws_smithy_runtime_api::client::ser_de::SerializeRequest for PutKeyPolicyRequestSerializer {
|
166 401 | #[allow(unused_mut, clippy::let_and_return, clippy::needless_borrow, clippy::useless_conversion)]
|
167 402 | fn serialize_input(
|
168 403 | &self,
|
169 404 | input: ::aws_smithy_runtime_api::client::interceptors::context::Input,
|
170 405 | _cfg: &mut ::aws_smithy_types::config_bag::ConfigBag,
|
171 406 | ) -> ::std::result::Result<::aws_smithy_runtime_api::client::orchestrator::HttpRequest, ::aws_smithy_runtime_api::box_error::BoxError> {
|
172 407 | let input = input
|
173 408 | .downcast::<crate::operation::put_key_policy::PutKeyPolicyInput>()
|
174 409 | .expect("correct type");
|
175 - | let _header_serialization_settings = _cfg
|
176 - | .load::<crate::serialization_settings::HeaderSerializationSettings>()
|
177 - | .cloned()
|
178 - | .unwrap_or_default();
|
179 - | let mut request_builder = {
|
180 - | #[allow(clippy::uninlined_format_args)]
|
181 - | fn uri_base(
|
182 - | _input: &crate::operation::put_key_policy::PutKeyPolicyInput,
|
183 - | output: &mut ::std::string::String,
|
184 - | ) -> ::std::result::Result<(), ::aws_smithy_types::error::operation::BuildError> {
|
185 - | use ::std::fmt::Write as _;
|
186 - | ::std::write!(output, "/").expect("formatting should succeed");
|
187 - | ::std::result::Result::Ok(())
|
188 - | }
|
189 - | #[allow(clippy::unnecessary_wraps)]
|
190 - | fn update_http_builder(
|
191 - | input: &crate::operation::put_key_policy::PutKeyPolicyInput,
|
192 - | builder: ::http_1x::request::Builder,
|
193 - | ) -> ::std::result::Result<::http_1x::request::Builder, ::aws_smithy_types::error::operation::BuildError> {
|
194 - | let mut uri = ::std::string::String::new();
|
195 - | uri_base(input, &mut uri)?;
|
196 - | ::std::result::Result::Ok(builder.method("POST").uri(uri))
|
197 - | }
|
198 - | let mut builder = update_http_builder(&input, ::http_1x::request::Builder::new())?;
|
199 - | builder = _header_serialization_settings.set_default_header(builder, ::http_1x::header::CONTENT_TYPE, "application/x-amz-json-1.1");
|
200 - | builder = _header_serialization_settings.set_default_header(
|
201 - | builder,
|
202 - | ::http_1x::header::HeaderName::from_static("x-amz-target"),
|
203 - | "TrentService.PutKeyPolicy",
|
204 - | );
|
205 - | builder
|
206 - | };
|
207 - | let body = ::aws_smithy_types::body::SdkBody::from(crate::protocol_serde::shape_put_key_policy::ser_put_key_policy_input(&input)?);
|
208 - | if let Some(content_length) = body.content_length() {
|
209 - | let content_length = content_length.to_string();
|
210 - | request_builder = _header_serialization_settings.set_default_header(request_builder, ::http_1x::header::CONTENT_LENGTH, &content_length);
|
211 - | }
|
212 - | ::std::result::Result::Ok(request_builder.body(body).expect("valid request").try_into().unwrap())
|
410 + | let protocol = _cfg
|
411 + | .load::<::aws_smithy_schema::protocol::SharedClientProtocol>()
|
412 + | .expect("a SharedClientProtocol is required");
|
413 + | let mut request = protocol
|
414 + | .serialize_request(&input, PutKeyPolicy::INPUT_SCHEMA, "", _cfg)
|
415 + | .map_err(::aws_smithy_runtime_api::box_error::BoxError::from)?;
|
416 + |
|
417 + | return ::std::result::Result::Ok(request);
|
213 418 | }
|
214 419 | }
|
215 420 | #[derive(Debug)]
|
216 421 | struct PutKeyPolicyEndpointParamsInterceptor;
|
217 422 |
|
218 423 | impl ::aws_smithy_runtime_api::client::interceptors::Intercept for PutKeyPolicyEndpointParamsInterceptor {
|
219 424 | fn name(&self) -> &'static str {
|
220 425 | "PutKeyPolicyEndpointParamsInterceptor"
|
221 426 | }
|
222 427 |
|