proxmox_api/generated/cluster/ha/
resources.rs

1pub mod sid;
2pub struct ResourcesClient<T> {
3    client: T,
4    path: String,
5}
6impl<T> ResourcesClient<T>
7where
8    T: crate::client::Client,
9{
10    pub fn new(client: T, parent_path: &str) -> Self {
11        Self {
12            client,
13            path: format!("{}{}", parent_path, "/resources"),
14        }
15    }
16}
17impl<T> ResourcesClient<T>
18where
19    T: crate::client::Client,
20{
21    #[doc = "List HA resources."]
22    pub fn get(&self, params: GetParams) -> Result<Vec<GetOutputItems>, T::Error> {
23        let path = self.path.to_string();
24        self.client.get(&path, &params)
25    }
26}
27impl<T> ResourcesClient<T>
28where
29    T: crate::client::Client,
30{
31    #[doc = "Create a new HA resource."]
32    pub fn post(&self, params: PostParams) -> Result<(), T::Error> {
33        let path = self.path.to_string();
34        self.client.post(&path, &params)
35    }
36}
37impl GetOutputItems {
38    pub fn new(sid: String) -> Self {
39        Self {
40            sid,
41            additional_properties: Default::default(),
42        }
43    }
44}
45#[derive(Clone, Debug, :: serde :: Serialize, :: serde :: Deserialize)]
46pub struct GetOutputItems {
47    pub sid: String,
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}
55#[derive(Clone, Debug, :: serde :: Serialize, :: serde :: Deserialize, Default)]
56pub struct GetParams {
57    #[serde(rename = "type")]
58    #[serde(skip_serializing_if = "Option::is_none", default)]
59    #[doc = "Only list resources of specific type"]
60    pub ty: Option<Type>,
61    #[serde(
62        flatten,
63        default,
64        skip_serializing_if = "::std::collections::HashMap::is_empty"
65    )]
66    pub additional_properties: ::std::collections::HashMap<String, ::serde_json::Value>,
67}
68impl PostParams {
69    pub fn new(sid: String) -> Self {
70        Self {
71            sid,
72            comment: Default::default(),
73            group: Default::default(),
74            max_relocate: Default::default(),
75            max_restart: Default::default(),
76            state: Default::default(),
77            ty: Default::default(),
78            additional_properties: Default::default(),
79        }
80    }
81}
82#[derive(Clone, Debug, :: serde :: Serialize, :: serde :: Deserialize)]
83pub struct PostParams {
84    #[serde(skip_serializing_if = "Option::is_none", default)]
85    #[doc = "Description."]
86    pub comment: Option<String>,
87    #[serde(skip_serializing_if = "Option::is_none", default)]
88    #[doc = "The HA group identifier."]
89    pub group: Option<String>,
90    #[serde(
91        serialize_with = "crate::types::serialize_int_optional",
92        deserialize_with = "crate::types::deserialize_int_optional"
93    )]
94    #[serde(skip_serializing_if = "Option::is_none", default)]
95    #[doc = "Maximal number of service relocate tries when a service failes to start."]
96    pub max_relocate: Option<u64>,
97    #[serde(
98        serialize_with = "crate::types::serialize_int_optional",
99        deserialize_with = "crate::types::deserialize_int_optional"
100    )]
101    #[serde(skip_serializing_if = "Option::is_none", default)]
102    #[doc = "Maximal number of tries to restart the service on a node after its start failed."]
103    pub max_restart: Option<u64>,
104    #[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)."]
105    pub sid: String,
106    #[serde(skip_serializing_if = "Option::is_none", default)]
107    #[doc = "Requested resource state."]
108    #[doc = "Requested resource state. The CRM reads this state and acts accordingly.\nPlease note that `enabled` is just an alias for `started`.\n\n`started`;;\n\nThe CRM tries to start the resource. Service state is\nset to `started` after successful start. On node failures, or when start\nfails, it tries to recover the resource.  If everything fails, service\nstate it set to `error`.\n\n`stopped`;;\n\nThe CRM tries to keep the resource in `stopped` state, but it\nstill tries to relocate the resources on node failures.\n\n`disabled`;;\n\nThe CRM tries to put the resource in `stopped` state, but does not try\nto relocate the resources on node failures. The main purpose of this\nstate is error recovery, because it is the only way to move a resource out\nof the `error` state.\n\n`ignored`;;\n\nThe resource gets removed from the manager status and so the CRM and the LRM do\nnot touch the resource anymore. All {pve} API calls affecting this resource\nwill be executed, directly bypassing the HA stack. CRM commands will be thrown\naway while there source is in this state. The resource will not get relocated\non node failures.\n\n"]
109    pub state: Option<State>,
110    #[serde(rename = "type")]
111    #[serde(skip_serializing_if = "Option::is_none", default)]
112    #[doc = "Resource type."]
113    pub ty: Option<Type>,
114    #[serde(
115        flatten,
116        default,
117        skip_serializing_if = "::std::collections::HashMap::is_empty"
118    )]
119    pub additional_properties: ::std::collections::HashMap<String, ::serde_json::Value>,
120}
121#[derive(Clone, Debug, :: serde :: Serialize, :: serde :: Deserialize)]
122pub enum State {
123    #[serde(rename = "disabled")]
124    Disabled,
125    #[serde(rename = "enabled")]
126    Enabled,
127    #[serde(rename = "ignored")]
128    Ignored,
129    #[serde(rename = "started")]
130    Started,
131    #[serde(rename = "stopped")]
132    Stopped,
133}
134impl Default for State {
135    fn default() -> Self {
136        Self::Started
137    }
138}
139#[derive(Clone, Debug, :: serde :: Serialize, :: serde :: Deserialize)]
140pub enum Type {
141    #[serde(rename = "ct")]
142    Ct,
143    #[serde(rename = "vm")]
144    Vm,
145}
146impl<T> ResourcesClient<T>
147where
148    T: crate::client::Client,
149{
150    pub fn sid(&self, sid: &str) -> sid::SidClient<T> {
151        sid::SidClient::<T>::new(self.client.clone(), &self.path, sid)
152    }
153}