/
model_record.go
57 lines (43 loc) · 1.17 KB
/
model_record.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
/*
* PiHole Management API
*
* A management webservice to be run locally on a PiHole instance
*
* API version: 1.0
* Generated by: OpenAPI Generator (https://openapi-generator.tech)
*/
package openapi
import (
"encoding/json"
)
type Record struct {
// CNAME or A
Type string `json:"type"`
// The domain to resolve
Domain string `json:"domain"`
// The destination IP or DNS record
Destination string `json:"destination"`
}
// UnmarshalJSON sets *m to a copy of data while respecting defaults if specified.
func (m *Record) UnmarshalJSON(data []byte) error {
type Alias Record // To avoid infinite recursion
return json.Unmarshal(data, (*Alias)(m))
}
// AssertRecordRequired checks if the required fields are not zero-ed
func AssertRecordRequired(obj Record) error {
elements := map[string]interface{}{
"type": obj.Type,
"domain": obj.Domain,
"destination": obj.Destination,
}
for name, el := range elements {
if isZero := IsZeroValue(el); isZero {
return &RequiredError{Field: name}
}
}
return nil
}
// AssertRecordConstraints checks if the values respects the defined constraints
func AssertRecordConstraints(obj Record) error {
return nil
}