1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package entries
20
21
22
23
24 import (
25 "fmt"
26 "io"
27
28 "github.com/go-openapi/errors"
29 "github.com/go-openapi/runtime"
30 "github.com/go-openapi/strfmt"
31
32 "github.com/sigstore/rekor/pkg/generated/models"
33 )
34
35
36 type CreateLogEntryReader struct {
37 formats strfmt.Registry
38 }
39
40
41 func (o *CreateLogEntryReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) {
42 switch response.Code() {
43 case 201:
44 result := NewCreateLogEntryCreated()
45 if err := result.readResponse(response, consumer, o.formats); err != nil {
46 return nil, err
47 }
48 return result, nil
49 case 400:
50 result := NewCreateLogEntryBadRequest()
51 if err := result.readResponse(response, consumer, o.formats); err != nil {
52 return nil, err
53 }
54 return nil, result
55 case 409:
56 result := NewCreateLogEntryConflict()
57 if err := result.readResponse(response, consumer, o.formats); err != nil {
58 return nil, err
59 }
60 return nil, result
61 default:
62 result := NewCreateLogEntryDefault(response.Code())
63 if err := result.readResponse(response, consumer, o.formats); err != nil {
64 return nil, err
65 }
66 if response.Code()/100 == 2 {
67 return result, nil
68 }
69 return nil, result
70 }
71 }
72
73
74 func NewCreateLogEntryCreated() *CreateLogEntryCreated {
75 return &CreateLogEntryCreated{}
76 }
77
78
83 type CreateLogEntryCreated struct {
84
85
87 ETag string
88
89
93 Location strfmt.URI
94
95 Payload models.LogEntry
96 }
97
98
99 func (o *CreateLogEntryCreated) IsSuccess() bool {
100 return true
101 }
102
103
104 func (o *CreateLogEntryCreated) IsRedirect() bool {
105 return false
106 }
107
108
109 func (o *CreateLogEntryCreated) IsClientError() bool {
110 return false
111 }
112
113
114 func (o *CreateLogEntryCreated) IsServerError() bool {
115 return false
116 }
117
118
119 func (o *CreateLogEntryCreated) IsCode(code int) bool {
120 return code == 201
121 }
122
123
124 func (o *CreateLogEntryCreated) Code() int {
125 return 201
126 }
127
128 func (o *CreateLogEntryCreated) Error() string {
129 return fmt.Sprintf("[POST /api/v1/log/entries][%d] createLogEntryCreated %+v", 201, o.Payload)
130 }
131
132 func (o *CreateLogEntryCreated) String() string {
133 return fmt.Sprintf("[POST /api/v1/log/entries][%d] createLogEntryCreated %+v", 201, o.Payload)
134 }
135
136 func (o *CreateLogEntryCreated) GetPayload() models.LogEntry {
137 return o.Payload
138 }
139
140 func (o *CreateLogEntryCreated) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error {
141
142
143 hdrETag := response.GetHeader("ETag")
144
145 if hdrETag != "" {
146 o.ETag = hdrETag
147 }
148
149
150 hdrLocation := response.GetHeader("Location")
151
152 if hdrLocation != "" {
153 vallocation, err := formats.Parse("uri", hdrLocation)
154 if err != nil {
155 return errors.InvalidType("Location", "header", "strfmt.URI", hdrLocation)
156 }
157 o.Location = *(vallocation.(*strfmt.URI))
158 }
159
160
161 if err := consumer.Consume(response.Body(), &o.Payload); err != nil && err != io.EOF {
162 return err
163 }
164
165 return nil
166 }
167
168
169 func NewCreateLogEntryBadRequest() *CreateLogEntryBadRequest {
170 return &CreateLogEntryBadRequest{}
171 }
172
173
178 type CreateLogEntryBadRequest struct {
179 Payload *models.Error
180 }
181
182
183 func (o *CreateLogEntryBadRequest) IsSuccess() bool {
184 return false
185 }
186
187
188 func (o *CreateLogEntryBadRequest) IsRedirect() bool {
189 return false
190 }
191
192
193 func (o *CreateLogEntryBadRequest) IsClientError() bool {
194 return true
195 }
196
197
198 func (o *CreateLogEntryBadRequest) IsServerError() bool {
199 return false
200 }
201
202
203 func (o *CreateLogEntryBadRequest) IsCode(code int) bool {
204 return code == 400
205 }
206
207
208 func (o *CreateLogEntryBadRequest) Code() int {
209 return 400
210 }
211
212 func (o *CreateLogEntryBadRequest) Error() string {
213 return fmt.Sprintf("[POST /api/v1/log/entries][%d] createLogEntryBadRequest %+v", 400, o.Payload)
214 }
215
216 func (o *CreateLogEntryBadRequest) String() string {
217 return fmt.Sprintf("[POST /api/v1/log/entries][%d] createLogEntryBadRequest %+v", 400, o.Payload)
218 }
219
220 func (o *CreateLogEntryBadRequest) GetPayload() *models.Error {
221 return o.Payload
222 }
223
224 func (o *CreateLogEntryBadRequest) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error {
225
226 o.Payload = new(models.Error)
227
228
229 if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF {
230 return err
231 }
232
233 return nil
234 }
235
236
237 func NewCreateLogEntryConflict() *CreateLogEntryConflict {
238 return &CreateLogEntryConflict{}
239 }
240
241
246 type CreateLogEntryConflict struct {
247 Location strfmt.URI
248
249 Payload *models.Error
250 }
251
252
253 func (o *CreateLogEntryConflict) IsSuccess() bool {
254 return false
255 }
256
257
258 func (o *CreateLogEntryConflict) IsRedirect() bool {
259 return false
260 }
261
262
263 func (o *CreateLogEntryConflict) IsClientError() bool {
264 return true
265 }
266
267
268 func (o *CreateLogEntryConflict) IsServerError() bool {
269 return false
270 }
271
272
273 func (o *CreateLogEntryConflict) IsCode(code int) bool {
274 return code == 409
275 }
276
277
278 func (o *CreateLogEntryConflict) Code() int {
279 return 409
280 }
281
282 func (o *CreateLogEntryConflict) Error() string {
283 return fmt.Sprintf("[POST /api/v1/log/entries][%d] createLogEntryConflict %+v", 409, o.Payload)
284 }
285
286 func (o *CreateLogEntryConflict) String() string {
287 return fmt.Sprintf("[POST /api/v1/log/entries][%d] createLogEntryConflict %+v", 409, o.Payload)
288 }
289
290 func (o *CreateLogEntryConflict) GetPayload() *models.Error {
291 return o.Payload
292 }
293
294 func (o *CreateLogEntryConflict) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error {
295
296
297 hdrLocation := response.GetHeader("Location")
298
299 if hdrLocation != "" {
300 vallocation, err := formats.Parse("uri", hdrLocation)
301 if err != nil {
302 return errors.InvalidType("Location", "header", "strfmt.URI", hdrLocation)
303 }
304 o.Location = *(vallocation.(*strfmt.URI))
305 }
306
307 o.Payload = new(models.Error)
308
309
310 if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF {
311 return err
312 }
313
314 return nil
315 }
316
317
318 func NewCreateLogEntryDefault(code int) *CreateLogEntryDefault {
319 return &CreateLogEntryDefault{
320 _statusCode: code,
321 }
322 }
323
324
329 type CreateLogEntryDefault struct {
330 _statusCode int
331
332 Payload *models.Error
333 }
334
335
336 func (o *CreateLogEntryDefault) IsSuccess() bool {
337 return o._statusCode/100 == 2
338 }
339
340
341 func (o *CreateLogEntryDefault) IsRedirect() bool {
342 return o._statusCode/100 == 3
343 }
344
345
346 func (o *CreateLogEntryDefault) IsClientError() bool {
347 return o._statusCode/100 == 4
348 }
349
350
351 func (o *CreateLogEntryDefault) IsServerError() bool {
352 return o._statusCode/100 == 5
353 }
354
355
356 func (o *CreateLogEntryDefault) IsCode(code int) bool {
357 return o._statusCode == code
358 }
359
360
361 func (o *CreateLogEntryDefault) Code() int {
362 return o._statusCode
363 }
364
365 func (o *CreateLogEntryDefault) Error() string {
366 return fmt.Sprintf("[POST /api/v1/log/entries][%d] createLogEntry default %+v", o._statusCode, o.Payload)
367 }
368
369 func (o *CreateLogEntryDefault) String() string {
370 return fmt.Sprintf("[POST /api/v1/log/entries][%d] createLogEntry default %+v", o._statusCode, o.Payload)
371 }
372
373 func (o *CreateLogEntryDefault) GetPayload() *models.Error {
374 return o.Payload
375 }
376
377 func (o *CreateLogEntryDefault) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error {
378
379 o.Payload = new(models.Error)
380
381
382 if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF {
383 return err
384 }
385
386 return nil
387 }
388
View as plain text