github.com/anuvu/nomad@v0.8.7-atom1/command/agent/region_endpoint.go (about)

     1  package agent
     2  
     3  import (
     4  	"net/http"
     5  
     6  	"github.com/hashicorp/nomad/nomad/structs"
     7  )
     8  
     9  func (s *HTTPServer) RegionListRequest(resp http.ResponseWriter, req *http.Request) (interface{}, error) {
    10  	if req.Method != "GET" {
    11  		return nil, CodedError(405, ErrInvalidMethod)
    12  	}
    13  
    14  	var args structs.GenericRequest
    15  	if s.parse(resp, req, &args.Region, &args.QueryOptions) {
    16  		return nil, nil
    17  	}
    18  
    19  	var regions []string
    20  	if err := s.agent.RPC("Region.List", &args, &regions); err != nil {
    21  		return nil, err
    22  	}
    23  	return regions, nil
    24  }