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