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