Skip to main content

proxmox_api/generated/cluster/ha/resources/
sid.rs

1pub mod migrate;
2pub mod relocate;
3#[derive(Debug, Clone)]
4pub struct SidClient<T> {
5    client: T,
6    path: String,
7}
8impl<T> SidClient<T>
9where
10    T: crate::client::Client,
11{
12    pub fn new(client: T, parent_path: &str, sid: &str) -> Self {
13        Self {
14            client,
15            path: format!("{}/{}", parent_path, sid),
16        }
17    }
18}
19impl<T> SidClient<T>
20where
21    T: crate::client::Client,
22{
23    #[doc = "Delete resource configuration."]
24    #[doc = ""]
25    #[doc = "Permission check: perm(\"/\", [\"Sys.Console\"])"]
26    pub async fn delete(&self, params: DeleteParams) -> Result<(), T::Error> {
27        let path = self.path.to_string();
28        self.client.delete(&path, &params).await
29    }
30}
31impl<T> SidClient<T>
32where
33    T: crate::client::Client,
34{
35    #[doc = "Read resource configuration."]
36    #[doc = ""]
37    #[doc = "Permission check: perm(\"/\", [\"Sys.Audit\"])"]
38    pub async fn get(&self) -> Result<GetOutput, T::Error> {
39        let path = self.path.to_string();
40        self.client.get(&path, &()).await
41    }
42}
43impl<T> SidClient<T>
44where
45    T: crate::client::Client,
46{
47    #[doc = "Update resource configuration."]
48    #[doc = ""]
49    #[doc = "Permission check: perm(\"/\", [\"Sys.Console\"])"]
50    pub async fn put(&self, params: PutParams) -> Result<(), T::Error> {
51        let path = self.path.to_string();
52        self.client.put(&path, &params).await
53    }
54}
55#[derive(Clone, Debug, :: serde :: Serialize, :: serde :: Deserialize, Default)]
56pub struct DeleteParams {
57    #[serde(
58        serialize_with = "crate::types::serialize_bool_optional",
59        deserialize_with = "crate::types::deserialize_bool_optional"
60    )]
61    #[serde(skip_serializing_if = "Option::is_none", default)]
62    #[doc = "Remove this resource from rules that reference it, deleting the rule if this resource is the only resource in the rule"]
63    #[doc = ""]
64    pub purge: Option<bool>,
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 GetOutput {
73    pub fn new(digest: String, sid: String, ty: String) -> Self {
74        Self {
75            digest,
76            sid,
77            ty,
78            comment: ::std::default::Default::default(),
79            failback: ::std::default::Default::default(),
80            group: ::std::default::Default::default(),
81            max_relocate: ::std::default::Default::default(),
82            max_restart: ::std::default::Default::default(),
83            state: ::std::default::Default::default(),
84            additional_properties: ::std::default::Default::default(),
85        }
86    }
87}
88#[derive(Clone, Debug, :: serde :: Serialize, :: serde :: Deserialize)]
89pub struct GetOutput {
90    #[serde(skip_serializing_if = "Option::is_none", default)]
91    #[doc = "Description."]
92    #[doc = ""]
93    pub comment: Option<String>,
94    #[doc = "Can be used to prevent concurrent modifications."]
95    #[doc = ""]
96    pub digest: String,
97    #[serde(
98        serialize_with = "crate::types::serialize_bool_optional",
99        deserialize_with = "crate::types::deserialize_bool_optional"
100    )]
101    #[serde(skip_serializing_if = "Option::is_none", default)]
102    #[doc = "The HA resource is automatically migrated to the node with the highest priority according to their node affinity rule, if a node with a higher priority than the current node comes online."]
103    #[doc = ""]
104    pub failback: Option<bool>,
105    #[serde(skip_serializing_if = "Option::is_none", default)]
106    #[doc = "The HA group identifier."]
107    #[doc = ""]
108    pub group: Option<String>,
109    #[serde(
110        serialize_with = "crate::types::serialize_int_optional",
111        deserialize_with = "crate::types::deserialize_int_optional"
112    )]
113    #[serde(skip_serializing_if = "Option::is_none", default)]
114    #[doc = "Maximal number of service relocate tries when a service failes to start."]
115    #[doc = ""]
116    pub max_relocate: Option<i64>,
117    #[serde(
118        serialize_with = "crate::types::serialize_int_optional",
119        deserialize_with = "crate::types::deserialize_int_optional"
120    )]
121    #[serde(skip_serializing_if = "Option::is_none", default)]
122    #[doc = "Maximal number of tries to restart the service on a node after its start failed."]
123    #[doc = ""]
124    pub max_restart: Option<i64>,
125    #[doc = "HA resource ID. This consists of a resource type followed by a resource specific name, separated with colon (example: vm:100 / ct:100). For virtual machines and containers, you can simply use the VM or CT id as a shortcut (example: 100)."]
126    #[doc = ""]
127    pub sid: String,
128    #[serde(skip_serializing_if = "Option::is_none", default)]
129    #[doc = "Requested resource state."]
130    #[doc = ""]
131    pub state: Option<State>,
132    #[serde(rename = "type")]
133    #[doc = "The type of the resources."]
134    #[doc = ""]
135    pub ty: String,
136    #[serde(
137        flatten,
138        default,
139        skip_serializing_if = "::std::collections::HashMap::is_empty"
140    )]
141    pub additional_properties: ::std::collections::HashMap<String, ::serde_json::Value>,
142}
143#[derive(Clone, Debug, :: serde :: Serialize, :: serde :: Deserialize, Default)]
144pub struct PutParams {
145    #[serde(skip_serializing_if = "Option::is_none", default)]
146    #[doc = "Description."]
147    #[doc = ""]
148    pub comment: Option<CommentStr>,
149    #[serde(skip_serializing_if = "Option::is_none", default)]
150    #[doc = "A list of settings you want to delete."]
151    #[doc = ""]
152    pub delete: Option<DeleteStr>,
153    #[serde(skip_serializing_if = "Option::is_none", default)]
154    #[doc = "Prevent changes if current configuration file has a different digest. This can be used to prevent concurrent modifications."]
155    #[doc = ""]
156    pub digest: Option<DigestStr>,
157    #[serde(
158        serialize_with = "crate::types::serialize_bool_optional",
159        deserialize_with = "crate::types::deserialize_bool_optional"
160    )]
161    #[serde(skip_serializing_if = "Option::is_none", default)]
162    #[doc = "Automatically migrate HA resource to the node with the highest priority according to their node affinity  rules, if a node with a higher priority than the current node comes online."]
163    #[doc = ""]
164    pub failback: Option<bool>,
165    #[serde(skip_serializing_if = "Option::is_none", default)]
166    #[doc = "The HA group identifier."]
167    #[doc = ""]
168    pub group: Option<String>,
169    #[serde(skip_serializing_if = "Option::is_none", default)]
170    #[doc = "Maximal number of service relocate tries when a service failes to start."]
171    #[doc = ""]
172    pub max_relocate: Option<MaxRelocateInt>,
173    #[serde(skip_serializing_if = "Option::is_none", default)]
174    #[doc = "Maximal number of tries to restart the service on a node after its start failed."]
175    #[doc = ""]
176    pub max_restart: Option<MaxRestartInt>,
177    #[serde(skip_serializing_if = "Option::is_none", default)]
178    #[doc = "Requested resource state."]
179    #[doc = ""]
180    #[doc = "Requested resource state. The CRM reads this state and acts accordingly."]
181    #[doc = ""]
182    #[doc = "Please note that `enabled` is just an alias for `started`."]
183    #[doc = ""]
184    #[doc = "`started`;;"]
185    #[doc = ""]
186    #[doc = "The CRM tries to start the resource. Service state is"]
187    #[doc = ""]
188    #[doc = "set to `started` after successful start. On node failures, or when start"]
189    #[doc = ""]
190    #[doc = "fails, it tries to recover the resource.  If everything fails, service"]
191    #[doc = ""]
192    #[doc = "state it set to `error`."]
193    #[doc = ""]
194    #[doc = "`stopped`;;"]
195    #[doc = ""]
196    #[doc = "The CRM tries to keep the resource in `stopped` state, but it"]
197    #[doc = ""]
198    #[doc = "still tries to relocate the resources on node failures."]
199    #[doc = ""]
200    #[doc = "`disabled`;;"]
201    #[doc = ""]
202    #[doc = "The CRM tries to put the resource in `stopped` state, but does not try"]
203    #[doc = ""]
204    #[doc = "to relocate the resources on node failures. The main purpose of this"]
205    #[doc = ""]
206    #[doc = "state is error recovery, because it is the only way to move a resource out"]
207    #[doc = ""]
208    #[doc = "of the `error` state."]
209    #[doc = ""]
210    #[doc = "`ignored`;;"]
211    #[doc = ""]
212    #[doc = "The resource gets removed from the manager status and so the CRM and the LRM do"]
213    #[doc = ""]
214    #[doc = "not touch the resource anymore. All {pve} API calls affecting this resource"]
215    #[doc = ""]
216    #[doc = "will be executed, directly bypassing the HA stack. CRM commands will be thrown"]
217    #[doc = ""]
218    #[doc = "away while there source is in this state. The resource will not get relocated"]
219    #[doc = ""]
220    #[doc = "on node failures."]
221    #[doc = ""]
222    pub state: Option<State2>,
223    #[serde(
224        flatten,
225        default,
226        skip_serializing_if = "::std::collections::HashMap::is_empty"
227    )]
228    pub additional_properties: ::std::collections::HashMap<String, ::serde_json::Value>,
229}
230#[derive(Clone, Debug, :: serde :: Serialize, :: serde :: Deserialize, PartialEq)]
231#[doc = "Requested resource state."]
232#[doc = ""]
233pub enum State {
234    #[serde(rename = "disabled")]
235    Disabled,
236    #[serde(rename = "enabled")]
237    Enabled,
238    #[serde(rename = "ignored")]
239    Ignored,
240    #[serde(rename = "started")]
241    Started,
242    #[serde(rename = "stopped")]
243    Stopped,
244}
245impl TryFrom<&str> for State {
246    type Error = String;
247    fn try_from(value: &str) -> Result<Self, <Self as TryFrom<&str>>::Error> {
248        match value {
249            "disabled" => Ok(Self::Disabled),
250            "enabled" => Ok(Self::Enabled),
251            "ignored" => Ok(Self::Ignored),
252            "started" => Ok(Self::Started),
253            "stopped" => Ok(Self::Stopped),
254            v => Err(format!("Unknown variant {v}")),
255        }
256    }
257}
258#[derive(Clone, Debug, :: serde :: Serialize, :: serde :: Deserialize, PartialEq, Default)]
259#[doc = "Requested resource state."]
260#[doc = ""]
261#[doc = "Requested resource state. The CRM reads this state and acts accordingly."]
262#[doc = ""]
263#[doc = "Please note that `enabled` is just an alias for `started`."]
264#[doc = ""]
265#[doc = "`started`;;"]
266#[doc = ""]
267#[doc = "The CRM tries to start the resource. Service state is"]
268#[doc = ""]
269#[doc = "set to `started` after successful start. On node failures, or when start"]
270#[doc = ""]
271#[doc = "fails, it tries to recover the resource.  If everything fails, service"]
272#[doc = ""]
273#[doc = "state it set to `error`."]
274#[doc = ""]
275#[doc = "`stopped`;;"]
276#[doc = ""]
277#[doc = "The CRM tries to keep the resource in `stopped` state, but it"]
278#[doc = ""]
279#[doc = "still tries to relocate the resources on node failures."]
280#[doc = ""]
281#[doc = "`disabled`;;"]
282#[doc = ""]
283#[doc = "The CRM tries to put the resource in `stopped` state, but does not try"]
284#[doc = ""]
285#[doc = "to relocate the resources on node failures. The main purpose of this"]
286#[doc = ""]
287#[doc = "state is error recovery, because it is the only way to move a resource out"]
288#[doc = ""]
289#[doc = "of the `error` state."]
290#[doc = ""]
291#[doc = "`ignored`;;"]
292#[doc = ""]
293#[doc = "The resource gets removed from the manager status and so the CRM and the LRM do"]
294#[doc = ""]
295#[doc = "not touch the resource anymore. All {pve} API calls affecting this resource"]
296#[doc = ""]
297#[doc = "will be executed, directly bypassing the HA stack. CRM commands will be thrown"]
298#[doc = ""]
299#[doc = "away while there source is in this state. The resource will not get relocated"]
300#[doc = ""]
301#[doc = "on node failures."]
302#[doc = ""]
303pub enum State2 {
304    #[serde(rename = "disabled")]
305    Disabled,
306    #[serde(rename = "enabled")]
307    Enabled,
308    #[serde(rename = "ignored")]
309    Ignored,
310    #[serde(rename = "started")]
311    #[default]
312    Started,
313    #[serde(rename = "stopped")]
314    Stopped,
315}
316impl TryFrom<&str> for State2 {
317    type Error = String;
318    fn try_from(value: &str) -> Result<Self, <Self as TryFrom<&str>>::Error> {
319        match value {
320            "disabled" => Ok(Self::Disabled),
321            "enabled" => Ok(Self::Enabled),
322            "ignored" => Ok(Self::Ignored),
323            "started" => Ok(Self::Started),
324            "stopped" => Ok(Self::Stopped),
325            v => Err(format!("Unknown variant {v}")),
326        }
327    }
328}
329#[derive(Debug, Clone, Copy, PartialEq, PartialOrd)]
330pub struct MaxRelocateInt(i128);
331impl crate::types::bounded_integer::BoundedInteger for MaxRelocateInt {
332    const MIN: Option<i128> = Some(0i128);
333    const MAX: Option<i128> = None::<i128>;
334    const DEFAULT: Option<i128> = Some(1i128);
335    const TYPE_DESCRIPTION: &'static str = "an integer greater than or equal to 0";
336    fn get(&self) -> i128 {
337        self.0
338    }
339    fn new(value: i128) -> Result<Self, crate::types::bounded_integer::BoundedIntegerError> {
340        Self::validate(value)?;
341        Ok(Self(value))
342    }
343}
344impl std::convert::TryFrom<i128> for MaxRelocateInt {
345    type Error = crate::types::bounded_integer::BoundedIntegerError;
346    fn try_from(value: i128) -> Result<Self, Self::Error> {
347        crate::types::bounded_integer::BoundedInteger::new(value)
348    }
349}
350impl ::serde::Serialize for MaxRelocateInt {
351    fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
352    where
353        S: ::serde::Serializer,
354    {
355        crate::types::bounded_integer::serialize_bounded_integer(self, serializer)
356    }
357}
358impl<'de> ::serde::Deserialize<'de> for MaxRelocateInt {
359    fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
360    where
361        D: ::serde::Deserializer<'de>,
362    {
363        crate::types::bounded_integer::deserialize_bounded_integer(deserializer)
364    }
365}
366#[derive(Debug, Clone, Copy, PartialEq, PartialOrd)]
367pub struct MaxRestartInt(i128);
368impl crate::types::bounded_integer::BoundedInteger for MaxRestartInt {
369    const MIN: Option<i128> = Some(0i128);
370    const MAX: Option<i128> = None::<i128>;
371    const DEFAULT: Option<i128> = Some(1i128);
372    const TYPE_DESCRIPTION: &'static str = "an integer greater than or equal to 0";
373    fn get(&self) -> i128 {
374        self.0
375    }
376    fn new(value: i128) -> Result<Self, crate::types::bounded_integer::BoundedIntegerError> {
377        Self::validate(value)?;
378        Ok(Self(value))
379    }
380}
381impl std::convert::TryFrom<i128> for MaxRestartInt {
382    type Error = crate::types::bounded_integer::BoundedIntegerError;
383    fn try_from(value: i128) -> Result<Self, Self::Error> {
384        crate::types::bounded_integer::BoundedInteger::new(value)
385    }
386}
387impl ::serde::Serialize for MaxRestartInt {
388    fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
389    where
390        S: ::serde::Serializer,
391    {
392        crate::types::bounded_integer::serialize_bounded_integer(self, serializer)
393    }
394}
395impl<'de> ::serde::Deserialize<'de> for MaxRestartInt {
396    fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
397    where
398        D: ::serde::Deserializer<'de>,
399    {
400        crate::types::bounded_integer::deserialize_bounded_integer(deserializer)
401    }
402}
403#[derive(Debug, Clone, PartialEq, PartialOrd)]
404pub struct CommentStr {
405    value: String,
406}
407impl crate::types::bounded_string::BoundedString for CommentStr {
408    const MIN_LENGTH: Option<usize> = None::<usize>;
409    const MAX_LENGTH: Option<usize> = Some(4096usize);
410    const DEFAULT: Option<&'static str> = None::<&'static str>;
411    const PATTERN: Option<&'static str> = None::<&'static str>;
412    const TYPE_DESCRIPTION: &'static str = "a string with length at most 4096";
413    fn get_value(&self) -> &str {
414        &self.value
415    }
416    fn new(value: String) -> Result<Self, crate::types::bounded_string::BoundedStringError> {
417        Self::validate(&value)?;
418        Ok(Self { value })
419    }
420}
421impl std::convert::TryFrom<String> for CommentStr {
422    type Error = crate::types::bounded_string::BoundedStringError;
423    fn try_from(value: String) -> Result<Self, Self::Error> {
424        crate::types::bounded_string::BoundedString::new(value)
425    }
426}
427impl ::serde::Serialize for CommentStr {
428    fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
429    where
430        S: ::serde::Serializer,
431    {
432        crate::types::bounded_string::serialize_bounded_string(self, serializer)
433    }
434}
435impl<'de> ::serde::Deserialize<'de> for CommentStr {
436    fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
437    where
438        D: ::serde::Deserializer<'de>,
439    {
440        crate::types::bounded_string::deserialize_bounded_string(deserializer)
441    }
442}
443#[derive(Debug, Clone, PartialEq, PartialOrd)]
444pub struct DeleteStr {
445    value: String,
446}
447impl crate::types::bounded_string::BoundedString for DeleteStr {
448    const MIN_LENGTH: Option<usize> = None::<usize>;
449    const MAX_LENGTH: Option<usize> = Some(4096usize);
450    const DEFAULT: Option<&'static str> = None::<&'static str>;
451    const PATTERN: Option<&'static str> = None::<&'static str>;
452    const TYPE_DESCRIPTION: &'static str = "a string with length at most 4096";
453    fn get_value(&self) -> &str {
454        &self.value
455    }
456    fn new(value: String) -> Result<Self, crate::types::bounded_string::BoundedStringError> {
457        Self::validate(&value)?;
458        Ok(Self { value })
459    }
460}
461impl std::convert::TryFrom<String> for DeleteStr {
462    type Error = crate::types::bounded_string::BoundedStringError;
463    fn try_from(value: String) -> Result<Self, Self::Error> {
464        crate::types::bounded_string::BoundedString::new(value)
465    }
466}
467impl ::serde::Serialize for DeleteStr {
468    fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
469    where
470        S: ::serde::Serializer,
471    {
472        crate::types::bounded_string::serialize_bounded_string(self, serializer)
473    }
474}
475impl<'de> ::serde::Deserialize<'de> for DeleteStr {
476    fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
477    where
478        D: ::serde::Deserializer<'de>,
479    {
480        crate::types::bounded_string::deserialize_bounded_string(deserializer)
481    }
482}
483#[derive(Debug, Clone, PartialEq, PartialOrd)]
484pub struct DigestStr {
485    value: String,
486}
487impl crate::types::bounded_string::BoundedString for DigestStr {
488    const MIN_LENGTH: Option<usize> = None::<usize>;
489    const MAX_LENGTH: Option<usize> = Some(64usize);
490    const DEFAULT: Option<&'static str> = None::<&'static str>;
491    const PATTERN: Option<&'static str> = None::<&'static str>;
492    const TYPE_DESCRIPTION: &'static str = "a string with length at most 64";
493    fn get_value(&self) -> &str {
494        &self.value
495    }
496    fn new(value: String) -> Result<Self, crate::types::bounded_string::BoundedStringError> {
497        Self::validate(&value)?;
498        Ok(Self { value })
499    }
500}
501impl std::convert::TryFrom<String> for DigestStr {
502    type Error = crate::types::bounded_string::BoundedStringError;
503    fn try_from(value: String) -> Result<Self, Self::Error> {
504        crate::types::bounded_string::BoundedString::new(value)
505    }
506}
507impl ::serde::Serialize for DigestStr {
508    fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
509    where
510        S: ::serde::Serializer,
511    {
512        crate::types::bounded_string::serialize_bounded_string(self, serializer)
513    }
514}
515impl<'de> ::serde::Deserialize<'de> for DigestStr {
516    fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
517    where
518        D: ::serde::Deserializer<'de>,
519    {
520        crate::types::bounded_string::deserialize_bounded_string(deserializer)
521    }
522}
523impl<T> SidClient<T>
524where
525    T: crate::client::Client,
526{
527    pub fn migrate(&self) -> migrate::MigrateClient<T> {
528        migrate::MigrateClient::<T>::new(self.client.clone(), &self.path)
529    }
530}
531impl<T> SidClient<T>
532where
533    T: crate::client::Client,
534{
535    pub fn relocate(&self) -> relocate::RelocateClient<T> {
536        relocate::RelocateClient::<T>::new(self.client.clone(), &self.path)
537    }
538}