OrganizationsByUser returns all organizations the user is a member of.
(ctx context.Context, user string)
| 1047 | |
| 1048 | // OrganizationsByUser returns all organizations the user is a member of. |
| 1049 | func (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 | |
| 1062 | func (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) |