proxmox_api/generated/cluster/config/nodes/
node.rs

1pub struct NodeClient<T> {
2    client: T,
3    path: String,
4}
5impl<T> NodeClient<T>
6where
7    T: crate::client::Client,
8{
9    pub fn new(client: T, parent_path: &str, node: &str) -> Self {
10        Self {
11            client,
12            path: format!("{}/{}", parent_path, node),
13        }
14    }
15}
16impl<T> NodeClient<T>
17where
18    T: crate::client::Client,
19{
20    #[doc = "Removes a node from the cluster configuration."]
21    pub fn delete(&self) -> Result<(), T::Error> {
22        let path = self.path.to_string();
23        self.client.delete(&path, &())
24    }
25}
26impl<T> NodeClient<T>
27where
28    T: crate::client::Client,
29{
30    #[doc = "Adds a node to the cluster configuration. This call is for internal use."]
31    pub fn post(&self, params: PostParams) -> Result<PostOutput, T::Error> {
32        let path = self.path.to_string();
33        self.client.post(&path, &params)
34    }
35}
36impl PostOutput {
37    pub fn new(corosync_authkey: String, corosync_conf: String, warnings: Vec<String>) -> Self {
38        Self {
39            corosync_authkey,
40            corosync_conf,
41            warnings,
42            additional_properties: Default::default(),
43        }
44    }
45}
46#[derive(Clone, Debug, :: serde :: Serialize, :: serde :: Deserialize)]
47pub struct PostOutput {
48    pub corosync_authkey: String,
49    pub corosync_conf: String,
50    #[serde(skip_serializing_if = "::std::vec::Vec::is_empty", default)]
51    pub warnings: Vec<String>,
52    #[serde(
53        flatten,
54        default,
55        skip_serializing_if = "::std::collections::HashMap::is_empty"
56    )]
57    pub additional_properties: ::std::collections::HashMap<String, ::serde_json::Value>,
58}
59#[derive(Clone, Debug, :: serde :: Serialize, :: serde :: Deserialize, Default)]
60pub struct PostParams {
61    #[serde(
62        serialize_with = "crate::types::serialize_int_optional",
63        deserialize_with = "crate::types::deserialize_int_optional"
64    )]
65    #[serde(skip_serializing_if = "Option::is_none", default)]
66    #[doc = "The JOIN_API_VERSION of the new node."]
67    pub apiversion: Option<u64>,
68    #[serde(
69        serialize_with = "crate::types::serialize_bool_optional",
70        deserialize_with = "crate::types::deserialize_bool_optional"
71    )]
72    #[serde(skip_serializing_if = "Option::is_none", default)]
73    #[doc = "Do not throw error if node already exists."]
74    pub force: Option<bool>,
75    #[serde(rename = "link[n]")]
76    #[serde(
77        serialize_with = "crate::types::serialize_multi::<NumberedLinks, _>",
78        deserialize_with = "crate::types::deserialize_multi::<NumberedLinks, _>"
79    )]
80    #[serde(skip_serializing_if = "::std::collections::HashMap::is_empty", default)]
81    #[serde(flatten)]
82    #[doc = "Address and priority information of a single corosync link. (up to 8 links supported; link0..link7)"]
83    pub links: ::std::collections::HashMap<u32, String>,
84    #[serde(skip_serializing_if = "Option::is_none", default)]
85    #[doc = "IP Address of node to add. Used as fallback if no links are given."]
86    pub new_node_ip: Option<::std::net::IpAddr>,
87    #[serde(
88        serialize_with = "crate::types::serialize_int_optional",
89        deserialize_with = "crate::types::deserialize_int_optional"
90    )]
91    #[serde(skip_serializing_if = "Option::is_none", default)]
92    #[doc = "Node id for this node."]
93    pub nodeid: Option<u64>,
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 = "Number of votes for this node"]
100    pub votes: Option<u64>,
101    #[serde(
102        flatten,
103        deserialize_with = "crate::types::multi::deserialize_additional_data::<'_, PostParams, _, _>"
104    )]
105    pub additional_properties: ::std::collections::HashMap<String, ::serde_json::Value>,
106}
107impl crate::types::multi::Test for PostParams {
108    fn test_fn() -> fn(&str) -> bool {
109        fn the_test(input: &str) -> bool {
110            let array = [
111                <NumberedLinks as crate::types::multi::NumberedItems>::key_matches
112                    as fn(&str) -> bool,
113            ];
114            array.iter().any(|f| f(input))
115        }
116        the_test as _
117    }
118}
119#[derive(Default)]
120struct NumberedLinks;
121impl crate::types::multi::NumberedItems for NumberedLinks {
122    type Item = String;
123    const PREFIX: &'static str = "link";
124}