]> git.proxmox.com Git - proxmox-backup.git/blame - src/api2/tape/mod.rs
more api type cleanups: avoid re-exports
[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
6use proxmox::{
7 api::{
8 api,
9 router::SubdirMap,
10 Router,
11 },
12 list_subdirs_api_method,
13};
14
6227654a
DM
15use pbs_api_types::TapeDeviceInfo;
16
887f1cb9 17use crate::{
9586ce2f 18 tape::{
a79082a0 19 lto_tape_device_list,
9586ce2f
DM
20 linux_tape_changer_list,
21 },
887f1cb9 22};
5d908606
DM
23
24pub mod drive;
25pub mod changer;
fba0b774 26pub mod media;
88356646 27pub mod backup;
b017bbc4 28pub mod restore;
5d908606 29
9586ce2f
DM
30#[api(
31 input: {
32 properties: {},
33 },
34 returns: {
35 description: "The list of autodetected tape drives.",
36 type: Array,
37 items: {
38 type: TapeDeviceInfo,
39 },
40 },
41)]
42/// Scan tape drives
43pub fn scan_drives(_param: Value) -> Result<Vec<TapeDeviceInfo>, Error> {
44
a79082a0 45 let list = lto_tape_device_list();
9586ce2f
DM
46
47 Ok(list)
48}
49
887f1cb9
DM
50#[api(
51 input: {
52 properties: {},
53 },
54 returns: {
55 description: "The list of autodetected tape changers.",
56 type: Array,
57 items: {
58 type: TapeDeviceInfo,
59 },
60 },
61)]
62/// Scan for SCSI tape changers
63pub fn scan_changers(_param: Value) -> Result<Vec<TapeDeviceInfo>, Error> {
64
65 let list = linux_tape_changer_list();
66
67 Ok(list)
68}
69
70const SUBDIRS: SubdirMap = &[
88356646 71 ("backup", &backup::ROUTER),
5d908606
DM
72 ("changer", &changer::ROUTER),
73 ("drive", &drive::ROUTER),
fba0b774 74 ("media", &media::ROUTER),
b9b4b312 75 ("restore", &restore::ROUTER),
740dc9d1
DC
76 (
77 "scan-changers",
78 &Router::new()
887f1cb9 79 .get(&API_METHOD_SCAN_CHANGERS),
740dc9d1 80 ),
5fdaecf6
DC
81 (
82 "scan-drives",
83 &Router::new()
9586ce2f 84 .get(&API_METHOD_SCAN_DRIVES),
5fdaecf6 85 ),
5d908606
DM
86];
87
88pub const ROUTER: Router = Router::new()
89 .get(&list_subdirs_api_method!(SUBDIRS))
90 .subdirs(SUBDIRS);