-
Notifications
You must be signed in to change notification settings - Fork 19
/
Copy pathusergroups_gen.go
556 lines (485 loc) · 15 KB
/
usergroups_gen.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
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
package slack
// Auto-generated by internal/cmd/genmethods/genmethods.go. DO NOT EDIT!
import (
"context"
"net/url"
"strconv"
"strings"
"github.com/lestrrat-go/slack/objects"
"github.com/pkg/errors"
)
var _ = strconv.Itoa
var _ = strings.Index
var _ = objects.EpochTime(0)
// UsergroupsCreateCall is created by UsergroupsService.Create method call
type UsergroupsCreateCall struct {
service *UsergroupsService
channels string // Comma-separated list of channels IDs
description string
handle string
includeCount bool
name string
}
// UsergroupsDisableCall is created by UsergroupsService.Disable method call
type UsergroupsDisableCall struct {
service *UsergroupsService
includeCount bool
usergroup string
}
// UsergroupsEnableCall is created by UsergroupsService.Enable method call
type UsergroupsEnableCall struct {
service *UsergroupsService
includeCount bool
usergroup string
}
// UsergroupsListCall is created by UsergroupsService.List method call
type UsergroupsListCall struct {
service *UsergroupsService
includeCount bool
includeDisabled bool
includeUsers bool
}
// UsergroupsUpdateCall is created by UsergroupsService.Update method call
type UsergroupsUpdateCall struct {
service *UsergroupsService
channels string // Comma-separated list of channels IDs
description string
handle string
includeCount bool
name string
usergroup string
}
// Create creates a UsergroupsCreateCall object in preparation for accessing the usergroups.create endpoint
func (s *UsergroupsService) Create(name string) *UsergroupsCreateCall {
var call UsergroupsCreateCall
call.service = s
call.name = name
return &call
}
// Channels sets the value for optional channels parameter
func (c *UsergroupsCreateCall) Channels(channels string) *UsergroupsCreateCall {
c.channels = channels
return c
}
// Description sets the value for optional description parameter
func (c *UsergroupsCreateCall) Description(description string) *UsergroupsCreateCall {
c.description = description
return c
}
// Handle sets the value for optional handle parameter
func (c *UsergroupsCreateCall) Handle(handle string) *UsergroupsCreateCall {
c.handle = handle
return c
}
// IncludeCount sets the value for optional includeCount parameter
func (c *UsergroupsCreateCall) IncludeCount(includeCount bool) *UsergroupsCreateCall {
c.includeCount = includeCount
return c
}
// ValidateArgs checks that all required fields are set in the UsergroupsCreateCall object
func (c *UsergroupsCreateCall) ValidateArgs() error {
if len(c.name) <= 0 {
return errors.New(`required field name not initialized`)
}
return nil
}
// Values returns the UsergroupsCreateCall object as url.Values
func (c *UsergroupsCreateCall) Values() (url.Values, error) {
if err := c.ValidateArgs(); err != nil {
return nil, errors.Wrap(err, `failed validation`)
}
v := url.Values{}
v.Set(`token`, c.service.token)
if len(c.channels) > 0 {
v.Set("channels", c.channels)
}
if len(c.description) > 0 {
v.Set("description", c.description)
}
if len(c.handle) > 0 {
v.Set("handle", c.handle)
}
if c.includeCount {
v.Set("include_count", "true")
}
v.Set("name", c.name)
return v, nil
}
// Do executes the call to access usergroups.create endpoint
func (c *UsergroupsCreateCall) Do(ctx context.Context) (*objects.Usergroup, error) {
const endpoint = "usergroups.create"
v, err := c.Values()
if err != nil {
return nil, err
}
var res struct {
objects.GenericResponse
*objects.Usergroup `json:"usergroup"`
}
if err := c.service.client.postForm(ctx, endpoint, v, &res); err != nil {
return nil, errors.Wrap(err, `failed to post to usergroups.create`)
}
if !res.OK {
return nil, errors.New(res.Error.String())
}
return res.Usergroup, nil
}
// FromValues parses the data in v and populates `c`
func (c *UsergroupsCreateCall) FromValues(v url.Values) error {
var tmp UsergroupsCreateCall
if raw := strings.TrimSpace(v.Get("channels")); len(raw) > 0 {
tmp.channels = raw
}
if raw := strings.TrimSpace(v.Get("description")); len(raw) > 0 {
tmp.description = raw
}
if raw := strings.TrimSpace(v.Get("handle")); len(raw) > 0 {
tmp.handle = raw
}
if raw := strings.TrimSpace(v.Get("include_count")); len(raw) > 0 {
parsed, err := strconv.ParseBool(raw)
if err != nil {
return errors.Wrap(err, `failed to parse boolean value "include_count"`)
}
tmp.includeCount = parsed
}
if raw := strings.TrimSpace(v.Get("name")); len(raw) > 0 {
tmp.name = raw
}
*c = tmp
return nil
}
// Disable creates a UsergroupsDisableCall object in preparation for accessing the usergroups.disable endpoint
func (s *UsergroupsService) Disable(usergroup string) *UsergroupsDisableCall {
var call UsergroupsDisableCall
call.service = s
call.usergroup = usergroup
return &call
}
// IncludeCount sets the value for optional includeCount parameter
func (c *UsergroupsDisableCall) IncludeCount(includeCount bool) *UsergroupsDisableCall {
c.includeCount = includeCount
return c
}
// ValidateArgs checks that all required fields are set in the UsergroupsDisableCall object
func (c *UsergroupsDisableCall) ValidateArgs() error {
if len(c.usergroup) <= 0 {
return errors.New(`required field usergroup not initialized`)
}
return nil
}
// Values returns the UsergroupsDisableCall object as url.Values
func (c *UsergroupsDisableCall) Values() (url.Values, error) {
if err := c.ValidateArgs(); err != nil {
return nil, errors.Wrap(err, `failed validation`)
}
v := url.Values{}
v.Set(`token`, c.service.token)
if c.includeCount {
v.Set("include_count", "true")
}
v.Set("usergroup", c.usergroup)
return v, nil
}
// Do executes the call to access usergroups.disable endpoint
func (c *UsergroupsDisableCall) Do(ctx context.Context) (*objects.Usergroup, error) {
const endpoint = "usergroups.disable"
v, err := c.Values()
if err != nil {
return nil, err
}
var res struct {
objects.GenericResponse
*objects.Usergroup `json:"usergroup"`
}
if err := c.service.client.postForm(ctx, endpoint, v, &res); err != nil {
return nil, errors.Wrap(err, `failed to post to usergroups.disable`)
}
if !res.OK {
return nil, errors.New(res.Error.String())
}
return res.Usergroup, nil
}
// FromValues parses the data in v and populates `c`
func (c *UsergroupsDisableCall) FromValues(v url.Values) error {
var tmp UsergroupsDisableCall
if raw := strings.TrimSpace(v.Get("include_count")); len(raw) > 0 {
parsed, err := strconv.ParseBool(raw)
if err != nil {
return errors.Wrap(err, `failed to parse boolean value "include_count"`)
}
tmp.includeCount = parsed
}
if raw := strings.TrimSpace(v.Get("usergroup")); len(raw) > 0 {
tmp.usergroup = raw
}
*c = tmp
return nil
}
// Enable creates a UsergroupsEnableCall object in preparation for accessing the usergroups.enable endpoint
func (s *UsergroupsService) Enable(usergroup string) *UsergroupsEnableCall {
var call UsergroupsEnableCall
call.service = s
call.usergroup = usergroup
return &call
}
// IncludeCount sets the value for optional includeCount parameter
func (c *UsergroupsEnableCall) IncludeCount(includeCount bool) *UsergroupsEnableCall {
c.includeCount = includeCount
return c
}
// ValidateArgs checks that all required fields are set in the UsergroupsEnableCall object
func (c *UsergroupsEnableCall) ValidateArgs() error {
if len(c.usergroup) <= 0 {
return errors.New(`required field usergroup not initialized`)
}
return nil
}
// Values returns the UsergroupsEnableCall object as url.Values
func (c *UsergroupsEnableCall) Values() (url.Values, error) {
if err := c.ValidateArgs(); err != nil {
return nil, errors.Wrap(err, `failed validation`)
}
v := url.Values{}
v.Set(`token`, c.service.token)
if c.includeCount {
v.Set("include_count", "true")
}
v.Set("usergroup", c.usergroup)
return v, nil
}
// Do executes the call to access usergroups.enable endpoint
func (c *UsergroupsEnableCall) Do(ctx context.Context) (*objects.Usergroup, error) {
const endpoint = "usergroups.enable"
v, err := c.Values()
if err != nil {
return nil, err
}
var res struct {
objects.GenericResponse
*objects.Usergroup `json:"usergroup"`
}
if err := c.service.client.postForm(ctx, endpoint, v, &res); err != nil {
return nil, errors.Wrap(err, `failed to post to usergroups.enable`)
}
if !res.OK {
return nil, errors.New(res.Error.String())
}
return res.Usergroup, nil
}
// FromValues parses the data in v and populates `c`
func (c *UsergroupsEnableCall) FromValues(v url.Values) error {
var tmp UsergroupsEnableCall
if raw := strings.TrimSpace(v.Get("include_count")); len(raw) > 0 {
parsed, err := strconv.ParseBool(raw)
if err != nil {
return errors.Wrap(err, `failed to parse boolean value "include_count"`)
}
tmp.includeCount = parsed
}
if raw := strings.TrimSpace(v.Get("usergroup")); len(raw) > 0 {
tmp.usergroup = raw
}
*c = tmp
return nil
}
// List creates a UsergroupsListCall object in preparation for accessing the usergroups.list endpoint
func (s *UsergroupsService) List() *UsergroupsListCall {
var call UsergroupsListCall
call.service = s
return &call
}
// IncludeCount sets the value for optional includeCount parameter
func (c *UsergroupsListCall) IncludeCount(includeCount bool) *UsergroupsListCall {
c.includeCount = includeCount
return c
}
// IncludeDisabled sets the value for optional includeDisabled parameter
func (c *UsergroupsListCall) IncludeDisabled(includeDisabled bool) *UsergroupsListCall {
c.includeDisabled = includeDisabled
return c
}
// IncludeUsers sets the value for optional includeUsers parameter
func (c *UsergroupsListCall) IncludeUsers(includeUsers bool) *UsergroupsListCall {
c.includeUsers = includeUsers
return c
}
// ValidateArgs checks that all required fields are set in the UsergroupsListCall object
func (c *UsergroupsListCall) ValidateArgs() error {
return nil
}
// Values returns the UsergroupsListCall object as url.Values
func (c *UsergroupsListCall) Values() (url.Values, error) {
if err := c.ValidateArgs(); err != nil {
return nil, errors.Wrap(err, `failed validation`)
}
v := url.Values{}
v.Set(`token`, c.service.token)
if c.includeCount {
v.Set("include_count", "true")
}
if c.includeDisabled {
v.Set("include_disabled", "true")
}
if c.includeUsers {
v.Set("include_users", "true")
}
return v, nil
}
// Do executes the call to access usergroups.list endpoint
func (c *UsergroupsListCall) Do(ctx context.Context) (objects.UsergroupList, error) {
const endpoint = "usergroups.list"
v, err := c.Values()
if err != nil {
return nil, err
}
var res struct {
objects.GenericResponse
objects.UsergroupList `json:"usergroups"`
}
if err := c.service.client.postForm(ctx, endpoint, v, &res); err != nil {
return nil, errors.Wrap(err, `failed to post to usergroups.list`)
}
if !res.OK {
return nil, errors.New(res.Error.String())
}
return res.UsergroupList, nil
}
// FromValues parses the data in v and populates `c`
func (c *UsergroupsListCall) FromValues(v url.Values) error {
var tmp UsergroupsListCall
if raw := strings.TrimSpace(v.Get("include_count")); len(raw) > 0 {
parsed, err := strconv.ParseBool(raw)
if err != nil {
return errors.Wrap(err, `failed to parse boolean value "include_count"`)
}
tmp.includeCount = parsed
}
if raw := strings.TrimSpace(v.Get("include_disabled")); len(raw) > 0 {
parsed, err := strconv.ParseBool(raw)
if err != nil {
return errors.Wrap(err, `failed to parse boolean value "include_disabled"`)
}
tmp.includeDisabled = parsed
}
if raw := strings.TrimSpace(v.Get("include_users")); len(raw) > 0 {
parsed, err := strconv.ParseBool(raw)
if err != nil {
return errors.Wrap(err, `failed to parse boolean value "include_users"`)
}
tmp.includeUsers = parsed
}
*c = tmp
return nil
}
// Update creates a UsergroupsUpdateCall object in preparation for accessing the usergroups.update endpoint
func (s *UsergroupsService) Update(usergroup string) *UsergroupsUpdateCall {
var call UsergroupsUpdateCall
call.service = s
call.usergroup = usergroup
return &call
}
// Channels sets the value for optional channels parameter
func (c *UsergroupsUpdateCall) Channels(channels string) *UsergroupsUpdateCall {
c.channels = channels
return c
}
// Description sets the value for optional description parameter
func (c *UsergroupsUpdateCall) Description(description string) *UsergroupsUpdateCall {
c.description = description
return c
}
// Handle sets the value for optional handle parameter
func (c *UsergroupsUpdateCall) Handle(handle string) *UsergroupsUpdateCall {
c.handle = handle
return c
}
// IncludeCount sets the value for optional includeCount parameter
func (c *UsergroupsUpdateCall) IncludeCount(includeCount bool) *UsergroupsUpdateCall {
c.includeCount = includeCount
return c
}
// Name sets the value for optional name parameter
func (c *UsergroupsUpdateCall) Name(name string) *UsergroupsUpdateCall {
c.name = name
return c
}
// ValidateArgs checks that all required fields are set in the UsergroupsUpdateCall object
func (c *UsergroupsUpdateCall) ValidateArgs() error {
if len(c.usergroup) <= 0 {
return errors.New(`required field usergroup not initialized`)
}
return nil
}
// Values returns the UsergroupsUpdateCall object as url.Values
func (c *UsergroupsUpdateCall) Values() (url.Values, error) {
if err := c.ValidateArgs(); err != nil {
return nil, errors.Wrap(err, `failed validation`)
}
v := url.Values{}
v.Set(`token`, c.service.token)
if len(c.channels) > 0 {
v.Set("channels", c.channels)
}
if len(c.description) > 0 {
v.Set("description", c.description)
}
if len(c.handle) > 0 {
v.Set("handle", c.handle)
}
if c.includeCount {
v.Set("include_count", "true")
}
if len(c.name) > 0 {
v.Set("name", c.name)
}
v.Set("usergroup", c.usergroup)
return v, nil
}
// Do executes the call to access usergroups.update endpoint
func (c *UsergroupsUpdateCall) Do(ctx context.Context) (*objects.Usergroup, error) {
const endpoint = "usergroups.update"
v, err := c.Values()
if err != nil {
return nil, err
}
var res struct {
objects.GenericResponse
*objects.Usergroup `json:"usergroup"`
}
if err := c.service.client.postForm(ctx, endpoint, v, &res); err != nil {
return nil, errors.Wrap(err, `failed to post to usergroups.update`)
}
if !res.OK {
return nil, errors.New(res.Error.String())
}
return res.Usergroup, nil
}
// FromValues parses the data in v and populates `c`
func (c *UsergroupsUpdateCall) FromValues(v url.Values) error {
var tmp UsergroupsUpdateCall
if raw := strings.TrimSpace(v.Get("channels")); len(raw) > 0 {
tmp.channels = raw
}
if raw := strings.TrimSpace(v.Get("description")); len(raw) > 0 {
tmp.description = raw
}
if raw := strings.TrimSpace(v.Get("handle")); len(raw) > 0 {
tmp.handle = raw
}
if raw := strings.TrimSpace(v.Get("include_count")); len(raw) > 0 {
parsed, err := strconv.ParseBool(raw)
if err != nil {
return errors.Wrap(err, `failed to parse boolean value "include_count"`)
}
tmp.includeCount = parsed
}
if raw := strings.TrimSpace(v.Get("name")); len(raw) > 0 {
tmp.name = raw
}
if raw := strings.TrimSpace(v.Get("usergroup")); len(raw) > 0 {
tmp.usergroup = raw
}
*c = tmp
return nil
}