Skip to main content

clientapi_pbs/apis/
tape_media_api.rs

1/*
2 * Proxmox Backup Server API
3 *
4 * Generated from apidoc.js. NOT an official Proxmox specification. See https://pbs.proxmox.com/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 [`tape_media_create_move`]
19#[derive(Debug, Clone, Serialize, Deserialize)]
20#[serde(untagged)]
21pub enum TapeMediaCreateMoveError {
22    Status400(models::PbsError),
23    Status401(models::PbsError),
24    Status403(models::PbsError),
25    Status404(models::PbsError),
26    Status500(models::PbsError),
27    Status501(models::PbsError),
28    Status503(models::PbsError),
29    UnknownValue(serde_json::Value),
30}
31
32/// struct for typed errors of method [`tape_media_create_status`]
33#[derive(Debug, Clone, Serialize, Deserialize)]
34#[serde(untagged)]
35pub enum TapeMediaCreateStatusError {
36    Status400(models::PbsError),
37    Status401(models::PbsError),
38    Status403(models::PbsError),
39    Status404(models::PbsError),
40    Status500(models::PbsError),
41    Status501(models::PbsError),
42    Status503(models::PbsError),
43    UnknownValue(serde_json::Value),
44}
45
46/// struct for typed errors of method [`tape_media_get_content`]
47#[derive(Debug, Clone, Serialize, Deserialize)]
48#[serde(untagged)]
49pub enum TapeMediaGetContentError {
50    Status400(models::PbsError),
51    Status401(models::PbsError),
52    Status403(models::PbsError),
53    Status404(models::PbsError),
54    Status500(models::PbsError),
55    Status501(models::PbsError),
56    Status503(models::PbsError),
57    UnknownValue(serde_json::Value),
58}
59
60/// struct for typed errors of method [`tape_media_get_destroy`]
61#[derive(Debug, Clone, Serialize, Deserialize)]
62#[serde(untagged)]
63pub enum TapeMediaGetDestroyError {
64    Status400(models::PbsError),
65    Status401(models::PbsError),
66    Status403(models::PbsError),
67    Status404(models::PbsError),
68    Status500(models::PbsError),
69    Status501(models::PbsError),
70    Status503(models::PbsError),
71    UnknownValue(serde_json::Value),
72}
73
74/// struct for typed errors of method [`tape_media_get_list`]
75#[derive(Debug, Clone, Serialize, Deserialize)]
76#[serde(untagged)]
77pub enum TapeMediaGetListError {
78    Status400(models::PbsError),
79    Status401(models::PbsError),
80    Status403(models::PbsError),
81    Status404(models::PbsError),
82    Status500(models::PbsError),
83    Status501(models::PbsError),
84    Status503(models::PbsError),
85    UnknownValue(serde_json::Value),
86}
87
88/// struct for typed errors of method [`tape_media_get_media`]
89#[derive(Debug, Clone, Serialize, Deserialize)]
90#[serde(untagged)]
91pub enum TapeMediaGetMediaError {
92    Status400(models::PbsError),
93    Status401(models::PbsError),
94    Status403(models::PbsError),
95    Status404(models::PbsError),
96    Status500(models::PbsError),
97    Status501(models::PbsError),
98    Status503(models::PbsError),
99    UnknownValue(serde_json::Value),
100}
101
102/// struct for typed errors of method [`tape_media_get_media_sets`]
103#[derive(Debug, Clone, Serialize, Deserialize)]
104#[serde(untagged)]
105pub enum TapeMediaGetMediaSetsError {
106    Status400(models::PbsError),
107    Status401(models::PbsError),
108    Status403(models::PbsError),
109    Status404(models::PbsError),
110    Status500(models::PbsError),
111    Status501(models::PbsError),
112    Status503(models::PbsError),
113    UnknownValue(serde_json::Value),
114}
115
116/// struct for typed errors of method [`tape_media_get_status`]
117#[derive(Debug, Clone, Serialize, Deserialize)]
118#[serde(untagged)]
119pub enum TapeMediaGetStatusError {
120    Status400(models::PbsError),
121    Status401(models::PbsError),
122    Status403(models::PbsError),
123    Status404(models::PbsError),
124    Status500(models::PbsError),
125    Status501(models::PbsError),
126    Status503(models::PbsError),
127    UnknownValue(serde_json::Value),
128}
129
130/// struct for typed errors of method [`tape_media_get_tape_media_list_by_uuid`]
131#[derive(Debug, Clone, Serialize, Deserialize)]
132#[serde(untagged)]
133pub enum TapeMediaGetTapeMediaListByUuidError {
134    Status400(models::PbsError),
135    Status401(models::PbsError),
136    Status403(models::PbsError),
137    Status404(models::PbsError),
138    Status500(models::PbsError),
139    Status501(models::PbsError),
140    Status503(models::PbsError),
141    UnknownValue(serde_json::Value),
142}
143
144
145/// Change Tape location to vault (if given), or offline.
146pub async fn tape_media_create_move(configuration: &configuration::Configuration, tape_media_create_move_request: Option<models::TapeMediaCreateMoveRequest>) -> Result<models::TapeMediaCreateMoveResponse, Error<TapeMediaCreateMoveError>> {
147    // add a prefix to parameters to efficiently prevent name collisions
148    let p_body_tape_media_create_move_request = tape_media_create_move_request;
149
150    let uri_str = format!("{}/tape/media/move", configuration.base_path);
151    let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
152
153    if let Some(ref user_agent) = configuration.user_agent {
154        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
155    }
156    if let Some(ref apikey) = configuration.api_key {
157        let key = apikey.key.clone();
158        let value = match apikey.prefix {
159            Some(ref prefix) => format!("{} {}", prefix, key),
160            None => key,
161        };
162        req_builder = req_builder.header("Authorization", value);
163    };
164    if let Some(ref apikey) = configuration.api_key {
165        let key = apikey.key.clone();
166        let value = match apikey.prefix {
167            Some(ref prefix) => format!("{} {}", prefix, key),
168            None => key,
169        };
170        req_builder = req_builder.header("CSRFPreventionToken", value);
171    };
172    req_builder = req_builder.json(&p_body_tape_media_create_move_request);
173
174    let req = req_builder.build()?;
175    let resp = configuration.client.execute(req).await?;
176
177    let status = resp.status();
178    let content_type = resp
179        .headers()
180        .get("content-type")
181        .and_then(|v| v.to_str().ok())
182        .unwrap_or("application/octet-stream");
183    let content_type = super::ContentType::from(content_type);
184
185    if !status.is_client_error() && !status.is_server_error() {
186        let content = resp.text().await?;
187        match content_type {
188            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
189            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::TapeMediaCreateMoveResponse`"))),
190            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::TapeMediaCreateMoveResponse`")))),
191        }
192    } else {
193        let content = resp.text().await?;
194        let entity: Option<TapeMediaCreateMoveError> = serde_json::from_str(&content).ok();
195        Err(Error::ResponseError(ResponseContent { status, content, entity }))
196    }
197}
198
199/// Update media status (None, 'full', 'damaged' or 'retired')  It is not allowed to set status to 'writable' or 'unknown' (those are internally managed states).
200pub async fn tape_media_create_status(configuration: &configuration::Configuration, uuid: &str, tape_media_create_status_request: Option<models::TapeMediaCreateStatusRequest>) -> Result<models::TapeMediaCreateStatusResponse, Error<TapeMediaCreateStatusError>> {
201    // add a prefix to parameters to efficiently prevent name collisions
202    let p_path_uuid = uuid;
203    let p_body_tape_media_create_status_request = tape_media_create_status_request;
204
205    let uri_str = format!("{}/tape/media/list/{uuid}/status", configuration.base_path, uuid=crate::apis::urlencode(p_path_uuid));
206    let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
207
208    if let Some(ref user_agent) = configuration.user_agent {
209        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
210    }
211    if let Some(ref apikey) = configuration.api_key {
212        let key = apikey.key.clone();
213        let value = match apikey.prefix {
214            Some(ref prefix) => format!("{} {}", prefix, key),
215            None => key,
216        };
217        req_builder = req_builder.header("Authorization", value);
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("CSRFPreventionToken", value);
226    };
227    req_builder = req_builder.json(&p_body_tape_media_create_status_request);
228
229    let req = req_builder.build()?;
230    let resp = configuration.client.execute(req).await?;
231
232    let status = resp.status();
233    let content_type = resp
234        .headers()
235        .get("content-type")
236        .and_then(|v| v.to_str().ok())
237        .unwrap_or("application/octet-stream");
238    let content_type = super::ContentType::from(content_type);
239
240    if !status.is_client_error() && !status.is_server_error() {
241        let content = resp.text().await?;
242        match content_type {
243            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
244            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::TapeMediaCreateStatusResponse`"))),
245            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::TapeMediaCreateStatusResponse`")))),
246        }
247    } else {
248        let content = resp.text().await?;
249        let entity: Option<TapeMediaCreateStatusError> = serde_json::from_str(&content).ok();
250        Err(Error::ResponseError(ResponseContent { status, content, entity }))
251    }
252}
253
254/// List media content  Permissions: List content filtered by Tape.Audit privilege on pool
255pub async fn tape_media_get_content(configuration: &configuration::Configuration, backup_id: Option<&str>, backup_type: Option<models::PbsBackupTypeEnum>, label_text: Option<&str>, media: Option<&str>, media_set: Option<&str>, pool: Option<&str>) -> Result<models::TapeMediaGetContentResponse, Error<TapeMediaGetContentError>> {
256    // add a prefix to parameters to efficiently prevent name collisions
257    let p_query_backup_id = backup_id;
258    let p_query_backup_type = backup_type;
259    let p_query_label_text = label_text;
260    let p_query_media = media;
261    let p_query_media_set = media_set;
262    let p_query_pool = pool;
263
264    let uri_str = format!("{}/tape/media/content", configuration.base_path);
265    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
266
267    if let Some(ref param_value) = p_query_backup_id {
268        req_builder = req_builder.query(&[("backup-id", &param_value.to_string())]);
269    }
270    if let Some(ref param_value) = p_query_backup_type {
271        req_builder = req_builder.query(&[("backup-type", &param_value.to_string())]);
272    }
273    if let Some(ref param_value) = p_query_label_text {
274        req_builder = req_builder.query(&[("label-text", &param_value.to_string())]);
275    }
276    if let Some(ref param_value) = p_query_media {
277        req_builder = req_builder.query(&[("media", &param_value.to_string())]);
278    }
279    if let Some(ref param_value) = p_query_media_set {
280        req_builder = req_builder.query(&[("media-set", &param_value.to_string())]);
281    }
282    if let Some(ref param_value) = p_query_pool {
283        req_builder = req_builder.query(&[("pool", &param_value.to_string())]);
284    }
285    if let Some(ref user_agent) = configuration.user_agent {
286        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
287    }
288    if let Some(ref apikey) = configuration.api_key {
289        let key = apikey.key.clone();
290        let value = match apikey.prefix {
291            Some(ref prefix) => format!("{} {}", prefix, key),
292            None => key,
293        };
294        req_builder = req_builder.header("Authorization", value);
295    };
296    if let Some(ref apikey) = configuration.api_key {
297        let key = apikey.key.clone();
298        let value = match apikey.prefix {
299            Some(ref prefix) => format!("{} {}", prefix, key),
300            None => key,
301        };
302        req_builder = req_builder.header("CSRFPreventionToken", value);
303    };
304
305    let req = req_builder.build()?;
306    let resp = configuration.client.execute(req).await?;
307
308    let status = resp.status();
309    let content_type = resp
310        .headers()
311        .get("content-type")
312        .and_then(|v| v.to_str().ok())
313        .unwrap_or("application/octet-stream");
314    let content_type = super::ContentType::from(content_type);
315
316    if !status.is_client_error() && !status.is_server_error() {
317        let content = resp.text().await?;
318        match content_type {
319            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
320            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::TapeMediaGetContentResponse`"))),
321            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::TapeMediaGetContentResponse`")))),
322        }
323    } else {
324        let content = resp.text().await?;
325        let entity: Option<TapeMediaGetContentError> = serde_json::from_str(&content).ok();
326        Err(Error::ResponseError(ResponseContent { status, content, entity }))
327    }
328}
329
330/// Destroy media (completely remove from database)
331pub async fn tape_media_get_destroy(configuration: &configuration::Configuration, force: Option<bool>, label_text: Option<&str>, uuid: Option<&str>) -> Result<models::TapeMediaGetDestroyResponse, Error<TapeMediaGetDestroyError>> {
332    // add a prefix to parameters to efficiently prevent name collisions
333    let p_query_force = force;
334    let p_query_label_text = label_text;
335    let p_query_uuid = uuid;
336
337    let uri_str = format!("{}/tape/media/destroy", configuration.base_path);
338    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
339
340    if let Some(ref param_value) = p_query_force {
341        req_builder = req_builder.query(&[("force", &param_value.to_string())]);
342    }
343    if let Some(ref param_value) = p_query_label_text {
344        req_builder = req_builder.query(&[("label-text", &param_value.to_string())]);
345    }
346    if let Some(ref param_value) = p_query_uuid {
347        req_builder = req_builder.query(&[("uuid", &param_value.to_string())]);
348    }
349    if let Some(ref user_agent) = configuration.user_agent {
350        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
351    }
352    if let Some(ref apikey) = configuration.api_key {
353        let key = apikey.key.clone();
354        let value = match apikey.prefix {
355            Some(ref prefix) => format!("{} {}", prefix, key),
356            None => key,
357        };
358        req_builder = req_builder.header("Authorization", value);
359    };
360    if let Some(ref apikey) = configuration.api_key {
361        let key = apikey.key.clone();
362        let value = match apikey.prefix {
363            Some(ref prefix) => format!("{} {}", prefix, key),
364            None => key,
365        };
366        req_builder = req_builder.header("CSRFPreventionToken", value);
367    };
368
369    let req = req_builder.build()?;
370    let resp = configuration.client.execute(req).await?;
371
372    let status = resp.status();
373    let content_type = resp
374        .headers()
375        .get("content-type")
376        .and_then(|v| v.to_str().ok())
377        .unwrap_or("application/octet-stream");
378    let content_type = super::ContentType::from(content_type);
379
380    if !status.is_client_error() && !status.is_server_error() {
381        let content = resp.text().await?;
382        match content_type {
383            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
384            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::TapeMediaGetDestroyResponse`"))),
385            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::TapeMediaGetDestroyResponse`")))),
386        }
387    } else {
388        let content = resp.text().await?;
389        let entity: Option<TapeMediaGetDestroyError> = serde_json::from_str(&content).ok();
390        Err(Error::ResponseError(ResponseContent { status, content, entity }))
391    }
392}
393
394/// List pool media  Permissions: List of registered backup media filtered by Tape.Audit privileges on pool
395pub async fn tape_media_get_list(configuration: &configuration::Configuration, pool: Option<&str>, update_status: Option<bool>, update_status_changer: Option<&str>) -> Result<models::TapeMediaGetListResponse, Error<TapeMediaGetListError>> {
396    // add a prefix to parameters to efficiently prevent name collisions
397    let p_query_pool = pool;
398    let p_query_update_status = update_status;
399    let p_query_update_status_changer = update_status_changer;
400
401    let uri_str = format!("{}/tape/media/list", configuration.base_path);
402    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
403
404    if let Some(ref param_value) = p_query_pool {
405        req_builder = req_builder.query(&[("pool", &param_value.to_string())]);
406    }
407    if let Some(ref param_value) = p_query_update_status {
408        req_builder = req_builder.query(&[("update-status", &param_value.to_string())]);
409    }
410    if let Some(ref param_value) = p_query_update_status_changer {
411        req_builder = req_builder.query(&[("update-status-changer", &param_value.to_string())]);
412    }
413    if let Some(ref user_agent) = configuration.user_agent {
414        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
415    }
416    if let Some(ref apikey) = configuration.api_key {
417        let key = apikey.key.clone();
418        let value = match apikey.prefix {
419            Some(ref prefix) => format!("{} {}", prefix, key),
420            None => key,
421        };
422        req_builder = req_builder.header("Authorization", value);
423    };
424    if let Some(ref apikey) = configuration.api_key {
425        let key = apikey.key.clone();
426        let value = match apikey.prefix {
427            Some(ref prefix) => format!("{} {}", prefix, key),
428            None => key,
429        };
430        req_builder = req_builder.header("CSRFPreventionToken", value);
431    };
432
433    let req = req_builder.build()?;
434    let resp = configuration.client.execute(req).await?;
435
436    let status = resp.status();
437    let content_type = resp
438        .headers()
439        .get("content-type")
440        .and_then(|v| v.to_str().ok())
441        .unwrap_or("application/octet-stream");
442    let content_type = super::ContentType::from(content_type);
443
444    if !status.is_client_error() && !status.is_server_error() {
445        let content = resp.text().await?;
446        match content_type {
447            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
448            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::TapeMediaGetListResponse`"))),
449            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::TapeMediaGetListResponse`")))),
450        }
451    } else {
452        let content = resp.text().await?;
453        let entity: Option<TapeMediaGetListError> = serde_json::from_str(&content).ok();
454        Err(Error::ResponseError(ResponseContent { status, content, entity }))
455    }
456}
457
458/// Directory index.
459pub async fn tape_media_get_media(configuration: &configuration::Configuration, ) -> Result<models::TapeMediaGetMediaResponse, Error<TapeMediaGetMediaError>> {
460
461    let uri_str = format!("{}/tape/media", configuration.base_path);
462    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
463
464    if let Some(ref user_agent) = configuration.user_agent {
465        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
466    }
467    if let Some(ref apikey) = configuration.api_key {
468        let key = apikey.key.clone();
469        let value = match apikey.prefix {
470            Some(ref prefix) => format!("{} {}", prefix, key),
471            None => key,
472        };
473        req_builder = req_builder.header("Authorization", value);
474    };
475    if let Some(ref apikey) = configuration.api_key {
476        let key = apikey.key.clone();
477        let value = match apikey.prefix {
478            Some(ref prefix) => format!("{} {}", prefix, key),
479            None => key,
480        };
481        req_builder = req_builder.header("CSRFPreventionToken", value);
482    };
483
484    let req = req_builder.build()?;
485    let resp = configuration.client.execute(req).await?;
486
487    let status = resp.status();
488    let content_type = resp
489        .headers()
490        .get("content-type")
491        .and_then(|v| v.to_str().ok())
492        .unwrap_or("application/octet-stream");
493    let content_type = super::ContentType::from(content_type);
494
495    if !status.is_client_error() && !status.is_server_error() {
496        let content = resp.text().await?;
497        match content_type {
498            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
499            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::TapeMediaGetMediaResponse`"))),
500            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::TapeMediaGetMediaResponse`")))),
501        }
502    } else {
503        let content = resp.text().await?;
504        let entity: Option<TapeMediaGetMediaError> = serde_json::from_str(&content).ok();
505        Err(Error::ResponseError(ResponseContent { status, content, entity }))
506    }
507}
508
509/// List Media sets  Permissions: List of media sets filtered by Tape.Audit privileges on pool
510pub async fn tape_media_get_media_sets(configuration: &configuration::Configuration, ) -> Result<models::TapeMediaGetMediaSetsResponse, Error<TapeMediaGetMediaSetsError>> {
511
512    let uri_str = format!("{}/tape/media/media-sets", configuration.base_path);
513    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
514
515    if let Some(ref user_agent) = configuration.user_agent {
516        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
517    }
518    if let Some(ref apikey) = configuration.api_key {
519        let key = apikey.key.clone();
520        let value = match apikey.prefix {
521            Some(ref prefix) => format!("{} {}", prefix, key),
522            None => key,
523        };
524        req_builder = req_builder.header("Authorization", value);
525    };
526    if let Some(ref apikey) = configuration.api_key {
527        let key = apikey.key.clone();
528        let value = match apikey.prefix {
529            Some(ref prefix) => format!("{} {}", prefix, key),
530            None => key,
531        };
532        req_builder = req_builder.header("CSRFPreventionToken", value);
533    };
534
535    let req = req_builder.build()?;
536    let resp = configuration.client.execute(req).await?;
537
538    let status = resp.status();
539    let content_type = resp
540        .headers()
541        .get("content-type")
542        .and_then(|v| v.to_str().ok())
543        .unwrap_or("application/octet-stream");
544    let content_type = super::ContentType::from(content_type);
545
546    if !status.is_client_error() && !status.is_server_error() {
547        let content = resp.text().await?;
548        match content_type {
549            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
550            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::TapeMediaGetMediaSetsResponse`"))),
551            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::TapeMediaGetMediaSetsResponse`")))),
552        }
553    } else {
554        let content = resp.text().await?;
555        let entity: Option<TapeMediaGetMediaSetsError> = serde_json::from_str(&content).ok();
556        Err(Error::ResponseError(ResponseContent { status, content, entity }))
557    }
558}
559
560/// Get current media status
561pub async fn tape_media_get_status(configuration: &configuration::Configuration, uuid: &str) -> Result<models::TapeMediaGetStatusResponse, Error<TapeMediaGetStatusError>> {
562    // add a prefix to parameters to efficiently prevent name collisions
563    let p_path_uuid = uuid;
564
565    let uri_str = format!("{}/tape/media/list/{uuid}/status", configuration.base_path, uuid=crate::apis::urlencode(p_path_uuid));
566    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
567
568    if let Some(ref user_agent) = configuration.user_agent {
569        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
570    }
571    if let Some(ref apikey) = configuration.api_key {
572        let key = apikey.key.clone();
573        let value = match apikey.prefix {
574            Some(ref prefix) => format!("{} {}", prefix, key),
575            None => key,
576        };
577        req_builder = req_builder.header("Authorization", value);
578    };
579    if let Some(ref apikey) = configuration.api_key {
580        let key = apikey.key.clone();
581        let value = match apikey.prefix {
582            Some(ref prefix) => format!("{} {}", prefix, key),
583            None => key,
584        };
585        req_builder = req_builder.header("CSRFPreventionToken", value);
586    };
587
588    let req = req_builder.build()?;
589    let resp = configuration.client.execute(req).await?;
590
591    let status = resp.status();
592    let content_type = resp
593        .headers()
594        .get("content-type")
595        .and_then(|v| v.to_str().ok())
596        .unwrap_or("application/octet-stream");
597    let content_type = super::ContentType::from(content_type);
598
599    if !status.is_client_error() && !status.is_server_error() {
600        let content = resp.text().await?;
601        match content_type {
602            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
603            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::TapeMediaGetStatusResponse`"))),
604            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::TapeMediaGetStatusResponse`")))),
605        }
606    } else {
607        let content = resp.text().await?;
608        let entity: Option<TapeMediaGetStatusError> = serde_json::from_str(&content).ok();
609        Err(Error::ResponseError(ResponseContent { status, content, entity }))
610    }
611}
612
613/// Directory index.
614pub async fn tape_media_get_tape_media_list_by_uuid(configuration: &configuration::Configuration, uuid: &str) -> Result<models::TapeMediaGetTapeMediaListByUuidResponse, Error<TapeMediaGetTapeMediaListByUuidError>> {
615    // add a prefix to parameters to efficiently prevent name collisions
616    let p_path_uuid = uuid;
617
618    let uri_str = format!("{}/tape/media/list/{uuid}", configuration.base_path, uuid=crate::apis::urlencode(p_path_uuid));
619    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
620
621    if let Some(ref user_agent) = configuration.user_agent {
622        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
623    }
624    if let Some(ref apikey) = configuration.api_key {
625        let key = apikey.key.clone();
626        let value = match apikey.prefix {
627            Some(ref prefix) => format!("{} {}", prefix, key),
628            None => key,
629        };
630        req_builder = req_builder.header("Authorization", value);
631    };
632    if let Some(ref apikey) = configuration.api_key {
633        let key = apikey.key.clone();
634        let value = match apikey.prefix {
635            Some(ref prefix) => format!("{} {}", prefix, key),
636            None => key,
637        };
638        req_builder = req_builder.header("CSRFPreventionToken", value);
639    };
640
641    let req = req_builder.build()?;
642    let resp = configuration.client.execute(req).await?;
643
644    let status = resp.status();
645    let content_type = resp
646        .headers()
647        .get("content-type")
648        .and_then(|v| v.to_str().ok())
649        .unwrap_or("application/octet-stream");
650    let content_type = super::ContentType::from(content_type);
651
652    if !status.is_client_error() && !status.is_server_error() {
653        let content = resp.text().await?;
654        match content_type {
655            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
656            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::TapeMediaGetTapeMediaListByUuidResponse`"))),
657            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::TapeMediaGetTapeMediaListByUuidResponse`")))),
658        }
659    } else {
660        let content = resp.text().await?;
661        let entity: Option<TapeMediaGetTapeMediaListByUuidError> = serde_json::from_str(&content).ok();
662        Err(Error::ResponseError(ResponseContent { status, content, entity }))
663    }
664}
665