github.com/djarvur/go-swagger@v0.18.0/examples/todo-list/client/todos/find_parameters.go (about) 1 // Code generated by go-swagger; DO NOT EDIT. 2 3 package todos 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 // NewFindParams creates a new FindParams object 22 // with the default values initialized. 23 func NewFindParams() *FindParams { 24 var () 25 return &FindParams{ 26 27 timeout: cr.DefaultTimeout, 28 } 29 } 30 31 // NewFindParamsWithTimeout creates a new FindParams object 32 // with the default values initialized, and the ability to set a timeout on a request 33 func NewFindParamsWithTimeout(timeout time.Duration) *FindParams { 34 var () 35 return &FindParams{ 36 37 timeout: timeout, 38 } 39 } 40 41 // NewFindParamsWithContext creates a new FindParams object 42 // with the default values initialized, and the ability to set a context for a request 43 func NewFindParamsWithContext(ctx context.Context) *FindParams { 44 var () 45 return &FindParams{ 46 47 Context: ctx, 48 } 49 } 50 51 // NewFindParamsWithHTTPClient creates a new FindParams object 52 // with the default values initialized, and the ability to set a custom HTTPClient for a request 53 func NewFindParamsWithHTTPClient(client *http.Client) *FindParams { 54 var () 55 return &FindParams{ 56 HTTPClient: client, 57 } 58 } 59 60 /*FindParams contains all the parameters to send to the API endpoint 61 for the find operation typically these are written to a http.Request 62 */ 63 type FindParams struct { 64 65 /*XRateLimit*/ 66 XRateLimit int32 67 /*Limit*/ 68 Limit int32 69 /*Tags*/ 70 Tags []int32 71 72 timeout time.Duration 73 Context context.Context 74 HTTPClient *http.Client 75 } 76 77 // WithTimeout adds the timeout to the find params 78 func (o *FindParams) WithTimeout(timeout time.Duration) *FindParams { 79 o.SetTimeout(timeout) 80 return o 81 } 82 83 // SetTimeout adds the timeout to the find params 84 func (o *FindParams) SetTimeout(timeout time.Duration) { 85 o.timeout = timeout 86 } 87 88 // WithContext adds the context to the find params 89 func (o *FindParams) WithContext(ctx context.Context) *FindParams { 90 o.SetContext(ctx) 91 return o 92 } 93 94 // SetContext adds the context to the find params 95 func (o *FindParams) SetContext(ctx context.Context) { 96 o.Context = ctx 97 } 98 99 // WithHTTPClient adds the HTTPClient to the find params 100 func (o *FindParams) WithHTTPClient(client *http.Client) *FindParams { 101 o.SetHTTPClient(client) 102 return o 103 } 104 105 // SetHTTPClient adds the HTTPClient to the find params 106 func (o *FindParams) SetHTTPClient(client *http.Client) { 107 o.HTTPClient = client 108 } 109 110 // WithXRateLimit adds the xRateLimit to the find params 111 func (o *FindParams) WithXRateLimit(xRateLimit int32) *FindParams { 112 o.SetXRateLimit(xRateLimit) 113 return o 114 } 115 116 // SetXRateLimit adds the xRateLimit to the find params 117 func (o *FindParams) SetXRateLimit(xRateLimit int32) { 118 o.XRateLimit = xRateLimit 119 } 120 121 // WithLimit adds the limit to the find params 122 func (o *FindParams) WithLimit(limit int32) *FindParams { 123 o.SetLimit(limit) 124 return o 125 } 126 127 // SetLimit adds the limit to the find params 128 func (o *FindParams) SetLimit(limit int32) { 129 o.Limit = limit 130 } 131 132 // WithTags adds the tags to the find params 133 func (o *FindParams) WithTags(tags []int32) *FindParams { 134 o.SetTags(tags) 135 return o 136 } 137 138 // SetTags adds the tags to the find params 139 func (o *FindParams) SetTags(tags []int32) { 140 o.Tags = tags 141 } 142 143 // WriteToRequest writes these params to a swagger request 144 func (o *FindParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error { 145 146 if err := r.SetTimeout(o.timeout); err != nil { 147 return err 148 } 149 var res []error 150 151 // header param X-Rate-Limit 152 if err := r.SetHeaderParam("X-Rate-Limit", swag.FormatInt32(o.XRateLimit)); err != nil { 153 return err 154 } 155 156 // form param limit 157 frLimit := o.Limit 158 fLimit := swag.FormatInt32(frLimit) 159 if err := r.SetFormParam("limit", fLimit); err != nil { 160 return err 161 } 162 163 var valuesTags []string 164 for _, v := range o.Tags { 165 valuesTags = append(valuesTags, swag.FormatInt32(v)) 166 } 167 168 joinedTags := swag.JoinByFormat(valuesTags, "multi") 169 // form array param tags 170 if err := r.SetFormParam("tags", joinedTags...); err != nil { 171 return err 172 } 173 174 if len(res) > 0 { 175 return errors.CompositeValidationError(res...) 176 } 177 return nil 178 }