cfn/aws/
codestarnotifications.rs1#[derive(Debug, Default)]
5pub struct NotificationRule {
6 properties: NotificationRuleProperties
7}
8
9#[derive(Debug, Default)]
11pub struct NotificationRuleProperties {
12 pub detail_type: ::Value<String>,
17 pub event_type_ids: ::ValueList<String>,
22 pub name: ::Value<String>,
27 pub resource: ::Value<String>,
32 pub status: Option<::Value<String>>,
37 pub tags: Option<::Value<::json::Value>>,
42 pub targets: ::ValueList<self::notification_rule::Target>,
47}
48
49impl ::serde::Serialize for NotificationRuleProperties {
50 fn serialize<S: ::serde::Serializer>(&self, s: S) -> Result<S::Ok, S::Error> {
51 let mut map = ::serde::Serializer::serialize_map(s, None)?;
52 ::serde::ser::SerializeMap::serialize_entry(&mut map, "DetailType", &self.detail_type)?;
53 ::serde::ser::SerializeMap::serialize_entry(&mut map, "EventTypeIds", &self.event_type_ids)?;
54 ::serde::ser::SerializeMap::serialize_entry(&mut map, "Name", &self.name)?;
55 ::serde::ser::SerializeMap::serialize_entry(&mut map, "Resource", &self.resource)?;
56 if let Some(ref status) = self.status {
57 ::serde::ser::SerializeMap::serialize_entry(&mut map, "Status", status)?;
58 }
59 if let Some(ref tags) = self.tags {
60 ::serde::ser::SerializeMap::serialize_entry(&mut map, "Tags", tags)?;
61 }
62 ::serde::ser::SerializeMap::serialize_entry(&mut map, "Targets", &self.targets)?;
63 ::serde::ser::SerializeMap::end(map)
64 }
65}
66
67impl<'de> ::serde::Deserialize<'de> for NotificationRuleProperties {
68 fn deserialize<D: ::serde::Deserializer<'de>>(d: D) -> Result<NotificationRuleProperties, D::Error> {
69 struct Visitor;
70
71 impl<'de> ::serde::de::Visitor<'de> for Visitor {
72 type Value = NotificationRuleProperties;
73
74 fn expecting(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
75 write!(f, "a struct of type NotificationRuleProperties")
76 }
77
78 fn visit_map<A: ::serde::de::MapAccess<'de>>(self, mut map: A) -> Result<Self::Value, A::Error> {
79 let mut detail_type: Option<::Value<String>> = None;
80 let mut event_type_ids: Option<::ValueList<String>> = None;
81 let mut name: Option<::Value<String>> = None;
82 let mut resource: Option<::Value<String>> = None;
83 let mut status: Option<::Value<String>> = None;
84 let mut tags: Option<::Value<::json::Value>> = None;
85 let mut targets: Option<::ValueList<self::notification_rule::Target>> = None;
86
87 while let Some(__cfn_key) = ::serde::de::MapAccess::next_key::<String>(&mut map)? {
88 match __cfn_key.as_ref() {
89 "DetailType" => {
90 detail_type = ::serde::de::MapAccess::next_value(&mut map)?;
91 }
92 "EventTypeIds" => {
93 event_type_ids = ::serde::de::MapAccess::next_value(&mut map)?;
94 }
95 "Name" => {
96 name = ::serde::de::MapAccess::next_value(&mut map)?;
97 }
98 "Resource" => {
99 resource = ::serde::de::MapAccess::next_value(&mut map)?;
100 }
101 "Status" => {
102 status = ::serde::de::MapAccess::next_value(&mut map)?;
103 }
104 "Tags" => {
105 tags = ::serde::de::MapAccess::next_value(&mut map)?;
106 }
107 "Targets" => {
108 targets = ::serde::de::MapAccess::next_value(&mut map)?;
109 }
110 _ => {}
111 }
112 }
113
114 Ok(NotificationRuleProperties {
115 detail_type: detail_type.ok_or(::serde::de::Error::missing_field("DetailType"))?,
116 event_type_ids: event_type_ids.ok_or(::serde::de::Error::missing_field("EventTypeIds"))?,
117 name: name.ok_or(::serde::de::Error::missing_field("Name"))?,
118 resource: resource.ok_or(::serde::de::Error::missing_field("Resource"))?,
119 status: status,
120 tags: tags,
121 targets: targets.ok_or(::serde::de::Error::missing_field("Targets"))?,
122 })
123 }
124 }
125
126 d.deserialize_map(Visitor)
127 }
128}
129
130impl ::Resource for NotificationRule {
131 type Properties = NotificationRuleProperties;
132 const TYPE: &'static str = "AWS::CodeStarNotifications::NotificationRule";
133 fn properties(&self) -> &NotificationRuleProperties {
134 &self.properties
135 }
136 fn properties_mut(&mut self) -> &mut NotificationRuleProperties {
137 &mut self.properties
138 }
139}
140
141impl ::private::Sealed for NotificationRule {}
142
143impl From<NotificationRuleProperties> for NotificationRule {
144 fn from(properties: NotificationRuleProperties) -> NotificationRule {
145 NotificationRule { properties }
146 }
147}
148
149pub mod notification_rule {
150 #[derive(Debug, Default)]
154 pub struct Target {
155 pub target_address: Option<::Value<String>>,
160 pub target_type: Option<::Value<String>>,
165 }
166
167 impl ::codec::SerializeValue for Target {
168 fn serialize<S: ::serde::Serializer>(&self, s: S) -> Result<S::Ok, S::Error> {
169 let mut map = ::serde::Serializer::serialize_map(s, None)?;
170 if let Some(ref target_address) = self.target_address {
171 ::serde::ser::SerializeMap::serialize_entry(&mut map, "TargetAddress", target_address)?;
172 }
173 if let Some(ref target_type) = self.target_type {
174 ::serde::ser::SerializeMap::serialize_entry(&mut map, "TargetType", target_type)?;
175 }
176 ::serde::ser::SerializeMap::end(map)
177 }
178 }
179
180 impl ::codec::DeserializeValue for Target {
181 fn deserialize<'de, D: ::serde::Deserializer<'de>>(d: D) -> Result<Target, D::Error> {
182 struct Visitor;
183
184 impl<'de> ::serde::de::Visitor<'de> for Visitor {
185 type Value = Target;
186
187 fn expecting(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
188 write!(f, "a struct of type Target")
189 }
190
191 fn visit_map<A: ::serde::de::MapAccess<'de>>(self, mut map: A) -> Result<Self::Value, A::Error> {
192 let mut target_address: Option<::Value<String>> = None;
193 let mut target_type: Option<::Value<String>> = None;
194
195 while let Some(__cfn_key) = ::serde::de::MapAccess::next_key::<String>(&mut map)? {
196 match __cfn_key.as_ref() {
197 "TargetAddress" => {
198 target_address = ::serde::de::MapAccess::next_value(&mut map)?;
199 }
200 "TargetType" => {
201 target_type = ::serde::de::MapAccess::next_value(&mut map)?;
202 }
203 _ => {}
204 }
205 }
206
207 Ok(Target {
208 target_address: target_address,
209 target_type: target_type,
210 })
211 }
212 }
213
214 d.deserialize_map(Visitor)
215 }
216 }
217}