github.com/circl-dev/go-swagger@v0.31.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/strfmt"
    13  	"github.com/circl-dev/runtime"
    14  
    15  	"github.com/circl-dev/go-swagger/examples/contributed-templates/stratoscale/models"
    16  )
    17  
    18  // PetGetReader is a Reader for the PetGet structure.
    19  type PetGetReader struct {
    20  	formats strfmt.Registry
    21  }
    22  
    23  // ReadResponse reads a server response into the received o.
    24  func (o *PetGetReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) {
    25  	switch response.Code() {
    26  	case 200:
    27  		result := NewPetGetOK()
    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 := NewPetGetBadRequest()
    34  		if err := result.readResponse(response, consumer, o.formats); err != nil {
    35  			return nil, err
    36  		}
    37  		return nil, result
    38  	case 404:
    39  		result := NewPetGetNotFound()
    40  		if err := result.readResponse(response, consumer, o.formats); err != nil {
    41  			return nil, err
    42  		}
    43  		return nil, result
    44  	default:
    45  		return nil, runtime.NewAPIError("response status code does not match any response statuses defined for this endpoint in the swagger spec", response, response.Code())
    46  	}
    47  }
    48  
    49  // NewPetGetOK creates a PetGetOK with default headers values
    50  func NewPetGetOK() *PetGetOK {
    51  	return &PetGetOK{}
    52  }
    53  
    54  /* PetGetOK describes a response with status code 200, with default header values.
    55  
    56  successful operation
    57  */
    58  type PetGetOK struct {
    59  	Payload *models.Pet
    60  }
    61  
    62  func (o *PetGetOK) Error() string {
    63  	return fmt.Sprintf("[GET /pet/{petId}][%d] petGetOK  %+v", 200, o.Payload)
    64  }
    65  func (o *PetGetOK) GetPayload() *models.Pet {
    66  	return o.Payload
    67  }
    68  
    69  func (o *PetGetOK) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error {
    70  
    71  	o.Payload = new(models.Pet)
    72  
    73  	// response payload
    74  	if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF {
    75  		return err
    76  	}
    77  
    78  	return nil
    79  }
    80  
    81  // NewPetGetBadRequest creates a PetGetBadRequest with default headers values
    82  func NewPetGetBadRequest() *PetGetBadRequest {
    83  	return &PetGetBadRequest{}
    84  }
    85  
    86  /* PetGetBadRequest describes a response with status code 400, with default header values.
    87  
    88  Invalid ID supplied
    89  */
    90  type PetGetBadRequest struct {
    91  }
    92  
    93  func (o *PetGetBadRequest) Error() string {
    94  	return fmt.Sprintf("[GET /pet/{petId}][%d] petGetBadRequest ", 400)
    95  }
    96  
    97  func (o *PetGetBadRequest) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error {
    98  
    99  	return nil
   100  }
   101  
   102  // NewPetGetNotFound creates a PetGetNotFound with default headers values
   103  func NewPetGetNotFound() *PetGetNotFound {
   104  	return &PetGetNotFound{}
   105  }
   106  
   107  /* PetGetNotFound describes a response with status code 404, with default header values.
   108  
   109  Pet not found
   110  */
   111  type PetGetNotFound struct {
   112  }
   113  
   114  func (o *PetGetNotFound) Error() string {
   115  	return fmt.Sprintf("[GET /pet/{petId}][%d] petGetNotFound ", 404)
   116  }
   117  
   118  func (o *PetGetNotFound) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error {
   119  
   120  	return nil
   121  }