github.com/ffalor/go-swagger@v0.0.0-20231011000038-9f25265ac351/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/runtime" 13 "github.com/go-openapi/strfmt" 14 15 "github.com/go-swagger/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 /* 56 UpdateTaskOK describes a response with status code 200, with default header values. 57 58 Task details 59 */ 60 type UpdateTaskOK struct { 61 Payload *models.Task 62 } 63 64 // IsSuccess returns true when this update task o k response has a 2xx status code 65 func (o *UpdateTaskOK) IsSuccess() bool { 66 return true 67 } 68 69 // IsRedirect returns true when this update task o k response has a 3xx status code 70 func (o *UpdateTaskOK) IsRedirect() bool { 71 return false 72 } 73 74 // IsClientError returns true when this update task o k response has a 4xx status code 75 func (o *UpdateTaskOK) IsClientError() bool { 76 return false 77 } 78 79 // IsServerError returns true when this update task o k response has a 5xx status code 80 func (o *UpdateTaskOK) IsServerError() bool { 81 return false 82 } 83 84 // IsCode returns true when this update task o k response a status code equal to that given 85 func (o *UpdateTaskOK) IsCode(code int) bool { 86 return code == 200 87 } 88 89 // Code gets the status code for the update task o k response 90 func (o *UpdateTaskOK) Code() int { 91 return 200 92 } 93 94 func (o *UpdateTaskOK) Error() string { 95 return fmt.Sprintf("[PUT /tasks/{id}][%d] updateTaskOK %+v", 200, o.Payload) 96 } 97 98 func (o *UpdateTaskOK) String() string { 99 return fmt.Sprintf("[PUT /tasks/{id}][%d] updateTaskOK %+v", 200, o.Payload) 100 } 101 102 func (o *UpdateTaskOK) GetPayload() *models.Task { 103 return o.Payload 104 } 105 106 func (o *UpdateTaskOK) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { 107 108 o.Payload = new(models.Task) 109 110 // response payload 111 if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { 112 return err 113 } 114 115 return nil 116 } 117 118 // NewUpdateTaskUnprocessableEntity creates a UpdateTaskUnprocessableEntity with default headers values 119 func NewUpdateTaskUnprocessableEntity() *UpdateTaskUnprocessableEntity { 120 return &UpdateTaskUnprocessableEntity{} 121 } 122 123 /* 124 UpdateTaskUnprocessableEntity describes a response with status code 422, with default header values. 125 126 Validation error 127 */ 128 type UpdateTaskUnprocessableEntity struct { 129 Payload *models.ValidationError 130 } 131 132 // IsSuccess returns true when this update task unprocessable entity response has a 2xx status code 133 func (o *UpdateTaskUnprocessableEntity) IsSuccess() bool { 134 return false 135 } 136 137 // IsRedirect returns true when this update task unprocessable entity response has a 3xx status code 138 func (o *UpdateTaskUnprocessableEntity) IsRedirect() bool { 139 return false 140 } 141 142 // IsClientError returns true when this update task unprocessable entity response has a 4xx status code 143 func (o *UpdateTaskUnprocessableEntity) IsClientError() bool { 144 return true 145 } 146 147 // IsServerError returns true when this update task unprocessable entity response has a 5xx status code 148 func (o *UpdateTaskUnprocessableEntity) IsServerError() bool { 149 return false 150 } 151 152 // IsCode returns true when this update task unprocessable entity response a status code equal to that given 153 func (o *UpdateTaskUnprocessableEntity) IsCode(code int) bool { 154 return code == 422 155 } 156 157 // Code gets the status code for the update task unprocessable entity response 158 func (o *UpdateTaskUnprocessableEntity) Code() int { 159 return 422 160 } 161 162 func (o *UpdateTaskUnprocessableEntity) Error() string { 163 return fmt.Sprintf("[PUT /tasks/{id}][%d] updateTaskUnprocessableEntity %+v", 422, o.Payload) 164 } 165 166 func (o *UpdateTaskUnprocessableEntity) String() string { 167 return fmt.Sprintf("[PUT /tasks/{id}][%d] updateTaskUnprocessableEntity %+v", 422, o.Payload) 168 } 169 170 func (o *UpdateTaskUnprocessableEntity) GetPayload() *models.ValidationError { 171 return o.Payload 172 } 173 174 func (o *UpdateTaskUnprocessableEntity) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { 175 176 o.Payload = new(models.ValidationError) 177 178 // response payload 179 if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { 180 return err 181 } 182 183 return nil 184 } 185 186 // NewUpdateTaskDefault creates a UpdateTaskDefault with default headers values 187 func NewUpdateTaskDefault(code int) *UpdateTaskDefault { 188 return &UpdateTaskDefault{ 189 _statusCode: code, 190 } 191 } 192 193 /* 194 UpdateTaskDefault describes a response with status code -1, with default header values. 195 196 Error response 197 */ 198 type UpdateTaskDefault struct { 199 _statusCode int 200 XErrorCode string 201 202 Payload *models.Error 203 } 204 205 // IsSuccess returns true when this update task default response has a 2xx status code 206 func (o *UpdateTaskDefault) IsSuccess() bool { 207 return o._statusCode/100 == 2 208 } 209 210 // IsRedirect returns true when this update task default response has a 3xx status code 211 func (o *UpdateTaskDefault) IsRedirect() bool { 212 return o._statusCode/100 == 3 213 } 214 215 // IsClientError returns true when this update task default response has a 4xx status code 216 func (o *UpdateTaskDefault) IsClientError() bool { 217 return o._statusCode/100 == 4 218 } 219 220 // IsServerError returns true when this update task default response has a 5xx status code 221 func (o *UpdateTaskDefault) IsServerError() bool { 222 return o._statusCode/100 == 5 223 } 224 225 // IsCode returns true when this update task default response a status code equal to that given 226 func (o *UpdateTaskDefault) IsCode(code int) bool { 227 return o._statusCode == code 228 } 229 230 // Code gets the status code for the update task default response 231 func (o *UpdateTaskDefault) Code() int { 232 return o._statusCode 233 } 234 235 func (o *UpdateTaskDefault) Error() string { 236 return fmt.Sprintf("[PUT /tasks/{id}][%d] updateTask default %+v", o._statusCode, o.Payload) 237 } 238 239 func (o *UpdateTaskDefault) String() string { 240 return fmt.Sprintf("[PUT /tasks/{id}][%d] updateTask default %+v", o._statusCode, o.Payload) 241 } 242 243 func (o *UpdateTaskDefault) GetPayload() *models.Error { 244 return o.Payload 245 } 246 247 func (o *UpdateTaskDefault) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { 248 249 // hydrates response header X-Error-Code 250 hdrXErrorCode := response.GetHeader("X-Error-Code") 251 252 if hdrXErrorCode != "" { 253 o.XErrorCode = hdrXErrorCode 254 } 255 256 o.Payload = new(models.Error) 257 258 // response payload 259 if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { 260 return err 261 } 262 263 return nil 264 }