github.com/josephspurrier/go-swagger@v0.2.1-0.20221129144919-1f672a142a00/examples/cli/client/todos/find_todos_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/strfmt" 17 "github.com/go-openapi/swag" 18 ) 19 20 // NewFindTodosParams creates a new FindTodosParams 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 NewFindTodosParams() *FindTodosParams { 27 return &FindTodosParams{ 28 timeout: cr.DefaultTimeout, 29 } 30 } 31 32 // NewFindTodosParamsWithTimeout creates a new FindTodosParams object 33 // with the ability to set a timeout on a request. 34 func NewFindTodosParamsWithTimeout(timeout time.Duration) *FindTodosParams { 35 return &FindTodosParams{ 36 timeout: timeout, 37 } 38 } 39 40 // NewFindTodosParamsWithContext creates a new FindTodosParams object 41 // with the ability to set a context for a request. 42 func NewFindTodosParamsWithContext(ctx context.Context) *FindTodosParams { 43 return &FindTodosParams{ 44 Context: ctx, 45 } 46 } 47 48 // NewFindTodosParamsWithHTTPClient creates a new FindTodosParams object 49 // with the ability to set a custom HTTPClient for a request. 50 func NewFindTodosParamsWithHTTPClient(client *http.Client) *FindTodosParams { 51 return &FindTodosParams{ 52 HTTPClient: client, 53 } 54 } 55 56 /* 57 FindTodosParams contains all the parameters to send to the API endpoint 58 59 for the find todos operation. 60 61 Typically these are written to a http.Request. 62 */ 63 type FindTodosParams struct { 64 65 // Limit. 66 // 67 // Format: int32 68 // Default: 20 69 Limit *int32 70 71 // Since. 72 // 73 // Format: int64 74 Since *int64 75 76 timeout time.Duration 77 Context context.Context 78 HTTPClient *http.Client 79 } 80 81 // WithDefaults hydrates default values in the find todos params (not the query body). 82 // 83 // All values with no default are reset to their zero value. 84 func (o *FindTodosParams) WithDefaults() *FindTodosParams { 85 o.SetDefaults() 86 return o 87 } 88 89 // SetDefaults hydrates default values in the find todos params (not the query body). 90 // 91 // All values with no default are reset to their zero value. 92 func (o *FindTodosParams) SetDefaults() { 93 var ( 94 limitDefault = int32(20) 95 ) 96 97 val := FindTodosParams{ 98 Limit: &limitDefault, 99 } 100 101 val.timeout = o.timeout 102 val.Context = o.Context 103 val.HTTPClient = o.HTTPClient 104 *o = val 105 } 106 107 // WithTimeout adds the timeout to the find todos params 108 func (o *FindTodosParams) WithTimeout(timeout time.Duration) *FindTodosParams { 109 o.SetTimeout(timeout) 110 return o 111 } 112 113 // SetTimeout adds the timeout to the find todos params 114 func (o *FindTodosParams) SetTimeout(timeout time.Duration) { 115 o.timeout = timeout 116 } 117 118 // WithContext adds the context to the find todos params 119 func (o *FindTodosParams) WithContext(ctx context.Context) *FindTodosParams { 120 o.SetContext(ctx) 121 return o 122 } 123 124 // SetContext adds the context to the find todos params 125 func (o *FindTodosParams) SetContext(ctx context.Context) { 126 o.Context = ctx 127 } 128 129 // WithHTTPClient adds the HTTPClient to the find todos params 130 func (o *FindTodosParams) WithHTTPClient(client *http.Client) *FindTodosParams { 131 o.SetHTTPClient(client) 132 return o 133 } 134 135 // SetHTTPClient adds the HTTPClient to the find todos params 136 func (o *FindTodosParams) SetHTTPClient(client *http.Client) { 137 o.HTTPClient = client 138 } 139 140 // WithLimit adds the limit to the find todos params 141 func (o *FindTodosParams) WithLimit(limit *int32) *FindTodosParams { 142 o.SetLimit(limit) 143 return o 144 } 145 146 // SetLimit adds the limit to the find todos params 147 func (o *FindTodosParams) SetLimit(limit *int32) { 148 o.Limit = limit 149 } 150 151 // WithSince adds the since to the find todos params 152 func (o *FindTodosParams) WithSince(since *int64) *FindTodosParams { 153 o.SetSince(since) 154 return o 155 } 156 157 // SetSince adds the since to the find todos params 158 func (o *FindTodosParams) SetSince(since *int64) { 159 o.Since = since 160 } 161 162 // WriteToRequest writes these params to a swagger request 163 func (o *FindTodosParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error { 164 165 if err := r.SetTimeout(o.timeout); err != nil { 166 return err 167 } 168 var res []error 169 170 if o.Limit != nil { 171 172 // query param limit 173 var qrLimit int32 174 175 if o.Limit != nil { 176 qrLimit = *o.Limit 177 } 178 qLimit := swag.FormatInt32(qrLimit) 179 if qLimit != "" { 180 181 if err := r.SetQueryParam("limit", qLimit); err != nil { 182 return err 183 } 184 } 185 } 186 187 if o.Since != nil { 188 189 // query param since 190 var qrSince int64 191 192 if o.Since != nil { 193 qrSince = *o.Since 194 } 195 qSince := swag.FormatInt64(qrSince) 196 if qSince != "" { 197 198 if err := r.SetQueryParam("since", qSince); err != nil { 199 return err 200 } 201 } 202 } 203 204 if len(res) > 0 { 205 return errors.CompositeValidationError(res...) 206 } 207 return nil 208 }