cfn/aws/
kms.rs

1//! Types for the `KMS` service.
2
3/// The [`AWS::KMS::Alias`](http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-kms-alias.html) resource type.
4#[derive(Debug, Default)]
5pub struct Alias {
6    properties: AliasProperties
7}
8
9/// Properties for the `Alias` resource.
10#[derive(Debug, Default)]
11pub struct AliasProperties {
12    /// Property [`AliasName`](http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-kms-alias.html#cfn-kms-alias-aliasname).
13    ///
14    /// Update type: _Immutable_.
15    /// AWS CloudFormation replaces the resource when you change this property.
16    pub alias_name: ::Value<String>,
17    /// Property [`TargetKeyId`](http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-kms-alias.html#cfn-kms-alias-targetkeyid).
18    ///
19    /// Update type: _Mutable_.
20    /// AWS CloudFormation doesn't replace the resource when you change this property.
21    pub target_key_id: ::Value<String>,
22}
23
24impl ::serde::Serialize for AliasProperties {
25    fn serialize<S: ::serde::Serializer>(&self, s: S) -> Result<S::Ok, S::Error> {
26        let mut map = ::serde::Serializer::serialize_map(s, None)?;
27        ::serde::ser::SerializeMap::serialize_entry(&mut map, "AliasName", &self.alias_name)?;
28        ::serde::ser::SerializeMap::serialize_entry(&mut map, "TargetKeyId", &self.target_key_id)?;
29        ::serde::ser::SerializeMap::end(map)
30    }
31}
32
33impl<'de> ::serde::Deserialize<'de> for AliasProperties {
34    fn deserialize<D: ::serde::Deserializer<'de>>(d: D) -> Result<AliasProperties, D::Error> {
35        struct Visitor;
36
37        impl<'de> ::serde::de::Visitor<'de> for Visitor {
38            type Value = AliasProperties;
39
40            fn expecting(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
41                write!(f, "a struct of type AliasProperties")
42            }
43
44            fn visit_map<A: ::serde::de::MapAccess<'de>>(self, mut map: A) -> Result<Self::Value, A::Error> {
45                let mut alias_name: Option<::Value<String>> = None;
46                let mut target_key_id: Option<::Value<String>> = None;
47
48                while let Some(__cfn_key) = ::serde::de::MapAccess::next_key::<String>(&mut map)? {
49                    match __cfn_key.as_ref() {
50                        "AliasName" => {
51                            alias_name = ::serde::de::MapAccess::next_value(&mut map)?;
52                        }
53                        "TargetKeyId" => {
54                            target_key_id = ::serde::de::MapAccess::next_value(&mut map)?;
55                        }
56                        _ => {}
57                    }
58                }
59
60                Ok(AliasProperties {
61                    alias_name: alias_name.ok_or(::serde::de::Error::missing_field("AliasName"))?,
62                    target_key_id: target_key_id.ok_or(::serde::de::Error::missing_field("TargetKeyId"))?,
63                })
64            }
65        }
66
67        d.deserialize_map(Visitor)
68    }
69}
70
71impl ::Resource for Alias {
72    type Properties = AliasProperties;
73    const TYPE: &'static str = "AWS::KMS::Alias";
74    fn properties(&self) -> &AliasProperties {
75        &self.properties
76    }
77    fn properties_mut(&mut self) -> &mut AliasProperties {
78        &mut self.properties
79    }
80}
81
82impl ::private::Sealed for Alias {}
83
84impl From<AliasProperties> for Alias {
85    fn from(properties: AliasProperties) -> Alias {
86        Alias { properties }
87    }
88}
89
90/// The [`AWS::KMS::Key`](http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-kms-key.html) resource type.
91#[derive(Debug, Default)]
92pub struct Key {
93    properties: KeyProperties
94}
95
96/// Properties for the `Key` resource.
97#[derive(Debug, Default)]
98pub struct KeyProperties {
99    /// Property [`Description`](http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-kms-key.html#cfn-kms-key-description).
100    ///
101    /// Update type: _Mutable_.
102    /// AWS CloudFormation doesn't replace the resource when you change this property.
103    pub description: Option<::Value<String>>,
104    /// Property [`EnableKeyRotation`](http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-kms-key.html#cfn-kms-key-enablekeyrotation).
105    ///
106    /// Update type: _Mutable_.
107    /// AWS CloudFormation doesn't replace the resource when you change this property.
108    pub enable_key_rotation: Option<::Value<bool>>,
109    /// Property [`Enabled`](http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-kms-key.html#cfn-kms-key-enabled).
110    ///
111    /// Update type: _Mutable_.
112    /// AWS CloudFormation doesn't replace the resource when you change this property.
113    pub enabled: Option<::Value<bool>>,
114    /// Property [`KeyPolicy`](http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-kms-key.html#cfn-kms-key-keypolicy).
115    ///
116    /// Update type: _Mutable_.
117    /// AWS CloudFormation doesn't replace the resource when you change this property.
118    pub key_policy: ::Value<::json::Value>,
119    /// Property [`KeySpec`](http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-kms-key.html#cfn-kms-key-keyspec).
120    ///
121    /// Update type: _Mutable_.
122    /// AWS CloudFormation doesn't replace the resource when you change this property.
123    pub key_spec: Option<::Value<String>>,
124    /// Property [`KeyUsage`](http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-kms-key.html#cfn-kms-key-keyusage).
125    ///
126    /// Update type: _Mutable_.
127    /// AWS CloudFormation doesn't replace the resource when you change this property.
128    pub key_usage: Option<::Value<String>>,
129    /// Property [`MultiRegion`](http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-kms-key.html#cfn-kms-key-multiregion).
130    ///
131    /// Update type: _Mutable_.
132    /// AWS CloudFormation doesn't replace the resource when you change this property.
133    pub multi_region: Option<::Value<bool>>,
134    /// Property [`PendingWindowInDays`](http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-kms-key.html#cfn-kms-key-pendingwindowindays).
135    ///
136    /// Update type: _Mutable_.
137    /// AWS CloudFormation doesn't replace the resource when you change this property.
138    pub pending_window_in_days: Option<::Value<u32>>,
139    /// Property [`Tags`](http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-kms-key.html#cfn-kms-key-tags).
140    ///
141    /// Update type: _Mutable_.
142    /// AWS CloudFormation doesn't replace the resource when you change this property.
143    pub tags: Option<::ValueList<::Tag>>,
144}
145
146impl ::serde::Serialize for KeyProperties {
147    fn serialize<S: ::serde::Serializer>(&self, s: S) -> Result<S::Ok, S::Error> {
148        let mut map = ::serde::Serializer::serialize_map(s, None)?;
149        if let Some(ref description) = self.description {
150            ::serde::ser::SerializeMap::serialize_entry(&mut map, "Description", description)?;
151        }
152        if let Some(ref enable_key_rotation) = self.enable_key_rotation {
153            ::serde::ser::SerializeMap::serialize_entry(&mut map, "EnableKeyRotation", enable_key_rotation)?;
154        }
155        if let Some(ref enabled) = self.enabled {
156            ::serde::ser::SerializeMap::serialize_entry(&mut map, "Enabled", enabled)?;
157        }
158        ::serde::ser::SerializeMap::serialize_entry(&mut map, "KeyPolicy", &self.key_policy)?;
159        if let Some(ref key_spec) = self.key_spec {
160            ::serde::ser::SerializeMap::serialize_entry(&mut map, "KeySpec", key_spec)?;
161        }
162        if let Some(ref key_usage) = self.key_usage {
163            ::serde::ser::SerializeMap::serialize_entry(&mut map, "KeyUsage", key_usage)?;
164        }
165        if let Some(ref multi_region) = self.multi_region {
166            ::serde::ser::SerializeMap::serialize_entry(&mut map, "MultiRegion", multi_region)?;
167        }
168        if let Some(ref pending_window_in_days) = self.pending_window_in_days {
169            ::serde::ser::SerializeMap::serialize_entry(&mut map, "PendingWindowInDays", pending_window_in_days)?;
170        }
171        if let Some(ref tags) = self.tags {
172            ::serde::ser::SerializeMap::serialize_entry(&mut map, "Tags", tags)?;
173        }
174        ::serde::ser::SerializeMap::end(map)
175    }
176}
177
178impl<'de> ::serde::Deserialize<'de> for KeyProperties {
179    fn deserialize<D: ::serde::Deserializer<'de>>(d: D) -> Result<KeyProperties, D::Error> {
180        struct Visitor;
181
182        impl<'de> ::serde::de::Visitor<'de> for Visitor {
183            type Value = KeyProperties;
184
185            fn expecting(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
186                write!(f, "a struct of type KeyProperties")
187            }
188
189            fn visit_map<A: ::serde::de::MapAccess<'de>>(self, mut map: A) -> Result<Self::Value, A::Error> {
190                let mut description: Option<::Value<String>> = None;
191                let mut enable_key_rotation: Option<::Value<bool>> = None;
192                let mut enabled: Option<::Value<bool>> = None;
193                let mut key_policy: Option<::Value<::json::Value>> = None;
194                let mut key_spec: Option<::Value<String>> = None;
195                let mut key_usage: Option<::Value<String>> = None;
196                let mut multi_region: Option<::Value<bool>> = None;
197                let mut pending_window_in_days: Option<::Value<u32>> = None;
198                let mut tags: Option<::ValueList<::Tag>> = None;
199
200                while let Some(__cfn_key) = ::serde::de::MapAccess::next_key::<String>(&mut map)? {
201                    match __cfn_key.as_ref() {
202                        "Description" => {
203                            description = ::serde::de::MapAccess::next_value(&mut map)?;
204                        }
205                        "EnableKeyRotation" => {
206                            enable_key_rotation = ::serde::de::MapAccess::next_value(&mut map)?;
207                        }
208                        "Enabled" => {
209                            enabled = ::serde::de::MapAccess::next_value(&mut map)?;
210                        }
211                        "KeyPolicy" => {
212                            key_policy = ::serde::de::MapAccess::next_value(&mut map)?;
213                        }
214                        "KeySpec" => {
215                            key_spec = ::serde::de::MapAccess::next_value(&mut map)?;
216                        }
217                        "KeyUsage" => {
218                            key_usage = ::serde::de::MapAccess::next_value(&mut map)?;
219                        }
220                        "MultiRegion" => {
221                            multi_region = ::serde::de::MapAccess::next_value(&mut map)?;
222                        }
223                        "PendingWindowInDays" => {
224                            pending_window_in_days = ::serde::de::MapAccess::next_value(&mut map)?;
225                        }
226                        "Tags" => {
227                            tags = ::serde::de::MapAccess::next_value(&mut map)?;
228                        }
229                        _ => {}
230                    }
231                }
232
233                Ok(KeyProperties {
234                    description: description,
235                    enable_key_rotation: enable_key_rotation,
236                    enabled: enabled,
237                    key_policy: key_policy.ok_or(::serde::de::Error::missing_field("KeyPolicy"))?,
238                    key_spec: key_spec,
239                    key_usage: key_usage,
240                    multi_region: multi_region,
241                    pending_window_in_days: pending_window_in_days,
242                    tags: tags,
243                })
244            }
245        }
246
247        d.deserialize_map(Visitor)
248    }
249}
250
251impl ::Resource for Key {
252    type Properties = KeyProperties;
253    const TYPE: &'static str = "AWS::KMS::Key";
254    fn properties(&self) -> &KeyProperties {
255        &self.properties
256    }
257    fn properties_mut(&mut self) -> &mut KeyProperties {
258        &mut self.properties
259    }
260}
261
262impl ::private::Sealed for Key {}
263
264impl From<KeyProperties> for Key {
265    fn from(properties: KeyProperties) -> Key {
266        Key { properties }
267    }
268}
269
270/// The [`AWS::KMS::ReplicaKey`](http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-kms-replicakey.html) resource type.
271#[derive(Debug, Default)]
272pub struct ReplicaKey {
273    properties: ReplicaKeyProperties
274}
275
276/// Properties for the `ReplicaKey` resource.
277#[derive(Debug, Default)]
278pub struct ReplicaKeyProperties {
279    /// Property [`Description`](http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-kms-replicakey.html#cfn-kms-replicakey-description).
280    ///
281    /// Update type: _Mutable_.
282    /// AWS CloudFormation doesn't replace the resource when you change this property.
283    pub description: Option<::Value<String>>,
284    /// Property [`Enabled`](http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-kms-replicakey.html#cfn-kms-replicakey-enabled).
285    ///
286    /// Update type: _Mutable_.
287    /// AWS CloudFormation doesn't replace the resource when you change this property.
288    pub enabled: Option<::Value<bool>>,
289    /// Property [`KeyPolicy`](http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-kms-replicakey.html#cfn-kms-replicakey-keypolicy).
290    ///
291    /// Update type: _Mutable_.
292    /// AWS CloudFormation doesn't replace the resource when you change this property.
293    pub key_policy: ::Value<::json::Value>,
294    /// Property [`PendingWindowInDays`](http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-kms-replicakey.html#cfn-kms-replicakey-pendingwindowindays).
295    ///
296    /// Update type: _Mutable_.
297    /// AWS CloudFormation doesn't replace the resource when you change this property.
298    pub pending_window_in_days: Option<::Value<u32>>,
299    /// Property [`PrimaryKeyArn`](http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-kms-replicakey.html#cfn-kms-replicakey-primarykeyarn).
300    ///
301    /// Update type: _Immutable_.
302    /// AWS CloudFormation replaces the resource when you change this property.
303    pub primary_key_arn: ::Value<String>,
304    /// Property [`Tags`](http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-kms-replicakey.html#cfn-kms-replicakey-tags).
305    ///
306    /// Update type: _Mutable_.
307    /// AWS CloudFormation doesn't replace the resource when you change this property.
308    pub tags: Option<::ValueList<::Tag>>,
309}
310
311impl ::serde::Serialize for ReplicaKeyProperties {
312    fn serialize<S: ::serde::Serializer>(&self, s: S) -> Result<S::Ok, S::Error> {
313        let mut map = ::serde::Serializer::serialize_map(s, None)?;
314        if let Some(ref description) = self.description {
315            ::serde::ser::SerializeMap::serialize_entry(&mut map, "Description", description)?;
316        }
317        if let Some(ref enabled) = self.enabled {
318            ::serde::ser::SerializeMap::serialize_entry(&mut map, "Enabled", enabled)?;
319        }
320        ::serde::ser::SerializeMap::serialize_entry(&mut map, "KeyPolicy", &self.key_policy)?;
321        if let Some(ref pending_window_in_days) = self.pending_window_in_days {
322            ::serde::ser::SerializeMap::serialize_entry(&mut map, "PendingWindowInDays", pending_window_in_days)?;
323        }
324        ::serde::ser::SerializeMap::serialize_entry(&mut map, "PrimaryKeyArn", &self.primary_key_arn)?;
325        if let Some(ref tags) = self.tags {
326            ::serde::ser::SerializeMap::serialize_entry(&mut map, "Tags", tags)?;
327        }
328        ::serde::ser::SerializeMap::end(map)
329    }
330}
331
332impl<'de> ::serde::Deserialize<'de> for ReplicaKeyProperties {
333    fn deserialize<D: ::serde::Deserializer<'de>>(d: D) -> Result<ReplicaKeyProperties, D::Error> {
334        struct Visitor;
335
336        impl<'de> ::serde::de::Visitor<'de> for Visitor {
337            type Value = ReplicaKeyProperties;
338
339            fn expecting(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
340                write!(f, "a struct of type ReplicaKeyProperties")
341            }
342
343            fn visit_map<A: ::serde::de::MapAccess<'de>>(self, mut map: A) -> Result<Self::Value, A::Error> {
344                let mut description: Option<::Value<String>> = None;
345                let mut enabled: Option<::Value<bool>> = None;
346                let mut key_policy: Option<::Value<::json::Value>> = None;
347                let mut pending_window_in_days: Option<::Value<u32>> = None;
348                let mut primary_key_arn: Option<::Value<String>> = None;
349                let mut tags: Option<::ValueList<::Tag>> = None;
350
351                while let Some(__cfn_key) = ::serde::de::MapAccess::next_key::<String>(&mut map)? {
352                    match __cfn_key.as_ref() {
353                        "Description" => {
354                            description = ::serde::de::MapAccess::next_value(&mut map)?;
355                        }
356                        "Enabled" => {
357                            enabled = ::serde::de::MapAccess::next_value(&mut map)?;
358                        }
359                        "KeyPolicy" => {
360                            key_policy = ::serde::de::MapAccess::next_value(&mut map)?;
361                        }
362                        "PendingWindowInDays" => {
363                            pending_window_in_days = ::serde::de::MapAccess::next_value(&mut map)?;
364                        }
365                        "PrimaryKeyArn" => {
366                            primary_key_arn = ::serde::de::MapAccess::next_value(&mut map)?;
367                        }
368                        "Tags" => {
369                            tags = ::serde::de::MapAccess::next_value(&mut map)?;
370                        }
371                        _ => {}
372                    }
373                }
374
375                Ok(ReplicaKeyProperties {
376                    description: description,
377                    enabled: enabled,
378                    key_policy: key_policy.ok_or(::serde::de::Error::missing_field("KeyPolicy"))?,
379                    pending_window_in_days: pending_window_in_days,
380                    primary_key_arn: primary_key_arn.ok_or(::serde::de::Error::missing_field("PrimaryKeyArn"))?,
381                    tags: tags,
382                })
383            }
384        }
385
386        d.deserialize_map(Visitor)
387    }
388}
389
390impl ::Resource for ReplicaKey {
391    type Properties = ReplicaKeyProperties;
392    const TYPE: &'static str = "AWS::KMS::ReplicaKey";
393    fn properties(&self) -> &ReplicaKeyProperties {
394        &self.properties
395    }
396    fn properties_mut(&mut self) -> &mut ReplicaKeyProperties {
397        &mut self.properties
398    }
399}
400
401impl ::private::Sealed for ReplicaKey {}
402
403impl From<ReplicaKeyProperties> for ReplicaKey {
404    fn from(properties: ReplicaKeyProperties) -> ReplicaKey {
405        ReplicaKey { properties }
406    }
407}