Replicas fetches the list of replicas.
(ctx context.Context)
| 29 | |
| 30 | // Replicas fetches the list of replicas. |
| 31 | func (c *Client) Replicas(ctx context.Context) ([]Replica, error) { |
| 32 | res, err := c.Request(ctx, http.MethodGet, "/api/v2/replicas", nil) |
| 33 | if err != nil { |
| 34 | return nil, xerrors.Errorf("execute request: %w", err) |
| 35 | } |
| 36 | defer res.Body.Close() |
| 37 | |
| 38 | if res.StatusCode != http.StatusOK { |
| 39 | return nil, ReadBodyAsError(res) |
| 40 | } |
| 41 | |
| 42 | var replicas []Replica |
| 43 | return replicas, json.NewDecoder(res.Body).Decode(&replicas) |
| 44 | } |