...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package alert
18
19
20
21
22 import (
23 "context"
24 "net/http"
25 "time"
26
27 "github.com/go-openapi/errors"
28 "github.com/go-openapi/runtime"
29 cr "github.com/go-openapi/runtime/client"
30 "github.com/go-openapi/strfmt"
31 "github.com/go-openapi/swag"
32 )
33
34
35
36
37
38
39
40 func NewGetAlertsParams() *GetAlertsParams {
41 return &GetAlertsParams{
42 timeout: cr.DefaultTimeout,
43 }
44 }
45
46
47
48 func NewGetAlertsParamsWithTimeout(timeout time.Duration) *GetAlertsParams {
49 return &GetAlertsParams{
50 timeout: timeout,
51 }
52 }
53
54
55
56 func NewGetAlertsParamsWithContext(ctx context.Context) *GetAlertsParams {
57 return &GetAlertsParams{
58 Context: ctx,
59 }
60 }
61
62
63
64 func NewGetAlertsParamsWithHTTPClient(client *http.Client) *GetAlertsParams {
65 return &GetAlertsParams{
66 HTTPClient: client,
67 }
68 }
69
70
77 type GetAlertsParams struct {
78
79
85 Active *bool
86
87
91 Filter []string
92
93
99 Inhibited *bool
100
101
105 Receiver *string
106
107
113 Silenced *bool
114
115
121 Unprocessed *bool
122
123 timeout time.Duration
124 Context context.Context
125 HTTPClient *http.Client
126 }
127
128
129
130
131 func (o *GetAlertsParams) WithDefaults() *GetAlertsParams {
132 o.SetDefaults()
133 return o
134 }
135
136
137
138
139 func (o *GetAlertsParams) SetDefaults() {
140 var (
141 activeDefault = bool(true)
142
143 inhibitedDefault = bool(true)
144
145 silencedDefault = bool(true)
146
147 unprocessedDefault = bool(true)
148 )
149
150 val := GetAlertsParams{
151 Active: &activeDefault,
152 Inhibited: &inhibitedDefault,
153 Silenced: &silencedDefault,
154 Unprocessed: &unprocessedDefault,
155 }
156
157 val.timeout = o.timeout
158 val.Context = o.Context
159 val.HTTPClient = o.HTTPClient
160 *o = val
161 }
162
163
164 func (o *GetAlertsParams) WithTimeout(timeout time.Duration) *GetAlertsParams {
165 o.SetTimeout(timeout)
166 return o
167 }
168
169
170 func (o *GetAlertsParams) SetTimeout(timeout time.Duration) {
171 o.timeout = timeout
172 }
173
174
175 func (o *GetAlertsParams) WithContext(ctx context.Context) *GetAlertsParams {
176 o.SetContext(ctx)
177 return o
178 }
179
180
181 func (o *GetAlertsParams) SetContext(ctx context.Context) {
182 o.Context = ctx
183 }
184
185
186 func (o *GetAlertsParams) WithHTTPClient(client *http.Client) *GetAlertsParams {
187 o.SetHTTPClient(client)
188 return o
189 }
190
191
192 func (o *GetAlertsParams) SetHTTPClient(client *http.Client) {
193 o.HTTPClient = client
194 }
195
196
197 func (o *GetAlertsParams) WithActive(active *bool) *GetAlertsParams {
198 o.SetActive(active)
199 return o
200 }
201
202
203 func (o *GetAlertsParams) SetActive(active *bool) {
204 o.Active = active
205 }
206
207
208 func (o *GetAlertsParams) WithFilter(filter []string) *GetAlertsParams {
209 o.SetFilter(filter)
210 return o
211 }
212
213
214 func (o *GetAlertsParams) SetFilter(filter []string) {
215 o.Filter = filter
216 }
217
218
219 func (o *GetAlertsParams) WithInhibited(inhibited *bool) *GetAlertsParams {
220 o.SetInhibited(inhibited)
221 return o
222 }
223
224
225 func (o *GetAlertsParams) SetInhibited(inhibited *bool) {
226 o.Inhibited = inhibited
227 }
228
229
230 func (o *GetAlertsParams) WithReceiver(receiver *string) *GetAlertsParams {
231 o.SetReceiver(receiver)
232 return o
233 }
234
235
236 func (o *GetAlertsParams) SetReceiver(receiver *string) {
237 o.Receiver = receiver
238 }
239
240
241 func (o *GetAlertsParams) WithSilenced(silenced *bool) *GetAlertsParams {
242 o.SetSilenced(silenced)
243 return o
244 }
245
246
247 func (o *GetAlertsParams) SetSilenced(silenced *bool) {
248 o.Silenced = silenced
249 }
250
251
252 func (o *GetAlertsParams) WithUnprocessed(unprocessed *bool) *GetAlertsParams {
253 o.SetUnprocessed(unprocessed)
254 return o
255 }
256
257
258 func (o *GetAlertsParams) SetUnprocessed(unprocessed *bool) {
259 o.Unprocessed = unprocessed
260 }
261
262
263 func (o *GetAlertsParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error {
264
265 if err := r.SetTimeout(o.timeout); err != nil {
266 return err
267 }
268 var res []error
269
270 if o.Active != nil {
271
272
273 var qrActive bool
274
275 if o.Active != nil {
276 qrActive = *o.Active
277 }
278 qActive := swag.FormatBool(qrActive)
279 if qActive != "" {
280
281 if err := r.SetQueryParam("active", qActive); err != nil {
282 return err
283 }
284 }
285 }
286
287 if o.Filter != nil {
288
289
290 joinedFilter := o.bindParamFilter(reg)
291
292
293 if err := r.SetQueryParam("filter", joinedFilter...); err != nil {
294 return err
295 }
296 }
297
298 if o.Inhibited != nil {
299
300
301 var qrInhibited bool
302
303 if o.Inhibited != nil {
304 qrInhibited = *o.Inhibited
305 }
306 qInhibited := swag.FormatBool(qrInhibited)
307 if qInhibited != "" {
308
309 if err := r.SetQueryParam("inhibited", qInhibited); err != nil {
310 return err
311 }
312 }
313 }
314
315 if o.Receiver != nil {
316
317
318 var qrReceiver string
319
320 if o.Receiver != nil {
321 qrReceiver = *o.Receiver
322 }
323 qReceiver := qrReceiver
324 if qReceiver != "" {
325
326 if err := r.SetQueryParam("receiver", qReceiver); err != nil {
327 return err
328 }
329 }
330 }
331
332 if o.Silenced != nil {
333
334
335 var qrSilenced bool
336
337 if o.Silenced != nil {
338 qrSilenced = *o.Silenced
339 }
340 qSilenced := swag.FormatBool(qrSilenced)
341 if qSilenced != "" {
342
343 if err := r.SetQueryParam("silenced", qSilenced); err != nil {
344 return err
345 }
346 }
347 }
348
349 if o.Unprocessed != nil {
350
351
352 var qrUnprocessed bool
353
354 if o.Unprocessed != nil {
355 qrUnprocessed = *o.Unprocessed
356 }
357 qUnprocessed := swag.FormatBool(qrUnprocessed)
358 if qUnprocessed != "" {
359
360 if err := r.SetQueryParam("unprocessed", qUnprocessed); err != nil {
361 return err
362 }
363 }
364 }
365
366 if len(res) > 0 {
367 return errors.CompositeValidationError(res...)
368 }
369 return nil
370 }
371
372
373 func (o *GetAlertsParams) bindParamFilter(formats strfmt.Registry) []string {
374 filterIR := o.Filter
375
376 var filterIC []string
377 for _, filterIIR := range filterIR {
378
379 filterIIV := filterIIR
380 filterIC = append(filterIC, filterIIV)
381 }
382
383
384 filterIS := swag.JoinByFormat(filterIC, "multi")
385
386 return filterIS
387 }
388
View as plain text