-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathapi_dns.go
113 lines (93 loc) · 2.75 KB
/
api_dns.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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
package sdk
import "fmt"
// Kubernetes :
type Kubernetes struct {
Cluster string `json:"cluster"`
Service string `json:"service"`
Namespace string `json:"namespace"`
Port int `json:"port"`
}
// RequestCreateDNSRecord :
type RequestCreateDNSRecord struct {
RootDomain string `json:"rootDomain"`
SubDomainName string `json:"subDomainName"`
IP string `json:"ip"`
Kubernetes Kubernetes `json:"kubernetes"`
}
// ResponseCreateDNSRecord :
type ResponseCreateDNSRecord struct {
Item struct {
Type string `json:"type"`
Name string `json:"name"`
IP string `json:"ip"`
Proxy bool `json:"proxy"`
} `json:"item"`
Code string `json:"code"`
Err *Error `json:"error"`
}
// CreateDNSRecord :
func (c Client) CreateDNSRecord(request RequestCreateDNSRecord) (*ResponseCreateDNSRecord, error) {
if c.err != nil {
return nil, c.err
}
method := pathCreateDNSRecordURL.method
requestURL := c.prepareAPIURL(pathCreateDNSRecordURL)
response := new(ResponseCreateDNSRecord)
if err := c.httpAPI(method, requestURL, request, response); err != nil {
return nil, err
}
return response, nil
}
// RequestGetDNSRecords :
type RequestGetDNSRecords struct {
RootDomain string `json:"rootDomain"`
SubDomainName string `json:"subDomainName"`
}
// ResponseGetDNSRecords :
type ResponseGetDNSRecords struct {
Items []struct {
Type string `json:"type"`
Name string `json:"name"`
IP string `json:"ip"`
Proxy bool `json:"proxy"`
} `json:"items"`
Code string `json:"code"`
Err *Error `json:"error"`
}
// GetDNSRecords :
func (c Client) GetDNSRecords(rootDomain, subDomainName string) (*ResponseGetDNSRecords, error) {
if c.err != nil {
return nil, c.err
}
method := pathGetDNSRecordsURL.method
requestURL := c.prepareAPIURL(pathGetDNSRecordsURL) + fmt.Sprintf("?rootDomain=%s&subDomainName=%s", rootDomain, subDomainName)
response := new(ResponseGetDNSRecords)
if err := c.httpAPI(method, requestURL, nil, response); err != nil {
return nil, err
}
return response, nil
}
// RequestDeleteDNSRecord :
type RequestDeleteDNSRecord struct {
RootDomain string `json:"rootDomain"`
SubDomainName string `json:"subDomainName"`
Kubernetes Kubernetes `json:"kubernetes"`
}
// ResponseDeleteDNSRecord :
type ResponseDeleteDNSRecord struct {
Code string `json:"code"`
Err *Error `json:"error"`
}
// DeleteDNSRecord :
func (c Client) DeleteDNSRecord(request RequestDeleteDNSRecord) (*ResponseDeleteDNSRecord, error) {
if c.err != nil {
return nil, c.err
}
method := pathDeleteDNSRecordURL.method
requestURL := c.prepareAPIURL(pathDeleteDNSRecordURL)
response := new(ResponseDeleteDNSRecord)
if err := c.httpAPI(method, requestURL, request, response); err != nil {
return nil, err
}
return response, nil
}