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