github.com/emreu/go-swagger@v0.22.1/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  	"fmt"
    10  	"io"
    11  
    12  	"github.com/go-openapi/runtime"
    13  
    14  	strfmt "github.com/go-openapi/strfmt"
    15  
    16  	models "github.com/go-swagger/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  
    52  	default:
    53  		return nil, runtime.NewAPIError("unknown error", response, response.Code())
    54  	}
    55  }
    56  
    57  // NewPetUpdateCreated creates a PetUpdateCreated with default headers values
    58  func NewPetUpdateCreated() *PetUpdateCreated {
    59  	return &PetUpdateCreated{}
    60  }
    61  
    62  /*PetUpdateCreated handles this case with default header values.
    63  
    64  Updated successfully
    65  */
    66  type PetUpdateCreated struct {
    67  	Payload *models.Pet
    68  }
    69  
    70  func (o *PetUpdateCreated) Error() string {
    71  	return fmt.Sprintf("[PUT /pet][%d] petUpdateCreated  %+v", 201, o.Payload)
    72  }
    73  
    74  func (o *PetUpdateCreated) GetPayload() *models.Pet {
    75  	return o.Payload
    76  }
    77  
    78  func (o *PetUpdateCreated) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error {
    79  
    80  	o.Payload = new(models.Pet)
    81  
    82  	// response payload
    83  	if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF {
    84  		return err
    85  	}
    86  
    87  	return nil
    88  }
    89  
    90  // NewPetUpdateBadRequest creates a PetUpdateBadRequest with default headers values
    91  func NewPetUpdateBadRequest() *PetUpdateBadRequest {
    92  	return &PetUpdateBadRequest{}
    93  }
    94  
    95  /*PetUpdateBadRequest handles this case with default header values.
    96  
    97  Invalid ID supplied
    98  */
    99  type PetUpdateBadRequest struct {
   100  }
   101  
   102  func (o *PetUpdateBadRequest) Error() string {
   103  	return fmt.Sprintf("[PUT /pet][%d] petUpdateBadRequest ", 400)
   104  }
   105  
   106  func (o *PetUpdateBadRequest) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error {
   107  
   108  	return nil
   109  }
   110  
   111  // NewPetUpdateNotFound creates a PetUpdateNotFound with default headers values
   112  func NewPetUpdateNotFound() *PetUpdateNotFound {
   113  	return &PetUpdateNotFound{}
   114  }
   115  
   116  /*PetUpdateNotFound handles this case with default header values.
   117  
   118  Pet not found
   119  */
   120  type PetUpdateNotFound struct {
   121  }
   122  
   123  func (o *PetUpdateNotFound) Error() string {
   124  	return fmt.Sprintf("[PUT /pet][%d] petUpdateNotFound ", 404)
   125  }
   126  
   127  func (o *PetUpdateNotFound) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error {
   128  
   129  	return nil
   130  }
   131  
   132  // NewPetUpdateMethodNotAllowed creates a PetUpdateMethodNotAllowed with default headers values
   133  func NewPetUpdateMethodNotAllowed() *PetUpdateMethodNotAllowed {
   134  	return &PetUpdateMethodNotAllowed{}
   135  }
   136  
   137  /*PetUpdateMethodNotAllowed handles this case with default header values.
   138  
   139  Validation exception
   140  */
   141  type PetUpdateMethodNotAllowed struct {
   142  }
   143  
   144  func (o *PetUpdateMethodNotAllowed) Error() string {
   145  	return fmt.Sprintf("[PUT /pet][%d] petUpdateMethodNotAllowed ", 405)
   146  }
   147  
   148  func (o *PetUpdateMethodNotAllowed) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error {
   149  
   150  	return nil
   151  }