| 248 | } |
| 249 | |
| 250 | func (c *Client) OrganizationByName(ctx context.Context, name string) (Organization, error) { |
| 251 | res, err := c.Request(ctx, http.MethodGet, fmt.Sprintf("/api/v2/organizations/%s", name), nil) |
| 252 | if err != nil { |
| 253 | return Organization{}, xerrors.Errorf("execute request: %w", err) |
| 254 | } |
| 255 | defer res.Body.Close() |
| 256 | |
| 257 | if res.StatusCode != http.StatusOK { |
| 258 | return Organization{}, ReadBodyAsError(res) |
| 259 | } |
| 260 | |
| 261 | var organization Organization |
| 262 | return organization, json.NewDecoder(res.Body).Decode(&organization) |
| 263 | } |
| 264 | |
| 265 | func (c *Client) Organizations(ctx context.Context) ([]Organization, error) { |
| 266 | res, err := c.Request(ctx, http.MethodGet, "/api/v2/organizations", nil) |