/
search.go
50 lines (38 loc) · 1.12 KB
/
search.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
package rest
import (
"fmt"
"net/http"
"gopkg.in/ns1/ns1-go.v2/rest/model/dns"
)
// RecordSearchService handles 'dns/record/search' endpoint.
type RecordSearchService service
// Find takes query parameters and returns matching DNS records.
func (s *RecordSearchService) Search(params string) (*dns.SearchResult, *http.Response, error) {
path := fmt.Sprintf("dns/record/search?%s", params)
req, err := s.client.NewRequest("GET", path, nil)
if err != nil {
return nil, nil, err
}
var r dns.SearchResult
resp, err := s.client.Do(req, &r)
if err != nil {
return nil, resp, err
}
return &r, resp, nil
}
// ZoneSearchService handles 'dns/zone/search' endpoint.
type ZoneSearchService service
// Find takes query parameters and returns matching DNS zones.
func (s *ZoneSearchService) Search(params string) (*dns.SearchResult, *http.Response, error) {
path := fmt.Sprintf("dns/zone/search?%s", params)
req, err := s.client.NewRequest("GET", path, nil)
if err != nil {
return nil, nil, err
}
var r dns.SearchResult
resp, err := s.client.Do(req, &r)
if err != nil {
return nil, resp, err
}
return &r, resp, nil
}