Skip to main content

proxmox_api/generated/cluster/sdn/fabrics/
fabric.rs

1pub mod id;
2#[derive(Debug, Clone)]
3pub struct FabricClient<T> {
4    client: T,
5    path: String,
6}
7impl<T> FabricClient<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, "/fabric"),
15        }
16    }
17}
18impl<T> FabricClient<T>
19where
20    T: crate::client::Client,
21{
22    #[doc = "SDN Fabrics Index"]
23    #[doc = ""]
24    #[doc = "Only list entries where you have 'SDN.Audit' or 'SDN.Allocate' permissions on '/sdn/fabrics/\\<fabric\\>'"]
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> FabricClient<T>
32where
33    T: crate::client::Client,
34{
35    #[doc = "Add a fabric"]
36    #[doc = ""]
37    #[doc = "Permission check: perm(\"/sdn/fabrics\", [\"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(id: String, protocol: Protocol) -> Self {
45        Self {
46            id,
47            protocol,
48            area: ::std::default::Default::default(),
49            csnp_interval: ::std::default::Default::default(),
50            digest: ::std::default::Default::default(),
51            hello_interval: ::std::default::Default::default(),
52            ip6_prefix: ::std::default::Default::default(),
53            ip_prefix: ::std::default::Default::default(),
54            lock_token: ::std::default::Default::default(),
55            additional_properties: ::std::default::Default::default(),
56        }
57    }
58}
59#[derive(Clone, Debug, :: serde :: Serialize, :: serde :: Deserialize)]
60pub struct GetOutputItems {
61    #[serde(skip_serializing_if = "Option::is_none", default)]
62    #[doc = "OSPF area. Either a IPv4 address or a 32-bit number. Gets validated in rust."]
63    #[doc = ""]
64    pub area: Option<String>,
65    #[serde(skip_serializing_if = "Option::is_none", default)]
66    #[doc = "The csnp_interval property for Openfabric"]
67    #[doc = ""]
68    pub csnp_interval: Option<CsnpIntervalNum>,
69    #[serde(skip_serializing_if = "Option::is_none", default)]
70    #[doc = "Prevent changes if current configuration file has a different digest. This can be used to prevent concurrent modifications."]
71    #[doc = ""]
72    pub digest: Option<DigestStr>,
73    #[serde(skip_serializing_if = "Option::is_none", default)]
74    #[doc = "The hello_interval property for Openfabric"]
75    #[doc = ""]
76    pub hello_interval: Option<HelloIntervalNum>,
77    #[doc = "Identifier for SDN fabrics"]
78    #[doc = ""]
79    pub id: String,
80    #[serde(skip_serializing_if = "Option::is_none", default)]
81    #[doc = "The IP prefix for Node IPs"]
82    #[doc = ""]
83    pub ip6_prefix: Option<String>,
84    #[serde(skip_serializing_if = "Option::is_none", default)]
85    #[doc = "The IP prefix for Node IPs"]
86    #[doc = ""]
87    pub ip_prefix: Option<String>,
88    #[serde(rename = "lock-token")]
89    #[serde(skip_serializing_if = "Option::is_none", default)]
90    #[doc = "the token for unlocking the global SDN configuration"]
91    #[doc = ""]
92    pub lock_token: Option<String>,
93    #[doc = "Type of configuration entry in an SDN Fabric section config"]
94    #[doc = ""]
95    pub protocol: Protocol,
96    #[serde(
97        flatten,
98        default,
99        skip_serializing_if = "::std::collections::HashMap::is_empty"
100    )]
101    pub additional_properties: ::std::collections::HashMap<String, ::serde_json::Value>,
102}
103#[derive(Clone, Debug, :: serde :: Serialize, :: serde :: Deserialize, Default)]
104pub struct GetParams {
105    #[serde(
106        serialize_with = "crate::types::serialize_bool_optional",
107        deserialize_with = "crate::types::deserialize_bool_optional"
108    )]
109    #[serde(skip_serializing_if = "Option::is_none", default)]
110    #[doc = "Display pending config."]
111    #[doc = ""]
112    pub pending: Option<bool>,
113    #[serde(
114        serialize_with = "crate::types::serialize_bool_optional",
115        deserialize_with = "crate::types::deserialize_bool_optional"
116    )]
117    #[serde(skip_serializing_if = "Option::is_none", default)]
118    #[doc = "Display running config."]
119    #[doc = ""]
120    pub running: Option<bool>,
121    #[serde(
122        flatten,
123        default,
124        skip_serializing_if = "::std::collections::HashMap::is_empty"
125    )]
126    pub additional_properties: ::std::collections::HashMap<String, ::serde_json::Value>,
127}
128impl PostParams {
129    pub fn new(id: String, protocol: Protocol) -> Self {
130        Self {
131            id,
132            protocol,
133            area: ::std::default::Default::default(),
134            csnp_interval: ::std::default::Default::default(),
135            digest: ::std::default::Default::default(),
136            hello_interval: ::std::default::Default::default(),
137            ip6_prefix: ::std::default::Default::default(),
138            ip_prefix: ::std::default::Default::default(),
139            lock_token: ::std::default::Default::default(),
140            additional_properties: ::std::default::Default::default(),
141        }
142    }
143}
144#[derive(Clone, Debug, :: serde :: Serialize, :: serde :: Deserialize)]
145pub struct PostParams {
146    #[serde(skip_serializing_if = "Option::is_none", default)]
147    #[doc = "OSPF area. Either a IPv4 address or a 32-bit number. Gets validated in rust."]
148    #[doc = ""]
149    pub area: Option<String>,
150    #[serde(skip_serializing_if = "Option::is_none", default)]
151    #[doc = "The csnp_interval property for Openfabric"]
152    #[doc = ""]
153    pub csnp_interval: Option<CsnpIntervalNum>,
154    #[serde(skip_serializing_if = "Option::is_none", default)]
155    #[doc = "Prevent changes if current configuration file has a different digest. This can be used to prevent concurrent modifications."]
156    #[doc = ""]
157    pub digest: Option<DigestStr>,
158    #[serde(skip_serializing_if = "Option::is_none", default)]
159    #[doc = "The hello_interval property for Openfabric"]
160    #[doc = ""]
161    pub hello_interval: Option<HelloIntervalNum>,
162    #[doc = "Identifier for SDN fabrics"]
163    #[doc = ""]
164    pub id: String,
165    #[serde(skip_serializing_if = "Option::is_none", default)]
166    #[doc = "The IP prefix for Node IPs"]
167    #[doc = ""]
168    pub ip6_prefix: Option<String>,
169    #[serde(skip_serializing_if = "Option::is_none", default)]
170    #[doc = "The IP prefix for Node IPs"]
171    #[doc = ""]
172    pub ip_prefix: Option<String>,
173    #[serde(rename = "lock-token")]
174    #[serde(skip_serializing_if = "Option::is_none", default)]
175    #[doc = "the token for unlocking the global SDN configuration"]
176    #[doc = ""]
177    pub lock_token: Option<String>,
178    #[doc = "Type of configuration entry in an SDN Fabric section config"]
179    #[doc = ""]
180    pub protocol: Protocol,
181    #[serde(
182        flatten,
183        default,
184        skip_serializing_if = "::std::collections::HashMap::is_empty"
185    )]
186    pub additional_properties: ::std::collections::HashMap<String, ::serde_json::Value>,
187}
188#[derive(Clone, Debug, :: serde :: Serialize, :: serde :: Deserialize, PartialEq)]
189#[doc = "Type of configuration entry in an SDN Fabric section config"]
190#[doc = ""]
191pub enum Protocol {
192    #[serde(rename = "openfabric")]
193    Openfabric,
194    #[serde(rename = "ospf")]
195    Ospf,
196}
197impl TryFrom<&str> for Protocol {
198    type Error = String;
199    fn try_from(value: &str) -> Result<Self, <Self as TryFrom<&str>>::Error> {
200        match value {
201            "openfabric" => Ok(Self::Openfabric),
202            "ospf" => Ok(Self::Ospf),
203            v => Err(format!("Unknown variant {v}")),
204        }
205    }
206}
207#[derive(Debug, Clone, Copy, PartialEq, PartialOrd)]
208pub struct CsnpIntervalNum(f64);
209impl crate::types::bounded_number::BoundedNumber for CsnpIntervalNum {
210    const MIN: Option<f64> = Some(1f64);
211    const MAX: Option<f64> = Some(600f64);
212    const DEFAULT: Option<f64> = None::<f64>;
213    const TYPE_DESCRIPTION: &'static str = "an number between 1 and 600";
214    fn get(&self) -> f64 {
215        self.0
216    }
217    fn new(value: f64) -> Result<Self, crate::types::bounded_number::BoundedNumberError> {
218        Self::validate(value)?;
219        Ok(Self(value))
220    }
221}
222impl std::convert::TryFrom<f64> for CsnpIntervalNum {
223    type Error = crate::types::bounded_number::BoundedNumberError;
224    fn try_from(value: f64) -> Result<Self, Self::Error> {
225        crate::types::bounded_number::BoundedNumber::new(value)
226    }
227}
228impl std::convert::TryFrom<f32> for CsnpIntervalNum {
229    type Error = crate::types::bounded_number::BoundedNumberError;
230    fn try_from(value: f32) -> Result<Self, Self::Error> {
231        crate::types::bounded_number::BoundedNumber::new(value as f64)
232    }
233}
234impl std::convert::TryFrom<i32> for CsnpIntervalNum {
235    type Error = crate::types::bounded_number::BoundedNumberError;
236    fn try_from(value: i32) -> Result<Self, Self::Error> {
237        crate::types::bounded_number::BoundedNumber::new(value as f64)
238    }
239}
240impl std::convert::TryFrom<i64> for CsnpIntervalNum {
241    type Error = crate::types::bounded_number::BoundedNumberError;
242    fn try_from(value: i64) -> Result<Self, Self::Error> {
243        crate::types::bounded_number::BoundedNumber::new(value as f64)
244    }
245}
246impl ::serde::Serialize for CsnpIntervalNum {
247    fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
248    where
249        S: ::serde::Serializer,
250    {
251        crate::types::bounded_number::serialize_bounded_number(self, serializer)
252    }
253}
254impl<'de> ::serde::Deserialize<'de> for CsnpIntervalNum {
255    fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
256    where
257        D: ::serde::Deserializer<'de>,
258    {
259        crate::types::bounded_number::deserialize_bounded_number(deserializer)
260    }
261}
262#[derive(Debug, Clone, Copy, PartialEq, PartialOrd)]
263pub struct HelloIntervalNum(f64);
264impl crate::types::bounded_number::BoundedNumber for HelloIntervalNum {
265    const MIN: Option<f64> = Some(1f64);
266    const MAX: Option<f64> = Some(600f64);
267    const DEFAULT: Option<f64> = None::<f64>;
268    const TYPE_DESCRIPTION: &'static str = "an number between 1 and 600";
269    fn get(&self) -> f64 {
270        self.0
271    }
272    fn new(value: f64) -> Result<Self, crate::types::bounded_number::BoundedNumberError> {
273        Self::validate(value)?;
274        Ok(Self(value))
275    }
276}
277impl std::convert::TryFrom<f64> for HelloIntervalNum {
278    type Error = crate::types::bounded_number::BoundedNumberError;
279    fn try_from(value: f64) -> Result<Self, Self::Error> {
280        crate::types::bounded_number::BoundedNumber::new(value)
281    }
282}
283impl std::convert::TryFrom<f32> for HelloIntervalNum {
284    type Error = crate::types::bounded_number::BoundedNumberError;
285    fn try_from(value: f32) -> Result<Self, Self::Error> {
286        crate::types::bounded_number::BoundedNumber::new(value as f64)
287    }
288}
289impl std::convert::TryFrom<i32> for HelloIntervalNum {
290    type Error = crate::types::bounded_number::BoundedNumberError;
291    fn try_from(value: i32) -> Result<Self, Self::Error> {
292        crate::types::bounded_number::BoundedNumber::new(value as f64)
293    }
294}
295impl std::convert::TryFrom<i64> for HelloIntervalNum {
296    type Error = crate::types::bounded_number::BoundedNumberError;
297    fn try_from(value: i64) -> Result<Self, Self::Error> {
298        crate::types::bounded_number::BoundedNumber::new(value as f64)
299    }
300}
301impl ::serde::Serialize for HelloIntervalNum {
302    fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
303    where
304        S: ::serde::Serializer,
305    {
306        crate::types::bounded_number::serialize_bounded_number(self, serializer)
307    }
308}
309impl<'de> ::serde::Deserialize<'de> for HelloIntervalNum {
310    fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
311    where
312        D: ::serde::Deserializer<'de>,
313    {
314        crate::types::bounded_number::deserialize_bounded_number(deserializer)
315    }
316}
317#[derive(Debug, Clone, PartialEq, PartialOrd)]
318pub struct DigestStr {
319    value: String,
320}
321impl crate::types::bounded_string::BoundedString for DigestStr {
322    const MIN_LENGTH: Option<usize> = None::<usize>;
323    const MAX_LENGTH: Option<usize> = Some(64usize);
324    const DEFAULT: Option<&'static str> = None::<&'static str>;
325    const PATTERN: Option<&'static str> = None::<&'static str>;
326    const TYPE_DESCRIPTION: &'static str = "a string with length at most 64";
327    fn get_value(&self) -> &str {
328        &self.value
329    }
330    fn new(value: String) -> Result<Self, crate::types::bounded_string::BoundedStringError> {
331        Self::validate(&value)?;
332        Ok(Self { value })
333    }
334}
335impl std::convert::TryFrom<String> for DigestStr {
336    type Error = crate::types::bounded_string::BoundedStringError;
337    fn try_from(value: String) -> Result<Self, Self::Error> {
338        crate::types::bounded_string::BoundedString::new(value)
339    }
340}
341impl ::serde::Serialize for DigestStr {
342    fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
343    where
344        S: ::serde::Serializer,
345    {
346        crate::types::bounded_string::serialize_bounded_string(self, serializer)
347    }
348}
349impl<'de> ::serde::Deserialize<'de> for DigestStr {
350    fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
351    where
352        D: ::serde::Deserializer<'de>,
353    {
354        crate::types::bounded_string::deserialize_bounded_string(deserializer)
355    }
356}
357impl<T> FabricClient<T>
358where
359    T: crate::client::Client,
360{
361    pub fn id(&self, id: &str) -> id::IdClient<T> {
362        id::IdClient::<T>::new(self.client.clone(), &self.path, id)
363    }
364}