-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdomains.go
59 lines (53 loc) · 1.54 KB
/
domains.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
51
52
53
54
55
56
57
58
59
package entrust
import (
"encoding/json"
"fmt"
"net/http"
"net/url"
"time"
)
// GetDomains lists domains based on a filter
func (c *Client) GetDomains(offset, limit int, expiry *time.Time) (*GetDomainsResponse, error) {
v := url.Values{}
v.Set("sort", "domainName:asc")
v.Set("offset", fmt.Sprintf("%d", offset))
v.Set("limit", fmt.Sprintf("%d", limit))
if expiry != nil {
v.Set("ovExpiry", fmt.Sprintf("lt:%s", expiry.Format(time.RFC3339)))
}
resp, err := c.exchange(fmt.Sprintf("/domains?%s", v.Encode()), http.MethodGet, nil)
if err != nil {
return nil, err
}
var domainsResponse *GetDomainsResponse
err = json.Unmarshal(resp, &domainsResponse)
if err != nil {
return nil, err
}
return domainsResponse, nil
}
// GetDomain requests information about a domain in the account
// GET /clients/{clientId}/domains/{domain}
func (c *Client) GetDomain(clientID int, domain string) (*Domain, error) {
resp, err := c.exchange(fmt.Sprintf("/clients/%d/domains/%s ", clientID, domain), http.MethodGet, nil)
if err != nil {
return nil, err
}
var domainResponse *Domain
err = json.Unmarshal(resp, &domainResponse)
if err != nil {
return nil, err
}
return domainResponse, nil
}
// ReverifyDomain sends a domain for reverification.
// PUT /clients/{clientId}/domains/{domain}
func (c *Client) ReverifyDomain(clientID int, domain string) error {
_, err := c.exchange(fmt.Sprintf("/clients/%d/domains/%s ", clientID, domain), http.MethodPut, ReverifyDomainRequest{
VerificationMethod: "DNS",
})
if err != nil {
return err
}
return nil
}