]> git.proxmox.com Git - proxmox-backup.git/commitdiff
proxmox-backup-manager: add subscription commands
authorThomas Lamprecht <t.lamprecht@proxmox.com>
Fri, 30 Oct 2020 11:51:19 +0000 (12:51 +0100)
committerThomas Lamprecht <t.lamprecht@proxmox.com>
Fri, 30 Oct 2020 12:03:58 +0000 (13:03 +0100)
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
src/bin/proxmox-backup-manager.rs
src/bin/proxmox_backup_manager/mod.rs
src/bin/proxmox_backup_manager/subscription.rs [new file with mode: 0644]

index 549be2ef0b0fc9ab4f5ac7f5be1eeb2e80e267b9..bbb3ed2f373130c9d9c8ae4c9a7e87c241057c82 100644 (file)
@@ -368,6 +368,7 @@ fn main() {
         .insert("remote", remote_commands())
         .insert("garbage-collection", garbage_collection_commands())
         .insert("cert", cert_mgmt_cli())
+        .insert("subscription", subscription_commands())
         .insert("sync-job", sync_job_commands())
         .insert("task", task_mgmt_cli())
         .insert(
index 33c1d5707c08cad5d50f4da163ac834759093f4a..1f3ff92eade2def03bbe65dccd23535c8639b314 100644 (file)
@@ -14,5 +14,7 @@ mod sync;
 pub use sync::*;
 mod user;
 pub use user::*;
+mod subscription;
+pub use subscription::*;
 mod disk;
 pub use disk::*;
diff --git a/src/bin/proxmox_backup_manager/subscription.rs b/src/bin/proxmox_backup_manager/subscription.rs
new file mode 100644 (file)
index 0000000..8daec62
--- /dev/null
@@ -0,0 +1,55 @@
+use anyhow::Error;
+use serde_json::Value;
+
+use proxmox::api::{api, cli::*, RpcEnvironment, ApiHandler};
+
+use proxmox_backup::api2;
+
+#[api(
+    input: {
+        properties: {
+            "output-format": {
+                schema: OUTPUT_FORMAT,
+                optional: true,
+            },
+        }
+    }
+)]
+/// Read subscription info.
+fn get(param: Value, rpcenv: &mut dyn RpcEnvironment) -> Result<Value, Error> {
+
+    let output_format = get_output_format(&param);
+
+    let info = &api2::node::subscription::API_METHOD_GET_SUBSCRIPTION;
+    let mut data = match info.handler {
+        ApiHandler::Sync(handler) => (handler)(param, info, rpcenv)?,
+        _ => unreachable!(),
+    };
+
+    let options = default_table_format_options();
+    format_and_print_result_full(&mut data, info.returns, &output_format, &options);
+
+    Ok(Value::Null)
+}
+
+pub fn subscription_commands() -> CommandLineInterface {
+
+    let cmd_def = CliCommandMap::new()
+        .insert("get", CliCommand::new(&API_METHOD_GET))
+        .insert("set",
+            CliCommand::new(&api2::node::subscription::API_METHOD_SET_SUBSCRIPTION)
+                .fixed_param("node", "localhost".into())
+                .arg_param(&["key"])
+        )
+        .insert("update",
+            CliCommand::new(&api2::node::subscription::API_METHOD_CHECK_SUBSCRIPTION)
+                .fixed_param("node", "localhost".into())
+        )
+        .insert("delete",
+            CliCommand::new(&api2::node::subscription::API_METHOD_DELETE_SUBSCRIPTION)
+                .fixed_param("node", "localhost".into())
+        )
+        ;
+
+    cmd_def.into()
+}