github.com/ffalor/go-swagger@v0.0.0-20231011000038-9f25265ac351/examples/contributed-templates/stratoscale/client/pet/pet_list_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 // PetListReader is a Reader for the PetList structure. 19 type PetListReader struct { 20 formats strfmt.Registry 21 } 22 23 // ReadResponse reads a server response into the received o. 24 func (o *PetListReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) { 25 switch response.Code() { 26 case 200: 27 result := NewPetListOK() 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 := NewPetListBadRequest() 34 if err := result.readResponse(response, consumer, o.formats); err != nil { 35 return nil, err 36 } 37 return nil, result 38 default: 39 return nil, runtime.NewAPIError("response status code does not match any response statuses defined for this endpoint in the swagger spec", response, response.Code()) 40 } 41 } 42 43 // NewPetListOK creates a PetListOK with default headers values 44 func NewPetListOK() *PetListOK { 45 return &PetListOK{} 46 } 47 48 /* 49 PetListOK describes a response with status code 200, with default header values. 50 51 successful operation 52 */ 53 type PetListOK struct { 54 Payload []*models.Pet 55 } 56 57 // IsSuccess returns true when this pet list o k response has a 2xx status code 58 func (o *PetListOK) IsSuccess() bool { 59 return true 60 } 61 62 // IsRedirect returns true when this pet list o k response has a 3xx status code 63 func (o *PetListOK) IsRedirect() bool { 64 return false 65 } 66 67 // IsClientError returns true when this pet list o k response has a 4xx status code 68 func (o *PetListOK) IsClientError() bool { 69 return false 70 } 71 72 // IsServerError returns true when this pet list o k response has a 5xx status code 73 func (o *PetListOK) IsServerError() bool { 74 return false 75 } 76 77 // IsCode returns true when this pet list o k response a status code equal to that given 78 func (o *PetListOK) IsCode(code int) bool { 79 return code == 200 80 } 81 82 // Code gets the status code for the pet list o k response 83 func (o *PetListOK) Code() int { 84 return 200 85 } 86 87 func (o *PetListOK) Error() string { 88 return fmt.Sprintf("[GET /pet][%d] petListOK %+v", 200, o.Payload) 89 } 90 91 func (o *PetListOK) String() string { 92 return fmt.Sprintf("[GET /pet][%d] petListOK %+v", 200, o.Payload) 93 } 94 95 func (o *PetListOK) GetPayload() []*models.Pet { 96 return o.Payload 97 } 98 99 func (o *PetListOK) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { 100 101 // response payload 102 if err := consumer.Consume(response.Body(), &o.Payload); err != nil && err != io.EOF { 103 return err 104 } 105 106 return nil 107 } 108 109 // NewPetListBadRequest creates a PetListBadRequest with default headers values 110 func NewPetListBadRequest() *PetListBadRequest { 111 return &PetListBadRequest{} 112 } 113 114 /* 115 PetListBadRequest describes a response with status code 400, with default header values. 116 117 Invalid status value 118 */ 119 type PetListBadRequest struct { 120 } 121 122 // IsSuccess returns true when this pet list bad request response has a 2xx status code 123 func (o *PetListBadRequest) IsSuccess() bool { 124 return false 125 } 126 127 // IsRedirect returns true when this pet list bad request response has a 3xx status code 128 func (o *PetListBadRequest) IsRedirect() bool { 129 return false 130 } 131 132 // IsClientError returns true when this pet list bad request response has a 4xx status code 133 func (o *PetListBadRequest) IsClientError() bool { 134 return true 135 } 136 137 // IsServerError returns true when this pet list bad request response has a 5xx status code 138 func (o *PetListBadRequest) IsServerError() bool { 139 return false 140 } 141 142 // IsCode returns true when this pet list bad request response a status code equal to that given 143 func (o *PetListBadRequest) IsCode(code int) bool { 144 return code == 400 145 } 146 147 // Code gets the status code for the pet list bad request response 148 func (o *PetListBadRequest) Code() int { 149 return 400 150 } 151 152 func (o *PetListBadRequest) Error() string { 153 return fmt.Sprintf("[GET /pet][%d] petListBadRequest ", 400) 154 } 155 156 func (o *PetListBadRequest) String() string { 157 return fmt.Sprintf("[GET /pet][%d] petListBadRequest ", 400) 158 } 159 160 func (o *PetListBadRequest) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { 161 162 return nil 163 }