github.com/ffalor/go-swagger@v0.0.0-20231011000038-9f25265ac351/examples/task-tracker/client/tasks/list_tasks_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/errors" 13 "github.com/go-openapi/runtime" 14 "github.com/go-openapi/strfmt" 15 "github.com/go-openapi/swag" 16 17 "github.com/go-swagger/go-swagger/examples/task-tracker/models" 18 ) 19 20 // ListTasksReader is a Reader for the ListTasks structure. 21 type ListTasksReader struct { 22 formats strfmt.Registry 23 } 24 25 // ReadResponse reads a server response into the received o. 26 func (o *ListTasksReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) { 27 switch response.Code() { 28 case 200: 29 result := NewListTasksOK() 30 if err := result.readResponse(response, consumer, o.formats); err != nil { 31 return nil, err 32 } 33 return result, nil 34 case 422: 35 result := NewListTasksUnprocessableEntity() 36 if err := result.readResponse(response, consumer, o.formats); err != nil { 37 return nil, err 38 } 39 return nil, result 40 default: 41 result := NewListTasksDefault(response.Code()) 42 if err := result.readResponse(response, consumer, o.formats); err != nil { 43 return nil, err 44 } 45 if response.Code()/100 == 2 { 46 return result, nil 47 } 48 return nil, result 49 } 50 } 51 52 // NewListTasksOK creates a ListTasksOK with default headers values 53 func NewListTasksOK() *ListTasksOK { 54 return &ListTasksOK{} 55 } 56 57 /* 58 ListTasksOK describes a response with status code 200, with default header values. 59 60 Successful response 61 */ 62 type ListTasksOK struct { 63 64 /* the last task id known to the application 65 66 Format: int64 67 */ 68 XLastTaskID int64 69 70 Payload []*models.TaskCard 71 } 72 73 // IsSuccess returns true when this list tasks o k response has a 2xx status code 74 func (o *ListTasksOK) IsSuccess() bool { 75 return true 76 } 77 78 // IsRedirect returns true when this list tasks o k response has a 3xx status code 79 func (o *ListTasksOK) IsRedirect() bool { 80 return false 81 } 82 83 // IsClientError returns true when this list tasks o k response has a 4xx status code 84 func (o *ListTasksOK) IsClientError() bool { 85 return false 86 } 87 88 // IsServerError returns true when this list tasks o k response has a 5xx status code 89 func (o *ListTasksOK) IsServerError() bool { 90 return false 91 } 92 93 // IsCode returns true when this list tasks o k response a status code equal to that given 94 func (o *ListTasksOK) IsCode(code int) bool { 95 return code == 200 96 } 97 98 // Code gets the status code for the list tasks o k response 99 func (o *ListTasksOK) Code() int { 100 return 200 101 } 102 103 func (o *ListTasksOK) Error() string { 104 return fmt.Sprintf("[GET /tasks][%d] listTasksOK %+v", 200, o.Payload) 105 } 106 107 func (o *ListTasksOK) String() string { 108 return fmt.Sprintf("[GET /tasks][%d] listTasksOK %+v", 200, o.Payload) 109 } 110 111 func (o *ListTasksOK) GetPayload() []*models.TaskCard { 112 return o.Payload 113 } 114 115 func (o *ListTasksOK) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { 116 117 // hydrates response header X-Last-Task-Id 118 hdrXLastTaskID := response.GetHeader("X-Last-Task-Id") 119 120 if hdrXLastTaskID != "" { 121 valxLastTaskId, err := swag.ConvertInt64(hdrXLastTaskID) 122 if err != nil { 123 return errors.InvalidType("X-Last-Task-Id", "header", "int64", hdrXLastTaskID) 124 } 125 o.XLastTaskID = valxLastTaskId 126 } 127 128 // response payload 129 if err := consumer.Consume(response.Body(), &o.Payload); err != nil && err != io.EOF { 130 return err 131 } 132 133 return nil 134 } 135 136 // NewListTasksUnprocessableEntity creates a ListTasksUnprocessableEntity with default headers values 137 func NewListTasksUnprocessableEntity() *ListTasksUnprocessableEntity { 138 return &ListTasksUnprocessableEntity{} 139 } 140 141 /* 142 ListTasksUnprocessableEntity describes a response with status code 422, with default header values. 143 144 Validation error 145 */ 146 type ListTasksUnprocessableEntity struct { 147 Payload *models.ValidationError 148 } 149 150 // IsSuccess returns true when this list tasks unprocessable entity response has a 2xx status code 151 func (o *ListTasksUnprocessableEntity) IsSuccess() bool { 152 return false 153 } 154 155 // IsRedirect returns true when this list tasks unprocessable entity response has a 3xx status code 156 func (o *ListTasksUnprocessableEntity) IsRedirect() bool { 157 return false 158 } 159 160 // IsClientError returns true when this list tasks unprocessable entity response has a 4xx status code 161 func (o *ListTasksUnprocessableEntity) IsClientError() bool { 162 return true 163 } 164 165 // IsServerError returns true when this list tasks unprocessable entity response has a 5xx status code 166 func (o *ListTasksUnprocessableEntity) IsServerError() bool { 167 return false 168 } 169 170 // IsCode returns true when this list tasks unprocessable entity response a status code equal to that given 171 func (o *ListTasksUnprocessableEntity) IsCode(code int) bool { 172 return code == 422 173 } 174 175 // Code gets the status code for the list tasks unprocessable entity response 176 func (o *ListTasksUnprocessableEntity) Code() int { 177 return 422 178 } 179 180 func (o *ListTasksUnprocessableEntity) Error() string { 181 return fmt.Sprintf("[GET /tasks][%d] listTasksUnprocessableEntity %+v", 422, o.Payload) 182 } 183 184 func (o *ListTasksUnprocessableEntity) String() string { 185 return fmt.Sprintf("[GET /tasks][%d] listTasksUnprocessableEntity %+v", 422, o.Payload) 186 } 187 188 func (o *ListTasksUnprocessableEntity) GetPayload() *models.ValidationError { 189 return o.Payload 190 } 191 192 func (o *ListTasksUnprocessableEntity) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { 193 194 o.Payload = new(models.ValidationError) 195 196 // response payload 197 if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { 198 return err 199 } 200 201 return nil 202 } 203 204 // NewListTasksDefault creates a ListTasksDefault with default headers values 205 func NewListTasksDefault(code int) *ListTasksDefault { 206 return &ListTasksDefault{ 207 _statusCode: code, 208 } 209 } 210 211 /* 212 ListTasksDefault describes a response with status code -1, with default header values. 213 214 Error response 215 */ 216 type ListTasksDefault struct { 217 _statusCode int 218 XErrorCode string 219 220 Payload *models.Error 221 } 222 223 // IsSuccess returns true when this list tasks default response has a 2xx status code 224 func (o *ListTasksDefault) IsSuccess() bool { 225 return o._statusCode/100 == 2 226 } 227 228 // IsRedirect returns true when this list tasks default response has a 3xx status code 229 func (o *ListTasksDefault) IsRedirect() bool { 230 return o._statusCode/100 == 3 231 } 232 233 // IsClientError returns true when this list tasks default response has a 4xx status code 234 func (o *ListTasksDefault) IsClientError() bool { 235 return o._statusCode/100 == 4 236 } 237 238 // IsServerError returns true when this list tasks default response has a 5xx status code 239 func (o *ListTasksDefault) IsServerError() bool { 240 return o._statusCode/100 == 5 241 } 242 243 // IsCode returns true when this list tasks default response a status code equal to that given 244 func (o *ListTasksDefault) IsCode(code int) bool { 245 return o._statusCode == code 246 } 247 248 // Code gets the status code for the list tasks default response 249 func (o *ListTasksDefault) Code() int { 250 return o._statusCode 251 } 252 253 func (o *ListTasksDefault) Error() string { 254 return fmt.Sprintf("[GET /tasks][%d] listTasks default %+v", o._statusCode, o.Payload) 255 } 256 257 func (o *ListTasksDefault) String() string { 258 return fmt.Sprintf("[GET /tasks][%d] listTasks default %+v", o._statusCode, o.Payload) 259 } 260 261 func (o *ListTasksDefault) GetPayload() *models.Error { 262 return o.Payload 263 } 264 265 func (o *ListTasksDefault) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { 266 267 // hydrates response header X-Error-Code 268 hdrXErrorCode := response.GetHeader("X-Error-Code") 269 270 if hdrXErrorCode != "" { 271 o.XErrorCode = hdrXErrorCode 272 } 273 274 o.Payload = new(models.Error) 275 276 // response payload 277 if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { 278 return err 279 } 280 281 return nil 282 }