]> git.proxmox.com Git - proxmox-backup.git/blame - src/api2/tape/mod.rs
update to first proxmox crate split
[proxmox-backup.git] / src / api2 / tape / mod.rs
CommitLineData
bf78f708
DM
1//! Tape Backup Management
2
887f1cb9
DM
3use anyhow::Error;
4use serde_json::Value;
5
6ef1b649
WB
6use proxmox_schema::api;
7use proxmox_router::{list_subdirs_api_method, Router, SubdirMap};
887f1cb9 8
6227654a 9use pbs_api_types::TapeDeviceInfo;
048b43af 10use pbs_tape::linux_list_drives::{lto_tape_device_list, linux_tape_changer_list};
5d908606
DM
11
12pub mod drive;
13pub mod changer;
fba0b774 14pub mod media;
88356646 15pub mod backup;
b017bbc4 16pub mod restore;
5d908606 17
9586ce2f
DM
18#[api(
19 input: {
20 properties: {},
21 },
22 returns: {
23 description: "The list of autodetected tape drives.",
24 type: Array,
25 items: {
26 type: TapeDeviceInfo,
27 },
28 },
29)]
30/// Scan tape drives
31pub fn scan_drives(_param: Value) -> Result<Vec<TapeDeviceInfo>, Error> {
32
a79082a0 33 let list = lto_tape_device_list();
9586ce2f
DM
34
35 Ok(list)
36}
37
887f1cb9
DM
38#[api(
39 input: {
40 properties: {},
41 },
42 returns: {
43 description: "The list of autodetected tape changers.",
44 type: Array,
45 items: {
46 type: TapeDeviceInfo,
47 },
48 },
49)]
50/// Scan for SCSI tape changers
51pub fn scan_changers(_param: Value) -> Result<Vec<TapeDeviceInfo>, Error> {
52
53 let list = linux_tape_changer_list();
54
55 Ok(list)
56}
57
58const SUBDIRS: SubdirMap = &[
88356646 59 ("backup", &backup::ROUTER),
5d908606
DM
60 ("changer", &changer::ROUTER),
61 ("drive", &drive::ROUTER),
fba0b774 62 ("media", &media::ROUTER),
b9b4b312 63 ("restore", &restore::ROUTER),
740dc9d1
DC
64 (
65 "scan-changers",
66 &Router::new()
887f1cb9 67 .get(&API_METHOD_SCAN_CHANGERS),
740dc9d1 68 ),
5fdaecf6
DC
69 (
70 "scan-drives",
71 &Router::new()
9586ce2f 72 .get(&API_METHOD_SCAN_DRIVES),
5fdaecf6 73 ),
5d908606
DM
74];
75
76pub const ROUTER: Router = Router::new()
77 .get(&list_subdirs_api_method!(SUBDIRS))
78 .subdirs(SUBDIRS);