Skip to main content

proxmox_api/generated/cluster/
config.rs

1pub mod apiversion;
2pub mod join;
3pub mod nodes;
4pub mod qdevice;
5pub mod totem;
6#[derive(Debug, Clone)]
7pub struct ConfigClient<T> {
8    client: T,
9    path: String,
10}
11impl<T> ConfigClient<T>
12where
13    T: crate::client::Client,
14{
15    pub fn new(client: T, parent_path: &str) -> Self {
16        Self {
17            client,
18            path: format!("{}{}", parent_path, "/config"),
19        }
20    }
21}
22impl<T> ConfigClient<T>
23where
24    T: crate::client::Client,
25{
26    #[doc = "Directory index."]
27    #[doc = ""]
28    #[doc = "Permission check: perm(\"/\", [\"Sys.Audit\"])"]
29    pub async fn get(&self) -> Result<Vec<GetOutputItems>, T::Error> {
30        let path = self.path.to_string();
31        let optional_vec: Option<Vec<GetOutputItems>> = self.client.get(&path, &()).await?;
32        Ok(optional_vec.unwrap_or_default())
33    }
34}
35impl<T> ConfigClient<T>
36where
37    T: crate::client::Client,
38{
39    #[doc = "Generate new cluster configuration. If no links given, default to local IP address as link0."]
40    #[doc = ""]
41    pub async fn post(&self, params: PostParams) -> Result<String, T::Error> {
42        let path = self.path.to_string();
43        self.client.post(&path, &params).await
44    }
45}
46#[derive(Clone, Debug, :: serde :: Serialize, :: serde :: Deserialize, Default)]
47pub struct GetOutputItems {
48    #[serde(
49        flatten,
50        default,
51        skip_serializing_if = "::std::collections::HashMap::is_empty"
52    )]
53    pub additional_properties: ::std::collections::HashMap<String, ::serde_json::Value>,
54}
55impl PostParams {
56    pub fn new(clustername: ClusternameStr) -> Self {
57        Self {
58            clustername,
59            links: ::std::default::Default::default(),
60            nodeid: ::std::default::Default::default(),
61            votes: ::std::default::Default::default(),
62            additional_properties: ::std::default::Default::default(),
63        }
64    }
65}
66#[derive(Clone, Debug, :: serde :: Serialize, :: serde :: Deserialize)]
67pub struct PostParams {
68    #[doc = "The name of the cluster."]
69    #[doc = ""]
70    pub clustername: ClusternameStr,
71    #[serde(rename = "link[n]")]
72    #[serde(
73        serialize_with = "crate::types::serialize_multi::<NumberedLinks, _>",
74        deserialize_with = "crate::types::deserialize_multi::<NumberedLinks, _>"
75    )]
76    #[serde(skip_serializing_if = "::std::collections::HashMap::is_empty", default)]
77    #[serde(flatten)]
78    #[doc = "Address and priority information of a single corosync link. (up to 8 links supported; link0..link7)"]
79    #[doc = ""]
80    pub links: ::std::collections::HashMap<u32, String>,
81    #[serde(
82        serialize_with = "crate::types::serialize_non_zero_pos_int_optional",
83        deserialize_with = "crate::types::deserialize_non_zero_pos_int_optional"
84    )]
85    #[serde(skip_serializing_if = "Option::is_none", default)]
86    #[doc = "Node id for this node."]
87    #[doc = ""]
88    pub nodeid: Option<std::num::NonZeroU64>,
89    #[serde(
90        serialize_with = "crate::types::serialize_non_zero_pos_int_optional",
91        deserialize_with = "crate::types::deserialize_non_zero_pos_int_optional"
92    )]
93    #[serde(skip_serializing_if = "Option::is_none", default)]
94    #[doc = "Number of votes for this node."]
95    #[doc = ""]
96    pub votes: Option<std::num::NonZeroU64>,
97    #[serde(
98        flatten,
99        deserialize_with = "crate::types::multi::deserialize_additional_data::<'_, PostParams, _, _>"
100    )]
101    pub additional_properties: ::std::collections::HashMap<String, ::serde_json::Value>,
102}
103impl crate::types::multi::Test for PostParams {
104    fn test_fn() -> fn(&str) -> bool {
105        fn the_test(input: &str) -> bool {
106            let array = [
107                <NumberedLinks as crate::types::multi::NumberedItems>::key_matches
108                    as fn(&str) -> bool,
109            ];
110            array.iter().any(|f| f(input))
111        }
112        the_test as _
113    }
114}
115#[derive(Default)]
116struct NumberedLinks;
117impl crate::types::multi::NumberedItems for NumberedLinks {
118    type Item = String;
119    const PREFIX: &'static str = "link";
120}
121#[derive(Debug, Clone, PartialEq, PartialOrd)]
122pub struct ClusternameStr {
123    value: String,
124}
125impl crate::types::bounded_string::BoundedString for ClusternameStr {
126    const MIN_LENGTH: Option<usize> = None::<usize>;
127    const MAX_LENGTH: Option<usize> = Some(15usize);
128    const DEFAULT: Option<&'static str> = None::<&'static str>;
129    const PATTERN: Option<&'static str> = None::<&'static str>;
130    const TYPE_DESCRIPTION: &'static str = "a string with length at most 15";
131    fn get_value(&self) -> &str {
132        &self.value
133    }
134    fn new(value: String) -> Result<Self, crate::types::bounded_string::BoundedStringError> {
135        Self::validate(&value)?;
136        Ok(Self { value })
137    }
138}
139impl std::convert::TryFrom<String> for ClusternameStr {
140    type Error = crate::types::bounded_string::BoundedStringError;
141    fn try_from(value: String) -> Result<Self, Self::Error> {
142        crate::types::bounded_string::BoundedString::new(value)
143    }
144}
145impl ::serde::Serialize for ClusternameStr {
146    fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
147    where
148        S: ::serde::Serializer,
149    {
150        crate::types::bounded_string::serialize_bounded_string(self, serializer)
151    }
152}
153impl<'de> ::serde::Deserialize<'de> for ClusternameStr {
154    fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
155    where
156        D: ::serde::Deserializer<'de>,
157    {
158        crate::types::bounded_string::deserialize_bounded_string(deserializer)
159    }
160}
161impl<T> ConfigClient<T>
162where
163    T: crate::client::Client,
164{
165    pub fn apiversion(&self) -> apiversion::ApiversionClient<T> {
166        apiversion::ApiversionClient::<T>::new(self.client.clone(), &self.path)
167    }
168}
169impl<T> ConfigClient<T>
170where
171    T: crate::client::Client,
172{
173    pub fn nodes(&self) -> nodes::NodesClient<T> {
174        nodes::NodesClient::<T>::new(self.client.clone(), &self.path)
175    }
176}
177impl<T> ConfigClient<T>
178where
179    T: crate::client::Client,
180{
181    pub fn join(&self) -> join::JoinClient<T> {
182        join::JoinClient::<T>::new(self.client.clone(), &self.path)
183    }
184}
185impl<T> ConfigClient<T>
186where
187    T: crate::client::Client,
188{
189    pub fn totem(&self) -> totem::TotemClient<T> {
190        totem::TotemClient::<T>::new(self.client.clone(), &self.path)
191    }
192}
193impl<T> ConfigClient<T>
194where
195    T: crate::client::Client,
196{
197    pub fn qdevice(&self) -> qdevice::QdeviceClient<T> {
198        qdevice::QdeviceClient::<T>::new(self.client.clone(), &self.path)
199    }
200}