1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
use crate::common::OpType;
use crate::DomainOpt;
impl DomainOpt {
pub fn debug(&self) -> bool {
match self {
DomainOpt::SetDisplayName(copt) => copt.copt.debug,
DomainOpt::SetLdapBasedn { copt, .. } => copt.debug,
DomainOpt::Show(copt) | DomainOpt::ResetTokenKey(copt) => copt.debug,
}
}
pub async fn exec(&self) {
match self {
DomainOpt::SetDisplayName(opt) => {
eprintln!(
"Attempting to set the domain's display name to: {:?}",
opt.new_display_name
);
let client = opt.copt.to_client(OpType::Write).await;
match client
.idm_domain_set_display_name(&opt.new_display_name)
.await
{
Ok(_) => println!("Success"),
Err(e) => eprintln!("{:?}", e),
}
}
DomainOpt::SetLdapBasedn { copt, new_basedn } => {
eprintln!(
"Attempting to set the domain's ldap basedn to: {:?}",
new_basedn
);
let client = copt.to_client(OpType::Write).await;
match client.idm_domain_set_ldap_basedn(new_basedn).await {
Ok(_) => println!("Success"),
Err(e) => eprintln!("{:?}", e),
}
}
DomainOpt::Show(copt) => {
let client = copt.to_client(OpType::Read).await;
match client.idm_domain_get().await {
Ok(e) => println!("{}", e),
Err(e) => error!("Error -> {:?}", e),
}
}
DomainOpt::ResetTokenKey(copt) => {
let client = copt.to_client(OpType::Write).await;
match client.idm_domain_reset_token_key().await {
Ok(_) => println!("Success"),
Err(e) => error!("Error -> {:?}", e),
}
}
}
}
}