github.com/thetreep/go-swagger@v0.0.0-20240223100711-35af64f14f01/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/strfmt"
    17  	"github.com/go-openapi/swag"
    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  /*
    57  UploadTaskFileParams contains all the parameters to send to the API endpoint
    58  
    59  	for the upload task file operation.
    60  
    61  	Typically these are written to a http.Request.
    62  */
    63  type UploadTaskFileParams struct {
    64  
    65  	/* Description.
    66  
    67  	   Extra information describing the file
    68  	*/
    69  	Description *string
    70  
    71  	/* File.
    72  
    73  	   The file to upload
    74  	*/
    75  	File runtime.NamedReadCloser
    76  
    77  	/* ID.
    78  
    79  	   The id of the item
    80  
    81  	   Format: int64
    82  	*/
    83  	ID int64
    84  
    85  	timeout    time.Duration
    86  	Context    context.Context
    87  	HTTPClient *http.Client
    88  }
    89  
    90  // WithDefaults hydrates default values in the upload task file params (not the query body).
    91  //
    92  // All values with no default are reset to their zero value.
    93  func (o *UploadTaskFileParams) WithDefaults() *UploadTaskFileParams {
    94  	o.SetDefaults()
    95  	return o
    96  }
    97  
    98  // SetDefaults hydrates default values in the upload task file params (not the query body).
    99  //
   100  // All values with no default are reset to their zero value.
   101  func (o *UploadTaskFileParams) SetDefaults() {
   102  	// no default values defined for this parameter
   103  }
   104  
   105  // WithTimeout adds the timeout to the upload task file params
   106  func (o *UploadTaskFileParams) WithTimeout(timeout time.Duration) *UploadTaskFileParams {
   107  	o.SetTimeout(timeout)
   108  	return o
   109  }
   110  
   111  // SetTimeout adds the timeout to the upload task file params
   112  func (o *UploadTaskFileParams) SetTimeout(timeout time.Duration) {
   113  	o.timeout = timeout
   114  }
   115  
   116  // WithContext adds the context to the upload task file params
   117  func (o *UploadTaskFileParams) WithContext(ctx context.Context) *UploadTaskFileParams {
   118  	o.SetContext(ctx)
   119  	return o
   120  }
   121  
   122  // SetContext adds the context to the upload task file params
   123  func (o *UploadTaskFileParams) SetContext(ctx context.Context) {
   124  	o.Context = ctx
   125  }
   126  
   127  // WithHTTPClient adds the HTTPClient to the upload task file params
   128  func (o *UploadTaskFileParams) WithHTTPClient(client *http.Client) *UploadTaskFileParams {
   129  	o.SetHTTPClient(client)
   130  	return o
   131  }
   132  
   133  // SetHTTPClient adds the HTTPClient to the upload task file params
   134  func (o *UploadTaskFileParams) SetHTTPClient(client *http.Client) {
   135  	o.HTTPClient = client
   136  }
   137  
   138  // WithDescription adds the description to the upload task file params
   139  func (o *UploadTaskFileParams) WithDescription(description *string) *UploadTaskFileParams {
   140  	o.SetDescription(description)
   141  	return o
   142  }
   143  
   144  // SetDescription adds the description to the upload task file params
   145  func (o *UploadTaskFileParams) SetDescription(description *string) {
   146  	o.Description = description
   147  }
   148  
   149  // WithFile adds the file to the upload task file params
   150  func (o *UploadTaskFileParams) WithFile(file runtime.NamedReadCloser) *UploadTaskFileParams {
   151  	o.SetFile(file)
   152  	return o
   153  }
   154  
   155  // SetFile adds the file to the upload task file params
   156  func (o *UploadTaskFileParams) SetFile(file runtime.NamedReadCloser) {
   157  	o.File = file
   158  }
   159  
   160  // WithID adds the id to the upload task file params
   161  func (o *UploadTaskFileParams) WithID(id int64) *UploadTaskFileParams {
   162  	o.SetID(id)
   163  	return o
   164  }
   165  
   166  // SetID adds the id to the upload task file params
   167  func (o *UploadTaskFileParams) SetID(id int64) {
   168  	o.ID = id
   169  }
   170  
   171  // WriteToRequest writes these params to a swagger request
   172  func (o *UploadTaskFileParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error {
   173  
   174  	if err := r.SetTimeout(o.timeout); err != nil {
   175  		return err
   176  	}
   177  	var res []error
   178  
   179  	if o.Description != nil {
   180  
   181  		// form param description
   182  		var frDescription string
   183  		if o.Description != nil {
   184  			frDescription = *o.Description
   185  		}
   186  		fDescription := frDescription
   187  		if fDescription != "" {
   188  			if err := r.SetFormParam("description", fDescription); err != nil {
   189  				return err
   190  			}
   191  		}
   192  	}
   193  
   194  	if o.File != nil {
   195  
   196  		if o.File != nil {
   197  			// form file param file
   198  			if err := r.SetFileParam("file", o.File); err != nil {
   199  				return err
   200  			}
   201  		}
   202  	}
   203  
   204  	// path param id
   205  	if err := r.SetPathParam("id", swag.FormatInt64(o.ID)); err != nil {
   206  		return err
   207  	}
   208  
   209  	if len(res) > 0 {
   210  		return errors.CompositeValidationError(res...)
   211  	}
   212  	return nil
   213  }