github.com/go-swagger/go-swagger@v0.31.0/examples/task-tracker/restapi/operations/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  	"net/http"
    10  
    11  	"github.com/go-openapi/runtime"
    12  	"github.com/go-openapi/swag"
    13  
    14  	"github.com/go-swagger/go-swagger/examples/task-tracker/models"
    15  )
    16  
    17  // ListTasksOKCode is the HTTP code returned for type ListTasksOK
    18  const ListTasksOKCode int = 200
    19  
    20  /*
    21  ListTasksOK Successful response
    22  
    23  swagger:response listTasksOK
    24  */
    25  type ListTasksOK struct {
    26  	/*the last task id known to the application
    27  
    28  	 */
    29  	XLastTaskID int64 `json:"X-Last-Task-Id"`
    30  
    31  	/*
    32  	  In: Body
    33  	*/
    34  	Payload []*models.TaskCard `json:"body,omitempty"`
    35  }
    36  
    37  // NewListTasksOK creates ListTasksOK with default headers values
    38  func NewListTasksOK() *ListTasksOK {
    39  
    40  	return &ListTasksOK{}
    41  }
    42  
    43  // WithXLastTaskID adds the xLastTaskId to the list tasks o k response
    44  func (o *ListTasksOK) WithXLastTaskID(xLastTaskID int64) *ListTasksOK {
    45  	o.XLastTaskID = xLastTaskID
    46  	return o
    47  }
    48  
    49  // SetXLastTaskID sets the xLastTaskId to the list tasks o k response
    50  func (o *ListTasksOK) SetXLastTaskID(xLastTaskID int64) {
    51  	o.XLastTaskID = xLastTaskID
    52  }
    53  
    54  // WithPayload adds the payload to the list tasks o k response
    55  func (o *ListTasksOK) WithPayload(payload []*models.TaskCard) *ListTasksOK {
    56  	o.Payload = payload
    57  	return o
    58  }
    59  
    60  // SetPayload sets the payload to the list tasks o k response
    61  func (o *ListTasksOK) SetPayload(payload []*models.TaskCard) {
    62  	o.Payload = payload
    63  }
    64  
    65  // WriteResponse to the client
    66  func (o *ListTasksOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {
    67  
    68  	// response header X-Last-Task-Id
    69  
    70  	xLastTaskID := swag.FormatInt64(o.XLastTaskID)
    71  	if xLastTaskID != "" {
    72  		rw.Header().Set("X-Last-Task-Id", xLastTaskID)
    73  	}
    74  
    75  	rw.WriteHeader(200)
    76  	payload := o.Payload
    77  	if payload == nil {
    78  		// return empty array
    79  		payload = make([]*models.TaskCard, 0, 50)
    80  	}
    81  
    82  	if err := producer.Produce(rw, payload); err != nil {
    83  		panic(err) // let the recovery middleware deal with this
    84  	}
    85  }
    86  
    87  // ListTasksUnprocessableEntityCode is the HTTP code returned for type ListTasksUnprocessableEntity
    88  const ListTasksUnprocessableEntityCode int = 422
    89  
    90  /*
    91  ListTasksUnprocessableEntity Validation error
    92  
    93  swagger:response listTasksUnprocessableEntity
    94  */
    95  type ListTasksUnprocessableEntity struct {
    96  
    97  	/*
    98  	  In: Body
    99  	*/
   100  	Payload *models.ValidationError `json:"body,omitempty"`
   101  }
   102  
   103  // NewListTasksUnprocessableEntity creates ListTasksUnprocessableEntity with default headers values
   104  func NewListTasksUnprocessableEntity() *ListTasksUnprocessableEntity {
   105  
   106  	return &ListTasksUnprocessableEntity{}
   107  }
   108  
   109  // WithPayload adds the payload to the list tasks unprocessable entity response
   110  func (o *ListTasksUnprocessableEntity) WithPayload(payload *models.ValidationError) *ListTasksUnprocessableEntity {
   111  	o.Payload = payload
   112  	return o
   113  }
   114  
   115  // SetPayload sets the payload to the list tasks unprocessable entity response
   116  func (o *ListTasksUnprocessableEntity) SetPayload(payload *models.ValidationError) {
   117  	o.Payload = payload
   118  }
   119  
   120  // WriteResponse to the client
   121  func (o *ListTasksUnprocessableEntity) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {
   122  
   123  	rw.WriteHeader(422)
   124  	if o.Payload != nil {
   125  		payload := o.Payload
   126  		if err := producer.Produce(rw, payload); err != nil {
   127  			panic(err) // let the recovery middleware deal with this
   128  		}
   129  	}
   130  }
   131  
   132  /*
   133  ListTasksDefault Error response
   134  
   135  swagger:response listTasksDefault
   136  */
   137  type ListTasksDefault struct {
   138  	_statusCode int
   139  	/*
   140  
   141  	 */
   142  	XErrorCode string `json:"X-Error-Code"`
   143  
   144  	/*
   145  	  In: Body
   146  	*/
   147  	Payload *models.Error `json:"body,omitempty"`
   148  }
   149  
   150  // NewListTasksDefault creates ListTasksDefault with default headers values
   151  func NewListTasksDefault(code int) *ListTasksDefault {
   152  	if code <= 0 {
   153  		code = 500
   154  	}
   155  
   156  	return &ListTasksDefault{
   157  		_statusCode: code,
   158  	}
   159  }
   160  
   161  // WithStatusCode adds the status to the list tasks default response
   162  func (o *ListTasksDefault) WithStatusCode(code int) *ListTasksDefault {
   163  	o._statusCode = code
   164  	return o
   165  }
   166  
   167  // SetStatusCode sets the status to the list tasks default response
   168  func (o *ListTasksDefault) SetStatusCode(code int) {
   169  	o._statusCode = code
   170  }
   171  
   172  // WithXErrorCode adds the xErrorCode to the list tasks default response
   173  func (o *ListTasksDefault) WithXErrorCode(xErrorCode string) *ListTasksDefault {
   174  	o.XErrorCode = xErrorCode
   175  	return o
   176  }
   177  
   178  // SetXErrorCode sets the xErrorCode to the list tasks default response
   179  func (o *ListTasksDefault) SetXErrorCode(xErrorCode string) {
   180  	o.XErrorCode = xErrorCode
   181  }
   182  
   183  // WithPayload adds the payload to the list tasks default response
   184  func (o *ListTasksDefault) WithPayload(payload *models.Error) *ListTasksDefault {
   185  	o.Payload = payload
   186  	return o
   187  }
   188  
   189  // SetPayload sets the payload to the list tasks default response
   190  func (o *ListTasksDefault) SetPayload(payload *models.Error) {
   191  	o.Payload = payload
   192  }
   193  
   194  // WriteResponse to the client
   195  func (o *ListTasksDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {
   196  
   197  	// response header X-Error-Code
   198  
   199  	xErrorCode := o.XErrorCode
   200  	if xErrorCode != "" {
   201  		rw.Header().Set("X-Error-Code", xErrorCode)
   202  	}
   203  
   204  	rw.WriteHeader(o._statusCode)
   205  	if o.Payload != nil {
   206  		payload := o.Payload
   207  		if err := producer.Produce(rw, payload); err != nil {
   208  			panic(err) // let the recovery middleware deal with this
   209  		}
   210  	}
   211  }