github.com/djenriquez/nomad-1@v0.8.1/api/regions.go (about)

     1  package api
     2  
     3  import "sort"
     4  
     5  // Regions is used to query the regions in the cluster.
     6  type Regions struct {
     7  	client *Client
     8  }
     9  
    10  // Regions returns a handle on the regions endpoints.
    11  func (c *Client) Regions() *Regions {
    12  	return &Regions{client: c}
    13  }
    14  
    15  // List returns a list of all of the regions.
    16  func (r *Regions) List() ([]string, error) {
    17  	var resp []string
    18  	if _, err := r.client.query("/v1/regions", &resp, nil); err != nil {
    19  		return nil, err
    20  	}
    21  	sort.Strings(resp)
    22  	return resp, nil
    23  }