1package internal 2 3import ( 4 "fmt" 5 "strconv" 6) 7 8// ClientError a detailed error. 9type ClientError struct { 10 errors []Error 11 StatusCode int 12 message string 13} 14 15func (f ClientError) Error() string { 16 msg := strconv.Itoa(f.StatusCode) + ": " 17 18 if f.message != "" { 19 msg += f.message + ": " 20 } 21 22 for i, e := range f.errors { 23 if i != 0 { 24 msg += ", " 25 } 26 27 msg += e.Error() 28 } 29 30 return msg 31} 32 33func (f ClientError) Unwrap() error { 34 if len(f.errors) == 0 { 35 return nil 36 } 37 38 return &f.errors[0] 39} 40 41// Error defines model for error. 42type Error struct { 43 // The error code. 44 Code string `json:"code,omitempty"` 45 46 // The error message. 47 Message string `json:"message,omitempty"` 48} 49 50func (e Error) Error() string { 51 return fmt.Sprintf("%s: %s", e.Code, e.Message) 52} 53 54// Zone defines model for zone. 55type Zone struct { 56 // The zone id. 57 ID string `json:"id,omitempty"` 58 59 // The zone name. 60 Name string `json:"name,omitempty"` 61 62 // Represents the possible zone types. 63 Type string `json:"type,omitempty"` 64} 65 66// CustomerZone defines model for customer-zone. 67type CustomerZone struct { 68 // The zone id. 69 ID string `json:"id,omitempty"` 70 71 // The zone name 72 Name string `json:"name,omitempty"` 73 Records []Record `json:"records,omitempty"` 74 75 // Represents the possible zone types. 76 Type string `json:"type,omitempty"` 77} 78 79// Record defines model for record. 80type Record struct { 81 ID string `json:"id,omitempty"` 82 83 Name string `json:"name,omitempty"` 84 Content string `json:"content,omitempty"` 85 86 // Time to live for the record, recommended 3600. 87 TTL int `json:"ttl,omitempty"` 88 89 // Holds supported dns record types. 90 Type string `json:"type,omitempty"` 91 92 Priority int `json:"prio,omitempty"` 93 94 // When is true, the record is not visible for lookup. 95 Disabled bool `json:"disabled,omitempty"` 96} 97 98type RecordsFilter struct { 99 // The FQDN used to filter all the record names that end with it. 100 Suffix string `url:"suffix,omitempty"` 101 102 // The record names that should be included (same as name field of Record) 103 RecordName string `url:"recordName,omitempty"` 104 105 // A comma-separated list of record types that should be included 106 RecordType string `url:"recordType,omitempty"` 107} 108