1package internal 2 3import ( 4 "fmt" 5 "strings" 6) 7 8// Search filters. 9const ( 10 StartsWith searchFilter = "startswith" 11 Exact searchFilter = "exact" 12 EndsWith searchFilter = "endswith" 13 Contains searchFilter = "contains" 14) 15 16type searchFilter string 17 18// NotFound Not found error. 19type NotFound struct { 20 *APIError 21} 22 23func (e *NotFound) Unwrap() error { 24 return e.APIError 25} 26 27// BadRequest Bad request error. 28type BadRequest struct { 29 *APIError 30} 31 32func (e *BadRequest) Unwrap() error { 33 return e.APIError 34} 35 36// APIError is the representation of an API error. 37type APIError struct { 38 StatusCode int `json:"statusCode"` 39 Errors []string `json:"errors"` 40} 41 42func (a APIError) Error() string { 43 return fmt.Sprintf("%d: %s", a.StatusCode, strings.Join(a.Errors, ": ")) 44} 45 46// SuccessMessage is the representation of a success message. 47type SuccessMessage struct { 48 Success string `json:"success"` 49} 50 51// RecordRequest is the representation of a request's record. 52type RecordRequest struct { 53 Name string `json:"name"` 54 TTL int `json:"ttl,omitempty"` 55 RoundRobin []RecordValue `json:"roundRobin,omitempty"` 56} 57 58// RecordValue is the representation of a record's value. 59type RecordValue struct { 60 Value string `json:"value,omitempty"` 61 DisableFlag bool `json:"disableFlag,omitempty"` // only for the response 62} 63 64// Record is the representation of a record. 65type Record struct { 66 ID int64 `json:"id"` 67 Type string `json:"type"` 68 RecordType string `json:"recordType"` 69 Name string `json:"name"` 70 RecordOption string `json:"recordOption,omitempty"` 71 NoAnswer bool `json:"noAnswer,omitempty"` 72 Note string `json:"note,omitempty"` 73 TTL int `json:"ttl,omitempty"` 74 GtdRegion int `json:"gtdRegion,omitempty"` 75 ParentID int `json:"parentId,omitempty"` 76 Parent string `json:"parent,omitempty"` 77 Source string `json:"source,omitempty"` 78 ModifiedTS int64 `json:"modifiedTs,omitempty"` 79 Value []RecordValue `json:"value,omitempty"` 80 RoundRobin []RecordValue `json:"roundRobin,omitempty"` 81} 82 83// Domain is the representation of a domain. 84type Domain struct { 85 ID int64 `json:"id"` 86 Name string `json:"name,omitempty"` 87 TypeID int64 `json:"typeId,omitempty"` 88 Version int64 `json:"version,omitempty"` 89 Status string `json:"status,omitempty"` 90} 91 92// PaginationParameters is pagination parameters. 93type PaginationParameters struct { 94 // Offset retrieves a subset of records starting with the offset value. 95 Offset int `url:"offset"` 96 // Max retrieves maximum number of dataset. 97 Max int `url:"max"` 98 // Sort on the basis of given property name. 99 Sort string `url:"sort"` 100 // Order Sort order. Possible values are asc / desc. 101 Order string `url:"order"` 102} 103