github.com/circl-dev/go-swagger@v0.31.0/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/strfmt"
    13  	"github.com/circl-dev/runtime"
    14  
    15  	"github.com/circl-dev/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  /* PetListOK describes a response with status code 200, with default header values.
    49  
    50  successful operation
    51  */
    52  type PetListOK struct {
    53  	Payload []*models.Pet
    54  }
    55  
    56  func (o *PetListOK) Error() string {
    57  	return fmt.Sprintf("[GET /pet][%d] petListOK  %+v", 200, o.Payload)
    58  }
    59  func (o *PetListOK) GetPayload() []*models.Pet {
    60  	return o.Payload
    61  }
    62  
    63  func (o *PetListOK) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error {
    64  
    65  	// response payload
    66  	if err := consumer.Consume(response.Body(), &o.Payload); err != nil && err != io.EOF {
    67  		return err
    68  	}
    69  
    70  	return nil
    71  }
    72  
    73  // NewPetListBadRequest creates a PetListBadRequest with default headers values
    74  func NewPetListBadRequest() *PetListBadRequest {
    75  	return &PetListBadRequest{}
    76  }
    77  
    78  /* PetListBadRequest describes a response with status code 400, with default header values.
    79  
    80  Invalid status value
    81  */
    82  type PetListBadRequest struct {
    83  }
    84  
    85  func (o *PetListBadRequest) Error() string {
    86  	return fmt.Sprintf("[GET /pet][%d] petListBadRequest ", 400)
    87  }
    88  
    89  func (o *PetListBadRequest) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error {
    90  
    91  	return nil
    92  }