github.com/thetreep/go-swagger@v0.0.0-20240223100711-35af64f14f01/examples/contributed-templates/stratoscale/client/pet/pet_create_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 // PetCreateReader is a Reader for the PetCreate structure. 20 type PetCreateReader struct { 21 formats strfmt.Registry 22 } 23 24 // ReadResponse reads a server response into the received o. 25 func (o *PetCreateReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) { 26 switch response.Code() { 27 case 201: 28 result := NewPetCreateCreated() 29 if err := result.readResponse(response, consumer, o.formats); err != nil { 30 return nil, err 31 } 32 return result, nil 33 case 405: 34 result := NewPetCreateMethodNotAllowed() 35 if err := result.readResponse(response, consumer, o.formats); err != nil { 36 return nil, err 37 } 38 return nil, result 39 default: 40 return nil, runtime.NewAPIError("[POST /pet] PetCreate", response, response.Code()) 41 } 42 } 43 44 // NewPetCreateCreated creates a PetCreateCreated with default headers values 45 func NewPetCreateCreated() *PetCreateCreated { 46 return &PetCreateCreated{} 47 } 48 49 /* 50 PetCreateCreated describes a response with status code 201, with default header values. 51 52 Created 53 */ 54 type PetCreateCreated struct { 55 Payload *models.Pet 56 } 57 58 // IsSuccess returns true when this pet create created response has a 2xx status code 59 func (o *PetCreateCreated) IsSuccess() bool { 60 return true 61 } 62 63 // IsRedirect returns true when this pet create created response has a 3xx status code 64 func (o *PetCreateCreated) IsRedirect() bool { 65 return false 66 } 67 68 // IsClientError returns true when this pet create created response has a 4xx status code 69 func (o *PetCreateCreated) IsClientError() bool { 70 return false 71 } 72 73 // IsServerError returns true when this pet create created response has a 5xx status code 74 func (o *PetCreateCreated) IsServerError() bool { 75 return false 76 } 77 78 // IsCode returns true when this pet create created response a status code equal to that given 79 func (o *PetCreateCreated) IsCode(code int) bool { 80 return code == 201 81 } 82 83 // Code gets the status code for the pet create created response 84 func (o *PetCreateCreated) Code() int { 85 return 201 86 } 87 88 func (o *PetCreateCreated) Error() string { 89 payload, _ := json.Marshal(o.Payload) 90 return fmt.Sprintf("[POST /pet][%d] petCreateCreated %s", 201, payload) 91 } 92 93 func (o *PetCreateCreated) String() string { 94 payload, _ := json.Marshal(o.Payload) 95 return fmt.Sprintf("[POST /pet][%d] petCreateCreated %s", 201, payload) 96 } 97 98 func (o *PetCreateCreated) GetPayload() *models.Pet { 99 return o.Payload 100 } 101 102 func (o *PetCreateCreated) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { 103 104 o.Payload = new(models.Pet) 105 106 // response payload 107 if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { 108 return err 109 } 110 111 return nil 112 } 113 114 // NewPetCreateMethodNotAllowed creates a PetCreateMethodNotAllowed with default headers values 115 func NewPetCreateMethodNotAllowed() *PetCreateMethodNotAllowed { 116 return &PetCreateMethodNotAllowed{} 117 } 118 119 /* 120 PetCreateMethodNotAllowed describes a response with status code 405, with default header values. 121 122 Invalid input 123 */ 124 type PetCreateMethodNotAllowed struct { 125 } 126 127 // IsSuccess returns true when this pet create method not allowed response has a 2xx status code 128 func (o *PetCreateMethodNotAllowed) IsSuccess() bool { 129 return false 130 } 131 132 // IsRedirect returns true when this pet create method not allowed response has a 3xx status code 133 func (o *PetCreateMethodNotAllowed) IsRedirect() bool { 134 return false 135 } 136 137 // IsClientError returns true when this pet create method not allowed response has a 4xx status code 138 func (o *PetCreateMethodNotAllowed) IsClientError() bool { 139 return true 140 } 141 142 // IsServerError returns true when this pet create method not allowed response has a 5xx status code 143 func (o *PetCreateMethodNotAllowed) IsServerError() bool { 144 return false 145 } 146 147 // IsCode returns true when this pet create method not allowed response a status code equal to that given 148 func (o *PetCreateMethodNotAllowed) IsCode(code int) bool { 149 return code == 405 150 } 151 152 // Code gets the status code for the pet create method not allowed response 153 func (o *PetCreateMethodNotAllowed) Code() int { 154 return 405 155 } 156 157 func (o *PetCreateMethodNotAllowed) Error() string { 158 return fmt.Sprintf("[POST /pet][%d] petCreateMethodNotAllowed", 405) 159 } 160 161 func (o *PetCreateMethodNotAllowed) String() string { 162 return fmt.Sprintf("[POST /pet][%d] petCreateMethodNotAllowed", 405) 163 } 164 165 func (o *PetCreateMethodNotAllowed) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { 166 167 return nil 168 }