...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package silence
18
19
20
21
22 import (
23 "errors"
24 "net/url"
25 golangswaggerpaths "path"
26
27 "github.com/go-openapi/swag"
28 )
29
30
31 type GetSilencesURL struct {
32 Filter []string
33
34 _basePath string
35
36 _ struct{}
37 }
38
39
40
41
42 func (o *GetSilencesURL) WithBasePath(bp string) *GetSilencesURL {
43 o.SetBasePath(bp)
44 return o
45 }
46
47
48
49
50 func (o *GetSilencesURL) SetBasePath(bp string) {
51 o._basePath = bp
52 }
53
54
55 func (o *GetSilencesURL) Build() (*url.URL, error) {
56 var _result url.URL
57
58 var _path = "/silences"
59
60 _basePath := o._basePath
61 if _basePath == "" {
62 _basePath = "/api/v2/"
63 }
64 _result.Path = golangswaggerpaths.Join(_basePath, _path)
65
66 qs := make(url.Values)
67
68 var filterIR []string
69 for _, filterI := range o.Filter {
70 filterIS := filterI
71 if filterIS != "" {
72 filterIR = append(filterIR, filterIS)
73 }
74 }
75
76 filter := swag.JoinByFormat(filterIR, "multi")
77
78 for _, qsv := range filter {
79 qs.Add("filter", qsv)
80 }
81
82 _result.RawQuery = qs.Encode()
83
84 return &_result, nil
85 }
86
87
88 func (o *GetSilencesURL) Must(u *url.URL, err error) *url.URL {
89 if err != nil {
90 panic(err)
91 }
92 if u == nil {
93 panic("url can't be nil")
94 }
95 return u
96 }
97
98
99 func (o *GetSilencesURL) String() string {
100 return o.Must(o.Build()).String()
101 }
102
103
104 func (o *GetSilencesURL) BuildFull(scheme, host string) (*url.URL, error) {
105 if scheme == "" {
106 return nil, errors.New("scheme is required for a full url on GetSilencesURL")
107 }
108 if host == "" {
109 return nil, errors.New("host is required for a full url on GetSilencesURL")
110 }
111
112 base, err := o.Build()
113 if err != nil {
114 return nil, err
115 }
116
117 base.Scheme = scheme
118 base.Host = host
119 return base, nil
120 }
121
122
123 func (o *GetSilencesURL) StringFull(scheme, host string) string {
124 return o.Must(o.BuildFull(scheme, host)).String()
125 }
126
View as plain text