Skip to main content

proxmox_api/generated/cluster/sdn/
ipams.rs

1pub mod ipam;
2#[derive(Debug, Clone)]
3pub struct IpamsClient<T> {
4    client: T,
5    path: String,
6}
7impl<T> IpamsClient<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, "/ipams"),
15        }
16    }
17}
18impl<T> IpamsClient<T>
19where
20    T: crate::client::Client,
21{
22    #[doc = "SDN ipams index."]
23    #[doc = ""]
24    #[doc = "Only list entries where you have 'SDN.Audit' or 'SDN.Allocate' permissions on '/sdn/ipams/\\<ipam\\>'"]
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> IpamsClient<T>
32where
33    T: crate::client::Client,
34{
35    #[doc = "Create a new sdn ipam object."]
36    #[doc = ""]
37    #[doc = "Permission check: perm(\"/sdn/ipams\", [\"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(ipam: String, ty: String) -> Self {
45        Self {
46            ipam,
47            ty,
48            additional_properties: ::std::default::Default::default(),
49        }
50    }
51}
52#[derive(Clone, Debug, :: serde :: Serialize, :: serde :: Deserialize)]
53pub struct GetOutputItems {
54    pub ipam: String,
55    #[serde(rename = "type")]
56    pub ty: String,
57    #[serde(
58        flatten,
59        default,
60        skip_serializing_if = "::std::collections::HashMap::is_empty"
61    )]
62    pub additional_properties: ::std::collections::HashMap<String, ::serde_json::Value>,
63}
64#[derive(Clone, Debug, :: serde :: Serialize, :: serde :: Deserialize, Default)]
65pub struct GetParams {
66    #[serde(rename = "type")]
67    #[serde(skip_serializing_if = "Option::is_none", default)]
68    #[doc = "Only list sdn ipams of specific type"]
69    #[doc = ""]
70    pub ty: Option<Type>,
71    #[serde(
72        flatten,
73        default,
74        skip_serializing_if = "::std::collections::HashMap::is_empty"
75    )]
76    pub additional_properties: ::std::collections::HashMap<String, ::serde_json::Value>,
77}
78impl PostParams {
79    pub fn new(ipam: String, ty: Type) -> Self {
80        Self {
81            ipam,
82            ty,
83            fingerprint: ::std::default::Default::default(),
84            lock_token: ::std::default::Default::default(),
85            section: ::std::default::Default::default(),
86            token: ::std::default::Default::default(),
87            url: ::std::default::Default::default(),
88            additional_properties: ::std::default::Default::default(),
89        }
90    }
91}
92#[derive(Clone, Debug, :: serde :: Serialize, :: serde :: Deserialize)]
93pub struct PostParams {
94    #[serde(skip_serializing_if = "Option::is_none", default)]
95    #[doc = "Certificate SHA 256 fingerprint."]
96    #[doc = ""]
97    pub fingerprint: Option<FingerprintStr>,
98    #[doc = "The SDN ipam object identifier."]
99    #[doc = ""]
100    pub ipam: String,
101    #[serde(rename = "lock-token")]
102    #[serde(skip_serializing_if = "Option::is_none", default)]
103    #[doc = "the token for unlocking the global SDN configuration"]
104    #[doc = ""]
105    pub lock_token: Option<String>,
106    #[serde(
107        serialize_with = "crate::types::serialize_int_optional",
108        deserialize_with = "crate::types::deserialize_int_optional"
109    )]
110    #[serde(skip_serializing_if = "Option::is_none", default)]
111    pub section: Option<i64>,
112    #[serde(skip_serializing_if = "Option::is_none", default)]
113    pub token: Option<String>,
114    #[serde(rename = "type")]
115    #[doc = "Plugin type."]
116    #[doc = ""]
117    pub ty: Type,
118    #[serde(skip_serializing_if = "Option::is_none", default)]
119    pub url: Option<String>,
120    #[serde(
121        flatten,
122        default,
123        skip_serializing_if = "::std::collections::HashMap::is_empty"
124    )]
125    pub additional_properties: ::std::collections::HashMap<String, ::serde_json::Value>,
126}
127#[derive(Clone, Debug, :: serde :: Serialize, :: serde :: Deserialize, PartialEq)]
128#[doc = "Only list sdn ipams of specific type"]
129#[doc = ""]
130pub enum Type {
131    #[serde(rename = "netbox")]
132    Netbox,
133    #[serde(rename = "phpipam")]
134    Phpipam,
135    #[serde(rename = "pve")]
136    Pve,
137}
138impl TryFrom<&str> for Type {
139    type Error = String;
140    fn try_from(value: &str) -> Result<Self, <Self as TryFrom<&str>>::Error> {
141        match value {
142            "netbox" => Ok(Self::Netbox),
143            "phpipam" => Ok(Self::Phpipam),
144            "pve" => Ok(Self::Pve),
145            v => Err(format!("Unknown variant {v}")),
146        }
147    }
148}
149#[derive(Debug, Clone, PartialEq, PartialOrd)]
150pub struct FingerprintStr {
151    value: String,
152}
153impl crate::types::bounded_string::BoundedString for FingerprintStr {
154    const MIN_LENGTH: Option<usize> = None::<usize>;
155    const MAX_LENGTH: Option<usize> = None::<usize>;
156    const DEFAULT: Option<&'static str> = None::<&'static str>;
157    const PATTERN: Option<&'static str> = Some("([A-Fa-f0-9]{2}:){31}[A-Fa-f0-9]{2}");
158    const TYPE_DESCRIPTION: &'static str =
159        "a string with pattern r\"([A-Fa-f0-9]{2}:){31}[A-Fa-f0-9]{2}\" and no length constraints";
160    fn get_value(&self) -> &str {
161        &self.value
162    }
163    fn new(value: String) -> Result<Self, crate::types::bounded_string::BoundedStringError> {
164        Self::validate(&value)?;
165        Ok(Self { value })
166    }
167}
168impl std::convert::TryFrom<String> for FingerprintStr {
169    type Error = crate::types::bounded_string::BoundedStringError;
170    fn try_from(value: String) -> Result<Self, Self::Error> {
171        crate::types::bounded_string::BoundedString::new(value)
172    }
173}
174impl ::serde::Serialize for FingerprintStr {
175    fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
176    where
177        S: ::serde::Serializer,
178    {
179        crate::types::bounded_string::serialize_bounded_string(self, serializer)
180    }
181}
182impl<'de> ::serde::Deserialize<'de> for FingerprintStr {
183    fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
184    where
185        D: ::serde::Deserializer<'de>,
186    {
187        crate::types::bounded_string::deserialize_bounded_string(deserializer)
188    }
189}
190impl<T> IpamsClient<T>
191where
192    T: crate::client::Client,
193{
194    pub fn ipam(&self, ipam: &str) -> ipam::IpamClient<T> {
195        ipam::IpamClient::<T>::new(self.client.clone(), &self.path, ipam)
196    }
197}