2015-11-24 21:11:48 +00:00
|
|
|
package api
|
|
|
|
|
|
|
|
import "sort"
|
|
|
|
|
|
|
|
// Regions is used to query the regions in the cluster.
|
|
|
|
type Regions struct {
|
|
|
|
client *Client
|
|
|
|
}
|
|
|
|
|
2017-01-18 06:48:01 +00:00
|
|
|
// Regions returns a handle on the regions endpoints.
|
2015-11-24 21:11:48 +00:00
|
|
|
func (c *Client) Regions() *Regions {
|
|
|
|
return &Regions{client: c}
|
|
|
|
}
|
|
|
|
|
2021-12-15 15:44:03 +00:00
|
|
|
// List returns a list of all of the regions from the server
|
|
|
|
// that serves the request. It is never forwarded to a leader.
|
2015-11-24 21:11:48 +00:00
|
|
|
func (r *Regions) List() ([]string, error) {
|
|
|
|
var resp []string
|
|
|
|
if _, err := r.client.query("/v1/regions", &resp, nil); err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
sort.Strings(resp)
|
|
|
|
return resp, nil
|
|
|
|
}
|