github.com/djarvur/go-swagger@v0.18.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/runtime" 15 cr "github.com/go-openapi/runtime/client" 16 "github.com/go-openapi/swag" 17 18 strfmt "github.com/go-openapi/strfmt" 19 ) 20 21 // NewPetUploadImageParams creates a new PetUploadImageParams object 22 // with the default values initialized. 23 func NewPetUploadImageParams() *PetUploadImageParams { 24 var () 25 return &PetUploadImageParams{ 26 27 timeout: cr.DefaultTimeout, 28 } 29 } 30 31 // NewPetUploadImageParamsWithTimeout creates a new PetUploadImageParams object 32 // with the default values initialized, and the ability to set a timeout on a request 33 func NewPetUploadImageParamsWithTimeout(timeout time.Duration) *PetUploadImageParams { 34 var () 35 return &PetUploadImageParams{ 36 37 timeout: timeout, 38 } 39 } 40 41 // NewPetUploadImageParamsWithContext creates a new PetUploadImageParams object 42 // with the default values initialized, and the ability to set a context for a request 43 func NewPetUploadImageParamsWithContext(ctx context.Context) *PetUploadImageParams { 44 var () 45 return &PetUploadImageParams{ 46 47 Context: ctx, 48 } 49 } 50 51 // NewPetUploadImageParamsWithHTTPClient creates a new PetUploadImageParams object 52 // with the default values initialized, and the ability to set a custom HTTPClient for a request 53 func NewPetUploadImageParamsWithHTTPClient(client *http.Client) *PetUploadImageParams { 54 var () 55 return &PetUploadImageParams{ 56 HTTPClient: client, 57 } 58 } 59 60 /*PetUploadImageParams contains all the parameters to send to the API endpoint 61 for the pet upload image operation typically these are written to a http.Request 62 */ 63 type PetUploadImageParams struct { 64 65 /*AdditionalMetadata 66 Additional data to pass to server 67 68 */ 69 AdditionalMetadata *string 70 /*File 71 file to upload 72 73 */ 74 File runtime.NamedReadCloser 75 /*PetID 76 ID of pet to update 77 78 */ 79 PetID int64 80 81 timeout time.Duration 82 Context context.Context 83 HTTPClient *http.Client 84 } 85 86 // WithTimeout adds the timeout to the pet upload image params 87 func (o *PetUploadImageParams) WithTimeout(timeout time.Duration) *PetUploadImageParams { 88 o.SetTimeout(timeout) 89 return o 90 } 91 92 // SetTimeout adds the timeout to the pet upload image params 93 func (o *PetUploadImageParams) SetTimeout(timeout time.Duration) { 94 o.timeout = timeout 95 } 96 97 // WithContext adds the context to the pet upload image params 98 func (o *PetUploadImageParams) WithContext(ctx context.Context) *PetUploadImageParams { 99 o.SetContext(ctx) 100 return o 101 } 102 103 // SetContext adds the context to the pet upload image params 104 func (o *PetUploadImageParams) SetContext(ctx context.Context) { 105 o.Context = ctx 106 } 107 108 // WithHTTPClient adds the HTTPClient to the pet upload image params 109 func (o *PetUploadImageParams) WithHTTPClient(client *http.Client) *PetUploadImageParams { 110 o.SetHTTPClient(client) 111 return o 112 } 113 114 // SetHTTPClient adds the HTTPClient to the pet upload image params 115 func (o *PetUploadImageParams) SetHTTPClient(client *http.Client) { 116 o.HTTPClient = client 117 } 118 119 // WithAdditionalMetadata adds the additionalMetadata to the pet upload image params 120 func (o *PetUploadImageParams) WithAdditionalMetadata(additionalMetadata *string) *PetUploadImageParams { 121 o.SetAdditionalMetadata(additionalMetadata) 122 return o 123 } 124 125 // SetAdditionalMetadata adds the additionalMetadata to the pet upload image params 126 func (o *PetUploadImageParams) SetAdditionalMetadata(additionalMetadata *string) { 127 o.AdditionalMetadata = additionalMetadata 128 } 129 130 // WithFile adds the file to the pet upload image params 131 func (o *PetUploadImageParams) WithFile(file runtime.NamedReadCloser) *PetUploadImageParams { 132 o.SetFile(file) 133 return o 134 } 135 136 // SetFile adds the file to the pet upload image params 137 func (o *PetUploadImageParams) SetFile(file runtime.NamedReadCloser) { 138 o.File = file 139 } 140 141 // WithPetID adds the petID to the pet upload image params 142 func (o *PetUploadImageParams) WithPetID(petID int64) *PetUploadImageParams { 143 o.SetPetID(petID) 144 return o 145 } 146 147 // SetPetID adds the petId to the pet upload image params 148 func (o *PetUploadImageParams) SetPetID(petID int64) { 149 o.PetID = petID 150 } 151 152 // WriteToRequest writes these params to a swagger request 153 func (o *PetUploadImageParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error { 154 155 if err := r.SetTimeout(o.timeout); err != nil { 156 return err 157 } 158 var res []error 159 160 if o.AdditionalMetadata != nil { 161 162 // form param additionalMetadata 163 var frAdditionalMetadata string 164 if o.AdditionalMetadata != nil { 165 frAdditionalMetadata = *o.AdditionalMetadata 166 } 167 fAdditionalMetadata := frAdditionalMetadata 168 if fAdditionalMetadata != "" { 169 if err := r.SetFormParam("additionalMetadata", fAdditionalMetadata); err != nil { 170 return err 171 } 172 } 173 174 } 175 176 if o.File != nil { 177 178 if o.File != nil { 179 180 // form file param file 181 if err := r.SetFileParam("file", o.File); err != nil { 182 return err 183 } 184 185 } 186 187 } 188 189 // path param petId 190 if err := r.SetPathParam("petId", swag.FormatInt64(o.PetID)); err != nil { 191 return err 192 } 193 194 if len(res) > 0 { 195 return errors.CompositeValidationError(res...) 196 } 197 return nil 198 }