adaptions for proxmox 0.9 and proxmox-api-macro 0.3

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
This commit is contained in:
Wolfgang Bumiller
2020-12-18 12:26:07 +01:00
committed by Dietmar Maurer
parent 54d968664a
commit b2362a1207
22 changed files with 67 additions and 58 deletions

View File

@ -15,6 +15,7 @@ use proxmox::api::{
format_and_print_result_full,
default_table_format_options,
},
router::ReturnType,
};
use proxmox_backup::backup::{
@ -178,7 +179,7 @@ fn render_result(
) -> Result<(), Error> {
let mut data = serde_json::to_value(benchmark_result)?;
let schema = &BenchmarkResult::API_SCHEMA;
let return_type = ReturnType::new(false, &BenchmarkResult::API_SCHEMA);
let render_speed = |value: &Value, _record: &Value| -> Result<String, Error> {
match value["speed"].as_f64() {
@ -211,7 +212,7 @@ fn render_result(
.right_align(false).renderer(render_speed));
format_and_print_result_full(&mut data, schema, output_format, &options);
format_and_print_result_full(&mut data, &return_type, output_format, &options);
Ok(())
}

View File

@ -15,6 +15,7 @@ use proxmox::api::cli::{
get_output_format,
OUTPUT_FORMAT,
};
use proxmox::api::router::ReturnType;
use proxmox::sys::linux::tty;
use proxmox::tools::fs::{file_get_contents, replace_file, CreateOptions};
@ -382,9 +383,14 @@ fn show_key(
.column(ColumnConfig::new("modified").renderer(tools::format::render_epoch))
.column(ColumnConfig::new("fingerprint"));
let schema = &KeyInfo::API_SCHEMA;
let return_type = ReturnType::new(false, &KeyInfo::API_SCHEMA);
format_and_print_result_full(&mut serde_json::to_value(info)?, schema, &output_format, &options);
format_and_print_result_full(
&mut serde_json::to_value(info)?,
&return_type,
&output_format,
&options,
);
Ok(())
}

View File

@ -97,9 +97,9 @@ async fn list_snapshots(param: Value) -> Result<Value, Error> {
.column(ColumnConfig::new("files").renderer(render_files))
;
let info = &proxmox_backup::api2::admin::datastore::API_RETURN_SCHEMA_LIST_SNAPSHOTS;
let return_type = &proxmox_backup::api2::admin::datastore::API_METHOD_LIST_SNAPSHOTS.returns;
format_and_print_result_full(&mut data, info, &output_format, &options);
format_and_print_result_full(&mut data, return_type, &output_format, &options);
Ok(Value::Null)
}
@ -144,13 +144,14 @@ async fn list_snapshot_files(param: Value) -> Result<Value, Error> {
record_repository(&repo);
let info = &proxmox_backup::api2::admin::datastore::API_RETURN_SCHEMA_LIST_SNAPSHOT_FILES;
let return_type =
&proxmox_backup::api2::admin::datastore::API_METHOD_LIST_SNAPSHOT_FILES.returns;
let mut data: Value = result["data"].take();
let options = default_table_format_options();
format_and_print_result_full(&mut data, info, &output_format, &options);
format_and_print_result_full(&mut data, return_type, &output_format, &options);
Ok(Value::Null)
}

View File

@ -64,7 +64,7 @@ async fn task_list(param: Value) -> Result<Value, Error> {
let mut result = client.get("api2/json/nodes/localhost/tasks", Some(args)).await?;
let mut data = result["data"].take();
let schema = &proxmox_backup::api2::node::tasks::API_RETURN_SCHEMA_LIST_TASKS;
let return_type = &proxmox_backup::api2::node::tasks::API_METHOD_LIST_TASKS.returns;
let options = default_table_format_options()
.column(ColumnConfig::new("starttime").right_align(false).renderer(tools::format::render_epoch))
@ -72,7 +72,7 @@ async fn task_list(param: Value) -> Result<Value, Error> {
.column(ColumnConfig::new("upid"))
.column(ColumnConfig::new("status").renderer(tools::format::render_task_status));
format_and_print_result_full(&mut data, schema, &output_format, &options);
format_and_print_result_full(&mut data, return_type, &output_format, &options);
Ok(Value::Null)
}