4 use proxmox
::api
::{api, cli::*, RpcEnvironment, ApiHandler}
;
6 use proxmox_backup
::config
;
7 use proxmox_backup
::api2
::{self, types::* }
;
13 schema
: OUTPUT_FORMAT
,
19 /// List configured remotes.
20 fn list_remotes(param
: Value
, rpcenv
: &mut dyn RpcEnvironment
) -> Result
<Value
, Error
> {
22 let output_format
= get_output_format(¶m
);
24 let info
= &api2
::config
::remote
::API_METHOD_LIST_REMOTES
;
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("name"))
32 .column(ColumnConfig
::new("host"))
33 .column(ColumnConfig
::new("userid"))
34 .column(ColumnConfig
::new("fingerprint"))
35 .column(ColumnConfig
::new("comment"));
37 format_and_print_result_full(&mut data
, &info
.returns
, &output_format
, &options
);
46 schema
: REMOTE_ID_SCHEMA
,
49 schema
: OUTPUT_FORMAT
,
55 /// Show remote configuration
56 fn show_remote(param
: Value
, rpcenv
: &mut dyn RpcEnvironment
) -> Result
<Value
, Error
> {
58 let output_format
= get_output_format(¶m
);
60 let info
= &api2
::config
::remote
::API_METHOD_READ_REMOTE
;
61 let mut data
= match info
.handler
{
62 ApiHandler
::Sync(handler
) => (handler
)(param
, info
, rpcenv
)?
,
66 let options
= default_table_format_options();
67 format_and_print_result_full(&mut data
, &info
.returns
, &output_format
, &options
);
72 pub fn remote_commands() -> CommandLineInterface
{
74 let cmd_def
= CliCommandMap
::new()
75 .insert("list", CliCommand
::new(&&API_METHOD_LIST_REMOTES
))
78 CliCommand
::new(&API_METHOD_SHOW_REMOTE
)
80 .completion_cb("name", config
::remote
::complete_remote_name
)
84 // fixme: howto handle password parameter?
85 CliCommand
::new(&api2
::config
::remote
::API_METHOD_CREATE_REMOTE
)
90 CliCommand
::new(&api2
::config
::remote
::API_METHOD_UPDATE_REMOTE
)
92 .completion_cb("name", config
::remote
::complete_remote_name
)
96 CliCommand
::new(&api2
::config
::remote
::API_METHOD_DELETE_REMOTE
)
98 .completion_cb("name", config
::remote
::complete_remote_name
)