github.com/kaisawind/go-swagger@v0.19.0/examples/task-tracker/client/tasks/update_task_parameters.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  	"context"
    10  	"net/http"
    11  	"time"
    12  
    13  	"github.com/go-openapi/errors"
    14  	"github.com/go-openapi/runtime"
    15  	cr "github.com/go-openapi/runtime/client"
    16  	"github.com/go-openapi/swag"
    17  
    18  	strfmt "github.com/go-openapi/strfmt"
    19  
    20  	models "github.com/go-swagger/go-swagger/examples/task-tracker/models"
    21  )
    22  
    23  // NewUpdateTaskParams creates a new UpdateTaskParams object
    24  // with the default values initialized.
    25  func NewUpdateTaskParams() *UpdateTaskParams {
    26  	var ()
    27  	return &UpdateTaskParams{
    28  
    29  		timeout: cr.DefaultTimeout,
    30  	}
    31  }
    32  
    33  // NewUpdateTaskParamsWithTimeout creates a new UpdateTaskParams object
    34  // with the default values initialized, and the ability to set a timeout on a request
    35  func NewUpdateTaskParamsWithTimeout(timeout time.Duration) *UpdateTaskParams {
    36  	var ()
    37  	return &UpdateTaskParams{
    38  
    39  		timeout: timeout,
    40  	}
    41  }
    42  
    43  // NewUpdateTaskParamsWithContext creates a new UpdateTaskParams object
    44  // with the default values initialized, and the ability to set a context for a request
    45  func NewUpdateTaskParamsWithContext(ctx context.Context) *UpdateTaskParams {
    46  	var ()
    47  	return &UpdateTaskParams{
    48  
    49  		Context: ctx,
    50  	}
    51  }
    52  
    53  // NewUpdateTaskParamsWithHTTPClient creates a new UpdateTaskParams object
    54  // with the default values initialized, and the ability to set a custom HTTPClient for a request
    55  func NewUpdateTaskParamsWithHTTPClient(client *http.Client) *UpdateTaskParams {
    56  	var ()
    57  	return &UpdateTaskParams{
    58  		HTTPClient: client,
    59  	}
    60  }
    61  
    62  /*UpdateTaskParams contains all the parameters to send to the API endpoint
    63  for the update task operation typically these are written to a http.Request
    64  */
    65  type UpdateTaskParams struct {
    66  
    67  	/*Body
    68  	  The task to update
    69  
    70  	*/
    71  	Body *models.Task
    72  	/*ID
    73  	  The id of the item
    74  
    75  	*/
    76  	ID int64
    77  
    78  	timeout    time.Duration
    79  	Context    context.Context
    80  	HTTPClient *http.Client
    81  }
    82  
    83  // WithTimeout adds the timeout to the update task params
    84  func (o *UpdateTaskParams) WithTimeout(timeout time.Duration) *UpdateTaskParams {
    85  	o.SetTimeout(timeout)
    86  	return o
    87  }
    88  
    89  // SetTimeout adds the timeout to the update task params
    90  func (o *UpdateTaskParams) SetTimeout(timeout time.Duration) {
    91  	o.timeout = timeout
    92  }
    93  
    94  // WithContext adds the context to the update task params
    95  func (o *UpdateTaskParams) WithContext(ctx context.Context) *UpdateTaskParams {
    96  	o.SetContext(ctx)
    97  	return o
    98  }
    99  
   100  // SetContext adds the context to the update task params
   101  func (o *UpdateTaskParams) SetContext(ctx context.Context) {
   102  	o.Context = ctx
   103  }
   104  
   105  // WithHTTPClient adds the HTTPClient to the update task params
   106  func (o *UpdateTaskParams) WithHTTPClient(client *http.Client) *UpdateTaskParams {
   107  	o.SetHTTPClient(client)
   108  	return o
   109  }
   110  
   111  // SetHTTPClient adds the HTTPClient to the update task params
   112  func (o *UpdateTaskParams) SetHTTPClient(client *http.Client) {
   113  	o.HTTPClient = client
   114  }
   115  
   116  // WithBody adds the body to the update task params
   117  func (o *UpdateTaskParams) WithBody(body *models.Task) *UpdateTaskParams {
   118  	o.SetBody(body)
   119  	return o
   120  }
   121  
   122  // SetBody adds the body to the update task params
   123  func (o *UpdateTaskParams) SetBody(body *models.Task) {
   124  	o.Body = body
   125  }
   126  
   127  // WithID adds the id to the update task params
   128  func (o *UpdateTaskParams) WithID(id int64) *UpdateTaskParams {
   129  	o.SetID(id)
   130  	return o
   131  }
   132  
   133  // SetID adds the id to the update task params
   134  func (o *UpdateTaskParams) SetID(id int64) {
   135  	o.ID = id
   136  }
   137  
   138  // WriteToRequest writes these params to a swagger request
   139  func (o *UpdateTaskParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error {
   140  
   141  	if err := r.SetTimeout(o.timeout); err != nil {
   142  		return err
   143  	}
   144  	var res []error
   145  
   146  	if o.Body != nil {
   147  		if err := r.SetBodyParam(o.Body); err != nil {
   148  			return err
   149  		}
   150  	}
   151  
   152  	// path param id
   153  	if err := r.SetPathParam("id", swag.FormatInt64(o.ID)); err != nil {
   154  		return err
   155  	}
   156  
   157  	if len(res) > 0 {
   158  		return errors.CompositeValidationError(res...)
   159  	}
   160  	return nil
   161  }