]> git.proxmox.com Git - proxmox-backup.git/blame - src/bin/proxmox_backup_manager/subscription.rs
update to first proxmox crate split
[proxmox-backup.git] / src / bin / proxmox_backup_manager / subscription.rs
CommitLineData
2762481c
TL
1use anyhow::Error;
2use serde_json::Value;
3
6ef1b649
WB
4use proxmox_router::{cli::*, ApiHandler, RpcEnvironment};
5use proxmox_schema::api;
2762481c
TL
6
7use proxmox_backup::api2;
8
9#[api(
10 input: {
11 properties: {
12 "output-format": {
13 schema: OUTPUT_FORMAT,
14 optional: true,
15 },
16 }
17 }
18)]
19/// Read subscription info.
20fn get(param: Value, rpcenv: &mut dyn RpcEnvironment) -> Result<Value, Error> {
21
22 let output_format = get_output_format(&param);
23
24 let info = &api2::node::subscription::API_METHOD_GET_SUBSCRIPTION;
25 let mut data = match info.handler {
26 ApiHandler::Sync(handler) => (handler)(param, info, rpcenv)?,
27 _ => unreachable!(),
28 };
29
30 let options = default_table_format_options();
b2362a12 31 format_and_print_result_full(&mut data, &info.returns, &output_format, &options);
2762481c
TL
32
33 Ok(Value::Null)
34}
35
36pub fn subscription_commands() -> CommandLineInterface {
37
38 let cmd_def = CliCommandMap::new()
39 .insert("get", CliCommand::new(&API_METHOD_GET))
40 .insert("set",
41 CliCommand::new(&api2::node::subscription::API_METHOD_SET_SUBSCRIPTION)
42 .fixed_param("node", "localhost".into())
43 .arg_param(&["key"])
44 )
45 .insert("update",
46 CliCommand::new(&api2::node::subscription::API_METHOD_CHECK_SUBSCRIPTION)
47 .fixed_param("node", "localhost".into())
48 )
fa7aceeb 49 .insert("remove",
2762481c
TL
50 CliCommand::new(&api2::node::subscription::API_METHOD_DELETE_SUBSCRIPTION)
51 .fixed_param("node", "localhost".into())
52 )
53 ;
54
55 cmd_def.into()
56}