-
Notifications
You must be signed in to change notification settings - Fork 25
/
output.go
392 lines (350 loc) · 12.5 KB
/
output.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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
// Code generated by goagen v1.4.3, DO NOT EDIT.
//
// API "feedpushr": output Resource Client
//
// Command:
// $ goagen
// --design=github.com/ncarlier/feedpushr/v3/design
// --out=/home/nicolas/workspace/feedpushr/autogen
// --version=v1.4.3
package client
import (
"bytes"
"context"
"fmt"
"net/http"
"net/url"
)
// CreateOutputPayload is the output create action payload.
type CreateOutputPayload struct {
// Alias of the output
Alias string `form:"alias" json:"alias" yaml:"alias" xml:"alias"`
// Conditional expression of the output
Condition string `form:"condition" json:"condition" yaml:"condition" xml:"condition"`
// Name of the output
Name string `form:"name" json:"name" yaml:"name" xml:"name"`
// Output properties
Props map[string]interface{} `form:"props,omitempty" json:"props,omitempty" yaml:"props,omitempty" xml:"props,omitempty"`
}
// CreateOutputPath computes a request path to the create action of output.
func CreateOutputPath() string {
return fmt.Sprintf("/v2/outputs")
}
// Create a new output
func (c *Client) CreateOutput(ctx context.Context, path string, payload *CreateOutputPayload, contentType string) (*http.Response, error) {
req, err := c.NewCreateOutputRequest(ctx, path, payload, contentType)
if err != nil {
return nil, err
}
return c.Client.Do(ctx, req)
}
// NewCreateOutputRequest create the request corresponding to the create action endpoint of the output resource.
func (c *Client) NewCreateOutputRequest(ctx context.Context, path string, payload *CreateOutputPayload, contentType string) (*http.Request, error) {
var body bytes.Buffer
if contentType == "" {
contentType = "*/*" // Use default encoder
}
err := c.Encoder.Encode(payload, &body, contentType)
if err != nil {
return nil, fmt.Errorf("failed to encode body: %s", err)
}
scheme := c.Scheme
if scheme == "" {
scheme = "http"
}
u := url.URL{Host: c.Host, Scheme: scheme, Path: path}
req, err := http.NewRequestWithContext(ctx, "POST", u.String(), &body)
if err != nil {
return nil, err
}
header := req.Header
if contentType == "*/*" {
header.Set("Content-Type", "application/json")
} else {
header.Set("Content-Type", contentType)
}
return req, nil
}
// CreateFilterOutputPayload is the output createFilter action payload.
type CreateFilterOutputPayload struct {
// Alias of the filter
Alias string `form:"alias" json:"alias" yaml:"alias" xml:"alias"`
// Conditional expression of the output
Condition string `form:"condition" json:"condition" yaml:"condition" xml:"condition"`
// Name of the filter
Name string `form:"name" json:"name" yaml:"name" xml:"name"`
// Filter properties
Props map[string]interface{} `form:"props,omitempty" json:"props,omitempty" yaml:"props,omitempty" xml:"props,omitempty"`
}
// CreateFilterOutputPath computes a request path to the createFilter action of output.
func CreateFilterOutputPath(id string) string {
param0 := id
return fmt.Sprintf("/v2/outputs/%s/filters", param0)
}
// Create a new filter
func (c *Client) CreateFilterOutput(ctx context.Context, path string, payload *CreateFilterOutputPayload, contentType string) (*http.Response, error) {
req, err := c.NewCreateFilterOutputRequest(ctx, path, payload, contentType)
if err != nil {
return nil, err
}
return c.Client.Do(ctx, req)
}
// NewCreateFilterOutputRequest create the request corresponding to the createFilter action endpoint of the output resource.
func (c *Client) NewCreateFilterOutputRequest(ctx context.Context, path string, payload *CreateFilterOutputPayload, contentType string) (*http.Request, error) {
var body bytes.Buffer
if contentType == "" {
contentType = "*/*" // Use default encoder
}
err := c.Encoder.Encode(payload, &body, contentType)
if err != nil {
return nil, fmt.Errorf("failed to encode body: %s", err)
}
scheme := c.Scheme
if scheme == "" {
scheme = "http"
}
u := url.URL{Host: c.Host, Scheme: scheme, Path: path}
req, err := http.NewRequestWithContext(ctx, "POST", u.String(), &body)
if err != nil {
return nil, err
}
header := req.Header
if contentType == "*/*" {
header.Set("Content-Type", "application/json")
} else {
header.Set("Content-Type", contentType)
}
return req, nil
}
// DeleteOutputPath computes a request path to the delete action of output.
func DeleteOutputPath(id string) string {
param0 := id
return fmt.Sprintf("/v2/outputs/%s", param0)
}
// Delete an output
func (c *Client) DeleteOutput(ctx context.Context, path string) (*http.Response, error) {
req, err := c.NewDeleteOutputRequest(ctx, path)
if err != nil {
return nil, err
}
return c.Client.Do(ctx, req)
}
// NewDeleteOutputRequest create the request corresponding to the delete action endpoint of the output resource.
func (c *Client) NewDeleteOutputRequest(ctx context.Context, path string) (*http.Request, error) {
scheme := c.Scheme
if scheme == "" {
scheme = "http"
}
u := url.URL{Host: c.Host, Scheme: scheme, Path: path}
req, err := http.NewRequestWithContext(ctx, "DELETE", u.String(), nil)
if err != nil {
return nil, err
}
return req, nil
}
// DeleteFilterOutputPath computes a request path to the deleteFilter action of output.
func DeleteFilterOutputPath(id string, idFilter string) string {
param0 := id
param1 := idFilter
return fmt.Sprintf("/v2/outputs/%s/filters/%s", param0, param1)
}
// Delete a filter
func (c *Client) DeleteFilterOutput(ctx context.Context, path string) (*http.Response, error) {
req, err := c.NewDeleteFilterOutputRequest(ctx, path)
if err != nil {
return nil, err
}
return c.Client.Do(ctx, req)
}
// NewDeleteFilterOutputRequest create the request corresponding to the deleteFilter action endpoint of the output resource.
func (c *Client) NewDeleteFilterOutputRequest(ctx context.Context, path string) (*http.Request, error) {
scheme := c.Scheme
if scheme == "" {
scheme = "http"
}
u := url.URL{Host: c.Host, Scheme: scheme, Path: path}
req, err := http.NewRequestWithContext(ctx, "DELETE", u.String(), nil)
if err != nil {
return nil, err
}
return req, nil
}
// GetOutputPath computes a request path to the get action of output.
func GetOutputPath(id string) string {
param0 := id
return fmt.Sprintf("/v2/outputs/%s", param0)
}
// Retrieve output with given ID
func (c *Client) GetOutput(ctx context.Context, path string) (*http.Response, error) {
req, err := c.NewGetOutputRequest(ctx, path)
if err != nil {
return nil, err
}
return c.Client.Do(ctx, req)
}
// NewGetOutputRequest create the request corresponding to the get action endpoint of the output resource.
func (c *Client) NewGetOutputRequest(ctx context.Context, path string) (*http.Request, error) {
scheme := c.Scheme
if scheme == "" {
scheme = "http"
}
u := url.URL{Host: c.Host, Scheme: scheme, Path: path}
req, err := http.NewRequestWithContext(ctx, "GET", u.String(), nil)
if err != nil {
return nil, err
}
return req, nil
}
// ListOutputPath computes a request path to the list action of output.
func ListOutputPath() string {
return fmt.Sprintf("/v2/outputs")
}
// Retrieve all outputs definitions
func (c *Client) ListOutput(ctx context.Context, path string) (*http.Response, error) {
req, err := c.NewListOutputRequest(ctx, path)
if err != nil {
return nil, err
}
return c.Client.Do(ctx, req)
}
// NewListOutputRequest create the request corresponding to the list action endpoint of the output resource.
func (c *Client) NewListOutputRequest(ctx context.Context, path string) (*http.Request, error) {
scheme := c.Scheme
if scheme == "" {
scheme = "http"
}
u := url.URL{Host: c.Host, Scheme: scheme, Path: path}
req, err := http.NewRequestWithContext(ctx, "GET", u.String(), nil)
if err != nil {
return nil, err
}
return req, nil
}
// SpecsOutputPath computes a request path to the specs action of output.
func SpecsOutputPath() string {
return fmt.Sprintf("/v2/outputs/_specs")
}
// Retrieve all output types available
func (c *Client) SpecsOutput(ctx context.Context, path string) (*http.Response, error) {
req, err := c.NewSpecsOutputRequest(ctx, path)
if err != nil {
return nil, err
}
return c.Client.Do(ctx, req)
}
// NewSpecsOutputRequest create the request corresponding to the specs action endpoint of the output resource.
func (c *Client) NewSpecsOutputRequest(ctx context.Context, path string) (*http.Request, error) {
scheme := c.Scheme
if scheme == "" {
scheme = "http"
}
u := url.URL{Host: c.Host, Scheme: scheme, Path: path}
req, err := http.NewRequestWithContext(ctx, "GET", u.String(), nil)
if err != nil {
return nil, err
}
return req, nil
}
// UpdateOutputPayload is the output update action payload.
type UpdateOutputPayload struct {
// Alias of the output
Alias *string `form:"alias,omitempty" json:"alias,omitempty" yaml:"alias,omitempty" xml:"alias,omitempty"`
// Conditional expression of the output
Condition *string `form:"condition,omitempty" json:"condition,omitempty" yaml:"condition,omitempty" xml:"condition,omitempty"`
// Output status
Enabled bool `form:"enabled" json:"enabled" yaml:"enabled" xml:"enabled"`
// Output properties
Props map[string]interface{} `form:"props,omitempty" json:"props,omitempty" yaml:"props,omitempty" xml:"props,omitempty"`
}
// UpdateOutputPath computes a request path to the update action of output.
func UpdateOutputPath(id string) string {
param0 := id
return fmt.Sprintf("/v2/outputs/%s", param0)
}
// Update an output
func (c *Client) UpdateOutput(ctx context.Context, path string, payload *UpdateOutputPayload, contentType string) (*http.Response, error) {
req, err := c.NewUpdateOutputRequest(ctx, path, payload, contentType)
if err != nil {
return nil, err
}
return c.Client.Do(ctx, req)
}
// NewUpdateOutputRequest create the request corresponding to the update action endpoint of the output resource.
func (c *Client) NewUpdateOutputRequest(ctx context.Context, path string, payload *UpdateOutputPayload, contentType string) (*http.Request, error) {
var body bytes.Buffer
if contentType == "" {
contentType = "*/*" // Use default encoder
}
err := c.Encoder.Encode(payload, &body, contentType)
if err != nil {
return nil, fmt.Errorf("failed to encode body: %s", err)
}
scheme := c.Scheme
if scheme == "" {
scheme = "http"
}
u := url.URL{Host: c.Host, Scheme: scheme, Path: path}
req, err := http.NewRequestWithContext(ctx, "PUT", u.String(), &body)
if err != nil {
return nil, err
}
header := req.Header
if contentType == "*/*" {
header.Set("Content-Type", "application/json")
} else {
header.Set("Content-Type", contentType)
}
return req, nil
}
// UpdateFilterOutputPayload is the output updateFilter action payload.
type UpdateFilterOutputPayload struct {
// Alias of the filter
Alias *string `form:"alias,omitempty" json:"alias,omitempty" yaml:"alias,omitempty" xml:"alias,omitempty"`
// Conditional expression of the output
Condition *string `form:"condition,omitempty" json:"condition,omitempty" yaml:"condition,omitempty" xml:"condition,omitempty"`
// Filter status
Enabled bool `form:"enabled" json:"enabled" yaml:"enabled" xml:"enabled"`
// Filter properties
Props map[string]interface{} `form:"props,omitempty" json:"props,omitempty" yaml:"props,omitempty" xml:"props,omitempty"`
}
// UpdateFilterOutputPath computes a request path to the updateFilter action of output.
func UpdateFilterOutputPath(id string, idFilter string) string {
param0 := id
param1 := idFilter
return fmt.Sprintf("/v2/outputs/%s/filters/%s", param0, param1)
}
// Update a filter
func (c *Client) UpdateFilterOutput(ctx context.Context, path string, payload *UpdateFilterOutputPayload, contentType string) (*http.Response, error) {
req, err := c.NewUpdateFilterOutputRequest(ctx, path, payload, contentType)
if err != nil {
return nil, err
}
return c.Client.Do(ctx, req)
}
// NewUpdateFilterOutputRequest create the request corresponding to the updateFilter action endpoint of the output resource.
func (c *Client) NewUpdateFilterOutputRequest(ctx context.Context, path string, payload *UpdateFilterOutputPayload, contentType string) (*http.Request, error) {
var body bytes.Buffer
if contentType == "" {
contentType = "*/*" // Use default encoder
}
err := c.Encoder.Encode(payload, &body, contentType)
if err != nil {
return nil, fmt.Errorf("failed to encode body: %s", err)
}
scheme := c.Scheme
if scheme == "" {
scheme = "http"
}
u := url.URL{Host: c.Host, Scheme: scheme, Path: path}
req, err := http.NewRequestWithContext(ctx, "PUT", u.String(), &body)
if err != nil {
return nil, err
}
header := req.Header
if contentType == "*/*" {
header.Set("Content-Type", "application/json")
} else {
header.Set("Content-Type", contentType)
}
return req, nil
}