Skip to main content

proxmox_api/generated/cluster/ha/
groups.rs

1pub mod group;
2#[derive(Debug, Clone)]
3pub struct GroupsClient<T> {
4    client: T,
5    path: String,
6}
7impl<T> GroupsClient<T>
8where
9    T: crate::client::Client,
10{
11    pub fn new(client: T, parent_path: &str) -> Self {
12        Self {
13            client,
14            path: format!("{}{}", parent_path, "/groups"),
15        }
16    }
17}
18impl<T> GroupsClient<T>
19where
20    T: crate::client::Client,
21{
22    #[doc = "Get HA groups. (deprecated in favor of HA rules)"]
23    #[doc = ""]
24    #[doc = "Permission check: perm(\"/\", [\"Sys.Audit\"])"]
25    pub async fn get(&self) -> Result<Vec<GetOutputItems>, T::Error> {
26        let path = self.path.to_string();
27        let optional_vec: Option<Vec<GetOutputItems>> = self.client.get(&path, &()).await?;
28        Ok(optional_vec.unwrap_or_default())
29    }
30}
31impl<T> GroupsClient<T>
32where
33    T: crate::client::Client,
34{
35    #[doc = "Create a new HA group. (deprecated in favor of HA rules)"]
36    #[doc = ""]
37    #[doc = "Permission check: perm(\"/\", [\"Sys.Console\"])"]
38    pub async fn post(&self, params: PostParams) -> Result<(), T::Error> {
39        let path = self.path.to_string();
40        self.client.post(&path, &params).await
41    }
42}
43impl GetOutputItems {
44    pub fn new(group: String) -> Self {
45        Self {
46            group,
47            additional_properties: ::std::default::Default::default(),
48        }
49    }
50}
51#[derive(Clone, Debug, :: serde :: Serialize, :: serde :: Deserialize)]
52pub struct GetOutputItems {
53    pub group: String,
54    #[serde(
55        flatten,
56        default,
57        skip_serializing_if = "::std::collections::HashMap::is_empty"
58    )]
59    pub additional_properties: ::std::collections::HashMap<String, ::serde_json::Value>,
60}
61impl PostParams {
62    pub fn new(group: String, nodes: String) -> Self {
63        Self {
64            group,
65            nodes,
66            comment: ::std::default::Default::default(),
67            nofailback: ::std::default::Default::default(),
68            restricted: ::std::default::Default::default(),
69            ty: ::std::default::Default::default(),
70            additional_properties: ::std::default::Default::default(),
71        }
72    }
73}
74#[derive(Clone, Debug, :: serde :: Serialize, :: serde :: Deserialize)]
75pub struct PostParams {
76    #[serde(skip_serializing_if = "Option::is_none", default)]
77    #[doc = "Description."]
78    #[doc = ""]
79    pub comment: Option<CommentStr>,
80    #[doc = "The HA group identifier."]
81    #[doc = ""]
82    pub group: String,
83    #[doc = "List of cluster node names with optional priority."]
84    #[doc = ""]
85    #[doc = "List of cluster node members, where a priority can be given to each node. A resource will run on the available nodes with the highest priority. If there are more nodes in the highest priority class, the resources will get distributed to those nodes. The priorities have a relative meaning only. The higher the number, the higher the priority."]
86    #[doc = ""]
87    pub nodes: String,
88    #[serde(
89        serialize_with = "crate::types::serialize_bool_optional",
90        deserialize_with = "crate::types::deserialize_bool_optional"
91    )]
92    #[serde(skip_serializing_if = "Option::is_none", default)]
93    #[doc = "The CRM tries to run services on the node with the highest priority. If a node with higher priority comes online, the CRM migrates the service to that node. Enabling nofailback prevents that behavior."]
94    #[doc = ""]
95    pub nofailback: Option<bool>,
96    #[serde(
97        serialize_with = "crate::types::serialize_bool_optional",
98        deserialize_with = "crate::types::deserialize_bool_optional"
99    )]
100    #[serde(skip_serializing_if = "Option::is_none", default)]
101    #[doc = "Resources bound to restricted groups may only run on nodes defined by the group."]
102    #[doc = ""]
103    #[doc = "Resources bound to restricted groups may only run on nodes defined by the group. The resource will be placed in the stopped state if no group node member is online. Resources on unrestricted groups may run on any cluster node if all group members are offline, but they will migrate back as soon as a group member comes online. One can implement a 'preferred node' behavior using an unrestricted group with only one member."]
104    #[doc = ""]
105    pub restricted: Option<bool>,
106    #[serde(rename = "type")]
107    #[serde(skip_serializing_if = "Option::is_none", default)]
108    #[doc = "Group type."]
109    #[doc = ""]
110    pub ty: Option<Type>,
111    #[serde(
112        flatten,
113        default,
114        skip_serializing_if = "::std::collections::HashMap::is_empty"
115    )]
116    pub additional_properties: ::std::collections::HashMap<String, ::serde_json::Value>,
117}
118#[derive(Clone, Debug, :: serde :: Serialize, :: serde :: Deserialize, PartialEq)]
119#[doc = "Group type."]
120#[doc = ""]
121pub enum Type {
122    #[serde(rename = "group")]
123    Group,
124}
125impl TryFrom<&str> for Type {
126    type Error = String;
127    fn try_from(value: &str) -> Result<Self, <Self as TryFrom<&str>>::Error> {
128        match value {
129            "group" => Ok(Self::Group),
130            v => Err(format!("Unknown variant {v}")),
131        }
132    }
133}
134#[derive(Debug, Clone, PartialEq, PartialOrd)]
135pub struct CommentStr {
136    value: String,
137}
138impl crate::types::bounded_string::BoundedString for CommentStr {
139    const MIN_LENGTH: Option<usize> = None::<usize>;
140    const MAX_LENGTH: Option<usize> = Some(4096usize);
141    const DEFAULT: Option<&'static str> = None::<&'static str>;
142    const PATTERN: Option<&'static str> = None::<&'static str>;
143    const TYPE_DESCRIPTION: &'static str = "a string with length at most 4096";
144    fn get_value(&self) -> &str {
145        &self.value
146    }
147    fn new(value: String) -> Result<Self, crate::types::bounded_string::BoundedStringError> {
148        Self::validate(&value)?;
149        Ok(Self { value })
150    }
151}
152impl std::convert::TryFrom<String> for CommentStr {
153    type Error = crate::types::bounded_string::BoundedStringError;
154    fn try_from(value: String) -> Result<Self, Self::Error> {
155        crate::types::bounded_string::BoundedString::new(value)
156    }
157}
158impl ::serde::Serialize for CommentStr {
159    fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
160    where
161        S: ::serde::Serializer,
162    {
163        crate::types::bounded_string::serialize_bounded_string(self, serializer)
164    }
165}
166impl<'de> ::serde::Deserialize<'de> for CommentStr {
167    fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
168    where
169        D: ::serde::Deserializer<'de>,
170    {
171        crate::types::bounded_string::deserialize_bounded_string(deserializer)
172    }
173}
174impl<T> GroupsClient<T>
175where
176    T: crate::client::Client,
177{
178    pub fn group(&self, group: &str) -> group::GroupClient<T> {
179        group::GroupClient::<T>::new(self.client.clone(), &self.path, group)
180    }
181}