4 use proxmox
::api
::{api, cli::*, RpcEnvironment, ApiHandler}
;
6 use proxmox_backup
::config
;
7 use proxmox_backup
::api2
::{self, types::* }
;
13 schema
: OUTPUT_FORMAT
,
20 fn list_sync_jobs(param
: Value
, rpcenv
: &mut dyn RpcEnvironment
) -> Result
<Value
, Error
> {
22 let output_format
= get_output_format(¶m
);
24 let info
= &api2
::config
::sync
::API_METHOD_LIST_SYNC_JOBS
;
25 let mut data
= match info
.handler
{
26 ApiHandler
::Sync(handler
) => (handler
)(param
, info
, rpcenv
)?
,
30 let options
= default_table_format_options()
31 .column(ColumnConfig
::new("id"))
32 .column(ColumnConfig
::new("store"))
33 .column(ColumnConfig
::new("remote"))
34 .column(ColumnConfig
::new("remote-store"))
35 .column(ColumnConfig
::new("schedule"))
36 .column(ColumnConfig
::new("comment"));
38 format_and_print_result_full(&mut data
, &info
.returns
, &output_format
, &options
);
47 schema
: JOB_ID_SCHEMA
,
50 schema
: OUTPUT_FORMAT
,
56 /// Show sync job configuration
57 fn show_sync_job(param
: Value
, rpcenv
: &mut dyn RpcEnvironment
) -> Result
<Value
, Error
> {
59 let output_format
= get_output_format(¶m
);
61 let info
= &api2
::config
::sync
::API_METHOD_READ_SYNC_JOB
;
62 let mut data
= match info
.handler
{
63 ApiHandler
::Sync(handler
) => (handler
)(param
, info
, rpcenv
)?
,
67 let options
= default_table_format_options();
68 format_and_print_result_full(&mut data
, &info
.returns
, &output_format
, &options
);
73 pub fn sync_job_commands() -> CommandLineInterface
{
75 let cmd_def
= CliCommandMap
::new()
76 .insert("list", CliCommand
::new(&API_METHOD_LIST_SYNC_JOBS
))
78 CliCommand
::new(&API_METHOD_SHOW_SYNC_JOB
)
80 .completion_cb("id", config
::sync
::complete_sync_job_id
)
83 CliCommand
::new(&api2
::config
::sync
::API_METHOD_CREATE_SYNC_JOB
)
85 .completion_cb("id", config
::sync
::complete_sync_job_id
)
86 .completion_cb("schedule", config
::datastore
::complete_calendar_event
)
87 .completion_cb("store", config
::datastore
::complete_datastore_name
)
88 .completion_cb("remote", config
::remote
::complete_remote_name
)
89 .completion_cb("remote-store", crate::complete_remote_datastore_name
)
92 CliCommand
::new(&api2
::config
::sync
::API_METHOD_UPDATE_SYNC_JOB
)
94 .completion_cb("id", config
::sync
::complete_sync_job_id
)
95 .completion_cb("schedule", config
::datastore
::complete_calendar_event
)
96 .completion_cb("store", config
::datastore
::complete_datastore_name
)
97 .completion_cb("remote-store", crate::complete_remote_datastore_name
)
100 CliCommand
::new(&api2
::config
::sync
::API_METHOD_DELETE_SYNC_JOB
)
102 .completion_cb("id", config
::sync
::complete_sync_job_id
)