github.com/circl-dev/go-swagger@v0.31.0/examples/task-tracker/client/tasks/upload_task_file_responses.go (about)

     1  // Code generated by go-swagger; DO NOT EDIT.
     2  
     3  package tasks
     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/strfmt"
    13  	"github.com/circl-dev/runtime"
    14  
    15  	"github.com/circl-dev/go-swagger/examples/task-tracker/models"
    16  )
    17  
    18  // UploadTaskFileReader is a Reader for the UploadTaskFile structure.
    19  type UploadTaskFileReader struct {
    20  	formats strfmt.Registry
    21  }
    22  
    23  // ReadResponse reads a server response into the received o.
    24  func (o *UploadTaskFileReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) {
    25  	switch response.Code() {
    26  	case 201:
    27  		result := NewUploadTaskFileCreated()
    28  		if err := result.readResponse(response, consumer, o.formats); err != nil {
    29  			return nil, err
    30  		}
    31  		return result, nil
    32  	default:
    33  		result := NewUploadTaskFileDefault(response.Code())
    34  		if err := result.readResponse(response, consumer, o.formats); err != nil {
    35  			return nil, err
    36  		}
    37  		if response.Code()/100 == 2 {
    38  			return result, nil
    39  		}
    40  		return nil, result
    41  	}
    42  }
    43  
    44  // NewUploadTaskFileCreated creates a UploadTaskFileCreated with default headers values
    45  func NewUploadTaskFileCreated() *UploadTaskFileCreated {
    46  	return &UploadTaskFileCreated{}
    47  }
    48  
    49  /* UploadTaskFileCreated describes a response with status code 201, with default header values.
    50  
    51  File added
    52  */
    53  type UploadTaskFileCreated struct {
    54  }
    55  
    56  func (o *UploadTaskFileCreated) Error() string {
    57  	return fmt.Sprintf("[POST /tasks/{id}/files][%d] uploadTaskFileCreated ", 201)
    58  }
    59  
    60  func (o *UploadTaskFileCreated) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error {
    61  
    62  	return nil
    63  }
    64  
    65  // NewUploadTaskFileDefault creates a UploadTaskFileDefault with default headers values
    66  func NewUploadTaskFileDefault(code int) *UploadTaskFileDefault {
    67  	return &UploadTaskFileDefault{
    68  		_statusCode: code,
    69  	}
    70  }
    71  
    72  /* UploadTaskFileDefault describes a response with status code -1, with default header values.
    73  
    74  Error response
    75  */
    76  type UploadTaskFileDefault struct {
    77  	_statusCode int
    78  	XErrorCode  string
    79  
    80  	Payload *models.Error
    81  }
    82  
    83  // Code gets the status code for the upload task file default response
    84  func (o *UploadTaskFileDefault) Code() int {
    85  	return o._statusCode
    86  }
    87  
    88  func (o *UploadTaskFileDefault) Error() string {
    89  	return fmt.Sprintf("[POST /tasks/{id}/files][%d] uploadTaskFile default  %+v", o._statusCode, o.Payload)
    90  }
    91  func (o *UploadTaskFileDefault) GetPayload() *models.Error {
    92  	return o.Payload
    93  }
    94  
    95  func (o *UploadTaskFileDefault) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error {
    96  
    97  	// hydrates response header X-Error-Code
    98  	hdrXErrorCode := response.GetHeader("X-Error-Code")
    99  
   100  	if hdrXErrorCode != "" {
   101  		o.XErrorCode = hdrXErrorCode
   102  	}
   103  
   104  	o.Payload = new(models.Error)
   105  
   106  	// response payload
   107  	if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF {
   108  		return err
   109  	}
   110  
   111  	return nil
   112  }