github.com/josephspurrier/go-swagger@v0.2.1-0.20221129144919-1f672a142a00/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 returns 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 returns 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 returns 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 returns 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 returns a 4xx status code 94 func (o *ListTasksOK) IsCode(code int) bool { 95 return code == 200 96 } 97 98 func (o *ListTasksOK) Error() string { 99 return fmt.Sprintf("[GET /tasks][%d] listTasksOK %+v", 200, o.Payload) 100 } 101 102 func (o *ListTasksOK) String() string { 103 return fmt.Sprintf("[GET /tasks][%d] listTasksOK %+v", 200, o.Payload) 104 } 105 106 func (o *ListTasksOK) GetPayload() []*models.TaskCard { 107 return o.Payload 108 } 109 110 func (o *ListTasksOK) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { 111 112 // hydrates response header X-Last-Task-Id 113 hdrXLastTaskID := response.GetHeader("X-Last-Task-Id") 114 115 if hdrXLastTaskID != "" { 116 valxLastTaskId, err := swag.ConvertInt64(hdrXLastTaskID) 117 if err != nil { 118 return errors.InvalidType("X-Last-Task-Id", "header", "int64", hdrXLastTaskID) 119 } 120 o.XLastTaskID = valxLastTaskId 121 } 122 123 // response payload 124 if err := consumer.Consume(response.Body(), &o.Payload); err != nil && err != io.EOF { 125 return err 126 } 127 128 return nil 129 } 130 131 // NewListTasksUnprocessableEntity creates a ListTasksUnprocessableEntity with default headers values 132 func NewListTasksUnprocessableEntity() *ListTasksUnprocessableEntity { 133 return &ListTasksUnprocessableEntity{} 134 } 135 136 /* 137 ListTasksUnprocessableEntity describes a response with status code 422, with default header values. 138 139 Validation error 140 */ 141 type ListTasksUnprocessableEntity struct { 142 Payload *models.ValidationError 143 } 144 145 // IsSuccess returns true when this list tasks unprocessable entity response returns a 2xx status code 146 func (o *ListTasksUnprocessableEntity) IsSuccess() bool { 147 return false 148 } 149 150 // IsRedirect returns true when this list tasks unprocessable entity response returns a 3xx status code 151 func (o *ListTasksUnprocessableEntity) IsRedirect() bool { 152 return false 153 } 154 155 // IsClientError returns true when this list tasks unprocessable entity response returns a 4xx status code 156 func (o *ListTasksUnprocessableEntity) IsClientError() bool { 157 return true 158 } 159 160 // IsServerError returns true when this list tasks unprocessable entity response returns a 5xx status code 161 func (o *ListTasksUnprocessableEntity) IsServerError() bool { 162 return false 163 } 164 165 // IsCode returns true when this list tasks unprocessable entity response returns a 4xx status code 166 func (o *ListTasksUnprocessableEntity) IsCode(code int) bool { 167 return code == 422 168 } 169 170 func (o *ListTasksUnprocessableEntity) Error() string { 171 return fmt.Sprintf("[GET /tasks][%d] listTasksUnprocessableEntity %+v", 422, o.Payload) 172 } 173 174 func (o *ListTasksUnprocessableEntity) String() string { 175 return fmt.Sprintf("[GET /tasks][%d] listTasksUnprocessableEntity %+v", 422, o.Payload) 176 } 177 178 func (o *ListTasksUnprocessableEntity) GetPayload() *models.ValidationError { 179 return o.Payload 180 } 181 182 func (o *ListTasksUnprocessableEntity) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { 183 184 o.Payload = new(models.ValidationError) 185 186 // response payload 187 if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { 188 return err 189 } 190 191 return nil 192 } 193 194 // NewListTasksDefault creates a ListTasksDefault with default headers values 195 func NewListTasksDefault(code int) *ListTasksDefault { 196 return &ListTasksDefault{ 197 _statusCode: code, 198 } 199 } 200 201 /* 202 ListTasksDefault describes a response with status code -1, with default header values. 203 204 Error response 205 */ 206 type ListTasksDefault struct { 207 _statusCode int 208 XErrorCode string 209 210 Payload *models.Error 211 } 212 213 // Code gets the status code for the list tasks default response 214 func (o *ListTasksDefault) Code() int { 215 return o._statusCode 216 } 217 218 // IsSuccess returns true when this list tasks default response returns a 2xx status code 219 func (o *ListTasksDefault) IsSuccess() bool { 220 return o._statusCode/100 == 2 221 } 222 223 // IsRedirect returns true when this list tasks default response returns a 3xx status code 224 func (o *ListTasksDefault) IsRedirect() bool { 225 return o._statusCode/100 == 3 226 } 227 228 // IsClientError returns true when this list tasks default response returns a 4xx status code 229 func (o *ListTasksDefault) IsClientError() bool { 230 return o._statusCode/100 == 4 231 } 232 233 // IsServerError returns true when this list tasks default response returns a 5xx status code 234 func (o *ListTasksDefault) IsServerError() bool { 235 return o._statusCode/100 == 5 236 } 237 238 // IsCode returns true when this list tasks default response returns a 4xx status code 239 func (o *ListTasksDefault) IsCode(code int) bool { 240 return o._statusCode == code 241 } 242 243 func (o *ListTasksDefault) Error() string { 244 return fmt.Sprintf("[GET /tasks][%d] listTasks default %+v", o._statusCode, o.Payload) 245 } 246 247 func (o *ListTasksDefault) String() string { 248 return fmt.Sprintf("[GET /tasks][%d] listTasks default %+v", o._statusCode, o.Payload) 249 } 250 251 func (o *ListTasksDefault) GetPayload() *models.Error { 252 return o.Payload 253 } 254 255 func (o *ListTasksDefault) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { 256 257 // hydrates response header X-Error-Code 258 hdrXErrorCode := response.GetHeader("X-Error-Code") 259 260 if hdrXErrorCode != "" { 261 o.XErrorCode = hdrXErrorCode 262 } 263 264 o.Payload = new(models.Error) 265 266 // response payload 267 if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { 268 return err 269 } 270 271 return nil 272 }