Skip to main content

proxmox_api/generated/cluster/sdn/
controllers.rs

1pub mod controller;
2#[derive(Debug, Clone)]
3pub struct ControllersClient<T> {
4    client: T,
5    path: String,
6}
7impl<T> ControllersClient<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, "/controllers"),
15        }
16    }
17}
18impl<T> ControllersClient<T>
19where
20    T: crate::client::Client,
21{
22    #[doc = "SDN controllers index."]
23    #[doc = ""]
24    #[doc = "Only list entries where you have 'SDN.Audit' or 'SDN.Allocate' permissions on '/sdn/controllers/\\<controller\\>'"]
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> ControllersClient<T>
32where
33    T: crate::client::Client,
34{
35    #[doc = "Create a new sdn controller object."]
36    #[doc = ""]
37    #[doc = "Permission check: perm(\"/sdn/controllers\", [\"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(controller: String, ty: Type) -> Self {
45        Self {
46            controller,
47            ty,
48            asn: ::std::default::Default::default(),
49            bgp_multipath_as_relax: ::std::default::Default::default(),
50            digest: ::std::default::Default::default(),
51            ebgp: ::std::default::Default::default(),
52            ebgp_multihop: ::std::default::Default::default(),
53            isis_domain: ::std::default::Default::default(),
54            isis_ifaces: ::std::default::Default::default(),
55            isis_net: ::std::default::Default::default(),
56            loopback: ::std::default::Default::default(),
57            node: ::std::default::Default::default(),
58            peers: ::std::default::Default::default(),
59            pending: ::std::default::Default::default(),
60            state: ::std::default::Default::default(),
61            additional_properties: ::std::default::Default::default(),
62        }
63    }
64}
65#[derive(Clone, Debug, :: serde :: Serialize, :: serde :: Deserialize)]
66pub struct GetOutputItems {
67    #[serde(skip_serializing_if = "Option::is_none", default)]
68    #[doc = "The local ASN of the controller. BGP & EVPN only."]
69    #[doc = ""]
70    pub asn: Option<AsnInt>,
71    #[serde(rename = "bgp-multipath-as-relax")]
72    #[serde(
73        serialize_with = "crate::types::serialize_bool_optional",
74        deserialize_with = "crate::types::deserialize_bool_optional"
75    )]
76    #[serde(skip_serializing_if = "Option::is_none", default)]
77    #[doc = "Consider different AS paths of equal length for multipath computation. BGP only."]
78    #[doc = ""]
79    pub bgp_multipath_as_relax: Option<bool>,
80    #[doc = "Name of the controller."]
81    #[doc = ""]
82    pub controller: String,
83    #[serde(skip_serializing_if = "Option::is_none", default)]
84    #[doc = "Digest of the controller section."]
85    #[doc = ""]
86    pub digest: Option<String>,
87    #[serde(
88        serialize_with = "crate::types::serialize_bool_optional",
89        deserialize_with = "crate::types::deserialize_bool_optional"
90    )]
91    #[serde(skip_serializing_if = "Option::is_none", default)]
92    #[doc = "Enable eBGP (remote-as external). BGP only."]
93    #[doc = ""]
94    pub ebgp: Option<bool>,
95    #[serde(rename = "ebgp-multihop")]
96    #[serde(
97        serialize_with = "crate::types::serialize_int_optional",
98        deserialize_with = "crate::types::deserialize_int_optional"
99    )]
100    #[serde(skip_serializing_if = "Option::is_none", default)]
101    #[doc = "Set maximum amount of hops for eBGP peers. Needs ebgp set to 1. BGP only."]
102    #[doc = ""]
103    pub ebgp_multihop: Option<i64>,
104    #[serde(rename = "isis-domain")]
105    #[serde(skip_serializing_if = "Option::is_none", default)]
106    #[doc = "Name of the IS-IS domain. IS-IS only."]
107    #[doc = ""]
108    pub isis_domain: Option<String>,
109    #[serde(rename = "isis-ifaces")]
110    #[serde(skip_serializing_if = "Option::is_none", default)]
111    #[doc = "Comma-separated list of interfaces where IS-IS should be active. IS-IS only."]
112    #[doc = ""]
113    pub isis_ifaces: Option<String>,
114    #[serde(rename = "isis-net")]
115    #[serde(skip_serializing_if = "Option::is_none", default)]
116    #[doc = "Network Entity title for this node in the IS-IS network. IS-IS only."]
117    #[doc = ""]
118    pub isis_net: Option<String>,
119    #[serde(skip_serializing_if = "Option::is_none", default)]
120    #[doc = "Name of the loopback/dummy interface that provides the Router-IP. BGP only."]
121    #[doc = ""]
122    pub loopback: Option<String>,
123    #[serde(skip_serializing_if = "Option::is_none", default)]
124    #[doc = "Node(s) where this controller is active."]
125    #[doc = ""]
126    pub node: Option<String>,
127    #[serde(skip_serializing_if = "Option::is_none", default)]
128    #[doc = "Comma-separated list of the peers IP addresses."]
129    #[doc = ""]
130    pub peers: Option<String>,
131    #[serde(skip_serializing_if = "Option::is_none", default)]
132    #[doc = "Changes that have not yet been applied to the running configuration."]
133    #[doc = ""]
134    pub pending: Option<PendingGetOutputItemsPending>,
135    #[serde(skip_serializing_if = "Option::is_none", default)]
136    #[doc = "State of the SDN configuration object."]
137    #[doc = ""]
138    pub state: Option<State>,
139    #[serde(rename = "type")]
140    #[doc = "Type of the controller"]
141    #[doc = ""]
142    pub ty: Type,
143    #[serde(
144        flatten,
145        default,
146        skip_serializing_if = "::std::collections::HashMap::is_empty"
147    )]
148    pub additional_properties: ::std::collections::HashMap<String, ::serde_json::Value>,
149}
150#[derive(Clone, Debug, :: serde :: Serialize, :: serde :: Deserialize, Default)]
151pub struct GetParams {
152    #[serde(
153        serialize_with = "crate::types::serialize_bool_optional",
154        deserialize_with = "crate::types::deserialize_bool_optional"
155    )]
156    #[serde(skip_serializing_if = "Option::is_none", default)]
157    #[doc = "Display pending config."]
158    #[doc = ""]
159    pub pending: Option<bool>,
160    #[serde(
161        serialize_with = "crate::types::serialize_bool_optional",
162        deserialize_with = "crate::types::deserialize_bool_optional"
163    )]
164    #[serde(skip_serializing_if = "Option::is_none", default)]
165    #[doc = "Display running config."]
166    #[doc = ""]
167    pub running: Option<bool>,
168    #[serde(rename = "type")]
169    #[serde(skip_serializing_if = "Option::is_none", default)]
170    #[doc = "Only list sdn controllers of specific type"]
171    #[doc = ""]
172    pub ty: Option<Type>,
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}
180#[derive(Clone, Debug, :: serde :: Serialize, :: serde :: Deserialize, Default)]
181pub struct PendingGetOutputItemsPending {
182    #[serde(skip_serializing_if = "Option::is_none", default)]
183    #[doc = "The local ASN of the controller. BGP & EVPN only."]
184    #[doc = ""]
185    pub asn: Option<AsnInt>,
186    #[serde(rename = "bgp-multipath-as-relax")]
187    #[serde(
188        serialize_with = "crate::types::serialize_bool_optional",
189        deserialize_with = "crate::types::deserialize_bool_optional"
190    )]
191    #[serde(skip_serializing_if = "Option::is_none", default)]
192    #[doc = "Consider different AS paths of equal length for multipath computation. BGP only."]
193    #[doc = ""]
194    pub bgp_multipath_as_relax: Option<bool>,
195    #[serde(
196        serialize_with = "crate::types::serialize_bool_optional",
197        deserialize_with = "crate::types::deserialize_bool_optional"
198    )]
199    #[serde(skip_serializing_if = "Option::is_none", default)]
200    #[doc = "Enable eBGP (remote-as external). BGP only."]
201    #[doc = ""]
202    pub ebgp: Option<bool>,
203    #[serde(rename = "ebgp-multihop")]
204    #[serde(
205        serialize_with = "crate::types::serialize_int_optional",
206        deserialize_with = "crate::types::deserialize_int_optional"
207    )]
208    #[serde(skip_serializing_if = "Option::is_none", default)]
209    #[doc = "Set maximum amount of hops for eBGP peers. Needs ebgp set to 1. BGP only."]
210    #[doc = ""]
211    pub ebgp_multihop: Option<i64>,
212    #[serde(rename = "isis-domain")]
213    #[serde(skip_serializing_if = "Option::is_none", default)]
214    #[doc = "Name of the IS-IS domain. IS-IS only."]
215    #[doc = ""]
216    pub isis_domain: Option<String>,
217    #[serde(rename = "isis-ifaces")]
218    #[serde(skip_serializing_if = "Option::is_none", default)]
219    #[doc = "Comma-separated list of interfaces where IS-IS should be active. IS-IS only."]
220    #[doc = ""]
221    pub isis_ifaces: Option<String>,
222    #[serde(rename = "isis-net")]
223    #[serde(skip_serializing_if = "Option::is_none", default)]
224    #[doc = "Network Entity title for this node in the IS-IS network. IS-IS only."]
225    #[doc = ""]
226    pub isis_net: Option<String>,
227    #[serde(skip_serializing_if = "Option::is_none", default)]
228    #[doc = "Name of the loopback/dummy interface that provides the Router-IP. BGP only."]
229    #[doc = ""]
230    pub loopback: Option<String>,
231    #[serde(skip_serializing_if = "Option::is_none", default)]
232    #[doc = "Node(s) where this controller is active."]
233    #[doc = ""]
234    pub node: Option<String>,
235    #[serde(skip_serializing_if = "Option::is_none", default)]
236    #[doc = "Comma-separated list of the peers IP addresses."]
237    #[doc = ""]
238    pub peers: Option<String>,
239    #[serde(
240        flatten,
241        default,
242        skip_serializing_if = "::std::collections::HashMap::is_empty"
243    )]
244    pub additional_properties: ::std::collections::HashMap<String, ::serde_json::Value>,
245}
246impl PostParams {
247    pub fn new(controller: String, ty: Type) -> Self {
248        Self {
249            controller,
250            ty,
251            asn: ::std::default::Default::default(),
252            bgp_multipath_as_path_relax: ::std::default::Default::default(),
253            ebgp: ::std::default::Default::default(),
254            ebgp_multihop: ::std::default::Default::default(),
255            fabric: ::std::default::Default::default(),
256            isis_domain: ::std::default::Default::default(),
257            isis_ifaces: ::std::default::Default::default(),
258            isis_net: ::std::default::Default::default(),
259            lock_token: ::std::default::Default::default(),
260            loopback: ::std::default::Default::default(),
261            node: ::std::default::Default::default(),
262            peers: ::std::default::Default::default(),
263            additional_properties: ::std::default::Default::default(),
264        }
265    }
266}
267#[derive(Clone, Debug, :: serde :: Serialize, :: serde :: Deserialize)]
268pub struct PostParams {
269    #[serde(skip_serializing_if = "Option::is_none", default)]
270    #[doc = "autonomous system number"]
271    #[doc = ""]
272    pub asn: Option<AsnInt>,
273    #[serde(rename = "bgp-multipath-as-path-relax")]
274    #[serde(
275        serialize_with = "crate::types::serialize_bool_optional",
276        deserialize_with = "crate::types::deserialize_bool_optional"
277    )]
278    #[serde(skip_serializing_if = "Option::is_none", default)]
279    #[doc = "Consider different AS paths of equal length for multipath computation."]
280    #[doc = ""]
281    pub bgp_multipath_as_path_relax: Option<bool>,
282    #[doc = "The SDN controller object identifier."]
283    #[doc = ""]
284    pub controller: String,
285    #[serde(
286        serialize_with = "crate::types::serialize_bool_optional",
287        deserialize_with = "crate::types::deserialize_bool_optional"
288    )]
289    #[serde(skip_serializing_if = "Option::is_none", default)]
290    #[doc = "Enable eBGP (remote-as external)."]
291    #[doc = ""]
292    pub ebgp: Option<bool>,
293    #[serde(rename = "ebgp-multihop")]
294    #[serde(
295        serialize_with = "crate::types::serialize_int_optional",
296        deserialize_with = "crate::types::deserialize_int_optional"
297    )]
298    #[serde(skip_serializing_if = "Option::is_none", default)]
299    #[doc = "Set maximum amount of hops for eBGP peers."]
300    #[doc = ""]
301    pub ebgp_multihop: Option<i64>,
302    #[serde(skip_serializing_if = "Option::is_none", default)]
303    #[doc = "SDN fabric to use as underlay for this EVPN controller."]
304    #[doc = ""]
305    pub fabric: Option<String>,
306    #[serde(rename = "isis-domain")]
307    #[serde(skip_serializing_if = "Option::is_none", default)]
308    #[doc = "Name of the IS-IS domain."]
309    #[doc = ""]
310    pub isis_domain: Option<String>,
311    #[serde(rename = "isis-ifaces")]
312    #[serde(skip_serializing_if = "Option::is_none", default)]
313    #[doc = "Comma-separated list of interfaces where IS-IS should be active."]
314    #[doc = ""]
315    pub isis_ifaces: Option<String>,
316    #[serde(rename = "isis-net")]
317    #[serde(skip_serializing_if = "Option::is_none", default)]
318    #[doc = "Network Entity title for this node in the IS-IS network."]
319    #[doc = ""]
320    pub isis_net: Option<String>,
321    #[serde(rename = "lock-token")]
322    #[serde(skip_serializing_if = "Option::is_none", default)]
323    #[doc = "the token for unlocking the global SDN configuration"]
324    #[doc = ""]
325    pub lock_token: Option<String>,
326    #[serde(skip_serializing_if = "Option::is_none", default)]
327    #[doc = "Name of the loopback/dummy interface that provides the Router-IP."]
328    #[doc = ""]
329    pub loopback: Option<String>,
330    #[serde(skip_serializing_if = "Option::is_none", default)]
331    #[doc = "The cluster node name."]
332    #[doc = ""]
333    pub node: Option<String>,
334    #[serde(skip_serializing_if = "Option::is_none", default)]
335    #[doc = "peers address list."]
336    #[doc = ""]
337    pub peers: Option<String>,
338    #[serde(rename = "type")]
339    #[doc = "Plugin type."]
340    #[doc = ""]
341    pub ty: Type,
342    #[serde(
343        flatten,
344        default,
345        skip_serializing_if = "::std::collections::HashMap::is_empty"
346    )]
347    pub additional_properties: ::std::collections::HashMap<String, ::serde_json::Value>,
348}
349#[derive(Clone, Debug, :: serde :: Serialize, :: serde :: Deserialize, PartialEq)]
350#[doc = "State of the SDN configuration object."]
351#[doc = ""]
352pub enum State {
353    #[serde(rename = "changed")]
354    Changed,
355    #[serde(rename = "deleted")]
356    Deleted,
357    #[serde(rename = "new")]
358    New,
359}
360impl TryFrom<&str> for State {
361    type Error = String;
362    fn try_from(value: &str) -> Result<Self, <Self as TryFrom<&str>>::Error> {
363        match value {
364            "changed" => Ok(Self::Changed),
365            "deleted" => Ok(Self::Deleted),
366            "new" => Ok(Self::New),
367            v => Err(format!("Unknown variant {v}")),
368        }
369    }
370}
371#[derive(Clone, Debug, :: serde :: Serialize, :: serde :: Deserialize, PartialEq)]
372#[doc = "Only list sdn controllers of specific type"]
373#[doc = ""]
374pub enum Type {
375    #[serde(rename = "bgp")]
376    Bgp,
377    #[serde(rename = "evpn")]
378    Evpn,
379    #[serde(rename = "faucet")]
380    Faucet,
381    #[serde(rename = "isis")]
382    Isis,
383}
384impl TryFrom<&str> for Type {
385    type Error = String;
386    fn try_from(value: &str) -> Result<Self, <Self as TryFrom<&str>>::Error> {
387        match value {
388            "bgp" => Ok(Self::Bgp),
389            "evpn" => Ok(Self::Evpn),
390            "faucet" => Ok(Self::Faucet),
391            "isis" => Ok(Self::Isis),
392            v => Err(format!("Unknown variant {v}")),
393        }
394    }
395}
396#[derive(Debug, Clone, Copy, PartialEq, PartialOrd)]
397pub struct AsnInt(i128);
398impl crate::types::bounded_integer::BoundedInteger for AsnInt {
399    const MIN: Option<i128> = Some(0i128);
400    const MAX: Option<i128> = Some(4294967295i128);
401    const DEFAULT: Option<i128> = None::<i128>;
402    const TYPE_DESCRIPTION: &'static str = "an integer between 0 and 4294967295";
403    fn get(&self) -> i128 {
404        self.0
405    }
406    fn new(value: i128) -> Result<Self, crate::types::bounded_integer::BoundedIntegerError> {
407        Self::validate(value)?;
408        Ok(Self(value))
409    }
410}
411impl std::convert::TryFrom<i128> for AsnInt {
412    type Error = crate::types::bounded_integer::BoundedIntegerError;
413    fn try_from(value: i128) -> Result<Self, Self::Error> {
414        crate::types::bounded_integer::BoundedInteger::new(value)
415    }
416}
417impl ::serde::Serialize for AsnInt {
418    fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
419    where
420        S: ::serde::Serializer,
421    {
422        crate::types::bounded_integer::serialize_bounded_integer(self, serializer)
423    }
424}
425impl<'de> ::serde::Deserialize<'de> for AsnInt {
426    fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
427    where
428        D: ::serde::Deserializer<'de>,
429    {
430        crate::types::bounded_integer::deserialize_bounded_integer(deserializer)
431    }
432}
433impl<T> ControllersClient<T>
434where
435    T: crate::client::Client,
436{
437    pub fn controller(&self, controller: &str) -> controller::ControllerClient<T> {
438        controller::ControllerClient::<T>::new(self.client.clone(), &self.path, controller)
439    }
440}