github.com/thetreep/go-swagger@v0.0.0-20240223100711-35af64f14f01/examples/task-tracker/client/tasks/update_task_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  	"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/task-tracker/models"
    17  )
    18  
    19  // UpdateTaskReader is a Reader for the UpdateTask structure.
    20  type UpdateTaskReader struct {
    21  	formats strfmt.Registry
    22  }
    23  
    24  // ReadResponse reads a server response into the received o.
    25  func (o *UpdateTaskReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) {
    26  	switch response.Code() {
    27  	case 200:
    28  		result := NewUpdateTaskOK()
    29  		if err := result.readResponse(response, consumer, o.formats); err != nil {
    30  			return nil, err
    31  		}
    32  		return result, nil
    33  	case 422:
    34  		result := NewUpdateTaskUnprocessableEntity()
    35  		if err := result.readResponse(response, consumer, o.formats); err != nil {
    36  			return nil, err
    37  		}
    38  		return nil, result
    39  	default:
    40  		result := NewUpdateTaskDefault(response.Code())
    41  		if err := result.readResponse(response, consumer, o.formats); err != nil {
    42  			return nil, err
    43  		}
    44  		if response.Code()/100 == 2 {
    45  			return result, nil
    46  		}
    47  		return nil, result
    48  	}
    49  }
    50  
    51  // NewUpdateTaskOK creates a UpdateTaskOK with default headers values
    52  func NewUpdateTaskOK() *UpdateTaskOK {
    53  	return &UpdateTaskOK{}
    54  }
    55  
    56  /*
    57  UpdateTaskOK describes a response with status code 200, with default header values.
    58  
    59  Task details
    60  */
    61  type UpdateTaskOK struct {
    62  	Payload *models.Task
    63  }
    64  
    65  // IsSuccess returns true when this update task o k response has a 2xx status code
    66  func (o *UpdateTaskOK) IsSuccess() bool {
    67  	return true
    68  }
    69  
    70  // IsRedirect returns true when this update task o k response has a 3xx status code
    71  func (o *UpdateTaskOK) IsRedirect() bool {
    72  	return false
    73  }
    74  
    75  // IsClientError returns true when this update task o k response has a 4xx status code
    76  func (o *UpdateTaskOK) IsClientError() bool {
    77  	return false
    78  }
    79  
    80  // IsServerError returns true when this update task o k response has a 5xx status code
    81  func (o *UpdateTaskOK) IsServerError() bool {
    82  	return false
    83  }
    84  
    85  // IsCode returns true when this update task o k response a status code equal to that given
    86  func (o *UpdateTaskOK) IsCode(code int) bool {
    87  	return code == 200
    88  }
    89  
    90  // Code gets the status code for the update task o k response
    91  func (o *UpdateTaskOK) Code() int {
    92  	return 200
    93  }
    94  
    95  func (o *UpdateTaskOK) Error() string {
    96  	payload, _ := json.Marshal(o.Payload)
    97  	return fmt.Sprintf("[PUT /tasks/{id}][%d] updateTaskOK %s", 200, payload)
    98  }
    99  
   100  func (o *UpdateTaskOK) String() string {
   101  	payload, _ := json.Marshal(o.Payload)
   102  	return fmt.Sprintf("[PUT /tasks/{id}][%d] updateTaskOK %s", 200, payload)
   103  }
   104  
   105  func (o *UpdateTaskOK) GetPayload() *models.Task {
   106  	return o.Payload
   107  }
   108  
   109  func (o *UpdateTaskOK) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error {
   110  
   111  	o.Payload = new(models.Task)
   112  
   113  	// response payload
   114  	if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF {
   115  		return err
   116  	}
   117  
   118  	return nil
   119  }
   120  
   121  // NewUpdateTaskUnprocessableEntity creates a UpdateTaskUnprocessableEntity with default headers values
   122  func NewUpdateTaskUnprocessableEntity() *UpdateTaskUnprocessableEntity {
   123  	return &UpdateTaskUnprocessableEntity{}
   124  }
   125  
   126  /*
   127  UpdateTaskUnprocessableEntity describes a response with status code 422, with default header values.
   128  
   129  Validation error
   130  */
   131  type UpdateTaskUnprocessableEntity struct {
   132  	Payload *models.ValidationError
   133  }
   134  
   135  // IsSuccess returns true when this update task unprocessable entity response has a 2xx status code
   136  func (o *UpdateTaskUnprocessableEntity) IsSuccess() bool {
   137  	return false
   138  }
   139  
   140  // IsRedirect returns true when this update task unprocessable entity response has a 3xx status code
   141  func (o *UpdateTaskUnprocessableEntity) IsRedirect() bool {
   142  	return false
   143  }
   144  
   145  // IsClientError returns true when this update task unprocessable entity response has a 4xx status code
   146  func (o *UpdateTaskUnprocessableEntity) IsClientError() bool {
   147  	return true
   148  }
   149  
   150  // IsServerError returns true when this update task unprocessable entity response has a 5xx status code
   151  func (o *UpdateTaskUnprocessableEntity) IsServerError() bool {
   152  	return false
   153  }
   154  
   155  // IsCode returns true when this update task unprocessable entity response a status code equal to that given
   156  func (o *UpdateTaskUnprocessableEntity) IsCode(code int) bool {
   157  	return code == 422
   158  }
   159  
   160  // Code gets the status code for the update task unprocessable entity response
   161  func (o *UpdateTaskUnprocessableEntity) Code() int {
   162  	return 422
   163  }
   164  
   165  func (o *UpdateTaskUnprocessableEntity) Error() string {
   166  	payload, _ := json.Marshal(o.Payload)
   167  	return fmt.Sprintf("[PUT /tasks/{id}][%d] updateTaskUnprocessableEntity %s", 422, payload)
   168  }
   169  
   170  func (o *UpdateTaskUnprocessableEntity) String() string {
   171  	payload, _ := json.Marshal(o.Payload)
   172  	return fmt.Sprintf("[PUT /tasks/{id}][%d] updateTaskUnprocessableEntity %s", 422, payload)
   173  }
   174  
   175  func (o *UpdateTaskUnprocessableEntity) GetPayload() *models.ValidationError {
   176  	return o.Payload
   177  }
   178  
   179  func (o *UpdateTaskUnprocessableEntity) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error {
   180  
   181  	o.Payload = new(models.ValidationError)
   182  
   183  	// response payload
   184  	if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF {
   185  		return err
   186  	}
   187  
   188  	return nil
   189  }
   190  
   191  // NewUpdateTaskDefault creates a UpdateTaskDefault with default headers values
   192  func NewUpdateTaskDefault(code int) *UpdateTaskDefault {
   193  	return &UpdateTaskDefault{
   194  		_statusCode: code,
   195  	}
   196  }
   197  
   198  /*
   199  UpdateTaskDefault describes a response with status code -1, with default header values.
   200  
   201  Error response
   202  */
   203  type UpdateTaskDefault struct {
   204  	_statusCode int
   205  	XErrorCode  string
   206  
   207  	Payload *models.Error
   208  }
   209  
   210  // IsSuccess returns true when this update task default response has a 2xx status code
   211  func (o *UpdateTaskDefault) IsSuccess() bool {
   212  	return o._statusCode/100 == 2
   213  }
   214  
   215  // IsRedirect returns true when this update task default response has a 3xx status code
   216  func (o *UpdateTaskDefault) IsRedirect() bool {
   217  	return o._statusCode/100 == 3
   218  }
   219  
   220  // IsClientError returns true when this update task default response has a 4xx status code
   221  func (o *UpdateTaskDefault) IsClientError() bool {
   222  	return o._statusCode/100 == 4
   223  }
   224  
   225  // IsServerError returns true when this update task default response has a 5xx status code
   226  func (o *UpdateTaskDefault) IsServerError() bool {
   227  	return o._statusCode/100 == 5
   228  }
   229  
   230  // IsCode returns true when this update task default response a status code equal to that given
   231  func (o *UpdateTaskDefault) IsCode(code int) bool {
   232  	return o._statusCode == code
   233  }
   234  
   235  // Code gets the status code for the update task default response
   236  func (o *UpdateTaskDefault) Code() int {
   237  	return o._statusCode
   238  }
   239  
   240  func (o *UpdateTaskDefault) Error() string {
   241  	payload, _ := json.Marshal(o.Payload)
   242  	return fmt.Sprintf("[PUT /tasks/{id}][%d] updateTask default %s", o._statusCode, payload)
   243  }
   244  
   245  func (o *UpdateTaskDefault) String() string {
   246  	payload, _ := json.Marshal(o.Payload)
   247  	return fmt.Sprintf("[PUT /tasks/{id}][%d] updateTask default %s", o._statusCode, payload)
   248  }
   249  
   250  func (o *UpdateTaskDefault) GetPayload() *models.Error {
   251  	return o.Payload
   252  }
   253  
   254  func (o *UpdateTaskDefault) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error {
   255  
   256  	// hydrates response header X-Error-Code
   257  	hdrXErrorCode := response.GetHeader("X-Error-Code")
   258  
   259  	if hdrXErrorCode != "" {
   260  		o.XErrorCode = hdrXErrorCode
   261  	}
   262  
   263  	o.Payload = new(models.Error)
   264  
   265  	// response payload
   266  	if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF {
   267  		return err
   268  	}
   269  
   270  	return nil
   271  }