github.com/emate/nomad@v0.8.2-wo-binpacking/api/search.go (about) 1 package api 2 3 import ( 4 "github.com/hashicorp/nomad/api/contexts" 5 ) 6 7 type Search struct { 8 client *Client 9 } 10 11 // Search returns a handle on the Search endpoints 12 func (c *Client) Search() *Search { 13 return &Search{client: c} 14 } 15 16 // PrefixSearch returns a list of matches for a particular context and prefix. 17 func (s *Search) PrefixSearch(prefix string, context contexts.Context, q *QueryOptions) (*SearchResponse, *QueryMeta, error) { 18 var resp SearchResponse 19 req := &SearchRequest{Prefix: prefix, Context: context} 20 21 qm, err := s.client.putQuery("/v1/search", req, &resp, q) 22 if err != nil { 23 return nil, nil, err 24 } 25 26 return &resp, qm, nil 27 } 28 29 type SearchRequest struct { 30 Prefix string 31 Context contexts.Context 32 QueryOptions 33 } 34 35 type SearchResponse struct { 36 Matches map[contexts.Context][]string 37 Truncations map[contexts.Context]bool 38 QueryMeta 39 }