github.com/thetreep/go-swagger@v0.0.0-20240223100711-35af64f14f01/examples/task-tracker/client/tasks/list_tasks_parameters.go (about) 1 // Code generated by go-swagger; DO NOT EDIT. 2 3 package tasks 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 "github.com/go-openapi/swag" 18 ) 19 20 // NewListTasksParams creates a new ListTasksParams 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 NewListTasksParams() *ListTasksParams { 27 return &ListTasksParams{ 28 timeout: cr.DefaultTimeout, 29 } 30 } 31 32 // NewListTasksParamsWithTimeout creates a new ListTasksParams object 33 // with the ability to set a timeout on a request. 34 func NewListTasksParamsWithTimeout(timeout time.Duration) *ListTasksParams { 35 return &ListTasksParams{ 36 timeout: timeout, 37 } 38 } 39 40 // NewListTasksParamsWithContext creates a new ListTasksParams object 41 // with the ability to set a context for a request. 42 func NewListTasksParamsWithContext(ctx context.Context) *ListTasksParams { 43 return &ListTasksParams{ 44 Context: ctx, 45 } 46 } 47 48 // NewListTasksParamsWithHTTPClient creates a new ListTasksParams object 49 // with the ability to set a custom HTTPClient for a request. 50 func NewListTasksParamsWithHTTPClient(client *http.Client) *ListTasksParams { 51 return &ListTasksParams{ 52 HTTPClient: client, 53 } 54 } 55 56 /* 57 ListTasksParams contains all the parameters to send to the API endpoint 58 59 for the list tasks operation. 60 61 Typically these are written to a http.Request. 62 */ 63 type ListTasksParams struct { 64 65 /* PageSize. 66 67 Amount of items to return in a single page 68 69 Format: int32 70 Default: 20 71 */ 72 PageSize *int32 73 74 /* SinceID. 75 76 The last id that was seen. 77 78 Format: int64 79 */ 80 SinceID *int64 81 82 /* Status. 83 84 the status to filter by 85 */ 86 Status []string 87 88 /* Tags. 89 90 the tags to filter by 91 */ 92 Tags []string 93 94 timeout time.Duration 95 Context context.Context 96 HTTPClient *http.Client 97 } 98 99 // WithDefaults hydrates default values in the list tasks params (not the query body). 100 // 101 // All values with no default are reset to their zero value. 102 func (o *ListTasksParams) WithDefaults() *ListTasksParams { 103 o.SetDefaults() 104 return o 105 } 106 107 // SetDefaults hydrates default values in the list tasks params (not the query body). 108 // 109 // All values with no default are reset to their zero value. 110 func (o *ListTasksParams) SetDefaults() { 111 var ( 112 pageSizeDefault = int32(20) 113 ) 114 115 val := ListTasksParams{ 116 PageSize: &pageSizeDefault, 117 } 118 119 val.timeout = o.timeout 120 val.Context = o.Context 121 val.HTTPClient = o.HTTPClient 122 *o = val 123 } 124 125 // WithTimeout adds the timeout to the list tasks params 126 func (o *ListTasksParams) WithTimeout(timeout time.Duration) *ListTasksParams { 127 o.SetTimeout(timeout) 128 return o 129 } 130 131 // SetTimeout adds the timeout to the list tasks params 132 func (o *ListTasksParams) SetTimeout(timeout time.Duration) { 133 o.timeout = timeout 134 } 135 136 // WithContext adds the context to the list tasks params 137 func (o *ListTasksParams) WithContext(ctx context.Context) *ListTasksParams { 138 o.SetContext(ctx) 139 return o 140 } 141 142 // SetContext adds the context to the list tasks params 143 func (o *ListTasksParams) SetContext(ctx context.Context) { 144 o.Context = ctx 145 } 146 147 // WithHTTPClient adds the HTTPClient to the list tasks params 148 func (o *ListTasksParams) WithHTTPClient(client *http.Client) *ListTasksParams { 149 o.SetHTTPClient(client) 150 return o 151 } 152 153 // SetHTTPClient adds the HTTPClient to the list tasks params 154 func (o *ListTasksParams) SetHTTPClient(client *http.Client) { 155 o.HTTPClient = client 156 } 157 158 // WithPageSize adds the pageSize to the list tasks params 159 func (o *ListTasksParams) WithPageSize(pageSize *int32) *ListTasksParams { 160 o.SetPageSize(pageSize) 161 return o 162 } 163 164 // SetPageSize adds the pageSize to the list tasks params 165 func (o *ListTasksParams) SetPageSize(pageSize *int32) { 166 o.PageSize = pageSize 167 } 168 169 // WithSinceID adds the sinceID to the list tasks params 170 func (o *ListTasksParams) WithSinceID(sinceID *int64) *ListTasksParams { 171 o.SetSinceID(sinceID) 172 return o 173 } 174 175 // SetSinceID adds the sinceId to the list tasks params 176 func (o *ListTasksParams) SetSinceID(sinceID *int64) { 177 o.SinceID = sinceID 178 } 179 180 // WithStatus adds the status to the list tasks params 181 func (o *ListTasksParams) WithStatus(status []string) *ListTasksParams { 182 o.SetStatus(status) 183 return o 184 } 185 186 // SetStatus adds the status to the list tasks params 187 func (o *ListTasksParams) SetStatus(status []string) { 188 o.Status = status 189 } 190 191 // WithTags adds the tags to the list tasks params 192 func (o *ListTasksParams) WithTags(tags []string) *ListTasksParams { 193 o.SetTags(tags) 194 return o 195 } 196 197 // SetTags adds the tags to the list tasks params 198 func (o *ListTasksParams) SetTags(tags []string) { 199 o.Tags = tags 200 } 201 202 // WriteToRequest writes these params to a swagger request 203 func (o *ListTasksParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error { 204 205 if err := r.SetTimeout(o.timeout); err != nil { 206 return err 207 } 208 var res []error 209 210 if o.PageSize != nil { 211 212 // query param pageSize 213 var qrPageSize int32 214 215 if o.PageSize != nil { 216 qrPageSize = *o.PageSize 217 } 218 qPageSize := swag.FormatInt32(qrPageSize) 219 if qPageSize != "" { 220 221 if err := r.SetQueryParam("pageSize", qPageSize); err != nil { 222 return err 223 } 224 } 225 } 226 227 if o.SinceID != nil { 228 229 // query param sinceId 230 var qrSinceID int64 231 232 if o.SinceID != nil { 233 qrSinceID = *o.SinceID 234 } 235 qSinceID := swag.FormatInt64(qrSinceID) 236 if qSinceID != "" { 237 238 if err := r.SetQueryParam("sinceId", qSinceID); err != nil { 239 return err 240 } 241 } 242 } 243 244 if o.Status != nil { 245 246 // binding items for status 247 joinedStatus := o.bindParamStatus(reg) 248 249 // query array param status 250 if err := r.SetQueryParam("status", joinedStatus...); err != nil { 251 return err 252 } 253 } 254 255 if o.Tags != nil { 256 257 // binding items for tags 258 joinedTags := o.bindParamTags(reg) 259 260 // query array param tags 261 if err := r.SetQueryParam("tags", joinedTags...); err != nil { 262 return err 263 } 264 } 265 266 if len(res) > 0 { 267 return errors.CompositeValidationError(res...) 268 } 269 return nil 270 } 271 272 // bindParamListTasks binds the parameter status 273 func (o *ListTasksParams) bindParamStatus(formats strfmt.Registry) []string { 274 statusIR := o.Status 275 276 var statusIC []string 277 for _, statusIIR := range statusIR { // explode []string 278 279 statusIIV := statusIIR // string as string 280 statusIC = append(statusIC, statusIIV) 281 } 282 283 // items.CollectionFormat: "pipes" 284 statusIS := swag.JoinByFormat(statusIC, "pipes") 285 286 return statusIS 287 } 288 289 // bindParamListTasks binds the parameter tags 290 func (o *ListTasksParams) bindParamTags(formats strfmt.Registry) []string { 291 tagsIR := o.Tags 292 293 var tagsIC []string 294 for _, tagsIIR := range tagsIR { // explode []string 295 296 tagsIIV := tagsIIR // string as string 297 tagsIC = append(tagsIC, tagsIIV) 298 } 299 300 // items.CollectionFormat: "" 301 tagsIS := swag.JoinByFormat(tagsIC, "") 302 303 return tagsIS 304 }