Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add set-role-description option in zms-cli #2255

Merged
merged 1 commit into from
Jul 25, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions libs/go/zmscli/cli.go
Original file line number Diff line number Diff line change
Expand Up @@ -1031,6 +1031,10 @@ func (cli Zms) EvalCommand(params []string) (*string, error) {
if argc == 2 {
return cli.SetRoleTokenSignAlgorithm(dn, args[0], args[1])
}
case "set-role-description":
if argc == 2 {
return cli.SetRoleDescription(dn, args[0], args[1])
}
case "set-role-notify-roles":
if argc == 2 {
return cli.SetRoleNotifyRoles(dn, args[0], args[1])
Expand Down Expand Up @@ -2814,6 +2818,17 @@ func (cli Zms) HelpSpecificCommand(interactive bool, cmd string) string {
buf.WriteString(" alg : either rsa or ec: token algorithm to be used for signing\n")
buf.WriteString(" examples:\n")
buf.WriteString(" " + domainExample + " set-role-token-sign-algorithm writers rsa\n")
case "set-role-description":
buf.WriteString(" syntax:\n")
buf.WriteString(" " + domainParam + " set-role-description role \"description\"\n")
buf.WriteString(" parameters:\n")
if !interactive {
buf.WriteString(" domain : name of the domain being updated\n")
}
buf.WriteString(" role : name of the role to be modified\n")
buf.WriteString(" description : role description\n")
buf.WriteString(" examples:\n")
buf.WriteString(" " + domainExample + " set-role-description writers \"contains our hockey writers\"\n")
case "set-role-notify-roles":
buf.WriteString(" syntax:\n")
buf.WriteString(" " + domainParam + " set-role-notify-roles role rolename[,rolename...]]\n")
Expand Down Expand Up @@ -3260,6 +3275,7 @@ func (cli Zms) HelpListCommand() string {
buf.WriteString(" set-role-notify-roles regular_role rolename[,rolename...]\n")
buf.WriteString(" set-role-user-authority-filter regular_role attribute[,attribute...]\n")
buf.WriteString(" set-role-user-authority-expiration regular_role attribute\n")
buf.WriteString(" set-role-description regular_role description\n")
buf.WriteString(" add-role-tag regular_role tag_key tag_value [tag_value ...]\n")
buf.WriteString(" delete-role-tag regular_role tag_key [tag_value]\n")
buf.WriteString(" put-membership-decision regular_role user_or_service [expiration] decision\n")
Expand Down
21 changes: 21 additions & 0 deletions libs/go/zmscli/role.go
Original file line number Diff line number Diff line change
Expand Up @@ -821,6 +821,27 @@ func (cli Zms) SetRoleTokenSignAlgorithm(dn string, rn string, alg string) (*str
return cli.dumpByFormat(message, cli.buildYAMLOutput)
}

func (cli Zms) SetRoleDescription(dn string, rn string, description string) (*string, error) {
role, err := cli.Zms.GetRole(zms.DomainName(dn), zms.EntityName(rn), nil, nil, nil)
if err != nil {
return nil, err
}
meta := getRoleMetaObject(role)
meta.Description = description

err = cli.Zms.PutRoleMeta(zms.DomainName(dn), zms.EntityName(rn), cli.AuditRef, &meta)
if err != nil {
return nil, err
}
s := "[domain " + dn + " role " + rn + " description attribute successfully updated]\n"
message := SuccessMessage{
Status: 200,
Message: s,
}

return cli.dumpByFormat(message, cli.buildYAMLOutput)
}

func (cli Zms) SetRoleNotifyRoles(dn string, rn string, notifyRoles string) (*string, error) {
role, err := cli.Zms.GetRole(zms.DomainName(dn), zms.EntityName(rn), nil, nil, nil)
if err != nil {
Expand Down