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