From 78d543604085160114c720df79db621451e1b033 Mon Sep 17 00:00:00 2001 From: Wolfgang Bumiller Date: Mon, 16 Dec 2019 11:24:42 +0100 Subject: [PATCH] client: use api macro for catalog_shell async fn Signed-off-by: Wolfgang Bumiller --- src/bin/proxmox-backup-client.rs | 56 +++++++++++++++----------------- 1 file changed, 27 insertions(+), 29 deletions(-) diff --git a/src/bin/proxmox-backup-client.rs b/src/bin/proxmox-backup-client.rs index 33d69252..c47a1bad 100644 --- a/src/bin/proxmox-backup-client.rs +++ b/src/bin/proxmox-backup-client.rs @@ -1856,18 +1856,31 @@ async fn mount_do(param: Value, pipe: Option) -> Result { Ok(Value::Null) } -fn catalog_shell<'a>( - param: Value, - _info: &ApiMethod, - _rpcenv: &'a mut dyn RpcEnvironment, -) -> ApiFuture<'a> { - - async move { - catalog_shell_async(param).await - }.boxed() -} - -async fn catalog_shell_async(param: Value) -> Result { +#[api( + input: { + properties: { + "snapshot": { + type: String, + description: "Group/Snapshot path.", + }, + "archive-name": { + type: String, + description: "Backup archive name.", + }, + "repository": { + optional: true, + schema: REPO_URL_SCHEMA, + }, + "keyfile": { + optional: true, + type: String, + description: "Path to encryption key.", + }, + }, + }, +)] +/// Shell to interactively inspect and restore snapshots. +async fn catalog_shell(param: Value) -> Result<(), Error> { let repo = extract_repository_from_value(¶m)?; let client = HttpClient::new(repo.host(), repo.user(), None)?; let path = tools::required_string_param(¶m, "snapshot")?; @@ -1971,26 +1984,11 @@ async fn catalog_shell_async(param: Value) -> Result { record_repository(&repo); - Ok(Value::Null) + Ok(()) } fn catalog_mgmt_cli() -> CliCommandMap { - - #[sortable] - const API_METHOD_SHELL: ApiMethod = ApiMethod::new( - &ApiHandler::Async(&catalog_shell), - &ObjectSchema::new( - "Shell to interactively inspect and restore snapshots.", - &sorted!([ - ("snapshot", false, &StringSchema::new("Group/Snapshot path.").schema()), - ("archive-name", false, &StringSchema::new("Backup archive name.").schema()), - ("repository", true, &REPO_URL_SCHEMA), - ("keyfile", true, &StringSchema::new("Path to encryption key.").schema()), - ]), - ) - ); - - let catalog_shell_cmd_def = CliCommand::new(&API_METHOD_SHELL) + let catalog_shell_cmd_def = CliCommand::new(&API_METHOD_CATALOG_SHELL) .arg_param(&["snapshot", "archive-name"]) .completion_cb("repository", complete_repository) .completion_cb("archive-name", complete_pxar_archive_name)