...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package alertgroup
18
19
20
21
22 import (
23 "errors"
24 "net/url"
25 golangswaggerpaths "path"
26
27 "github.com/go-openapi/swag"
28 )
29
30
31 type GetAlertGroupsURL struct {
32 Active *bool
33 Filter []string
34 Inhibited *bool
35 Receiver *string
36 Silenced *bool
37
38 _basePath string
39
40 _ struct{}
41 }
42
43
44
45
46 func (o *GetAlertGroupsURL) WithBasePath(bp string) *GetAlertGroupsURL {
47 o.SetBasePath(bp)
48 return o
49 }
50
51
52
53
54 func (o *GetAlertGroupsURL) SetBasePath(bp string) {
55 o._basePath = bp
56 }
57
58
59 func (o *GetAlertGroupsURL) Build() (*url.URL, error) {
60 var _result url.URL
61
62 var _path = "/alerts/groups"
63
64 _basePath := o._basePath
65 if _basePath == "" {
66 _basePath = "/api/v2/"
67 }
68 _result.Path = golangswaggerpaths.Join(_basePath, _path)
69
70 qs := make(url.Values)
71
72 var activeQ string
73 if o.Active != nil {
74 activeQ = swag.FormatBool(*o.Active)
75 }
76 if activeQ != "" {
77 qs.Set("active", activeQ)
78 }
79
80 var filterIR []string
81 for _, filterI := range o.Filter {
82 filterIS := filterI
83 if filterIS != "" {
84 filterIR = append(filterIR, filterIS)
85 }
86 }
87
88 filter := swag.JoinByFormat(filterIR, "multi")
89
90 for _, qsv := range filter {
91 qs.Add("filter", qsv)
92 }
93
94 var inhibitedQ string
95 if o.Inhibited != nil {
96 inhibitedQ = swag.FormatBool(*o.Inhibited)
97 }
98 if inhibitedQ != "" {
99 qs.Set("inhibited", inhibitedQ)
100 }
101
102 var receiverQ string
103 if o.Receiver != nil {
104 receiverQ = *o.Receiver
105 }
106 if receiverQ != "" {
107 qs.Set("receiver", receiverQ)
108 }
109
110 var silencedQ string
111 if o.Silenced != nil {
112 silencedQ = swag.FormatBool(*o.Silenced)
113 }
114 if silencedQ != "" {
115 qs.Set("silenced", silencedQ)
116 }
117
118 _result.RawQuery = qs.Encode()
119
120 return &_result, nil
121 }
122
123
124 func (o *GetAlertGroupsURL) Must(u *url.URL, err error) *url.URL {
125 if err != nil {
126 panic(err)
127 }
128 if u == nil {
129 panic("url can't be nil")
130 }
131 return u
132 }
133
134
135 func (o *GetAlertGroupsURL) String() string {
136 return o.Must(o.Build()).String()
137 }
138
139
140 func (o *GetAlertGroupsURL) BuildFull(scheme, host string) (*url.URL, error) {
141 if scheme == "" {
142 return nil, errors.New("scheme is required for a full url on GetAlertGroupsURL")
143 }
144 if host == "" {
145 return nil, errors.New("host is required for a full url on GetAlertGroupsURL")
146 }
147
148 base, err := o.Build()
149 if err != nil {
150 return nil, err
151 }
152
153 base.Scheme = scheme
154 base.Host = host
155 return base, nil
156 }
157
158
159 func (o *GetAlertGroupsURL) StringFull(scheme, host string) string {
160 return o.Must(o.BuildFull(scheme, host)).String()
161 }
162
View as plain text