github.com/kaisawind/go-swagger@v0.19.0/examples/task-tracker/restapi/operations/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  	"net/http"
    10  
    11  	"github.com/go-openapi/runtime"
    12  
    13  	models "github.com/go-swagger/go-swagger/examples/task-tracker/models"
    14  )
    15  
    16  // UpdateTaskOKCode is the HTTP code returned for type UpdateTaskOK
    17  const UpdateTaskOKCode int = 200
    18  
    19  /*UpdateTaskOK Task details
    20  
    21  swagger:response updateTaskOK
    22  */
    23  type UpdateTaskOK struct {
    24  
    25  	/*
    26  	  In: Body
    27  	*/
    28  	Payload *models.Task `json:"body,omitempty"`
    29  }
    30  
    31  // NewUpdateTaskOK creates UpdateTaskOK with default headers values
    32  func NewUpdateTaskOK() *UpdateTaskOK {
    33  
    34  	return &UpdateTaskOK{}
    35  }
    36  
    37  // WithPayload adds the payload to the update task o k response
    38  func (o *UpdateTaskOK) WithPayload(payload *models.Task) *UpdateTaskOK {
    39  	o.Payload = payload
    40  	return o
    41  }
    42  
    43  // SetPayload sets the payload to the update task o k response
    44  func (o *UpdateTaskOK) SetPayload(payload *models.Task) {
    45  	o.Payload = payload
    46  }
    47  
    48  // WriteResponse to the client
    49  func (o *UpdateTaskOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {
    50  
    51  	rw.WriteHeader(200)
    52  	if o.Payload != nil {
    53  		payload := o.Payload
    54  		if err := producer.Produce(rw, payload); err != nil {
    55  			panic(err) // let the recovery middleware deal with this
    56  		}
    57  	}
    58  }
    59  
    60  // UpdateTaskUnprocessableEntityCode is the HTTP code returned for type UpdateTaskUnprocessableEntity
    61  const UpdateTaskUnprocessableEntityCode int = 422
    62  
    63  /*UpdateTaskUnprocessableEntity Validation error
    64  
    65  swagger:response updateTaskUnprocessableEntity
    66  */
    67  type UpdateTaskUnprocessableEntity struct {
    68  
    69  	/*
    70  	  In: Body
    71  	*/
    72  	Payload *models.ValidationError `json:"body,omitempty"`
    73  }
    74  
    75  // NewUpdateTaskUnprocessableEntity creates UpdateTaskUnprocessableEntity with default headers values
    76  func NewUpdateTaskUnprocessableEntity() *UpdateTaskUnprocessableEntity {
    77  
    78  	return &UpdateTaskUnprocessableEntity{}
    79  }
    80  
    81  // WithPayload adds the payload to the update task unprocessable entity response
    82  func (o *UpdateTaskUnprocessableEntity) WithPayload(payload *models.ValidationError) *UpdateTaskUnprocessableEntity {
    83  	o.Payload = payload
    84  	return o
    85  }
    86  
    87  // SetPayload sets the payload to the update task unprocessable entity response
    88  func (o *UpdateTaskUnprocessableEntity) SetPayload(payload *models.ValidationError) {
    89  	o.Payload = payload
    90  }
    91  
    92  // WriteResponse to the client
    93  func (o *UpdateTaskUnprocessableEntity) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {
    94  
    95  	rw.WriteHeader(422)
    96  	if o.Payload != nil {
    97  		payload := o.Payload
    98  		if err := producer.Produce(rw, payload); err != nil {
    99  			panic(err) // let the recovery middleware deal with this
   100  		}
   101  	}
   102  }
   103  
   104  /*UpdateTaskDefault Error response
   105  
   106  swagger:response updateTaskDefault
   107  */
   108  type UpdateTaskDefault struct {
   109  	_statusCode int
   110  	/*
   111  
   112  	 */
   113  	XErrorCode string `json:"X-Error-Code"`
   114  
   115  	/*
   116  	  In: Body
   117  	*/
   118  	Payload *models.Error `json:"body,omitempty"`
   119  }
   120  
   121  // NewUpdateTaskDefault creates UpdateTaskDefault with default headers values
   122  func NewUpdateTaskDefault(code int) *UpdateTaskDefault {
   123  	if code <= 0 {
   124  		code = 500
   125  	}
   126  
   127  	return &UpdateTaskDefault{
   128  		_statusCode: code,
   129  	}
   130  }
   131  
   132  // WithStatusCode adds the status to the update task default response
   133  func (o *UpdateTaskDefault) WithStatusCode(code int) *UpdateTaskDefault {
   134  	o._statusCode = code
   135  	return o
   136  }
   137  
   138  // SetStatusCode sets the status to the update task default response
   139  func (o *UpdateTaskDefault) SetStatusCode(code int) {
   140  	o._statusCode = code
   141  }
   142  
   143  // WithXErrorCode adds the xErrorCode to the update task default response
   144  func (o *UpdateTaskDefault) WithXErrorCode(xErrorCode string) *UpdateTaskDefault {
   145  	o.XErrorCode = xErrorCode
   146  	return o
   147  }
   148  
   149  // SetXErrorCode sets the xErrorCode to the update task default response
   150  func (o *UpdateTaskDefault) SetXErrorCode(xErrorCode string) {
   151  	o.XErrorCode = xErrorCode
   152  }
   153  
   154  // WithPayload adds the payload to the update task default response
   155  func (o *UpdateTaskDefault) WithPayload(payload *models.Error) *UpdateTaskDefault {
   156  	o.Payload = payload
   157  	return o
   158  }
   159  
   160  // SetPayload sets the payload to the update task default response
   161  func (o *UpdateTaskDefault) SetPayload(payload *models.Error) {
   162  	o.Payload = payload
   163  }
   164  
   165  // WriteResponse to the client
   166  func (o *UpdateTaskDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {
   167  
   168  	// response header X-Error-Code
   169  
   170  	xErrorCode := o.XErrorCode
   171  	if xErrorCode != "" {
   172  		rw.Header().Set("X-Error-Code", xErrorCode)
   173  	}
   174  
   175  	rw.WriteHeader(o._statusCode)
   176  	if o.Payload != nil {
   177  		payload := o.Payload
   178  		if err := producer.Produce(rw, payload); err != nil {
   179  			panic(err) // let the recovery middleware deal with this
   180  		}
   181  	}
   182  }