1
9
10 package openapi
11
12 import (
13 "encoding/json"
14 "net/http"
15 "strings"
16
17 "github.com/gorilla/mux"
18 )
19
20
21 type DevstateApiController struct {
22 service DevstateApiServicer
23 errorHandler ErrorHandler
24 }
25
26
27 type DevstateApiOption func(*DevstateApiController)
28
29
30 func WithDevstateApiErrorHandler(h ErrorHandler) DevstateApiOption {
31 return func(c *DevstateApiController) {
32 c.errorHandler = h
33 }
34 }
35
36
37 func NewDevstateApiController(s DevstateApiServicer, opts ...DevstateApiOption) Router {
38 controller := &DevstateApiController{
39 service: s,
40 errorHandler: DefaultErrorHandler,
41 }
42
43 for _, opt := range opts {
44 opt(controller)
45 }
46
47 return controller
48 }
49
50
51 func (c *DevstateApiController) Routes() Routes {
52 return Routes{
53 {
54 "DevstateApplyCommandCommandNamePatch",
55 strings.ToUpper("Patch"),
56 "/api/v1/devstate/applyCommand/{commandName}",
57 c.DevstateApplyCommandCommandNamePatch,
58 },
59 {
60 "DevstateApplyCommandPost",
61 strings.ToUpper("Post"),
62 "/api/v1/devstate/applyCommand",
63 c.DevstateApplyCommandPost,
64 },
65 {
66 "DevstateChartGet",
67 strings.ToUpper("Get"),
68 "/api/v1/devstate/chart",
69 c.DevstateChartGet,
70 },
71 {
72 "DevstateCommandCommandNameDelete",
73 strings.ToUpper("Delete"),
74 "/api/v1/devstate/command/{commandName}",
75 c.DevstateCommandCommandNameDelete,
76 },
77 {
78 "DevstateCommandCommandNameMovePost",
79 strings.ToUpper("Post"),
80 "/api/v1/devstate/command/{commandName}/move",
81 c.DevstateCommandCommandNameMovePost,
82 },
83 {
84 "DevstateCommandCommandNameSetDefaultPost",
85 strings.ToUpper("Post"),
86 "/api/v1/devstate/command/{commandName}/setDefault",
87 c.DevstateCommandCommandNameSetDefaultPost,
88 },
89 {
90 "DevstateCommandCommandNameUnsetDefaultPost",
91 strings.ToUpper("Post"),
92 "/api/v1/devstate/command/{commandName}/unsetDefault",
93 c.DevstateCommandCommandNameUnsetDefaultPost,
94 },
95 {
96 "DevstateCompositeCommandCommandNamePatch",
97 strings.ToUpper("Patch"),
98 "/api/v1/devstate/compositeCommand/{commandName}",
99 c.DevstateCompositeCommandCommandNamePatch,
100 },
101 {
102 "DevstateCompositeCommandPost",
103 strings.ToUpper("Post"),
104 "/api/v1/devstate/compositeCommand",
105 c.DevstateCompositeCommandPost,
106 },
107 {
108 "DevstateContainerContainerNameDelete",
109 strings.ToUpper("Delete"),
110 "/api/v1/devstate/container/{containerName}",
111 c.DevstateContainerContainerNameDelete,
112 },
113 {
114 "DevstateContainerContainerNamePatch",
115 strings.ToUpper("Patch"),
116 "/api/v1/devstate/container/{containerName}",
117 c.DevstateContainerContainerNamePatch,
118 },
119 {
120 "DevstateContainerPost",
121 strings.ToUpper("Post"),
122 "/api/v1/devstate/container",
123 c.DevstateContainerPost,
124 },
125 {
126 "DevstateDevfileDelete",
127 strings.ToUpper("Delete"),
128 "/api/v1/devstate/devfile",
129 c.DevstateDevfileDelete,
130 },
131 {
132 "DevstateDevfileGet",
133 strings.ToUpper("Get"),
134 "/api/v1/devstate/devfile",
135 c.DevstateDevfileGet,
136 },
137 {
138 "DevstateDevfilePut",
139 strings.ToUpper("Put"),
140 "/api/v1/devstate/devfile",
141 c.DevstateDevfilePut,
142 },
143 {
144 "DevstateEventsPut",
145 strings.ToUpper("Put"),
146 "/api/v1/devstate/events",
147 c.DevstateEventsPut,
148 },
149 {
150 "DevstateExecCommandCommandNamePatch",
151 strings.ToUpper("Patch"),
152 "/api/v1/devstate/execCommand/{commandName}",
153 c.DevstateExecCommandCommandNamePatch,
154 },
155 {
156 "DevstateExecCommandPost",
157 strings.ToUpper("Post"),
158 "/api/v1/devstate/execCommand",
159 c.DevstateExecCommandPost,
160 },
161 {
162 "DevstateImageImageNameDelete",
163 strings.ToUpper("Delete"),
164 "/api/v1/devstate/image/{imageName}",
165 c.DevstateImageImageNameDelete,
166 },
167 {
168 "DevstateImageImageNamePatch",
169 strings.ToUpper("Patch"),
170 "/api/v1/devstate/image/{imageName}",
171 c.DevstateImageImageNamePatch,
172 },
173 {
174 "DevstateImagePost",
175 strings.ToUpper("Post"),
176 "/api/v1/devstate/image",
177 c.DevstateImagePost,
178 },
179 {
180 "DevstateMetadataPut",
181 strings.ToUpper("Put"),
182 "/api/v1/devstate/metadata",
183 c.DevstateMetadataPut,
184 },
185 {
186 "DevstateQuantityValidPost",
187 strings.ToUpper("Post"),
188 "/api/v1/devstate/quantityValid",
189 c.DevstateQuantityValidPost,
190 },
191 {
192 "DevstateResourcePost",
193 strings.ToUpper("Post"),
194 "/api/v1/devstate/resource",
195 c.DevstateResourcePost,
196 },
197 {
198 "DevstateResourceResourceNameDelete",
199 strings.ToUpper("Delete"),
200 "/api/v1/devstate/resource/{resourceName}",
201 c.DevstateResourceResourceNameDelete,
202 },
203 {
204 "DevstateResourceResourceNamePatch",
205 strings.ToUpper("Patch"),
206 "/api/v1/devstate/resource/{resourceName}",
207 c.DevstateResourceResourceNamePatch,
208 },
209 {
210 "DevstateVolumePost",
211 strings.ToUpper("Post"),
212 "/api/v1/devstate/volume",
213 c.DevstateVolumePost,
214 },
215 {
216 "DevstateVolumeVolumeNameDelete",
217 strings.ToUpper("Delete"),
218 "/api/v1/devstate/volume/{volumeName}",
219 c.DevstateVolumeVolumeNameDelete,
220 },
221 {
222 "DevstateVolumeVolumeNamePatch",
223 strings.ToUpper("Patch"),
224 "/api/v1/devstate/volume/{volumeName}",
225 c.DevstateVolumeVolumeNamePatch,
226 },
227 }
228 }
229
230
231 func (c *DevstateApiController) DevstateApplyCommandCommandNamePatch(w http.ResponseWriter, r *http.Request) {
232 params := mux.Vars(r)
233 commandNameParam := params["commandName"]
234 devstateApplyCommandCommandNamePatchRequestParam := DevstateApplyCommandCommandNamePatchRequest{}
235 d := json.NewDecoder(r.Body)
236 d.DisallowUnknownFields()
237 if err := d.Decode(&devstateApplyCommandCommandNamePatchRequestParam); err != nil {
238 c.errorHandler(w, r, &ParsingError{Err: err}, nil)
239 return
240 }
241 if err := AssertDevstateApplyCommandCommandNamePatchRequestRequired(devstateApplyCommandCommandNamePatchRequestParam); err != nil {
242 c.errorHandler(w, r, err, nil)
243 return
244 }
245 result, err := c.service.DevstateApplyCommandCommandNamePatch(r.Context(), commandNameParam, devstateApplyCommandCommandNamePatchRequestParam)
246
247 if err != nil {
248 c.errorHandler(w, r, err, &result)
249 return
250 }
251
252 EncodeJSONResponse(result.Body, &result.Code, w)
253
254 }
255
256
257 func (c *DevstateApiController) DevstateApplyCommandPost(w http.ResponseWriter, r *http.Request) {
258 devstateApplyCommandPostRequestParam := DevstateApplyCommandPostRequest{}
259 d := json.NewDecoder(r.Body)
260 d.DisallowUnknownFields()
261 if err := d.Decode(&devstateApplyCommandPostRequestParam); err != nil {
262 c.errorHandler(w, r, &ParsingError{Err: err}, nil)
263 return
264 }
265 if err := AssertDevstateApplyCommandPostRequestRequired(devstateApplyCommandPostRequestParam); err != nil {
266 c.errorHandler(w, r, err, nil)
267 return
268 }
269 result, err := c.service.DevstateApplyCommandPost(r.Context(), devstateApplyCommandPostRequestParam)
270
271 if err != nil {
272 c.errorHandler(w, r, err, &result)
273 return
274 }
275
276 EncodeJSONResponse(result.Body, &result.Code, w)
277
278 }
279
280
281 func (c *DevstateApiController) DevstateChartGet(w http.ResponseWriter, r *http.Request) {
282 result, err := c.service.DevstateChartGet(r.Context())
283
284 if err != nil {
285 c.errorHandler(w, r, err, &result)
286 return
287 }
288
289 EncodeJSONResponse(result.Body, &result.Code, w)
290
291 }
292
293
294 func (c *DevstateApiController) DevstateCommandCommandNameDelete(w http.ResponseWriter, r *http.Request) {
295 params := mux.Vars(r)
296 commandNameParam := params["commandName"]
297 result, err := c.service.DevstateCommandCommandNameDelete(r.Context(), commandNameParam)
298
299 if err != nil {
300 c.errorHandler(w, r, err, &result)
301 return
302 }
303
304 EncodeJSONResponse(result.Body, &result.Code, w)
305
306 }
307
308
309 func (c *DevstateApiController) DevstateCommandCommandNameMovePost(w http.ResponseWriter, r *http.Request) {
310 params := mux.Vars(r)
311 commandNameParam := params["commandName"]
312 devstateCommandCommandNameMovePostRequestParam := DevstateCommandCommandNameMovePostRequest{}
313 d := json.NewDecoder(r.Body)
314 d.DisallowUnknownFields()
315 if err := d.Decode(&devstateCommandCommandNameMovePostRequestParam); err != nil {
316 c.errorHandler(w, r, &ParsingError{Err: err}, nil)
317 return
318 }
319 if err := AssertDevstateCommandCommandNameMovePostRequestRequired(devstateCommandCommandNameMovePostRequestParam); err != nil {
320 c.errorHandler(w, r, err, nil)
321 return
322 }
323 result, err := c.service.DevstateCommandCommandNameMovePost(r.Context(), commandNameParam, devstateCommandCommandNameMovePostRequestParam)
324
325 if err != nil {
326 c.errorHandler(w, r, err, &result)
327 return
328 }
329
330 EncodeJSONResponse(result.Body, &result.Code, w)
331
332 }
333
334
335 func (c *DevstateApiController) DevstateCommandCommandNameSetDefaultPost(w http.ResponseWriter, r *http.Request) {
336 params := mux.Vars(r)
337 commandNameParam := params["commandName"]
338 devstateCommandCommandNameSetDefaultPostRequestParam := DevstateCommandCommandNameSetDefaultPostRequest{}
339 d := json.NewDecoder(r.Body)
340 d.DisallowUnknownFields()
341 if err := d.Decode(&devstateCommandCommandNameSetDefaultPostRequestParam); err != nil {
342 c.errorHandler(w, r, &ParsingError{Err: err}, nil)
343 return
344 }
345 if err := AssertDevstateCommandCommandNameSetDefaultPostRequestRequired(devstateCommandCommandNameSetDefaultPostRequestParam); err != nil {
346 c.errorHandler(w, r, err, nil)
347 return
348 }
349 result, err := c.service.DevstateCommandCommandNameSetDefaultPost(r.Context(), commandNameParam, devstateCommandCommandNameSetDefaultPostRequestParam)
350
351 if err != nil {
352 c.errorHandler(w, r, err, &result)
353 return
354 }
355
356 EncodeJSONResponse(result.Body, &result.Code, w)
357
358 }
359
360
361 func (c *DevstateApiController) DevstateCommandCommandNameUnsetDefaultPost(w http.ResponseWriter, r *http.Request) {
362 params := mux.Vars(r)
363 commandNameParam := params["commandName"]
364 result, err := c.service.DevstateCommandCommandNameUnsetDefaultPost(r.Context(), commandNameParam)
365
366 if err != nil {
367 c.errorHandler(w, r, err, &result)
368 return
369 }
370
371 EncodeJSONResponse(result.Body, &result.Code, w)
372
373 }
374
375
376 func (c *DevstateApiController) DevstateCompositeCommandCommandNamePatch(w http.ResponseWriter, r *http.Request) {
377 params := mux.Vars(r)
378 commandNameParam := params["commandName"]
379 devstateCompositeCommandCommandNamePatchRequestParam := DevstateCompositeCommandCommandNamePatchRequest{}
380 d := json.NewDecoder(r.Body)
381 d.DisallowUnknownFields()
382 if err := d.Decode(&devstateCompositeCommandCommandNamePatchRequestParam); err != nil {
383 c.errorHandler(w, r, &ParsingError{Err: err}, nil)
384 return
385 }
386 if err := AssertDevstateCompositeCommandCommandNamePatchRequestRequired(devstateCompositeCommandCommandNamePatchRequestParam); err != nil {
387 c.errorHandler(w, r, err, nil)
388 return
389 }
390 result, err := c.service.DevstateCompositeCommandCommandNamePatch(r.Context(), commandNameParam, devstateCompositeCommandCommandNamePatchRequestParam)
391
392 if err != nil {
393 c.errorHandler(w, r, err, &result)
394 return
395 }
396
397 EncodeJSONResponse(result.Body, &result.Code, w)
398
399 }
400
401
402 func (c *DevstateApiController) DevstateCompositeCommandPost(w http.ResponseWriter, r *http.Request) {
403 devstateCompositeCommandPostRequestParam := DevstateCompositeCommandPostRequest{}
404 d := json.NewDecoder(r.Body)
405 d.DisallowUnknownFields()
406 if err := d.Decode(&devstateCompositeCommandPostRequestParam); err != nil {
407 c.errorHandler(w, r, &ParsingError{Err: err}, nil)
408 return
409 }
410 if err := AssertDevstateCompositeCommandPostRequestRequired(devstateCompositeCommandPostRequestParam); err != nil {
411 c.errorHandler(w, r, err, nil)
412 return
413 }
414 result, err := c.service.DevstateCompositeCommandPost(r.Context(), devstateCompositeCommandPostRequestParam)
415
416 if err != nil {
417 c.errorHandler(w, r, err, &result)
418 return
419 }
420
421 EncodeJSONResponse(result.Body, &result.Code, w)
422
423 }
424
425
426 func (c *DevstateApiController) DevstateContainerContainerNameDelete(w http.ResponseWriter, r *http.Request) {
427 params := mux.Vars(r)
428 containerNameParam := params["containerName"]
429 result, err := c.service.DevstateContainerContainerNameDelete(r.Context(), containerNameParam)
430
431 if err != nil {
432 c.errorHandler(w, r, err, &result)
433 return
434 }
435
436 EncodeJSONResponse(result.Body, &result.Code, w)
437
438 }
439
440
441 func (c *DevstateApiController) DevstateContainerContainerNamePatch(w http.ResponseWriter, r *http.Request) {
442 params := mux.Vars(r)
443 containerNameParam := params["containerName"]
444 devstateContainerContainerNamePatchRequestParam := DevstateContainerContainerNamePatchRequest{}
445 d := json.NewDecoder(r.Body)
446 d.DisallowUnknownFields()
447 if err := d.Decode(&devstateContainerContainerNamePatchRequestParam); err != nil {
448 c.errorHandler(w, r, &ParsingError{Err: err}, nil)
449 return
450 }
451 if err := AssertDevstateContainerContainerNamePatchRequestRequired(devstateContainerContainerNamePatchRequestParam); err != nil {
452 c.errorHandler(w, r, err, nil)
453 return
454 }
455 result, err := c.service.DevstateContainerContainerNamePatch(r.Context(), containerNameParam, devstateContainerContainerNamePatchRequestParam)
456
457 if err != nil {
458 c.errorHandler(w, r, err, &result)
459 return
460 }
461
462 EncodeJSONResponse(result.Body, &result.Code, w)
463
464 }
465
466
467 func (c *DevstateApiController) DevstateContainerPost(w http.ResponseWriter, r *http.Request) {
468 devstateContainerPostRequestParam := DevstateContainerPostRequest{}
469 d := json.NewDecoder(r.Body)
470 d.DisallowUnknownFields()
471 if err := d.Decode(&devstateContainerPostRequestParam); err != nil {
472 c.errorHandler(w, r, &ParsingError{Err: err}, nil)
473 return
474 }
475 if err := AssertDevstateContainerPostRequestRequired(devstateContainerPostRequestParam); err != nil {
476 c.errorHandler(w, r, err, nil)
477 return
478 }
479 result, err := c.service.DevstateContainerPost(r.Context(), devstateContainerPostRequestParam)
480
481 if err != nil {
482 c.errorHandler(w, r, err, &result)
483 return
484 }
485
486 EncodeJSONResponse(result.Body, &result.Code, w)
487
488 }
489
490
491 func (c *DevstateApiController) DevstateDevfileDelete(w http.ResponseWriter, r *http.Request) {
492 result, err := c.service.DevstateDevfileDelete(r.Context())
493
494 if err != nil {
495 c.errorHandler(w, r, err, &result)
496 return
497 }
498
499 EncodeJSONResponse(result.Body, &result.Code, w)
500
501 }
502
503
504 func (c *DevstateApiController) DevstateDevfileGet(w http.ResponseWriter, r *http.Request) {
505 result, err := c.service.DevstateDevfileGet(r.Context())
506
507 if err != nil {
508 c.errorHandler(w, r, err, &result)
509 return
510 }
511
512 EncodeJSONResponse(result.Body, &result.Code, w)
513
514 }
515
516
517 func (c *DevstateApiController) DevstateDevfilePut(w http.ResponseWriter, r *http.Request) {
518 devstateDevfilePutRequestParam := DevstateDevfilePutRequest{}
519 d := json.NewDecoder(r.Body)
520 d.DisallowUnknownFields()
521 if err := d.Decode(&devstateDevfilePutRequestParam); err != nil {
522 c.errorHandler(w, r, &ParsingError{Err: err}, nil)
523 return
524 }
525 if err := AssertDevstateDevfilePutRequestRequired(devstateDevfilePutRequestParam); err != nil {
526 c.errorHandler(w, r, err, nil)
527 return
528 }
529 result, err := c.service.DevstateDevfilePut(r.Context(), devstateDevfilePutRequestParam)
530
531 if err != nil {
532 c.errorHandler(w, r, err, &result)
533 return
534 }
535
536 EncodeJSONResponse(result.Body, &result.Code, w)
537
538 }
539
540
541 func (c *DevstateApiController) DevstateEventsPut(w http.ResponseWriter, r *http.Request) {
542 devstateEventsPutRequestParam := DevstateEventsPutRequest{}
543 d := json.NewDecoder(r.Body)
544 d.DisallowUnknownFields()
545 if err := d.Decode(&devstateEventsPutRequestParam); err != nil {
546 c.errorHandler(w, r, &ParsingError{Err: err}, nil)
547 return
548 }
549 if err := AssertDevstateEventsPutRequestRequired(devstateEventsPutRequestParam); err != nil {
550 c.errorHandler(w, r, err, nil)
551 return
552 }
553 result, err := c.service.DevstateEventsPut(r.Context(), devstateEventsPutRequestParam)
554
555 if err != nil {
556 c.errorHandler(w, r, err, &result)
557 return
558 }
559
560 EncodeJSONResponse(result.Body, &result.Code, w)
561
562 }
563
564
565 func (c *DevstateApiController) DevstateExecCommandCommandNamePatch(w http.ResponseWriter, r *http.Request) {
566 params := mux.Vars(r)
567 commandNameParam := params["commandName"]
568 devstateExecCommandCommandNamePatchRequestParam := DevstateExecCommandCommandNamePatchRequest{}
569 d := json.NewDecoder(r.Body)
570 d.DisallowUnknownFields()
571 if err := d.Decode(&devstateExecCommandCommandNamePatchRequestParam); err != nil {
572 c.errorHandler(w, r, &ParsingError{Err: err}, nil)
573 return
574 }
575 if err := AssertDevstateExecCommandCommandNamePatchRequestRequired(devstateExecCommandCommandNamePatchRequestParam); err != nil {
576 c.errorHandler(w, r, err, nil)
577 return
578 }
579 result, err := c.service.DevstateExecCommandCommandNamePatch(r.Context(), commandNameParam, devstateExecCommandCommandNamePatchRequestParam)
580
581 if err != nil {
582 c.errorHandler(w, r, err, &result)
583 return
584 }
585
586 EncodeJSONResponse(result.Body, &result.Code, w)
587
588 }
589
590
591 func (c *DevstateApiController) DevstateExecCommandPost(w http.ResponseWriter, r *http.Request) {
592 devstateExecCommandPostRequestParam := DevstateExecCommandPostRequest{}
593 d := json.NewDecoder(r.Body)
594 d.DisallowUnknownFields()
595 if err := d.Decode(&devstateExecCommandPostRequestParam); err != nil {
596 c.errorHandler(w, r, &ParsingError{Err: err}, nil)
597 return
598 }
599 if err := AssertDevstateExecCommandPostRequestRequired(devstateExecCommandPostRequestParam); err != nil {
600 c.errorHandler(w, r, err, nil)
601 return
602 }
603 result, err := c.service.DevstateExecCommandPost(r.Context(), devstateExecCommandPostRequestParam)
604
605 if err != nil {
606 c.errorHandler(w, r, err, &result)
607 return
608 }
609
610 EncodeJSONResponse(result.Body, &result.Code, w)
611
612 }
613
614
615 func (c *DevstateApiController) DevstateImageImageNameDelete(w http.ResponseWriter, r *http.Request) {
616 params := mux.Vars(r)
617 imageNameParam := params["imageName"]
618 result, err := c.service.DevstateImageImageNameDelete(r.Context(), imageNameParam)
619
620 if err != nil {
621 c.errorHandler(w, r, err, &result)
622 return
623 }
624
625 EncodeJSONResponse(result.Body, &result.Code, w)
626
627 }
628
629
630 func (c *DevstateApiController) DevstateImageImageNamePatch(w http.ResponseWriter, r *http.Request) {
631 params := mux.Vars(r)
632 imageNameParam := params["imageName"]
633 devstateImageImageNamePatchRequestParam := DevstateImageImageNamePatchRequest{}
634 d := json.NewDecoder(r.Body)
635 d.DisallowUnknownFields()
636 if err := d.Decode(&devstateImageImageNamePatchRequestParam); err != nil {
637 c.errorHandler(w, r, &ParsingError{Err: err}, nil)
638 return
639 }
640 if err := AssertDevstateImageImageNamePatchRequestRequired(devstateImageImageNamePatchRequestParam); err != nil {
641 c.errorHandler(w, r, err, nil)
642 return
643 }
644 result, err := c.service.DevstateImageImageNamePatch(r.Context(), imageNameParam, devstateImageImageNamePatchRequestParam)
645
646 if err != nil {
647 c.errorHandler(w, r, err, &result)
648 return
649 }
650
651 EncodeJSONResponse(result.Body, &result.Code, w)
652
653 }
654
655
656 func (c *DevstateApiController) DevstateImagePost(w http.ResponseWriter, r *http.Request) {
657 devstateImagePostRequestParam := DevstateImagePostRequest{}
658 d := json.NewDecoder(r.Body)
659 d.DisallowUnknownFields()
660 if err := d.Decode(&devstateImagePostRequestParam); err != nil {
661 c.errorHandler(w, r, &ParsingError{Err: err}, nil)
662 return
663 }
664 if err := AssertDevstateImagePostRequestRequired(devstateImagePostRequestParam); err != nil {
665 c.errorHandler(w, r, err, nil)
666 return
667 }
668 result, err := c.service.DevstateImagePost(r.Context(), devstateImagePostRequestParam)
669
670 if err != nil {
671 c.errorHandler(w, r, err, &result)
672 return
673 }
674
675 EncodeJSONResponse(result.Body, &result.Code, w)
676
677 }
678
679
680 func (c *DevstateApiController) DevstateMetadataPut(w http.ResponseWriter, r *http.Request) {
681 metadataRequestParam := MetadataRequest{}
682 d := json.NewDecoder(r.Body)
683 d.DisallowUnknownFields()
684 if err := d.Decode(&metadataRequestParam); err != nil {
685 c.errorHandler(w, r, &ParsingError{Err: err}, nil)
686 return
687 }
688 if err := AssertMetadataRequestRequired(metadataRequestParam); err != nil {
689 c.errorHandler(w, r, err, nil)
690 return
691 }
692 result, err := c.service.DevstateMetadataPut(r.Context(), metadataRequestParam)
693
694 if err != nil {
695 c.errorHandler(w, r, err, &result)
696 return
697 }
698
699 EncodeJSONResponse(result.Body, &result.Code, w)
700
701 }
702
703
704 func (c *DevstateApiController) DevstateQuantityValidPost(w http.ResponseWriter, r *http.Request) {
705 devstateQuantityValidPostRequestParam := DevstateQuantityValidPostRequest{}
706 d := json.NewDecoder(r.Body)
707 d.DisallowUnknownFields()
708 if err := d.Decode(&devstateQuantityValidPostRequestParam); err != nil {
709 c.errorHandler(w, r, &ParsingError{Err: err}, nil)
710 return
711 }
712 if err := AssertDevstateQuantityValidPostRequestRequired(devstateQuantityValidPostRequestParam); err != nil {
713 c.errorHandler(w, r, err, nil)
714 return
715 }
716 result, err := c.service.DevstateQuantityValidPost(r.Context(), devstateQuantityValidPostRequestParam)
717
718 if err != nil {
719 c.errorHandler(w, r, err, &result)
720 return
721 }
722
723 EncodeJSONResponse(result.Body, &result.Code, w)
724
725 }
726
727
728 func (c *DevstateApiController) DevstateResourcePost(w http.ResponseWriter, r *http.Request) {
729 devstateResourcePostRequestParam := DevstateResourcePostRequest{}
730 d := json.NewDecoder(r.Body)
731 d.DisallowUnknownFields()
732 if err := d.Decode(&devstateResourcePostRequestParam); err != nil {
733 c.errorHandler(w, r, &ParsingError{Err: err}, nil)
734 return
735 }
736 if err := AssertDevstateResourcePostRequestRequired(devstateResourcePostRequestParam); err != nil {
737 c.errorHandler(w, r, err, nil)
738 return
739 }
740 result, err := c.service.DevstateResourcePost(r.Context(), devstateResourcePostRequestParam)
741
742 if err != nil {
743 c.errorHandler(w, r, err, &result)
744 return
745 }
746
747 EncodeJSONResponse(result.Body, &result.Code, w)
748
749 }
750
751
752 func (c *DevstateApiController) DevstateResourceResourceNameDelete(w http.ResponseWriter, r *http.Request) {
753 params := mux.Vars(r)
754 resourceNameParam := params["resourceName"]
755 result, err := c.service.DevstateResourceResourceNameDelete(r.Context(), resourceNameParam)
756
757 if err != nil {
758 c.errorHandler(w, r, err, &result)
759 return
760 }
761
762 EncodeJSONResponse(result.Body, &result.Code, w)
763
764 }
765
766
767 func (c *DevstateApiController) DevstateResourceResourceNamePatch(w http.ResponseWriter, r *http.Request) {
768 params := mux.Vars(r)
769 resourceNameParam := params["resourceName"]
770 devstateResourceResourceNamePatchRequestParam := DevstateResourceResourceNamePatchRequest{}
771 d := json.NewDecoder(r.Body)
772 d.DisallowUnknownFields()
773 if err := d.Decode(&devstateResourceResourceNamePatchRequestParam); err != nil {
774 c.errorHandler(w, r, &ParsingError{Err: err}, nil)
775 return
776 }
777 if err := AssertDevstateResourceResourceNamePatchRequestRequired(devstateResourceResourceNamePatchRequestParam); err != nil {
778 c.errorHandler(w, r, err, nil)
779 return
780 }
781 result, err := c.service.DevstateResourceResourceNamePatch(r.Context(), resourceNameParam, devstateResourceResourceNamePatchRequestParam)
782
783 if err != nil {
784 c.errorHandler(w, r, err, &result)
785 return
786 }
787
788 EncodeJSONResponse(result.Body, &result.Code, w)
789
790 }
791
792
793 func (c *DevstateApiController) DevstateVolumePost(w http.ResponseWriter, r *http.Request) {
794 devstateVolumePostRequestParam := DevstateVolumePostRequest{}
795 d := json.NewDecoder(r.Body)
796 d.DisallowUnknownFields()
797 if err := d.Decode(&devstateVolumePostRequestParam); err != nil {
798 c.errorHandler(w, r, &ParsingError{Err: err}, nil)
799 return
800 }
801 if err := AssertDevstateVolumePostRequestRequired(devstateVolumePostRequestParam); err != nil {
802 c.errorHandler(w, r, err, nil)
803 return
804 }
805 result, err := c.service.DevstateVolumePost(r.Context(), devstateVolumePostRequestParam)
806
807 if err != nil {
808 c.errorHandler(w, r, err, &result)
809 return
810 }
811
812 EncodeJSONResponse(result.Body, &result.Code, w)
813
814 }
815
816
817 func (c *DevstateApiController) DevstateVolumeVolumeNameDelete(w http.ResponseWriter, r *http.Request) {
818 params := mux.Vars(r)
819 volumeNameParam := params["volumeName"]
820 result, err := c.service.DevstateVolumeVolumeNameDelete(r.Context(), volumeNameParam)
821
822 if err != nil {
823 c.errorHandler(w, r, err, &result)
824 return
825 }
826
827 EncodeJSONResponse(result.Body, &result.Code, w)
828
829 }
830
831
832 func (c *DevstateApiController) DevstateVolumeVolumeNamePatch(w http.ResponseWriter, r *http.Request) {
833 params := mux.Vars(r)
834 volumeNameParam := params["volumeName"]
835 devstateVolumeVolumeNamePatchRequestParam := DevstateVolumeVolumeNamePatchRequest{}
836 d := json.NewDecoder(r.Body)
837 d.DisallowUnknownFields()
838 if err := d.Decode(&devstateVolumeVolumeNamePatchRequestParam); err != nil {
839 c.errorHandler(w, r, &ParsingError{Err: err}, nil)
840 return
841 }
842 if err := AssertDevstateVolumeVolumeNamePatchRequestRequired(devstateVolumeVolumeNamePatchRequestParam); err != nil {
843 c.errorHandler(w, r, err, nil)
844 return
845 }
846 result, err := c.service.DevstateVolumeVolumeNamePatch(r.Context(), volumeNameParam, devstateVolumeVolumeNamePatchRequestParam)
847
848 if err != nil {
849 c.errorHandler(w, r, err, &result)
850 return
851 }
852
853 EncodeJSONResponse(result.Body, &result.Code, w)
854
855 }
856
View as plain text