github.com/circl-dev/go-swagger@v0.31.0/examples/file-server/client/uploads/upload_file_parameters.go (about)

     1  // Code generated by go-swagger; DO NOT EDIT.
     2  
     3  package uploads
     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/circl-dev/runtime"
    16  	cr "github.com/circl-dev/runtime/client"
    17  )
    18  
    19  // NewUploadFileParams creates a new UploadFileParams object,
    20  // with the default timeout for this client.
    21  //
    22  // Default values are not hydrated, since defaults are normally applied by the API server side.
    23  //
    24  // To enforce default values in parameter, use SetDefaults or WithDefaults.
    25  func NewUploadFileParams() *UploadFileParams {
    26  	return &UploadFileParams{
    27  		timeout: cr.DefaultTimeout,
    28  	}
    29  }
    30  
    31  // NewUploadFileParamsWithTimeout creates a new UploadFileParams object
    32  // with the ability to set a timeout on a request.
    33  func NewUploadFileParamsWithTimeout(timeout time.Duration) *UploadFileParams {
    34  	return &UploadFileParams{
    35  		timeout: timeout,
    36  	}
    37  }
    38  
    39  // NewUploadFileParamsWithContext creates a new UploadFileParams object
    40  // with the ability to set a context for a request.
    41  func NewUploadFileParamsWithContext(ctx context.Context) *UploadFileParams {
    42  	return &UploadFileParams{
    43  		Context: ctx,
    44  	}
    45  }
    46  
    47  // NewUploadFileParamsWithHTTPClient creates a new UploadFileParams object
    48  // with the ability to set a custom HTTPClient for a request.
    49  func NewUploadFileParamsWithHTTPClient(client *http.Client) *UploadFileParams {
    50  	return &UploadFileParams{
    51  		HTTPClient: client,
    52  	}
    53  }
    54  
    55  /* UploadFileParams contains all the parameters to send to the API endpoint
    56     for the upload file operation.
    57  
    58     Typically these are written to a http.Request.
    59  */
    60  type UploadFileParams struct {
    61  
    62  	// File.
    63  	File runtime.NamedReadCloser
    64  
    65  	timeout    time.Duration
    66  	Context    context.Context
    67  	HTTPClient *http.Client
    68  }
    69  
    70  // WithDefaults hydrates default values in the upload file params (not the query body).
    71  //
    72  // All values with no default are reset to their zero value.
    73  func (o *UploadFileParams) WithDefaults() *UploadFileParams {
    74  	o.SetDefaults()
    75  	return o
    76  }
    77  
    78  // SetDefaults hydrates default values in the upload file params (not the query body).
    79  //
    80  // All values with no default are reset to their zero value.
    81  func (o *UploadFileParams) SetDefaults() {
    82  	// no default values defined for this parameter
    83  }
    84  
    85  // WithTimeout adds the timeout to the upload file params
    86  func (o *UploadFileParams) WithTimeout(timeout time.Duration) *UploadFileParams {
    87  	o.SetTimeout(timeout)
    88  	return o
    89  }
    90  
    91  // SetTimeout adds the timeout to the upload file params
    92  func (o *UploadFileParams) SetTimeout(timeout time.Duration) {
    93  	o.timeout = timeout
    94  }
    95  
    96  // WithContext adds the context to the upload file params
    97  func (o *UploadFileParams) WithContext(ctx context.Context) *UploadFileParams {
    98  	o.SetContext(ctx)
    99  	return o
   100  }
   101  
   102  // SetContext adds the context to the upload file params
   103  func (o *UploadFileParams) SetContext(ctx context.Context) {
   104  	o.Context = ctx
   105  }
   106  
   107  // WithHTTPClient adds the HTTPClient to the upload file params
   108  func (o *UploadFileParams) WithHTTPClient(client *http.Client) *UploadFileParams {
   109  	o.SetHTTPClient(client)
   110  	return o
   111  }
   112  
   113  // SetHTTPClient adds the HTTPClient to the upload file params
   114  func (o *UploadFileParams) SetHTTPClient(client *http.Client) {
   115  	o.HTTPClient = client
   116  }
   117  
   118  // WithFile adds the file to the upload file params
   119  func (o *UploadFileParams) WithFile(file runtime.NamedReadCloser) *UploadFileParams {
   120  	o.SetFile(file)
   121  	return o
   122  }
   123  
   124  // SetFile adds the file to the upload file params
   125  func (o *UploadFileParams) SetFile(file runtime.NamedReadCloser) {
   126  	o.File = file
   127  }
   128  
   129  // WriteToRequest writes these params to a swagger request
   130  func (o *UploadFileParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error {
   131  
   132  	if err := r.SetTimeout(o.timeout); err != nil {
   133  		return err
   134  	}
   135  	var res []error
   136  	// form file param file
   137  	if err := r.SetFileParam("file", o.File); err != nil {
   138  		return err
   139  	}
   140  
   141  	if len(res) > 0 {
   142  		return errors.CompositeValidationError(res...)
   143  	}
   144  	return nil
   145  }