github.com/sap/cf-mta-plugin@v2.6.3+incompatible/clients/mtaclient/operations/upload_mta_file_parameters.go (about) 1 // Code generated by go-swagger; DO NOT EDIT. 2 3 package operations 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 "net/http" 10 "os" 11 "strconv" 12 "time" 13 14 "golang.org/x/net/context" 15 16 "github.com/go-openapi/errors" 17 "github.com/go-openapi/runtime" 18 cr "github.com/go-openapi/runtime/client" 19 20 strfmt "github.com/go-openapi/strfmt" 21 ) 22 23 // NewUploadMtaFileParams creates a new UploadMtaFileParams object 24 // with the default values initialized. 25 func NewUploadMtaFileParams() *UploadMtaFileParams { 26 return &UploadMtaFileParams{ 27 timeout: cr.DefaultTimeout, 28 } 29 } 30 31 // NewUploadMtaFileParamsWithTimeout creates a new UploadMtaFileParams object 32 // with the default values initialized, and the ability to set a timeout on a request 33 func NewUploadMtaFileParamsWithTimeout(timeout time.Duration) *UploadMtaFileParams { 34 return &UploadMtaFileParams{ 35 timeout: timeout, 36 } 37 } 38 39 // NewUploadMtaFileParamsWithContext creates a new UploadMtaFileParams object 40 // with the default values initialized, and the ability to set a context for a request 41 func NewUploadMtaFileParamsWithContext(ctx context.Context) *UploadMtaFileParams { 42 return &UploadMtaFileParams{ 43 Context: ctx, 44 } 45 } 46 47 // NewUploadMtaFileParamsWithHTTPClient creates a new UploadMtaFileParams object 48 // with the default values initialized, and the ability to set a custom HTTPClient for a request 49 func NewUploadMtaFileParamsWithHTTPClient(client *http.Client) *UploadMtaFileParams { 50 return &UploadMtaFileParams{ 51 HTTPClient: client, 52 } 53 } 54 55 /*UploadMtaFileParams contains all the parameters to send to the API endpoint 56 for the upload mta file operation typically these are written to a http.Request 57 */ 58 type UploadMtaFileParams struct { 59 60 /*Namespace 61 file namespace 62 63 */ 64 Namespace *string 65 66 /*File*/ 67 File os.File 68 69 FileSize int64 70 71 timeout time.Duration 72 Context context.Context 73 HTTPClient *http.Client 74 } 75 76 // WithTimeout adds the timeout to the upload mta file params 77 func (o *UploadMtaFileParams) WithTimeout(timeout time.Duration) *UploadMtaFileParams { 78 o.SetTimeout(timeout) 79 return o 80 } 81 82 // SetTimeout adds the timeout to the upload mta file params 83 func (o *UploadMtaFileParams) SetTimeout(timeout time.Duration) { 84 o.timeout = timeout 85 } 86 87 // WithContext adds the context to the upload mta file params 88 func (o *UploadMtaFileParams) WithContext(ctx context.Context) *UploadMtaFileParams { 89 o.SetContext(ctx) 90 return o 91 } 92 93 // SetContext adds the context to the upload mta file params 94 func (o *UploadMtaFileParams) SetContext(ctx context.Context) { 95 o.Context = ctx 96 } 97 98 // WithHTTPClient adds the HTTPClient to the upload mta file params 99 func (o *UploadMtaFileParams) WithHTTPClient(client *http.Client) *UploadMtaFileParams { 100 o.SetHTTPClient(client) 101 return o 102 } 103 104 // SetHTTPClient adds the HTTPClient to the upload mta file params 105 func (o *UploadMtaFileParams) SetHTTPClient(client *http.Client) { 106 o.HTTPClient = client 107 } 108 109 // WithNamespace adds the namespace to the upload mta file params 110 func (o *UploadMtaFileParams) WithNamespace(namespace *string) *UploadMtaFileParams { 111 o.SetNamespace(namespace) 112 return o 113 } 114 115 // SetNamespace adds the namespace to the upload mta file params 116 func (o *UploadMtaFileParams) SetNamespace(namespace *string) { 117 o.Namespace = namespace 118 } 119 120 // WithFile adds the file to the upload mta file params 121 func (o *UploadMtaFileParams) WithFile(file os.File) *UploadMtaFileParams { 122 o.SetFile(file) 123 return o 124 } 125 126 // SetFile adds the file to the upload mta file params 127 func (o *UploadMtaFileParams) SetFile(file os.File) { 128 o.File = file 129 } 130 131 func (o *UploadMtaFileParams) WithFileSize(fileSize int64) *UploadMtaFileParams { 132 o.SetFileSize(fileSize) 133 return o 134 } 135 136 func (o *UploadMtaFileParams) SetFileSize(fileSize int64) { 137 o.FileSize = fileSize 138 } 139 140 // WriteToRequest writes these params to a swagger request 141 func (o *UploadMtaFileParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error { 142 143 if err := r.SetTimeout(o.timeout); err != nil { 144 return err 145 } 146 var res []error 147 148 if o.Namespace != nil { 149 150 // query param namespace 151 var qrNamespace string 152 if o.Namespace != nil { 153 qrNamespace = *o.Namespace 154 } 155 qNamespace := qrNamespace 156 if qNamespace != "" { 157 if err := r.SetQueryParam("namespace", qNamespace); err != nil { 158 return err 159 } 160 } 161 162 } 163 164 // form file param file 165 if err := r.SetFileParam("file", &o.File); err != nil { 166 return err 167 } 168 169 if err := r.SetHeaderParam("X-File-Size", strconv.FormatInt(o.FileSize, 10)); err != nil { 170 return err 171 } 172 173 if len(res) > 0 { 174 return errors.CompositeValidationError(res...) 175 } 176 return nil 177 }