Skip to main content

proxmox_api/generated/cluster/sdn/vnets/vnet/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 vnet firewall options."]
22    #[doc = ""]
23    #[doc = "Needs SDN.Audit or SDN.Allocate permissions on '/sdn/zones/\\<zone\\>/\\<vnet\\>'"]
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 = "Needs SDN.Allocate permissions on '/sdn/zones/\\<zone\\>/\\<vnet\\>'"]
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/disable firewall rules."]
49    #[doc = ""]
50    pub enable: Option<bool>,
51    #[serde(skip_serializing_if = "Option::is_none", default)]
52    #[doc = "Log level for forwarded traffic."]
53    #[doc = ""]
54    pub log_level_forward: Option<LogLevelForward>,
55    #[serde(skip_serializing_if = "Option::is_none", default)]
56    #[doc = "Forward policy."]
57    #[doc = ""]
58    pub policy_forward: Option<PolicyForward>,
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}
66#[derive(Clone, Debug, :: serde :: Serialize, :: serde :: Deserialize, Default)]
67pub struct PutParams {
68    #[serde(skip_serializing_if = "Option::is_none", default)]
69    #[doc = "A list of settings you want to delete."]
70    #[doc = ""]
71    pub delete: Option<String>,
72    #[serde(skip_serializing_if = "Option::is_none", default)]
73    #[doc = "Prevent changes if current configuration file has a different digest. This can be used to prevent concurrent modifications."]
74    #[doc = ""]
75    pub digest: Option<DigestStr>,
76    #[serde(
77        serialize_with = "crate::types::serialize_bool_optional",
78        deserialize_with = "crate::types::deserialize_bool_optional"
79    )]
80    #[serde(skip_serializing_if = "Option::is_none", default)]
81    #[doc = "Enable/disable firewall rules."]
82    #[doc = ""]
83    pub enable: Option<bool>,
84    #[serde(skip_serializing_if = "Option::is_none", default)]
85    #[doc = "Log level for forwarded traffic."]
86    #[doc = ""]
87    pub log_level_forward: Option<LogLevelForward>,
88    #[serde(skip_serializing_if = "Option::is_none", default)]
89    #[doc = "Forward policy."]
90    #[doc = ""]
91    pub policy_forward: Option<PolicyForward>,
92    #[serde(
93        flatten,
94        default,
95        skip_serializing_if = "::std::collections::HashMap::is_empty"
96    )]
97    pub additional_properties: ::std::collections::HashMap<String, ::serde_json::Value>,
98}
99#[derive(Clone, Debug, :: serde :: Serialize, :: serde :: Deserialize, PartialEq)]
100#[doc = "Log level for forwarded traffic."]
101#[doc = ""]
102pub enum LogLevelForward {
103    #[serde(rename = "alert")]
104    Alert,
105    #[serde(rename = "crit")]
106    Crit,
107    #[serde(rename = "debug")]
108    Debug,
109    #[serde(rename = "emerg")]
110    Emerg,
111    #[serde(rename = "err")]
112    Err,
113    #[serde(rename = "info")]
114    Info,
115    #[serde(rename = "nolog")]
116    Nolog,
117    #[serde(rename = "notice")]
118    Notice,
119    #[serde(rename = "warning")]
120    Warning,
121}
122impl TryFrom<&str> for LogLevelForward {
123    type Error = String;
124    fn try_from(value: &str) -> Result<Self, <Self as TryFrom<&str>>::Error> {
125        match value {
126            "alert" => Ok(Self::Alert),
127            "crit" => Ok(Self::Crit),
128            "debug" => Ok(Self::Debug),
129            "emerg" => Ok(Self::Emerg),
130            "err" => Ok(Self::Err),
131            "info" => Ok(Self::Info),
132            "nolog" => Ok(Self::Nolog),
133            "notice" => Ok(Self::Notice),
134            "warning" => Ok(Self::Warning),
135            v => Err(format!("Unknown variant {v}")),
136        }
137    }
138}
139#[derive(Clone, Debug, :: serde :: Serialize, :: serde :: Deserialize, PartialEq)]
140#[doc = "Forward policy."]
141#[doc = ""]
142pub enum PolicyForward {
143    ACCEPT,
144    DROP,
145}
146impl TryFrom<&str> for PolicyForward {
147    type Error = String;
148    fn try_from(value: &str) -> Result<Self, <Self as TryFrom<&str>>::Error> {
149        match value {
150            "ACCEPT" => Ok(Self::ACCEPT),
151            "DROP" => Ok(Self::DROP),
152            v => Err(format!("Unknown variant {v}")),
153        }
154    }
155}
156#[derive(Debug, Clone, PartialEq, PartialOrd)]
157pub struct DigestStr {
158    value: String,
159}
160impl crate::types::bounded_string::BoundedString for DigestStr {
161    const MIN_LENGTH: Option<usize> = None::<usize>;
162    const MAX_LENGTH: Option<usize> = Some(64usize);
163    const DEFAULT: Option<&'static str> = None::<&'static str>;
164    const PATTERN: Option<&'static str> = None::<&'static str>;
165    const TYPE_DESCRIPTION: &'static str = "a string with length at most 64";
166    fn get_value(&self) -> &str {
167        &self.value
168    }
169    fn new(value: String) -> Result<Self, crate::types::bounded_string::BoundedStringError> {
170        Self::validate(&value)?;
171        Ok(Self { value })
172    }
173}
174impl std::convert::TryFrom<String> for DigestStr {
175    type Error = crate::types::bounded_string::BoundedStringError;
176    fn try_from(value: String) -> Result<Self, Self::Error> {
177        crate::types::bounded_string::BoundedString::new(value)
178    }
179}
180impl ::serde::Serialize for DigestStr {
181    fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
182    where
183        S: ::serde::Serializer,
184    {
185        crate::types::bounded_string::serialize_bounded_string(self, serializer)
186    }
187}
188impl<'de> ::serde::Deserialize<'de> for DigestStr {
189    fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
190    where
191        D: ::serde::Deserializer<'de>,
192    {
193        crate::types::bounded_string::deserialize_bounded_string(deserializer)
194    }
195}