github.com/ffalor/go-swagger@v0.0.0-20231011000038-9f25265ac351/examples/contributed-templates/stratoscale/client/pet/pet_update_responses.go (about) 1 // Code generated by go-swagger; DO NOT EDIT. 2 3 package pet 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/contributed-templates/stratoscale/models" 16 ) 17 18 // PetUpdateReader is a Reader for the PetUpdate structure. 19 type PetUpdateReader struct { 20 formats strfmt.Registry 21 } 22 23 // ReadResponse reads a server response into the received o. 24 func (o *PetUpdateReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) { 25 switch response.Code() { 26 case 201: 27 result := NewPetUpdateCreated() 28 if err := result.readResponse(response, consumer, o.formats); err != nil { 29 return nil, err 30 } 31 return result, nil 32 case 400: 33 result := NewPetUpdateBadRequest() 34 if err := result.readResponse(response, consumer, o.formats); err != nil { 35 return nil, err 36 } 37 return nil, result 38 case 404: 39 result := NewPetUpdateNotFound() 40 if err := result.readResponse(response, consumer, o.formats); err != nil { 41 return nil, err 42 } 43 return nil, result 44 case 405: 45 result := NewPetUpdateMethodNotAllowed() 46 if err := result.readResponse(response, consumer, o.formats); err != nil { 47 return nil, err 48 } 49 return nil, result 50 default: 51 return nil, runtime.NewAPIError("response status code does not match any response statuses defined for this endpoint in the swagger spec", response, response.Code()) 52 } 53 } 54 55 // NewPetUpdateCreated creates a PetUpdateCreated with default headers values 56 func NewPetUpdateCreated() *PetUpdateCreated { 57 return &PetUpdateCreated{} 58 } 59 60 /* 61 PetUpdateCreated describes a response with status code 201, with default header values. 62 63 Updated successfully 64 */ 65 type PetUpdateCreated struct { 66 Payload *models.Pet 67 } 68 69 // IsSuccess returns true when this pet update created response has a 2xx status code 70 func (o *PetUpdateCreated) IsSuccess() bool { 71 return true 72 } 73 74 // IsRedirect returns true when this pet update created response has a 3xx status code 75 func (o *PetUpdateCreated) IsRedirect() bool { 76 return false 77 } 78 79 // IsClientError returns true when this pet update created response has a 4xx status code 80 func (o *PetUpdateCreated) IsClientError() bool { 81 return false 82 } 83 84 // IsServerError returns true when this pet update created response has a 5xx status code 85 func (o *PetUpdateCreated) IsServerError() bool { 86 return false 87 } 88 89 // IsCode returns true when this pet update created response a status code equal to that given 90 func (o *PetUpdateCreated) IsCode(code int) bool { 91 return code == 201 92 } 93 94 // Code gets the status code for the pet update created response 95 func (o *PetUpdateCreated) Code() int { 96 return 201 97 } 98 99 func (o *PetUpdateCreated) Error() string { 100 return fmt.Sprintf("[PUT /pet][%d] petUpdateCreated %+v", 201, o.Payload) 101 } 102 103 func (o *PetUpdateCreated) String() string { 104 return fmt.Sprintf("[PUT /pet][%d] petUpdateCreated %+v", 201, o.Payload) 105 } 106 107 func (o *PetUpdateCreated) GetPayload() *models.Pet { 108 return o.Payload 109 } 110 111 func (o *PetUpdateCreated) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { 112 113 o.Payload = new(models.Pet) 114 115 // response payload 116 if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { 117 return err 118 } 119 120 return nil 121 } 122 123 // NewPetUpdateBadRequest creates a PetUpdateBadRequest with default headers values 124 func NewPetUpdateBadRequest() *PetUpdateBadRequest { 125 return &PetUpdateBadRequest{} 126 } 127 128 /* 129 PetUpdateBadRequest describes a response with status code 400, with default header values. 130 131 Invalid ID supplied 132 */ 133 type PetUpdateBadRequest struct { 134 } 135 136 // IsSuccess returns true when this pet update bad request response has a 2xx status code 137 func (o *PetUpdateBadRequest) IsSuccess() bool { 138 return false 139 } 140 141 // IsRedirect returns true when this pet update bad request response has a 3xx status code 142 func (o *PetUpdateBadRequest) IsRedirect() bool { 143 return false 144 } 145 146 // IsClientError returns true when this pet update bad request response has a 4xx status code 147 func (o *PetUpdateBadRequest) IsClientError() bool { 148 return true 149 } 150 151 // IsServerError returns true when this pet update bad request response has a 5xx status code 152 func (o *PetUpdateBadRequest) IsServerError() bool { 153 return false 154 } 155 156 // IsCode returns true when this pet update bad request response a status code equal to that given 157 func (o *PetUpdateBadRequest) IsCode(code int) bool { 158 return code == 400 159 } 160 161 // Code gets the status code for the pet update bad request response 162 func (o *PetUpdateBadRequest) Code() int { 163 return 400 164 } 165 166 func (o *PetUpdateBadRequest) Error() string { 167 return fmt.Sprintf("[PUT /pet][%d] petUpdateBadRequest ", 400) 168 } 169 170 func (o *PetUpdateBadRequest) String() string { 171 return fmt.Sprintf("[PUT /pet][%d] petUpdateBadRequest ", 400) 172 } 173 174 func (o *PetUpdateBadRequest) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { 175 176 return nil 177 } 178 179 // NewPetUpdateNotFound creates a PetUpdateNotFound with default headers values 180 func NewPetUpdateNotFound() *PetUpdateNotFound { 181 return &PetUpdateNotFound{} 182 } 183 184 /* 185 PetUpdateNotFound describes a response with status code 404, with default header values. 186 187 Pet not found 188 */ 189 type PetUpdateNotFound struct { 190 } 191 192 // IsSuccess returns true when this pet update not found response has a 2xx status code 193 func (o *PetUpdateNotFound) IsSuccess() bool { 194 return false 195 } 196 197 // IsRedirect returns true when this pet update not found response has a 3xx status code 198 func (o *PetUpdateNotFound) IsRedirect() bool { 199 return false 200 } 201 202 // IsClientError returns true when this pet update not found response has a 4xx status code 203 func (o *PetUpdateNotFound) IsClientError() bool { 204 return true 205 } 206 207 // IsServerError returns true when this pet update not found response has a 5xx status code 208 func (o *PetUpdateNotFound) IsServerError() bool { 209 return false 210 } 211 212 // IsCode returns true when this pet update not found response a status code equal to that given 213 func (o *PetUpdateNotFound) IsCode(code int) bool { 214 return code == 404 215 } 216 217 // Code gets the status code for the pet update not found response 218 func (o *PetUpdateNotFound) Code() int { 219 return 404 220 } 221 222 func (o *PetUpdateNotFound) Error() string { 223 return fmt.Sprintf("[PUT /pet][%d] petUpdateNotFound ", 404) 224 } 225 226 func (o *PetUpdateNotFound) String() string { 227 return fmt.Sprintf("[PUT /pet][%d] petUpdateNotFound ", 404) 228 } 229 230 func (o *PetUpdateNotFound) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { 231 232 return nil 233 } 234 235 // NewPetUpdateMethodNotAllowed creates a PetUpdateMethodNotAllowed with default headers values 236 func NewPetUpdateMethodNotAllowed() *PetUpdateMethodNotAllowed { 237 return &PetUpdateMethodNotAllowed{} 238 } 239 240 /* 241 PetUpdateMethodNotAllowed describes a response with status code 405, with default header values. 242 243 Validation exception 244 */ 245 type PetUpdateMethodNotAllowed struct { 246 } 247 248 // IsSuccess returns true when this pet update method not allowed response has a 2xx status code 249 func (o *PetUpdateMethodNotAllowed) IsSuccess() bool { 250 return false 251 } 252 253 // IsRedirect returns true when this pet update method not allowed response has a 3xx status code 254 func (o *PetUpdateMethodNotAllowed) IsRedirect() bool { 255 return false 256 } 257 258 // IsClientError returns true when this pet update method not allowed response has a 4xx status code 259 func (o *PetUpdateMethodNotAllowed) IsClientError() bool { 260 return true 261 } 262 263 // IsServerError returns true when this pet update method not allowed response has a 5xx status code 264 func (o *PetUpdateMethodNotAllowed) IsServerError() bool { 265 return false 266 } 267 268 // IsCode returns true when this pet update method not allowed response a status code equal to that given 269 func (o *PetUpdateMethodNotAllowed) IsCode(code int) bool { 270 return code == 405 271 } 272 273 // Code gets the status code for the pet update method not allowed response 274 func (o *PetUpdateMethodNotAllowed) Code() int { 275 return 405 276 } 277 278 func (o *PetUpdateMethodNotAllowed) Error() string { 279 return fmt.Sprintf("[PUT /pet][%d] petUpdateMethodNotAllowed ", 405) 280 } 281 282 func (o *PetUpdateMethodNotAllowed) String() string { 283 return fmt.Sprintf("[PUT /pet][%d] petUpdateMethodNotAllowed ", 405) 284 } 285 286 func (o *PetUpdateMethodNotAllowed) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { 287 288 return nil 289 }