Skip to main content

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

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