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