github.com/josephspurrier/go-swagger@v0.2.1-0.20221129144919-1f672a142a00/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 returns 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 returns 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 returns 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 returns 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 returns a 4xx status code 78 func (o *PetListOK) IsCode(code int) bool { 79 return code == 200 80 } 81 82 func (o *PetListOK) Error() string { 83 return fmt.Sprintf("[GET /pet][%d] petListOK %+v", 200, o.Payload) 84 } 85 86 func (o *PetListOK) String() string { 87 return fmt.Sprintf("[GET /pet][%d] petListOK %+v", 200, o.Payload) 88 } 89 90 func (o *PetListOK) GetPayload() []*models.Pet { 91 return o.Payload 92 } 93 94 func (o *PetListOK) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { 95 96 // response payload 97 if err := consumer.Consume(response.Body(), &o.Payload); err != nil && err != io.EOF { 98 return err 99 } 100 101 return nil 102 } 103 104 // NewPetListBadRequest creates a PetListBadRequest with default headers values 105 func NewPetListBadRequest() *PetListBadRequest { 106 return &PetListBadRequest{} 107 } 108 109 /* 110 PetListBadRequest describes a response with status code 400, with default header values. 111 112 Invalid status value 113 */ 114 type PetListBadRequest struct { 115 } 116 117 // IsSuccess returns true when this pet list bad request response returns a 2xx status code 118 func (o *PetListBadRequest) IsSuccess() bool { 119 return false 120 } 121 122 // IsRedirect returns true when this pet list bad request response returns a 3xx status code 123 func (o *PetListBadRequest) IsRedirect() bool { 124 return false 125 } 126 127 // IsClientError returns true when this pet list bad request response returns a 4xx status code 128 func (o *PetListBadRequest) IsClientError() bool { 129 return true 130 } 131 132 // IsServerError returns true when this pet list bad request response returns a 5xx status code 133 func (o *PetListBadRequest) IsServerError() bool { 134 return false 135 } 136 137 // IsCode returns true when this pet list bad request response returns a 4xx status code 138 func (o *PetListBadRequest) IsCode(code int) bool { 139 return code == 400 140 } 141 142 func (o *PetListBadRequest) Error() string { 143 return fmt.Sprintf("[GET /pet][%d] petListBadRequest ", 400) 144 } 145 146 func (o *PetListBadRequest) String() string { 147 return fmt.Sprintf("[GET /pet][%d] petListBadRequest ", 400) 148 } 149 150 func (o *PetListBadRequest) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { 151 152 return nil 153 }