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