aws_sdk_cloudwatchevents/protocol_serde/
shape_enable_rule.rs1#[allow(clippy::unnecessary_wraps)]
3pub fn de_enable_rule_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::enable_rule::EnableRuleOutput, crate::operation::enable_rule::EnableRuleError> {
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::enable_rule::EnableRuleError::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::enable_rule::EnableRuleError::unhandled(generic)),
16 };
17
18 let _error_message = generic.message().map(|msg| msg.to_owned());
19 Err(match error_code {
20 "ConcurrentModificationException" => crate::operation::enable_rule::EnableRuleError::ConcurrentModificationException({
21 #[allow(unused_mut)]
22 let mut tmp = {
23 #[allow(unused_mut)]
24 let mut output = crate::types::error::builders::ConcurrentModificationExceptionBuilder::default();
25 output = crate::protocol_serde::shape_concurrent_modification_exception::de_concurrent_modification_exception_json_err(
26 _response_body,
27 output,
28 )
29 .map_err(crate::operation::enable_rule::EnableRuleError::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 "InternalException" => crate::operation::enable_rule::EnableRuleError::InternalException({
39 #[allow(unused_mut)]
40 let mut tmp = {
41 #[allow(unused_mut)]
42 let mut output = crate::types::error::builders::InternalExceptionBuilder::default();
43 output = crate::protocol_serde::shape_internal_exception::de_internal_exception_json_err(_response_body, output)
44 .map_err(crate::operation::enable_rule::EnableRuleError::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 "ManagedRuleException" => crate::operation::enable_rule::EnableRuleError::ManagedRuleException({
54 #[allow(unused_mut)]
55 let mut tmp = {
56 #[allow(unused_mut)]
57 let mut output = crate::types::error::builders::ManagedRuleExceptionBuilder::default();
58 output = crate::protocol_serde::shape_managed_rule_exception::de_managed_rule_exception_json_err(_response_body, output)
59 .map_err(crate::operation::enable_rule::EnableRuleError::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 "ResourceNotFoundException" => crate::operation::enable_rule::EnableRuleError::ResourceNotFoundException({
69 #[allow(unused_mut)]
70 let mut tmp = {
71 #[allow(unused_mut)]
72 let mut output = crate::types::error::builders::ResourceNotFoundExceptionBuilder::default();
73 output = crate::protocol_serde::shape_resource_not_found_exception::de_resource_not_found_exception_json_err(_response_body, output)
74 .map_err(crate::operation::enable_rule::EnableRuleError::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 _ => crate::operation::enable_rule::EnableRuleError::generic(generic),
84 })
85}
86
87#[allow(clippy::unnecessary_wraps)]
88pub fn de_enable_rule_http_response(
89 _response_status: u16,
90 _response_headers: &::aws_smithy_runtime_api::http::Headers,
91 _response_body: &[u8],
92) -> std::result::Result<crate::operation::enable_rule::EnableRuleOutput, crate::operation::enable_rule::EnableRuleError> {
93 Ok({
94 #[allow(unused_mut)]
95 let mut output = crate::operation::enable_rule::builders::EnableRuleOutputBuilder::default();
96 output._set_request_id(::aws_types::request_id::RequestId::request_id(_response_headers).map(str::to_string));
97 output.build()
98 })
99}
100
101pub fn ser_enable_rule_input(
102 input: &crate::operation::enable_rule::EnableRuleInput,
103) -> ::std::result::Result<::aws_smithy_types::body::SdkBody, ::aws_smithy_types::error::operation::SerializationError> {
104 let mut out = String::new();
105 let mut object = ::aws_smithy_json::serialize::JsonObjectWriter::new(&mut out);
106 crate::protocol_serde::shape_enable_rule_input::ser_enable_rule_input_input(&mut object, input)?;
107 object.finish();
108 Ok(::aws_smithy_types::body::SdkBody::from(out))
109}