MCPcopy Index your code
hub / github.com/coder/coder / assignableOrgRoles

Method assignableOrgRoles

coderd/roles.go:62–85  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

60// @Success 200 {array} codersdk.AssignableRoles
61// @Router /api/v2/organizations/{organization}/members/roles [get]
62func (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
87func assignableRoles(actorRoles rbac.ExpandableRoles, roles []rbac.Role, customRoles []database.CustomRole) []codersdk.AssignableRoles {
88 assignable := make([]codersdk.AssignableRoles, 0)

Callers

nothing calls this directly

Calls 11

AuthorizeMethod · 0.95
OrganizationParamFunction · 0.92
UserAuthorizationFunction · 0.92
ResourceNotFoundFunction · 0.92
OrganizationRolesFunction · 0.92
InternalServerErrorFunction · 0.92
WriteFunction · 0.92
assignableRolesFunction · 0.85
InOrgMethod · 0.80
ContextMethod · 0.65
CustomRolesMethod · 0.65

Tested by

no test coverage detected