github.com/djarvur/go-swagger@v0.18.0/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/swag" 17 18 strfmt "github.com/go-openapi/strfmt" 19 ) 20 21 // NewListTasksParams creates a new ListTasksParams object 22 // with the default values initialized. 23 func NewListTasksParams() *ListTasksParams { 24 var ( 25 pageSizeDefault = int32(20) 26 ) 27 return &ListTasksParams{ 28 PageSize: &pageSizeDefault, 29 30 timeout: cr.DefaultTimeout, 31 } 32 } 33 34 // NewListTasksParamsWithTimeout creates a new ListTasksParams object 35 // with the default values initialized, and the ability to set a timeout on a request 36 func NewListTasksParamsWithTimeout(timeout time.Duration) *ListTasksParams { 37 var ( 38 pageSizeDefault = int32(20) 39 ) 40 return &ListTasksParams{ 41 PageSize: &pageSizeDefault, 42 43 timeout: timeout, 44 } 45 } 46 47 // NewListTasksParamsWithContext creates a new ListTasksParams object 48 // with the default values initialized, and the ability to set a context for a request 49 func NewListTasksParamsWithContext(ctx context.Context) *ListTasksParams { 50 var ( 51 pageSizeDefault = int32(20) 52 ) 53 return &ListTasksParams{ 54 PageSize: &pageSizeDefault, 55 56 Context: ctx, 57 } 58 } 59 60 // NewListTasksParamsWithHTTPClient creates a new ListTasksParams object 61 // with the default values initialized, and the ability to set a custom HTTPClient for a request 62 func NewListTasksParamsWithHTTPClient(client *http.Client) *ListTasksParams { 63 var ( 64 pageSizeDefault = int32(20) 65 ) 66 return &ListTasksParams{ 67 PageSize: &pageSizeDefault, 68 HTTPClient: client, 69 } 70 } 71 72 /*ListTasksParams contains all the parameters to send to the API endpoint 73 for the list tasks operation typically these are written to a http.Request 74 */ 75 type ListTasksParams struct { 76 77 /*PageSize 78 Amount of items to return in a single page 79 80 */ 81 PageSize *int32 82 /*SinceID 83 The last id that was seen. 84 85 */ 86 SinceID *int64 87 /*Status 88 the status to filter by 89 90 */ 91 Status []string 92 /*Tags 93 the tags to filter by 94 95 */ 96 Tags []string 97 98 timeout time.Duration 99 Context context.Context 100 HTTPClient *http.Client 101 } 102 103 // WithTimeout adds the timeout to the list tasks params 104 func (o *ListTasksParams) WithTimeout(timeout time.Duration) *ListTasksParams { 105 o.SetTimeout(timeout) 106 return o 107 } 108 109 // SetTimeout adds the timeout to the list tasks params 110 func (o *ListTasksParams) SetTimeout(timeout time.Duration) { 111 o.timeout = timeout 112 } 113 114 // WithContext adds the context to the list tasks params 115 func (o *ListTasksParams) WithContext(ctx context.Context) *ListTasksParams { 116 o.SetContext(ctx) 117 return o 118 } 119 120 // SetContext adds the context to the list tasks params 121 func (o *ListTasksParams) SetContext(ctx context.Context) { 122 o.Context = ctx 123 } 124 125 // WithHTTPClient adds the HTTPClient to the list tasks params 126 func (o *ListTasksParams) WithHTTPClient(client *http.Client) *ListTasksParams { 127 o.SetHTTPClient(client) 128 return o 129 } 130 131 // SetHTTPClient adds the HTTPClient to the list tasks params 132 func (o *ListTasksParams) SetHTTPClient(client *http.Client) { 133 o.HTTPClient = client 134 } 135 136 // WithPageSize adds the pageSize to the list tasks params 137 func (o *ListTasksParams) WithPageSize(pageSize *int32) *ListTasksParams { 138 o.SetPageSize(pageSize) 139 return o 140 } 141 142 // SetPageSize adds the pageSize to the list tasks params 143 func (o *ListTasksParams) SetPageSize(pageSize *int32) { 144 o.PageSize = pageSize 145 } 146 147 // WithSinceID adds the sinceID to the list tasks params 148 func (o *ListTasksParams) WithSinceID(sinceID *int64) *ListTasksParams { 149 o.SetSinceID(sinceID) 150 return o 151 } 152 153 // SetSinceID adds the sinceId to the list tasks params 154 func (o *ListTasksParams) SetSinceID(sinceID *int64) { 155 o.SinceID = sinceID 156 } 157 158 // WithStatus adds the status to the list tasks params 159 func (o *ListTasksParams) WithStatus(status []string) *ListTasksParams { 160 o.SetStatus(status) 161 return o 162 } 163 164 // SetStatus adds the status to the list tasks params 165 func (o *ListTasksParams) SetStatus(status []string) { 166 o.Status = status 167 } 168 169 // WithTags adds the tags to the list tasks params 170 func (o *ListTasksParams) WithTags(tags []string) *ListTasksParams { 171 o.SetTags(tags) 172 return o 173 } 174 175 // SetTags adds the tags to the list tasks params 176 func (o *ListTasksParams) SetTags(tags []string) { 177 o.Tags = tags 178 } 179 180 // WriteToRequest writes these params to a swagger request 181 func (o *ListTasksParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error { 182 183 if err := r.SetTimeout(o.timeout); err != nil { 184 return err 185 } 186 var res []error 187 188 if o.PageSize != nil { 189 190 // query param pageSize 191 var qrPageSize int32 192 if o.PageSize != nil { 193 qrPageSize = *o.PageSize 194 } 195 qPageSize := swag.FormatInt32(qrPageSize) 196 if qPageSize != "" { 197 if err := r.SetQueryParam("pageSize", qPageSize); err != nil { 198 return err 199 } 200 } 201 202 } 203 204 if o.SinceID != nil { 205 206 // query param sinceId 207 var qrSinceID int64 208 if o.SinceID != nil { 209 qrSinceID = *o.SinceID 210 } 211 qSinceID := swag.FormatInt64(qrSinceID) 212 if qSinceID != "" { 213 if err := r.SetQueryParam("sinceId", qSinceID); err != nil { 214 return err 215 } 216 } 217 218 } 219 220 valuesStatus := o.Status 221 222 joinedStatus := swag.JoinByFormat(valuesStatus, "pipes") 223 // query array param status 224 if err := r.SetQueryParam("status", joinedStatus...); err != nil { 225 return err 226 } 227 228 valuesTags := o.Tags 229 230 joinedTags := swag.JoinByFormat(valuesTags, "") 231 // query array param tags 232 if err := r.SetQueryParam("tags", joinedTags...); err != nil { 233 return err 234 } 235 236 if len(res) > 0 { 237 return errors.CompositeValidationError(res...) 238 } 239 return nil 240 }