kanidm_cli/system_config/
denied_names.rs1use kanidm_proto::cli::OpType;
2
3use crate::{handle_client_error, DeniedNamesOpt, KanidmClientParser, OutputMode};
4
5impl DeniedNamesOpt {
6 pub async fn exec(&self, opt: KanidmClientParser) {
7 match self {
8 DeniedNamesOpt::Show => {
9 let client = opt.to_client(OpType::Read).await;
10 match client.system_denied_names_get().await {
11 Ok(list) => match opt.output_mode {
12 OutputMode::Json => {
13 let json = serde_json::to_string(&list)
14 .expect("Failed to serialise list to JSON!");
15 println!("{json}");
16 }
17 OutputMode::Text => {
18 for i in list {
19 println!("{i}");
20 }
21 eprintln!("--");
22 eprintln!("Success");
23 }
24 },
25 Err(e) => crate::handle_client_error(e, opt.output_mode),
26 }
27 }
28 DeniedNamesOpt::Append { names } => {
29 let client = opt.to_client(OpType::Write).await;
30
31 match client.system_denied_names_append(names).await {
32 Ok(_) => opt.output_mode.print_message("Success"),
33 Err(e) => handle_client_error(e, opt.output_mode),
34 }
35 }
36 DeniedNamesOpt::Remove { names } => {
37 let client = opt.to_client(OpType::Write).await;
38
39 match client.system_denied_names_remove(names).await {
40 Ok(_) => opt.output_mode.print_message("Success"),
41 Err(e) => handle_client_error(e, opt.output_mode),
42 }
43 }
44 }
45 }
46}