Skip to content

Commit

Permalink
add set-role-description option in zms-cli (#2255)
Browse files Browse the repository at this point in the history
Signed-off-by: Henry Avetisyan <[email protected]>
Co-authored-by: Henry Avetisyan <[email protected]>
  • Loading branch information
havetisyan and havetisyan authored Jul 25, 2023
1 parent 60c48df commit d2891ba
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 0 deletions.
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

0 comments on commit d2891ba

Please sign in to comment.