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