wavefront-cli 6.1.0 → 8.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (67) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +9 -7
  3. data/.travis.yml +4 -5
  4. data/HISTORY.md +34 -1
  5. data/README.md +3 -4
  6. data/lib/wavefront-cli/account.rb +119 -0
  7. data/lib/wavefront-cli/alert.rb +29 -0
  8. data/lib/wavefront-cli/base.rb +10 -12
  9. data/lib/wavefront-cli/cloudintegration.rb +12 -0
  10. data/lib/wavefront-cli/commands/.rubocop.yml +12 -6
  11. data/lib/wavefront-cli/commands/account.rb +61 -0
  12. data/lib/wavefront-cli/commands/alert.rb +1 -0
  13. data/lib/wavefront-cli/commands/base.rb +1 -1
  14. data/lib/wavefront-cli/commands/cloudintegration.rb +4 -1
  15. data/lib/wavefront-cli/commands/query.rb +4 -1
  16. data/lib/wavefront-cli/commands/role.rb +44 -0
  17. data/lib/wavefront-cli/commands/spy.rb +0 -5
  18. data/lib/wavefront-cli/commands/usergroup.rb +7 -11
  19. data/lib/wavefront-cli/commands/write.rb +7 -2
  20. data/lib/wavefront-cli/config.rb +3 -1
  21. data/lib/wavefront-cli/controller.rb +6 -66
  22. data/lib/wavefront-cli/display/account.rb +122 -0
  23. data/lib/wavefront-cli/display/alert.rb +8 -0
  24. data/lib/wavefront-cli/display/base.rb +1 -1
  25. data/lib/wavefront-cli/display/cloudintegration.rb +15 -2
  26. data/lib/wavefront-cli/display/printer/long.rb +7 -2
  27. data/lib/wavefront-cli/display/query.rb +24 -0
  28. data/lib/wavefront-cli/display/role.rb +66 -0
  29. data/lib/wavefront-cli/display/settings.rb +1 -0
  30. data/lib/wavefront-cli/display/usergroup.rb +18 -14
  31. data/lib/wavefront-cli/event.rb +2 -0
  32. data/lib/wavefront-cli/exception_handler.rb +87 -0
  33. data/lib/wavefront-cli/externallink.rb +4 -6
  34. data/lib/wavefront-cli/helpers/load_file.rb +1 -1
  35. data/lib/wavefront-cli/opt_handler.rb +5 -3
  36. data/lib/wavefront-cli/output/hcl/base.rb +1 -1
  37. data/lib/wavefront-cli/query.rb +13 -7
  38. data/lib/wavefront-cli/role.rb +54 -0
  39. data/lib/wavefront-cli/serviceaccount.rb +0 -6
  40. data/lib/wavefront-cli/spy.rb +0 -8
  41. data/lib/wavefront-cli/usergroup.rb +8 -8
  42. data/lib/wavefront-cli/version.rb +1 -1
  43. data/lib/wavefront-cli/write.rb +33 -11
  44. data/spec/.rubocop.yml +13 -6
  45. data/spec/support/minitest_assertions.rb +2 -4
  46. data/spec/test_mixins/delete.rb +1 -2
  47. data/spec/wavefront-cli/account_spec.rb +303 -0
  48. data/spec/wavefront-cli/alert_spec.rb +28 -0
  49. data/spec/wavefront-cli/cloudintegration_spec.rb +19 -6
  50. data/spec/wavefront-cli/commands/write_spec.rb +1 -1
  51. data/spec/wavefront-cli/config_spec.rb +1 -1
  52. data/spec/wavefront-cli/controller_spec.rb +2 -0
  53. data/spec/wavefront-cli/event_spec.rb +1 -1
  54. data/spec/wavefront-cli/output/csv/query_spec.rb +1 -1
  55. data/spec/wavefront-cli/output/wavefront/query_spec.rb +2 -2
  56. data/spec/wavefront-cli/query_spec.rb +20 -3
  57. data/spec/wavefront-cli/role_spec.rb +187 -0
  58. data/spec/wavefront-cli/serviceaccount_spec.rb +3 -3
  59. data/spec/wavefront-cli/usergroup_spec.rb +48 -43
  60. data/spec/wavefront-cli/write_spec.rb +44 -0
  61. data/wavefront-cli.gemspec +6 -6
  62. metadata +27 -36
  63. data/lib/wavefront-cli/commands/user.rb +0 -54
  64. data/lib/wavefront-cli/display/user.rb +0 -103
  65. data/lib/wavefront-cli/user.rb +0 -92
  66. data/spec/wavefront-cli/resources/responses/user-list.json +0 -1
  67. data/spec/wavefront-cli/user_spec.rb +0 -311
@@ -209,4 +209,48 @@ class WavefrontCliWriteTest < MiniTest::Test
209
209
  refute WavefrontCli::Write.new(infileformat: 'fma').distribution?
210
210
  refute WavefrontCli::Write.new({}).distribution?
211
211
  end
212
+
213
+ def test_sane_value
214
+ assert_equal(0, wf.sane_value(0))
215
+ assert_equal(0, wf.sane_value(''))
216
+ assert_equal(-10, wf.sane_value('-10.0'))
217
+ assert_equal(10, wf.sane_value(' 10'))
218
+ assert_equal(10, wf.sane_value('\\10'))
219
+ assert_equal(10, wf.sane_value('\10'))
220
+ assert_raises(WavefrontCli::Exception::InvalidValue) { wf.sane_value(nil) }
221
+ assert_raises(WavefrontCli::Exception::InvalidValue) { wf.sane_value({}) }
222
+ assert_raises(WavefrontCli::Exception::InvalidValue) { wf.sane_value([]) }
223
+ end
224
+
225
+ def test_random_value_asymmetric_range
226
+ lower_bound = -5
227
+ upper_bound = 20
228
+
229
+ max = (1..1000).map { wf.random_value(lower_bound, upper_bound) }.max
230
+ min = (1..1000).map { wf.random_value(lower_bound, upper_bound) }.min
231
+
232
+ assert(max <= upper_bound)
233
+ assert(min >= lower_bound)
234
+ refute_equal(max, min)
235
+ end
236
+
237
+ def test_random_value_symmetric_range
238
+ lower_bound = -15
239
+ upper_bound = 15
240
+
241
+ max = (1..1000).map { wf.random_value(lower_bound, upper_bound) }.max
242
+ min = (1..1000).map { wf.random_value(lower_bound, upper_bound) }.min
243
+
244
+ assert(max <= upper_bound)
245
+ assert(min >= lower_bound)
246
+ refute_equal(max, min)
247
+ end
248
+
249
+ def test_random_value_single_value
250
+ lower_bound = 5
251
+ upper_bound = 5
252
+
253
+ assert_equal([5, 5, 5, 5, 5, 5, 5, 5, 5, 5],
254
+ (1..10).map { wf.random_value(lower_bound, upper_bound) })
255
+ end
212
256
  end
@@ -26,14 +26,14 @@ Gem::Specification.new do |gem|
26
26
 
27
27
  gem.add_runtime_dependency 'docopt', '~> 0.6.0'
28
28
  gem.add_runtime_dependency 'inifile', '~> 3.0'
29
- gem.add_runtime_dependency 'wavefront-sdk', '~> 4.0', '>= 4.0.0'
29
+ gem.add_runtime_dependency 'wavefront-sdk', '~> 5.2'
30
30
 
31
- gem.add_development_dependency 'minitest', '~> 5.11', '>= 5.11.0'
32
- gem.add_development_dependency 'rake', '~> 12.0'
33
- gem.add_development_dependency 'rubocop', '~> 0.79'
31
+ gem.add_development_dependency 'minitest', '~> 5.14'
32
+ gem.add_development_dependency 'rake', '~> 13.0'
33
+ gem.add_development_dependency 'rubocop', '0.91.0'
34
34
  gem.add_development_dependency 'spy', '~> 1.0.0'
35
- gem.add_development_dependency 'webmock', '~> 3.7'
35
+ gem.add_development_dependency 'webmock', '~> 3.8'
36
36
  gem.add_development_dependency 'yard', '~> 0.9.5'
37
37
 
38
- gem.required_ruby_version = Gem::Requirement.new('>= 2.4.0')
38
+ gem.required_ruby_version = Gem::Requirement.new('>= 2.5.0')
39
39
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: wavefront-cli
3
3
  version: !ruby/object:Gem::Version
4
- version: 6.1.0
4
+ version: 8.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Robert Fisher
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-06-02 00:00:00.000000000 Z
11
+ date: 2020-10-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: docopt
@@ -44,68 +44,56 @@ dependencies:
44
44
  requirements:
45
45
  - - "~>"
46
46
  - !ruby/object:Gem::Version
47
- version: '4.0'
48
- - - ">="
49
- - !ruby/object:Gem::Version
50
- version: 4.0.0
47
+ version: '5.2'
51
48
  type: :runtime
52
49
  prerelease: false
53
50
  version_requirements: !ruby/object:Gem::Requirement
54
51
  requirements:
55
52
  - - "~>"
56
53
  - !ruby/object:Gem::Version
57
- version: '4.0'
58
- - - ">="
59
- - !ruby/object:Gem::Version
60
- version: 4.0.0
54
+ version: '5.2'
61
55
  - !ruby/object:Gem::Dependency
62
56
  name: minitest
63
57
  requirement: !ruby/object:Gem::Requirement
64
58
  requirements:
65
59
  - - "~>"
66
60
  - !ruby/object:Gem::Version
67
- version: '5.11'
68
- - - ">="
69
- - !ruby/object:Gem::Version
70
- version: 5.11.0
61
+ version: '5.14'
71
62
  type: :development
72
63
  prerelease: false
73
64
  version_requirements: !ruby/object:Gem::Requirement
74
65
  requirements:
75
66
  - - "~>"
76
67
  - !ruby/object:Gem::Version
77
- version: '5.11'
78
- - - ">="
79
- - !ruby/object:Gem::Version
80
- version: 5.11.0
68
+ version: '5.14'
81
69
  - !ruby/object:Gem::Dependency
82
70
  name: rake
83
71
  requirement: !ruby/object:Gem::Requirement
84
72
  requirements:
85
73
  - - "~>"
86
74
  - !ruby/object:Gem::Version
87
- version: '12.0'
75
+ version: '13.0'
88
76
  type: :development
89
77
  prerelease: false
90
78
  version_requirements: !ruby/object:Gem::Requirement
91
79
  requirements:
92
80
  - - "~>"
93
81
  - !ruby/object:Gem::Version
94
- version: '12.0'
82
+ version: '13.0'
95
83
  - !ruby/object:Gem::Dependency
96
84
  name: rubocop
97
85
  requirement: !ruby/object:Gem::Requirement
98
86
  requirements:
99
- - - "~>"
87
+ - - '='
100
88
  - !ruby/object:Gem::Version
101
- version: '0.79'
89
+ version: 0.91.0
102
90
  type: :development
103
91
  prerelease: false
104
92
  version_requirements: !ruby/object:Gem::Requirement
105
93
  requirements:
106
- - - "~>"
94
+ - - '='
107
95
  - !ruby/object:Gem::Version
108
- version: '0.79'
96
+ version: 0.91.0
109
97
  - !ruby/object:Gem::Dependency
110
98
  name: spy
111
99
  requirement: !ruby/object:Gem::Requirement
@@ -126,14 +114,14 @@ dependencies:
126
114
  requirements:
127
115
  - - "~>"
128
116
  - !ruby/object:Gem::Version
129
- version: '3.7'
117
+ version: '3.8'
130
118
  type: :development
131
119
  prerelease: false
132
120
  version_requirements: !ruby/object:Gem::Requirement
133
121
  requirements:
134
122
  - - "~>"
135
123
  - !ruby/object:Gem::Version
136
- version: '3.7'
124
+ version: '3.8'
137
125
  - !ruby/object:Gem::Dependency
138
126
  name: yard
139
127
  requirement: !ruby/object:Gem::Requirement
@@ -165,6 +153,7 @@ files:
165
153
  - README.md
166
154
  - Rakefile
167
155
  - bin/wf
156
+ - lib/wavefront-cli/account.rb
168
157
  - lib/wavefront-cli/alert.rb
169
158
  - lib/wavefront-cli/apitoken.rb
170
159
  - lib/wavefront-cli/base.rb
@@ -172,6 +161,7 @@ files:
172
161
  - lib/wavefront-cli/command_mixins/acl.rb
173
162
  - lib/wavefront-cli/command_mixins/tag.rb
174
163
  - lib/wavefront-cli/commands/.rubocop.yml
164
+ - lib/wavefront-cli/commands/account.rb
175
165
  - lib/wavefront-cli/commands/alert.rb
176
166
  - lib/wavefront-cli/commands/apitoken.rb
177
167
  - lib/wavefront-cli/commands/base.rb
@@ -188,13 +178,13 @@ files:
188
178
  - lib/wavefront-cli/commands/notificant.rb
189
179
  - lib/wavefront-cli/commands/proxy.rb
190
180
  - lib/wavefront-cli/commands/query.rb
181
+ - lib/wavefront-cli/commands/role.rb
191
182
  - lib/wavefront-cli/commands/savedsearch.rb
192
183
  - lib/wavefront-cli/commands/serviceaccount.rb
193
184
  - lib/wavefront-cli/commands/settings.rb
194
185
  - lib/wavefront-cli/commands/source.rb
195
186
  - lib/wavefront-cli/commands/spy.rb
196
187
  - lib/wavefront-cli/commands/usage.rb
197
- - lib/wavefront-cli/commands/user.rb
198
188
  - lib/wavefront-cli/commands/usergroup.rb
199
189
  - lib/wavefront-cli/commands/webhook.rb
200
190
  - lib/wavefront-cli/commands/window.rb
@@ -204,6 +194,7 @@ files:
204
194
  - lib/wavefront-cli/controller.rb
205
195
  - lib/wavefront-cli/dashboard.rb
206
196
  - lib/wavefront-cli/derivedmetric.rb
197
+ - lib/wavefront-cli/display/account.rb
207
198
  - lib/wavefront-cli/display/alert.rb
208
199
  - lib/wavefront-cli/display/apitoken.rb
209
200
  - lib/wavefront-cli/display/base.rb
@@ -224,18 +215,19 @@ files:
224
215
  - lib/wavefront-cli/display/printer/terse.rb
225
216
  - lib/wavefront-cli/display/proxy.rb
226
217
  - lib/wavefront-cli/display/query.rb
218
+ - lib/wavefront-cli/display/role.rb
227
219
  - lib/wavefront-cli/display/savedsearch.rb
228
220
  - lib/wavefront-cli/display/serviceaccount.rb
229
221
  - lib/wavefront-cli/display/settings.rb
230
222
  - lib/wavefront-cli/display/source.rb
231
223
  - lib/wavefront-cli/display/spy.rb
232
224
  - lib/wavefront-cli/display/usage.rb
233
- - lib/wavefront-cli/display/user.rb
234
225
  - lib/wavefront-cli/display/usergroup.rb
235
226
  - lib/wavefront-cli/display/webhook.rb
236
227
  - lib/wavefront-cli/display/write.rb
237
228
  - lib/wavefront-cli/event.rb
238
229
  - lib/wavefront-cli/exception.rb
230
+ - lib/wavefront-cli/exception_handler.rb
239
231
  - lib/wavefront-cli/externallink.rb
240
232
  - lib/wavefront-cli/helpers/load_file.rb
241
233
  - lib/wavefront-cli/ingestionpolicy.rb
@@ -263,6 +255,7 @@ files:
263
255
  - lib/wavefront-cli/output/yaml.rb
264
256
  - lib/wavefront-cli/proxy.rb
265
257
  - lib/wavefront-cli/query.rb
258
+ - lib/wavefront-cli/role.rb
266
259
  - lib/wavefront-cli/savedsearch.rb
267
260
  - lib/wavefront-cli/serviceaccount.rb
268
261
  - lib/wavefront-cli/settings.rb
@@ -272,7 +265,6 @@ files:
272
265
  - lib/wavefront-cli/stdlib/string.rb
273
266
  - lib/wavefront-cli/subcommands/import.rb
274
267
  - lib/wavefront-cli/usage.rb
275
- - lib/wavefront-cli/user.rb
276
268
  - lib/wavefront-cli/usergroup.rb
277
269
  - lib/wavefront-cli/version.rb
278
270
  - lib/wavefront-cli/webhook.rb
@@ -296,6 +288,7 @@ files:
296
288
  - spec/test_mixins/search.rb
297
289
  - spec/test_mixins/set.rb
298
290
  - spec/test_mixins/tag.rb
291
+ - spec/wavefront-cli/account_spec.rb
299
292
  - spec/wavefront-cli/alert_spec.rb
300
293
  - spec/wavefront-cli/apitoken_spec.rb
301
294
  - spec/wavefront-cli/base_spec.rb
@@ -369,7 +362,6 @@ files:
369
362
  - spec/wavefront-cli/resources/responses/query.json
370
363
  - spec/wavefront-cli/resources/responses/savedsearch-list.json
371
364
  - spec/wavefront-cli/resources/responses/usage-export-csv.json
372
- - spec/wavefront-cli/resources/responses/user-list.json
373
365
  - spec/wavefront-cli/resources/responses/user-validate.json
374
366
  - spec/wavefront-cli/resources/responses/usergroup-list.json
375
367
  - spec/wavefront-cli/resources/responses/webhook-list.json
@@ -379,6 +371,7 @@ files:
379
371
  - spec/wavefront-cli/resources/updates/alert.json
380
372
  - spec/wavefront-cli/resources/updates/dashboard.json
381
373
  - spec/wavefront-cli/resources/wavefront.conf
374
+ - spec/wavefront-cli/role_spec.rb
382
375
  - spec/wavefront-cli/savedsearch_spec.rb
383
376
  - spec/wavefront-cli/serviceaccount_spec.rb
384
377
  - spec/wavefront-cli/settings_spec.rb
@@ -387,7 +380,6 @@ files:
387
380
  - spec/wavefront-cli/stdlib/array_spec.rb
388
381
  - spec/wavefront-cli/stdlib/string_spec.rb
389
382
  - spec/wavefront-cli/usage_spec.rb
390
- - spec/wavefront-cli/user_spec.rb
391
383
  - spec/wavefront-cli/usergroup_spec.rb
392
384
  - spec/wavefront-cli/webhook_spec.rb
393
385
  - spec/wavefront-cli/write_spec.rb
@@ -404,15 +396,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
404
396
  requirements:
405
397
  - - ">="
406
398
  - !ruby/object:Gem::Version
407
- version: 2.4.0
399
+ version: 2.5.0
408
400
  required_rubygems_version: !ruby/object:Gem::Requirement
409
401
  requirements:
410
402
  - - ">="
411
403
  - !ruby/object:Gem::Version
412
404
  version: '0'
413
405
  requirements: []
414
- rubyforge_project:
415
- rubygems_version: 2.7.7
406
+ rubygems_version: 3.0.8
416
407
  signing_key:
417
408
  specification_version: 4
418
409
  summary: CLI for Wavefront API v2
@@ -436,6 +427,7 @@ test_files:
436
427
  - spec/test_mixins/search.rb
437
428
  - spec/test_mixins/set.rb
438
429
  - spec/test_mixins/tag.rb
430
+ - spec/wavefront-cli/account_spec.rb
439
431
  - spec/wavefront-cli/alert_spec.rb
440
432
  - spec/wavefront-cli/apitoken_spec.rb
441
433
  - spec/wavefront-cli/base_spec.rb
@@ -509,7 +501,6 @@ test_files:
509
501
  - spec/wavefront-cli/resources/responses/query.json
510
502
  - spec/wavefront-cli/resources/responses/savedsearch-list.json
511
503
  - spec/wavefront-cli/resources/responses/usage-export-csv.json
512
- - spec/wavefront-cli/resources/responses/user-list.json
513
504
  - spec/wavefront-cli/resources/responses/user-validate.json
514
505
  - spec/wavefront-cli/resources/responses/usergroup-list.json
515
506
  - spec/wavefront-cli/resources/responses/webhook-list.json
@@ -519,6 +510,7 @@ test_files:
519
510
  - spec/wavefront-cli/resources/updates/alert.json
520
511
  - spec/wavefront-cli/resources/updates/dashboard.json
521
512
  - spec/wavefront-cli/resources/wavefront.conf
513
+ - spec/wavefront-cli/role_spec.rb
522
514
  - spec/wavefront-cli/savedsearch_spec.rb
523
515
  - spec/wavefront-cli/serviceaccount_spec.rb
524
516
  - spec/wavefront-cli/settings_spec.rb
@@ -527,7 +519,6 @@ test_files:
527
519
  - spec/wavefront-cli/stdlib/array_spec.rb
528
520
  - spec/wavefront-cli/stdlib/string_spec.rb
529
521
  - spec/wavefront-cli/usage_spec.rb
530
- - spec/wavefront-cli/user_spec.rb
531
522
  - spec/wavefront-cli/usergroup_spec.rb
532
523
  - spec/wavefront-cli/webhook_spec.rb
533
524
  - spec/wavefront-cli/write_spec.rb
@@ -1,54 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require_relative 'base'
4
-
5
- # Define the user command.
6
- #
7
- class WavefrontCommandUser < WavefrontCommandBase
8
- def description
9
- "view and manage Wavefront #{things}"
10
- end
11
-
12
- # delete uses a different string because it accepts multiples.
13
- # Adding ellipsis to <id> causes everything else to expect an
14
- # array.
15
- #
16
- def _commands
17
- ["list #{CMN} [-l] [-O fields]",
18
- "describe #{CMN} <id>",
19
- "create #{CMN} [-e] [-m permission...] [-g group...] <id>",
20
- "invite #{CMN} [-m permission...] [-g group...] <id>",
21
- "delete #{CMN} <user>...",
22
- "dump #{CMN}",
23
- "import #{CMN} [-uU] <file>",
24
- "groups #{CMN} <id>",
25
- "privileges #{CMN} <id>",
26
- "join #{CMN} <id> <group>...",
27
- "leave #{CMN} <id> <group>...",
28
- "grant #{CMN} <privilege> to <id>",
29
- "revoke #{CMN} <privilege> from <id>",
30
- "business functions #{CMN} <id>",
31
- "validate #{CMN} [-l] <user>...",
32
- "search #{CMN} [-al] [-o offset] [-L limit] [-O fields] <condition>..."]
33
- end
34
-
35
- def _options
36
- [common_options,
37
- "-l, --long list #{things} in detail",
38
- "-a, --all list all #{things}",
39
- "-o, --offset=n start from nth #{thing}",
40
- "-L, --limit=COUNT number of #{things} to list",
41
- '-O, --fields=F1,F2,... only show given fields',
42
- "-u, --update update an existing #{thing}",
43
- "-U, --upsert import new or update existing #{thing}",
44
- "-e, --email send e-mail to #{thing} on account creation",
45
- "-m, --permission=STRING give #{thing} this permission",
46
- "-g, --group=STRING add #{thing} to this user group"]
47
- end
48
-
49
- def postscript
50
- 'If your account does not have RBAC enabled, you must grant user ' \
51
- "permissions with '-m'. For a list of permissions, see " \
52
- "'wf usergroup --help'.".fold(TW, 0)
53
- end
54
- end
@@ -1,103 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require_relative 'base'
4
-
5
- module WavefrontDisplay
6
- #
7
- # Format human-readable output for user management.
8
- #
9
- class User < Base
10
- def do_list_brief
11
- data.each { |user| puts user[:identifier] }
12
- end
13
-
14
- def do_groups
15
- groups = data.first.userGroups
16
-
17
- if groups.empty?
18
- puts 'User does not belong to any groups.'
19
- else
20
- groups.each { |u| puts format('%<id>s (%<name>s)', u) }
21
- end
22
- end
23
-
24
- def do_privileges
25
- puts(if data.first[:groups].empty?
26
- 'User does not have any Wavefront privileges.'
27
- else
28
- data.first[:groups]
29
- end)
30
- end
31
-
32
- def do_create
33
- info = data[0]
34
- puts format("Created user '%<user>s'.\nPermission groups\n" \
35
- "%<perm_groups>s\nUser groups\n%<user_groups>s",
36
- user: info[:identifier],
37
- perm_groups: groups_as_string(info[:groups]),
38
- user_groups: user_groups_as_string(info[:userGroups]))
39
- end
40
-
41
- def groups_as_string(groups)
42
- return ' <none>' if groups.empty?
43
-
44
- data.response.groups.map do |g|
45
- format(' %<group>s', group: g)
46
- end.join("\n ")
47
- end
48
-
49
- def user_groups_as_string(groups)
50
- return ' <none>' if groups.empty?
51
-
52
- groups.map { |g| format(' %<name>s (%<id>s)', g) }.join("\n")
53
- end
54
-
55
- def do_delete
56
- puts format('Deleted %<quoted_user>s.',
57
- quoted_user: quoted(options[:'<user>']))
58
- end
59
-
60
- def do_invite
61
- puts format("Sent invitation to '%<id>s'.", id: options[:'<id>'])
62
- end
63
-
64
- def do_grant
65
- puts format("Granted '%<priv>s' to '%<id>s'.",
66
- priv: options[:'<privilege>'],
67
- id: options[:'<id>'])
68
- end
69
-
70
- def do_revoke
71
- puts format("Revoked '%<priv>s' from '%<id>s'.",
72
- priv: options[:'<privilege>'],
73
- id: options[:'<id>'])
74
- end
75
-
76
- def do_join
77
- puts format("Added '%<id>s' to %<quoted_group>s.",
78
- id: options[:'<id>'],
79
- quoted_group: quoted(options[:'<group>']))
80
- end
81
-
82
- def do_leave
83
- puts format("Removed '%<id>s' from %<quoted_group>s.",
84
- id: options[:'<id>'],
85
- quoted_group: quoted(options[:'<group>']))
86
- end
87
-
88
- def do_business_functions
89
- puts data.sort
90
- end
91
-
92
- def do_validate_brief
93
- valid = data[0][:validUsers]
94
- invalid = data[0][:invalidIdentifiers]
95
-
96
- puts 'valid ',
97
- valid.empty? ? ' <none>' : valid.map { |u| " #{u[:identifier]}" }
98
-
99
- puts 'invalid',
100
- invalid.empty? ? ' <none>' : invalid.map { |u| " #{u}" }
101
- end
102
- end
103
- end