github.com/djarvur/go-swagger@v0.18.0/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 "fmt" 10 "io" 11 12 "github.com/go-openapi/runtime" 13 14 strfmt "github.com/go-openapi/strfmt" 15 16 models "github.com/go-swagger/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 28 case 200: 29 result := NewPetGetOK() 30 if err := result.readResponse(response, consumer, o.formats); err != nil { 31 return nil, err 32 } 33 return result, nil 34 35 case 400: 36 result := NewPetGetBadRequest() 37 if err := result.readResponse(response, consumer, o.formats); err != nil { 38 return nil, err 39 } 40 return nil, result 41 42 case 404: 43 result := NewPetGetNotFound() 44 if err := result.readResponse(response, consumer, o.formats); err != nil { 45 return nil, err 46 } 47 return nil, result 48 49 default: 50 return nil, runtime.NewAPIError("unknown error", response, response.Code()) 51 } 52 } 53 54 // NewPetGetOK creates a PetGetOK with default headers values 55 func NewPetGetOK() *PetGetOK { 56 return &PetGetOK{} 57 } 58 59 /*PetGetOK handles this case with default header values. 60 61 successful operation 62 */ 63 type PetGetOK struct { 64 Payload *models.Pet 65 } 66 67 func (o *PetGetOK) Error() string { 68 return fmt.Sprintf("[GET /pet/{petId}][%d] petGetOK %+v", 200, o.Payload) 69 } 70 71 func (o *PetGetOK) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { 72 73 o.Payload = new(models.Pet) 74 75 // response payload 76 if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { 77 return err 78 } 79 80 return nil 81 } 82 83 // NewPetGetBadRequest creates a PetGetBadRequest with default headers values 84 func NewPetGetBadRequest() *PetGetBadRequest { 85 return &PetGetBadRequest{} 86 } 87 88 /*PetGetBadRequest handles this case with default header values. 89 90 Invalid ID supplied 91 */ 92 type PetGetBadRequest struct { 93 } 94 95 func (o *PetGetBadRequest) Error() string { 96 return fmt.Sprintf("[GET /pet/{petId}][%d] petGetBadRequest ", 400) 97 } 98 99 func (o *PetGetBadRequest) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { 100 101 return nil 102 } 103 104 // NewPetGetNotFound creates a PetGetNotFound with default headers values 105 func NewPetGetNotFound() *PetGetNotFound { 106 return &PetGetNotFound{} 107 } 108 109 /*PetGetNotFound handles this case with default header values. 110 111 Pet not found 112 */ 113 type PetGetNotFound struct { 114 } 115 116 func (o *PetGetNotFound) Error() string { 117 return fmt.Sprintf("[GET /pet/{petId}][%d] petGetNotFound ", 404) 118 } 119 120 func (o *PetGetNotFound) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { 121 122 return nil 123 }