Skip to main content

proxmox_api/generated/cluster/sdn/
vnets.rs

1pub mod vnet;
2#[derive(Debug, Clone)]
3pub struct VnetsClient<T> {
4    client: T,
5    path: String,
6}
7impl<T> VnetsClient<T>
8where
9    T: crate::client::Client,
10{
11    pub fn new(client: T, parent_path: &str) -> Self {
12        Self {
13            client,
14            path: format!("{}{}", parent_path, "/vnets"),
15        }
16    }
17}
18impl<T> VnetsClient<T>
19where
20    T: crate::client::Client,
21{
22    #[doc = "SDN vnets index."]
23    #[doc = ""]
24    #[doc = "Only list entries where you have 'SDN.Audit' or 'SDN.Allocate' permissions on '/sdn/zones/\\<zone\\>/\\<vnet\\>'"]
25    pub async fn get(&self, params: GetParams) -> Result<Vec<GetOutputItems>, T::Error> {
26        let path = self.path.to_string();
27        let optional_vec: Option<Vec<GetOutputItems>> = self.client.get(&path, &params).await?;
28        Ok(optional_vec.unwrap_or_default())
29    }
30}
31impl<T> VnetsClient<T>
32where
33    T: crate::client::Client,
34{
35    #[doc = "Create a new sdn vnet object."]
36    #[doc = ""]
37    #[doc = "Permission check: perm(\"/sdn/zones/{zone}\", [\"SDN.Allocate\"])"]
38    pub async fn post(&self, params: PostParams) -> Result<(), T::Error> {
39        let path = self.path.to_string();
40        self.client.post(&path, &params).await
41    }
42}
43impl GetOutputItems {
44    pub fn new(ty: Type, vnet: String) -> Self {
45        Self {
46            ty,
47            vnet,
48            alias: ::std::default::Default::default(),
49            digest: ::std::default::Default::default(),
50            isolate_ports: ::std::default::Default::default(),
51            pending: ::std::default::Default::default(),
52            state: ::std::default::Default::default(),
53            tag: ::std::default::Default::default(),
54            vlanaware: ::std::default::Default::default(),
55            zone: ::std::default::Default::default(),
56            additional_properties: ::std::default::Default::default(),
57        }
58    }
59}
60#[derive(Clone, Debug, :: serde :: Serialize, :: serde :: Deserialize)]
61pub struct GetOutputItems {
62    #[serde(skip_serializing_if = "Option::is_none", default)]
63    #[doc = "Alias name of the VNet."]
64    #[doc = ""]
65    pub alias: Option<AliasStr>,
66    #[serde(skip_serializing_if = "Option::is_none", default)]
67    #[doc = "Digest of the VNet section."]
68    #[doc = ""]
69    pub digest: Option<String>,
70    #[serde(rename = "isolate-ports")]
71    #[serde(
72        serialize_with = "crate::types::serialize_bool_optional",
73        deserialize_with = "crate::types::deserialize_bool_optional"
74    )]
75    #[serde(skip_serializing_if = "Option::is_none", default)]
76    #[doc = "If true, sets the isolated property for all interfaces on the bridge of this VNet."]
77    #[doc = ""]
78    pub isolate_ports: Option<bool>,
79    #[serde(skip_serializing_if = "Option::is_none", default)]
80    #[doc = "Changes that have not yet been applied to the running configuration."]
81    #[doc = ""]
82    pub pending: Option<PendingGetOutputItemsPending>,
83    #[serde(skip_serializing_if = "Option::is_none", default)]
84    #[doc = "State of the SDN configuration object."]
85    #[doc = ""]
86    pub state: Option<State>,
87    #[serde(skip_serializing_if = "Option::is_none", default)]
88    #[doc = "VLAN Tag (for VLAN or QinQ zones) or VXLAN VNI (for VXLAN or EVPN zones)."]
89    #[doc = ""]
90    pub tag: Option<TagInt>,
91    #[serde(rename = "type")]
92    #[doc = "Type of the VNet."]
93    #[doc = ""]
94    pub ty: Type,
95    #[serde(
96        serialize_with = "crate::types::serialize_bool_optional",
97        deserialize_with = "crate::types::deserialize_bool_optional"
98    )]
99    #[serde(skip_serializing_if = "Option::is_none", default)]
100    #[doc = "Allow VLANs to pass through this VNet."]
101    #[doc = ""]
102    pub vlanaware: Option<bool>,
103    #[doc = "Name of the VNet."]
104    #[doc = ""]
105    pub vnet: String,
106    #[serde(skip_serializing_if = "Option::is_none", default)]
107    #[doc = "Name of the zone this VNet belongs to."]
108    #[doc = ""]
109    pub zone: Option<String>,
110    #[serde(
111        flatten,
112        default,
113        skip_serializing_if = "::std::collections::HashMap::is_empty"
114    )]
115    pub additional_properties: ::std::collections::HashMap<String, ::serde_json::Value>,
116}
117#[derive(Clone, Debug, :: serde :: Serialize, :: serde :: Deserialize, Default)]
118pub struct GetParams {
119    #[serde(
120        serialize_with = "crate::types::serialize_bool_optional",
121        deserialize_with = "crate::types::deserialize_bool_optional"
122    )]
123    #[serde(skip_serializing_if = "Option::is_none", default)]
124    #[doc = "Display pending config."]
125    #[doc = ""]
126    pub pending: Option<bool>,
127    #[serde(
128        serialize_with = "crate::types::serialize_bool_optional",
129        deserialize_with = "crate::types::deserialize_bool_optional"
130    )]
131    #[serde(skip_serializing_if = "Option::is_none", default)]
132    #[doc = "Display running config."]
133    #[doc = ""]
134    pub running: Option<bool>,
135    #[serde(
136        flatten,
137        default,
138        skip_serializing_if = "::std::collections::HashMap::is_empty"
139    )]
140    pub additional_properties: ::std::collections::HashMap<String, ::serde_json::Value>,
141}
142#[derive(Clone, Debug, :: serde :: Serialize, :: serde :: Deserialize, Default)]
143pub struct PendingGetOutputItemsPending {
144    #[serde(skip_serializing_if = "Option::is_none", default)]
145    #[doc = "Alias name of the VNet."]
146    #[doc = ""]
147    pub alias: Option<AliasStr>,
148    #[serde(rename = "isolate-ports")]
149    #[serde(
150        serialize_with = "crate::types::serialize_bool_optional",
151        deserialize_with = "crate::types::deserialize_bool_optional"
152    )]
153    #[serde(skip_serializing_if = "Option::is_none", default)]
154    #[doc = "If true, sets the isolated property for all interfaces on the bridge of this VNet."]
155    #[doc = ""]
156    pub isolate_ports: Option<bool>,
157    #[serde(skip_serializing_if = "Option::is_none", default)]
158    #[doc = "VLAN Tag (for VLAN or QinQ zones) or VXLAN VNI (for VXLAN or EVPN zones)."]
159    #[doc = ""]
160    pub tag: Option<TagInt>,
161    #[serde(
162        serialize_with = "crate::types::serialize_bool_optional",
163        deserialize_with = "crate::types::deserialize_bool_optional"
164    )]
165    #[serde(skip_serializing_if = "Option::is_none", default)]
166    #[doc = "Allow VLANs to pass through this VNet."]
167    #[doc = ""]
168    pub vlanaware: Option<bool>,
169    #[serde(skip_serializing_if = "Option::is_none", default)]
170    #[doc = "Name of the zone this VNet belongs to."]
171    #[doc = ""]
172    pub zone: Option<String>,
173    #[serde(
174        flatten,
175        default,
176        skip_serializing_if = "::std::collections::HashMap::is_empty"
177    )]
178    pub additional_properties: ::std::collections::HashMap<String, ::serde_json::Value>,
179}
180impl PostParams {
181    pub fn new(vnet: String, zone: String) -> Self {
182        Self {
183            vnet,
184            zone,
185            alias: ::std::default::Default::default(),
186            isolate_ports: ::std::default::Default::default(),
187            lock_token: ::std::default::Default::default(),
188            tag: ::std::default::Default::default(),
189            ty: ::std::default::Default::default(),
190            vlanaware: ::std::default::Default::default(),
191            additional_properties: ::std::default::Default::default(),
192        }
193    }
194}
195#[derive(Clone, Debug, :: serde :: Serialize, :: serde :: Deserialize)]
196pub struct PostParams {
197    #[serde(skip_serializing_if = "Option::is_none", default)]
198    #[doc = "Alias name of the VNet."]
199    #[doc = ""]
200    pub alias: Option<AliasStr>,
201    #[serde(rename = "isolate-ports")]
202    #[serde(
203        serialize_with = "crate::types::serialize_bool_optional",
204        deserialize_with = "crate::types::deserialize_bool_optional"
205    )]
206    #[serde(skip_serializing_if = "Option::is_none", default)]
207    #[doc = "If true, sets the isolated property for all interfaces on the bridge of this VNet."]
208    #[doc = ""]
209    pub isolate_ports: Option<bool>,
210    #[serde(rename = "lock-token")]
211    #[serde(skip_serializing_if = "Option::is_none", default)]
212    #[doc = "the token for unlocking the global SDN configuration"]
213    #[doc = ""]
214    pub lock_token: Option<String>,
215    #[serde(skip_serializing_if = "Option::is_none", default)]
216    #[doc = "VLAN Tag (for VLAN or QinQ zones) or VXLAN VNI (for VXLAN or EVPN zones)."]
217    #[doc = ""]
218    pub tag: Option<TagInt>,
219    #[serde(rename = "type")]
220    #[serde(skip_serializing_if = "Option::is_none", default)]
221    #[doc = "Type of the VNet."]
222    #[doc = ""]
223    pub ty: Option<Type>,
224    #[serde(
225        serialize_with = "crate::types::serialize_bool_optional",
226        deserialize_with = "crate::types::deserialize_bool_optional"
227    )]
228    #[serde(skip_serializing_if = "Option::is_none", default)]
229    #[doc = "Allow VLANs to pass through this vnet."]
230    #[doc = ""]
231    pub vlanaware: Option<bool>,
232    #[doc = "The SDN vnet object identifier."]
233    #[doc = ""]
234    pub vnet: String,
235    #[doc = "Name of the zone this VNet belongs to."]
236    #[doc = ""]
237    pub zone: String,
238    #[serde(
239        flatten,
240        default,
241        skip_serializing_if = "::std::collections::HashMap::is_empty"
242    )]
243    pub additional_properties: ::std::collections::HashMap<String, ::serde_json::Value>,
244}
245#[derive(Clone, Debug, :: serde :: Serialize, :: serde :: Deserialize, PartialEq)]
246#[doc = "State of the SDN configuration object."]
247#[doc = ""]
248pub enum State {
249    #[serde(rename = "changed")]
250    Changed,
251    #[serde(rename = "deleted")]
252    Deleted,
253    #[serde(rename = "new")]
254    New,
255}
256impl TryFrom<&str> for State {
257    type Error = String;
258    fn try_from(value: &str) -> Result<Self, <Self as TryFrom<&str>>::Error> {
259        match value {
260            "changed" => Ok(Self::Changed),
261            "deleted" => Ok(Self::Deleted),
262            "new" => Ok(Self::New),
263            v => Err(format!("Unknown variant {v}")),
264        }
265    }
266}
267#[derive(Clone, Debug, :: serde :: Serialize, :: serde :: Deserialize, PartialEq)]
268#[doc = "Type of the VNet."]
269#[doc = ""]
270pub enum Type {
271    #[serde(rename = "vnet")]
272    Vnet,
273}
274impl TryFrom<&str> for Type {
275    type Error = String;
276    fn try_from(value: &str) -> Result<Self, <Self as TryFrom<&str>>::Error> {
277        match value {
278            "vnet" => Ok(Self::Vnet),
279            v => Err(format!("Unknown variant {v}")),
280        }
281    }
282}
283#[derive(Debug, Clone, Copy, PartialEq, PartialOrd)]
284pub struct TagInt(i128);
285impl crate::types::bounded_integer::BoundedInteger for TagInt {
286    const MIN: Option<i128> = Some(1i128);
287    const MAX: Option<i128> = Some(16777215i128);
288    const DEFAULT: Option<i128> = None::<i128>;
289    const TYPE_DESCRIPTION: &'static str = "an integer between 1 and 16777215";
290    fn get(&self) -> i128 {
291        self.0
292    }
293    fn new(value: i128) -> Result<Self, crate::types::bounded_integer::BoundedIntegerError> {
294        Self::validate(value)?;
295        Ok(Self(value))
296    }
297}
298impl std::convert::TryFrom<i128> for TagInt {
299    type Error = crate::types::bounded_integer::BoundedIntegerError;
300    fn try_from(value: i128) -> Result<Self, Self::Error> {
301        crate::types::bounded_integer::BoundedInteger::new(value)
302    }
303}
304impl ::serde::Serialize for TagInt {
305    fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
306    where
307        S: ::serde::Serializer,
308    {
309        crate::types::bounded_integer::serialize_bounded_integer(self, serializer)
310    }
311}
312impl<'de> ::serde::Deserialize<'de> for TagInt {
313    fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
314    where
315        D: ::serde::Deserializer<'de>,
316    {
317        crate::types::bounded_integer::deserialize_bounded_integer(deserializer)
318    }
319}
320#[derive(Debug, Clone, PartialEq, PartialOrd)]
321pub struct AliasStr {
322    value: String,
323}
324impl crate::types::bounded_string::BoundedString for AliasStr {
325    const MIN_LENGTH: Option<usize> = None::<usize>;
326    const MAX_LENGTH: Option<usize> = Some(256usize);
327    const DEFAULT: Option<&'static str> = None::<&'static str>;
328    const PATTERN: Option<&'static str> = Some("(?^i:[\\(\\)-_.\\w\\d\\s]{0,256})");
329    const TYPE_DESCRIPTION: &'static str =
330        "a string with pattern r\"(?^i:[\\(\\)-_.\\w\\d\\s]{0,256})\" and length at most 256";
331    fn get_value(&self) -> &str {
332        &self.value
333    }
334    fn new(value: String) -> Result<Self, crate::types::bounded_string::BoundedStringError> {
335        Self::validate(&value)?;
336        Ok(Self { value })
337    }
338}
339impl std::convert::TryFrom<String> for AliasStr {
340    type Error = crate::types::bounded_string::BoundedStringError;
341    fn try_from(value: String) -> Result<Self, Self::Error> {
342        crate::types::bounded_string::BoundedString::new(value)
343    }
344}
345impl ::serde::Serialize for AliasStr {
346    fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
347    where
348        S: ::serde::Serializer,
349    {
350        crate::types::bounded_string::serialize_bounded_string(self, serializer)
351    }
352}
353impl<'de> ::serde::Deserialize<'de> for AliasStr {
354    fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
355    where
356        D: ::serde::Deserializer<'de>,
357    {
358        crate::types::bounded_string::deserialize_bounded_string(deserializer)
359    }
360}
361impl<T> VnetsClient<T>
362where
363    T: crate::client::Client,
364{
365    pub fn vnet(&self, vnet: &str) -> vnet::VnetClient<T> {
366        vnet::VnetClient::<T>::new(self.client.clone(), &self.path, vnet)
367    }
368}