github.com/josephspurrier/go-swagger@v0.2.1-0.20221129144919-1f672a142a00/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/runtime"
    13  	"github.com/go-openapi/strfmt"
    14  
    15  	"github.com/go-swagger/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  /*
    49  	PetCreateCreated describes a response with status code 201, with default header values.
    50  
    51  Created
    52  */
    53  type PetCreateCreated struct {
    54  	Payload *models.Pet
    55  }
    56  
    57  // IsSuccess returns true when this pet create created response returns a 2xx status code
    58  func (o *PetCreateCreated) IsSuccess() bool {
    59  	return true
    60  }
    61  
    62  // IsRedirect returns true when this pet create created response returns a 3xx status code
    63  func (o *PetCreateCreated) IsRedirect() bool {
    64  	return false
    65  }
    66  
    67  // IsClientError returns true when this pet create created response returns a 4xx status code
    68  func (o *PetCreateCreated) IsClientError() bool {
    69  	return false
    70  }
    71  
    72  // IsServerError returns true when this pet create created response returns a 5xx status code
    73  func (o *PetCreateCreated) IsServerError() bool {
    74  	return false
    75  }
    76  
    77  // IsCode returns true when this pet create created response returns a 4xx status code
    78  func (o *PetCreateCreated) IsCode(code int) bool {
    79  	return code == 201
    80  }
    81  
    82  func (o *PetCreateCreated) Error() string {
    83  	return fmt.Sprintf("[POST /pet][%d] petCreateCreated  %+v", 201, o.Payload)
    84  }
    85  
    86  func (o *PetCreateCreated) String() string {
    87  	return fmt.Sprintf("[POST /pet][%d] petCreateCreated  %+v", 201, o.Payload)
    88  }
    89  
    90  func (o *PetCreateCreated) GetPayload() *models.Pet {
    91  	return o.Payload
    92  }
    93  
    94  func (o *PetCreateCreated) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error {
    95  
    96  	o.Payload = new(models.Pet)
    97  
    98  	// response payload
    99  	if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF {
   100  		return err
   101  	}
   102  
   103  	return nil
   104  }
   105  
   106  // NewPetCreateMethodNotAllowed creates a PetCreateMethodNotAllowed with default headers values
   107  func NewPetCreateMethodNotAllowed() *PetCreateMethodNotAllowed {
   108  	return &PetCreateMethodNotAllowed{}
   109  }
   110  
   111  /*
   112  	PetCreateMethodNotAllowed describes a response with status code 405, with default header values.
   113  
   114  Invalid input
   115  */
   116  type PetCreateMethodNotAllowed struct {
   117  }
   118  
   119  // IsSuccess returns true when this pet create method not allowed response returns a 2xx status code
   120  func (o *PetCreateMethodNotAllowed) IsSuccess() bool {
   121  	return false
   122  }
   123  
   124  // IsRedirect returns true when this pet create method not allowed response returns a 3xx status code
   125  func (o *PetCreateMethodNotAllowed) IsRedirect() bool {
   126  	return false
   127  }
   128  
   129  // IsClientError returns true when this pet create method not allowed response returns a 4xx status code
   130  func (o *PetCreateMethodNotAllowed) IsClientError() bool {
   131  	return true
   132  }
   133  
   134  // IsServerError returns true when this pet create method not allowed response returns a 5xx status code
   135  func (o *PetCreateMethodNotAllowed) IsServerError() bool {
   136  	return false
   137  }
   138  
   139  // IsCode returns true when this pet create method not allowed response returns a 4xx status code
   140  func (o *PetCreateMethodNotAllowed) IsCode(code int) bool {
   141  	return code == 405
   142  }
   143  
   144  func (o *PetCreateMethodNotAllowed) Error() string {
   145  	return fmt.Sprintf("[POST /pet][%d] petCreateMethodNotAllowed ", 405)
   146  }
   147  
   148  func (o *PetCreateMethodNotAllowed) String() string {
   149  	return fmt.Sprintf("[POST /pet][%d] petCreateMethodNotAllowed ", 405)
   150  }
   151  
   152  func (o *PetCreateMethodNotAllowed) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error {
   153  
   154  	return nil
   155  }