Skip to main content

rusty_cdk_core/shared/
update_delete_policy.rs

1use serde::{Deserialize, Serialize};
2
3pub enum UpdateReplacePolicy {
4    /// `Delete` is the default, deleting the resource (if possible)
5    Delete,
6    /// `Snapshot` deletes it after creating a snapshot
7    Snapshot,
8    /// `Retain` keeps the resource
9    Retain,
10}
11
12impl From<UpdateReplacePolicy> for String {
13    fn from(value: UpdateReplacePolicy) -> String {
14        match value {
15            UpdateReplacePolicy::Delete => "Delete".to_string(),
16            UpdateReplacePolicy::Snapshot => "Snapshot".to_string(),
17            UpdateReplacePolicy::Retain => "Retain".to_string(),
18        }
19    }
20}
21
22/// Determines what happens with an existing resource when it is deleted
23pub enum DeletionPolicy {
24    /// `Delete` deletes the resource (default)
25    Delete,
26    /// `Snapshot` deletes it after creating a snapshot (*if snapshots are possible*)
27    Snapshot,
28    /// `Retain` keeps the resource
29    Retain,
30    /// `RetainExceptOnCreate` keeps the resource, except when it was just created during this stack operation
31    RetainExceptOnCreate,
32}
33
34impl From<DeletionPolicy> for String {
35    fn from(value: DeletionPolicy) -> String {
36        match value {
37            DeletionPolicy::Delete => "Delete".to_string(),
38            DeletionPolicy::Snapshot => "Snapshot".to_string(),
39            DeletionPolicy::Retain => "Retain".to_string(),
40            DeletionPolicy::RetainExceptOnCreate => "RetainExceptOnCreate".to_string(),
41        }
42    }
43}
44
45#[derive(Debug, Serialize, Deserialize)]
46pub struct UpdateDeletePolicyDTO {
47    #[serde(rename = "DeletionPolicy", skip_serializing_if = "Option::is_none")]
48    pub(crate) deletion_policy: Option<String>,
49    #[serde(rename = "UpdateReplacePolicy", skip_serializing_if = "Option::is_none")]
50    pub(crate) update_replace_policy: Option<String>,
51}