structures.go raw
1 package helper
2
3 import (
4 "fmt"
5 "net/url"
6 )
7
8 // QueryInfo wraps the structure of ultradns query info.
9 type QueryInfo struct {
10 Query string `json:"q,omitempty"`
11 Sort string `json:"sort,omitempty"`
12 Cursor string `json:"cursor,omitempty"`
13 Reverse bool `json:"reverse,omitempty"`
14 Limit int `json:"limit,omitempty"`
15 Offset int `json:"offset,omitempty"`
16 }
17
18 // ResultInfo wraps the structure of ultradns result info.
19 type ResultInfo struct {
20 TotalCount int `json:"totalCount,omitempty"`
21 Offset int `json:"offset,omitempty"`
22 ReturnedCount int `json:"returnedCount,omitempty"`
23 }
24
25 // CursorInfo wraps the structure of ultradns cursor info.
26 type CursorInfo struct {
27 Limit int `json:"limit,omitempty"`
28 Next string `json:"next,omitempty"`
29 Previous string `json:"previous,omitempty"`
30 First string `json:"first,omitempty"`
31 Last string `json:"last,omitempty"`
32 }
33
34 func (q *QueryInfo) URI() string {
35 if q.Limit == 0 {
36 q.Limit = 100
37 }
38
39 queryInfo := fmt.Sprintf("&q=%v&offset=%v&cursor=%v&limit=%v&sort=%v&reverse=%v", q.Query, q.Offset, q.Cursor, q.Limit, q.Sort, q.Reverse)
40
41 return "?" + url.PathEscape(queryInfo)
42 }
43