kanidm_cli/system_config/
application.rs1use crate::{handle_client_error, ApplicationOpt, KanidmClientParser, OpType};
2
3use kanidm_proto::scim_v1::client::{ScimEntryApplicationPost, ScimReference};
4
5impl ApplicationOpt {
6 pub async fn exec(&self, opt: KanidmClientParser) {
7 match self {
8 Self::List => {
9 let client = opt.to_client(OpType::Read).await;
10 match client.idm_application_list(None).await {
11 Ok(response) => opt.output_mode.print_struct(&response),
12 Err(e) => handle_client_error(e, opt.output_mode),
13 }
14 }
15
16 Self::Create {
17 name,
18 displayname,
19 linked_group,
20 } => {
21 let client = opt.to_client(OpType::Write).await;
22
23 let linked_group = ScimReference::from(linked_group);
24
25 let application = ScimEntryApplicationPost {
26 name: name.clone(),
27 displayname: displayname.clone(),
28 linked_group,
29 };
30
31 match client.idm_application_create(&application).await {
32 Ok(_) => opt.output_mode.print_message("Success"),
33 Err(e) => handle_client_error(e, opt.output_mode),
34 }
35 }
36
37 Self::Get { name } => {
38 let client = opt.to_client(OpType::Read).await;
39
40 match client.idm_application_get(name, None).await {
41 Ok(response) => opt.output_mode.print_struct(&response),
42 Err(e) => handle_client_error(e, opt.output_mode),
43 }
44 }
45
46 Self::Delete { name } => {
47 let client = opt.to_client(OpType::Write).await;
48
49 match client.idm_application_delete(name).await {
50 Ok(_) => opt.output_mode.print_message("Success"),
51 Err(e) => handle_client_error(e, opt.output_mode),
52 }
53 }
54 }
55 }
56}