proxmox_api/generated/cluster/config/
join.rs

1pub struct JoinClient<T> {
2    client: T,
3    path: String,
4}
5impl<T> JoinClient<T>
6where
7    T: crate::client::Client,
8{
9    pub fn new(client: T, parent_path: &str) -> Self {
10        Self {
11            client,
12            path: format!("{}{}", parent_path, "/join"),
13        }
14    }
15}
16impl<T> JoinClient<T>
17where
18    T: crate::client::Client,
19{
20    #[doc = "Get information needed to join this cluster over the connected node."]
21    pub fn get(&self, params: GetParams) -> Result<GetOutput, T::Error> {
22        let path = self.path.to_string();
23        self.client.get(&path, &params)
24    }
25}
26impl<T> JoinClient<T>
27where
28    T: crate::client::Client,
29{
30    #[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)."]
31    pub fn post(&self, params: PostParams) -> Result<String, T::Error> {
32        let path = self.path.to_string();
33        self.client.post(&path, &params)
34    }
35}
36impl GetOutput {
37    pub fn new(
38        config_digest: String,
39        nodelist: Vec<NodelistGetOutputNodelistItems>,
40        preferred_node: String,
41        totem: TotemGetOutputTotem,
42    ) -> Self {
43        Self {
44            config_digest,
45            nodelist,
46            preferred_node,
47            totem,
48        }
49    }
50}
51#[derive(Clone, Debug, :: serde :: Serialize, :: serde :: Deserialize)]
52pub struct GetOutput {
53    pub config_digest: String,
54    #[serde(skip_serializing_if = "::std::vec::Vec::is_empty", default)]
55    pub nodelist: Vec<NodelistGetOutputNodelistItems>,
56    #[doc = "The cluster node name."]
57    pub preferred_node: String,
58    pub totem: TotemGetOutputTotem,
59}
60#[derive(Clone, Debug, :: serde :: Serialize, :: serde :: Deserialize, Default)]
61pub struct GetParams {
62    #[serde(skip_serializing_if = "Option::is_none", default)]
63    #[doc = "The node for which the joinee gets the nodeinfo. "]
64    pub node: Option<String>,
65    #[serde(
66        flatten,
67        default,
68        skip_serializing_if = "::std::collections::HashMap::is_empty"
69    )]
70    pub additional_properties: ::std::collections::HashMap<String, ::serde_json::Value>,
71}
72impl NodelistGetOutputNodelistItems {
73    pub fn new(
74        name: String,
75        pve_addr: ::std::net::IpAddr,
76        pve_fp: String,
77        quorum_votes: u64,
78    ) -> Self {
79        Self {
80            name,
81            pve_addr,
82            pve_fp,
83            quorum_votes,
84            nodeid: Default::default(),
85            ring0_addr: Default::default(),
86            additional_properties: Default::default(),
87        }
88    }
89}
90#[derive(Clone, Debug, :: serde :: Serialize, :: serde :: Deserialize)]
91pub struct NodelistGetOutputNodelistItems {
92    #[doc = "The cluster node name."]
93    pub name: String,
94    #[serde(
95        serialize_with = "crate::types::serialize_int_optional",
96        deserialize_with = "crate::types::deserialize_int_optional"
97    )]
98    #[serde(skip_serializing_if = "Option::is_none", default)]
99    #[doc = "Node id for this node."]
100    pub nodeid: Option<u64>,
101    pub pve_addr: ::std::net::IpAddr,
102    #[doc = "Certificate SHA 256 fingerprint."]
103    pub pve_fp: String,
104    #[serde(
105        serialize_with = "crate::types::serialize_int",
106        deserialize_with = "crate::types::deserialize_int"
107    )]
108    pub quorum_votes: u64,
109    #[serde(skip_serializing_if = "Option::is_none", default)]
110    #[doc = "Address and priority information of a single corosync link. (up to 8 links supported; link0..link7)"]
111    pub ring0_addr: Option<String>,
112    #[serde(
113        flatten,
114        default,
115        skip_serializing_if = "::std::collections::HashMap::is_empty"
116    )]
117    pub additional_properties: ::std::collections::HashMap<String, ::serde_json::Value>,
118}
119impl PostParams {
120    pub fn new(fingerprint: String, hostname: String, password: String) -> Self {
121        Self {
122            fingerprint,
123            hostname,
124            password,
125            force: Default::default(),
126            links: Default::default(),
127            nodeid: Default::default(),
128            votes: Default::default(),
129            additional_properties: Default::default(),
130        }
131    }
132}
133#[derive(Clone, Debug, :: serde :: Serialize, :: serde :: Deserialize)]
134pub struct PostParams {
135    #[doc = "Certificate SHA 256 fingerprint."]
136    pub fingerprint: String,
137    #[serde(
138        serialize_with = "crate::types::serialize_bool_optional",
139        deserialize_with = "crate::types::deserialize_bool_optional"
140    )]
141    #[serde(skip_serializing_if = "Option::is_none", default)]
142    #[doc = "Do not throw error if node already exists."]
143    pub force: Option<bool>,
144    #[doc = "Hostname (or IP) of an existing cluster member."]
145    pub hostname: String,
146    #[serde(rename = "link[n]")]
147    #[serde(
148        serialize_with = "crate::types::serialize_multi::<NumberedLinks, _>",
149        deserialize_with = "crate::types::deserialize_multi::<NumberedLinks, _>"
150    )]
151    #[serde(skip_serializing_if = "::std::collections::HashMap::is_empty", default)]
152    #[serde(flatten)]
153    #[doc = "Address and priority information of a single corosync link. (up to 8 links supported; link0..link7)"]
154    pub links: ::std::collections::HashMap<u32, String>,
155    #[serde(
156        serialize_with = "crate::types::serialize_int_optional",
157        deserialize_with = "crate::types::deserialize_int_optional"
158    )]
159    #[serde(skip_serializing_if = "Option::is_none", default)]
160    #[doc = "Node id for this node."]
161    pub nodeid: Option<u64>,
162    #[doc = "Superuser (root) password of peer node."]
163    pub password: String,
164    #[serde(
165        serialize_with = "crate::types::serialize_int_optional",
166        deserialize_with = "crate::types::deserialize_int_optional"
167    )]
168    #[serde(skip_serializing_if = "Option::is_none", default)]
169    #[doc = "Number of votes for this node"]
170    pub votes: Option<u64>,
171    #[serde(
172        flatten,
173        deserialize_with = "crate::types::multi::deserialize_additional_data::<'_, PostParams, _, _>"
174    )]
175    pub additional_properties: ::std::collections::HashMap<String, ::serde_json::Value>,
176}
177impl crate::types::multi::Test for PostParams {
178    fn test_fn() -> fn(&str) -> bool {
179        fn the_test(input: &str) -> bool {
180            let array = [
181                <NumberedLinks as crate::types::multi::NumberedItems>::key_matches
182                    as fn(&str) -> bool,
183            ];
184            array.iter().any(|f| f(input))
185        }
186        the_test as _
187    }
188}
189#[derive(Clone, Debug, :: serde :: Serialize, :: serde :: Deserialize, Default)]
190pub struct TotemGetOutputTotem {
191    #[serde(
192        flatten,
193        default,
194        skip_serializing_if = "::std::collections::HashMap::is_empty"
195    )]
196    pub additional_properties: ::std::collections::HashMap<String, ::serde_json::Value>,
197}
198#[derive(Default)]
199struct NumberedLinks;
200impl crate::types::multi::NumberedItems for NumberedLinks {
201    type Item = String;
202    const PREFIX: &'static str = "link";
203}