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

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