github.com/thetreep/go-swagger@v0.0.0-20240223100711-35af64f14f01/examples/contributed-templates/stratoscale/client/pet/pet_get_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 "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/contributed-templates/stratoscale/models" 17 ) 18 19 // PetGetReader is a Reader for the PetGet structure. 20 type PetGetReader struct { 21 formats strfmt.Registry 22 } 23 24 // ReadResponse reads a server response into the received o. 25 func (o *PetGetReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) { 26 switch response.Code() { 27 case 200: 28 result := NewPetGetOK() 29 if err := result.readResponse(response, consumer, o.formats); err != nil { 30 return nil, err 31 } 32 return result, nil 33 case 400: 34 result := NewPetGetBadRequest() 35 if err := result.readResponse(response, consumer, o.formats); err != nil { 36 return nil, err 37 } 38 return nil, result 39 case 404: 40 result := NewPetGetNotFound() 41 if err := result.readResponse(response, consumer, o.formats); err != nil { 42 return nil, err 43 } 44 return nil, result 45 default: 46 return nil, runtime.NewAPIError("[GET /pet/{petId}] PetGet", response, response.Code()) 47 } 48 } 49 50 // NewPetGetOK creates a PetGetOK with default headers values 51 func NewPetGetOK() *PetGetOK { 52 return &PetGetOK{} 53 } 54 55 /* 56 PetGetOK describes a response with status code 200, with default header values. 57 58 successful operation 59 */ 60 type PetGetOK struct { 61 Payload *models.Pet 62 } 63 64 // IsSuccess returns true when this pet get o k response has a 2xx status code 65 func (o *PetGetOK) IsSuccess() bool { 66 return true 67 } 68 69 // IsRedirect returns true when this pet get o k response has a 3xx status code 70 func (o *PetGetOK) IsRedirect() bool { 71 return false 72 } 73 74 // IsClientError returns true when this pet get o k response has a 4xx status code 75 func (o *PetGetOK) IsClientError() bool { 76 return false 77 } 78 79 // IsServerError returns true when this pet get o k response has a 5xx status code 80 func (o *PetGetOK) IsServerError() bool { 81 return false 82 } 83 84 // IsCode returns true when this pet get o k response a status code equal to that given 85 func (o *PetGetOK) IsCode(code int) bool { 86 return code == 200 87 } 88 89 // Code gets the status code for the pet get o k response 90 func (o *PetGetOK) Code() int { 91 return 200 92 } 93 94 func (o *PetGetOK) Error() string { 95 payload, _ := json.Marshal(o.Payload) 96 return fmt.Sprintf("[GET /pet/{petId}][%d] petGetOK %s", 200, payload) 97 } 98 99 func (o *PetGetOK) String() string { 100 payload, _ := json.Marshal(o.Payload) 101 return fmt.Sprintf("[GET /pet/{petId}][%d] petGetOK %s", 200, payload) 102 } 103 104 func (o *PetGetOK) GetPayload() *models.Pet { 105 return o.Payload 106 } 107 108 func (o *PetGetOK) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { 109 110 o.Payload = new(models.Pet) 111 112 // response payload 113 if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { 114 return err 115 } 116 117 return nil 118 } 119 120 // NewPetGetBadRequest creates a PetGetBadRequest with default headers values 121 func NewPetGetBadRequest() *PetGetBadRequest { 122 return &PetGetBadRequest{} 123 } 124 125 /* 126 PetGetBadRequest describes a response with status code 400, with default header values. 127 128 Invalid ID supplied 129 */ 130 type PetGetBadRequest struct { 131 } 132 133 // IsSuccess returns true when this pet get bad request response has a 2xx status code 134 func (o *PetGetBadRequest) IsSuccess() bool { 135 return false 136 } 137 138 // IsRedirect returns true when this pet get bad request response has a 3xx status code 139 func (o *PetGetBadRequest) IsRedirect() bool { 140 return false 141 } 142 143 // IsClientError returns true when this pet get bad request response has a 4xx status code 144 func (o *PetGetBadRequest) IsClientError() bool { 145 return true 146 } 147 148 // IsServerError returns true when this pet get bad request response has a 5xx status code 149 func (o *PetGetBadRequest) IsServerError() bool { 150 return false 151 } 152 153 // IsCode returns true when this pet get bad request response a status code equal to that given 154 func (o *PetGetBadRequest) IsCode(code int) bool { 155 return code == 400 156 } 157 158 // Code gets the status code for the pet get bad request response 159 func (o *PetGetBadRequest) Code() int { 160 return 400 161 } 162 163 func (o *PetGetBadRequest) Error() string { 164 return fmt.Sprintf("[GET /pet/{petId}][%d] petGetBadRequest", 400) 165 } 166 167 func (o *PetGetBadRequest) String() string { 168 return fmt.Sprintf("[GET /pet/{petId}][%d] petGetBadRequest", 400) 169 } 170 171 func (o *PetGetBadRequest) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { 172 173 return nil 174 } 175 176 // NewPetGetNotFound creates a PetGetNotFound with default headers values 177 func NewPetGetNotFound() *PetGetNotFound { 178 return &PetGetNotFound{} 179 } 180 181 /* 182 PetGetNotFound describes a response with status code 404, with default header values. 183 184 Pet not found 185 */ 186 type PetGetNotFound struct { 187 } 188 189 // IsSuccess returns true when this pet get not found response has a 2xx status code 190 func (o *PetGetNotFound) IsSuccess() bool { 191 return false 192 } 193 194 // IsRedirect returns true when this pet get not found response has a 3xx status code 195 func (o *PetGetNotFound) IsRedirect() bool { 196 return false 197 } 198 199 // IsClientError returns true when this pet get not found response has a 4xx status code 200 func (o *PetGetNotFound) IsClientError() bool { 201 return true 202 } 203 204 // IsServerError returns true when this pet get not found response has a 5xx status code 205 func (o *PetGetNotFound) IsServerError() bool { 206 return false 207 } 208 209 // IsCode returns true when this pet get not found response a status code equal to that given 210 func (o *PetGetNotFound) IsCode(code int) bool { 211 return code == 404 212 } 213 214 // Code gets the status code for the pet get not found response 215 func (o *PetGetNotFound) Code() int { 216 return 404 217 } 218 219 func (o *PetGetNotFound) Error() string { 220 return fmt.Sprintf("[GET /pet/{petId}][%d] petGetNotFound", 404) 221 } 222 223 func (o *PetGetNotFound) String() string { 224 return fmt.Sprintf("[GET /pet/{petId}][%d] petGetNotFound", 404) 225 } 226 227 func (o *PetGetNotFound) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { 228 229 return nil 230 }