(ctx context.Context)
| 203 | } |
| 204 | |
| 205 | func (c *Client) Regions(ctx context.Context) ([]Region, error) { |
| 206 | res, err := c.Request(ctx, http.MethodGet, |
| 207 | "/api/v2/regions", |
| 208 | nil, |
| 209 | ) |
| 210 | if err != nil { |
| 211 | return nil, xerrors.Errorf("make request: %w", err) |
| 212 | } |
| 213 | defer res.Body.Close() |
| 214 | |
| 215 | if res.StatusCode != http.StatusOK { |
| 216 | return nil, ReadBodyAsError(res) |
| 217 | } |
| 218 | |
| 219 | var regions RegionsResponse[Region] |
| 220 | return regions.Regions, json.NewDecoder(res.Body).Decode(®ions) |
| 221 | } |