Skip to main content

proxmox_api/generated/nodes/node/lxc/vmid/firewall/
options.rs

1#[derive(Debug, Clone)]
2pub struct OptionsClient<T> {
3    client: T,
4    path: String,
5}
6impl<T> OptionsClient<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, "/options"),
14        }
15    }
16}
17impl<T> OptionsClient<T>
18where
19    T: crate::client::Client,
20{
21    #[doc = "Get VM firewall options."]
22    #[doc = ""]
23    #[doc = "Permission check: perm(\"/vms/{vmid}\", [\"VM.Audit\"])"]
24    pub async fn get(&self) -> Result<GetOutput, T::Error> {
25        let path = self.path.to_string();
26        self.client.get(&path, &()).await
27    }
28}
29impl<T> OptionsClient<T>
30where
31    T: crate::client::Client,
32{
33    #[doc = "Set Firewall options."]
34    #[doc = ""]
35    #[doc = "Permission check: perm(\"/vms/{vmid}\", [\"VM.Config.Network\"])"]
36    pub async fn put(&self, params: PutParams) -> Result<(), T::Error> {
37        let path = self.path.to_string();
38        self.client.put(&path, &params).await
39    }
40}
41#[derive(Clone, Debug, :: serde :: Serialize, :: serde :: Deserialize, Default)]
42pub struct GetOutput {
43    #[serde(
44        serialize_with = "crate::types::serialize_bool_optional",
45        deserialize_with = "crate::types::deserialize_bool_optional"
46    )]
47    #[serde(skip_serializing_if = "Option::is_none", default)]
48    #[doc = "Enable DHCP."]
49    #[doc = ""]
50    pub dhcp: Option<bool>,
51    #[serde(
52        serialize_with = "crate::types::serialize_bool_optional",
53        deserialize_with = "crate::types::deserialize_bool_optional"
54    )]
55    #[serde(skip_serializing_if = "Option::is_none", default)]
56    #[doc = "Enable/disable firewall rules."]
57    #[doc = ""]
58    pub enable: Option<bool>,
59    #[serde(
60        serialize_with = "crate::types::serialize_bool_optional",
61        deserialize_with = "crate::types::deserialize_bool_optional"
62    )]
63    #[serde(skip_serializing_if = "Option::is_none", default)]
64    #[doc = "Enable default IP filters. This is equivalent to adding an empty ipfilter-net\\\\<id\\\\> ipset for every interface. Such ipsets implicitly contain sane default restrictions such as restricting IPv6 link local addresses to the one derived from the interface's MAC address. For containers the configured IP addresses will be implicitly added."]
65    #[doc = ""]
66    pub ipfilter: Option<bool>,
67    #[serde(skip_serializing_if = "Option::is_none", default)]
68    #[doc = "Log level for incoming traffic."]
69    #[doc = ""]
70    pub log_level_in: Option<LogLevelIn>,
71    #[serde(skip_serializing_if = "Option::is_none", default)]
72    #[doc = "Log level for outgoing traffic."]
73    #[doc = ""]
74    pub log_level_out: Option<LogLevelOut>,
75    #[serde(
76        serialize_with = "crate::types::serialize_bool_optional",
77        deserialize_with = "crate::types::deserialize_bool_optional"
78    )]
79    #[serde(skip_serializing_if = "Option::is_none", default)]
80    #[doc = "Enable/disable MAC address filter."]
81    #[doc = ""]
82    pub macfilter: Option<bool>,
83    #[serde(
84        serialize_with = "crate::types::serialize_bool_optional",
85        deserialize_with = "crate::types::deserialize_bool_optional"
86    )]
87    #[serde(skip_serializing_if = "Option::is_none", default)]
88    #[doc = "Enable NDP (Neighbor Discovery Protocol)."]
89    #[doc = ""]
90    pub ndp: Option<bool>,
91    #[serde(skip_serializing_if = "Option::is_none", default)]
92    #[doc = "Input policy."]
93    #[doc = ""]
94    pub policy_in: Option<PolicyIn>,
95    #[serde(skip_serializing_if = "Option::is_none", default)]
96    #[doc = "Output policy."]
97    #[doc = ""]
98    pub policy_out: Option<PolicyOut>,
99    #[serde(
100        serialize_with = "crate::types::serialize_bool_optional",
101        deserialize_with = "crate::types::deserialize_bool_optional"
102    )]
103    #[serde(skip_serializing_if = "Option::is_none", default)]
104    #[doc = "Allow sending Router Advertisement."]
105    #[doc = ""]
106    pub radv: Option<bool>,
107    #[serde(
108        flatten,
109        default,
110        skip_serializing_if = "::std::collections::HashMap::is_empty"
111    )]
112    pub additional_properties: ::std::collections::HashMap<String, ::serde_json::Value>,
113}
114#[derive(Clone, Debug, :: serde :: Serialize, :: serde :: Deserialize, Default)]
115pub struct PutParams {
116    #[serde(skip_serializing_if = "Option::is_none", default)]
117    #[doc = "A list of settings you want to delete."]
118    #[doc = ""]
119    pub delete: Option<String>,
120    #[serde(
121        serialize_with = "crate::types::serialize_bool_optional",
122        deserialize_with = "crate::types::deserialize_bool_optional"
123    )]
124    #[serde(skip_serializing_if = "Option::is_none", default)]
125    #[doc = "Enable DHCP."]
126    #[doc = ""]
127    pub dhcp: Option<bool>,
128    #[serde(skip_serializing_if = "Option::is_none", default)]
129    #[doc = "Prevent changes if current configuration file has a different digest. This can be used to prevent concurrent modifications."]
130    #[doc = ""]
131    pub digest: Option<DigestStr>,
132    #[serde(
133        serialize_with = "crate::types::serialize_bool_optional",
134        deserialize_with = "crate::types::deserialize_bool_optional"
135    )]
136    #[serde(skip_serializing_if = "Option::is_none", default)]
137    #[doc = "Enable/disable firewall rules."]
138    #[doc = ""]
139    pub enable: Option<bool>,
140    #[serde(
141        serialize_with = "crate::types::serialize_bool_optional",
142        deserialize_with = "crate::types::deserialize_bool_optional"
143    )]
144    #[serde(skip_serializing_if = "Option::is_none", default)]
145    #[doc = "Enable default IP filters. This is equivalent to adding an empty ipfilter-net\\\\<id\\\\> ipset for every interface. Such ipsets implicitly contain sane default restrictions such as restricting IPv6 link local addresses to the one derived from the interface's MAC address. For containers the configured IP addresses will be implicitly added."]
146    #[doc = ""]
147    pub ipfilter: Option<bool>,
148    #[serde(skip_serializing_if = "Option::is_none", default)]
149    #[doc = "Log level for incoming traffic."]
150    #[doc = ""]
151    pub log_level_in: Option<LogLevelIn>,
152    #[serde(skip_serializing_if = "Option::is_none", default)]
153    #[doc = "Log level for outgoing traffic."]
154    #[doc = ""]
155    pub log_level_out: Option<LogLevelOut>,
156    #[serde(
157        serialize_with = "crate::types::serialize_bool_optional",
158        deserialize_with = "crate::types::deserialize_bool_optional"
159    )]
160    #[serde(skip_serializing_if = "Option::is_none", default)]
161    #[doc = "Enable/disable MAC address filter."]
162    #[doc = ""]
163    pub macfilter: Option<bool>,
164    #[serde(
165        serialize_with = "crate::types::serialize_bool_optional",
166        deserialize_with = "crate::types::deserialize_bool_optional"
167    )]
168    #[serde(skip_serializing_if = "Option::is_none", default)]
169    #[doc = "Enable NDP (Neighbor Discovery Protocol)."]
170    #[doc = ""]
171    pub ndp: Option<bool>,
172    #[serde(skip_serializing_if = "Option::is_none", default)]
173    #[doc = "Input policy."]
174    #[doc = ""]
175    pub policy_in: Option<PolicyIn>,
176    #[serde(skip_serializing_if = "Option::is_none", default)]
177    #[doc = "Output policy."]
178    #[doc = ""]
179    pub policy_out: Option<PolicyOut>,
180    #[serde(
181        serialize_with = "crate::types::serialize_bool_optional",
182        deserialize_with = "crate::types::deserialize_bool_optional"
183    )]
184    #[serde(skip_serializing_if = "Option::is_none", default)]
185    #[doc = "Allow sending Router Advertisement."]
186    #[doc = ""]
187    pub radv: Option<bool>,
188    #[serde(
189        flatten,
190        default,
191        skip_serializing_if = "::std::collections::HashMap::is_empty"
192    )]
193    pub additional_properties: ::std::collections::HashMap<String, ::serde_json::Value>,
194}
195#[derive(Clone, Debug, :: serde :: Serialize, :: serde :: Deserialize, PartialEq)]
196#[doc = "Log level for incoming traffic."]
197#[doc = ""]
198pub enum LogLevelIn {
199    #[serde(rename = "alert")]
200    Alert,
201    #[serde(rename = "crit")]
202    Crit,
203    #[serde(rename = "debug")]
204    Debug,
205    #[serde(rename = "emerg")]
206    Emerg,
207    #[serde(rename = "err")]
208    Err,
209    #[serde(rename = "info")]
210    Info,
211    #[serde(rename = "nolog")]
212    Nolog,
213    #[serde(rename = "notice")]
214    Notice,
215    #[serde(rename = "warning")]
216    Warning,
217}
218impl TryFrom<&str> for LogLevelIn {
219    type Error = String;
220    fn try_from(value: &str) -> Result<Self, <Self as TryFrom<&str>>::Error> {
221        match value {
222            "alert" => Ok(Self::Alert),
223            "crit" => Ok(Self::Crit),
224            "debug" => Ok(Self::Debug),
225            "emerg" => Ok(Self::Emerg),
226            "err" => Ok(Self::Err),
227            "info" => Ok(Self::Info),
228            "nolog" => Ok(Self::Nolog),
229            "notice" => Ok(Self::Notice),
230            "warning" => Ok(Self::Warning),
231            v => Err(format!("Unknown variant {v}")),
232        }
233    }
234}
235#[derive(Clone, Debug, :: serde :: Serialize, :: serde :: Deserialize, PartialEq)]
236#[doc = "Log level for outgoing traffic."]
237#[doc = ""]
238pub enum LogLevelOut {
239    #[serde(rename = "alert")]
240    Alert,
241    #[serde(rename = "crit")]
242    Crit,
243    #[serde(rename = "debug")]
244    Debug,
245    #[serde(rename = "emerg")]
246    Emerg,
247    #[serde(rename = "err")]
248    Err,
249    #[serde(rename = "info")]
250    Info,
251    #[serde(rename = "nolog")]
252    Nolog,
253    #[serde(rename = "notice")]
254    Notice,
255    #[serde(rename = "warning")]
256    Warning,
257}
258impl TryFrom<&str> for LogLevelOut {
259    type Error = String;
260    fn try_from(value: &str) -> Result<Self, <Self as TryFrom<&str>>::Error> {
261        match value {
262            "alert" => Ok(Self::Alert),
263            "crit" => Ok(Self::Crit),
264            "debug" => Ok(Self::Debug),
265            "emerg" => Ok(Self::Emerg),
266            "err" => Ok(Self::Err),
267            "info" => Ok(Self::Info),
268            "nolog" => Ok(Self::Nolog),
269            "notice" => Ok(Self::Notice),
270            "warning" => Ok(Self::Warning),
271            v => Err(format!("Unknown variant {v}")),
272        }
273    }
274}
275#[derive(Clone, Debug, :: serde :: Serialize, :: serde :: Deserialize, PartialEq)]
276#[doc = "Input policy."]
277#[doc = ""]
278pub enum PolicyIn {
279    ACCEPT,
280    DROP,
281    REJECT,
282}
283impl TryFrom<&str> for PolicyIn {
284    type Error = String;
285    fn try_from(value: &str) -> Result<Self, <Self as TryFrom<&str>>::Error> {
286        match value {
287            "ACCEPT" => Ok(Self::ACCEPT),
288            "DROP" => Ok(Self::DROP),
289            "REJECT" => Ok(Self::REJECT),
290            v => Err(format!("Unknown variant {v}")),
291        }
292    }
293}
294#[derive(Clone, Debug, :: serde :: Serialize, :: serde :: Deserialize, PartialEq)]
295#[doc = "Output policy."]
296#[doc = ""]
297pub enum PolicyOut {
298    ACCEPT,
299    DROP,
300    REJECT,
301}
302impl TryFrom<&str> for PolicyOut {
303    type Error = String;
304    fn try_from(value: &str) -> Result<Self, <Self as TryFrom<&str>>::Error> {
305        match value {
306            "ACCEPT" => Ok(Self::ACCEPT),
307            "DROP" => Ok(Self::DROP),
308            "REJECT" => Ok(Self::REJECT),
309            v => Err(format!("Unknown variant {v}")),
310        }
311    }
312}
313#[derive(Debug, Clone, PartialEq, PartialOrd)]
314pub struct DigestStr {
315    value: String,
316}
317impl crate::types::bounded_string::BoundedString for DigestStr {
318    const MIN_LENGTH: Option<usize> = None::<usize>;
319    const MAX_LENGTH: Option<usize> = Some(64usize);
320    const DEFAULT: Option<&'static str> = None::<&'static str>;
321    const PATTERN: Option<&'static str> = None::<&'static str>;
322    const TYPE_DESCRIPTION: &'static str = "a string with length at most 64";
323    fn get_value(&self) -> &str {
324        &self.value
325    }
326    fn new(value: String) -> Result<Self, crate::types::bounded_string::BoundedStringError> {
327        Self::validate(&value)?;
328        Ok(Self { value })
329    }
330}
331impl std::convert::TryFrom<String> for DigestStr {
332    type Error = crate::types::bounded_string::BoundedStringError;
333    fn try_from(value: String) -> Result<Self, Self::Error> {
334        crate::types::bounded_string::BoundedString::new(value)
335    }
336}
337impl ::serde::Serialize for DigestStr {
338    fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
339    where
340        S: ::serde::Serializer,
341    {
342        crate::types::bounded_string::serialize_bounded_string(self, serializer)
343    }
344}
345impl<'de> ::serde::Deserialize<'de> for DigestStr {
346    fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
347    where
348        D: ::serde::Deserializer<'de>,
349    {
350        crate::types::bounded_string::deserialize_bounded_string(deserializer)
351    }
352}