github.com/djarvur/go-swagger@v0.18.0/examples/task-tracker/client/tasks/upload_task_file_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  
    21  // NewUploadTaskFileParams creates a new UploadTaskFileParams object
    22  // with the default values initialized.
    23  func NewUploadTaskFileParams() *UploadTaskFileParams {
    24  	var ()
    25  	return &UploadTaskFileParams{
    26  
    27  		timeout: cr.DefaultTimeout,
    28  	}
    29  }
    30  
    31  // NewUploadTaskFileParamsWithTimeout creates a new UploadTaskFileParams object
    32  // with the default values initialized, and the ability to set a timeout on a request
    33  func NewUploadTaskFileParamsWithTimeout(timeout time.Duration) *UploadTaskFileParams {
    34  	var ()
    35  	return &UploadTaskFileParams{
    36  
    37  		timeout: timeout,
    38  	}
    39  }
    40  
    41  // NewUploadTaskFileParamsWithContext creates a new UploadTaskFileParams object
    42  // with the default values initialized, and the ability to set a context for a request
    43  func NewUploadTaskFileParamsWithContext(ctx context.Context) *UploadTaskFileParams {
    44  	var ()
    45  	return &UploadTaskFileParams{
    46  
    47  		Context: ctx,
    48  	}
    49  }
    50  
    51  // NewUploadTaskFileParamsWithHTTPClient creates a new UploadTaskFileParams object
    52  // with the default values initialized, and the ability to set a custom HTTPClient for a request
    53  func NewUploadTaskFileParamsWithHTTPClient(client *http.Client) *UploadTaskFileParams {
    54  	var ()
    55  	return &UploadTaskFileParams{
    56  		HTTPClient: client,
    57  	}
    58  }
    59  
    60  /*UploadTaskFileParams contains all the parameters to send to the API endpoint
    61  for the upload task file operation typically these are written to a http.Request
    62  */
    63  type UploadTaskFileParams struct {
    64  
    65  	/*Description
    66  	  Extra information describing the file
    67  
    68  	*/
    69  	Description *string
    70  	/*File
    71  	  The file to upload
    72  
    73  	*/
    74  	File runtime.NamedReadCloser
    75  	/*ID
    76  	  The id of the item
    77  
    78  	*/
    79  	ID int64
    80  
    81  	timeout    time.Duration
    82  	Context    context.Context
    83  	HTTPClient *http.Client
    84  }
    85  
    86  // WithTimeout adds the timeout to the upload task file params
    87  func (o *UploadTaskFileParams) WithTimeout(timeout time.Duration) *UploadTaskFileParams {
    88  	o.SetTimeout(timeout)
    89  	return o
    90  }
    91  
    92  // SetTimeout adds the timeout to the upload task file params
    93  func (o *UploadTaskFileParams) SetTimeout(timeout time.Duration) {
    94  	o.timeout = timeout
    95  }
    96  
    97  // WithContext adds the context to the upload task file params
    98  func (o *UploadTaskFileParams) WithContext(ctx context.Context) *UploadTaskFileParams {
    99  	o.SetContext(ctx)
   100  	return o
   101  }
   102  
   103  // SetContext adds the context to the upload task file params
   104  func (o *UploadTaskFileParams) SetContext(ctx context.Context) {
   105  	o.Context = ctx
   106  }
   107  
   108  // WithHTTPClient adds the HTTPClient to the upload task file params
   109  func (o *UploadTaskFileParams) WithHTTPClient(client *http.Client) *UploadTaskFileParams {
   110  	o.SetHTTPClient(client)
   111  	return o
   112  }
   113  
   114  // SetHTTPClient adds the HTTPClient to the upload task file params
   115  func (o *UploadTaskFileParams) SetHTTPClient(client *http.Client) {
   116  	o.HTTPClient = client
   117  }
   118  
   119  // WithDescription adds the description to the upload task file params
   120  func (o *UploadTaskFileParams) WithDescription(description *string) *UploadTaskFileParams {
   121  	o.SetDescription(description)
   122  	return o
   123  }
   124  
   125  // SetDescription adds the description to the upload task file params
   126  func (o *UploadTaskFileParams) SetDescription(description *string) {
   127  	o.Description = description
   128  }
   129  
   130  // WithFile adds the file to the upload task file params
   131  func (o *UploadTaskFileParams) WithFile(file runtime.NamedReadCloser) *UploadTaskFileParams {
   132  	o.SetFile(file)
   133  	return o
   134  }
   135  
   136  // SetFile adds the file to the upload task file params
   137  func (o *UploadTaskFileParams) SetFile(file runtime.NamedReadCloser) {
   138  	o.File = file
   139  }
   140  
   141  // WithID adds the id to the upload task file params
   142  func (o *UploadTaskFileParams) WithID(id int64) *UploadTaskFileParams {
   143  	o.SetID(id)
   144  	return o
   145  }
   146  
   147  // SetID adds the id to the upload task file params
   148  func (o *UploadTaskFileParams) SetID(id int64) {
   149  	o.ID = id
   150  }
   151  
   152  // WriteToRequest writes these params to a swagger request
   153  func (o *UploadTaskFileParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error {
   154  
   155  	if err := r.SetTimeout(o.timeout); err != nil {
   156  		return err
   157  	}
   158  	var res []error
   159  
   160  	if o.Description != nil {
   161  
   162  		// form param description
   163  		var frDescription string
   164  		if o.Description != nil {
   165  			frDescription = *o.Description
   166  		}
   167  		fDescription := frDescription
   168  		if fDescription != "" {
   169  			if err := r.SetFormParam("description", fDescription); err != nil {
   170  				return err
   171  			}
   172  		}
   173  
   174  	}
   175  
   176  	if o.File != nil {
   177  
   178  		if o.File != nil {
   179  
   180  			// form file param file
   181  			if err := r.SetFileParam("file", o.File); err != nil {
   182  				return err
   183  			}
   184  
   185  		}
   186  
   187  	}
   188  
   189  	// path param id
   190  	if err := r.SetPathParam("id", swag.FormatInt64(o.ID)); err != nil {
   191  		return err
   192  	}
   193  
   194  	if len(res) > 0 {
   195  		return errors.CompositeValidationError(res...)
   196  	}
   197  	return nil
   198  }