client: use api macro for catalog_shell async fn

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
This commit is contained in:
Wolfgang Bumiller 2019-12-16 11:24:42 +01:00
parent 87c423751a
commit 78d5436040

View File

@ -1856,18 +1856,31 @@ async fn mount_do(param: Value, pipe: Option<RawFd>) -> Result<Value, Error> {
Ok(Value::Null) Ok(Value::Null)
} }
fn catalog_shell<'a>( #[api(
param: Value, input: {
_info: &ApiMethod, properties: {
_rpcenv: &'a mut dyn RpcEnvironment, "snapshot": {
) -> ApiFuture<'a> { type: String,
description: "Group/Snapshot path.",
async move { },
catalog_shell_async(param).await "archive-name": {
}.boxed() type: String,
} description: "Backup archive name.",
},
async fn catalog_shell_async(param: Value) -> Result<Value, Error> { "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(&param)?; let repo = extract_repository_from_value(&param)?;
let client = HttpClient::new(repo.host(), repo.user(), None)?; let client = HttpClient::new(repo.host(), repo.user(), None)?;
let path = tools::required_string_param(&param, "snapshot")?; let path = tools::required_string_param(&param, "snapshot")?;
@ -1971,26 +1984,11 @@ async fn catalog_shell_async(param: Value) -> Result<Value, Error> {
record_repository(&repo); record_repository(&repo);
Ok(Value::Null) Ok(())
} }
fn catalog_mgmt_cli() -> CliCommandMap { fn catalog_mgmt_cli() -> CliCommandMap {
let catalog_shell_cmd_def = CliCommand::new(&API_METHOD_CATALOG_SHELL)
#[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)
.arg_param(&["snapshot", "archive-name"]) .arg_param(&["snapshot", "archive-name"])
.completion_cb("repository", complete_repository) .completion_cb("repository", complete_repository)
.completion_cb("archive-name", complete_pxar_archive_name) .completion_cb("archive-name", complete_pxar_archive_name)