forked from go-swagger/go-swagger
/
find_parameters.go
82 lines (67 loc) · 1.92 KB
/
find_parameters.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
package todos
// This file was generated by the swagger tool.
// Editing this file might prove futile when you re-run the swagger generate command
import (
"github.com/go-swagger/go-swagger/client"
"github.com/go-swagger/go-swagger/errors"
"github.com/go-swagger/go-swagger/strfmt"
"github.com/go-swagger/go-swagger/swag"
)
// NewFindParams creates a new FindParams object
// with the default values initialized.
func NewFindParams() *FindParams {
return &FindParams{}
}
/*FindParams contains all the parameters to send to the API endpoint
for the find operation typically these are written to a http.Request
*/
type FindParams struct {
/*XRateLimit*/
XRateLimit int32
/*Limit*/
Limit int32
/*Tags*/
Tags []int32
}
// WithXRateLimit adds the xRateLimit to the find params
func (o *FindParams) WithXRateLimit(xRateLimit int32) *FindParams {
o.XRateLimit = xRateLimit
return o
}
// WithLimit adds the limit to the find params
func (o *FindParams) WithLimit(limit int32) *FindParams {
o.Limit = limit
return o
}
// WithTags adds the tags to the find params
func (o *FindParams) WithTags(tags []int32) *FindParams {
o.Tags = tags
return o
}
// WriteToRequest writes these params to a swagger request
func (o *FindParams) WriteToRequest(r client.Request, reg strfmt.Registry) error {
var res []error
// header param X-Rate-Limit
if err := r.SetHeaderParam("X-Rate-Limit", swag.FormatInt32(o.XRateLimit)); err != nil {
return err
}
// form param limit
frLimit := o.Limit
fLimit := swag.FormatInt32(frLimit)
if err := r.SetFormParam("limit", fLimit); err != nil {
return err
}
var valuesTags []string
for _, v := range o.Tags {
valuesTags = append(valuesTags, swag.FormatInt32(v))
}
joinedTags := swag.JoinByFormat(valuesTags, "multi")
// form array param tags
if err := r.SetFormParam("tags", joinedTags...); err != nil {
return err
}
if len(res) > 0 {
return errors.CompositeValidationError(res...)
}
return nil
}