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