...
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 "fmt"
24 "io"
25
26 "github.com/go-openapi/runtime"
27 "github.com/go-openapi/strfmt"
28
29 "github.com/prometheus/alertmanager/api/v2/models"
30 )
31
32
33 type GetAlertsReader struct {
34 formats strfmt.Registry
35 }
36
37
38 func (o *GetAlertsReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) {
39 switch response.Code() {
40 case 200:
41 result := NewGetAlertsOK()
42 if err := result.readResponse(response, consumer, o.formats); err != nil {
43 return nil, err
44 }
45 return result, nil
46 case 400:
47 result := NewGetAlertsBadRequest()
48 if err := result.readResponse(response, consumer, o.formats); err != nil {
49 return nil, err
50 }
51 return nil, result
52 case 500:
53 result := NewGetAlertsInternalServerError()
54 if err := result.readResponse(response, consumer, o.formats); err != nil {
55 return nil, err
56 }
57 return nil, result
58 default:
59 return nil, runtime.NewAPIError("response status code does not match any response statuses defined for this endpoint in the swagger spec", response, response.Code())
60 }
61 }
62
63
64 func NewGetAlertsOK() *GetAlertsOK {
65 return &GetAlertsOK{}
66 }
67
68
73 type GetAlertsOK struct {
74 Payload models.GettableAlerts
75 }
76
77
78 func (o *GetAlertsOK) IsSuccess() bool {
79 return true
80 }
81
82
83 func (o *GetAlertsOK) IsRedirect() bool {
84 return false
85 }
86
87
88 func (o *GetAlertsOK) IsClientError() bool {
89 return false
90 }
91
92
93 func (o *GetAlertsOK) IsServerError() bool {
94 return false
95 }
96
97
98 func (o *GetAlertsOK) IsCode(code int) bool {
99 return code == 200
100 }
101
102 func (o *GetAlertsOK) Error() string {
103 return fmt.Sprintf("[GET /alerts][%d] getAlertsOK %+v", 200, o.Payload)
104 }
105
106 func (o *GetAlertsOK) String() string {
107 return fmt.Sprintf("[GET /alerts][%d] getAlertsOK %+v", 200, o.Payload)
108 }
109
110 func (o *GetAlertsOK) GetPayload() models.GettableAlerts {
111 return o.Payload
112 }
113
114 func (o *GetAlertsOK) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error {
115
116
117 if err := consumer.Consume(response.Body(), &o.Payload); err != nil && err != io.EOF {
118 return err
119 }
120
121 return nil
122 }
123
124
125 func NewGetAlertsBadRequest() *GetAlertsBadRequest {
126 return &GetAlertsBadRequest{}
127 }
128
129
134 type GetAlertsBadRequest struct {
135 Payload string
136 }
137
138
139 func (o *GetAlertsBadRequest) IsSuccess() bool {
140 return false
141 }
142
143
144 func (o *GetAlertsBadRequest) IsRedirect() bool {
145 return false
146 }
147
148
149 func (o *GetAlertsBadRequest) IsClientError() bool {
150 return true
151 }
152
153
154 func (o *GetAlertsBadRequest) IsServerError() bool {
155 return false
156 }
157
158
159 func (o *GetAlertsBadRequest) IsCode(code int) bool {
160 return code == 400
161 }
162
163 func (o *GetAlertsBadRequest) Error() string {
164 return fmt.Sprintf("[GET /alerts][%d] getAlertsBadRequest %+v", 400, o.Payload)
165 }
166
167 func (o *GetAlertsBadRequest) String() string {
168 return fmt.Sprintf("[GET /alerts][%d] getAlertsBadRequest %+v", 400, o.Payload)
169 }
170
171 func (o *GetAlertsBadRequest) GetPayload() string {
172 return o.Payload
173 }
174
175 func (o *GetAlertsBadRequest) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error {
176
177
178 if err := consumer.Consume(response.Body(), &o.Payload); err != nil && err != io.EOF {
179 return err
180 }
181
182 return nil
183 }
184
185
186 func NewGetAlertsInternalServerError() *GetAlertsInternalServerError {
187 return &GetAlertsInternalServerError{}
188 }
189
190
195 type GetAlertsInternalServerError struct {
196 Payload string
197 }
198
199
200 func (o *GetAlertsInternalServerError) IsSuccess() bool {
201 return false
202 }
203
204
205 func (o *GetAlertsInternalServerError) IsRedirect() bool {
206 return false
207 }
208
209
210 func (o *GetAlertsInternalServerError) IsClientError() bool {
211 return false
212 }
213
214
215 func (o *GetAlertsInternalServerError) IsServerError() bool {
216 return true
217 }
218
219
220 func (o *GetAlertsInternalServerError) IsCode(code int) bool {
221 return code == 500
222 }
223
224 func (o *GetAlertsInternalServerError) Error() string {
225 return fmt.Sprintf("[GET /alerts][%d] getAlertsInternalServerError %+v", 500, o.Payload)
226 }
227
228 func (o *GetAlertsInternalServerError) String() string {
229 return fmt.Sprintf("[GET /alerts][%d] getAlertsInternalServerError %+v", 500, o.Payload)
230 }
231
232 func (o *GetAlertsInternalServerError) GetPayload() string {
233 return o.Payload
234 }
235
236 func (o *GetAlertsInternalServerError) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error {
237
238
239 if err := consumer.Consume(response.Body(), &o.Payload); err != nil && err != io.EOF {
240 return err
241 }
242
243 return nil
244 }
245
View as plain text