Skip to main content

clientapi_pve/apis/
cluster_ha_api.rs

1/*
2 * Proxmox Virtual Environment API
3 *
4 * Generated from apidoc.js. NOT an official Proxmox specification. See https://pve.proxmox.com/pve-docs/api-viewer/ for the upstream documentation.
5 *
6 * The version of the OpenAPI document: 9.x
7 * 
8 * Generated by: https://openapi-generator.tech
9 */
10
11
12use reqwest;
13use serde::{Deserialize, Serialize, de::Error as _};
14use crate::{apis::ResponseContent, models};
15use super::{Error, configuration, ContentType};
16
17
18/// struct for typed errors of method [`cluster_ha_arm_ha`]
19#[derive(Debug, Clone, Serialize, Deserialize)]
20#[serde(untagged)]
21pub enum ClusterHaArmHaError {
22    Status400(models::PveError),
23    Status401(models::PveError),
24    Status403(models::PveError),
25    Status404(models::PveError),
26    Status500(models::PveError),
27    Status501(models::PveError),
28    Status503(models::PveError),
29    UnknownValue(serde_json::Value),
30}
31
32/// struct for typed errors of method [`cluster_ha_create_groups`]
33#[derive(Debug, Clone, Serialize, Deserialize)]
34#[serde(untagged)]
35pub enum ClusterHaCreateGroupsError {
36    Status400(models::PveError),
37    Status401(models::PveError),
38    Status403(models::PveError),
39    Status404(models::PveError),
40    Status500(models::PveError),
41    Status501(models::PveError),
42    Status503(models::PveError),
43    UnknownValue(serde_json::Value),
44}
45
46/// struct for typed errors of method [`cluster_ha_create_resources`]
47#[derive(Debug, Clone, Serialize, Deserialize)]
48#[serde(untagged)]
49pub enum ClusterHaCreateResourcesError {
50    Status400(models::PveError),
51    Status401(models::PveError),
52    Status403(models::PveError),
53    Status404(models::PveError),
54    Status500(models::PveError),
55    Status501(models::PveError),
56    Status503(models::PveError),
57    UnknownValue(serde_json::Value),
58}
59
60/// struct for typed errors of method [`cluster_ha_create_rule`]
61#[derive(Debug, Clone, Serialize, Deserialize)]
62#[serde(untagged)]
63pub enum ClusterHaCreateRuleError {
64    Status400(models::PveError),
65    Status401(models::PveError),
66    Status403(models::PveError),
67    Status404(models::PveError),
68    Status500(models::PveError),
69    Status501(models::PveError),
70    Status503(models::PveError),
71    UnknownValue(serde_json::Value),
72}
73
74/// struct for typed errors of method [`cluster_ha_delete_groups`]
75#[derive(Debug, Clone, Serialize, Deserialize)]
76#[serde(untagged)]
77pub enum ClusterHaDeleteGroupsError {
78    Status400(models::PveError),
79    Status401(models::PveError),
80    Status403(models::PveError),
81    Status404(models::PveError),
82    Status500(models::PveError),
83    Status501(models::PveError),
84    Status503(models::PveError),
85    UnknownValue(serde_json::Value),
86}
87
88/// struct for typed errors of method [`cluster_ha_delete_resources`]
89#[derive(Debug, Clone, Serialize, Deserialize)]
90#[serde(untagged)]
91pub enum ClusterHaDeleteResourcesError {
92    Status400(models::PveError),
93    Status401(models::PveError),
94    Status403(models::PveError),
95    Status404(models::PveError),
96    Status500(models::PveError),
97    Status501(models::PveError),
98    Status503(models::PveError),
99    UnknownValue(serde_json::Value),
100}
101
102/// struct for typed errors of method [`cluster_ha_delete_rule`]
103#[derive(Debug, Clone, Serialize, Deserialize)]
104#[serde(untagged)]
105pub enum ClusterHaDeleteRuleError {
106    Status400(models::PveError),
107    Status401(models::PveError),
108    Status403(models::PveError),
109    Status404(models::PveError),
110    Status500(models::PveError),
111    Status501(models::PveError),
112    Status503(models::PveError),
113    UnknownValue(serde_json::Value),
114}
115
116/// struct for typed errors of method [`cluster_ha_disarm_ha`]
117#[derive(Debug, Clone, Serialize, Deserialize)]
118#[serde(untagged)]
119pub enum ClusterHaDisarmHaError {
120    Status400(models::PveError),
121    Status401(models::PveError),
122    Status403(models::PveError),
123    Status404(models::PveError),
124    Status500(models::PveError),
125    Status501(models::PveError),
126    Status503(models::PveError),
127    UnknownValue(serde_json::Value),
128}
129
130/// struct for typed errors of method [`cluster_ha_get_groups`]
131#[derive(Debug, Clone, Serialize, Deserialize)]
132#[serde(untagged)]
133pub enum ClusterHaGetGroupsError {
134    Status400(models::PveError),
135    Status401(models::PveError),
136    Status403(models::PveError),
137    Status404(models::PveError),
138    Status500(models::PveError),
139    Status501(models::PveError),
140    Status503(models::PveError),
141    UnknownValue(serde_json::Value),
142}
143
144/// struct for typed errors of method [`cluster_ha_get_ha`]
145#[derive(Debug, Clone, Serialize, Deserialize)]
146#[serde(untagged)]
147pub enum ClusterHaGetHaError {
148    Status400(models::PveError),
149    Status401(models::PveError),
150    Status403(models::PveError),
151    Status404(models::PveError),
152    Status500(models::PveError),
153    Status501(models::PveError),
154    Status503(models::PveError),
155    UnknownValue(serde_json::Value),
156}
157
158/// struct for typed errors of method [`cluster_ha_get_resources`]
159#[derive(Debug, Clone, Serialize, Deserialize)]
160#[serde(untagged)]
161pub enum ClusterHaGetResourcesError {
162    Status400(models::PveError),
163    Status401(models::PveError),
164    Status403(models::PveError),
165    Status404(models::PveError),
166    Status500(models::PveError),
167    Status501(models::PveError),
168    Status503(models::PveError),
169    UnknownValue(serde_json::Value),
170}
171
172/// struct for typed errors of method [`cluster_ha_get_rules`]
173#[derive(Debug, Clone, Serialize, Deserialize)]
174#[serde(untagged)]
175pub enum ClusterHaGetRulesError {
176    Status400(models::PveError),
177    Status401(models::PveError),
178    Status403(models::PveError),
179    Status404(models::PveError),
180    Status500(models::PveError),
181    Status501(models::PveError),
182    Status503(models::PveError),
183    UnknownValue(serde_json::Value),
184}
185
186/// struct for typed errors of method [`cluster_ha_get_status`]
187#[derive(Debug, Clone, Serialize, Deserialize)]
188#[serde(untagged)]
189pub enum ClusterHaGetStatusError {
190    Status400(models::PveError),
191    Status401(models::PveError),
192    Status403(models::PveError),
193    Status404(models::PveError),
194    Status500(models::PveError),
195    Status501(models::PveError),
196    Status503(models::PveError),
197    UnknownValue(serde_json::Value),
198}
199
200/// struct for typed errors of method [`cluster_ha_manager_status`]
201#[derive(Debug, Clone, Serialize, Deserialize)]
202#[serde(untagged)]
203pub enum ClusterHaManagerStatusError {
204    Status400(models::PveError),
205    Status401(models::PveError),
206    Status403(models::PveError),
207    Status404(models::PveError),
208    Status500(models::PveError),
209    Status501(models::PveError),
210    Status503(models::PveError),
211    UnknownValue(serde_json::Value),
212}
213
214/// struct for typed errors of method [`cluster_ha_migrate`]
215#[derive(Debug, Clone, Serialize, Deserialize)]
216#[serde(untagged)]
217pub enum ClusterHaMigrateError {
218    Status400(models::PveError),
219    Status401(models::PveError),
220    Status403(models::PveError),
221    Status404(models::PveError),
222    Status500(models::PveError),
223    Status501(models::PveError),
224    Status503(models::PveError),
225    UnknownValue(serde_json::Value),
226}
227
228/// struct for typed errors of method [`cluster_ha_read_get_groups`]
229#[derive(Debug, Clone, Serialize, Deserialize)]
230#[serde(untagged)]
231pub enum ClusterHaReadGetGroupsError {
232    Status400(models::PveError),
233    Status401(models::PveError),
234    Status403(models::PveError),
235    Status404(models::PveError),
236    Status500(models::PveError),
237    Status501(models::PveError),
238    Status503(models::PveError),
239    UnknownValue(serde_json::Value),
240}
241
242/// struct for typed errors of method [`cluster_ha_read_get_resources`]
243#[derive(Debug, Clone, Serialize, Deserialize)]
244#[serde(untagged)]
245pub enum ClusterHaReadGetResourcesError {
246    Status400(models::PveError),
247    Status401(models::PveError),
248    Status403(models::PveError),
249    Status404(models::PveError),
250    Status500(models::PveError),
251    Status501(models::PveError),
252    Status503(models::PveError),
253    UnknownValue(serde_json::Value),
254}
255
256/// struct for typed errors of method [`cluster_ha_read_rule`]
257#[derive(Debug, Clone, Serialize, Deserialize)]
258#[serde(untagged)]
259pub enum ClusterHaReadRuleError {
260    Status400(models::PveError),
261    Status401(models::PveError),
262    Status403(models::PveError),
263    Status404(models::PveError),
264    Status500(models::PveError),
265    Status501(models::PveError),
266    Status503(models::PveError),
267    UnknownValue(serde_json::Value),
268}
269
270/// struct for typed errors of method [`cluster_ha_relocate`]
271#[derive(Debug, Clone, Serialize, Deserialize)]
272#[serde(untagged)]
273pub enum ClusterHaRelocateError {
274    Status400(models::PveError),
275    Status401(models::PveError),
276    Status403(models::PveError),
277    Status404(models::PveError),
278    Status500(models::PveError),
279    Status501(models::PveError),
280    Status503(models::PveError),
281    UnknownValue(serde_json::Value),
282}
283
284/// struct for typed errors of method [`cluster_ha_status`]
285#[derive(Debug, Clone, Serialize, Deserialize)]
286#[serde(untagged)]
287pub enum ClusterHaStatusError {
288    Status400(models::PveError),
289    Status401(models::PveError),
290    Status403(models::PveError),
291    Status404(models::PveError),
292    Status500(models::PveError),
293    Status501(models::PveError),
294    Status503(models::PveError),
295    UnknownValue(serde_json::Value),
296}
297
298/// struct for typed errors of method [`cluster_ha_update_groups`]
299#[derive(Debug, Clone, Serialize, Deserialize)]
300#[serde(untagged)]
301pub enum ClusterHaUpdateGroupsError {
302    Status400(models::PveError),
303    Status401(models::PveError),
304    Status403(models::PveError),
305    Status404(models::PveError),
306    Status500(models::PveError),
307    Status501(models::PveError),
308    Status503(models::PveError),
309    UnknownValue(serde_json::Value),
310}
311
312/// struct for typed errors of method [`cluster_ha_update_resources`]
313#[derive(Debug, Clone, Serialize, Deserialize)]
314#[serde(untagged)]
315pub enum ClusterHaUpdateResourcesError {
316    Status400(models::PveError),
317    Status401(models::PveError),
318    Status403(models::PveError),
319    Status404(models::PveError),
320    Status500(models::PveError),
321    Status501(models::PveError),
322    Status503(models::PveError),
323    UnknownValue(serde_json::Value),
324}
325
326/// struct for typed errors of method [`cluster_ha_update_rule`]
327#[derive(Debug, Clone, Serialize, Deserialize)]
328#[serde(untagged)]
329pub enum ClusterHaUpdateRuleError {
330    Status400(models::PveError),
331    Status401(models::PveError),
332    Status403(models::PveError),
333    Status404(models::PveError),
334    Status500(models::PveError),
335    Status501(models::PveError),
336    Status503(models::PveError),
337    UnknownValue(serde_json::Value),
338}
339
340
341/// Request re-arming the HA stack after it was disarmed.
342pub async fn cluster_ha_arm_ha(configuration: &configuration::Configuration, ) -> Result<models::ClusterHaArmHaResponse, Error<ClusterHaArmHaError>> {
343
344    let uri_str = format!("{}/cluster/ha/status/arm-ha", configuration.base_path);
345    let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
346
347    if let Some(ref user_agent) = configuration.user_agent {
348        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
349    }
350    if let Some(ref apikey) = configuration.api_key {
351        let key = apikey.key.clone();
352        let value = match apikey.prefix {
353            Some(ref prefix) => format!("{} {}", prefix, key),
354            None => key,
355        };
356        req_builder = req_builder.header("Authorization", value);
357    };
358    if let Some(ref apikey) = configuration.api_key {
359        let key = apikey.key.clone();
360        let value = match apikey.prefix {
361            Some(ref prefix) => format!("{} {}", prefix, key),
362            None => key,
363        };
364        req_builder = req_builder.header("CSRFPreventionToken", value);
365    };
366
367    let req = req_builder.build()?;
368    let resp = configuration.client.execute(req).await?;
369
370    let status = resp.status();
371    let content_type = resp
372        .headers()
373        .get("content-type")
374        .and_then(|v| v.to_str().ok())
375        .unwrap_or("application/octet-stream");
376    let content_type = super::ContentType::from(content_type);
377
378    if !status.is_client_error() && !status.is_server_error() {
379        let content = resp.text().await?;
380        match content_type {
381            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
382            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::ClusterHaArmHaResponse`"))),
383            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::ClusterHaArmHaResponse`")))),
384        }
385    } else {
386        let content = resp.text().await?;
387        let entity: Option<ClusterHaArmHaError> = serde_json::from_str(&content).ok();
388        Err(Error::ResponseError(ResponseContent { status, content, entity }))
389    }
390}
391
392/// Create a new HA group. (deprecated in favor of HA rules)
393pub async fn cluster_ha_create_groups(configuration: &configuration::Configuration, cluster_ha_create_groups_request: models::ClusterHaCreateGroupsRequest) -> Result<models::ClusterHaCreateGroupsResponse, Error<ClusterHaCreateGroupsError>> {
394    // add a prefix to parameters to efficiently prevent name collisions
395    let p_body_cluster_ha_create_groups_request = cluster_ha_create_groups_request;
396
397    let uri_str = format!("{}/cluster/ha/groups", configuration.base_path);
398    let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
399
400    if let Some(ref user_agent) = configuration.user_agent {
401        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
402    }
403    if let Some(ref apikey) = configuration.api_key {
404        let key = apikey.key.clone();
405        let value = match apikey.prefix {
406            Some(ref prefix) => format!("{} {}", prefix, key),
407            None => key,
408        };
409        req_builder = req_builder.header("Authorization", value);
410    };
411    if let Some(ref apikey) = configuration.api_key {
412        let key = apikey.key.clone();
413        let value = match apikey.prefix {
414            Some(ref prefix) => format!("{} {}", prefix, key),
415            None => key,
416        };
417        req_builder = req_builder.header("CSRFPreventionToken", value);
418    };
419    req_builder = req_builder.json(&p_body_cluster_ha_create_groups_request);
420
421    let req = req_builder.build()?;
422    let resp = configuration.client.execute(req).await?;
423
424    let status = resp.status();
425    let content_type = resp
426        .headers()
427        .get("content-type")
428        .and_then(|v| v.to_str().ok())
429        .unwrap_or("application/octet-stream");
430    let content_type = super::ContentType::from(content_type);
431
432    if !status.is_client_error() && !status.is_server_error() {
433        let content = resp.text().await?;
434        match content_type {
435            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
436            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::ClusterHaCreateGroupsResponse`"))),
437            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::ClusterHaCreateGroupsResponse`")))),
438        }
439    } else {
440        let content = resp.text().await?;
441        let entity: Option<ClusterHaCreateGroupsError> = serde_json::from_str(&content).ok();
442        Err(Error::ResponseError(ResponseContent { status, content, entity }))
443    }
444}
445
446/// Create a new HA resource.
447pub async fn cluster_ha_create_resources(configuration: &configuration::Configuration, cluster_ha_create_resources_request: models::ClusterHaCreateResourcesRequest) -> Result<models::ClusterHaCreateResourcesResponse, Error<ClusterHaCreateResourcesError>> {
448    // add a prefix to parameters to efficiently prevent name collisions
449    let p_body_cluster_ha_create_resources_request = cluster_ha_create_resources_request;
450
451    let uri_str = format!("{}/cluster/ha/resources", configuration.base_path);
452    let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
453
454    if let Some(ref user_agent) = configuration.user_agent {
455        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
456    }
457    if let Some(ref apikey) = configuration.api_key {
458        let key = apikey.key.clone();
459        let value = match apikey.prefix {
460            Some(ref prefix) => format!("{} {}", prefix, key),
461            None => key,
462        };
463        req_builder = req_builder.header("Authorization", value);
464    };
465    if let Some(ref apikey) = configuration.api_key {
466        let key = apikey.key.clone();
467        let value = match apikey.prefix {
468            Some(ref prefix) => format!("{} {}", prefix, key),
469            None => key,
470        };
471        req_builder = req_builder.header("CSRFPreventionToken", value);
472    };
473    req_builder = req_builder.json(&p_body_cluster_ha_create_resources_request);
474
475    let req = req_builder.build()?;
476    let resp = configuration.client.execute(req).await?;
477
478    let status = resp.status();
479    let content_type = resp
480        .headers()
481        .get("content-type")
482        .and_then(|v| v.to_str().ok())
483        .unwrap_or("application/octet-stream");
484    let content_type = super::ContentType::from(content_type);
485
486    if !status.is_client_error() && !status.is_server_error() {
487        let content = resp.text().await?;
488        match content_type {
489            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
490            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::ClusterHaCreateResourcesResponse`"))),
491            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::ClusterHaCreateResourcesResponse`")))),
492        }
493    } else {
494        let content = resp.text().await?;
495        let entity: Option<ClusterHaCreateResourcesError> = serde_json::from_str(&content).ok();
496        Err(Error::ResponseError(ResponseContent { status, content, entity }))
497    }
498}
499
500/// Create HA rule.
501pub async fn cluster_ha_create_rule(configuration: &configuration::Configuration, cluster_ha_create_rule_request: models::ClusterHaCreateRuleRequest) -> Result<models::ClusterHaCreateRuleResponse, Error<ClusterHaCreateRuleError>> {
502    // add a prefix to parameters to efficiently prevent name collisions
503    let p_body_cluster_ha_create_rule_request = cluster_ha_create_rule_request;
504
505    let uri_str = format!("{}/cluster/ha/rules", configuration.base_path);
506    let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
507
508    if let Some(ref user_agent) = configuration.user_agent {
509        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
510    }
511    if let Some(ref apikey) = configuration.api_key {
512        let key = apikey.key.clone();
513        let value = match apikey.prefix {
514            Some(ref prefix) => format!("{} {}", prefix, key),
515            None => key,
516        };
517        req_builder = req_builder.header("Authorization", value);
518    };
519    if let Some(ref apikey) = configuration.api_key {
520        let key = apikey.key.clone();
521        let value = match apikey.prefix {
522            Some(ref prefix) => format!("{} {}", prefix, key),
523            None => key,
524        };
525        req_builder = req_builder.header("CSRFPreventionToken", value);
526    };
527    req_builder = req_builder.json(&p_body_cluster_ha_create_rule_request);
528
529    let req = req_builder.build()?;
530    let resp = configuration.client.execute(req).await?;
531
532    let status = resp.status();
533    let content_type = resp
534        .headers()
535        .get("content-type")
536        .and_then(|v| v.to_str().ok())
537        .unwrap_or("application/octet-stream");
538    let content_type = super::ContentType::from(content_type);
539
540    if !status.is_client_error() && !status.is_server_error() {
541        let content = resp.text().await?;
542        match content_type {
543            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
544            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::ClusterHaCreateRuleResponse`"))),
545            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::ClusterHaCreateRuleResponse`")))),
546        }
547    } else {
548        let content = resp.text().await?;
549        let entity: Option<ClusterHaCreateRuleError> = serde_json::from_str(&content).ok();
550        Err(Error::ResponseError(ResponseContent { status, content, entity }))
551    }
552}
553
554/// Delete ha group configuration. (deprecated in favor of HA rules)
555pub async fn cluster_ha_delete_groups(configuration: &configuration::Configuration, group: &str) -> Result<models::ClusterHaDeleteGroupsResponse, Error<ClusterHaDeleteGroupsError>> {
556    // add a prefix to parameters to efficiently prevent name collisions
557    let p_path_group = group;
558
559    let uri_str = format!("{}/cluster/ha/groups/{group}", configuration.base_path, group=crate::apis::urlencode(p_path_group));
560    let mut req_builder = configuration.client.request(reqwest::Method::DELETE, &uri_str);
561
562    if let Some(ref user_agent) = configuration.user_agent {
563        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
564    }
565    if let Some(ref apikey) = configuration.api_key {
566        let key = apikey.key.clone();
567        let value = match apikey.prefix {
568            Some(ref prefix) => format!("{} {}", prefix, key),
569            None => key,
570        };
571        req_builder = req_builder.header("Authorization", value);
572    };
573    if let Some(ref apikey) = configuration.api_key {
574        let key = apikey.key.clone();
575        let value = match apikey.prefix {
576            Some(ref prefix) => format!("{} {}", prefix, key),
577            None => key,
578        };
579        req_builder = req_builder.header("CSRFPreventionToken", value);
580    };
581
582    let req = req_builder.build()?;
583    let resp = configuration.client.execute(req).await?;
584
585    let status = resp.status();
586    let content_type = resp
587        .headers()
588        .get("content-type")
589        .and_then(|v| v.to_str().ok())
590        .unwrap_or("application/octet-stream");
591    let content_type = super::ContentType::from(content_type);
592
593    if !status.is_client_error() && !status.is_server_error() {
594        let content = resp.text().await?;
595        match content_type {
596            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
597            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::ClusterHaDeleteGroupsResponse`"))),
598            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::ClusterHaDeleteGroupsResponse`")))),
599        }
600    } else {
601        let content = resp.text().await?;
602        let entity: Option<ClusterHaDeleteGroupsError> = serde_json::from_str(&content).ok();
603        Err(Error::ResponseError(ResponseContent { status, content, entity }))
604    }
605}
606
607/// Delete resource configuration.
608pub async fn cluster_ha_delete_resources(configuration: &configuration::Configuration, sid: &str, purge: Option<&str>) -> Result<models::ClusterHaDeleteResourcesResponse, Error<ClusterHaDeleteResourcesError>> {
609    // add a prefix to parameters to efficiently prevent name collisions
610    let p_path_sid = sid;
611    let p_query_purge = purge;
612
613    let uri_str = format!("{}/cluster/ha/resources/{sid}", configuration.base_path, sid=crate::apis::urlencode(p_path_sid));
614    let mut req_builder = configuration.client.request(reqwest::Method::DELETE, &uri_str);
615
616    if let Some(ref param_value) = p_query_purge {
617        req_builder = req_builder.query(&[("purge", &param_value.to_string())]);
618    }
619    if let Some(ref user_agent) = configuration.user_agent {
620        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
621    }
622    if let Some(ref apikey) = configuration.api_key {
623        let key = apikey.key.clone();
624        let value = match apikey.prefix {
625            Some(ref prefix) => format!("{} {}", prefix, key),
626            None => key,
627        };
628        req_builder = req_builder.header("Authorization", value);
629    };
630    if let Some(ref apikey) = configuration.api_key {
631        let key = apikey.key.clone();
632        let value = match apikey.prefix {
633            Some(ref prefix) => format!("{} {}", prefix, key),
634            None => key,
635        };
636        req_builder = req_builder.header("CSRFPreventionToken", value);
637    };
638
639    let req = req_builder.build()?;
640    let resp = configuration.client.execute(req).await?;
641
642    let status = resp.status();
643    let content_type = resp
644        .headers()
645        .get("content-type")
646        .and_then(|v| v.to_str().ok())
647        .unwrap_or("application/octet-stream");
648    let content_type = super::ContentType::from(content_type);
649
650    if !status.is_client_error() && !status.is_server_error() {
651        let content = resp.text().await?;
652        match content_type {
653            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
654            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::ClusterHaDeleteResourcesResponse`"))),
655            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::ClusterHaDeleteResourcesResponse`")))),
656        }
657    } else {
658        let content = resp.text().await?;
659        let entity: Option<ClusterHaDeleteResourcesError> = serde_json::from_str(&content).ok();
660        Err(Error::ResponseError(ResponseContent { status, content, entity }))
661    }
662}
663
664/// Delete HA rule.
665pub async fn cluster_ha_delete_rule(configuration: &configuration::Configuration, rule: &str) -> Result<models::ClusterHaDeleteRuleResponse, Error<ClusterHaDeleteRuleError>> {
666    // add a prefix to parameters to efficiently prevent name collisions
667    let p_path_rule = rule;
668
669    let uri_str = format!("{}/cluster/ha/rules/{rule}", configuration.base_path, rule=crate::apis::urlencode(p_path_rule));
670    let mut req_builder = configuration.client.request(reqwest::Method::DELETE, &uri_str);
671
672    if let Some(ref user_agent) = configuration.user_agent {
673        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
674    }
675    if let Some(ref apikey) = configuration.api_key {
676        let key = apikey.key.clone();
677        let value = match apikey.prefix {
678            Some(ref prefix) => format!("{} {}", prefix, key),
679            None => key,
680        };
681        req_builder = req_builder.header("Authorization", value);
682    };
683    if let Some(ref apikey) = configuration.api_key {
684        let key = apikey.key.clone();
685        let value = match apikey.prefix {
686            Some(ref prefix) => format!("{} {}", prefix, key),
687            None => key,
688        };
689        req_builder = req_builder.header("CSRFPreventionToken", value);
690    };
691
692    let req = req_builder.build()?;
693    let resp = configuration.client.execute(req).await?;
694
695    let status = resp.status();
696    let content_type = resp
697        .headers()
698        .get("content-type")
699        .and_then(|v| v.to_str().ok())
700        .unwrap_or("application/octet-stream");
701    let content_type = super::ContentType::from(content_type);
702
703    if !status.is_client_error() && !status.is_server_error() {
704        let content = resp.text().await?;
705        match content_type {
706            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
707            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::ClusterHaDeleteRuleResponse`"))),
708            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::ClusterHaDeleteRuleResponse`")))),
709        }
710    } else {
711        let content = resp.text().await?;
712        let entity: Option<ClusterHaDeleteRuleError> = serde_json::from_str(&content).ok();
713        Err(Error::ResponseError(ResponseContent { status, content, entity }))
714    }
715}
716
717/// Request disarming the HA stack, releasing all watchdogs cluster-wide.
718pub async fn cluster_ha_disarm_ha(configuration: &configuration::Configuration, cluster_ha_disarm_ha_request: models::ClusterHaDisarmHaRequest) -> Result<models::ClusterHaDisarmHaResponse, Error<ClusterHaDisarmHaError>> {
719    // add a prefix to parameters to efficiently prevent name collisions
720    let p_body_cluster_ha_disarm_ha_request = cluster_ha_disarm_ha_request;
721
722    let uri_str = format!("{}/cluster/ha/status/disarm-ha", configuration.base_path);
723    let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
724
725    if let Some(ref user_agent) = configuration.user_agent {
726        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
727    }
728    if let Some(ref apikey) = configuration.api_key {
729        let key = apikey.key.clone();
730        let value = match apikey.prefix {
731            Some(ref prefix) => format!("{} {}", prefix, key),
732            None => key,
733        };
734        req_builder = req_builder.header("Authorization", value);
735    };
736    if let Some(ref apikey) = configuration.api_key {
737        let key = apikey.key.clone();
738        let value = match apikey.prefix {
739            Some(ref prefix) => format!("{} {}", prefix, key),
740            None => key,
741        };
742        req_builder = req_builder.header("CSRFPreventionToken", value);
743    };
744    req_builder = req_builder.json(&p_body_cluster_ha_disarm_ha_request);
745
746    let req = req_builder.build()?;
747    let resp = configuration.client.execute(req).await?;
748
749    let status = resp.status();
750    let content_type = resp
751        .headers()
752        .get("content-type")
753        .and_then(|v| v.to_str().ok())
754        .unwrap_or("application/octet-stream");
755    let content_type = super::ContentType::from(content_type);
756
757    if !status.is_client_error() && !status.is_server_error() {
758        let content = resp.text().await?;
759        match content_type {
760            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
761            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::ClusterHaDisarmHaResponse`"))),
762            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::ClusterHaDisarmHaResponse`")))),
763        }
764    } else {
765        let content = resp.text().await?;
766        let entity: Option<ClusterHaDisarmHaError> = serde_json::from_str(&content).ok();
767        Err(Error::ResponseError(ResponseContent { status, content, entity }))
768    }
769}
770
771/// Get HA groups. (deprecated in favor of HA rules)
772pub async fn cluster_ha_get_groups(configuration: &configuration::Configuration, ) -> Result<models::ClusterHaGetGroupsResponse, Error<ClusterHaGetGroupsError>> {
773
774    let uri_str = format!("{}/cluster/ha/groups", configuration.base_path);
775    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
776
777    if let Some(ref user_agent) = configuration.user_agent {
778        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
779    }
780    if let Some(ref apikey) = configuration.api_key {
781        let key = apikey.key.clone();
782        let value = match apikey.prefix {
783            Some(ref prefix) => format!("{} {}", prefix, key),
784            None => key,
785        };
786        req_builder = req_builder.header("Authorization", value);
787    };
788    if let Some(ref apikey) = configuration.api_key {
789        let key = apikey.key.clone();
790        let value = match apikey.prefix {
791            Some(ref prefix) => format!("{} {}", prefix, key),
792            None => key,
793        };
794        req_builder = req_builder.header("CSRFPreventionToken", value);
795    };
796
797    let req = req_builder.build()?;
798    let resp = configuration.client.execute(req).await?;
799
800    let status = resp.status();
801    let content_type = resp
802        .headers()
803        .get("content-type")
804        .and_then(|v| v.to_str().ok())
805        .unwrap_or("application/octet-stream");
806    let content_type = super::ContentType::from(content_type);
807
808    if !status.is_client_error() && !status.is_server_error() {
809        let content = resp.text().await?;
810        match content_type {
811            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
812            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::ClusterHaGetGroupsResponse`"))),
813            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::ClusterHaGetGroupsResponse`")))),
814        }
815    } else {
816        let content = resp.text().await?;
817        let entity: Option<ClusterHaGetGroupsError> = serde_json::from_str(&content).ok();
818        Err(Error::ResponseError(ResponseContent { status, content, entity }))
819    }
820}
821
822/// Directory index.
823pub async fn cluster_ha_get_ha(configuration: &configuration::Configuration, ) -> Result<models::ClusterHaGetHaResponse, Error<ClusterHaGetHaError>> {
824
825    let uri_str = format!("{}/cluster/ha", configuration.base_path);
826    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
827
828    if let Some(ref user_agent) = configuration.user_agent {
829        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
830    }
831    if let Some(ref apikey) = configuration.api_key {
832        let key = apikey.key.clone();
833        let value = match apikey.prefix {
834            Some(ref prefix) => format!("{} {}", prefix, key),
835            None => key,
836        };
837        req_builder = req_builder.header("Authorization", value);
838    };
839    if let Some(ref apikey) = configuration.api_key {
840        let key = apikey.key.clone();
841        let value = match apikey.prefix {
842            Some(ref prefix) => format!("{} {}", prefix, key),
843            None => key,
844        };
845        req_builder = req_builder.header("CSRFPreventionToken", value);
846    };
847
848    let req = req_builder.build()?;
849    let resp = configuration.client.execute(req).await?;
850
851    let status = resp.status();
852    let content_type = resp
853        .headers()
854        .get("content-type")
855        .and_then(|v| v.to_str().ok())
856        .unwrap_or("application/octet-stream");
857    let content_type = super::ContentType::from(content_type);
858
859    if !status.is_client_error() && !status.is_server_error() {
860        let content = resp.text().await?;
861        match content_type {
862            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
863            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::ClusterHaGetHaResponse`"))),
864            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::ClusterHaGetHaResponse`")))),
865        }
866    } else {
867        let content = resp.text().await?;
868        let entity: Option<ClusterHaGetHaError> = serde_json::from_str(&content).ok();
869        Err(Error::ResponseError(ResponseContent { status, content, entity }))
870    }
871}
872
873/// List HA resources.
874pub async fn cluster_ha_get_resources(configuration: &configuration::Configuration, r#type: Option<models::PveClusterHaTypeTypeEnum>) -> Result<models::ClusterHaGetResourcesResponse, Error<ClusterHaGetResourcesError>> {
875    // add a prefix to parameters to efficiently prevent name collisions
876    let p_query_type = r#type;
877
878    let uri_str = format!("{}/cluster/ha/resources", configuration.base_path);
879    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
880
881    if let Some(ref param_value) = p_query_type {
882        req_builder = req_builder.query(&[("type", &param_value.to_string())]);
883    }
884    if let Some(ref user_agent) = configuration.user_agent {
885        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
886    }
887    if let Some(ref apikey) = configuration.api_key {
888        let key = apikey.key.clone();
889        let value = match apikey.prefix {
890            Some(ref prefix) => format!("{} {}", prefix, key),
891            None => key,
892        };
893        req_builder = req_builder.header("Authorization", value);
894    };
895    if let Some(ref apikey) = configuration.api_key {
896        let key = apikey.key.clone();
897        let value = match apikey.prefix {
898            Some(ref prefix) => format!("{} {}", prefix, key),
899            None => key,
900        };
901        req_builder = req_builder.header("CSRFPreventionToken", value);
902    };
903
904    let req = req_builder.build()?;
905    let resp = configuration.client.execute(req).await?;
906
907    let status = resp.status();
908    let content_type = resp
909        .headers()
910        .get("content-type")
911        .and_then(|v| v.to_str().ok())
912        .unwrap_or("application/octet-stream");
913    let content_type = super::ContentType::from(content_type);
914
915    if !status.is_client_error() && !status.is_server_error() {
916        let content = resp.text().await?;
917        match content_type {
918            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
919            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::ClusterHaGetResourcesResponse`"))),
920            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::ClusterHaGetResourcesResponse`")))),
921        }
922    } else {
923        let content = resp.text().await?;
924        let entity: Option<ClusterHaGetResourcesError> = serde_json::from_str(&content).ok();
925        Err(Error::ResponseError(ResponseContent { status, content, entity }))
926    }
927}
928
929/// Get HA rules.
930pub async fn cluster_ha_get_rules(configuration: &configuration::Configuration, resource: Option<&str>, r#type: Option<models::PveCauseEnum>) -> Result<models::ClusterHaGetRulesResponse, Error<ClusterHaGetRulesError>> {
931    // add a prefix to parameters to efficiently prevent name collisions
932    let p_query_resource = resource;
933    let p_query_type = r#type;
934
935    let uri_str = format!("{}/cluster/ha/rules", configuration.base_path);
936    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
937
938    if let Some(ref param_value) = p_query_resource {
939        req_builder = req_builder.query(&[("resource", &param_value.to_string())]);
940    }
941    if let Some(ref param_value) = p_query_type {
942        req_builder = req_builder.query(&[("type", &param_value.to_string())]);
943    }
944    if let Some(ref user_agent) = configuration.user_agent {
945        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
946    }
947    if let Some(ref apikey) = configuration.api_key {
948        let key = apikey.key.clone();
949        let value = match apikey.prefix {
950            Some(ref prefix) => format!("{} {}", prefix, key),
951            None => key,
952        };
953        req_builder = req_builder.header("Authorization", value);
954    };
955    if let Some(ref apikey) = configuration.api_key {
956        let key = apikey.key.clone();
957        let value = match apikey.prefix {
958            Some(ref prefix) => format!("{} {}", prefix, key),
959            None => key,
960        };
961        req_builder = req_builder.header("CSRFPreventionToken", value);
962    };
963
964    let req = req_builder.build()?;
965    let resp = configuration.client.execute(req).await?;
966
967    let status = resp.status();
968    let content_type = resp
969        .headers()
970        .get("content-type")
971        .and_then(|v| v.to_str().ok())
972        .unwrap_or("application/octet-stream");
973    let content_type = super::ContentType::from(content_type);
974
975    if !status.is_client_error() && !status.is_server_error() {
976        let content = resp.text().await?;
977        match content_type {
978            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
979            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::ClusterHaGetRulesResponse`"))),
980            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::ClusterHaGetRulesResponse`")))),
981        }
982    } else {
983        let content = resp.text().await?;
984        let entity: Option<ClusterHaGetRulesError> = serde_json::from_str(&content).ok();
985        Err(Error::ResponseError(ResponseContent { status, content, entity }))
986    }
987}
988
989/// Directory index.
990pub async fn cluster_ha_get_status(configuration: &configuration::Configuration, ) -> Result<models::ClusterHaGetStatusResponse, Error<ClusterHaGetStatusError>> {
991
992    let uri_str = format!("{}/cluster/ha/status", configuration.base_path);
993    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
994
995    if let Some(ref user_agent) = configuration.user_agent {
996        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
997    }
998    if let Some(ref apikey) = configuration.api_key {
999        let key = apikey.key.clone();
1000        let value = match apikey.prefix {
1001            Some(ref prefix) => format!("{} {}", prefix, key),
1002            None => key,
1003        };
1004        req_builder = req_builder.header("Authorization", value);
1005    };
1006    if let Some(ref apikey) = configuration.api_key {
1007        let key = apikey.key.clone();
1008        let value = match apikey.prefix {
1009            Some(ref prefix) => format!("{} {}", prefix, key),
1010            None => key,
1011        };
1012        req_builder = req_builder.header("CSRFPreventionToken", value);
1013    };
1014
1015    let req = req_builder.build()?;
1016    let resp = configuration.client.execute(req).await?;
1017
1018    let status = resp.status();
1019    let content_type = resp
1020        .headers()
1021        .get("content-type")
1022        .and_then(|v| v.to_str().ok())
1023        .unwrap_or("application/octet-stream");
1024    let content_type = super::ContentType::from(content_type);
1025
1026    if !status.is_client_error() && !status.is_server_error() {
1027        let content = resp.text().await?;
1028        match content_type {
1029            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
1030            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::ClusterHaGetStatusResponse`"))),
1031            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::ClusterHaGetStatusResponse`")))),
1032        }
1033    } else {
1034        let content = resp.text().await?;
1035        let entity: Option<ClusterHaGetStatusError> = serde_json::from_str(&content).ok();
1036        Err(Error::ResponseError(ResponseContent { status, content, entity }))
1037    }
1038}
1039
1040/// Get full HA manager status, including LRM status.
1041pub async fn cluster_ha_manager_status(configuration: &configuration::Configuration, ) -> Result<models::ClusterHaManagerStatusResponse, Error<ClusterHaManagerStatusError>> {
1042
1043    let uri_str = format!("{}/cluster/ha/status/manager_status", configuration.base_path);
1044    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
1045
1046    if let Some(ref user_agent) = configuration.user_agent {
1047        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
1048    }
1049    if let Some(ref apikey) = configuration.api_key {
1050        let key = apikey.key.clone();
1051        let value = match apikey.prefix {
1052            Some(ref prefix) => format!("{} {}", prefix, key),
1053            None => key,
1054        };
1055        req_builder = req_builder.header("Authorization", value);
1056    };
1057    if let Some(ref apikey) = configuration.api_key {
1058        let key = apikey.key.clone();
1059        let value = match apikey.prefix {
1060            Some(ref prefix) => format!("{} {}", prefix, key),
1061            None => key,
1062        };
1063        req_builder = req_builder.header("CSRFPreventionToken", value);
1064    };
1065
1066    let req = req_builder.build()?;
1067    let resp = configuration.client.execute(req).await?;
1068
1069    let status = resp.status();
1070    let content_type = resp
1071        .headers()
1072        .get("content-type")
1073        .and_then(|v| v.to_str().ok())
1074        .unwrap_or("application/octet-stream");
1075    let content_type = super::ContentType::from(content_type);
1076
1077    if !status.is_client_error() && !status.is_server_error() {
1078        let content = resp.text().await?;
1079        match content_type {
1080            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
1081            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::ClusterHaManagerStatusResponse`"))),
1082            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::ClusterHaManagerStatusResponse`")))),
1083        }
1084    } else {
1085        let content = resp.text().await?;
1086        let entity: Option<ClusterHaManagerStatusError> = serde_json::from_str(&content).ok();
1087        Err(Error::ResponseError(ResponseContent { status, content, entity }))
1088    }
1089}
1090
1091/// Request resource migration (online) to another node.
1092pub async fn cluster_ha_migrate(configuration: &configuration::Configuration, sid: &str, cluster_ha_migrate_request: models::ClusterHaMigrateRequest) -> Result<models::ClusterHaMigrateResponse, Error<ClusterHaMigrateError>> {
1093    // add a prefix to parameters to efficiently prevent name collisions
1094    let p_path_sid = sid;
1095    let p_body_cluster_ha_migrate_request = cluster_ha_migrate_request;
1096
1097    let uri_str = format!("{}/cluster/ha/resources/{sid}/migrate", configuration.base_path, sid=crate::apis::urlencode(p_path_sid));
1098    let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
1099
1100    if let Some(ref user_agent) = configuration.user_agent {
1101        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
1102    }
1103    if let Some(ref apikey) = configuration.api_key {
1104        let key = apikey.key.clone();
1105        let value = match apikey.prefix {
1106            Some(ref prefix) => format!("{} {}", prefix, key),
1107            None => key,
1108        };
1109        req_builder = req_builder.header("Authorization", value);
1110    };
1111    if let Some(ref apikey) = configuration.api_key {
1112        let key = apikey.key.clone();
1113        let value = match apikey.prefix {
1114            Some(ref prefix) => format!("{} {}", prefix, key),
1115            None => key,
1116        };
1117        req_builder = req_builder.header("CSRFPreventionToken", value);
1118    };
1119    req_builder = req_builder.json(&p_body_cluster_ha_migrate_request);
1120
1121    let req = req_builder.build()?;
1122    let resp = configuration.client.execute(req).await?;
1123
1124    let status = resp.status();
1125    let content_type = resp
1126        .headers()
1127        .get("content-type")
1128        .and_then(|v| v.to_str().ok())
1129        .unwrap_or("application/octet-stream");
1130    let content_type = super::ContentType::from(content_type);
1131
1132    if !status.is_client_error() && !status.is_server_error() {
1133        let content = resp.text().await?;
1134        match content_type {
1135            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
1136            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::ClusterHaMigrateResponse`"))),
1137            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::ClusterHaMigrateResponse`")))),
1138        }
1139    } else {
1140        let content = resp.text().await?;
1141        let entity: Option<ClusterHaMigrateError> = serde_json::from_str(&content).ok();
1142        Err(Error::ResponseError(ResponseContent { status, content, entity }))
1143    }
1144}
1145
1146/// Read ha group configuration. (deprecated in favor of HA rules)
1147pub async fn cluster_ha_read_get_groups(configuration: &configuration::Configuration, group: &str) -> Result<models::ClusterHaReadGetGroupsResponse, Error<ClusterHaReadGetGroupsError>> {
1148    // add a prefix to parameters to efficiently prevent name collisions
1149    let p_path_group = group;
1150
1151    let uri_str = format!("{}/cluster/ha/groups/{group}", configuration.base_path, group=crate::apis::urlencode(p_path_group));
1152    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
1153
1154    if let Some(ref user_agent) = configuration.user_agent {
1155        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
1156    }
1157    if let Some(ref apikey) = configuration.api_key {
1158        let key = apikey.key.clone();
1159        let value = match apikey.prefix {
1160            Some(ref prefix) => format!("{} {}", prefix, key),
1161            None => key,
1162        };
1163        req_builder = req_builder.header("Authorization", value);
1164    };
1165    if let Some(ref apikey) = configuration.api_key {
1166        let key = apikey.key.clone();
1167        let value = match apikey.prefix {
1168            Some(ref prefix) => format!("{} {}", prefix, key),
1169            None => key,
1170        };
1171        req_builder = req_builder.header("CSRFPreventionToken", value);
1172    };
1173
1174    let req = req_builder.build()?;
1175    let resp = configuration.client.execute(req).await?;
1176
1177    let status = resp.status();
1178    let content_type = resp
1179        .headers()
1180        .get("content-type")
1181        .and_then(|v| v.to_str().ok())
1182        .unwrap_or("application/octet-stream");
1183    let content_type = super::ContentType::from(content_type);
1184
1185    if !status.is_client_error() && !status.is_server_error() {
1186        let content = resp.text().await?;
1187        match content_type {
1188            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
1189            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::ClusterHaReadGetGroupsResponse`"))),
1190            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::ClusterHaReadGetGroupsResponse`")))),
1191        }
1192    } else {
1193        let content = resp.text().await?;
1194        let entity: Option<ClusterHaReadGetGroupsError> = serde_json::from_str(&content).ok();
1195        Err(Error::ResponseError(ResponseContent { status, content, entity }))
1196    }
1197}
1198
1199/// Read resource configuration.
1200pub async fn cluster_ha_read_get_resources(configuration: &configuration::Configuration, sid: &str) -> Result<models::ClusterHaReadGetResourcesResponse, Error<ClusterHaReadGetResourcesError>> {
1201    // add a prefix to parameters to efficiently prevent name collisions
1202    let p_path_sid = sid;
1203
1204    let uri_str = format!("{}/cluster/ha/resources/{sid}", configuration.base_path, sid=crate::apis::urlencode(p_path_sid));
1205    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
1206
1207    if let Some(ref user_agent) = configuration.user_agent {
1208        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
1209    }
1210    if let Some(ref apikey) = configuration.api_key {
1211        let key = apikey.key.clone();
1212        let value = match apikey.prefix {
1213            Some(ref prefix) => format!("{} {}", prefix, key),
1214            None => key,
1215        };
1216        req_builder = req_builder.header("Authorization", value);
1217    };
1218    if let Some(ref apikey) = configuration.api_key {
1219        let key = apikey.key.clone();
1220        let value = match apikey.prefix {
1221            Some(ref prefix) => format!("{} {}", prefix, key),
1222            None => key,
1223        };
1224        req_builder = req_builder.header("CSRFPreventionToken", value);
1225    };
1226
1227    let req = req_builder.build()?;
1228    let resp = configuration.client.execute(req).await?;
1229
1230    let status = resp.status();
1231    let content_type = resp
1232        .headers()
1233        .get("content-type")
1234        .and_then(|v| v.to_str().ok())
1235        .unwrap_or("application/octet-stream");
1236    let content_type = super::ContentType::from(content_type);
1237
1238    if !status.is_client_error() && !status.is_server_error() {
1239        let content = resp.text().await?;
1240        match content_type {
1241            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
1242            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::ClusterHaReadGetResourcesResponse`"))),
1243            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::ClusterHaReadGetResourcesResponse`")))),
1244        }
1245    } else {
1246        let content = resp.text().await?;
1247        let entity: Option<ClusterHaReadGetResourcesError> = serde_json::from_str(&content).ok();
1248        Err(Error::ResponseError(ResponseContent { status, content, entity }))
1249    }
1250}
1251
1252/// Read HA rule.
1253pub async fn cluster_ha_read_rule(configuration: &configuration::Configuration, rule: &str) -> Result<models::ClusterHaReadRuleResponse, Error<ClusterHaReadRuleError>> {
1254    // add a prefix to parameters to efficiently prevent name collisions
1255    let p_path_rule = rule;
1256
1257    let uri_str = format!("{}/cluster/ha/rules/{rule}", configuration.base_path, rule=crate::apis::urlencode(p_path_rule));
1258    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
1259
1260    if let Some(ref user_agent) = configuration.user_agent {
1261        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
1262    }
1263    if let Some(ref apikey) = configuration.api_key {
1264        let key = apikey.key.clone();
1265        let value = match apikey.prefix {
1266            Some(ref prefix) => format!("{} {}", prefix, key),
1267            None => key,
1268        };
1269        req_builder = req_builder.header("Authorization", value);
1270    };
1271    if let Some(ref apikey) = configuration.api_key {
1272        let key = apikey.key.clone();
1273        let value = match apikey.prefix {
1274            Some(ref prefix) => format!("{} {}", prefix, key),
1275            None => key,
1276        };
1277        req_builder = req_builder.header("CSRFPreventionToken", value);
1278    };
1279
1280    let req = req_builder.build()?;
1281    let resp = configuration.client.execute(req).await?;
1282
1283    let status = resp.status();
1284    let content_type = resp
1285        .headers()
1286        .get("content-type")
1287        .and_then(|v| v.to_str().ok())
1288        .unwrap_or("application/octet-stream");
1289    let content_type = super::ContentType::from(content_type);
1290
1291    if !status.is_client_error() && !status.is_server_error() {
1292        let content = resp.text().await?;
1293        match content_type {
1294            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
1295            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::ClusterHaReadRuleResponse`"))),
1296            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::ClusterHaReadRuleResponse`")))),
1297        }
1298    } else {
1299        let content = resp.text().await?;
1300        let entity: Option<ClusterHaReadRuleError> = serde_json::from_str(&content).ok();
1301        Err(Error::ResponseError(ResponseContent { status, content, entity }))
1302    }
1303}
1304
1305/// Request resource relocation to another node. This stops the service on the old node, and restarts it on the target node.
1306pub async fn cluster_ha_relocate(configuration: &configuration::Configuration, sid: &str, cluster_ha_migrate_request: models::ClusterHaMigrateRequest) -> Result<models::ClusterHaRelocateResponse, Error<ClusterHaRelocateError>> {
1307    // add a prefix to parameters to efficiently prevent name collisions
1308    let p_path_sid = sid;
1309    let p_body_cluster_ha_migrate_request = cluster_ha_migrate_request;
1310
1311    let uri_str = format!("{}/cluster/ha/resources/{sid}/relocate", configuration.base_path, sid=crate::apis::urlencode(p_path_sid));
1312    let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
1313
1314    if let Some(ref user_agent) = configuration.user_agent {
1315        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
1316    }
1317    if let Some(ref apikey) = configuration.api_key {
1318        let key = apikey.key.clone();
1319        let value = match apikey.prefix {
1320            Some(ref prefix) => format!("{} {}", prefix, key),
1321            None => key,
1322        };
1323        req_builder = req_builder.header("Authorization", value);
1324    };
1325    if let Some(ref apikey) = configuration.api_key {
1326        let key = apikey.key.clone();
1327        let value = match apikey.prefix {
1328            Some(ref prefix) => format!("{} {}", prefix, key),
1329            None => key,
1330        };
1331        req_builder = req_builder.header("CSRFPreventionToken", value);
1332    };
1333    req_builder = req_builder.json(&p_body_cluster_ha_migrate_request);
1334
1335    let req = req_builder.build()?;
1336    let resp = configuration.client.execute(req).await?;
1337
1338    let status = resp.status();
1339    let content_type = resp
1340        .headers()
1341        .get("content-type")
1342        .and_then(|v| v.to_str().ok())
1343        .unwrap_or("application/octet-stream");
1344    let content_type = super::ContentType::from(content_type);
1345
1346    if !status.is_client_error() && !status.is_server_error() {
1347        let content = resp.text().await?;
1348        match content_type {
1349            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
1350            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::ClusterHaRelocateResponse`"))),
1351            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::ClusterHaRelocateResponse`")))),
1352        }
1353    } else {
1354        let content = resp.text().await?;
1355        let entity: Option<ClusterHaRelocateError> = serde_json::from_str(&content).ok();
1356        Err(Error::ResponseError(ResponseContent { status, content, entity }))
1357    }
1358}
1359
1360/// Get HA manager status.
1361pub async fn cluster_ha_status(configuration: &configuration::Configuration, ) -> Result<models::ClusterHaStatusResponse, Error<ClusterHaStatusError>> {
1362
1363    let uri_str = format!("{}/cluster/ha/status/current", configuration.base_path);
1364    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
1365
1366    if let Some(ref user_agent) = configuration.user_agent {
1367        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
1368    }
1369    if let Some(ref apikey) = configuration.api_key {
1370        let key = apikey.key.clone();
1371        let value = match apikey.prefix {
1372            Some(ref prefix) => format!("{} {}", prefix, key),
1373            None => key,
1374        };
1375        req_builder = req_builder.header("Authorization", value);
1376    };
1377    if let Some(ref apikey) = configuration.api_key {
1378        let key = apikey.key.clone();
1379        let value = match apikey.prefix {
1380            Some(ref prefix) => format!("{} {}", prefix, key),
1381            None => key,
1382        };
1383        req_builder = req_builder.header("CSRFPreventionToken", value);
1384    };
1385
1386    let req = req_builder.build()?;
1387    let resp = configuration.client.execute(req).await?;
1388
1389    let status = resp.status();
1390    let content_type = resp
1391        .headers()
1392        .get("content-type")
1393        .and_then(|v| v.to_str().ok())
1394        .unwrap_or("application/octet-stream");
1395    let content_type = super::ContentType::from(content_type);
1396
1397    if !status.is_client_error() && !status.is_server_error() {
1398        let content = resp.text().await?;
1399        match content_type {
1400            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
1401            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::ClusterHaStatusResponse`"))),
1402            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::ClusterHaStatusResponse`")))),
1403        }
1404    } else {
1405        let content = resp.text().await?;
1406        let entity: Option<ClusterHaStatusError> = serde_json::from_str(&content).ok();
1407        Err(Error::ResponseError(ResponseContent { status, content, entity }))
1408    }
1409}
1410
1411/// Update ha group configuration. (deprecated in favor of HA rules)
1412pub async fn cluster_ha_update_groups(configuration: &configuration::Configuration, group: &str, cluster_ha_update_groups_request: Option<models::ClusterHaUpdateGroupsRequest>) -> Result<models::ClusterHaUpdateGroupsResponse, Error<ClusterHaUpdateGroupsError>> {
1413    // add a prefix to parameters to efficiently prevent name collisions
1414    let p_path_group = group;
1415    let p_body_cluster_ha_update_groups_request = cluster_ha_update_groups_request;
1416
1417    let uri_str = format!("{}/cluster/ha/groups/{group}", configuration.base_path, group=crate::apis::urlencode(p_path_group));
1418    let mut req_builder = configuration.client.request(reqwest::Method::PUT, &uri_str);
1419
1420    if let Some(ref user_agent) = configuration.user_agent {
1421        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
1422    }
1423    if let Some(ref apikey) = configuration.api_key {
1424        let key = apikey.key.clone();
1425        let value = match apikey.prefix {
1426            Some(ref prefix) => format!("{} {}", prefix, key),
1427            None => key,
1428        };
1429        req_builder = req_builder.header("Authorization", value);
1430    };
1431    if let Some(ref apikey) = configuration.api_key {
1432        let key = apikey.key.clone();
1433        let value = match apikey.prefix {
1434            Some(ref prefix) => format!("{} {}", prefix, key),
1435            None => key,
1436        };
1437        req_builder = req_builder.header("CSRFPreventionToken", value);
1438    };
1439    req_builder = req_builder.json(&p_body_cluster_ha_update_groups_request);
1440
1441    let req = req_builder.build()?;
1442    let resp = configuration.client.execute(req).await?;
1443
1444    let status = resp.status();
1445    let content_type = resp
1446        .headers()
1447        .get("content-type")
1448        .and_then(|v| v.to_str().ok())
1449        .unwrap_or("application/octet-stream");
1450    let content_type = super::ContentType::from(content_type);
1451
1452    if !status.is_client_error() && !status.is_server_error() {
1453        let content = resp.text().await?;
1454        match content_type {
1455            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
1456            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::ClusterHaUpdateGroupsResponse`"))),
1457            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::ClusterHaUpdateGroupsResponse`")))),
1458        }
1459    } else {
1460        let content = resp.text().await?;
1461        let entity: Option<ClusterHaUpdateGroupsError> = serde_json::from_str(&content).ok();
1462        Err(Error::ResponseError(ResponseContent { status, content, entity }))
1463    }
1464}
1465
1466/// Update resource configuration.
1467pub async fn cluster_ha_update_resources(configuration: &configuration::Configuration, sid: &str, cluster_ha_update_resources_request: Option<models::ClusterHaUpdateResourcesRequest>) -> Result<models::ClusterHaUpdateResourcesResponse, Error<ClusterHaUpdateResourcesError>> {
1468    // add a prefix to parameters to efficiently prevent name collisions
1469    let p_path_sid = sid;
1470    let p_body_cluster_ha_update_resources_request = cluster_ha_update_resources_request;
1471
1472    let uri_str = format!("{}/cluster/ha/resources/{sid}", configuration.base_path, sid=crate::apis::urlencode(p_path_sid));
1473    let mut req_builder = configuration.client.request(reqwest::Method::PUT, &uri_str);
1474
1475    if let Some(ref user_agent) = configuration.user_agent {
1476        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
1477    }
1478    if let Some(ref apikey) = configuration.api_key {
1479        let key = apikey.key.clone();
1480        let value = match apikey.prefix {
1481            Some(ref prefix) => format!("{} {}", prefix, key),
1482            None => key,
1483        };
1484        req_builder = req_builder.header("Authorization", value);
1485    };
1486    if let Some(ref apikey) = configuration.api_key {
1487        let key = apikey.key.clone();
1488        let value = match apikey.prefix {
1489            Some(ref prefix) => format!("{} {}", prefix, key),
1490            None => key,
1491        };
1492        req_builder = req_builder.header("CSRFPreventionToken", value);
1493    };
1494    req_builder = req_builder.json(&p_body_cluster_ha_update_resources_request);
1495
1496    let req = req_builder.build()?;
1497    let resp = configuration.client.execute(req).await?;
1498
1499    let status = resp.status();
1500    let content_type = resp
1501        .headers()
1502        .get("content-type")
1503        .and_then(|v| v.to_str().ok())
1504        .unwrap_or("application/octet-stream");
1505    let content_type = super::ContentType::from(content_type);
1506
1507    if !status.is_client_error() && !status.is_server_error() {
1508        let content = resp.text().await?;
1509        match content_type {
1510            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
1511            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::ClusterHaUpdateResourcesResponse`"))),
1512            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::ClusterHaUpdateResourcesResponse`")))),
1513        }
1514    } else {
1515        let content = resp.text().await?;
1516        let entity: Option<ClusterHaUpdateResourcesError> = serde_json::from_str(&content).ok();
1517        Err(Error::ResponseError(ResponseContent { status, content, entity }))
1518    }
1519}
1520
1521/// Update HA rule.
1522pub async fn cluster_ha_update_rule(configuration: &configuration::Configuration, rule: &str, cluster_ha_update_rule_request: models::ClusterHaUpdateRuleRequest) -> Result<models::ClusterHaUpdateRuleResponse, Error<ClusterHaUpdateRuleError>> {
1523    // add a prefix to parameters to efficiently prevent name collisions
1524    let p_path_rule = rule;
1525    let p_body_cluster_ha_update_rule_request = cluster_ha_update_rule_request;
1526
1527    let uri_str = format!("{}/cluster/ha/rules/{rule}", configuration.base_path, rule=crate::apis::urlencode(p_path_rule));
1528    let mut req_builder = configuration.client.request(reqwest::Method::PUT, &uri_str);
1529
1530    if let Some(ref user_agent) = configuration.user_agent {
1531        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
1532    }
1533    if let Some(ref apikey) = configuration.api_key {
1534        let key = apikey.key.clone();
1535        let value = match apikey.prefix {
1536            Some(ref prefix) => format!("{} {}", prefix, key),
1537            None => key,
1538        };
1539        req_builder = req_builder.header("Authorization", value);
1540    };
1541    if let Some(ref apikey) = configuration.api_key {
1542        let key = apikey.key.clone();
1543        let value = match apikey.prefix {
1544            Some(ref prefix) => format!("{} {}", prefix, key),
1545            None => key,
1546        };
1547        req_builder = req_builder.header("CSRFPreventionToken", value);
1548    };
1549    req_builder = req_builder.json(&p_body_cluster_ha_update_rule_request);
1550
1551    let req = req_builder.build()?;
1552    let resp = configuration.client.execute(req).await?;
1553
1554    let status = resp.status();
1555    let content_type = resp
1556        .headers()
1557        .get("content-type")
1558        .and_then(|v| v.to_str().ok())
1559        .unwrap_or("application/octet-stream");
1560    let content_type = super::ContentType::from(content_type);
1561
1562    if !status.is_client_error() && !status.is_server_error() {
1563        let content = resp.text().await?;
1564        match content_type {
1565            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
1566            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::ClusterHaUpdateRuleResponse`"))),
1567            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::ClusterHaUpdateRuleResponse`")))),
1568        }
1569    } else {
1570        let content = resp.text().await?;
1571        let entity: Option<ClusterHaUpdateRuleError> = serde_json::from_str(&content).ok();
1572        Err(Error::ResponseError(ResponseContent { status, content, entity }))
1573    }
1574}
1575