clientapi_pve/models/
pve_notify_config.rs1use crate::models;
12use serde::{Deserialize, Serialize};
13
14#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)]
15pub struct PveNotifyConfig {
16
17 #[serde(rename = "fencing", skip_serializing_if = "Option::is_none")]
19 pub fencing: Option<models::PveFencingEnum>,
20
21 #[serde(rename = "package-updates", skip_serializing_if = "Option::is_none")]
23 pub package_updates: Option<models::PveClusterOptionsPackageUpdatesEnum>,
24
25 #[serde(rename = "replication", skip_serializing_if = "Option::is_none")]
27 pub replication: Option<models::PveFencingEnum>,
28
29 #[serde(rename = "target-fencing", skip_serializing_if = "Option::is_none")]
31 pub target_fencing: Option<String>,
32
33 #[serde(rename = "target-package-updates", skip_serializing_if = "Option::is_none")]
35 pub target_package_updates: Option<String>,
36
37 #[serde(rename = "target-replication", skip_serializing_if = "Option::is_none")]
39 pub target_replication: Option<String>,
40
41
42}
43
44impl PveNotifyConfig {
45 pub fn new() -> PveNotifyConfig {
46 PveNotifyConfig {
47
48 fencing: None,
49
50 package_updates: None,
51
52 replication: None,
53
54 target_fencing: None,
55
56 target_package_updates: None,
57
58 target_replication: None,
59
60 }
61 }
62}
63
64
65impl PveNotifyConfig {
66 pub fn to_shorthand(&self) -> String {
74 let mut parts: Vec<String> = Vec::new();
75
76
77
78 if let Some(ref v) = self.fencing {
79 parts.push(format!("fencing={}", v));
80 }
81
82
83 if let Some(ref v) = self.package_updates {
84 parts.push(format!("package-updates={}", v));
85 }
86
87
88 if let Some(ref v) = self.replication {
89 parts.push(format!("replication={}", v));
90 }
91
92
93 if let Some(ref v) = self.target_fencing {
94 parts.push(format!("target-fencing={}", v));
95 }
96
97
98 if let Some(ref v) = self.target_package_updates {
99 parts.push(format!("target-package-updates={}", v));
100 }
101
102
103 if let Some(ref v) = self.target_replication {
104 parts.push(format!("target-replication={}", v));
105 }
106
107 parts.join(",")
108 }
109}
110