Skip to main content

proxmox_api/generated/cluster/sdn/fabrics/node/
fabric_id.rs

1pub mod node_id;
2#[derive(Debug, Clone)]
3pub struct FabricIdClient<T> {
4    client: T,
5    path: String,
6}
7impl<T> FabricIdClient<T>
8where
9    T: crate::client::Client,
10{
11    pub fn new(client: T, parent_path: &str, fabric_id: &str) -> Self {
12        Self {
13            client,
14            path: format!("{}/{}", parent_path, fabric_id),
15        }
16    }
17}
18impl<T> FabricIdClient<T>
19where
20    T: crate::client::Client,
21{
22    #[doc = "SDN Fabrics Index"]
23    #[doc = ""]
24    #[doc = "Permission check: perm(\"/sdn/fabrics/{fabric_id}\", [\"SDN.Audit\"])"]
25    #[doc = "Only returns nodes where you have 'Sys.Audit' or 'Sys.Modify' permissions."]
26    pub async fn get(&self, params: GetParams) -> Result<Vec<GetOutputItems>, T::Error> {
27        let path = self.path.to_string();
28        let optional_vec: Option<Vec<GetOutputItems>> = self.client.get(&path, &params).await?;
29        Ok(optional_vec.unwrap_or_default())
30    }
31}
32impl<T> FabricIdClient<T>
33where
34    T: crate::client::Client,
35{
36    #[doc = "Add a node"]
37    #[doc = ""]
38    #[doc = "Permission check: and(perm(\"/sdn/fabrics/{fabric_id}\", [\"SDN.Allocate\"]), perm(\"/nodes/{node_id}\", [\"Sys.Modify\"]))"]
39    pub async fn post(&self, params: PostParams) -> Result<(), T::Error> {
40        let path = self.path.to_string();
41        self.client.post(&path, &params).await
42    }
43}
44impl GetOutputItems {
45    pub fn new(fabric_id: String, node_id: String, protocol: Protocol) -> Self {
46        Self {
47            fabric_id,
48            node_id,
49            protocol,
50            digest: ::std::default::Default::default(),
51            ip: ::std::default::Default::default(),
52            ip6: ::std::default::Default::default(),
53            lock_token: ::std::default::Default::default(),
54            additional_properties: ::std::default::Default::default(),
55        }
56    }
57}
58#[derive(Clone, Debug, :: serde :: Serialize, :: serde :: Deserialize)]
59pub struct GetOutputItems {
60    #[serde(skip_serializing_if = "Option::is_none", default)]
61    #[doc = "Prevent changes if current configuration file has a different digest. This can be used to prevent concurrent modifications."]
62    #[doc = ""]
63    pub digest: Option<DigestStr>,
64    #[doc = "Identifier for SDN fabrics"]
65    #[doc = ""]
66    pub fabric_id: String,
67    #[serde(skip_serializing_if = "Option::is_none", default)]
68    #[doc = "IPv4 address for this node"]
69    #[doc = ""]
70    pub ip: Option<::std::net::Ipv4Addr>,
71    #[serde(skip_serializing_if = "Option::is_none", default)]
72    #[doc = "IPv6 address for this node"]
73    #[doc = ""]
74    pub ip6: Option<::std::net::Ipv6Addr>,
75    #[serde(rename = "lock-token")]
76    #[serde(skip_serializing_if = "Option::is_none", default)]
77    #[doc = "the token for unlocking the global SDN configuration"]
78    #[doc = ""]
79    pub lock_token: Option<String>,
80    #[doc = "Identifier for nodes in an SDN fabric"]
81    #[doc = ""]
82    pub node_id: String,
83    #[doc = "Type of configuration entry in an SDN Fabric section config"]
84    #[doc = ""]
85    pub protocol: Protocol,
86    #[serde(
87        flatten,
88        default,
89        skip_serializing_if = "::std::collections::HashMap::is_empty"
90    )]
91    pub additional_properties: ::std::collections::HashMap<String, ::serde_json::Value>,
92}
93#[derive(Clone, Debug, :: serde :: Serialize, :: serde :: Deserialize, Default)]
94pub struct GetParams {
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 = "Display pending config."]
101    #[doc = ""]
102    pub pending: Option<bool>,
103    #[serde(
104        serialize_with = "crate::types::serialize_bool_optional",
105        deserialize_with = "crate::types::deserialize_bool_optional"
106    )]
107    #[serde(skip_serializing_if = "Option::is_none", default)]
108    #[doc = "Display running config."]
109    #[doc = ""]
110    pub running: Option<bool>,
111    #[serde(
112        flatten,
113        default,
114        skip_serializing_if = "::std::collections::HashMap::is_empty"
115    )]
116    pub additional_properties: ::std::collections::HashMap<String, ::serde_json::Value>,
117}
118impl PostParams {
119    pub fn new(node_id: String, protocol: Protocol) -> Self {
120        Self {
121            node_id,
122            protocol,
123            digest: ::std::default::Default::default(),
124            ip: ::std::default::Default::default(),
125            ip6: ::std::default::Default::default(),
126            lock_token: ::std::default::Default::default(),
127            additional_properties: ::std::default::Default::default(),
128        }
129    }
130}
131#[derive(Clone, Debug, :: serde :: Serialize, :: serde :: Deserialize)]
132pub struct PostParams {
133    #[serde(skip_serializing_if = "Option::is_none", default)]
134    #[doc = "Prevent changes if current configuration file has a different digest. This can be used to prevent concurrent modifications."]
135    #[doc = ""]
136    pub digest: Option<DigestStr>,
137    #[serde(skip_serializing_if = "Option::is_none", default)]
138    #[doc = "IPv4 address for this node"]
139    #[doc = ""]
140    pub ip: Option<::std::net::Ipv4Addr>,
141    #[serde(skip_serializing_if = "Option::is_none", default)]
142    #[doc = "IPv6 address for this node"]
143    #[doc = ""]
144    pub ip6: Option<::std::net::Ipv6Addr>,
145    #[serde(rename = "lock-token")]
146    #[serde(skip_serializing_if = "Option::is_none", default)]
147    #[doc = "the token for unlocking the global SDN configuration"]
148    #[doc = ""]
149    pub lock_token: Option<String>,
150    #[doc = "Identifier for nodes in an SDN fabric"]
151    #[doc = ""]
152    pub node_id: String,
153    #[doc = "Type of configuration entry in an SDN Fabric section config"]
154    #[doc = ""]
155    pub protocol: Protocol,
156    #[serde(
157        flatten,
158        default,
159        skip_serializing_if = "::std::collections::HashMap::is_empty"
160    )]
161    pub additional_properties: ::std::collections::HashMap<String, ::serde_json::Value>,
162}
163#[derive(Clone, Debug, :: serde :: Serialize, :: serde :: Deserialize, PartialEq)]
164#[doc = "Type of configuration entry in an SDN Fabric section config"]
165#[doc = ""]
166pub enum Protocol {
167    #[serde(rename = "openfabric")]
168    Openfabric,
169    #[serde(rename = "ospf")]
170    Ospf,
171}
172impl TryFrom<&str> for Protocol {
173    type Error = String;
174    fn try_from(value: &str) -> Result<Self, <Self as TryFrom<&str>>::Error> {
175        match value {
176            "openfabric" => Ok(Self::Openfabric),
177            "ospf" => Ok(Self::Ospf),
178            v => Err(format!("Unknown variant {v}")),
179        }
180    }
181}
182#[derive(Debug, Clone, PartialEq, PartialOrd)]
183pub struct DigestStr {
184    value: String,
185}
186impl crate::types::bounded_string::BoundedString for DigestStr {
187    const MIN_LENGTH: Option<usize> = None::<usize>;
188    const MAX_LENGTH: Option<usize> = Some(64usize);
189    const DEFAULT: Option<&'static str> = None::<&'static str>;
190    const PATTERN: Option<&'static str> = None::<&'static str>;
191    const TYPE_DESCRIPTION: &'static str = "a string with length at most 64";
192    fn get_value(&self) -> &str {
193        &self.value
194    }
195    fn new(value: String) -> Result<Self, crate::types::bounded_string::BoundedStringError> {
196        Self::validate(&value)?;
197        Ok(Self { value })
198    }
199}
200impl std::convert::TryFrom<String> for DigestStr {
201    type Error = crate::types::bounded_string::BoundedStringError;
202    fn try_from(value: String) -> Result<Self, Self::Error> {
203        crate::types::bounded_string::BoundedString::new(value)
204    }
205}
206impl ::serde::Serialize for DigestStr {
207    fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
208    where
209        S: ::serde::Serializer,
210    {
211        crate::types::bounded_string::serialize_bounded_string(self, serializer)
212    }
213}
214impl<'de> ::serde::Deserialize<'de> for DigestStr {
215    fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
216    where
217        D: ::serde::Deserializer<'de>,
218    {
219        crate::types::bounded_string::deserialize_bounded_string(deserializer)
220    }
221}
222impl<T> FabricIdClient<T>
223where
224    T: crate::client::Client,
225{
226    pub fn node_id(&self, node_id: &str) -> node_id::NodeIdClient<T> {
227        node_id::NodeIdClient::<T>::new(self.client.clone(), &self.path, node_id)
228    }
229}