proxmox_api/generated/cluster/ha/
resources.rs1pub mod sid;
2#[derive(Debug, Clone)]
3pub struct ResourcesClient<T> {
4 client: T,
5 path: String,
6}
7impl<T> ResourcesClient<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, "/resources"),
15 }
16 }
17}
18impl<T> ResourcesClient<T>
19where
20 T: crate::client::Client,
21{
22 #[doc = "List HA resources."]
23 #[doc = ""]
24 #[doc = "Permission check: perm(\"/\", [\"Sys.Audit\"])"]
25 pub async fn get(&self, params: GetParams) -> Result<Vec<GetOutputItems>, T::Error> {
26 let path = self.path.to_string();
27 let optional_vec: Option<Vec<GetOutputItems>> = self.client.get(&path, ¶ms).await?;
28 Ok(optional_vec.unwrap_or_default())
29 }
30}
31impl<T> ResourcesClient<T>
32where
33 T: crate::client::Client,
34{
35 #[doc = "Create a new HA resource."]
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, ¶ms).await
41 }
42}
43impl GetOutputItems {
44 pub fn new(sid: String) -> Self {
45 Self {
46 sid,
47 additional_properties: ::std::default::Default::default(),
48 }
49 }
50}
51#[derive(Clone, Debug, :: serde :: Serialize, :: serde :: Deserialize)]
52pub struct GetOutputItems {
53 pub sid: 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}
61#[derive(Clone, Debug, :: serde :: Serialize, :: serde :: Deserialize, Default)]
62pub struct GetParams {
63 #[serde(rename = "type")]
64 #[serde(skip_serializing_if = "Option::is_none", default)]
65 #[doc = "Only list resources of specific type"]
66 #[doc = ""]
67 pub ty: Option<Type>,
68 #[serde(
69 flatten,
70 default,
71 skip_serializing_if = "::std::collections::HashMap::is_empty"
72 )]
73 pub additional_properties: ::std::collections::HashMap<String, ::serde_json::Value>,
74}
75impl PostParams {
76 pub fn new(sid: String) -> Self {
77 Self {
78 sid,
79 comment: ::std::default::Default::default(),
80 failback: ::std::default::Default::default(),
81 group: ::std::default::Default::default(),
82 max_relocate: ::std::default::Default::default(),
83 max_restart: ::std::default::Default::default(),
84 state: ::std::default::Default::default(),
85 ty: ::std::default::Default::default(),
86 additional_properties: ::std::default::Default::default(),
87 }
88 }
89}
90#[derive(Clone, Debug, :: serde :: Serialize, :: serde :: Deserialize)]
91pub struct PostParams {
92 #[serde(skip_serializing_if = "Option::is_none", default)]
93 #[doc = "Description."]
94 #[doc = ""]
95 pub comment: Option<CommentStr>,
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 = "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."]
102 #[doc = ""]
103 pub failback: Option<bool>,
104 #[serde(skip_serializing_if = "Option::is_none", default)]
105 #[doc = "The HA group identifier."]
106 #[doc = ""]
107 pub group: Option<String>,
108 #[serde(skip_serializing_if = "Option::is_none", default)]
109 #[doc = "Maximal number of service relocate tries when a service failes to start."]
110 #[doc = ""]
111 pub max_relocate: Option<MaxRelocateInt>,
112 #[serde(skip_serializing_if = "Option::is_none", default)]
113 #[doc = "Maximal number of tries to restart the service on a node after its start failed."]
114 #[doc = ""]
115 pub max_restart: Option<MaxRestartInt>,
116 #[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)."]
117 #[doc = ""]
118 pub sid: String,
119 #[serde(skip_serializing_if = "Option::is_none", default)]
120 #[doc = "Requested resource state."]
121 #[doc = ""]
122 #[doc = "Requested resource state. The CRM reads this state and acts accordingly."]
123 #[doc = ""]
124 #[doc = "Please note that `enabled` is just an alias for `started`."]
125 #[doc = ""]
126 #[doc = "`started`;;"]
127 #[doc = ""]
128 #[doc = "The CRM tries to start the resource. Service state is"]
129 #[doc = ""]
130 #[doc = "set to `started` after successful start. On node failures, or when start"]
131 #[doc = ""]
132 #[doc = "fails, it tries to recover the resource. If everything fails, service"]
133 #[doc = ""]
134 #[doc = "state it set to `error`."]
135 #[doc = ""]
136 #[doc = "`stopped`;;"]
137 #[doc = ""]
138 #[doc = "The CRM tries to keep the resource in `stopped` state, but it"]
139 #[doc = ""]
140 #[doc = "still tries to relocate the resources on node failures."]
141 #[doc = ""]
142 #[doc = "`disabled`;;"]
143 #[doc = ""]
144 #[doc = "The CRM tries to put the resource in `stopped` state, but does not try"]
145 #[doc = ""]
146 #[doc = "to relocate the resources on node failures. The main purpose of this"]
147 #[doc = ""]
148 #[doc = "state is error recovery, because it is the only way to move a resource out"]
149 #[doc = ""]
150 #[doc = "of the `error` state."]
151 #[doc = ""]
152 #[doc = "`ignored`;;"]
153 #[doc = ""]
154 #[doc = "The resource gets removed from the manager status and so the CRM and the LRM do"]
155 #[doc = ""]
156 #[doc = "not touch the resource anymore. All {pve} API calls affecting this resource"]
157 #[doc = ""]
158 #[doc = "will be executed, directly bypassing the HA stack. CRM commands will be thrown"]
159 #[doc = ""]
160 #[doc = "away while there source is in this state. The resource will not get relocated"]
161 #[doc = ""]
162 #[doc = "on node failures."]
163 #[doc = ""]
164 pub state: Option<State>,
165 #[serde(rename = "type")]
166 #[serde(skip_serializing_if = "Option::is_none", default)]
167 #[doc = "Resource type."]
168 #[doc = ""]
169 pub ty: Option<Type>,
170 #[serde(
171 flatten,
172 default,
173 skip_serializing_if = "::std::collections::HashMap::is_empty"
174 )]
175 pub additional_properties: ::std::collections::HashMap<String, ::serde_json::Value>,
176}
177#[derive(Clone, Debug, :: serde :: Serialize, :: serde :: Deserialize, PartialEq, 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 = ""]
222pub enum State {
223 #[serde(rename = "disabled")]
224 Disabled,
225 #[serde(rename = "enabled")]
226 Enabled,
227 #[serde(rename = "ignored")]
228 Ignored,
229 #[serde(rename = "started")]
230 #[default]
231 Started,
232 #[serde(rename = "stopped")]
233 Stopped,
234}
235impl TryFrom<&str> for State {
236 type Error = String;
237 fn try_from(value: &str) -> Result<Self, <Self as TryFrom<&str>>::Error> {
238 match value {
239 "disabled" => Ok(Self::Disabled),
240 "enabled" => Ok(Self::Enabled),
241 "ignored" => Ok(Self::Ignored),
242 "started" => Ok(Self::Started),
243 "stopped" => Ok(Self::Stopped),
244 v => Err(format!("Unknown variant {v}")),
245 }
246 }
247}
248#[derive(Clone, Debug, :: serde :: Serialize, :: serde :: Deserialize, PartialEq)]
249#[doc = "Only list resources of specific type"]
250#[doc = ""]
251pub enum Type {
252 #[serde(rename = "ct")]
253 Ct,
254 #[serde(rename = "vm")]
255 Vm,
256}
257impl TryFrom<&str> for Type {
258 type Error = String;
259 fn try_from(value: &str) -> Result<Self, <Self as TryFrom<&str>>::Error> {
260 match value {
261 "ct" => Ok(Self::Ct),
262 "vm" => Ok(Self::Vm),
263 v => Err(format!("Unknown variant {v}")),
264 }
265 }
266}
267#[derive(Debug, Clone, Copy, PartialEq, PartialOrd)]
268pub struct MaxRelocateInt(i128);
269impl crate::types::bounded_integer::BoundedInteger for MaxRelocateInt {
270 const MIN: Option<i128> = Some(0i128);
271 const MAX: Option<i128> = None::<i128>;
272 const DEFAULT: Option<i128> = Some(1i128);
273 const TYPE_DESCRIPTION: &'static str = "an integer greater than or equal to 0";
274 fn get(&self) -> i128 {
275 self.0
276 }
277 fn new(value: i128) -> Result<Self, crate::types::bounded_integer::BoundedIntegerError> {
278 Self::validate(value)?;
279 Ok(Self(value))
280 }
281}
282impl std::convert::TryFrom<i128> for MaxRelocateInt {
283 type Error = crate::types::bounded_integer::BoundedIntegerError;
284 fn try_from(value: i128) -> Result<Self, Self::Error> {
285 crate::types::bounded_integer::BoundedInteger::new(value)
286 }
287}
288impl ::serde::Serialize for MaxRelocateInt {
289 fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
290 where
291 S: ::serde::Serializer,
292 {
293 crate::types::bounded_integer::serialize_bounded_integer(self, serializer)
294 }
295}
296impl<'de> ::serde::Deserialize<'de> for MaxRelocateInt {
297 fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
298 where
299 D: ::serde::Deserializer<'de>,
300 {
301 crate::types::bounded_integer::deserialize_bounded_integer(deserializer)
302 }
303}
304#[derive(Debug, Clone, Copy, PartialEq, PartialOrd)]
305pub struct MaxRestartInt(i128);
306impl crate::types::bounded_integer::BoundedInteger for MaxRestartInt {
307 const MIN: Option<i128> = Some(0i128);
308 const MAX: Option<i128> = None::<i128>;
309 const DEFAULT: Option<i128> = Some(1i128);
310 const TYPE_DESCRIPTION: &'static str = "an integer greater than or equal to 0";
311 fn get(&self) -> i128 {
312 self.0
313 }
314 fn new(value: i128) -> Result<Self, crate::types::bounded_integer::BoundedIntegerError> {
315 Self::validate(value)?;
316 Ok(Self(value))
317 }
318}
319impl std::convert::TryFrom<i128> for MaxRestartInt {
320 type Error = crate::types::bounded_integer::BoundedIntegerError;
321 fn try_from(value: i128) -> Result<Self, Self::Error> {
322 crate::types::bounded_integer::BoundedInteger::new(value)
323 }
324}
325impl ::serde::Serialize for MaxRestartInt {
326 fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
327 where
328 S: ::serde::Serializer,
329 {
330 crate::types::bounded_integer::serialize_bounded_integer(self, serializer)
331 }
332}
333impl<'de> ::serde::Deserialize<'de> for MaxRestartInt {
334 fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
335 where
336 D: ::serde::Deserializer<'de>,
337 {
338 crate::types::bounded_integer::deserialize_bounded_integer(deserializer)
339 }
340}
341#[derive(Debug, Clone, PartialEq, PartialOrd)]
342pub struct CommentStr {
343 value: String,
344}
345impl crate::types::bounded_string::BoundedString for CommentStr {
346 const MIN_LENGTH: Option<usize> = None::<usize>;
347 const MAX_LENGTH: Option<usize> = Some(4096usize);
348 const DEFAULT: Option<&'static str> = None::<&'static str>;
349 const PATTERN: Option<&'static str> = None::<&'static str>;
350 const TYPE_DESCRIPTION: &'static str = "a string with length at most 4096";
351 fn get_value(&self) -> &str {
352 &self.value
353 }
354 fn new(value: String) -> Result<Self, crate::types::bounded_string::BoundedStringError> {
355 Self::validate(&value)?;
356 Ok(Self { value })
357 }
358}
359impl std::convert::TryFrom<String> for CommentStr {
360 type Error = crate::types::bounded_string::BoundedStringError;
361 fn try_from(value: String) -> Result<Self, Self::Error> {
362 crate::types::bounded_string::BoundedString::new(value)
363 }
364}
365impl ::serde::Serialize for CommentStr {
366 fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
367 where
368 S: ::serde::Serializer,
369 {
370 crate::types::bounded_string::serialize_bounded_string(self, serializer)
371 }
372}
373impl<'de> ::serde::Deserialize<'de> for CommentStr {
374 fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
375 where
376 D: ::serde::Deserializer<'de>,
377 {
378 crate::types::bounded_string::deserialize_bounded_string(deserializer)
379 }
380}
381impl<T> ResourcesClient<T>
382where
383 T: crate::client::Client,
384{
385 pub fn sid(&self, sid: &str) -> sid::SidClient<T> {
386 sid::SidClient::<T>::new(self.client.clone(), &self.path, sid)
387 }
388}