forked from go-acme/lego
-
Notifications
You must be signed in to change notification settings - Fork 0
/
types.go
63 lines (52 loc) · 1.4 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
package internal
import "fmt"
type APIResponse struct {
Status string `json:"status"`
Info string `json:"info"`
}
// error
type APIError struct {
APIResponse
AddRecordMessage string `json:"add_record"`
DelRecordMessage string `json:"del_record"`
AddDomainMessage string `json:"add_domain"`
DelDomainMessage string `json:"del_domain"`
}
func (a APIError) Error() string {
msg := a.Info
switch {
case a.AddRecordMessage != "":
msg = a.AddRecordMessage
case a.DelRecordMessage != "":
msg = a.DelRecordMessage
case a.AddDomainMessage != "":
msg = a.AddDomainMessage
case a.DelDomainMessage != "":
msg = a.DelDomainMessage
}
if msg == "" {
return fmt.Sprintf("%s: %s", a.Status, a.Info)
}
return fmt.Sprintf("%s (%s): %s", a.Info, a.Status, msg)
}
// get_domains
type Domains struct {
APIResponse
APICall string `json:"add_domain"`
Subdomains map[string]Subdomain `json:"subdomains"`
}
type Subdomain struct {
Updates int `json:"updates"`
Wildcard int `json:"wildcard"`
DomainUpdateHash string `json:"domain_update_hash"`
Records []Record `json:"records"`
}
type Record struct {
RecordID int `json:"record_id"`
Content string `json:"content"`
TTL int `json:"ttl"`
Type string `json:"type"`
Prefix string `json:"praefix"`
LastUpdate string `json:"last_update"`
RecordKey string `json:"record_key"`
}