assignableOrgRoles returns all org wide roles that can be assigned. @Summary Get member roles by organization @ID get-member-roles-by-organization @Security CoderSessionToken @Produce json @Tags Members @Param organization path string true "Organization ID" format(uuid) @Success 200 {array} codersd
(rw http.ResponseWriter, r *http.Request)
| 60 | // @Success 200 {array} codersdk.AssignableRoles |
| 61 | // @Router /api/v2/organizations/{organization}/members/roles [get] |
| 62 | func (api *API) assignableOrgRoles(rw http.ResponseWriter, r *http.Request) { |
| 63 | ctx := r.Context() |
| 64 | organization := httpmw.OrganizationParam(r) |
| 65 | actorRoles := httpmw.UserAuthorization(r.Context()) |
| 66 | |
| 67 | if !api.Authorize(r, policy.ActionRead, rbac.ResourceAssignOrgRole.InOrg(organization.ID)) { |
| 68 | httpapi.ResourceNotFound(rw) |
| 69 | return |
| 70 | } |
| 71 | |
| 72 | roles := rbac.OrganizationRoles(organization.ID) |
| 73 | dbCustomRoles, err := api.Database.CustomRoles(ctx, database.CustomRolesParams{ |
| 74 | LookupRoles: nil, |
| 75 | ExcludeOrgRoles: false, |
| 76 | OrganizationID: organization.ID, |
| 77 | IncludeSystemRoles: false, |
| 78 | }) |
| 79 | if err != nil { |
| 80 | httpapi.InternalServerError(rw, err) |
| 81 | return |
| 82 | } |
| 83 | |
| 84 | httpapi.Write(ctx, rw, http.StatusOK, assignableRoles(actorRoles.Roles, roles, dbCustomRoles)) |
| 85 | } |
| 86 | |
| 87 | func assignableRoles(actorRoles rbac.ExpandableRoles, roles []rbac.Role, customRoles []database.CustomRole) []codersdk.AssignableRoles { |
| 88 | assignable := make([]codersdk.AssignableRoles, 0) |
nothing calls this directly
no test coverage detected