cfn/aws/
codestarnotifications.rs

1//! Types for the `CodeStarNotifications` service.
2
3/// The [`AWS::CodeStarNotifications::NotificationRule`](http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-codestarnotifications-notificationrule.html) resource type.
4#[derive(Debug, Default)]
5pub struct NotificationRule {
6    properties: NotificationRuleProperties
7}
8
9/// Properties for the `NotificationRule` resource.
10#[derive(Debug, Default)]
11pub struct NotificationRuleProperties {
12    /// Property [`DetailType`](http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-codestarnotifications-notificationrule.html#cfn-codestarnotifications-notificationrule-detailtype).
13    ///
14    /// Update type: _Mutable_.
15    /// AWS CloudFormation doesn't replace the resource when you change this property.
16    pub detail_type: ::Value<String>,
17    /// Property [`EventTypeIds`](http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-codestarnotifications-notificationrule.html#cfn-codestarnotifications-notificationrule-eventtypeids).
18    ///
19    /// Update type: _Mutable_.
20    /// AWS CloudFormation doesn't replace the resource when you change this property.
21    pub event_type_ids: ::ValueList<String>,
22    /// Property [`Name`](http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-codestarnotifications-notificationrule.html#cfn-codestarnotifications-notificationrule-name).
23    ///
24    /// Update type: _Mutable_.
25    /// AWS CloudFormation doesn't replace the resource when you change this property.
26    pub name: ::Value<String>,
27    /// Property [`Resource`](http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-codestarnotifications-notificationrule.html#cfn-codestarnotifications-notificationrule-resource).
28    ///
29    /// Update type: _Immutable_.
30    /// AWS CloudFormation replaces the resource when you change this property.
31    pub resource: ::Value<String>,
32    /// Property [`Status`](http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-codestarnotifications-notificationrule.html#cfn-codestarnotifications-notificationrule-status).
33    ///
34    /// Update type: _Mutable_.
35    /// AWS CloudFormation doesn't replace the resource when you change this property.
36    pub status: Option<::Value<String>>,
37    /// Property [`Tags`](http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-codestarnotifications-notificationrule.html#cfn-codestarnotifications-notificationrule-tags).
38    ///
39    /// Update type: _Immutable_.
40    /// AWS CloudFormation replaces the resource when you change this property.
41    pub tags: Option<::Value<::json::Value>>,
42    /// Property [`Targets`](http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-codestarnotifications-notificationrule.html#cfn-codestarnotifications-notificationrule-targets).
43    ///
44    /// Update type: _Mutable_.
45    /// AWS CloudFormation doesn't replace the resource when you change this property.
46    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    //! Property types for the `NotificationRule` resource.
151
152    /// The [`AWS::CodeStarNotifications::NotificationRule.Target`](http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-codestarnotifications-notificationrule-target.html) property type.
153    #[derive(Debug, Default)]
154    pub struct Target {
155        /// Property [`TargetAddress`](http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-codestarnotifications-notificationrule-target.html#cfn-codestarnotifications-notificationrule-target-targetaddress).
156        ///
157        /// Update type: _Mutable_.
158        /// AWS CloudFormation doesn't replace the resource when you change this property.
159        pub target_address: Option<::Value<String>>,
160        /// Property [`TargetType`](http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-codestarnotifications-notificationrule-target.html#cfn-codestarnotifications-notificationrule-target-targettype).
161        ///
162        /// Update type: _Mutable_.
163        /// AWS CloudFormation doesn't replace the resource when you change this property.
164        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}