github.com/ffalor/go-swagger@v0.0.0-20231011000038-9f25265ac351/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/runtime"
    13  	"github.com/go-openapi/strfmt"
    14  
    15  	"github.com/go-swagger/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  /*
    55  PetGetOK describes a response with status code 200, with default header values.
    56  
    57  successful operation
    58  */
    59  type PetGetOK struct {
    60  	Payload *models.Pet
    61  }
    62  
    63  // IsSuccess returns true when this pet get o k response has a 2xx status code
    64  func (o *PetGetOK) IsSuccess() bool {
    65  	return true
    66  }
    67  
    68  // IsRedirect returns true when this pet get o k response has a 3xx status code
    69  func (o *PetGetOK) IsRedirect() bool {
    70  	return false
    71  }
    72  
    73  // IsClientError returns true when this pet get o k response has a 4xx status code
    74  func (o *PetGetOK) IsClientError() bool {
    75  	return false
    76  }
    77  
    78  // IsServerError returns true when this pet get o k response has a 5xx status code
    79  func (o *PetGetOK) IsServerError() bool {
    80  	return false
    81  }
    82  
    83  // IsCode returns true when this pet get o k response a status code equal to that given
    84  func (o *PetGetOK) IsCode(code int) bool {
    85  	return code == 200
    86  }
    87  
    88  // Code gets the status code for the pet get o k response
    89  func (o *PetGetOK) Code() int {
    90  	return 200
    91  }
    92  
    93  func (o *PetGetOK) Error() string {
    94  	return fmt.Sprintf("[GET /pet/{petId}][%d] petGetOK  %+v", 200, o.Payload)
    95  }
    96  
    97  func (o *PetGetOK) String() string {
    98  	return fmt.Sprintf("[GET /pet/{petId}][%d] petGetOK  %+v", 200, o.Payload)
    99  }
   100  
   101  func (o *PetGetOK) GetPayload() *models.Pet {
   102  	return o.Payload
   103  }
   104  
   105  func (o *PetGetOK) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error {
   106  
   107  	o.Payload = new(models.Pet)
   108  
   109  	// response payload
   110  	if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF {
   111  		return err
   112  	}
   113  
   114  	return nil
   115  }
   116  
   117  // NewPetGetBadRequest creates a PetGetBadRequest with default headers values
   118  func NewPetGetBadRequest() *PetGetBadRequest {
   119  	return &PetGetBadRequest{}
   120  }
   121  
   122  /*
   123  PetGetBadRequest describes a response with status code 400, with default header values.
   124  
   125  Invalid ID supplied
   126  */
   127  type PetGetBadRequest struct {
   128  }
   129  
   130  // IsSuccess returns true when this pet get bad request response has a 2xx status code
   131  func (o *PetGetBadRequest) IsSuccess() bool {
   132  	return false
   133  }
   134  
   135  // IsRedirect returns true when this pet get bad request response has a 3xx status code
   136  func (o *PetGetBadRequest) IsRedirect() bool {
   137  	return false
   138  }
   139  
   140  // IsClientError returns true when this pet get bad request response has a 4xx status code
   141  func (o *PetGetBadRequest) IsClientError() bool {
   142  	return true
   143  }
   144  
   145  // IsServerError returns true when this pet get bad request response has a 5xx status code
   146  func (o *PetGetBadRequest) IsServerError() bool {
   147  	return false
   148  }
   149  
   150  // IsCode returns true when this pet get bad request response a status code equal to that given
   151  func (o *PetGetBadRequest) IsCode(code int) bool {
   152  	return code == 400
   153  }
   154  
   155  // Code gets the status code for the pet get bad request response
   156  func (o *PetGetBadRequest) Code() int {
   157  	return 400
   158  }
   159  
   160  func (o *PetGetBadRequest) Error() string {
   161  	return fmt.Sprintf("[GET /pet/{petId}][%d] petGetBadRequest ", 400)
   162  }
   163  
   164  func (o *PetGetBadRequest) String() string {
   165  	return fmt.Sprintf("[GET /pet/{petId}][%d] petGetBadRequest ", 400)
   166  }
   167  
   168  func (o *PetGetBadRequest) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error {
   169  
   170  	return nil
   171  }
   172  
   173  // NewPetGetNotFound creates a PetGetNotFound with default headers values
   174  func NewPetGetNotFound() *PetGetNotFound {
   175  	return &PetGetNotFound{}
   176  }
   177  
   178  /*
   179  PetGetNotFound describes a response with status code 404, with default header values.
   180  
   181  Pet not found
   182  */
   183  type PetGetNotFound struct {
   184  }
   185  
   186  // IsSuccess returns true when this pet get not found response has a 2xx status code
   187  func (o *PetGetNotFound) IsSuccess() bool {
   188  	return false
   189  }
   190  
   191  // IsRedirect returns true when this pet get not found response has a 3xx status code
   192  func (o *PetGetNotFound) IsRedirect() bool {
   193  	return false
   194  }
   195  
   196  // IsClientError returns true when this pet get not found response has a 4xx status code
   197  func (o *PetGetNotFound) IsClientError() bool {
   198  	return true
   199  }
   200  
   201  // IsServerError returns true when this pet get not found response has a 5xx status code
   202  func (o *PetGetNotFound) IsServerError() bool {
   203  	return false
   204  }
   205  
   206  // IsCode returns true when this pet get not found response a status code equal to that given
   207  func (o *PetGetNotFound) IsCode(code int) bool {
   208  	return code == 404
   209  }
   210  
   211  // Code gets the status code for the pet get not found response
   212  func (o *PetGetNotFound) Code() int {
   213  	return 404
   214  }
   215  
   216  func (o *PetGetNotFound) Error() string {
   217  	return fmt.Sprintf("[GET /pet/{petId}][%d] petGetNotFound ", 404)
   218  }
   219  
   220  func (o *PetGetNotFound) String() string {
   221  	return fmt.Sprintf("[GET /pet/{petId}][%d] petGetNotFound ", 404)
   222  }
   223  
   224  func (o *PetGetNotFound) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error {
   225  
   226  	return nil
   227  }