Expose group rename (#2999)

* feat(cli): add group rename
This commit is contained in:
Firstyear 2024-08-23 16:18:29 +10:00 committed by GitHub
parent 87b20d22d1
commit 2ea8a0ed88
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 30 additions and 1 deletions

View file

@ -20,6 +20,11 @@ impl KanidmClient {
.await
}
pub async fn group_rename(&self, name: &str, new_name: &str) -> Result<(), ClientError> {
self.perform_put_request(&format!("/v1/group/{}/_attr/name", name), vec![new_name])
.await
}
pub async fn group_account_policy_authsession_expiry_set(
&self,
id: &str,

View file

@ -16,7 +16,7 @@ impl GroupOpt {
GroupOpt::RemoveMembers(gcopt) => gcopt.copt.debug,
GroupOpt::SetMembers(gcopt) => gcopt.copt.debug,
GroupOpt::PurgeMembers(gcopt) => gcopt.copt.debug,
GroupOpt::SetMail { copt, .. } => copt.debug,
GroupOpt::Rename { copt, .. } | GroupOpt::SetMail { copt, .. } => copt.debug,
GroupOpt::Posix { commands } => match commands {
GroupPosix::Show(gcopt) => gcopt.copt.debug,
GroupPosix::Set(gcopt) => gcopt.copt.debug,
@ -178,6 +178,20 @@ impl GroupOpt {
Ok(_) => println!("Successfully set mail for group {}", name.as_str()),
}
}
GroupOpt::Rename {
copt,
name,
new_name,
} => {
let client = copt.to_client(OpType::Write).await;
let result = client.group_rename(name.as_str(), new_name.as_str()).await;
match result {
Err(e) => handle_client_error(e, copt.output_mode),
Ok(_) => println!("Successfully renamed group {} to {}", name, new_name),
}
}
GroupOpt::SetEntryManagedBy {
name,
entry_managed_by,

View file

@ -284,6 +284,16 @@ pub enum GroupOpt {
#[clap(flatten)]
copt: CommonOpt,
},
/// Rename an existing group
#[clap(name = "rename")]
Rename {
/// The name of the group
name: String,
/// The new name of the group
new_name: String,
#[clap(flatten)]
copt: CommonOpt,
},
/// Delete all members of a group.
#[clap(name = "purge-members")]
PurgeMembers(Named),