github.com/circl-dev/go-swagger@v0.31.0/examples/contributed-templates/stratoscale/client/pet/pet_upload_image_parameters.go (about) 1 // Code generated by go-swagger; DO NOT EDIT. 2 3 package pet 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 // NewPetUploadImageParams creates a new PetUploadImageParams 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 NewPetUploadImageParams() *PetUploadImageParams { 27 return &PetUploadImageParams{ 28 timeout: cr.DefaultTimeout, 29 } 30 } 31 32 // NewPetUploadImageParamsWithTimeout creates a new PetUploadImageParams object 33 // with the ability to set a timeout on a request. 34 func NewPetUploadImageParamsWithTimeout(timeout time.Duration) *PetUploadImageParams { 35 return &PetUploadImageParams{ 36 timeout: timeout, 37 } 38 } 39 40 // NewPetUploadImageParamsWithContext creates a new PetUploadImageParams object 41 // with the ability to set a context for a request. 42 func NewPetUploadImageParamsWithContext(ctx context.Context) *PetUploadImageParams { 43 return &PetUploadImageParams{ 44 Context: ctx, 45 } 46 } 47 48 // NewPetUploadImageParamsWithHTTPClient creates a new PetUploadImageParams object 49 // with the ability to set a custom HTTPClient for a request. 50 func NewPetUploadImageParamsWithHTTPClient(client *http.Client) *PetUploadImageParams { 51 return &PetUploadImageParams{ 52 HTTPClient: client, 53 } 54 } 55 56 /* PetUploadImageParams contains all the parameters to send to the API endpoint 57 for the pet upload image operation. 58 59 Typically these are written to a http.Request. 60 */ 61 type PetUploadImageParams struct { 62 63 /* AdditionalMetadata. 64 65 Additional data to pass to server 66 */ 67 AdditionalMetadata *string 68 69 /* File. 70 71 file to upload 72 */ 73 File runtime.NamedReadCloser 74 75 /* PetID. 76 77 ID of pet to update 78 79 Format: int64 80 */ 81 PetID int64 82 83 timeout time.Duration 84 Context context.Context 85 HTTPClient *http.Client 86 } 87 88 // WithDefaults hydrates default values in the pet upload image params (not the query body). 89 // 90 // All values with no default are reset to their zero value. 91 func (o *PetUploadImageParams) WithDefaults() *PetUploadImageParams { 92 o.SetDefaults() 93 return o 94 } 95 96 // SetDefaults hydrates default values in the pet upload image params (not the query body). 97 // 98 // All values with no default are reset to their zero value. 99 func (o *PetUploadImageParams) SetDefaults() { 100 // no default values defined for this parameter 101 } 102 103 // WithTimeout adds the timeout to the pet upload image params 104 func (o *PetUploadImageParams) WithTimeout(timeout time.Duration) *PetUploadImageParams { 105 o.SetTimeout(timeout) 106 return o 107 } 108 109 // SetTimeout adds the timeout to the pet upload image params 110 func (o *PetUploadImageParams) SetTimeout(timeout time.Duration) { 111 o.timeout = timeout 112 } 113 114 // WithContext adds the context to the pet upload image params 115 func (o *PetUploadImageParams) WithContext(ctx context.Context) *PetUploadImageParams { 116 o.SetContext(ctx) 117 return o 118 } 119 120 // SetContext adds the context to the pet upload image params 121 func (o *PetUploadImageParams) SetContext(ctx context.Context) { 122 o.Context = ctx 123 } 124 125 // WithHTTPClient adds the HTTPClient to the pet upload image params 126 func (o *PetUploadImageParams) WithHTTPClient(client *http.Client) *PetUploadImageParams { 127 o.SetHTTPClient(client) 128 return o 129 } 130 131 // SetHTTPClient adds the HTTPClient to the pet upload image params 132 func (o *PetUploadImageParams) SetHTTPClient(client *http.Client) { 133 o.HTTPClient = client 134 } 135 136 // WithAdditionalMetadata adds the additionalMetadata to the pet upload image params 137 func (o *PetUploadImageParams) WithAdditionalMetadata(additionalMetadata *string) *PetUploadImageParams { 138 o.SetAdditionalMetadata(additionalMetadata) 139 return o 140 } 141 142 // SetAdditionalMetadata adds the additionalMetadata to the pet upload image params 143 func (o *PetUploadImageParams) SetAdditionalMetadata(additionalMetadata *string) { 144 o.AdditionalMetadata = additionalMetadata 145 } 146 147 // WithFile adds the file to the pet upload image params 148 func (o *PetUploadImageParams) WithFile(file runtime.NamedReadCloser) *PetUploadImageParams { 149 o.SetFile(file) 150 return o 151 } 152 153 // SetFile adds the file to the pet upload image params 154 func (o *PetUploadImageParams) SetFile(file runtime.NamedReadCloser) { 155 o.File = file 156 } 157 158 // WithPetID adds the petID to the pet upload image params 159 func (o *PetUploadImageParams) WithPetID(petID int64) *PetUploadImageParams { 160 o.SetPetID(petID) 161 return o 162 } 163 164 // SetPetID adds the petId to the pet upload image params 165 func (o *PetUploadImageParams) SetPetID(petID int64) { 166 o.PetID = petID 167 } 168 169 // WriteToRequest writes these params to a swagger request 170 func (o *PetUploadImageParams) 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.AdditionalMetadata != nil { 178 179 // form param additionalMetadata 180 var frAdditionalMetadata string 181 if o.AdditionalMetadata != nil { 182 frAdditionalMetadata = *o.AdditionalMetadata 183 } 184 fAdditionalMetadata := frAdditionalMetadata 185 if fAdditionalMetadata != "" { 186 if err := r.SetFormParam("additionalMetadata", fAdditionalMetadata); 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 petId 203 if err := r.SetPathParam("petId", swag.FormatInt64(o.PetID)); err != nil { 204 return err 205 } 206 207 if len(res) > 0 { 208 return errors.CompositeValidationError(res...) 209 } 210 return nil 211 }