proxmox-backup-manager: add sync-job cli
This commit is contained in:
parent
b29d046e89
commit
a3016d6583
|
@ -314,6 +314,7 @@ fn main() {
|
||||||
.insert("remote", remote_commands())
|
.insert("remote", remote_commands())
|
||||||
.insert("garbage-collection", garbage_collection_commands())
|
.insert("garbage-collection", garbage_collection_commands())
|
||||||
.insert("cert", cert_mgmt_cli())
|
.insert("cert", cert_mgmt_cli())
|
||||||
|
.insert("sync-job", sync_job_commands())
|
||||||
.insert("task", task_mgmt_cli())
|
.insert("task", task_mgmt_cli())
|
||||||
.insert(
|
.insert(
|
||||||
"pull",
|
"pull",
|
||||||
|
|
|
@ -10,5 +10,7 @@ mod network;
|
||||||
pub use network::*;
|
pub use network::*;
|
||||||
mod remote;
|
mod remote;
|
||||||
pub use remote::*;
|
pub use remote::*;
|
||||||
|
mod sync;
|
||||||
|
pub use sync::*;
|
||||||
mod user;
|
mod user;
|
||||||
pub use user::*;
|
pub use user::*;
|
||||||
|
|
|
@ -0,0 +1,106 @@
|
||||||
|
use anyhow::Error;
|
||||||
|
use serde_json::Value;
|
||||||
|
|
||||||
|
use proxmox::api::{api, cli::*, RpcEnvironment, ApiHandler};
|
||||||
|
|
||||||
|
use proxmox_backup::config;
|
||||||
|
use proxmox_backup::api2::{self, types::* };
|
||||||
|
|
||||||
|
#[api(
|
||||||
|
input: {
|
||||||
|
properties: {
|
||||||
|
"output-format": {
|
||||||
|
schema: OUTPUT_FORMAT,
|
||||||
|
optional: true,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
}
|
||||||
|
)]
|
||||||
|
/// Sync job list.
|
||||||
|
fn list_sync_jobs(param: Value, rpcenv: &mut dyn RpcEnvironment) -> Result<Value, Error> {
|
||||||
|
|
||||||
|
let output_format = get_output_format(¶m);
|
||||||
|
|
||||||
|
let info = &api2::config::sync::API_METHOD_LIST_SYNC_JOBS;
|
||||||
|
let mut data = match info.handler {
|
||||||
|
ApiHandler::Sync(handler) => (handler)(param, info, rpcenv)?,
|
||||||
|
_ => unreachable!(),
|
||||||
|
};
|
||||||
|
|
||||||
|
let options = default_table_format_options()
|
||||||
|
.column(ColumnConfig::new("id"))
|
||||||
|
.column(ColumnConfig::new("store"))
|
||||||
|
.column(ColumnConfig::new("remote"))
|
||||||
|
.column(ColumnConfig::new("remote-store"))
|
||||||
|
.column(ColumnConfig::new("schedule"))
|
||||||
|
.column(ColumnConfig::new("comment"));
|
||||||
|
|
||||||
|
format_and_print_result_full(&mut data, info.returns, &output_format, &options);
|
||||||
|
|
||||||
|
Ok(Value::Null)
|
||||||
|
}
|
||||||
|
|
||||||
|
#[api(
|
||||||
|
input: {
|
||||||
|
properties: {
|
||||||
|
id: {
|
||||||
|
schema: JOB_ID_SCHEMA,
|
||||||
|
},
|
||||||
|
"output-format": {
|
||||||
|
schema: OUTPUT_FORMAT,
|
||||||
|
optional: true,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
}
|
||||||
|
)]
|
||||||
|
/// Show sync job configuration
|
||||||
|
fn show_sync_job(param: Value, rpcenv: &mut dyn RpcEnvironment) -> Result<Value, Error> {
|
||||||
|
|
||||||
|
let output_format = get_output_format(¶m);
|
||||||
|
|
||||||
|
let info = &api2::config::sync::API_METHOD_READ_SYNC_JOB;
|
||||||
|
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 sync_job_commands() -> CommandLineInterface {
|
||||||
|
|
||||||
|
let cmd_def = CliCommandMap::new()
|
||||||
|
.insert("list", CliCommand::new(&API_METHOD_LIST_SYNC_JOBS))
|
||||||
|
.insert("show",
|
||||||
|
CliCommand::new(&API_METHOD_SHOW_SYNC_JOB)
|
||||||
|
.arg_param(&["id"])
|
||||||
|
.completion_cb("id", config::sync::complete_sync_job_id)
|
||||||
|
)
|
||||||
|
.insert("create",
|
||||||
|
CliCommand::new(&api2::config::sync::API_METHOD_CREATE_SYNC_JOB)
|
||||||
|
.arg_param(&["id"])
|
||||||
|
.completion_cb("id", config::sync::complete_sync_job_id)
|
||||||
|
.completion_cb("schedule", config::datastore::complete_calendar_event)
|
||||||
|
.completion_cb("store", config::datastore::complete_datastore_name)
|
||||||
|
.completion_cb("remote", config::remote::complete_remote_name)
|
||||||
|
.completion_cb("remote-store", crate::complete_remote_datastore_name)
|
||||||
|
)
|
||||||
|
.insert("update",
|
||||||
|
CliCommand::new(&api2::config::sync::API_METHOD_UPDATE_SYNC_JOB)
|
||||||
|
.arg_param(&["id"])
|
||||||
|
.completion_cb("id", config::sync::complete_sync_job_id)
|
||||||
|
.completion_cb("schedule", config::datastore::complete_calendar_event)
|
||||||
|
.completion_cb("store", config::datastore::complete_datastore_name)
|
||||||
|
.completion_cb("remote-store", crate::complete_remote_datastore_name)
|
||||||
|
)
|
||||||
|
.insert("remove",
|
||||||
|
CliCommand::new(&api2::config::sync::API_METHOD_DELETE_SYNC_JOB)
|
||||||
|
.arg_param(&["id"])
|
||||||
|
.completion_cb("id", config::sync::complete_sync_job_id)
|
||||||
|
);
|
||||||
|
|
||||||
|
cmd_def.into()
|
||||||
|
}
|
Loading…
Reference in New Issue