proxmox_api/generated/cluster/config/
join.rs1#[derive(Debug, Clone)]
2pub struct JoinClient<T> {
3 client: T,
4 path: String,
5}
6impl<T> JoinClient<T>
7where
8 T: crate::client::Client,
9{
10 pub fn new(client: T, parent_path: &str) -> Self {
11 Self {
12 client,
13 path: format!("{}{}", parent_path, "/join"),
14 }
15 }
16}
17impl<T> JoinClient<T>
18where
19 T: crate::client::Client,
20{
21 #[doc = "Get information needed to join this cluster over the connected node."]
22 #[doc = ""]
23 #[doc = "Permission check: perm(\"/\", [\"Sys.Audit\"])"]
24 pub async fn get(&self, params: GetParams) -> Result<GetOutput, T::Error> {
25 let path = self.path.to_string();
26 self.client.get(&path, ¶ms).await
27 }
28}
29impl<T> JoinClient<T>
30where
31 T: crate::client::Client,
32{
33 #[doc = "Joins this node into an existing cluster. If no links are given, default to IP resolved by node's hostname on single link (fallback fails for clusters with multiple links)."]
34 #[doc = ""]
35 pub async fn post(&self, params: PostParams) -> Result<String, T::Error> {
36 let path = self.path.to_string();
37 self.client.post(&path, ¶ms).await
38 }
39}
40impl GetOutput {
41 pub fn new(
42 config_digest: String,
43 nodelist: Vec<NodelistGetOutputNodelistItems>,
44 preferred_node: String,
45 totem: TotemGetOutputTotem,
46 ) -> Self {
47 Self {
48 config_digest,
49 nodelist,
50 preferred_node,
51 totem,
52 }
53 }
54}
55#[derive(Clone, Debug, :: serde :: Serialize, :: serde :: Deserialize)]
56pub struct GetOutput {
57 pub config_digest: String,
58 #[serde(skip_serializing_if = "::std::vec::Vec::is_empty", default)]
59 pub nodelist: Vec<NodelistGetOutputNodelistItems>,
60 #[doc = "The cluster node name."]
61 #[doc = ""]
62 pub preferred_node: String,
63 pub totem: TotemGetOutputTotem,
64}
65#[derive(Clone, Debug, :: serde :: Serialize, :: serde :: Deserialize, Default)]
66pub struct GetParams {
67 #[serde(skip_serializing_if = "Option::is_none", default)]
68 #[doc = "The node for which the joinee gets the nodeinfo."]
69 #[doc = ""]
70 pub node: Option<String>,
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 NodelistGetOutputNodelistItems {
79 pub fn new(
80 name: String,
81 pve_addr: ::std::net::IpAddr,
82 pve_fp: PveFpStr,
83 quorum_votes: u64,
84 ) -> Self {
85 Self {
86 name,
87 pve_addr,
88 pve_fp,
89 quorum_votes,
90 nodeid: ::std::default::Default::default(),
91 ring0_addr: ::std::default::Default::default(),
92 additional_properties: ::std::default::Default::default(),
93 }
94 }
95}
96#[derive(Clone, Debug, :: serde :: Serialize, :: serde :: Deserialize)]
97pub struct NodelistGetOutputNodelistItems {
98 #[doc = "The cluster node name."]
99 #[doc = ""]
100 pub name: String,
101 #[serde(
102 serialize_with = "crate::types::serialize_non_zero_pos_int_optional",
103 deserialize_with = "crate::types::deserialize_non_zero_pos_int_optional"
104 )]
105 #[serde(skip_serializing_if = "Option::is_none", default)]
106 #[doc = "Node id for this node."]
107 #[doc = ""]
108 pub nodeid: Option<std::num::NonZeroU64>,
109 pub pve_addr: ::std::net::IpAddr,
110 #[doc = "Certificate SHA 256 fingerprint."]
111 #[doc = ""]
112 pub pve_fp: PveFpStr,
113 #[serde(
114 serialize_with = "crate::types::serialize_unsigned_int",
115 deserialize_with = "crate::types::deserialize_unsigned_int"
116 )]
117 pub quorum_votes: u64,
118 #[serde(skip_serializing_if = "Option::is_none", default)]
119 #[doc = "Address and priority information of a single corosync link. (up to 8 links supported; link0..link7)"]
120 #[doc = ""]
121 pub ring0_addr: Option<String>,
122 #[serde(
123 flatten,
124 default,
125 skip_serializing_if = "::std::collections::HashMap::is_empty"
126 )]
127 pub additional_properties: ::std::collections::HashMap<String, ::serde_json::Value>,
128}
129impl PostParams {
130 pub fn new(fingerprint: FingerprintStr, hostname: String, password: PasswordStr) -> Self {
131 Self {
132 fingerprint,
133 hostname,
134 password,
135 force: ::std::default::Default::default(),
136 links: ::std::default::Default::default(),
137 nodeid: ::std::default::Default::default(),
138 votes: ::std::default::Default::default(),
139 additional_properties: ::std::default::Default::default(),
140 }
141 }
142}
143#[derive(Clone, Debug, :: serde :: Serialize, :: serde :: Deserialize)]
144pub struct PostParams {
145 #[doc = "Certificate SHA 256 fingerprint."]
146 #[doc = ""]
147 pub fingerprint: FingerprintStr,
148 #[serde(
149 serialize_with = "crate::types::serialize_bool_optional",
150 deserialize_with = "crate::types::deserialize_bool_optional"
151 )]
152 #[serde(skip_serializing_if = "Option::is_none", default)]
153 #[doc = "Do not throw error if node already exists."]
154 #[doc = ""]
155 pub force: Option<bool>,
156 #[doc = "Hostname (or IP) of an existing cluster member."]
157 #[doc = ""]
158 pub hostname: String,
159 #[serde(rename = "link[n]")]
160 #[serde(
161 serialize_with = "crate::types::serialize_multi::<NumberedLinks, _>",
162 deserialize_with = "crate::types::deserialize_multi::<NumberedLinks, _>"
163 )]
164 #[serde(skip_serializing_if = "::std::collections::HashMap::is_empty", default)]
165 #[serde(flatten)]
166 #[doc = "Address and priority information of a single corosync link. (up to 8 links supported; link0..link7)"]
167 #[doc = ""]
168 pub links: ::std::collections::HashMap<u32, String>,
169 #[serde(
170 serialize_with = "crate::types::serialize_non_zero_pos_int_optional",
171 deserialize_with = "crate::types::deserialize_non_zero_pos_int_optional"
172 )]
173 #[serde(skip_serializing_if = "Option::is_none", default)]
174 #[doc = "Node id for this node."]
175 #[doc = ""]
176 pub nodeid: Option<std::num::NonZeroU64>,
177 #[doc = "Superuser (root) password of peer node."]
178 #[doc = ""]
179 pub password: PasswordStr,
180 #[serde(
181 serialize_with = "crate::types::serialize_unsigned_int_optional",
182 deserialize_with = "crate::types::deserialize_unsigned_int_optional"
183 )]
184 #[serde(skip_serializing_if = "Option::is_none", default)]
185 #[doc = "Number of votes for this node"]
186 #[doc = ""]
187 pub votes: Option<u64>,
188 #[serde(
189 flatten,
190 deserialize_with = "crate::types::multi::deserialize_additional_data::<'_, PostParams, _, _>"
191 )]
192 pub additional_properties: ::std::collections::HashMap<String, ::serde_json::Value>,
193}
194impl crate::types::multi::Test for PostParams {
195 fn test_fn() -> fn(&str) -> bool {
196 fn the_test(input: &str) -> bool {
197 let array = [
198 <NumberedLinks as crate::types::multi::NumberedItems>::key_matches
199 as fn(&str) -> bool,
200 ];
201 array.iter().any(|f| f(input))
202 }
203 the_test as _
204 }
205}
206#[derive(Clone, Debug, :: serde :: Serialize, :: serde :: Deserialize, Default)]
207pub struct TotemGetOutputTotem {
208 #[serde(
209 flatten,
210 default,
211 skip_serializing_if = "::std::collections::HashMap::is_empty"
212 )]
213 pub additional_properties: ::std::collections::HashMap<String, ::serde_json::Value>,
214}
215#[derive(Default)]
216struct NumberedLinks;
217impl crate::types::multi::NumberedItems for NumberedLinks {
218 type Item = String;
219 const PREFIX: &'static str = "link";
220}
221#[derive(Debug, Clone, PartialEq, PartialOrd)]
222pub struct FingerprintStr {
223 value: String,
224}
225impl crate::types::bounded_string::BoundedString for FingerprintStr {
226 const MIN_LENGTH: Option<usize> = None::<usize>;
227 const MAX_LENGTH: Option<usize> = None::<usize>;
228 const DEFAULT: Option<&'static str> = None::<&'static str>;
229 const PATTERN: Option<&'static str> = Some("([A-Fa-f0-9]{2}:){31}[A-Fa-f0-9]{2}");
230 const TYPE_DESCRIPTION: &'static str =
231 "a string with pattern r\"([A-Fa-f0-9]{2}:){31}[A-Fa-f0-9]{2}\" and no length constraints";
232 fn get_value(&self) -> &str {
233 &self.value
234 }
235 fn new(value: String) -> Result<Self, crate::types::bounded_string::BoundedStringError> {
236 Self::validate(&value)?;
237 Ok(Self { value })
238 }
239}
240impl std::convert::TryFrom<String> for FingerprintStr {
241 type Error = crate::types::bounded_string::BoundedStringError;
242 fn try_from(value: String) -> Result<Self, Self::Error> {
243 crate::types::bounded_string::BoundedString::new(value)
244 }
245}
246impl ::serde::Serialize for FingerprintStr {
247 fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
248 where
249 S: ::serde::Serializer,
250 {
251 crate::types::bounded_string::serialize_bounded_string(self, serializer)
252 }
253}
254impl<'de> ::serde::Deserialize<'de> for FingerprintStr {
255 fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
256 where
257 D: ::serde::Deserializer<'de>,
258 {
259 crate::types::bounded_string::deserialize_bounded_string(deserializer)
260 }
261}
262#[derive(Debug, Clone, PartialEq, PartialOrd)]
263pub struct PasswordStr {
264 value: String,
265}
266impl crate::types::bounded_string::BoundedString for PasswordStr {
267 const MIN_LENGTH: Option<usize> = None::<usize>;
268 const MAX_LENGTH: Option<usize> = Some(128usize);
269 const DEFAULT: Option<&'static str> = None::<&'static str>;
270 const PATTERN: Option<&'static str> = None::<&'static str>;
271 const TYPE_DESCRIPTION: &'static str = "a string with length at most 128";
272 fn get_value(&self) -> &str {
273 &self.value
274 }
275 fn new(value: String) -> Result<Self, crate::types::bounded_string::BoundedStringError> {
276 Self::validate(&value)?;
277 Ok(Self { value })
278 }
279}
280impl std::convert::TryFrom<String> for PasswordStr {
281 type Error = crate::types::bounded_string::BoundedStringError;
282 fn try_from(value: String) -> Result<Self, Self::Error> {
283 crate::types::bounded_string::BoundedString::new(value)
284 }
285}
286impl ::serde::Serialize for PasswordStr {
287 fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
288 where
289 S: ::serde::Serializer,
290 {
291 crate::types::bounded_string::serialize_bounded_string(self, serializer)
292 }
293}
294impl<'de> ::serde::Deserialize<'de> for PasswordStr {
295 fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
296 where
297 D: ::serde::Deserializer<'de>,
298 {
299 crate::types::bounded_string::deserialize_bounded_string(deserializer)
300 }
301}
302#[derive(Debug, Clone, PartialEq, PartialOrd)]
303pub struct PveFpStr {
304 value: String,
305}
306impl crate::types::bounded_string::BoundedString for PveFpStr {
307 const MIN_LENGTH: Option<usize> = None::<usize>;
308 const MAX_LENGTH: Option<usize> = None::<usize>;
309 const DEFAULT: Option<&'static str> = None::<&'static str>;
310 const PATTERN: Option<&'static str> = Some("([A-Fa-f0-9]{2}:){31}[A-Fa-f0-9]{2}");
311 const TYPE_DESCRIPTION: &'static str =
312 "a string with pattern r\"([A-Fa-f0-9]{2}:){31}[A-Fa-f0-9]{2}\" and no length constraints";
313 fn get_value(&self) -> &str {
314 &self.value
315 }
316 fn new(value: String) -> Result<Self, crate::types::bounded_string::BoundedStringError> {
317 Self::validate(&value)?;
318 Ok(Self { value })
319 }
320}
321impl std::convert::TryFrom<String> for PveFpStr {
322 type Error = crate::types::bounded_string::BoundedStringError;
323 fn try_from(value: String) -> Result<Self, Self::Error> {
324 crate::types::bounded_string::BoundedString::new(value)
325 }
326}
327impl ::serde::Serialize for PveFpStr {
328 fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
329 where
330 S: ::serde::Serializer,
331 {
332 crate::types::bounded_string::serialize_bounded_string(self, serializer)
333 }
334}
335impl<'de> ::serde::Deserialize<'de> for PveFpStr {
336 fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
337 where
338 D: ::serde::Deserializer<'de>,
339 {
340 crate::types::bounded_string::deserialize_bounded_string(deserializer)
341 }
342}