From 3f1020b7326c59ec29a55deee249d566f43cc120 Mon Sep 17 00:00:00 2001 From: Dietmar Maurer Date: Fri, 13 Dec 2019 09:43:08 +0100 Subject: [PATCH] src/bin/proxmox-backup-client.rs: implement task stop --- src/bin/proxmox-backup-client.rs | 36 +++++++++++++++++++++++++++++++- 1 file changed, 35 insertions(+), 1 deletion(-) diff --git a/src/bin/proxmox-backup-client.rs b/src/bin/proxmox-backup-client.rs index 56159144..0831c4d6 100644 --- a/src/bin/proxmox-backup-client.rs +++ b/src/bin/proxmox-backup-client.rs @@ -2039,6 +2039,37 @@ fn task_log(param: Value) -> Result { Ok(Value::Null) } +#[api( + input: { + properties: { + repository: { + schema: REPO_URL_SCHEMA, + optional: true, + }, + upid: { + schema: UPID_SCHEMA, + }, + } + } +)] +/// Try to stop a specific task. +fn task_stop(param: Value) -> Result { + + async_main(async { + let repo = extract_repository_from_value(¶m)?; + let upid_str = tools::required_string_param(¶m, "upid")?; + + let mut client = HttpClient::new(repo.host(), repo.user(), None)?; + + let path = format!("api2/json/nodes/localhost/tasks/{}", upid_str); + let _ = client.delete(&path, None).await?; + + Ok::<_, Error>(()) + })?; + + Ok(Value::Null) +} + fn task_mgmt_cli() -> CliCommandMap { let task_list_cmd_def = CliCommand::new(&API_METHOD_TASK_LIST) @@ -2047,10 +2078,13 @@ fn task_mgmt_cli() -> CliCommandMap { let task_log_cmd_def = CliCommand::new(&API_METHOD_TASK_LOG) .arg_param(&["upid"]); + let task_stop_cmd_def = CliCommand::new(&API_METHOD_TASK_STOP) + .arg_param(&["upid"]); + CliCommandMap::new() .insert("log", task_log_cmd_def) .insert("list", task_list_cmd_def) - + .insert("stop", task_stop_cmd_def) } fn main() { -- 2.39.2