github.com/circl-dev/go-swagger@v0.31.0/examples/task-tracker/client/tasks/update_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 // UpdateTaskReader is a Reader for the UpdateTask structure. 19 type UpdateTaskReader struct { 20 formats strfmt.Registry 21 } 22 23 // ReadResponse reads a server response into the received o. 24 func (o *UpdateTaskReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) { 25 switch response.Code() { 26 case 200: 27 result := NewUpdateTaskOK() 28 if err := result.readResponse(response, consumer, o.formats); err != nil { 29 return nil, err 30 } 31 return result, nil 32 case 422: 33 result := NewUpdateTaskUnprocessableEntity() 34 if err := result.readResponse(response, consumer, o.formats); err != nil { 35 return nil, err 36 } 37 return nil, result 38 default: 39 result := NewUpdateTaskDefault(response.Code()) 40 if err := result.readResponse(response, consumer, o.formats); err != nil { 41 return nil, err 42 } 43 if response.Code()/100 == 2 { 44 return result, nil 45 } 46 return nil, result 47 } 48 } 49 50 // NewUpdateTaskOK creates a UpdateTaskOK with default headers values 51 func NewUpdateTaskOK() *UpdateTaskOK { 52 return &UpdateTaskOK{} 53 } 54 55 /* UpdateTaskOK describes a response with status code 200, with default header values. 56 57 Task details 58 */ 59 type UpdateTaskOK struct { 60 Payload *models.Task 61 } 62 63 func (o *UpdateTaskOK) Error() string { 64 return fmt.Sprintf("[PUT /tasks/{id}][%d] updateTaskOK %+v", 200, o.Payload) 65 } 66 func (o *UpdateTaskOK) GetPayload() *models.Task { 67 return o.Payload 68 } 69 70 func (o *UpdateTaskOK) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { 71 72 o.Payload = new(models.Task) 73 74 // response payload 75 if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { 76 return err 77 } 78 79 return nil 80 } 81 82 // NewUpdateTaskUnprocessableEntity creates a UpdateTaskUnprocessableEntity with default headers values 83 func NewUpdateTaskUnprocessableEntity() *UpdateTaskUnprocessableEntity { 84 return &UpdateTaskUnprocessableEntity{} 85 } 86 87 /* UpdateTaskUnprocessableEntity describes a response with status code 422, with default header values. 88 89 Validation error 90 */ 91 type UpdateTaskUnprocessableEntity struct { 92 Payload *models.ValidationError 93 } 94 95 func (o *UpdateTaskUnprocessableEntity) Error() string { 96 return fmt.Sprintf("[PUT /tasks/{id}][%d] updateTaskUnprocessableEntity %+v", 422, o.Payload) 97 } 98 func (o *UpdateTaskUnprocessableEntity) GetPayload() *models.ValidationError { 99 return o.Payload 100 } 101 102 func (o *UpdateTaskUnprocessableEntity) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { 103 104 o.Payload = new(models.ValidationError) 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 } 113 114 // NewUpdateTaskDefault creates a UpdateTaskDefault with default headers values 115 func NewUpdateTaskDefault(code int) *UpdateTaskDefault { 116 return &UpdateTaskDefault{ 117 _statusCode: code, 118 } 119 } 120 121 /* UpdateTaskDefault describes a response with status code -1, with default header values. 122 123 Error response 124 */ 125 type UpdateTaskDefault struct { 126 _statusCode int 127 XErrorCode string 128 129 Payload *models.Error 130 } 131 132 // Code gets the status code for the update task default response 133 func (o *UpdateTaskDefault) Code() int { 134 return o._statusCode 135 } 136 137 func (o *UpdateTaskDefault) Error() string { 138 return fmt.Sprintf("[PUT /tasks/{id}][%d] updateTask default %+v", o._statusCode, o.Payload) 139 } 140 func (o *UpdateTaskDefault) GetPayload() *models.Error { 141 return o.Payload 142 } 143 144 func (o *UpdateTaskDefault) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { 145 146 // hydrates response header X-Error-Code 147 hdrXErrorCode := response.GetHeader("X-Error-Code") 148 149 if hdrXErrorCode != "" { 150 o.XErrorCode = hdrXErrorCode 151 } 152 153 o.Payload = new(models.Error) 154 155 // response payload 156 if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { 157 return err 158 } 159 160 return nil 161 }