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

Method UserRoles

codersdk/users.go:870–881  ·  view source on GitHub ↗

UserRoles returns all roles the user has

(ctx context.Context, user string)

Source from the content-addressed store, hash-verified

868
869// UserRoles returns all roles the user has
870func (c *Client) UserRoles(ctx context.Context, user string) (UserRoles, error) {
871 res, err := c.Request(ctx, http.MethodGet, fmt.Sprintf("/api/v2/users/%s/roles", user), nil)
872 if err != nil {
873 return UserRoles{}, err
874 }
875 defer res.Body.Close()
876 if res.StatusCode != http.StatusOK {
877 return UserRoles{}, ReadBodyAsError(res)
878 }
879 var roles UserRoles
880 return roles, json.NewDecoder(res.Body).Decode(&roles)
881}
882
883// UserOIDCClaims returns the merged OIDC claims for the authenticated user.
884func (c *Client) UserOIDCClaims(ctx context.Context) (OIDCClaimsResponse, error) {

Callers 3

TestInitialRolesFunction · 0.80
userEditRolesMethod · 0.80
TestUserEditRolesFunction · 0.80

Calls 3

RequestMethod · 0.95
ReadBodyAsErrorFunction · 0.85
CloseMethod · 0.65

Tested by 2

TestInitialRolesFunction · 0.64
TestUserEditRolesFunction · 0.64