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