| 263 | } |
| 264 | |
| 265 | func (c *Client) Organizations(ctx context.Context) ([]Organization, error) { |
| 266 | res, err := c.Request(ctx, http.MethodGet, "/api/v2/organizations", nil) |
| 267 | if err != nil { |
| 268 | return []Organization{}, xerrors.Errorf("execute request: %w", err) |
| 269 | } |
| 270 | defer res.Body.Close() |
| 271 | |
| 272 | if res.StatusCode != http.StatusOK { |
| 273 | return []Organization{}, ReadBodyAsError(res) |
| 274 | } |
| 275 | |
| 276 | var organizations []Organization |
| 277 | return organizations, json.NewDecoder(res.Body).Decode(&organizations) |
| 278 | } |
| 279 | |
| 280 | func (c *Client) Organization(ctx context.Context, id uuid.UUID) (Organization, error) { |
| 281 | // OrganizationByName uses the exact same endpoint. It accepts a name or uuid. |