github.com/josephspurrier/go-swagger@v0.2.1-0.20221129144919-1f672a142a00/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 returns 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 returns 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 returns 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 returns 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 returns a 4xx status code 90 func (o *PetUpdateCreated) IsCode(code int) bool { 91 return code == 201 92 } 93 94 func (o *PetUpdateCreated) Error() string { 95 return fmt.Sprintf("[PUT /pet][%d] petUpdateCreated %+v", 201, o.Payload) 96 } 97 98 func (o *PetUpdateCreated) String() string { 99 return fmt.Sprintf("[PUT /pet][%d] petUpdateCreated %+v", 201, o.Payload) 100 } 101 102 func (o *PetUpdateCreated) GetPayload() *models.Pet { 103 return o.Payload 104 } 105 106 func (o *PetUpdateCreated) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { 107 108 o.Payload = new(models.Pet) 109 110 // response payload 111 if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { 112 return err 113 } 114 115 return nil 116 } 117 118 // NewPetUpdateBadRequest creates a PetUpdateBadRequest with default headers values 119 func NewPetUpdateBadRequest() *PetUpdateBadRequest { 120 return &PetUpdateBadRequest{} 121 } 122 123 /* 124 PetUpdateBadRequest describes a response with status code 400, with default header values. 125 126 Invalid ID supplied 127 */ 128 type PetUpdateBadRequest struct { 129 } 130 131 // IsSuccess returns true when this pet update bad request response returns a 2xx status code 132 func (o *PetUpdateBadRequest) IsSuccess() bool { 133 return false 134 } 135 136 // IsRedirect returns true when this pet update bad request response returns a 3xx status code 137 func (o *PetUpdateBadRequest) IsRedirect() bool { 138 return false 139 } 140 141 // IsClientError returns true when this pet update bad request response returns a 4xx status code 142 func (o *PetUpdateBadRequest) IsClientError() bool { 143 return true 144 } 145 146 // IsServerError returns true when this pet update bad request response returns a 5xx status code 147 func (o *PetUpdateBadRequest) IsServerError() bool { 148 return false 149 } 150 151 // IsCode returns true when this pet update bad request response returns a 4xx status code 152 func (o *PetUpdateBadRequest) IsCode(code int) bool { 153 return code == 400 154 } 155 156 func (o *PetUpdateBadRequest) Error() string { 157 return fmt.Sprintf("[PUT /pet][%d] petUpdateBadRequest ", 400) 158 } 159 160 func (o *PetUpdateBadRequest) String() string { 161 return fmt.Sprintf("[PUT /pet][%d] petUpdateBadRequest ", 400) 162 } 163 164 func (o *PetUpdateBadRequest) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { 165 166 return nil 167 } 168 169 // NewPetUpdateNotFound creates a PetUpdateNotFound with default headers values 170 func NewPetUpdateNotFound() *PetUpdateNotFound { 171 return &PetUpdateNotFound{} 172 } 173 174 /* 175 PetUpdateNotFound describes a response with status code 404, with default header values. 176 177 Pet not found 178 */ 179 type PetUpdateNotFound struct { 180 } 181 182 // IsSuccess returns true when this pet update not found response returns a 2xx status code 183 func (o *PetUpdateNotFound) IsSuccess() bool { 184 return false 185 } 186 187 // IsRedirect returns true when this pet update not found response returns a 3xx status code 188 func (o *PetUpdateNotFound) IsRedirect() bool { 189 return false 190 } 191 192 // IsClientError returns true when this pet update not found response returns a 4xx status code 193 func (o *PetUpdateNotFound) IsClientError() bool { 194 return true 195 } 196 197 // IsServerError returns true when this pet update not found response returns a 5xx status code 198 func (o *PetUpdateNotFound) IsServerError() bool { 199 return false 200 } 201 202 // IsCode returns true when this pet update not found response returns a 4xx status code 203 func (o *PetUpdateNotFound) IsCode(code int) bool { 204 return code == 404 205 } 206 207 func (o *PetUpdateNotFound) Error() string { 208 return fmt.Sprintf("[PUT /pet][%d] petUpdateNotFound ", 404) 209 } 210 211 func (o *PetUpdateNotFound) String() string { 212 return fmt.Sprintf("[PUT /pet][%d] petUpdateNotFound ", 404) 213 } 214 215 func (o *PetUpdateNotFound) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { 216 217 return nil 218 } 219 220 // NewPetUpdateMethodNotAllowed creates a PetUpdateMethodNotAllowed with default headers values 221 func NewPetUpdateMethodNotAllowed() *PetUpdateMethodNotAllowed { 222 return &PetUpdateMethodNotAllowed{} 223 } 224 225 /* 226 PetUpdateMethodNotAllowed describes a response with status code 405, with default header values. 227 228 Validation exception 229 */ 230 type PetUpdateMethodNotAllowed struct { 231 } 232 233 // IsSuccess returns true when this pet update method not allowed response returns a 2xx status code 234 func (o *PetUpdateMethodNotAllowed) IsSuccess() bool { 235 return false 236 } 237 238 // IsRedirect returns true when this pet update method not allowed response returns a 3xx status code 239 func (o *PetUpdateMethodNotAllowed) IsRedirect() bool { 240 return false 241 } 242 243 // IsClientError returns true when this pet update method not allowed response returns a 4xx status code 244 func (o *PetUpdateMethodNotAllowed) IsClientError() bool { 245 return true 246 } 247 248 // IsServerError returns true when this pet update method not allowed response returns a 5xx status code 249 func (o *PetUpdateMethodNotAllowed) IsServerError() bool { 250 return false 251 } 252 253 // IsCode returns true when this pet update method not allowed response returns a 4xx status code 254 func (o *PetUpdateMethodNotAllowed) IsCode(code int) bool { 255 return code == 405 256 } 257 258 func (o *PetUpdateMethodNotAllowed) Error() string { 259 return fmt.Sprintf("[PUT /pet][%d] petUpdateMethodNotAllowed ", 405) 260 } 261 262 func (o *PetUpdateMethodNotAllowed) String() string { 263 return fmt.Sprintf("[PUT /pet][%d] petUpdateMethodNotAllowed ", 405) 264 } 265 266 func (o *PetUpdateMethodNotAllowed) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { 267 268 return nil 269 }