Skip to main content

clientapi_pve/apis/
cluster_backup_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_create_job`]
19#[derive(Debug, Clone, Serialize, Deserialize)]
20#[serde(untagged)]
21pub enum ClusterBackupCreateJobError {
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_delete_job`]
33#[derive(Debug, Clone, Serialize, Deserialize)]
34#[serde(untagged)]
35pub enum ClusterBackupDeleteJobError {
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_backup_get_backup`]
47#[derive(Debug, Clone, Serialize, Deserialize)]
48#[serde(untagged)]
49pub enum ClusterBackupGetBackupError {
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_backup_get_volume_backup_included`]
61#[derive(Debug, Clone, Serialize, Deserialize)]
62#[serde(untagged)]
63pub enum ClusterBackupGetVolumeBackupIncludedError {
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_backup_read_job`]
75#[derive(Debug, Clone, Serialize, Deserialize)]
76#[serde(untagged)]
77pub enum ClusterBackupReadJobError {
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_backup_update_job`]
89#[derive(Debug, Clone, Serialize, Deserialize)]
90#[serde(untagged)]
91pub enum ClusterBackupUpdateJobError {
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
103/// Create new vzdump backup job.  Permissions: The 'tmpdir', 'dumpdir' and 'script' parameters are additionally restricted to the 'root@pam' user.
104pub async fn cluster_backup_create_job(configuration: &configuration::Configuration, cluster_backup_create_job_request: Option<models::ClusterBackupCreateJobRequest>) -> Result<models::ClusterBackupCreateJobResponse, Error<ClusterBackupCreateJobError>> {
105    // add a prefix to parameters to efficiently prevent name collisions
106    let p_body_cluster_backup_create_job_request = cluster_backup_create_job_request;
107
108    let uri_str = format!("{}/cluster/backup", configuration.base_path);
109    let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
110
111    if let Some(ref user_agent) = configuration.user_agent {
112        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
113    }
114    if let Some(ref apikey) = configuration.api_key {
115        let key = apikey.key.clone();
116        let value = match apikey.prefix {
117            Some(ref prefix) => format!("{} {}", prefix, key),
118            None => key,
119        };
120        req_builder = req_builder.header("Authorization", value);
121    };
122    if let Some(ref apikey) = configuration.api_key {
123        let key = apikey.key.clone();
124        let value = match apikey.prefix {
125            Some(ref prefix) => format!("{} {}", prefix, key),
126            None => key,
127        };
128        req_builder = req_builder.header("CSRFPreventionToken", value);
129    };
130    req_builder = req_builder.json(&p_body_cluster_backup_create_job_request);
131
132    let req = req_builder.build()?;
133    let resp = configuration.client.execute(req).await?;
134
135    let status = resp.status();
136    let content_type = resp
137        .headers()
138        .get("content-type")
139        .and_then(|v| v.to_str().ok())
140        .unwrap_or("application/octet-stream");
141    let content_type = super::ContentType::from(content_type);
142
143    if !status.is_client_error() && !status.is_server_error() {
144        let content = resp.text().await?;
145        match content_type {
146            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
147            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::ClusterBackupCreateJobResponse`"))),
148            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::ClusterBackupCreateJobResponse`")))),
149        }
150    } else {
151        let content = resp.text().await?;
152        let entity: Option<ClusterBackupCreateJobError> = serde_json::from_str(&content).ok();
153        Err(Error::ResponseError(ResponseContent { status, content, entity }))
154    }
155}
156
157/// Delete vzdump backup job definition.
158pub async fn cluster_backup_delete_job(configuration: &configuration::Configuration, id: &str) -> Result<models::ClusterBackupDeleteJobResponse, Error<ClusterBackupDeleteJobError>> {
159    // add a prefix to parameters to efficiently prevent name collisions
160    let p_path_id = id;
161
162    let uri_str = format!("{}/cluster/backup/{id}", configuration.base_path, id=crate::apis::urlencode(p_path_id));
163    let mut req_builder = configuration.client.request(reqwest::Method::DELETE, &uri_str);
164
165    if let Some(ref user_agent) = configuration.user_agent {
166        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
167    }
168    if let Some(ref apikey) = configuration.api_key {
169        let key = apikey.key.clone();
170        let value = match apikey.prefix {
171            Some(ref prefix) => format!("{} {}", prefix, key),
172            None => key,
173        };
174        req_builder = req_builder.header("Authorization", value);
175    };
176    if let Some(ref apikey) = configuration.api_key {
177        let key = apikey.key.clone();
178        let value = match apikey.prefix {
179            Some(ref prefix) => format!("{} {}", prefix, key),
180            None => key,
181        };
182        req_builder = req_builder.header("CSRFPreventionToken", value);
183    };
184
185    let req = req_builder.build()?;
186    let resp = configuration.client.execute(req).await?;
187
188    let status = resp.status();
189    let content_type = resp
190        .headers()
191        .get("content-type")
192        .and_then(|v| v.to_str().ok())
193        .unwrap_or("application/octet-stream");
194    let content_type = super::ContentType::from(content_type);
195
196    if !status.is_client_error() && !status.is_server_error() {
197        let content = resp.text().await?;
198        match content_type {
199            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
200            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::ClusterBackupDeleteJobResponse`"))),
201            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::ClusterBackupDeleteJobResponse`")))),
202        }
203    } else {
204        let content = resp.text().await?;
205        let entity: Option<ClusterBackupDeleteJobError> = serde_json::from_str(&content).ok();
206        Err(Error::ResponseError(ResponseContent { status, content, entity }))
207    }
208}
209
210/// List vzdump backup schedule.
211pub async fn cluster_backup_get_backup(configuration: &configuration::Configuration, ) -> Result<models::ClusterBackupGetBackupResponse, Error<ClusterBackupGetBackupError>> {
212
213    let uri_str = format!("{}/cluster/backup", configuration.base_path);
214    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
215
216    if let Some(ref user_agent) = configuration.user_agent {
217        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
218    }
219    if let Some(ref apikey) = configuration.api_key {
220        let key = apikey.key.clone();
221        let value = match apikey.prefix {
222            Some(ref prefix) => format!("{} {}", prefix, key),
223            None => key,
224        };
225        req_builder = req_builder.header("Authorization", value);
226    };
227    if let Some(ref apikey) = configuration.api_key {
228        let key = apikey.key.clone();
229        let value = match apikey.prefix {
230            Some(ref prefix) => format!("{} {}", prefix, key),
231            None => key,
232        };
233        req_builder = req_builder.header("CSRFPreventionToken", value);
234    };
235
236    let req = req_builder.build()?;
237    let resp = configuration.client.execute(req).await?;
238
239    let status = resp.status();
240    let content_type = resp
241        .headers()
242        .get("content-type")
243        .and_then(|v| v.to_str().ok())
244        .unwrap_or("application/octet-stream");
245    let content_type = super::ContentType::from(content_type);
246
247    if !status.is_client_error() && !status.is_server_error() {
248        let content = resp.text().await?;
249        match content_type {
250            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
251            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::ClusterBackupGetBackupResponse`"))),
252            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::ClusterBackupGetBackupResponse`")))),
253        }
254    } else {
255        let content = resp.text().await?;
256        let entity: Option<ClusterBackupGetBackupError> = serde_json::from_str(&content).ok();
257        Err(Error::ResponseError(ResponseContent { status, content, entity }))
258    }
259}
260
261/// Returns included guests and the backup status of their disks. Optimized to be used in ExtJS tree views.
262pub async fn cluster_backup_get_volume_backup_included(configuration: &configuration::Configuration, id: &str) -> Result<models::ClusterBackupGetVolumeBackupIncludedResponse, Error<ClusterBackupGetVolumeBackupIncludedError>> {
263    // add a prefix to parameters to efficiently prevent name collisions
264    let p_path_id = id;
265
266    let uri_str = format!("{}/cluster/backup/{id}/included_volumes", configuration.base_path, id=crate::apis::urlencode(p_path_id));
267    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
268
269    if let Some(ref user_agent) = configuration.user_agent {
270        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
271    }
272    if let Some(ref apikey) = configuration.api_key {
273        let key = apikey.key.clone();
274        let value = match apikey.prefix {
275            Some(ref prefix) => format!("{} {}", prefix, key),
276            None => key,
277        };
278        req_builder = req_builder.header("Authorization", value);
279    };
280    if let Some(ref apikey) = configuration.api_key {
281        let key = apikey.key.clone();
282        let value = match apikey.prefix {
283            Some(ref prefix) => format!("{} {}", prefix, key),
284            None => key,
285        };
286        req_builder = req_builder.header("CSRFPreventionToken", value);
287    };
288
289    let req = req_builder.build()?;
290    let resp = configuration.client.execute(req).await?;
291
292    let status = resp.status();
293    let content_type = resp
294        .headers()
295        .get("content-type")
296        .and_then(|v| v.to_str().ok())
297        .unwrap_or("application/octet-stream");
298    let content_type = super::ContentType::from(content_type);
299
300    if !status.is_client_error() && !status.is_server_error() {
301        let content = resp.text().await?;
302        match content_type {
303            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
304            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::ClusterBackupGetVolumeBackupIncludedResponse`"))),
305            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::ClusterBackupGetVolumeBackupIncludedResponse`")))),
306        }
307    } else {
308        let content = resp.text().await?;
309        let entity: Option<ClusterBackupGetVolumeBackupIncludedError> = serde_json::from_str(&content).ok();
310        Err(Error::ResponseError(ResponseContent { status, content, entity }))
311    }
312}
313
314/// Read vzdump backup job definition.
315pub async fn cluster_backup_read_job(configuration: &configuration::Configuration, id: &str) -> Result<models::ClusterBackupReadJobResponse, Error<ClusterBackupReadJobError>> {
316    // add a prefix to parameters to efficiently prevent name collisions
317    let p_path_id = id;
318
319    let uri_str = format!("{}/cluster/backup/{id}", configuration.base_path, id=crate::apis::urlencode(p_path_id));
320    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
321
322    if let Some(ref user_agent) = configuration.user_agent {
323        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
324    }
325    if let Some(ref apikey) = configuration.api_key {
326        let key = apikey.key.clone();
327        let value = match apikey.prefix {
328            Some(ref prefix) => format!("{} {}", prefix, key),
329            None => key,
330        };
331        req_builder = req_builder.header("Authorization", value);
332    };
333    if let Some(ref apikey) = configuration.api_key {
334        let key = apikey.key.clone();
335        let value = match apikey.prefix {
336            Some(ref prefix) => format!("{} {}", prefix, key),
337            None => key,
338        };
339        req_builder = req_builder.header("CSRFPreventionToken", value);
340    };
341
342    let req = req_builder.build()?;
343    let resp = configuration.client.execute(req).await?;
344
345    let status = resp.status();
346    let content_type = resp
347        .headers()
348        .get("content-type")
349        .and_then(|v| v.to_str().ok())
350        .unwrap_or("application/octet-stream");
351    let content_type = super::ContentType::from(content_type);
352
353    if !status.is_client_error() && !status.is_server_error() {
354        let content = resp.text().await?;
355        match content_type {
356            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
357            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::ClusterBackupReadJobResponse`"))),
358            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::ClusterBackupReadJobResponse`")))),
359        }
360    } else {
361        let content = resp.text().await?;
362        let entity: Option<ClusterBackupReadJobError> = serde_json::from_str(&content).ok();
363        Err(Error::ResponseError(ResponseContent { status, content, entity }))
364    }
365}
366
367/// Update vzdump backup job definition.  Permissions: The 'tmpdir', 'dumpdir' and 'script' parameters are additionally restricted to the 'root@pam' user.
368pub async fn cluster_backup_update_job(configuration: &configuration::Configuration, id: &str, cluster_backup_update_job_request: Option<models::ClusterBackupUpdateJobRequest>) -> Result<models::ClusterBackupUpdateJobResponse, Error<ClusterBackupUpdateJobError>> {
369    // add a prefix to parameters to efficiently prevent name collisions
370    let p_path_id = id;
371    let p_body_cluster_backup_update_job_request = cluster_backup_update_job_request;
372
373    let uri_str = format!("{}/cluster/backup/{id}", configuration.base_path, id=crate::apis::urlencode(p_path_id));
374    let mut req_builder = configuration.client.request(reqwest::Method::PUT, &uri_str);
375
376    if let Some(ref user_agent) = configuration.user_agent {
377        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
378    }
379    if let Some(ref apikey) = configuration.api_key {
380        let key = apikey.key.clone();
381        let value = match apikey.prefix {
382            Some(ref prefix) => format!("{} {}", prefix, key),
383            None => key,
384        };
385        req_builder = req_builder.header("Authorization", value);
386    };
387    if let Some(ref apikey) = configuration.api_key {
388        let key = apikey.key.clone();
389        let value = match apikey.prefix {
390            Some(ref prefix) => format!("{} {}", prefix, key),
391            None => key,
392        };
393        req_builder = req_builder.header("CSRFPreventionToken", value);
394    };
395    req_builder = req_builder.json(&p_body_cluster_backup_update_job_request);
396
397    let req = req_builder.build()?;
398    let resp = configuration.client.execute(req).await?;
399
400    let status = resp.status();
401    let content_type = resp
402        .headers()
403        .get("content-type")
404        .and_then(|v| v.to_str().ok())
405        .unwrap_or("application/octet-stream");
406    let content_type = super::ContentType::from(content_type);
407
408    if !status.is_client_error() && !status.is_server_error() {
409        let content = resp.text().await?;
410        match content_type {
411            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
412            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::ClusterBackupUpdateJobResponse`"))),
413            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::ClusterBackupUpdateJobResponse`")))),
414        }
415    } else {
416        let content = resp.text().await?;
417        let entity: Option<ClusterBackupUpdateJobError> = serde_json::from_str(&content).ok();
418        Err(Error::ResponseError(ResponseContent { status, content, entity }))
419    }
420}
421