github.com/circl-dev/go-swagger@v0.31.0/examples/task-tracker/client/tasks/delete_task_responses.go (about) 1 // Code generated by go-swagger; DO NOT EDIT. 2 3 package tasks 4 5 // This file was generated by the swagger tool. 6 // Editing this file might prove futile when you re-run the swagger generate command 7 8 import ( 9 "fmt" 10 "io" 11 12 "github.com/go-openapi/strfmt" 13 "github.com/circl-dev/runtime" 14 15 "github.com/circl-dev/go-swagger/examples/task-tracker/models" 16 ) 17 18 // DeleteTaskReader is a Reader for the DeleteTask structure. 19 type DeleteTaskReader struct { 20 formats strfmt.Registry 21 } 22 23 // ReadResponse reads a server response into the received o. 24 func (o *DeleteTaskReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) { 25 switch response.Code() { 26 case 204: 27 result := NewDeleteTaskNoContent() 28 if err := result.readResponse(response, consumer, o.formats); err != nil { 29 return nil, err 30 } 31 return result, nil 32 default: 33 result := NewDeleteTaskDefault(response.Code()) 34 if err := result.readResponse(response, consumer, o.formats); err != nil { 35 return nil, err 36 } 37 if response.Code()/100 == 2 { 38 return result, nil 39 } 40 return nil, result 41 } 42 } 43 44 // NewDeleteTaskNoContent creates a DeleteTaskNoContent with default headers values 45 func NewDeleteTaskNoContent() *DeleteTaskNoContent { 46 return &DeleteTaskNoContent{} 47 } 48 49 /* DeleteTaskNoContent describes a response with status code 204, with default header values. 50 51 Task deleted 52 */ 53 type DeleteTaskNoContent struct { 54 } 55 56 func (o *DeleteTaskNoContent) Error() string { 57 return fmt.Sprintf("[DELETE /tasks/{id}][%d] deleteTaskNoContent ", 204) 58 } 59 60 func (o *DeleteTaskNoContent) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { 61 62 return nil 63 } 64 65 // NewDeleteTaskDefault creates a DeleteTaskDefault with default headers values 66 func NewDeleteTaskDefault(code int) *DeleteTaskDefault { 67 return &DeleteTaskDefault{ 68 _statusCode: code, 69 } 70 } 71 72 /* DeleteTaskDefault describes a response with status code -1, with default header values. 73 74 Error response 75 */ 76 type DeleteTaskDefault struct { 77 _statusCode int 78 XErrorCode string 79 80 Payload *models.Error 81 } 82 83 // Code gets the status code for the delete task default response 84 func (o *DeleteTaskDefault) Code() int { 85 return o._statusCode 86 } 87 88 func (o *DeleteTaskDefault) Error() string { 89 return fmt.Sprintf("[DELETE /tasks/{id}][%d] deleteTask default %+v", o._statusCode, o.Payload) 90 } 91 func (o *DeleteTaskDefault) GetPayload() *models.Error { 92 return o.Payload 93 } 94 95 func (o *DeleteTaskDefault) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { 96 97 // hydrates response header X-Error-Code 98 hdrXErrorCode := response.GetHeader("X-Error-Code") 99 100 if hdrXErrorCode != "" { 101 o.XErrorCode = hdrXErrorCode 102 } 103 104 o.Payload = new(models.Error) 105 106 // response payload 107 if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { 108 return err 109 } 110 111 return nil 112 }