...
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 "context"
24 "net/http"
25 "time"
26
27 "github.com/go-openapi/errors"
28 "github.com/go-openapi/runtime"
29 cr "github.com/go-openapi/runtime/client"
30 "github.com/go-openapi/strfmt"
31
32 "github.com/prometheus/alertmanager/api/v2/models"
33 )
34
35
36
37
38
39
40
41 func NewPostSilencesParams() *PostSilencesParams {
42 return &PostSilencesParams{
43 timeout: cr.DefaultTimeout,
44 }
45 }
46
47
48
49 func NewPostSilencesParamsWithTimeout(timeout time.Duration) *PostSilencesParams {
50 return &PostSilencesParams{
51 timeout: timeout,
52 }
53 }
54
55
56
57 func NewPostSilencesParamsWithContext(ctx context.Context) *PostSilencesParams {
58 return &PostSilencesParams{
59 Context: ctx,
60 }
61 }
62
63
64
65 func NewPostSilencesParamsWithHTTPClient(client *http.Client) *PostSilencesParams {
66 return &PostSilencesParams{
67 HTTPClient: client,
68 }
69 }
70
71
78 type PostSilencesParams struct {
79
80
84 Silence *models.PostableSilence
85
86 timeout time.Duration
87 Context context.Context
88 HTTPClient *http.Client
89 }
90
91
92
93
94 func (o *PostSilencesParams) WithDefaults() *PostSilencesParams {
95 o.SetDefaults()
96 return o
97 }
98
99
100
101
102 func (o *PostSilencesParams) SetDefaults() {
103
104 }
105
106
107 func (o *PostSilencesParams) WithTimeout(timeout time.Duration) *PostSilencesParams {
108 o.SetTimeout(timeout)
109 return o
110 }
111
112
113 func (o *PostSilencesParams) SetTimeout(timeout time.Duration) {
114 o.timeout = timeout
115 }
116
117
118 func (o *PostSilencesParams) WithContext(ctx context.Context) *PostSilencesParams {
119 o.SetContext(ctx)
120 return o
121 }
122
123
124 func (o *PostSilencesParams) SetContext(ctx context.Context) {
125 o.Context = ctx
126 }
127
128
129 func (o *PostSilencesParams) WithHTTPClient(client *http.Client) *PostSilencesParams {
130 o.SetHTTPClient(client)
131 return o
132 }
133
134
135 func (o *PostSilencesParams) SetHTTPClient(client *http.Client) {
136 o.HTTPClient = client
137 }
138
139
140 func (o *PostSilencesParams) WithSilence(silence *models.PostableSilence) *PostSilencesParams {
141 o.SetSilence(silence)
142 return o
143 }
144
145
146 func (o *PostSilencesParams) SetSilence(silence *models.PostableSilence) {
147 o.Silence = silence
148 }
149
150
151 func (o *PostSilencesParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error {
152
153 if err := r.SetTimeout(o.timeout); err != nil {
154 return err
155 }
156 var res []error
157 if o.Silence != nil {
158 if err := r.SetBodyParam(o.Silence); err != nil {
159 return err
160 }
161 }
162
163 if len(res) > 0 {
164 return errors.CompositeValidationError(res...)
165 }
166 return nil
167 }
168
View as plain text