github.com/circl-dev/go-swagger@v0.31.0/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 "fmt" 10 "io" 11 12 "github.com/go-openapi/strfmt" 13 "github.com/circl-dev/runtime" 14 15 "github.com/circl-dev/go-swagger/examples/contributed-templates/stratoscale/models" 16 ) 17 18 // PetCreateReader is a Reader for the PetCreate structure. 19 type PetCreateReader struct { 20 formats strfmt.Registry 21 } 22 23 // ReadResponse reads a server response into the received o. 24 func (o *PetCreateReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) { 25 switch response.Code() { 26 case 201: 27 result := NewPetCreateCreated() 28 if err := result.readResponse(response, consumer, o.formats); err != nil { 29 return nil, err 30 } 31 return result, nil 32 case 405: 33 result := NewPetCreateMethodNotAllowed() 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 // NewPetCreateCreated creates a PetCreateCreated with default headers values 44 func NewPetCreateCreated() *PetCreateCreated { 45 return &PetCreateCreated{} 46 } 47 48 /* PetCreateCreated describes a response with status code 201, with default header values. 49 50 Created 51 */ 52 type PetCreateCreated struct { 53 Payload *models.Pet 54 } 55 56 func (o *PetCreateCreated) Error() string { 57 return fmt.Sprintf("[POST /pet][%d] petCreateCreated %+v", 201, o.Payload) 58 } 59 func (o *PetCreateCreated) GetPayload() *models.Pet { 60 return o.Payload 61 } 62 63 func (o *PetCreateCreated) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { 64 65 o.Payload = new(models.Pet) 66 67 // response payload 68 if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { 69 return err 70 } 71 72 return nil 73 } 74 75 // NewPetCreateMethodNotAllowed creates a PetCreateMethodNotAllowed with default headers values 76 func NewPetCreateMethodNotAllowed() *PetCreateMethodNotAllowed { 77 return &PetCreateMethodNotAllowed{} 78 } 79 80 /* PetCreateMethodNotAllowed describes a response with status code 405, with default header values. 81 82 Invalid input 83 */ 84 type PetCreateMethodNotAllowed struct { 85 } 86 87 func (o *PetCreateMethodNotAllowed) Error() string { 88 return fmt.Sprintf("[POST /pet][%d] petCreateMethodNotAllowed ", 405) 89 } 90 91 func (o *PetCreateMethodNotAllowed) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { 92 93 return nil 94 }