Skip to main content

clientapi_pve/apis/
cluster_backup_info_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_backup_info_get_backup_info`]
19#[derive(Debug, Clone, Serialize, Deserialize)]
20#[serde(untagged)]
21pub enum ClusterBackupInfoGetBackupInfoError {
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_backup_info_get_guests_not_in_backup`]
33#[derive(Debug, Clone, Serialize, Deserialize)]
34#[serde(untagged)]
35pub enum ClusterBackupInfoGetGuestsNotInBackupError {
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
47/// Index for backup info related endpoints
48pub async fn cluster_backup_info_get_backup_info(configuration: &configuration::Configuration, ) -> Result<models::ClusterBackupInfoGetBackupInfoResponse, Error<ClusterBackupInfoGetBackupInfoError>> {
49
50    let uri_str = format!("{}/cluster/backup-info", configuration.base_path);
51    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
52
53    if let Some(ref user_agent) = configuration.user_agent {
54        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
55    }
56    if let Some(ref apikey) = configuration.api_key {
57        let key = apikey.key.clone();
58        let value = match apikey.prefix {
59            Some(ref prefix) => format!("{} {}", prefix, key),
60            None => key,
61        };
62        req_builder = req_builder.header("Authorization", value);
63    };
64    if let Some(ref apikey) = configuration.api_key {
65        let key = apikey.key.clone();
66        let value = match apikey.prefix {
67            Some(ref prefix) => format!("{} {}", prefix, key),
68            None => key,
69        };
70        req_builder = req_builder.header("CSRFPreventionToken", value);
71    };
72
73    let req = req_builder.build()?;
74    let resp = configuration.client.execute(req).await?;
75
76    let status = resp.status();
77    let content_type = resp
78        .headers()
79        .get("content-type")
80        .and_then(|v| v.to_str().ok())
81        .unwrap_or("application/octet-stream");
82    let content_type = super::ContentType::from(content_type);
83
84    if !status.is_client_error() && !status.is_server_error() {
85        let content = resp.text().await?;
86        match content_type {
87            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
88            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::ClusterBackupInfoGetBackupInfoResponse`"))),
89            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::ClusterBackupInfoGetBackupInfoResponse`")))),
90        }
91    } else {
92        let content = resp.text().await?;
93        let entity: Option<ClusterBackupInfoGetBackupInfoError> = serde_json::from_str(&content).ok();
94        Err(Error::ResponseError(ResponseContent { status, content, entity }))
95    }
96}
97
98/// Shows all guests which are not covered by any backup job.
99pub async fn cluster_backup_info_get_guests_not_in_backup(configuration: &configuration::Configuration, ) -> Result<models::ClusterBackupInfoGetGuestsNotInBackupResponse, Error<ClusterBackupInfoGetGuestsNotInBackupError>> {
100
101    let uri_str = format!("{}/cluster/backup-info/not-backed-up", configuration.base_path);
102    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
103
104    if let Some(ref user_agent) = configuration.user_agent {
105        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
106    }
107    if let Some(ref apikey) = configuration.api_key {
108        let key = apikey.key.clone();
109        let value = match apikey.prefix {
110            Some(ref prefix) => format!("{} {}", prefix, key),
111            None => key,
112        };
113        req_builder = req_builder.header("Authorization", value);
114    };
115    if let Some(ref apikey) = configuration.api_key {
116        let key = apikey.key.clone();
117        let value = match apikey.prefix {
118            Some(ref prefix) => format!("{} {}", prefix, key),
119            None => key,
120        };
121        req_builder = req_builder.header("CSRFPreventionToken", value);
122    };
123
124    let req = req_builder.build()?;
125    let resp = configuration.client.execute(req).await?;
126
127    let status = resp.status();
128    let content_type = resp
129        .headers()
130        .get("content-type")
131        .and_then(|v| v.to_str().ok())
132        .unwrap_or("application/octet-stream");
133    let content_type = super::ContentType::from(content_type);
134
135    if !status.is_client_error() && !status.is_server_error() {
136        let content = resp.text().await?;
137        match content_type {
138            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
139            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::ClusterBackupInfoGetGuestsNotInBackupResponse`"))),
140            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::ClusterBackupInfoGetGuestsNotInBackupResponse`")))),
141        }
142    } else {
143        let content = resp.text().await?;
144        let entity: Option<ClusterBackupInfoGetGuestsNotInBackupError> = serde_json::from_str(&content).ok();
145        Err(Error::ResponseError(ResponseContent { status, content, entity }))
146    }
147}
148