/
query_params.go
55 lines (45 loc) · 1.33 KB
/
query_params.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
package resources
type ListQueryParams struct {
Filters *map[string][]string `json:"Filters,omitempty"`
OrderBy *string `json:"OrderBy,omitempty"`
MaxResults *int32 `json:"MaxResults,omitempty"`
QueryParams QueryParams `json:"QueryParams,omitempty"`
}
func (q ListQueryParams) SetFilters(filters map[string][]string) ListQueryParams {
q.Filters = &filters
return q
}
func (q ListQueryParams) SetOrderBy(orderBy string) ListQueryParams {
if orderBy != "" {
q.OrderBy = &orderBy
}
return q
}
func (q ListQueryParams) SetMaxResults(maxResults int32) ListQueryParams {
if maxResults > 0 {
q.MaxResults = &maxResults
}
return q
}
func (q ListQueryParams) SetDepth(depth int32) ListQueryParams {
q.QueryParams.Depth = &depth
return q
}
func (q ListQueryParams) SetPretty(pretty bool) ListQueryParams {
q.QueryParams.Pretty = &pretty
return q
}
// TODO: Merge ListQueryParams into QueryParams
// TODO: Once Compute namespace is added, add all of QueryParam's flags as Global flags, to reduce duplication
type QueryParams struct {
Depth *int32 `json:"Depth,omitempty"`
Pretty *bool `json:"Pretty,omitempty"`
}
func (d QueryParams) SetDepth(depth int32) QueryParams {
d.Depth = &depth
return d
}
func (d QueryParams) SetPretty(pretty bool) QueryParams {
d.Pretty = &pretty
return d
}