...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package silence
18
19
20
21
22 import (
23 "context"
24 "fmt"
25 "io"
26
27 "github.com/go-openapi/runtime"
28 "github.com/go-openapi/strfmt"
29 "github.com/go-openapi/swag"
30 )
31
32
33 type PostSilencesReader struct {
34 formats strfmt.Registry
35 }
36
37
38 func (o *PostSilencesReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) {
39 switch response.Code() {
40 case 200:
41 result := NewPostSilencesOK()
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 := NewPostSilencesBadRequest()
48 if err := result.readResponse(response, consumer, o.formats); err != nil {
49 return nil, err
50 }
51 return nil, result
52 case 404:
53 result := NewPostSilencesNotFound()
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 NewPostSilencesOK() *PostSilencesOK {
65 return &PostSilencesOK{}
66 }
67
68
73 type PostSilencesOK struct {
74 Payload *PostSilencesOKBody
75 }
76
77
78 func (o *PostSilencesOK) IsSuccess() bool {
79 return true
80 }
81
82
83 func (o *PostSilencesOK) IsRedirect() bool {
84 return false
85 }
86
87
88 func (o *PostSilencesOK) IsClientError() bool {
89 return false
90 }
91
92
93 func (o *PostSilencesOK) IsServerError() bool {
94 return false
95 }
96
97
98 func (o *PostSilencesOK) IsCode(code int) bool {
99 return code == 200
100 }
101
102 func (o *PostSilencesOK) Error() string {
103 return fmt.Sprintf("[POST /silences][%d] postSilencesOK %+v", 200, o.Payload)
104 }
105
106 func (o *PostSilencesOK) String() string {
107 return fmt.Sprintf("[POST /silences][%d] postSilencesOK %+v", 200, o.Payload)
108 }
109
110 func (o *PostSilencesOK) GetPayload() *PostSilencesOKBody {
111 return o.Payload
112 }
113
114 func (o *PostSilencesOK) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error {
115
116 o.Payload = new(PostSilencesOKBody)
117
118
119 if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF {
120 return err
121 }
122
123 return nil
124 }
125
126
127 func NewPostSilencesBadRequest() *PostSilencesBadRequest {
128 return &PostSilencesBadRequest{}
129 }
130
131
136 type PostSilencesBadRequest struct {
137 Payload string
138 }
139
140
141 func (o *PostSilencesBadRequest) IsSuccess() bool {
142 return false
143 }
144
145
146 func (o *PostSilencesBadRequest) IsRedirect() bool {
147 return false
148 }
149
150
151 func (o *PostSilencesBadRequest) IsClientError() bool {
152 return true
153 }
154
155
156 func (o *PostSilencesBadRequest) IsServerError() bool {
157 return false
158 }
159
160
161 func (o *PostSilencesBadRequest) IsCode(code int) bool {
162 return code == 400
163 }
164
165 func (o *PostSilencesBadRequest) Error() string {
166 return fmt.Sprintf("[POST /silences][%d] postSilencesBadRequest %+v", 400, o.Payload)
167 }
168
169 func (o *PostSilencesBadRequest) String() string {
170 return fmt.Sprintf("[POST /silences][%d] postSilencesBadRequest %+v", 400, o.Payload)
171 }
172
173 func (o *PostSilencesBadRequest) GetPayload() string {
174 return o.Payload
175 }
176
177 func (o *PostSilencesBadRequest) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error {
178
179
180 if err := consumer.Consume(response.Body(), &o.Payload); err != nil && err != io.EOF {
181 return err
182 }
183
184 return nil
185 }
186
187
188 func NewPostSilencesNotFound() *PostSilencesNotFound {
189 return &PostSilencesNotFound{}
190 }
191
192
197 type PostSilencesNotFound struct {
198 Payload string
199 }
200
201
202 func (o *PostSilencesNotFound) IsSuccess() bool {
203 return false
204 }
205
206
207 func (o *PostSilencesNotFound) IsRedirect() bool {
208 return false
209 }
210
211
212 func (o *PostSilencesNotFound) IsClientError() bool {
213 return true
214 }
215
216
217 func (o *PostSilencesNotFound) IsServerError() bool {
218 return false
219 }
220
221
222 func (o *PostSilencesNotFound) IsCode(code int) bool {
223 return code == 404
224 }
225
226 func (o *PostSilencesNotFound) Error() string {
227 return fmt.Sprintf("[POST /silences][%d] postSilencesNotFound %+v", 404, o.Payload)
228 }
229
230 func (o *PostSilencesNotFound) String() string {
231 return fmt.Sprintf("[POST /silences][%d] postSilencesNotFound %+v", 404, o.Payload)
232 }
233
234 func (o *PostSilencesNotFound) GetPayload() string {
235 return o.Payload
236 }
237
238 func (o *PostSilencesNotFound) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error {
239
240
241 if err := consumer.Consume(response.Body(), &o.Payload); err != nil && err != io.EOF {
242 return err
243 }
244
245 return nil
246 }
247
248
252 type PostSilencesOKBody struct {
253
254
255 SilenceID string `json:"silenceID,omitempty"`
256 }
257
258
259 func (o *PostSilencesOKBody) Validate(formats strfmt.Registry) error {
260 return nil
261 }
262
263
264 func (o *PostSilencesOKBody) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
265 return nil
266 }
267
268
269 func (o *PostSilencesOKBody) MarshalBinary() ([]byte, error) {
270 if o == nil {
271 return nil, nil
272 }
273 return swag.WriteJSON(o)
274 }
275
276
277 func (o *PostSilencesOKBody) UnmarshalBinary(b []byte) error {
278 var res PostSilencesOKBody
279 if err := swag.ReadJSON(b, &res); err != nil {
280 return err
281 }
282 *o = res
283 return nil
284 }
285
View as plain text