github.com/thetreep/go-swagger@v0.0.0-20240223100711-35af64f14f01/examples/contributed-templates/stratoscale/client/pet/pet_update_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  // PetUpdateReader is a Reader for the PetUpdate structure.
    20  type PetUpdateReader struct {
    21  	formats strfmt.Registry
    22  }
    23  
    24  // ReadResponse reads a server response into the received o.
    25  func (o *PetUpdateReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) {
    26  	switch response.Code() {
    27  	case 201:
    28  		result := NewPetUpdateCreated()
    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 := NewPetUpdateBadRequest()
    35  		if err := result.readResponse(response, consumer, o.formats); err != nil {
    36  			return nil, err
    37  		}
    38  		return nil, result
    39  	case 404:
    40  		result := NewPetUpdateNotFound()
    41  		if err := result.readResponse(response, consumer, o.formats); err != nil {
    42  			return nil, err
    43  		}
    44  		return nil, result
    45  	case 405:
    46  		result := NewPetUpdateMethodNotAllowed()
    47  		if err := result.readResponse(response, consumer, o.formats); err != nil {
    48  			return nil, err
    49  		}
    50  		return nil, result
    51  	default:
    52  		return nil, runtime.NewAPIError("[PUT /pet] PetUpdate", response, response.Code())
    53  	}
    54  }
    55  
    56  // NewPetUpdateCreated creates a PetUpdateCreated with default headers values
    57  func NewPetUpdateCreated() *PetUpdateCreated {
    58  	return &PetUpdateCreated{}
    59  }
    60  
    61  /*
    62  PetUpdateCreated describes a response with status code 201, with default header values.
    63  
    64  Updated successfully
    65  */
    66  type PetUpdateCreated struct {
    67  	Payload *models.Pet
    68  }
    69  
    70  // IsSuccess returns true when this pet update created response has a 2xx status code
    71  func (o *PetUpdateCreated) IsSuccess() bool {
    72  	return true
    73  }
    74  
    75  // IsRedirect returns true when this pet update created response has a 3xx status code
    76  func (o *PetUpdateCreated) IsRedirect() bool {
    77  	return false
    78  }
    79  
    80  // IsClientError returns true when this pet update created response has a 4xx status code
    81  func (o *PetUpdateCreated) IsClientError() bool {
    82  	return false
    83  }
    84  
    85  // IsServerError returns true when this pet update created response has a 5xx status code
    86  func (o *PetUpdateCreated) IsServerError() bool {
    87  	return false
    88  }
    89  
    90  // IsCode returns true when this pet update created response a status code equal to that given
    91  func (o *PetUpdateCreated) IsCode(code int) bool {
    92  	return code == 201
    93  }
    94  
    95  // Code gets the status code for the pet update created response
    96  func (o *PetUpdateCreated) Code() int {
    97  	return 201
    98  }
    99  
   100  func (o *PetUpdateCreated) Error() string {
   101  	payload, _ := json.Marshal(o.Payload)
   102  	return fmt.Sprintf("[PUT /pet][%d] petUpdateCreated %s", 201, payload)
   103  }
   104  
   105  func (o *PetUpdateCreated) String() string {
   106  	payload, _ := json.Marshal(o.Payload)
   107  	return fmt.Sprintf("[PUT /pet][%d] petUpdateCreated %s", 201, payload)
   108  }
   109  
   110  func (o *PetUpdateCreated) GetPayload() *models.Pet {
   111  	return o.Payload
   112  }
   113  
   114  func (o *PetUpdateCreated) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error {
   115  
   116  	o.Payload = new(models.Pet)
   117  
   118  	// response payload
   119  	if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF {
   120  		return err
   121  	}
   122  
   123  	return nil
   124  }
   125  
   126  // NewPetUpdateBadRequest creates a PetUpdateBadRequest with default headers values
   127  func NewPetUpdateBadRequest() *PetUpdateBadRequest {
   128  	return &PetUpdateBadRequest{}
   129  }
   130  
   131  /*
   132  PetUpdateBadRequest describes a response with status code 400, with default header values.
   133  
   134  Invalid ID supplied
   135  */
   136  type PetUpdateBadRequest struct {
   137  }
   138  
   139  // IsSuccess returns true when this pet update bad request response has a 2xx status code
   140  func (o *PetUpdateBadRequest) IsSuccess() bool {
   141  	return false
   142  }
   143  
   144  // IsRedirect returns true when this pet update bad request response has a 3xx status code
   145  func (o *PetUpdateBadRequest) IsRedirect() bool {
   146  	return false
   147  }
   148  
   149  // IsClientError returns true when this pet update bad request response has a 4xx status code
   150  func (o *PetUpdateBadRequest) IsClientError() bool {
   151  	return true
   152  }
   153  
   154  // IsServerError returns true when this pet update bad request response has a 5xx status code
   155  func (o *PetUpdateBadRequest) IsServerError() bool {
   156  	return false
   157  }
   158  
   159  // IsCode returns true when this pet update bad request response a status code equal to that given
   160  func (o *PetUpdateBadRequest) IsCode(code int) bool {
   161  	return code == 400
   162  }
   163  
   164  // Code gets the status code for the pet update bad request response
   165  func (o *PetUpdateBadRequest) Code() int {
   166  	return 400
   167  }
   168  
   169  func (o *PetUpdateBadRequest) Error() string {
   170  	return fmt.Sprintf("[PUT /pet][%d] petUpdateBadRequest", 400)
   171  }
   172  
   173  func (o *PetUpdateBadRequest) String() string {
   174  	return fmt.Sprintf("[PUT /pet][%d] petUpdateBadRequest", 400)
   175  }
   176  
   177  func (o *PetUpdateBadRequest) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error {
   178  
   179  	return nil
   180  }
   181  
   182  // NewPetUpdateNotFound creates a PetUpdateNotFound with default headers values
   183  func NewPetUpdateNotFound() *PetUpdateNotFound {
   184  	return &PetUpdateNotFound{}
   185  }
   186  
   187  /*
   188  PetUpdateNotFound describes a response with status code 404, with default header values.
   189  
   190  Pet not found
   191  */
   192  type PetUpdateNotFound struct {
   193  }
   194  
   195  // IsSuccess returns true when this pet update not found response has a 2xx status code
   196  func (o *PetUpdateNotFound) IsSuccess() bool {
   197  	return false
   198  }
   199  
   200  // IsRedirect returns true when this pet update not found response has a 3xx status code
   201  func (o *PetUpdateNotFound) IsRedirect() bool {
   202  	return false
   203  }
   204  
   205  // IsClientError returns true when this pet update not found response has a 4xx status code
   206  func (o *PetUpdateNotFound) IsClientError() bool {
   207  	return true
   208  }
   209  
   210  // IsServerError returns true when this pet update not found response has a 5xx status code
   211  func (o *PetUpdateNotFound) IsServerError() bool {
   212  	return false
   213  }
   214  
   215  // IsCode returns true when this pet update not found response a status code equal to that given
   216  func (o *PetUpdateNotFound) IsCode(code int) bool {
   217  	return code == 404
   218  }
   219  
   220  // Code gets the status code for the pet update not found response
   221  func (o *PetUpdateNotFound) Code() int {
   222  	return 404
   223  }
   224  
   225  func (o *PetUpdateNotFound) Error() string {
   226  	return fmt.Sprintf("[PUT /pet][%d] petUpdateNotFound", 404)
   227  }
   228  
   229  func (o *PetUpdateNotFound) String() string {
   230  	return fmt.Sprintf("[PUT /pet][%d] petUpdateNotFound", 404)
   231  }
   232  
   233  func (o *PetUpdateNotFound) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error {
   234  
   235  	return nil
   236  }
   237  
   238  // NewPetUpdateMethodNotAllowed creates a PetUpdateMethodNotAllowed with default headers values
   239  func NewPetUpdateMethodNotAllowed() *PetUpdateMethodNotAllowed {
   240  	return &PetUpdateMethodNotAllowed{}
   241  }
   242  
   243  /*
   244  PetUpdateMethodNotAllowed describes a response with status code 405, with default header values.
   245  
   246  Validation exception
   247  */
   248  type PetUpdateMethodNotAllowed struct {
   249  }
   250  
   251  // IsSuccess returns true when this pet update method not allowed response has a 2xx status code
   252  func (o *PetUpdateMethodNotAllowed) IsSuccess() bool {
   253  	return false
   254  }
   255  
   256  // IsRedirect returns true when this pet update method not allowed response has a 3xx status code
   257  func (o *PetUpdateMethodNotAllowed) IsRedirect() bool {
   258  	return false
   259  }
   260  
   261  // IsClientError returns true when this pet update method not allowed response has a 4xx status code
   262  func (o *PetUpdateMethodNotAllowed) IsClientError() bool {
   263  	return true
   264  }
   265  
   266  // IsServerError returns true when this pet update method not allowed response has a 5xx status code
   267  func (o *PetUpdateMethodNotAllowed) IsServerError() bool {
   268  	return false
   269  }
   270  
   271  // IsCode returns true when this pet update method not allowed response a status code equal to that given
   272  func (o *PetUpdateMethodNotAllowed) IsCode(code int) bool {
   273  	return code == 405
   274  }
   275  
   276  // Code gets the status code for the pet update method not allowed response
   277  func (o *PetUpdateMethodNotAllowed) Code() int {
   278  	return 405
   279  }
   280  
   281  func (o *PetUpdateMethodNotAllowed) Error() string {
   282  	return fmt.Sprintf("[PUT /pet][%d] petUpdateMethodNotAllowed", 405)
   283  }
   284  
   285  func (o *PetUpdateMethodNotAllowed) String() string {
   286  	return fmt.Sprintf("[PUT /pet][%d] petUpdateMethodNotAllowed", 405)
   287  }
   288  
   289  func (o *PetUpdateMethodNotAllowed) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error {
   290  
   291  	return nil
   292  }