add user configiguration

This commit is contained in:
Dietmar Maurer
2020-04-06 12:09:27 +02:00
parent cf459b1982
commit 579728c641
5 changed files with 534 additions and 0 deletions

View File

@ -110,6 +110,67 @@ fn remote_commands() -> CommandLineInterface {
cmd_def.into()
}
#[api(
input: {
properties: {
"output-format": {
schema: OUTPUT_FORMAT,
optional: true,
},
}
}
)]
/// List configured users.
fn list_users(param: Value, rpcenv: &mut dyn RpcEnvironment) -> Result<Value, Error> {
let output_format = get_output_format(&param);
let info = &api2::config::user::API_METHOD_LIST_USERS;
let mut data = match info.handler {
ApiHandler::Sync(handler) => (handler)(param, info, rpcenv)?,
_ => unreachable!(),
};
let options = default_table_format_options()
.column(ColumnConfig::new("userid"))
.column(ColumnConfig::new("enable"))
.column(ColumnConfig::new("expire"))
.column(ColumnConfig::new("firstname"))
.column(ColumnConfig::new("lastname"))
.column(ColumnConfig::new("email"))
.column(ColumnConfig::new("comment"));
format_and_print_result_full(&mut data, info.returns, &output_format, &options);
Ok(Value::Null)
}
fn user_commands() -> CommandLineInterface {
let cmd_def = CliCommandMap::new()
.insert("list", CliCommand::new(&&API_METHOD_LIST_USERS))
.insert(
"create",
// fixme: howto handle password parameter?
CliCommand::new(&api2::config::user::API_METHOD_CREATE_USER)
.arg_param(&["userid"])
)
.insert(
"update",
CliCommand::new(&api2::config::user::API_METHOD_UPDATE_USER)
.arg_param(&["userid"])
.completion_cb("userid", config::user::complete_user_name)
)
.insert(
"remove",
CliCommand::new(&api2::config::user::API_METHOD_DELETE_USER)
.arg_param(&["userid"])
.completion_cb("userid", config::user::complete_user_name)
);
cmd_def.into()
}
fn datastore_commands() -> CommandLineInterface {
let cmd_def = CliCommandMap::new()
@ -479,6 +540,7 @@ fn main() {
let cmd_def = CliCommandMap::new()
.insert("datastore", datastore_commands())
.insert("user", user_commands())
.insert("remote", remote_commands())
.insert("garbage-collection", garbage_collection_commands())
.insert("cert", cert_mgmt_cli())