ListOrganizationRoles lists all assignable roles for a given organization.
(ctx context.Context, org uuid.UUID)
| 164 | |
| 165 | // ListOrganizationRoles lists all assignable roles for a given organization. |
| 166 | func (c *Client) ListOrganizationRoles(ctx context.Context, org uuid.UUID) ([]AssignableRoles, error) { |
| 167 | res, err := c.Request(ctx, http.MethodGet, fmt.Sprintf("/api/v2/organizations/%s/members/roles", org.String()), nil) |
| 168 | if err != nil { |
| 169 | return nil, err |
| 170 | } |
| 171 | defer res.Body.Close() |
| 172 | if res.StatusCode != http.StatusOK { |
| 173 | return nil, ReadBodyAsError(res) |
| 174 | } |
| 175 | var roles []AssignableRoles |
| 176 | return roles, json.NewDecoder(res.Body).Decode(&roles) |
| 177 | } |
| 178 | |
| 179 | // CreatePermissions is a helper function to quickly build permissions. |
| 180 | func CreatePermissions(mapping map[RBACResource][]RBACAction) []Permission { |