...
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
32 "github.com/prometheus/alertmanager/api/v2/models"
33 )
34
35
36
37
38
39
40
41 func NewPostAlertsParams() *PostAlertsParams {
42 return &PostAlertsParams{
43 timeout: cr.DefaultTimeout,
44 }
45 }
46
47
48
49 func NewPostAlertsParamsWithTimeout(timeout time.Duration) *PostAlertsParams {
50 return &PostAlertsParams{
51 timeout: timeout,
52 }
53 }
54
55
56
57 func NewPostAlertsParamsWithContext(ctx context.Context) *PostAlertsParams {
58 return &PostAlertsParams{
59 Context: ctx,
60 }
61 }
62
63
64
65 func NewPostAlertsParamsWithHTTPClient(client *http.Client) *PostAlertsParams {
66 return &PostAlertsParams{
67 HTTPClient: client,
68 }
69 }
70
71
78 type PostAlertsParams struct {
79
80
84 Alerts models.PostableAlerts
85
86 timeout time.Duration
87 Context context.Context
88 HTTPClient *http.Client
89 }
90
91
92
93
94 func (o *PostAlertsParams) WithDefaults() *PostAlertsParams {
95 o.SetDefaults()
96 return o
97 }
98
99
100
101
102 func (o *PostAlertsParams) SetDefaults() {
103
104 }
105
106
107 func (o *PostAlertsParams) WithTimeout(timeout time.Duration) *PostAlertsParams {
108 o.SetTimeout(timeout)
109 return o
110 }
111
112
113 func (o *PostAlertsParams) SetTimeout(timeout time.Duration) {
114 o.timeout = timeout
115 }
116
117
118 func (o *PostAlertsParams) WithContext(ctx context.Context) *PostAlertsParams {
119 o.SetContext(ctx)
120 return o
121 }
122
123
124 func (o *PostAlertsParams) SetContext(ctx context.Context) {
125 o.Context = ctx
126 }
127
128
129 func (o *PostAlertsParams) WithHTTPClient(client *http.Client) *PostAlertsParams {
130 o.SetHTTPClient(client)
131 return o
132 }
133
134
135 func (o *PostAlertsParams) SetHTTPClient(client *http.Client) {
136 o.HTTPClient = client
137 }
138
139
140 func (o *PostAlertsParams) WithAlerts(alerts models.PostableAlerts) *PostAlertsParams {
141 o.SetAlerts(alerts)
142 return o
143 }
144
145
146 func (o *PostAlertsParams) SetAlerts(alerts models.PostableAlerts) {
147 o.Alerts = alerts
148 }
149
150
151 func (o *PostAlertsParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error {
152
153 if err := r.SetTimeout(o.timeout); err != nil {
154 return err
155 }
156 var res []error
157 if o.Alerts != nil {
158 if err := r.SetBodyParam(o.Alerts); err != nil {
159 return err
160 }
161 }
162
163 if len(res) > 0 {
164 return errors.CompositeValidationError(res...)
165 }
166 return nil
167 }
168
View as plain text