]>
Commit | Line | Data |
---|---|---|
2762481c TL |
1 | use anyhow::Error; |
2 | use serde_json::Value; | |
3 | ||
6ef1b649 WB |
4 | use proxmox_router::{cli::*, ApiHandler, RpcEnvironment}; |
5 | use proxmox_schema::api; | |
2762481c TL |
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 | ||
22 | let output_format = get_output_format(¶m); | |
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 | ||
36 | pub 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 | } |