1 use anyhow
::{bail, Error}
;
4 use proxmox_router
::{cli::*, ApiHandler, RpcEnvironment}
;
5 use proxmox_schema
::api
;
7 use proxmox_backup
::api2
;
13 schema
: OUTPUT_FORMAT
,
19 /// Access Control list.
20 fn list_acls(param
: Value
, rpcenv
: &mut dyn RpcEnvironment
) -> Result
<Value
, Error
> {
22 let output_format
= get_output_format(¶m
);
24 let info
= &api2
::access
::acl
::API_METHOD_READ_ACL
;
25 let mut data
= match info
.handler
{
26 ApiHandler
::Sync(handler
) => (handler
)(param
, info
, rpcenv
)?
,
30 fn render_ugid(value
: &Value
, record
: &Value
) -> Result
<String
, Error
> {
31 if value
.is_null() { return Ok(String::new()); }
32 let ugid
= value
.as_str().unwrap();
33 let ugid_type
= record
["ugid_type"].as_str().unwrap();
35 if ugid_type
== "user" {
37 } else if ugid_type
== "group" {
38 Ok(format
!("@{}", ugid
))
40 bail
!("render_ugid: got unknown ugid_type");
44 let options
= default_table_format_options()
45 .column(ColumnConfig
::new("ugid").renderer(render_ugid
))
46 .column(ColumnConfig
::new("path"))
47 .column(ColumnConfig
::new("propagate"))
48 .column(ColumnConfig
::new("roleid"));
50 format_and_print_result_full(&mut data
, &info
.returns
, &output_format
, &options
);
55 pub fn acl_commands() -> CommandLineInterface
{
57 let cmd_def
= CliCommandMap
::new()
58 .insert("list", CliCommand
::new(&&API_METHOD_LIST_ACLS
))
61 CliCommand
::new(&api2
::access
::acl
::API_METHOD_UPDATE_ACL
)
62 .arg_param(&["path", "role"])
63 .completion_cb("auth-id", pbs_config
::user
::complete_authid
)
64 .completion_cb("path", pbs_config
::datastore
::complete_acl_path
)