4 use proxmox
::api
::{api, cli::*, RpcEnvironment, ApiHandler}
;
6 use pbs_api_types
::JOB_ID_SCHEMA
;
8 use proxmox_backup
::api2
;
14 schema
: OUTPUT_FORMAT
,
21 fn list_sync_jobs(param
: Value
, rpcenv
: &mut dyn RpcEnvironment
) -> Result
<Value
, Error
> {
23 let output_format
= get_output_format(¶m
);
25 let info
= &api2
::config
::sync
::API_METHOD_LIST_SYNC_JOBS
;
26 let mut data
= match info
.handler
{
27 ApiHandler
::Sync(handler
) => (handler
)(param
, info
, rpcenv
)?
,
31 let options
= default_table_format_options()
32 .column(ColumnConfig
::new("id"))
33 .column(ColumnConfig
::new("store"))
34 .column(ColumnConfig
::new("remote"))
35 .column(ColumnConfig
::new("remote-store"))
36 .column(ColumnConfig
::new("schedule"))
37 .column(ColumnConfig
::new("comment"));
39 format_and_print_result_full(&mut data
, &info
.returns
, &output_format
, &options
);
48 schema
: JOB_ID_SCHEMA
,
51 schema
: OUTPUT_FORMAT
,
57 /// Show sync job configuration
58 fn show_sync_job(param
: Value
, rpcenv
: &mut dyn RpcEnvironment
) -> Result
<Value
, Error
> {
60 let output_format
= get_output_format(¶m
);
62 let info
= &api2
::config
::sync
::API_METHOD_READ_SYNC_JOB
;
63 let mut data
= match info
.handler
{
64 ApiHandler
::Sync(handler
) => (handler
)(param
, info
, rpcenv
)?
,
68 let options
= default_table_format_options();
69 format_and_print_result_full(&mut data
, &info
.returns
, &output_format
, &options
);
74 pub fn sync_job_commands() -> CommandLineInterface
{
76 let cmd_def
= CliCommandMap
::new()
77 .insert("list", CliCommand
::new(&API_METHOD_LIST_SYNC_JOBS
))
79 CliCommand
::new(&API_METHOD_SHOW_SYNC_JOB
)
81 .completion_cb("id", pbs_config
::sync
::complete_sync_job_id
)
84 CliCommand
::new(&api2
::config
::sync
::API_METHOD_CREATE_SYNC_JOB
)
86 .completion_cb("id", pbs_config
::sync
::complete_sync_job_id
)
87 .completion_cb("schedule", pbs_config
::datastore
::complete_calendar_event
)
88 .completion_cb("store", pbs_config
::datastore
::complete_datastore_name
)
89 .completion_cb("remote", pbs_config
::remote
::complete_remote_name
)
90 .completion_cb("remote-store", crate::complete_remote_datastore_name
)
93 CliCommand
::new(&api2
::config
::sync
::API_METHOD_UPDATE_SYNC_JOB
)
95 .completion_cb("id", pbs_config
::sync
::complete_sync_job_id
)
96 .completion_cb("schedule", pbs_config
::datastore
::complete_calendar_event
)
97 .completion_cb("store", pbs_config
::datastore
::complete_datastore_name
)
98 .completion_cb("remote-store", crate::complete_remote_datastore_name
)
101 CliCommand
::new(&api2
::config
::sync
::API_METHOD_DELETE_SYNC_JOB
)
103 .completion_cb("id", pbs_config
::sync
::complete_sync_job_id
)