-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathdns-provider.go
More file actions
43 lines (38 loc) · 909 Bytes
/
dns-provider.go
File metadata and controls
43 lines (38 loc) · 909 Bytes
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
package cloud66
import (
"strconv"
"time"
)
type DnsProvider struct {
Uuid string `json:"uuid"`
DisplayName string `json:"display_name"`
Type string `json:"type"`
Key string `json:"key"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
}
func (c *Client) ListDnsProviders() ([]DnsProvider, error) {
queryStrings := make(map[string]string)
queryStrings["page"] = "1"
var p Pagination
var result []DnsProvider
var pageResult []DnsProvider
for {
req, err := c.NewRequest("GET", "/dns_providers.json", nil, queryStrings)
if err != nil {
return nil, err
}
pageResult = nil
err = c.DoReq(req, &pageResult, &p)
if err != nil {
return nil, err
}
result = append(result, pageResult...)
if p.Current < p.Next {
queryStrings["page"] = strconv.Itoa(p.Next)
} else {
break
}
}
return result, nil
}