-
Notifications
You must be signed in to change notification settings - Fork 2
/
types.go
68 lines (56 loc) · 1.45 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
package hcdns
import (
"fmt"
"strings"
"time"
)
type root struct {
Zones []Zone `json:"zones"`
Zone Zone `json:"zone"`
Records []Record `json:"records"`
Record Record `json:"record"`
PrimaryServers []PrimaryServer `json:"primary_servers"`
PrimaryServer PrimaryServer `json:"primary_server"`
Meta struct {
Pagination pagination `json:"pagination"`
} `json:"meta"`
Error err `json:"error"`
}
type pagination struct {
Page uint `json:"page"`
PerPage uint `json:"per_page"`
PreviousPage uint `json:"previous_page"`
NextPage uint `json:"next_page"`
LastPage uint `json:"last_page"`
TotalEntries uint `json:"total_entries"`
}
type err struct {
Message string `json:"message"`
Code int `json:"code"`
}
type Time struct {
inner *time.Time
}
func (t *Time) UnmarshalJSON(b []byte) error {
value := strings.ReplaceAll(string(b), `"`, "")
if value == "" {
return nil
}
tt, err := time.Parse("2006-01-02 15:04:05.999 -0700 MST", value)
if err != nil {
return fmt.Errorf("parse time: %w", err)
}
t.inner = &tt
return nil
}
func (t Time) String() string {
return t.inner.Format(time.RFC3339)
}
type PrimaryServer struct {
Port int `json:"port"`
ID string `json:"id"`
Created time.Time `json:"created"`
Modified time.Time `json:"modified"`
ZoneID string `json:"zone_id"`
Address string `json:"address"`
}