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

Method OrganizationsByUser

codersdk/users.go:1049–1060  ·  view source on GitHub ↗

OrganizationsByUser returns all organizations the user is a member of.

(ctx context.Context, user string)

Source from the content-addressed store, hash-verified

1047
1048// OrganizationsByUser returns all organizations the user is a member of.
1049func (c *Client) OrganizationsByUser(ctx context.Context, user string) ([]Organization, error) {
1050 res, err := c.Request(ctx, http.MethodGet, fmt.Sprintf("/api/v2/users/%s/organizations", user), nil)
1051 if err != nil {
1052 return nil, err
1053 }
1054 defer res.Body.Close()
1055 if res.StatusCode > http.StatusOK {
1056 return nil, ReadBodyAsError(res)
1057 }
1058 var orgs []Organization
1059 return orgs, json.NewDecoder(res.Body).Decode(&orgs)
1060}
1061
1062func (c *Client) OrganizationByUserAndName(ctx context.Context, user string, name string) (Organization, error) {
1063 res, err := c.Request(ctx, http.MethodGet, fmt.Sprintf("/api/v2/users/%s/organizations/%s", user, name), nil)

Callers 8

showOrganizationMethod · 0.80
SelectedMethod · 0.80
resolveTemplateIDFunction · 0.80
AssertOrganizationsMethod · 0.80
TestEnterprisePostUserFunction · 0.80
TestMultiOrgFetchFunction · 0.80
TestOrganizationsByUserFunction · 0.80

Calls 3

RequestMethod · 0.95
ReadBodyAsErrorFunction · 0.85
CloseMethod · 0.65

Tested by 5

AssertOrganizationsMethod · 0.64
TestEnterprisePostUserFunction · 0.64
TestMultiOrgFetchFunction · 0.64
TestOrganizationsByUserFunction · 0.64