proxmox_api/generated/cluster/notifications/matchers/
name.rs1#[derive(Debug, Clone)]
2pub struct NameClient<T> {
3 client: T,
4 path: String,
5}
6impl<T> NameClient<T>
7where
8 T: crate::client::Client,
9{
10 pub fn new(client: T, parent_path: &str, name: &str) -> Self {
11 Self {
12 client,
13 path: format!("{}/{}", parent_path, name),
14 }
15 }
16}
17impl<T> NameClient<T>
18where
19 T: crate::client::Client,
20{
21 #[doc = "Remove matcher"]
22 #[doc = ""]
23 #[doc = "Permission check: perm(\"/mapping/notifications\", [\"Mapping.Modify\"])"]
24 pub async fn delete(&self) -> Result<(), T::Error> {
25 let path = self.path.to_string();
26 self.client.delete(&path, &()).await
27 }
28}
29impl<T> NameClient<T>
30where
31 T: crate::client::Client,
32{
33 #[doc = "Return a specific matcher"]
34 #[doc = ""]
35 #[doc = "Permission check: or(perm(\"/mapping/notifications\", [\"Mapping.Modify\"]), perm(\"/mapping/notifications\", [\"Mapping.Audit\"]))"]
36 pub async fn get(&self) -> Result<GetOutput, T::Error> {
37 let path = self.path.to_string();
38 self.client.get(&path, &()).await
39 }
40}
41impl<T> NameClient<T>
42where
43 T: crate::client::Client,
44{
45 #[doc = "Update existing matcher"]
46 #[doc = ""]
47 #[doc = "Permission check: perm(\"/mapping/notifications\", [\"Mapping.Modify\"])"]
48 pub async fn put(&self, params: PutParams) -> Result<(), T::Error> {
49 let path = self.path.to_string();
50 self.client.put(&path, ¶ms).await
51 }
52}
53impl GetOutput {
54 pub fn new(name: String) -> Self {
55 Self {
56 name,
57 comment: ::std::default::Default::default(),
58 digest: ::std::default::Default::default(),
59 disable: ::std::default::Default::default(),
60 invert_match: ::std::default::Default::default(),
61 match_calendar: ::std::default::Default::default(),
62 match_field: ::std::default::Default::default(),
63 match_severity: ::std::default::Default::default(),
64 mode: ::std::default::Default::default(),
65 target: ::std::default::Default::default(),
66 additional_properties: ::std::default::Default::default(),
67 }
68 }
69}
70#[derive(Clone, Debug, :: serde :: Serialize, :: serde :: Deserialize)]
71pub struct GetOutput {
72 #[serde(skip_serializing_if = "Option::is_none", default)]
73 #[doc = "Comment"]
74 #[doc = ""]
75 pub comment: Option<String>,
76 #[serde(skip_serializing_if = "Option::is_none", default)]
77 #[doc = "Prevent changes if current configuration file has a different digest. This can be used to prevent concurrent modifications."]
78 #[doc = ""]
79 pub digest: Option<DigestStr>,
80 #[serde(
81 serialize_with = "crate::types::serialize_bool_optional",
82 deserialize_with = "crate::types::deserialize_bool_optional"
83 )]
84 #[serde(skip_serializing_if = "Option::is_none", default)]
85 #[doc = "Disable this matcher"]
86 #[doc = ""]
87 pub disable: Option<bool>,
88 #[serde(rename = "invert-match")]
89 #[serde(
90 serialize_with = "crate::types::serialize_bool_optional",
91 deserialize_with = "crate::types::deserialize_bool_optional"
92 )]
93 #[serde(skip_serializing_if = "Option::is_none", default)]
94 #[doc = "Invert match of the whole matcher"]
95 #[doc = ""]
96 pub invert_match: Option<bool>,
97 #[serde(rename = "match-calendar")]
98 #[serde(skip_serializing_if = "::std::vec::Vec::is_empty", default)]
99 #[doc = "Match notification timestamp"]
100 #[doc = ""]
101 pub match_calendar: Vec<String>,
102 #[serde(rename = "match-field")]
103 #[serde(skip_serializing_if = "::std::vec::Vec::is_empty", default)]
104 #[doc = "Metadata fields to match (regex or exact match). Must be in the form (regex|exact):\\\\<field\\\\>=\\\\<value\\\\>"]
105 #[doc = ""]
106 pub match_field: Vec<String>,
107 #[serde(rename = "match-severity")]
108 #[serde(skip_serializing_if = "::std::vec::Vec::is_empty", default)]
109 #[doc = "Notification severities to match"]
110 #[doc = ""]
111 pub match_severity: Vec<String>,
112 #[serde(skip_serializing_if = "Option::is_none", default)]
113 #[doc = "Choose between 'all' and 'any' for when multiple properties are specified"]
114 #[doc = ""]
115 pub mode: Option<Mode>,
116 #[doc = "Name of the matcher."]
117 #[doc = ""]
118 pub name: String,
119 #[serde(skip_serializing_if = "::std::vec::Vec::is_empty", default)]
120 #[doc = "Targets to notify on match"]
121 #[doc = ""]
122 pub target: Vec<String>,
123 #[serde(
124 flatten,
125 default,
126 skip_serializing_if = "::std::collections::HashMap::is_empty"
127 )]
128 pub additional_properties: ::std::collections::HashMap<String, ::serde_json::Value>,
129}
130#[derive(Clone, Debug, :: serde :: Serialize, :: serde :: Deserialize, Default)]
131pub struct PutParams {
132 #[serde(skip_serializing_if = "Option::is_none", default)]
133 #[doc = "Comment"]
134 #[doc = ""]
135 pub comment: Option<String>,
136 #[serde(skip_serializing_if = "::std::vec::Vec::is_empty", default)]
137 #[doc = "A list of settings you want to delete."]
138 #[doc = ""]
139 pub delete: Vec<String>,
140 #[serde(skip_serializing_if = "Option::is_none", default)]
141 #[doc = "Prevent changes if current configuration file has a different digest. This can be used to prevent concurrent modifications."]
142 #[doc = ""]
143 pub digest: Option<DigestStr>,
144 #[serde(
145 serialize_with = "crate::types::serialize_bool_optional",
146 deserialize_with = "crate::types::deserialize_bool_optional"
147 )]
148 #[serde(skip_serializing_if = "Option::is_none", default)]
149 #[doc = "Disable this matcher"]
150 #[doc = ""]
151 pub disable: Option<bool>,
152 #[serde(rename = "invert-match")]
153 #[serde(
154 serialize_with = "crate::types::serialize_bool_optional",
155 deserialize_with = "crate::types::deserialize_bool_optional"
156 )]
157 #[serde(skip_serializing_if = "Option::is_none", default)]
158 #[doc = "Invert match of the whole matcher"]
159 #[doc = ""]
160 pub invert_match: Option<bool>,
161 #[serde(rename = "match-calendar")]
162 #[serde(skip_serializing_if = "::std::vec::Vec::is_empty", default)]
163 #[doc = "Match notification timestamp"]
164 #[doc = ""]
165 pub match_calendar: Vec<String>,
166 #[serde(rename = "match-field")]
167 #[serde(skip_serializing_if = "::std::vec::Vec::is_empty", default)]
168 #[doc = "Metadata fields to match (regex or exact match). Must be in the form (regex|exact):\\\\<field\\\\>=\\\\<value\\\\>"]
169 #[doc = ""]
170 pub match_field: Vec<String>,
171 #[serde(rename = "match-severity")]
172 #[serde(skip_serializing_if = "::std::vec::Vec::is_empty", default)]
173 #[doc = "Notification severities to match"]
174 #[doc = ""]
175 pub match_severity: Vec<String>,
176 #[serde(skip_serializing_if = "Option::is_none", default)]
177 #[doc = "Choose between 'all' and 'any' for when multiple properties are specified"]
178 #[doc = ""]
179 pub mode: Option<Mode>,
180 #[serde(skip_serializing_if = "::std::vec::Vec::is_empty", default)]
181 #[doc = "Targets to notify on match"]
182 #[doc = ""]
183 pub target: Vec<String>,
184 #[serde(
185 flatten,
186 default,
187 skip_serializing_if = "::std::collections::HashMap::is_empty"
188 )]
189 pub additional_properties: ::std::collections::HashMap<String, ::serde_json::Value>,
190}
191#[derive(Clone, Debug, :: serde :: Serialize, :: serde :: Deserialize, PartialEq, Default)]
192#[doc = "Choose between 'all' and 'any' for when multiple properties are specified"]
193#[doc = ""]
194pub enum Mode {
195 #[serde(rename = "all")]
196 #[default]
197 All,
198 #[serde(rename = "any")]
199 Any,
200}
201impl TryFrom<&str> for Mode {
202 type Error = String;
203 fn try_from(value: &str) -> Result<Self, <Self as TryFrom<&str>>::Error> {
204 match value {
205 "all" => Ok(Self::All),
206 "any" => Ok(Self::Any),
207 v => Err(format!("Unknown variant {v}")),
208 }
209 }
210}
211#[derive(Debug, Clone, PartialEq, PartialOrd)]
212pub struct DigestStr {
213 value: String,
214}
215impl crate::types::bounded_string::BoundedString for DigestStr {
216 const MIN_LENGTH: Option<usize> = None::<usize>;
217 const MAX_LENGTH: Option<usize> = Some(64usize);
218 const DEFAULT: Option<&'static str> = None::<&'static str>;
219 const PATTERN: Option<&'static str> = None::<&'static str>;
220 const TYPE_DESCRIPTION: &'static str = "a string with length at most 64";
221 fn get_value(&self) -> &str {
222 &self.value
223 }
224 fn new(value: String) -> Result<Self, crate::types::bounded_string::BoundedStringError> {
225 Self::validate(&value)?;
226 Ok(Self { value })
227 }
228}
229impl std::convert::TryFrom<String> for DigestStr {
230 type Error = crate::types::bounded_string::BoundedStringError;
231 fn try_from(value: String) -> Result<Self, Self::Error> {
232 crate::types::bounded_string::BoundedString::new(value)
233 }
234}
235impl ::serde::Serialize for DigestStr {
236 fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
237 where
238 S: ::serde::Serializer,
239 {
240 crate::types::bounded_string::serialize_bounded_string(self, serializer)
241 }
242}
243impl<'de> ::serde::Deserialize<'de> for DigestStr {
244 fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
245 where
246 D: ::serde::Deserializer<'de>,
247 {
248 crate::types::bounded_string::deserialize_bounded_string(deserializer)
249 }
250}