-
-
Notifications
You must be signed in to change notification settings - Fork 977
/
types.go
107 lines (80 loc) · 2.12 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
package internal
import (
"fmt"
"strconv"
)
// ClientError a detailed error.
type ClientError struct {
errors []Error
StatusCode int
message string
}
func (f ClientError) Error() string {
msg := strconv.Itoa(f.StatusCode) + ": "
if f.message != "" {
msg += f.message + ": "
}
for i, e := range f.errors {
if i != 0 {
msg += ", "
}
msg += e.Error()
}
return msg
}
func (f ClientError) Unwrap() error {
if len(f.errors) == 0 {
return nil
}
return &f.errors[0]
}
// Error defines model for error.
type Error struct {
// The error code.
Code string `json:"code,omitempty"`
// The error message.
Message string `json:"message,omitempty"`
}
func (e Error) Error() string {
return fmt.Sprintf("%s: %s", e.Code, e.Message)
}
// Zone defines model for zone.
type Zone struct {
// The zone id.
ID string `json:"id,omitempty"`
// The zone name.
Name string `json:"name,omitempty"`
// Represents the possible zone types.
Type string `json:"type,omitempty"`
}
// CustomerZone defines model for customer-zone.
type CustomerZone struct {
// The zone id.
ID string `json:"id,omitempty"`
// The zone name
Name string `json:"name,omitempty"`
Records []Record `json:"records,omitempty"`
// Represents the possible zone types.
Type string `json:"type,omitempty"`
}
// Record defines model for record.
type Record struct {
ID string `json:"id,omitempty"`
Name string `json:"name,omitempty"`
Content string `json:"content,omitempty"`
// Time to live for the record, recommended 3600.
TTL int `json:"ttl,omitempty"`
// Holds supported dns record types.
Type string `json:"type,omitempty"`
Priority int `json:"prio,omitempty"`
// When is true, the record is not visible for lookup.
Disabled bool `json:"disabled,omitempty"`
}
type RecordsFilter struct {
// The FQDN used to filter all the record names that end with it.
Suffix string `url:"suffix,omitempty"`
// The record names that should be included (same as name field of Record)
RecordName string `url:"recordName,omitempty"`
// A comma-separated list of record types that should be included
RecordType string `url:"recordType,omitempty"`
}