aws_sdk_codestarnotifications/protocol_serde/
shape_delete_notification_rule.rs1#[allow(clippy::unnecessary_wraps)]
3pub fn de_delete_notification_rule_http_error(
4 _response_status: u16,
5 _response_headers: &::aws_smithy_runtime_api::http::Headers,
6 _response_body: &[u8],
7) -> std::result::Result<
8 crate::operation::delete_notification_rule::DeleteNotificationRuleOutput,
9 crate::operation::delete_notification_rule::DeleteNotificationRuleError,
10> {
11 #[allow(unused_mut)]
12 let mut generic_builder = crate::protocol_serde::parse_http_error_metadata(_response_status, _response_headers, _response_body)
13 .map_err(crate::operation::delete_notification_rule::DeleteNotificationRuleError::unhandled)?;
14 generic_builder = ::aws_types::request_id::apply_request_id(generic_builder, _response_headers);
15 let generic = generic_builder.build();
16 let error_code = match generic.code() {
17 Some(code) => code,
18 None => {
19 return Err(crate::operation::delete_notification_rule::DeleteNotificationRuleError::unhandled(
20 generic,
21 ))
22 }
23 };
24
25 let _error_message = generic.message().map(|msg| msg.to_owned());
26 Err(match error_code {
27 "ConcurrentModificationException" => {
28 crate::operation::delete_notification_rule::DeleteNotificationRuleError::ConcurrentModificationException({
29 #[allow(unused_mut)]
30 let mut tmp = {
31 #[allow(unused_mut)]
32 let mut output = crate::types::error::builders::ConcurrentModificationExceptionBuilder::default();
33 output = crate::protocol_serde::shape_concurrent_modification_exception::de_concurrent_modification_exception_json_err(
34 _response_body,
35 output,
36 )
37 .map_err(crate::operation::delete_notification_rule::DeleteNotificationRuleError::unhandled)?;
38 let output = output.meta(generic);
39 output.build()
40 };
41 if tmp.message.is_none() {
42 tmp.message = _error_message;
43 }
44 tmp
45 })
46 }
47 "LimitExceededException" => crate::operation::delete_notification_rule::DeleteNotificationRuleError::LimitExceededException({
48 #[allow(unused_mut)]
49 let mut tmp = {
50 #[allow(unused_mut)]
51 let mut output = crate::types::error::builders::LimitExceededExceptionBuilder::default();
52 output = crate::protocol_serde::shape_limit_exceeded_exception::de_limit_exceeded_exception_json_err(_response_body, output)
53 .map_err(crate::operation::delete_notification_rule::DeleteNotificationRuleError::unhandled)?;
54 let output = output.meta(generic);
55 output.build()
56 };
57 if tmp.message.is_none() {
58 tmp.message = _error_message;
59 }
60 tmp
61 }),
62 "ValidationException" => crate::operation::delete_notification_rule::DeleteNotificationRuleError::ValidationException({
63 #[allow(unused_mut)]
64 let mut tmp = {
65 #[allow(unused_mut)]
66 let mut output = crate::types::error::builders::ValidationExceptionBuilder::default();
67 output = crate::protocol_serde::shape_validation_exception::de_validation_exception_json_err(_response_body, output)
68 .map_err(crate::operation::delete_notification_rule::DeleteNotificationRuleError::unhandled)?;
69 let output = output.meta(generic);
70 output.build()
71 };
72 if tmp.message.is_none() {
73 tmp.message = _error_message;
74 }
75 tmp
76 }),
77 _ => crate::operation::delete_notification_rule::DeleteNotificationRuleError::generic(generic),
78 })
79}
80
81#[allow(clippy::unnecessary_wraps)]
82pub fn de_delete_notification_rule_http_response(
83 _response_status: u16,
84 _response_headers: &::aws_smithy_runtime_api::http::Headers,
85 _response_body: &[u8],
86) -> std::result::Result<
87 crate::operation::delete_notification_rule::DeleteNotificationRuleOutput,
88 crate::operation::delete_notification_rule::DeleteNotificationRuleError,
89> {
90 Ok({
91 #[allow(unused_mut)]
92 let mut output = crate::operation::delete_notification_rule::builders::DeleteNotificationRuleOutputBuilder::default();
93 output = crate::protocol_serde::shape_delete_notification_rule::de_delete_notification_rule(_response_body, output)
94 .map_err(crate::operation::delete_notification_rule::DeleteNotificationRuleError::unhandled)?;
95 output._set_request_id(::aws_types::request_id::RequestId::request_id(_response_headers).map(str::to_string));
96 output.build()
97 })
98}
99
100pub fn ser_delete_notification_rule_input(
101 input: &crate::operation::delete_notification_rule::DeleteNotificationRuleInput,
102) -> ::std::result::Result<::aws_smithy_types::body::SdkBody, ::aws_smithy_types::error::operation::SerializationError> {
103 let mut out = String::new();
104 let mut object = ::aws_smithy_json::serialize::JsonObjectWriter::new(&mut out);
105 crate::protocol_serde::shape_delete_notification_rule_input::ser_delete_notification_rule_input_input(&mut object, input)?;
106 object.finish();
107 Ok(::aws_smithy_types::body::SdkBody::from(out))
108}
109
110pub(crate) fn de_delete_notification_rule(
111 value: &[u8],
112 mut builder: crate::operation::delete_notification_rule::builders::DeleteNotificationRuleOutputBuilder,
113) -> ::std::result::Result<
114 crate::operation::delete_notification_rule::builders::DeleteNotificationRuleOutputBuilder,
115 ::aws_smithy_json::deserialize::error::DeserializeError,
116> {
117 let mut tokens_owned = ::aws_smithy_json::deserialize::json_token_iter(crate::protocol_serde::or_empty_doc(value)).peekable();
118 let tokens = &mut tokens_owned;
119 ::aws_smithy_json::deserialize::token::expect_start_object(tokens.next())?;
120 loop {
121 match tokens.next().transpose()? {
122 Some(::aws_smithy_json::deserialize::Token::EndObject { .. }) => break,
123 Some(::aws_smithy_json::deserialize::Token::ObjectKey { key, .. }) => match key.to_unescaped()?.as_ref() {
124 "Arn" => {
125 builder = builder.set_arn(
126 ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
127 .map(|s| s.to_unescaped().map(|u| u.into_owned()))
128 .transpose()?,
129 );
130 }
131 _ => ::aws_smithy_json::deserialize::token::skip_value(tokens)?,
132 },
133 other => {
134 return Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(format!(
135 "expected object key or end object, found: {other:?}"
136 )))
137 }
138 }
139 }
140 if tokens.next().is_some() {
141 return Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(
142 "found more JSON tokens after completing parsing",
143 ));
144 }
145 Ok(builder)
146}