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