github.com/circl-dev/go-swagger@v0.31.0/examples/task-tracker/client/tasks/list_tasks_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/errors"
    13  	"github.com/go-openapi/strfmt"
    14  	"github.com/go-openapi/swag"
    15  	"github.com/circl-dev/runtime"
    16  
    17  	"github.com/circl-dev/go-swagger/examples/task-tracker/models"
    18  )
    19  
    20  // ListTasksReader is a Reader for the ListTasks structure.
    21  type ListTasksReader struct {
    22  	formats strfmt.Registry
    23  }
    24  
    25  // ReadResponse reads a server response into the received o.
    26  func (o *ListTasksReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) {
    27  	switch response.Code() {
    28  	case 200:
    29  		result := NewListTasksOK()
    30  		if err := result.readResponse(response, consumer, o.formats); err != nil {
    31  			return nil, err
    32  		}
    33  		return result, nil
    34  	case 422:
    35  		result := NewListTasksUnprocessableEntity()
    36  		if err := result.readResponse(response, consumer, o.formats); err != nil {
    37  			return nil, err
    38  		}
    39  		return nil, result
    40  	default:
    41  		result := NewListTasksDefault(response.Code())
    42  		if err := result.readResponse(response, consumer, o.formats); err != nil {
    43  			return nil, err
    44  		}
    45  		if response.Code()/100 == 2 {
    46  			return result, nil
    47  		}
    48  		return nil, result
    49  	}
    50  }
    51  
    52  // NewListTasksOK creates a ListTasksOK with default headers values
    53  func NewListTasksOK() *ListTasksOK {
    54  	return &ListTasksOK{}
    55  }
    56  
    57  /* ListTasksOK describes a response with status code 200, with default header values.
    58  
    59  Successful response
    60  */
    61  type ListTasksOK struct {
    62  
    63  	/* the last task id known to the application
    64  
    65  	   Format: int64
    66  	*/
    67  	XLastTaskID int64
    68  
    69  	Payload []*models.TaskCard
    70  }
    71  
    72  func (o *ListTasksOK) Error() string {
    73  	return fmt.Sprintf("[GET /tasks][%d] listTasksOK  %+v", 200, o.Payload)
    74  }
    75  func (o *ListTasksOK) GetPayload() []*models.TaskCard {
    76  	return o.Payload
    77  }
    78  
    79  func (o *ListTasksOK) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error {
    80  
    81  	// hydrates response header X-Last-Task-Id
    82  	hdrXLastTaskID := response.GetHeader("X-Last-Task-Id")
    83  
    84  	if hdrXLastTaskID != "" {
    85  		valxLastTaskId, err := swag.ConvertInt64(hdrXLastTaskID)
    86  		if err != nil {
    87  			return errors.InvalidType("X-Last-Task-Id", "header", "int64", hdrXLastTaskID)
    88  		}
    89  		o.XLastTaskID = valxLastTaskId
    90  	}
    91  
    92  	// response payload
    93  	if err := consumer.Consume(response.Body(), &o.Payload); err != nil && err != io.EOF {
    94  		return err
    95  	}
    96  
    97  	return nil
    98  }
    99  
   100  // NewListTasksUnprocessableEntity creates a ListTasksUnprocessableEntity with default headers values
   101  func NewListTasksUnprocessableEntity() *ListTasksUnprocessableEntity {
   102  	return &ListTasksUnprocessableEntity{}
   103  }
   104  
   105  /* ListTasksUnprocessableEntity describes a response with status code 422, with default header values.
   106  
   107  Validation error
   108  */
   109  type ListTasksUnprocessableEntity struct {
   110  	Payload *models.ValidationError
   111  }
   112  
   113  func (o *ListTasksUnprocessableEntity) Error() string {
   114  	return fmt.Sprintf("[GET /tasks][%d] listTasksUnprocessableEntity  %+v", 422, o.Payload)
   115  }
   116  func (o *ListTasksUnprocessableEntity) GetPayload() *models.ValidationError {
   117  	return o.Payload
   118  }
   119  
   120  func (o *ListTasksUnprocessableEntity) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error {
   121  
   122  	o.Payload = new(models.ValidationError)
   123  
   124  	// response payload
   125  	if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF {
   126  		return err
   127  	}
   128  
   129  	return nil
   130  }
   131  
   132  // NewListTasksDefault creates a ListTasksDefault with default headers values
   133  func NewListTasksDefault(code int) *ListTasksDefault {
   134  	return &ListTasksDefault{
   135  		_statusCode: code,
   136  	}
   137  }
   138  
   139  /* ListTasksDefault describes a response with status code -1, with default header values.
   140  
   141  Error response
   142  */
   143  type ListTasksDefault struct {
   144  	_statusCode int
   145  	XErrorCode  string
   146  
   147  	Payload *models.Error
   148  }
   149  
   150  // Code gets the status code for the list tasks default response
   151  func (o *ListTasksDefault) Code() int {
   152  	return o._statusCode
   153  }
   154  
   155  func (o *ListTasksDefault) Error() string {
   156  	return fmt.Sprintf("[GET /tasks][%d] listTasks default  %+v", o._statusCode, o.Payload)
   157  }
   158  func (o *ListTasksDefault) GetPayload() *models.Error {
   159  	return o.Payload
   160  }
   161  
   162  func (o *ListTasksDefault) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error {
   163  
   164  	// hydrates response header X-Error-Code
   165  	hdrXErrorCode := response.GetHeader("X-Error-Code")
   166  
   167  	if hdrXErrorCode != "" {
   168  		o.XErrorCode = hdrXErrorCode
   169  	}
   170  
   171  	o.Payload = new(models.Error)
   172  
   173  	// response payload
   174  	if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF {
   175  		return err
   176  	}
   177  
   178  	return nil
   179  }