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

1pub mod migrate;
2pub mod relocate;
3pub struct SidClient<T> {
4    client: T,
5    path: String,
6}
7impl<T> SidClient<T>
8where
9    T: crate::client::Client,
10{
11    pub fn new(client: T, parent_path: &str, sid: &str) -> Self {
12        Self {
13            client,
14            path: format!("{}/{}", parent_path, sid),
15        }
16    }
17}
18impl<T> SidClient<T>
19where
20    T: crate::client::Client,
21{
22    #[doc = "Delete resource configuration."]
23    pub fn delete(&self) -> Result<(), T::Error> {
24        let path = self.path.to_string();
25        self.client.delete(&path, &())
26    }
27}
28impl<T> SidClient<T>
29where
30    T: crate::client::Client,
31{
32    #[doc = "Read resource configuration."]
33    pub fn get(&self) -> Result<GetOutput, T::Error> {
34        let path = self.path.to_string();
35        self.client.get(&path, &())
36    }
37}
38impl<T> SidClient<T>
39where
40    T: crate::client::Client,
41{
42    #[doc = "Update resource configuration."]
43    pub fn put(&self, params: PutParams) -> Result<(), T::Error> {
44        let path = self.path.to_string();
45        self.client.put(&path, &params)
46    }
47}
48impl GetOutput {
49    pub fn new(digest: String, sid: String, ty: String) -> Self {
50        Self {
51            digest,
52            sid,
53            ty,
54            comment: Default::default(),
55            group: Default::default(),
56            max_relocate: Default::default(),
57            max_restart: Default::default(),
58            state: Default::default(),
59            additional_properties: Default::default(),
60        }
61    }
62}
63#[derive(Clone, Debug, :: serde :: Serialize, :: serde :: Deserialize)]
64pub struct GetOutput {
65    #[serde(skip_serializing_if = "Option::is_none", default)]
66    #[doc = "Description."]
67    pub comment: Option<String>,
68    #[doc = "Can be used to prevent concurrent modifications."]
69    pub digest: String,
70    #[serde(skip_serializing_if = "Option::is_none", default)]
71    #[doc = "The HA group identifier."]
72    pub group: Option<String>,
73    #[serde(
74        serialize_with = "crate::types::serialize_int_optional",
75        deserialize_with = "crate::types::deserialize_int_optional"
76    )]
77    #[serde(skip_serializing_if = "Option::is_none", default)]
78    #[doc = "Maximal number of service relocate tries when a service failes to start."]
79    pub max_relocate: Option<u64>,
80    #[serde(
81        serialize_with = "crate::types::serialize_int_optional",
82        deserialize_with = "crate::types::deserialize_int_optional"
83    )]
84    #[serde(skip_serializing_if = "Option::is_none", default)]
85    #[doc = "Maximal number of tries to restart the service on a node after its start failed."]
86    pub max_restart: Option<u64>,
87    #[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)."]
88    pub sid: String,
89    #[serde(skip_serializing_if = "Option::is_none", default)]
90    #[doc = "Requested resource state."]
91    pub state: Option<State>,
92    #[serde(rename = "type")]
93    #[doc = "The type of the resources."]
94    pub ty: String,
95    #[serde(
96        flatten,
97        default,
98        skip_serializing_if = "::std::collections::HashMap::is_empty"
99    )]
100    pub additional_properties: ::std::collections::HashMap<String, ::serde_json::Value>,
101}
102#[derive(Clone, Debug, :: serde :: Serialize, :: serde :: Deserialize, Default)]
103pub struct PutParams {
104    #[serde(skip_serializing_if = "Option::is_none", default)]
105    #[doc = "Description."]
106    pub comment: Option<String>,
107    #[serde(skip_serializing_if = "Option::is_none", default)]
108    #[doc = "A list of settings you want to delete."]
109    pub delete: Option<String>,
110    #[serde(skip_serializing_if = "Option::is_none", default)]
111    #[doc = "Prevent changes if current configuration file has a different digest. This can be used to prevent concurrent modifications."]
112    pub digest: Option<String>,
113    #[serde(skip_serializing_if = "Option::is_none", default)]
114    #[doc = "The HA group identifier."]
115    pub group: Option<String>,
116    #[serde(
117        serialize_with = "crate::types::serialize_int_optional",
118        deserialize_with = "crate::types::deserialize_int_optional"
119    )]
120    #[serde(skip_serializing_if = "Option::is_none", default)]
121    #[doc = "Maximal number of service relocate tries when a service failes to start."]
122    pub max_relocate: Option<u64>,
123    #[serde(
124        serialize_with = "crate::types::serialize_int_optional",
125        deserialize_with = "crate::types::deserialize_int_optional"
126    )]
127    #[serde(skip_serializing_if = "Option::is_none", default)]
128    #[doc = "Maximal number of tries to restart the service on a node after its start failed."]
129    pub max_restart: Option<u64>,
130    #[serde(skip_serializing_if = "Option::is_none", default)]
131    #[doc = "Requested resource state."]
132    #[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"]
133    pub state: Option<State>,
134    #[serde(
135        flatten,
136        default,
137        skip_serializing_if = "::std::collections::HashMap::is_empty"
138    )]
139    pub additional_properties: ::std::collections::HashMap<String, ::serde_json::Value>,
140}
141#[derive(Clone, Debug, :: serde :: Serialize, :: serde :: Deserialize)]
142pub enum State {
143    #[serde(rename = "disabled")]
144    Disabled,
145    #[serde(rename = "enabled")]
146    Enabled,
147    #[serde(rename = "ignored")]
148    Ignored,
149    #[serde(rename = "started")]
150    Started,
151    #[serde(rename = "stopped")]
152    Stopped,
153}
154impl<T> SidClient<T>
155where
156    T: crate::client::Client,
157{
158    pub fn migrate(&self) -> migrate::MigrateClient<T> {
159        migrate::MigrateClient::<T>::new(self.client.clone(), &self.path)
160    }
161}
162impl<T> SidClient<T>
163where
164    T: crate::client::Client,
165{
166    pub fn relocate(&self) -> relocate::RelocateClient<T> {
167        relocate::RelocateClient::<T>::new(self.client.clone(), &self.path)
168    }
169}