-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathdomainDns.go
81 lines (68 loc) · 2.14 KB
/
domainDns.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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
package aftermarketpl
type domainNameRequest struct {
Name string `url:"name"`
}
type domainDNSListResponse struct {
Data []DomainDNSListEntry `json:"data"`
}
//DomainDNSListEntry represents DNS entry
type DomainDNSListEntry struct {
Name string `json:"name"`
Value string `json:"value"`
EntryID int `json:"entryId"`
Type string `json:"type"`
}
// DomainDNSList returns the list of domain DNS entries.
func (a *Aftermarketpl) DomainDNSList(name string) ([]DomainDNSListEntry, error) {
d := domainDNSListResponse{}
err := a.Do("/domain/dns/list", domainNameRequest{Name: name}, &d)
return d.Data, err
}
type domainDNSListCountResponse struct {
Data int `json:"data"`
}
// DomainDNSListCount returns the number of domain DNS entries.
func (a *Aftermarketpl) DomainDNSListCount(name string) (int, error) {
d := domainDNSListCountResponse{}
err := a.Do("/domain/dns/list/count", domainNameRequest{Name: name}, &d)
return d.Data, err
}
type domainDNSRemoveRequest struct {
EntryID int `url:"entryId"`
Name string `url:"name"`
}
type domainDNSRemoveResponse struct {
Data bool `json:"data"`
}
//DomainDNSRemove Remove DNS entry for domain.
func (a *Aftermarketpl) DomainDNSRemove(name string, entryID int) (bool, error) {
request := domainDNSRemoveRequest{Name: name, EntryID: entryID}
d := domainDNSRemoveResponse{}
err := a.Do("/domain/dns/remove", request, &d)
return d.Data, err
}
const (
RecordTypeA string = "A"
RecordTypeAAAA string = "AAAA"
RecordTypeCNAME string = "CNAME"
RecordTypeMX string = "MX"
RecordTypeTXT string = "TXT"
RecordTypeNS string = "NS"
RecordTypeCAA string = "CAA"
RecordTypeSRV string = "SRV"
)
type domainDNSAddRequest struct {
Name string `url:"name"`
Value string `url:"value"`
RecordType string `url:"type"`
}
type domainDNSAddResponse struct {
Data int `json:"data"`
}
//DomainDNSAdd adds new DNS entry for domain
func (a *Aftermarketpl) DomainDNSAdd(name, value, recordType string) (int, error) {
request := domainDNSAddRequest{Name: name, Value: value, RecordType: recordType}
d := domainDNSAddResponse{}
err := a.Do("/domain/dns/add", request, &d)
return d.Data, err
}