/
types.go
183 lines (133 loc) · 3.79 KB
/
types.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
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
package internal
import (
"encoding/xml"
"fmt"
)
// Response status.
const (
StatusOK = "ok"
StatusError = "error"
)
// Request.
type RequestPacketType struct {
XMLName xml.Name `xml:"packet"`
Text string `xml:",chardata"`
DNS *DNSInputType `xml:"dns,omitempty"`
Site *SiteTypeRequest `xml:"site,omitempty"`
}
type DNSInputType struct {
Text string `xml:",chardata"`
AddRec []AddRecRequest `xml:"add_rec,omitempty"`
DelRec []DelRecRequest `xml:"del_rec,omitempty"`
}
type AddRecRequest struct {
Text string `xml:",chardata"`
SiteID int `xml:"site-id,omitempty"`
Type string `xml:"type,omitempty"`
Host string `xml:"host,omitempty"`
Value string `xml:"value,omitempty"`
}
type DelRecRequest struct {
Text string `xml:",chardata"`
Filter DNSSelectionFilterType `xml:"filter"`
}
type DNSSelectionFilterType struct {
Text string `xml:",chardata"`
ID int `xml:"id"`
}
type SiteTypeRequest struct {
Text string `xml:",chardata"`
Get SiteGetRequest `xml:"get"`
}
type SiteGetRequest struct {
Text string `xml:",chardata"`
Filter *SiteFilterType `xml:"filter,omitempty"`
Dataset SiteDatasetType `xml:"dataset,omitempty"`
}
type SiteFilterType struct {
Text string `xml:",chardata"`
Name string `xml:"name"`
}
type SiteDatasetType struct {
Text string `xml:",chardata"`
GenInfo *SiteGenInfoType `xml:"gen_info,omitempty"`
}
type SiteGenInfoType struct {
Text string `xml:",chardata"`
CrDate string `xml:"cr_date,omitempty"`
Name string `xml:"name,omitempty"`
ASCIIName string `xml:"ascii-name,omitempty"`
Status string `xml:"status,omitempty"`
RealSize string `xml:"real_size,omitempty"`
DNSIPAddress string `xml:"dns_ip_address,omitempty"`
HType string `xml:"htype,omitempty"`
GUID string `xml:"guid,omitempty"`
WebspaceGUID string `xml:"webspace-guid,omitempty"`
SbSiteUUID string `xml:"sb-site-uuid,omitempty"`
WebspaceID string `xml:"webspace-id,omitempty"`
Description string `xml:"description,omitempty"`
}
// Response.
type ResponsePacketType struct {
XMLName xml.Name `xml:"packet"`
Text string `xml:",chardata"`
DNS DNSResponseType `xml:"dns,omitempty"`
Site SiteResponseType `xml:"site,omitempty"`
System *System `xml:"system,omitempty"`
}
type System struct {
Text string `xml:",chardata"`
Status string `xml:"status"`
ErrCode string `xml:"errcode"`
ErrText string `xml:"errtext"`
}
func (s System) Error() string {
return fmt.Sprintf("%s: %s - %s", s.Status, s.ErrCode, s.ErrText)
}
type DNSResponseType struct {
Text string `xml:",chardata"`
AddRec []AddRecResponse `xml:"add_rec,omitempty"`
DelRec []DelRecResponse `xml:"del_rec,omitempty"`
}
type AddRecResponse struct {
Text string `xml:",chardata"`
Result RecResult `xml:"result,omitempty"`
}
type DelRecResponse struct {
Text string `xml:",chardata"`
Result RecResult `xml:"result"`
}
type RecResult struct {
Text string `xml:",chardata"`
ID int `xml:"id"`
Status string `xml:"status"`
ErrCode string `xml:"errcode"`
ErrText string `xml:"errtext"`
}
func (r RecResult) Error() string {
return fmt.Sprintf("%s: %s - %s", r.Status, r.ErrCode, r.ErrText)
}
type SiteResponseType struct {
Text string `xml:",chardata"`
Get SiteGetResponse `xml:"get"`
}
type SiteGetResponse struct {
Text string `xml:",chardata"`
Result *SiteResult `xml:"result,omitempty"`
}
type SiteResult struct {
Text string `xml:",chardata"`
ID int `xml:"id"`
FilterID string `xml:"filter-id"`
Status string `xml:"status"`
ErrCode string `xml:"errcode"`
ErrText string `xml:"errtext"`
Data *SiteResultData `xml:"data"`
}
func (s SiteResult) Error() string {
return fmt.Sprintf("%s: %s - %s", s.Status, s.ErrCode, s.ErrText)
}
type SiteResultData struct {
Text string `xml:",chardata"`
GenInfo *SiteGenInfoType `xml:"gen_info"`
}