Skip to main content

proxmox_api/generated/cluster/firewall/rules/
pos.rs

1#[derive(Debug, Clone)]
2pub struct PosClient<T> {
3    client: T,
4    path: String,
5}
6impl<T> PosClient<T>
7where
8    T: crate::client::Client,
9{
10    pub fn new(client: T, parent_path: &str, pos: &str) -> Self {
11        Self {
12            client,
13            path: format!("{}/{}", parent_path, pos),
14        }
15    }
16}
17impl<T> PosClient<T>
18where
19    T: crate::client::Client,
20{
21    #[doc = "Delete rule."]
22    #[doc = ""]
23    #[doc = "Permission check: perm(\"/\", [\"Sys.Modify\"])"]
24    pub async fn delete(&self, params: DeleteParams) -> Result<(), T::Error> {
25        let path = self.path.to_string();
26        self.client.delete(&path, &params).await
27    }
28}
29impl<T> PosClient<T>
30where
31    T: crate::client::Client,
32{
33    #[doc = "Get single rule data."]
34    #[doc = ""]
35    #[doc = "Permission check: perm(\"/\", [\"Sys.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> PosClient<T>
42where
43    T: crate::client::Client,
44{
45    #[doc = "Modify rule data."]
46    #[doc = ""]
47    #[doc = "Permission check: perm(\"/\", [\"Sys.Modify\"])"]
48    pub async fn put(&self, params: PutParams) -> Result<(), T::Error> {
49        let path = self.path.to_string();
50        self.client.put(&path, &params).await
51    }
52}
53#[derive(Clone, Debug, :: serde :: Serialize, :: serde :: Deserialize, Default)]
54pub struct DeleteParams {
55    #[serde(skip_serializing_if = "Option::is_none", default)]
56    #[doc = "Prevent changes if current configuration file has a different digest. This can be used to prevent concurrent modifications."]
57    #[doc = ""]
58    pub digest: Option<DigestStr>,
59    #[serde(
60        flatten,
61        default,
62        skip_serializing_if = "::std::collections::HashMap::is_empty"
63    )]
64    pub additional_properties: ::std::collections::HashMap<String, ::serde_json::Value>,
65}
66impl GetOutput {
67    pub fn new(action: String, pos: i64, ty: String) -> Self {
68        Self {
69            action,
70            pos,
71            ty,
72            comment: ::std::default::Default::default(),
73            dest: ::std::default::Default::default(),
74            dport: ::std::default::Default::default(),
75            enable: ::std::default::Default::default(),
76            icmp_type: ::std::default::Default::default(),
77            iface: ::std::default::Default::default(),
78            ipversion: ::std::default::Default::default(),
79            log: ::std::default::Default::default(),
80            macro_def: ::std::default::Default::default(),
81            proto: ::std::default::Default::default(),
82            source: ::std::default::Default::default(),
83            sport: ::std::default::Default::default(),
84            additional_properties: ::std::default::Default::default(),
85        }
86    }
87}
88#[derive(Clone, Debug, :: serde :: Serialize, :: serde :: Deserialize)]
89pub struct GetOutput {
90    #[doc = "Rule action ('ACCEPT', 'DROP', 'REJECT') or security group name"]
91    #[doc = ""]
92    pub action: String,
93    #[serde(skip_serializing_if = "Option::is_none", default)]
94    #[doc = "Descriptive comment"]
95    #[doc = ""]
96    pub comment: Option<String>,
97    #[serde(skip_serializing_if = "Option::is_none", default)]
98    #[doc = "Restrict packet destination address"]
99    #[doc = ""]
100    pub dest: Option<String>,
101    #[serde(skip_serializing_if = "Option::is_none", default)]
102    #[doc = "Restrict TCP/UDP destination port"]
103    #[doc = ""]
104    pub dport: Option<String>,
105    #[serde(
106        serialize_with = "crate::types::serialize_int_optional",
107        deserialize_with = "crate::types::deserialize_int_optional"
108    )]
109    #[serde(skip_serializing_if = "Option::is_none", default)]
110    #[doc = "Flag to enable/disable a rule"]
111    #[doc = ""]
112    pub enable: Option<i64>,
113    #[serde(rename = "icmp-type")]
114    #[serde(skip_serializing_if = "Option::is_none", default)]
115    #[doc = "Specify icmp-type. Only valid if proto equals 'icmp' or 'icmpv6'/'ipv6-icmp'"]
116    #[doc = ""]
117    pub icmp_type: Option<String>,
118    #[serde(skip_serializing_if = "Option::is_none", default)]
119    #[doc = "Network interface name. You have to use network configuration key names for VMs and containers"]
120    #[doc = ""]
121    pub iface: Option<String>,
122    #[serde(
123        serialize_with = "crate::types::serialize_int_optional",
124        deserialize_with = "crate::types::deserialize_int_optional"
125    )]
126    #[serde(skip_serializing_if = "Option::is_none", default)]
127    #[doc = "IP version (4 or 6) - automatically determined from source/dest addresses"]
128    #[doc = ""]
129    pub ipversion: Option<i64>,
130    #[serde(skip_serializing_if = "Option::is_none", default)]
131    #[doc = "Log level for firewall rule"]
132    #[doc = ""]
133    pub log: Option<Log>,
134    #[serde(rename = "macro")]
135    #[serde(skip_serializing_if = "Option::is_none", default)]
136    #[doc = "Use predefined standard macro"]
137    #[doc = ""]
138    pub macro_def: Option<String>,
139    #[serde(
140        serialize_with = "crate::types::serialize_int",
141        deserialize_with = "crate::types::deserialize_int"
142    )]
143    #[doc = "Rule position in the ruleset"]
144    #[doc = ""]
145    pub pos: i64,
146    #[serde(skip_serializing_if = "Option::is_none", default)]
147    #[doc = "IP protocol. You can use protocol names ('tcp'/'udp') or simple numbers, as defined in '/etc/protocols'"]
148    #[doc = ""]
149    pub proto: Option<String>,
150    #[serde(skip_serializing_if = "Option::is_none", default)]
151    #[doc = "Restrict packet source address"]
152    #[doc = ""]
153    pub source: Option<String>,
154    #[serde(skip_serializing_if = "Option::is_none", default)]
155    #[doc = "Restrict TCP/UDP source port"]
156    #[doc = ""]
157    pub sport: Option<String>,
158    #[serde(rename = "type")]
159    #[doc = "Rule type"]
160    #[doc = ""]
161    pub ty: String,
162    #[serde(
163        flatten,
164        default,
165        skip_serializing_if = "::std::collections::HashMap::is_empty"
166    )]
167    pub additional_properties: ::std::collections::HashMap<String, ::serde_json::Value>,
168}
169#[derive(Clone, Debug, :: serde :: Serialize, :: serde :: Deserialize, Default)]
170pub struct PutParams {
171    #[serde(skip_serializing_if = "Option::is_none", default)]
172    #[doc = "Rule action ('ACCEPT', 'DROP', 'REJECT') or security group name."]
173    #[doc = ""]
174    pub action: Option<ActionStr>,
175    #[serde(skip_serializing_if = "Option::is_none", default)]
176    #[doc = "Descriptive comment."]
177    #[doc = ""]
178    pub comment: Option<String>,
179    #[serde(skip_serializing_if = "Option::is_none", default)]
180    #[doc = "A list of settings you want to delete."]
181    #[doc = ""]
182    pub delete: Option<String>,
183    #[serde(skip_serializing_if = "Option::is_none", default)]
184    #[doc = "Restrict packet destination address. This can refer to a single IP address, an IP set ('+ipsetname') or an IP alias definition. You can also specify an address range like '20.34.101.207-201.3.9.99', or a list of IP addresses and networks (entries are separated by comma). Please do not mix IPv4 and IPv6 addresses inside such lists."]
185    #[doc = ""]
186    pub dest: Option<DestStr>,
187    #[serde(skip_serializing_if = "Option::is_none", default)]
188    #[doc = "Prevent changes if current configuration file has a different digest. This can be used to prevent concurrent modifications."]
189    #[doc = ""]
190    pub digest: Option<DigestStr>,
191    #[serde(skip_serializing_if = "Option::is_none", default)]
192    #[doc = "Restrict TCP/UDP destination port. You can use service names or simple numbers (0-65535), as defined in '/etc/services'. Port ranges can be specified with '\\d+:\\d+', for example '80:85', and you can use comma separated list to match several ports or ranges."]
193    #[doc = ""]
194    pub dport: Option<String>,
195    #[serde(
196        serialize_with = "crate::types::serialize_unsigned_int_optional",
197        deserialize_with = "crate::types::deserialize_unsigned_int_optional"
198    )]
199    #[serde(skip_serializing_if = "Option::is_none", default)]
200    #[doc = "Flag to enable/disable a rule."]
201    #[doc = ""]
202    pub enable: Option<u64>,
203    #[serde(rename = "icmp-type")]
204    #[serde(skip_serializing_if = "Option::is_none", default)]
205    #[doc = "Specify icmp-type. Only valid if proto equals 'icmp' or 'icmpv6'/'ipv6-icmp'."]
206    #[doc = ""]
207    pub icmp_type: Option<String>,
208    #[serde(skip_serializing_if = "Option::is_none", default)]
209    #[doc = "Network interface name. You have to use network configuration key names for VMs and containers ('net\\d+'). Host related rules can use arbitrary strings."]
210    #[doc = ""]
211    pub iface: Option<IfaceStr>,
212    #[serde(skip_serializing_if = "Option::is_none", default)]
213    #[doc = "Log level for firewall rule."]
214    #[doc = ""]
215    pub log: Option<Log>,
216    #[serde(rename = "macro")]
217    #[serde(skip_serializing_if = "Option::is_none", default)]
218    #[doc = "Use predefined standard macro."]
219    #[doc = ""]
220    pub macro_def: Option<MacroStr>,
221    #[serde(
222        serialize_with = "crate::types::serialize_unsigned_int_optional",
223        deserialize_with = "crate::types::deserialize_unsigned_int_optional"
224    )]
225    #[serde(skip_serializing_if = "Option::is_none", default)]
226    #[doc = "Move rule to new position \\\\<moveto\\\\>. Other arguments are ignored."]
227    #[doc = ""]
228    pub moveto: Option<u64>,
229    #[serde(skip_serializing_if = "Option::is_none", default)]
230    #[doc = "IP protocol. You can use protocol names ('tcp'/'udp') or simple numbers, as defined in '/etc/protocols'."]
231    #[doc = ""]
232    pub proto: Option<String>,
233    #[serde(skip_serializing_if = "Option::is_none", default)]
234    #[doc = "Restrict packet source address. This can refer to a single IP address, an IP set ('+ipsetname') or an IP alias definition. You can also specify an address range like '20.34.101.207-201.3.9.99', or a list of IP addresses and networks (entries are separated by comma). Please do not mix IPv4 and IPv6 addresses inside such lists."]
235    #[doc = ""]
236    pub source: Option<SourceStr>,
237    #[serde(skip_serializing_if = "Option::is_none", default)]
238    #[doc = "Restrict TCP/UDP source port. You can use service names or simple numbers (0-65535), as defined in '/etc/services'. Port ranges can be specified with '\\d+:\\d+', for example '80:85', and you can use comma separated list to match several ports or ranges."]
239    #[doc = ""]
240    pub sport: Option<String>,
241    #[serde(rename = "type")]
242    #[serde(skip_serializing_if = "Option::is_none", default)]
243    #[doc = "Rule type."]
244    #[doc = ""]
245    pub ty: Option<Type>,
246    #[serde(
247        flatten,
248        default,
249        skip_serializing_if = "::std::collections::HashMap::is_empty"
250    )]
251    pub additional_properties: ::std::collections::HashMap<String, ::serde_json::Value>,
252}
253#[derive(Clone, Debug, :: serde :: Serialize, :: serde :: Deserialize, PartialEq)]
254#[doc = "Log level for firewall rule"]
255#[doc = ""]
256pub enum Log {
257    #[serde(rename = "alert")]
258    Alert,
259    #[serde(rename = "crit")]
260    Crit,
261    #[serde(rename = "debug")]
262    Debug,
263    #[serde(rename = "emerg")]
264    Emerg,
265    #[serde(rename = "err")]
266    Err,
267    #[serde(rename = "info")]
268    Info,
269    #[serde(rename = "nolog")]
270    Nolog,
271    #[serde(rename = "notice")]
272    Notice,
273    #[serde(rename = "warning")]
274    Warning,
275}
276impl TryFrom<&str> for Log {
277    type Error = String;
278    fn try_from(value: &str) -> Result<Self, <Self as TryFrom<&str>>::Error> {
279        match value {
280            "alert" => Ok(Self::Alert),
281            "crit" => Ok(Self::Crit),
282            "debug" => Ok(Self::Debug),
283            "emerg" => Ok(Self::Emerg),
284            "err" => Ok(Self::Err),
285            "info" => Ok(Self::Info),
286            "nolog" => Ok(Self::Nolog),
287            "notice" => Ok(Self::Notice),
288            "warning" => Ok(Self::Warning),
289            v => Err(format!("Unknown variant {v}")),
290        }
291    }
292}
293#[derive(Clone, Debug, :: serde :: Serialize, :: serde :: Deserialize, PartialEq)]
294#[doc = "Rule type."]
295#[doc = ""]
296pub enum Type {
297    #[serde(rename = "forward")]
298    Forward,
299    #[serde(rename = "group")]
300    Group,
301    #[serde(rename = "in")]
302    In,
303    #[serde(rename = "out")]
304    Out,
305}
306impl TryFrom<&str> for Type {
307    type Error = String;
308    fn try_from(value: &str) -> Result<Self, <Self as TryFrom<&str>>::Error> {
309        match value {
310            "forward" => Ok(Self::Forward),
311            "group" => Ok(Self::Group),
312            "in" => Ok(Self::In),
313            "out" => Ok(Self::Out),
314            v => Err(format!("Unknown variant {v}")),
315        }
316    }
317}
318#[derive(Debug, Clone, PartialEq, PartialOrd)]
319pub struct ActionStr {
320    value: String,
321}
322impl crate::types::bounded_string::BoundedString for ActionStr {
323    const MIN_LENGTH: Option<usize> = Some(2usize);
324    const MAX_LENGTH: Option<usize> = Some(20usize);
325    const DEFAULT: Option<&'static str> = None::<&'static str>;
326    const PATTERN: Option<&'static str> = Some("[A-Za-z][A-Za-z0-9\\-\\_]+");
327    const TYPE_DESCRIPTION: &'static str =
328        "a string with pattern r\"[A-Za-z][A-Za-z0-9\\-\\_]+\" and length between 2 and 20";
329    fn get_value(&self) -> &str {
330        &self.value
331    }
332    fn new(value: String) -> Result<Self, crate::types::bounded_string::BoundedStringError> {
333        Self::validate(&value)?;
334        Ok(Self { value })
335    }
336}
337impl std::convert::TryFrom<String> for ActionStr {
338    type Error = crate::types::bounded_string::BoundedStringError;
339    fn try_from(value: String) -> Result<Self, Self::Error> {
340        crate::types::bounded_string::BoundedString::new(value)
341    }
342}
343impl ::serde::Serialize for ActionStr {
344    fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
345    where
346        S: ::serde::Serializer,
347    {
348        crate::types::bounded_string::serialize_bounded_string(self, serializer)
349    }
350}
351impl<'de> ::serde::Deserialize<'de> for ActionStr {
352    fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
353    where
354        D: ::serde::Deserializer<'de>,
355    {
356        crate::types::bounded_string::deserialize_bounded_string(deserializer)
357    }
358}
359#[derive(Debug, Clone, PartialEq, PartialOrd)]
360pub struct DestStr {
361    value: String,
362}
363impl crate::types::bounded_string::BoundedString for DestStr {
364    const MIN_LENGTH: Option<usize> = None::<usize>;
365    const MAX_LENGTH: Option<usize> = Some(512usize);
366    const DEFAULT: Option<&'static str> = None::<&'static str>;
367    const PATTERN: Option<&'static str> = None::<&'static str>;
368    const TYPE_DESCRIPTION: &'static str = "a string with length at most 512";
369    fn get_value(&self) -> &str {
370        &self.value
371    }
372    fn new(value: String) -> Result<Self, crate::types::bounded_string::BoundedStringError> {
373        Self::validate(&value)?;
374        Ok(Self { value })
375    }
376}
377impl std::convert::TryFrom<String> for DestStr {
378    type Error = crate::types::bounded_string::BoundedStringError;
379    fn try_from(value: String) -> Result<Self, Self::Error> {
380        crate::types::bounded_string::BoundedString::new(value)
381    }
382}
383impl ::serde::Serialize for DestStr {
384    fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
385    where
386        S: ::serde::Serializer,
387    {
388        crate::types::bounded_string::serialize_bounded_string(self, serializer)
389    }
390}
391impl<'de> ::serde::Deserialize<'de> for DestStr {
392    fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
393    where
394        D: ::serde::Deserializer<'de>,
395    {
396        crate::types::bounded_string::deserialize_bounded_string(deserializer)
397    }
398}
399#[derive(Debug, Clone, PartialEq, PartialOrd)]
400pub struct DigestStr {
401    value: String,
402}
403impl crate::types::bounded_string::BoundedString for DigestStr {
404    const MIN_LENGTH: Option<usize> = None::<usize>;
405    const MAX_LENGTH: Option<usize> = Some(64usize);
406    const DEFAULT: Option<&'static str> = None::<&'static str>;
407    const PATTERN: Option<&'static str> = None::<&'static str>;
408    const TYPE_DESCRIPTION: &'static str = "a string with length at most 64";
409    fn get_value(&self) -> &str {
410        &self.value
411    }
412    fn new(value: String) -> Result<Self, crate::types::bounded_string::BoundedStringError> {
413        Self::validate(&value)?;
414        Ok(Self { value })
415    }
416}
417impl std::convert::TryFrom<String> for DigestStr {
418    type Error = crate::types::bounded_string::BoundedStringError;
419    fn try_from(value: String) -> Result<Self, Self::Error> {
420        crate::types::bounded_string::BoundedString::new(value)
421    }
422}
423impl ::serde::Serialize for DigestStr {
424    fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
425    where
426        S: ::serde::Serializer,
427    {
428        crate::types::bounded_string::serialize_bounded_string(self, serializer)
429    }
430}
431impl<'de> ::serde::Deserialize<'de> for DigestStr {
432    fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
433    where
434        D: ::serde::Deserializer<'de>,
435    {
436        crate::types::bounded_string::deserialize_bounded_string(deserializer)
437    }
438}
439#[derive(Debug, Clone, PartialEq, PartialOrd)]
440pub struct IfaceStr {
441    value: String,
442}
443impl crate::types::bounded_string::BoundedString for IfaceStr {
444    const MIN_LENGTH: Option<usize> = Some(2usize);
445    const MAX_LENGTH: Option<usize> = Some(20usize);
446    const DEFAULT: Option<&'static str> = None::<&'static str>;
447    const PATTERN: Option<&'static str> = None::<&'static str>;
448    const TYPE_DESCRIPTION: &'static str = "a string with length between 2 and 20";
449    fn get_value(&self) -> &str {
450        &self.value
451    }
452    fn new(value: String) -> Result<Self, crate::types::bounded_string::BoundedStringError> {
453        Self::validate(&value)?;
454        Ok(Self { value })
455    }
456}
457impl std::convert::TryFrom<String> for IfaceStr {
458    type Error = crate::types::bounded_string::BoundedStringError;
459    fn try_from(value: String) -> Result<Self, Self::Error> {
460        crate::types::bounded_string::BoundedString::new(value)
461    }
462}
463impl ::serde::Serialize for IfaceStr {
464    fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
465    where
466        S: ::serde::Serializer,
467    {
468        crate::types::bounded_string::serialize_bounded_string(self, serializer)
469    }
470}
471impl<'de> ::serde::Deserialize<'de> for IfaceStr {
472    fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
473    where
474        D: ::serde::Deserializer<'de>,
475    {
476        crate::types::bounded_string::deserialize_bounded_string(deserializer)
477    }
478}
479#[derive(Debug, Clone, PartialEq, PartialOrd)]
480pub struct MacroStr {
481    value: String,
482}
483impl crate::types::bounded_string::BoundedString for MacroStr {
484    const MIN_LENGTH: Option<usize> = None::<usize>;
485    const MAX_LENGTH: Option<usize> = Some(128usize);
486    const DEFAULT: Option<&'static str> = None::<&'static str>;
487    const PATTERN: Option<&'static str> = None::<&'static str>;
488    const TYPE_DESCRIPTION: &'static str = "a string with length at most 128";
489    fn get_value(&self) -> &str {
490        &self.value
491    }
492    fn new(value: String) -> Result<Self, crate::types::bounded_string::BoundedStringError> {
493        Self::validate(&value)?;
494        Ok(Self { value })
495    }
496}
497impl std::convert::TryFrom<String> for MacroStr {
498    type Error = crate::types::bounded_string::BoundedStringError;
499    fn try_from(value: String) -> Result<Self, Self::Error> {
500        crate::types::bounded_string::BoundedString::new(value)
501    }
502}
503impl ::serde::Serialize for MacroStr {
504    fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
505    where
506        S: ::serde::Serializer,
507    {
508        crate::types::bounded_string::serialize_bounded_string(self, serializer)
509    }
510}
511impl<'de> ::serde::Deserialize<'de> for MacroStr {
512    fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
513    where
514        D: ::serde::Deserializer<'de>,
515    {
516        crate::types::bounded_string::deserialize_bounded_string(deserializer)
517    }
518}
519#[derive(Debug, Clone, PartialEq, PartialOrd)]
520pub struct SourceStr {
521    value: String,
522}
523impl crate::types::bounded_string::BoundedString for SourceStr {
524    const MIN_LENGTH: Option<usize> = None::<usize>;
525    const MAX_LENGTH: Option<usize> = Some(512usize);
526    const DEFAULT: Option<&'static str> = None::<&'static str>;
527    const PATTERN: Option<&'static str> = None::<&'static str>;
528    const TYPE_DESCRIPTION: &'static str = "a string with length at most 512";
529    fn get_value(&self) -> &str {
530        &self.value
531    }
532    fn new(value: String) -> Result<Self, crate::types::bounded_string::BoundedStringError> {
533        Self::validate(&value)?;
534        Ok(Self { value })
535    }
536}
537impl std::convert::TryFrom<String> for SourceStr {
538    type Error = crate::types::bounded_string::BoundedStringError;
539    fn try_from(value: String) -> Result<Self, Self::Error> {
540        crate::types::bounded_string::BoundedString::new(value)
541    }
542}
543impl ::serde::Serialize for SourceStr {
544    fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
545    where
546        S: ::serde::Serializer,
547    {
548        crate::types::bounded_string::serialize_bounded_string(self, serializer)
549    }
550}
551impl<'de> ::serde::Deserialize<'de> for SourceStr {
552    fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
553    where
554        D: ::serde::Deserializer<'de>,
555    {
556        crate::types::bounded_string::deserialize_bounded_string(deserializer)
557    }
558}