mirror of
https://github.com/kanidm/kanidm.git
synced 2025-04-19 08:45:39 +02:00
Add set-description to group tooling (#3511)
This commit is contained in:
parent
1e91f244a2
commit
b13951a79b
|
@ -195,4 +195,20 @@ impl KanidmClient {
|
||||||
self.perform_get_request(&format!("/v1/group/{}/_attr/mail", id))
|
self.perform_get_request(&format!("/v1/group/{}/_attr/mail", id))
|
||||||
.await
|
.await
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub async fn idm_group_purge_description(&self, id: &str) -> Result<(), ClientError> {
|
||||||
|
self.idm_group_purge_attr(id, "description").await
|
||||||
|
}
|
||||||
|
|
||||||
|
pub async fn idm_group_set_description(
|
||||||
|
&self,
|
||||||
|
id: &str,
|
||||||
|
description: &str,
|
||||||
|
) -> Result<(), ClientError> {
|
||||||
|
self.perform_put_request(
|
||||||
|
&format!("/v1/group/{}/_attr/description", id),
|
||||||
|
&[description],
|
||||||
|
)
|
||||||
|
.await
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,7 +16,9 @@ impl GroupOpt {
|
||||||
GroupOpt::RemoveMembers(gcopt) => gcopt.copt.debug,
|
GroupOpt::RemoveMembers(gcopt) => gcopt.copt.debug,
|
||||||
GroupOpt::SetMembers(gcopt) => gcopt.copt.debug,
|
GroupOpt::SetMembers(gcopt) => gcopt.copt.debug,
|
||||||
GroupOpt::PurgeMembers(gcopt) => gcopt.copt.debug,
|
GroupOpt::PurgeMembers(gcopt) => gcopt.copt.debug,
|
||||||
GroupOpt::Rename { copt, .. } | GroupOpt::SetMail { copt, .. } => copt.debug,
|
GroupOpt::SetDescription { copt, .. }
|
||||||
|
| GroupOpt::Rename { copt, .. }
|
||||||
|
| GroupOpt::SetMail { copt, .. } => copt.debug,
|
||||||
GroupOpt::Posix { commands } => match commands {
|
GroupOpt::Posix { commands } => match commands {
|
||||||
GroupPosix::Show(gcopt) => gcopt.copt.debug,
|
GroupPosix::Show(gcopt) => gcopt.copt.debug,
|
||||||
GroupPosix::Set(gcopt) => gcopt.copt.debug,
|
GroupPosix::Set(gcopt) => gcopt.copt.debug,
|
||||||
|
@ -178,6 +180,26 @@ impl GroupOpt {
|
||||||
Ok(_) => println!("Successfully set mail for group {}", name.as_str()),
|
Ok(_) => println!("Successfully set mail for group {}", name.as_str()),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
GroupOpt::SetDescription {
|
||||||
|
copt,
|
||||||
|
name,
|
||||||
|
description,
|
||||||
|
} => {
|
||||||
|
let client = copt.to_client(OpType::Write).await;
|
||||||
|
|
||||||
|
let result = if let Some(description) = description {
|
||||||
|
client
|
||||||
|
.idm_group_set_description(name.as_str(), description.as_str())
|
||||||
|
.await
|
||||||
|
} else {
|
||||||
|
client.idm_group_purge_description(name.as_str()).await
|
||||||
|
};
|
||||||
|
|
||||||
|
match result {
|
||||||
|
Err(e) => handle_client_error(e, copt.output_mode),
|
||||||
|
Ok(_) => println!("Successfully set description for group {}", name.as_str()),
|
||||||
|
}
|
||||||
|
}
|
||||||
GroupOpt::Rename {
|
GroupOpt::Rename {
|
||||||
copt,
|
copt,
|
||||||
name,
|
name,
|
||||||
|
|
|
@ -348,6 +348,14 @@ pub enum GroupOpt {
|
||||||
name: String,
|
name: String,
|
||||||
mail: Vec<String>,
|
mail: Vec<String>,
|
||||||
},
|
},
|
||||||
|
/// Set the description of this group. If no description is provided, the value is cleared
|
||||||
|
#[clap(name = "set-description")]
|
||||||
|
SetDescription {
|
||||||
|
#[clap(flatten)]
|
||||||
|
copt: CommonOpt,
|
||||||
|
name: String,
|
||||||
|
description: Option<String>,
|
||||||
|
},
|
||||||
/// Set a new entry-managed-by for this group.
|
/// Set a new entry-managed-by for this group.
|
||||||
#[clap(name = "set-entry-manager")]
|
#[clap(name = "set-entry-manager")]
|
||||||
SetEntryManagedBy {
|
SetEntryManagedBy {
|
||||||
|
|
Loading…
Reference in a new issue