Skip to content

Commit

Permalink
Added role CRUD operations
Browse files Browse the repository at this point in the history
  • Loading branch information
SivaanandM committed Nov 13, 2024
1 parent a5e8725 commit 58866fb
Showing 1 changed file with 34 additions and 0 deletions.
34 changes: 34 additions & 0 deletions client/role.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,3 +39,37 @@ func (h *V1Client) GetRoleByID(roleUID string) (*models.V1Role, error) {

return resp.Payload, nil
}

// CreateRole create new role.
func (h *V1Client) CreateRole(role *models.V1Role) (string, error) {
// ACL scoped to tenant only
params := clientv1.NewV1RolesCreateParams().WithBody(role)
resp, err := h.Client.V1RolesCreate(params)
if err != nil {
return "", err
}

return *resp.Payload.UID, nil
}

// UpdateRole Update existing role with ID
func (h *V1Client) UpdateRole(role *models.V1Role, roleUID string) error {
// ACL scoped to tenant only
params := clientv1.NewV1RolesUIDUpdateParams().WithBody(role).WithUID(roleUID)
_, err := h.Client.V1RolesUIDUpdate(params)
if err != nil {
return err
}
return nil
}

// DeleteRole Delete existing role with ID
func (h *V1Client) DeleteRole(roleUID string) error {
// ACL scoped to tenant only
params := clientv1.NewV1RolesUIDDeleteParams().WithUID(roleUID)
_, err := h.Client.V1RolesUIDDelete(params)
if err != nil {
return err
}
return nil
}

0 comments on commit 58866fb

Please sign in to comment.