github.com/thetreep/go-swagger@v0.0.0-20240223100711-35af64f14f01/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/runtime" 15 cr "github.com/go-openapi/runtime/client" 16 "github.com/go-openapi/strfmt" 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 /* 56 UploadFileParams contains all the parameters to send to the API endpoint 57 58 for the upload file operation. 59 60 Typically these are written to a http.Request. 61 */ 62 type UploadFileParams struct { 63 64 // File. 65 File runtime.NamedReadCloser 66 67 timeout time.Duration 68 Context context.Context 69 HTTPClient *http.Client 70 } 71 72 // WithDefaults hydrates default values in the upload file params (not the query body). 73 // 74 // All values with no default are reset to their zero value. 75 func (o *UploadFileParams) WithDefaults() *UploadFileParams { 76 o.SetDefaults() 77 return o 78 } 79 80 // SetDefaults hydrates default values in the upload file params (not the query body). 81 // 82 // All values with no default are reset to their zero value. 83 func (o *UploadFileParams) SetDefaults() { 84 // no default values defined for this parameter 85 } 86 87 // WithTimeout adds the timeout to the upload file params 88 func (o *UploadFileParams) WithTimeout(timeout time.Duration) *UploadFileParams { 89 o.SetTimeout(timeout) 90 return o 91 } 92 93 // SetTimeout adds the timeout to the upload file params 94 func (o *UploadFileParams) SetTimeout(timeout time.Duration) { 95 o.timeout = timeout 96 } 97 98 // WithContext adds the context to the upload file params 99 func (o *UploadFileParams) WithContext(ctx context.Context) *UploadFileParams { 100 o.SetContext(ctx) 101 return o 102 } 103 104 // SetContext adds the context to the upload file params 105 func (o *UploadFileParams) SetContext(ctx context.Context) { 106 o.Context = ctx 107 } 108 109 // WithHTTPClient adds the HTTPClient to the upload file params 110 func (o *UploadFileParams) WithHTTPClient(client *http.Client) *UploadFileParams { 111 o.SetHTTPClient(client) 112 return o 113 } 114 115 // SetHTTPClient adds the HTTPClient to the upload file params 116 func (o *UploadFileParams) SetHTTPClient(client *http.Client) { 117 o.HTTPClient = client 118 } 119 120 // WithFile adds the file to the upload file params 121 func (o *UploadFileParams) WithFile(file runtime.NamedReadCloser) *UploadFileParams { 122 o.SetFile(file) 123 return o 124 } 125 126 // SetFile adds the file to the upload file params 127 func (o *UploadFileParams) SetFile(file runtime.NamedReadCloser) { 128 o.File = file 129 } 130 131 // WriteToRequest writes these params to a swagger request 132 func (o *UploadFileParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error { 133 134 if err := r.SetTimeout(o.timeout); err != nil { 135 return err 136 } 137 var res []error 138 // form file param file 139 if err := r.SetFileParam("file", o.File); err != nil { 140 return err 141 } 142 143 if len(res) > 0 { 144 return errors.CompositeValidationError(res...) 145 } 146 return nil 147 }