aws_sdk_eventbridge/protocol_serde/
shape_put_rule.rs1#[allow(clippy::unnecessary_wraps)]
3pub fn de_put_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::put_rule::PutRuleOutput, crate::operation::put_rule::PutRuleError> {
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::put_rule::PutRuleError::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::put_rule::PutRuleError::unhandled(generic)),
16 };
17
18 let _error_message = generic.message().map(|msg| msg.to_owned());
19 Err(match error_code {
20 "ConcurrentModificationException" => crate::operation::put_rule::PutRuleError::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::put_rule::PutRuleError::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::put_rule::PutRuleError::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::put_rule::PutRuleError::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 "InvalidEventPatternException" => crate::operation::put_rule::PutRuleError::InvalidEventPatternException({
54 #[allow(unused_mut)]
55 let mut tmp = {
56 #[allow(unused_mut)]
57 let mut output = crate::types::error::builders::InvalidEventPatternExceptionBuilder::default();
58 output =
59 crate::protocol_serde::shape_invalid_event_pattern_exception::de_invalid_event_pattern_exception_json_err(_response_body, output)
60 .map_err(crate::operation::put_rule::PutRuleError::unhandled)?;
61 let output = output.meta(generic);
62 output.build()
63 };
64 if tmp.message.is_none() {
65 tmp.message = _error_message;
66 }
67 tmp
68 }),
69 "LimitExceededException" => crate::operation::put_rule::PutRuleError::LimitExceededException({
70 #[allow(unused_mut)]
71 let mut tmp = {
72 #[allow(unused_mut)]
73 let mut output = crate::types::error::builders::LimitExceededExceptionBuilder::default();
74 output = crate::protocol_serde::shape_limit_exceeded_exception::de_limit_exceeded_exception_json_err(_response_body, output)
75 .map_err(crate::operation::put_rule::PutRuleError::unhandled)?;
76 let output = output.meta(generic);
77 output.build()
78 };
79 if tmp.message.is_none() {
80 tmp.message = _error_message;
81 }
82 tmp
83 }),
84 "ManagedRuleException" => crate::operation::put_rule::PutRuleError::ManagedRuleException({
85 #[allow(unused_mut)]
86 let mut tmp = {
87 #[allow(unused_mut)]
88 let mut output = crate::types::error::builders::ManagedRuleExceptionBuilder::default();
89 output = crate::protocol_serde::shape_managed_rule_exception::de_managed_rule_exception_json_err(_response_body, output)
90 .map_err(crate::operation::put_rule::PutRuleError::unhandled)?;
91 let output = output.meta(generic);
92 output.build()
93 };
94 if tmp.message.is_none() {
95 tmp.message = _error_message;
96 }
97 tmp
98 }),
99 "ResourceNotFoundException" => crate::operation::put_rule::PutRuleError::ResourceNotFoundException({
100 #[allow(unused_mut)]
101 let mut tmp = {
102 #[allow(unused_mut)]
103 let mut output = crate::types::error::builders::ResourceNotFoundExceptionBuilder::default();
104 output = crate::protocol_serde::shape_resource_not_found_exception::de_resource_not_found_exception_json_err(_response_body, output)
105 .map_err(crate::operation::put_rule::PutRuleError::unhandled)?;
106 let output = output.meta(generic);
107 output.build()
108 };
109 if tmp.message.is_none() {
110 tmp.message = _error_message;
111 }
112 tmp
113 }),
114 _ => crate::operation::put_rule::PutRuleError::generic(generic),
115 })
116}
117
118#[allow(clippy::unnecessary_wraps)]
119pub fn de_put_rule_http_response(
120 _response_status: u16,
121 _response_headers: &::aws_smithy_runtime_api::http::Headers,
122 _response_body: &[u8],
123) -> std::result::Result<crate::operation::put_rule::PutRuleOutput, crate::operation::put_rule::PutRuleError> {
124 Ok({
125 #[allow(unused_mut)]
126 let mut output = crate::operation::put_rule::builders::PutRuleOutputBuilder::default();
127 output = crate::protocol_serde::shape_put_rule::de_put_rule(_response_body, output)
128 .map_err(crate::operation::put_rule::PutRuleError::unhandled)?;
129 output._set_request_id(::aws_types::request_id::RequestId::request_id(_response_headers).map(str::to_string));
130 output.build()
131 })
132}
133
134pub fn ser_put_rule_input(
135 input: &crate::operation::put_rule::PutRuleInput,
136) -> ::std::result::Result<::aws_smithy_types::body::SdkBody, ::aws_smithy_types::error::operation::SerializationError> {
137 let mut out = String::new();
138 let mut object = ::aws_smithy_json::serialize::JsonObjectWriter::new(&mut out);
139 crate::protocol_serde::shape_put_rule_input::ser_put_rule_input_input(&mut object, input)?;
140 object.finish();
141 Ok(::aws_smithy_types::body::SdkBody::from(out))
142}
143
144pub(crate) fn de_put_rule(
145 value: &[u8],
146 mut builder: crate::operation::put_rule::builders::PutRuleOutputBuilder,
147) -> ::std::result::Result<crate::operation::put_rule::builders::PutRuleOutputBuilder, ::aws_smithy_json::deserialize::error::DeserializeError> {
148 let mut tokens_owned = ::aws_smithy_json::deserialize::json_token_iter(crate::protocol_serde::or_empty_doc(value)).peekable();
149 let tokens = &mut tokens_owned;
150 ::aws_smithy_json::deserialize::token::expect_start_object(tokens.next())?;
151 loop {
152 match tokens.next().transpose()? {
153 Some(::aws_smithy_json::deserialize::Token::EndObject { .. }) => break,
154 Some(::aws_smithy_json::deserialize::Token::ObjectKey { key, .. }) => match key.to_unescaped()?.as_ref() {
155 "RuleArn" => {
156 builder = builder.set_rule_arn(
157 ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
158 .map(|s| s.to_unescaped().map(|u| u.into_owned()))
159 .transpose()?,
160 );
161 }
162 _ => ::aws_smithy_json::deserialize::token::skip_value(tokens)?,
163 },
164 other => {
165 return Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(format!(
166 "expected object key or end object, found: {:?}",
167 other
168 )))
169 }
170 }
171 }
172 if tokens.next().is_some() {
173 return Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(
174 "found more JSON tokens after completing parsing",
175 ));
176 }
177 Ok(builder)
178}