proxmox_api/generated/nodes/node/firewall/
rules.rs

1pub mod pos;
2pub struct RulesClient<T> {
3    client: T,
4    path: String,
5}
6impl<T> RulesClient<T>
7where
8    T: crate::client::Client,
9{
10    pub fn new(client: T, parent_path: &str) -> Self {
11        Self {
12            client,
13            path: format!("{}{}", parent_path, "/rules"),
14        }
15    }
16}
17impl<T> RulesClient<T>
18where
19    T: crate::client::Client,
20{
21    #[doc = "List rules."]
22    pub fn get(&self) -> Result<Vec<GetOutputItems>, T::Error> {
23        let path = self.path.to_string();
24        self.client.get(&path, &())
25    }
26}
27impl<T> RulesClient<T>
28where
29    T: crate::client::Client,
30{
31    #[doc = "Create new rule."]
32    pub fn post(&self, params: PostParams) -> Result<(), T::Error> {
33        let path = self.path.to_string();
34        self.client.post(&path, &params)
35    }
36}
37impl GetOutputItems {
38    pub fn new(pos: u64) -> Self {
39        Self {
40            pos,
41            additional_properties: Default::default(),
42        }
43    }
44}
45#[derive(Clone, Debug, :: serde :: Serialize, :: serde :: Deserialize)]
46pub struct GetOutputItems {
47    #[serde(
48        serialize_with = "crate::types::serialize_int",
49        deserialize_with = "crate::types::deserialize_int"
50    )]
51    pub pos: u64,
52    #[serde(
53        flatten,
54        default,
55        skip_serializing_if = "::std::collections::HashMap::is_empty"
56    )]
57    pub additional_properties: ::std::collections::HashMap<String, ::serde_json::Value>,
58}
59impl PostParams {
60    pub fn new(action: String, ty: Type) -> Self {
61        Self {
62            action,
63            ty,
64            comment: Default::default(),
65            dest: Default::default(),
66            digest: Default::default(),
67            dport: Default::default(),
68            enable: Default::default(),
69            icmp_type: Default::default(),
70            iface: Default::default(),
71            log: Default::default(),
72            macro_def: Default::default(),
73            pos: Default::default(),
74            proto: Default::default(),
75            source: Default::default(),
76            sport: Default::default(),
77            additional_properties: Default::default(),
78        }
79    }
80}
81#[derive(Clone, Debug, :: serde :: Serialize, :: serde :: Deserialize)]
82pub struct PostParams {
83    #[doc = "Rule action ('ACCEPT', 'DROP', 'REJECT') or security group name."]
84    pub action: String,
85    #[serde(skip_serializing_if = "Option::is_none", default)]
86    #[doc = "Descriptive comment."]
87    pub comment: Option<String>,
88    #[serde(skip_serializing_if = "Option::is_none", default)]
89    #[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."]
90    pub dest: Option<String>,
91    #[serde(skip_serializing_if = "Option::is_none", default)]
92    #[doc = "Prevent changes if current configuration file has a different digest. This can be used to prevent concurrent modifications."]
93    pub digest: Option<String>,
94    #[serde(skip_serializing_if = "Option::is_none", default)]
95    #[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."]
96    pub dport: Option<String>,
97    #[serde(
98        serialize_with = "crate::types::serialize_int_optional",
99        deserialize_with = "crate::types::deserialize_int_optional"
100    )]
101    #[serde(skip_serializing_if = "Option::is_none", default)]
102    #[doc = "Flag to enable/disable a rule."]
103    pub enable: Option<u64>,
104    #[serde(rename = "icmp-type")]
105    #[serde(skip_serializing_if = "Option::is_none", default)]
106    #[doc = "Specify icmp-type. Only valid if proto equals 'icmp' or 'icmpv6'/'ipv6-icmp'."]
107    pub icmp_type: Option<String>,
108    #[serde(skip_serializing_if = "Option::is_none", default)]
109    #[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."]
110    pub iface: Option<String>,
111    #[serde(skip_serializing_if = "Option::is_none", default)]
112    #[doc = "Log level for firewall rule."]
113    pub log: Option<Log>,
114    #[serde(rename = "macro")]
115    #[serde(skip_serializing_if = "Option::is_none", default)]
116    #[doc = "Use predefined standard macro."]
117    pub macro_def: Option<String>,
118    #[serde(
119        serialize_with = "crate::types::serialize_int_optional",
120        deserialize_with = "crate::types::deserialize_int_optional"
121    )]
122    #[serde(skip_serializing_if = "Option::is_none", default)]
123    #[doc = "Update rule at position \\<pos\\>."]
124    pub pos: Option<u64>,
125    #[serde(skip_serializing_if = "Option::is_none", default)]
126    #[doc = "IP protocol. You can use protocol names ('tcp'/'udp') or simple numbers, as defined in '/etc/protocols'."]
127    pub proto: Option<String>,
128    #[serde(skip_serializing_if = "Option::is_none", default)]
129    #[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."]
130    pub source: Option<String>,
131    #[serde(skip_serializing_if = "Option::is_none", default)]
132    #[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."]
133    pub sport: Option<String>,
134    #[serde(rename = "type")]
135    #[doc = "Rule type."]
136    pub ty: Type,
137    #[serde(
138        flatten,
139        default,
140        skip_serializing_if = "::std::collections::HashMap::is_empty"
141    )]
142    pub additional_properties: ::std::collections::HashMap<String, ::serde_json::Value>,
143}
144#[derive(Clone, Debug, :: serde :: Serialize, :: serde :: Deserialize)]
145pub enum Log {
146    #[serde(rename = "alert")]
147    Alert,
148    #[serde(rename = "crit")]
149    Crit,
150    #[serde(rename = "debug")]
151    Debug,
152    #[serde(rename = "emerg")]
153    Emerg,
154    #[serde(rename = "err")]
155    Err,
156    #[serde(rename = "info")]
157    Info,
158    #[serde(rename = "nolog")]
159    Nolog,
160    #[serde(rename = "notice")]
161    Notice,
162    #[serde(rename = "warning")]
163    Warning,
164}
165#[derive(Clone, Debug, :: serde :: Serialize, :: serde :: Deserialize)]
166pub enum Type {
167    #[serde(rename = "group")]
168    Group,
169    #[serde(rename = "in")]
170    In,
171    #[serde(rename = "out")]
172    Out,
173}
174impl<T> RulesClient<T>
175where
176    T: crate::client::Client,
177{
178    pub fn pos(&self, pos: &str) -> pos::PosClient<T> {
179        pos::PosClient::<T>::new(self.client.clone(), &self.path, pos)
180    }
181}