]> git.proxmox.com Git - proxmox-backup.git/blob - src/bin/proxmox_backup_manager/subscription.rs
a0adab3479d4d1ea70503239c188051704b950cd
[proxmox-backup.git] / src / bin / proxmox_backup_manager / subscription.rs
1 use anyhow::Error;
2 use serde_json::Value;
3
4 use proxmox_router::{cli::*, ApiHandler, RpcEnvironment};
5 use proxmox_schema::api;
6
7 use 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.
20 fn get(param: Value, rpcenv: &mut dyn RpcEnvironment) -> Result<Value, Error> {
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 let cmd_def = CliCommandMap::new()
37 .insert("get", CliCommand::new(&API_METHOD_GET))
38 .insert(
39 "set",
40 CliCommand::new(&api2::node::subscription::API_METHOD_SET_SUBSCRIPTION)
41 .fixed_param("node", "localhost".into())
42 .arg_param(&["key"]),
43 )
44 .insert(
45 "update",
46 CliCommand::new(&api2::node::subscription::API_METHOD_CHECK_SUBSCRIPTION)
47 .fixed_param("node", "localhost".into()),
48 )
49 .insert(
50 "remove",
51 CliCommand::new(&api2::node::subscription::API_METHOD_DELETE_SUBSCRIPTION)
52 .fixed_param("node", "localhost".into()),
53 );
54
55 cmd_def.into()
56 }