wavefront-cli 6.1.0 → 7.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.rubocop.yml +34 -1
- data/HISTORY.md +17 -1
- data/README.md +2 -3
- data/lib/wavefront-cli/account.rb +119 -0
- data/lib/wavefront-cli/alert.rb +29 -0
- data/lib/wavefront-cli/base.rb +0 -2
- data/lib/wavefront-cli/commands/.rubocop.yml +34 -0
- data/lib/wavefront-cli/commands/account.rb +61 -0
- data/lib/wavefront-cli/commands/alert.rb +1 -0
- data/lib/wavefront-cli/commands/base.rb +1 -1
- data/lib/wavefront-cli/commands/query.rb +4 -1
- data/lib/wavefront-cli/commands/role.rb +44 -0
- data/lib/wavefront-cli/commands/spy.rb +0 -5
- data/lib/wavefront-cli/commands/usergroup.rb +7 -11
- data/lib/wavefront-cli/commands/write.rb +7 -2
- data/lib/wavefront-cli/controller.rb +5 -63
- data/lib/wavefront-cli/display/account.rb +122 -0
- data/lib/wavefront-cli/display/alert.rb +8 -0
- data/lib/wavefront-cli/display/base.rb +1 -1
- data/lib/wavefront-cli/display/cloudintegration.rb +3 -2
- data/lib/wavefront-cli/display/printer/long.rb +2 -1
- data/lib/wavefront-cli/display/role.rb +66 -0
- data/lib/wavefront-cli/display/settings.rb +1 -0
- data/lib/wavefront-cli/display/usergroup.rb +18 -14
- data/lib/wavefront-cli/exception_handler.rb +87 -0
- data/lib/wavefront-cli/output/hcl/base.rb +1 -1
- data/lib/wavefront-cli/query.rb +13 -7
- data/lib/wavefront-cli/role.rb +54 -0
- data/lib/wavefront-cli/serviceaccount.rb +0 -6
- data/lib/wavefront-cli/spy.rb +0 -8
- data/lib/wavefront-cli/usergroup.rb +8 -8
- data/lib/wavefront-cli/version.rb +1 -1
- data/lib/wavefront-cli/write.rb +28 -4
- data/spec/.rubocop.yml +34 -0
- data/spec/test_mixins/delete.rb +1 -2
- data/spec/wavefront-cli/account_spec.rb +303 -0
- data/spec/wavefront-cli/alert_spec.rb +28 -0
- data/spec/wavefront-cli/commands/write_spec.rb +1 -1
- data/spec/wavefront-cli/event_spec.rb +1 -1
- data/spec/wavefront-cli/output/csv/query_spec.rb +1 -1
- data/spec/wavefront-cli/output/wavefront/query_spec.rb +2 -2
- data/spec/wavefront-cli/query_spec.rb +20 -3
- data/spec/wavefront-cli/role_spec.rb +187 -0
- data/spec/wavefront-cli/serviceaccount_spec.rb +3 -3
- data/spec/wavefront-cli/usergroup_spec.rb +48 -43
- data/spec/wavefront-cli/write_spec.rb +44 -0
- data/wavefront-cli.gemspec +3 -3
- metadata +30 -27
- data/lib/wavefront-cli/commands/user.rb +0 -54
- data/lib/wavefront-cli/display/user.rb +0 -103
- data/lib/wavefront-cli/user.rb +0 -92
- data/spec/wavefront-cli/resources/responses/user-list.json +0 -1
- 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
|
data/wavefront-cli.gemspec
CHANGED
@@ -26,11 +26,11 @@ 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', '~>
|
29
|
+
gem.add_runtime_dependency 'wavefront-sdk', '~> 5.0', '>= 5.0.1'
|
30
30
|
|
31
31
|
gem.add_development_dependency 'minitest', '~> 5.11', '>= 5.11.0'
|
32
|
-
gem.add_development_dependency 'rake', '~>
|
33
|
-
gem.add_development_dependency 'rubocop', '
|
32
|
+
gem.add_development_dependency 'rake', '~> 13.0'
|
33
|
+
gem.add_development_dependency 'rubocop', '0.87.1'
|
34
34
|
gem.add_development_dependency 'spy', '~> 1.0.0'
|
35
35
|
gem.add_development_dependency 'webmock', '~> 3.7'
|
36
36
|
gem.add_development_dependency 'yard', '~> 0.9.5'
|
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:
|
4
|
+
version: 7.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-
|
11
|
+
date: 2020-08-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: docopt
|
@@ -44,68 +44,68 @@ dependencies:
|
|
44
44
|
requirements:
|
45
45
|
- - "~>"
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version: '
|
47
|
+
version: '5.0'
|
48
48
|
- - ">="
|
49
49
|
- !ruby/object:Gem::Version
|
50
|
-
version:
|
50
|
+
version: 5.0.1
|
51
51
|
type: :runtime
|
52
52
|
prerelease: false
|
53
53
|
version_requirements: !ruby/object:Gem::Requirement
|
54
54
|
requirements:
|
55
55
|
- - "~>"
|
56
56
|
- !ruby/object:Gem::Version
|
57
|
-
version: '
|
57
|
+
version: '5.0'
|
58
58
|
- - ">="
|
59
59
|
- !ruby/object:Gem::Version
|
60
|
-
version:
|
60
|
+
version: 5.0.1
|
61
61
|
- !ruby/object:Gem::Dependency
|
62
62
|
name: minitest
|
63
63
|
requirement: !ruby/object:Gem::Requirement
|
64
64
|
requirements:
|
65
|
-
- - "~>"
|
66
|
-
- !ruby/object:Gem::Version
|
67
|
-
version: '5.11'
|
68
65
|
- - ">="
|
69
66
|
- !ruby/object:Gem::Version
|
70
67
|
version: 5.11.0
|
68
|
+
- - "~>"
|
69
|
+
- !ruby/object:Gem::Version
|
70
|
+
version: '5.11'
|
71
71
|
type: :development
|
72
72
|
prerelease: false
|
73
73
|
version_requirements: !ruby/object:Gem::Requirement
|
74
74
|
requirements:
|
75
|
-
- - "~>"
|
76
|
-
- !ruby/object:Gem::Version
|
77
|
-
version: '5.11'
|
78
75
|
- - ">="
|
79
76
|
- !ruby/object:Gem::Version
|
80
77
|
version: 5.11.0
|
78
|
+
- - "~>"
|
79
|
+
- !ruby/object:Gem::Version
|
80
|
+
version: '5.11'
|
81
81
|
- !ruby/object:Gem::Dependency
|
82
82
|
name: rake
|
83
83
|
requirement: !ruby/object:Gem::Requirement
|
84
84
|
requirements:
|
85
85
|
- - "~>"
|
86
86
|
- !ruby/object:Gem::Version
|
87
|
-
version: '
|
87
|
+
version: '13.0'
|
88
88
|
type: :development
|
89
89
|
prerelease: false
|
90
90
|
version_requirements: !ruby/object:Gem::Requirement
|
91
91
|
requirements:
|
92
92
|
- - "~>"
|
93
93
|
- !ruby/object:Gem::Version
|
94
|
-
version: '
|
94
|
+
version: '13.0'
|
95
95
|
- !ruby/object:Gem::Dependency
|
96
96
|
name: rubocop
|
97
97
|
requirement: !ruby/object:Gem::Requirement
|
98
98
|
requirements:
|
99
|
-
- -
|
99
|
+
- - '='
|
100
100
|
- !ruby/object:Gem::Version
|
101
|
-
version:
|
101
|
+
version: 0.87.1
|
102
102
|
type: :development
|
103
103
|
prerelease: false
|
104
104
|
version_requirements: !ruby/object:Gem::Requirement
|
105
105
|
requirements:
|
106
|
-
- -
|
106
|
+
- - '='
|
107
107
|
- !ruby/object:Gem::Version
|
108
|
-
version:
|
108
|
+
version: 0.87.1
|
109
109
|
- !ruby/object:Gem::Dependency
|
110
110
|
name: spy
|
111
111
|
requirement: !ruby/object:Gem::Requirement
|
@@ -165,6 +165,7 @@ files:
|
|
165
165
|
- README.md
|
166
166
|
- Rakefile
|
167
167
|
- bin/wf
|
168
|
+
- lib/wavefront-cli/account.rb
|
168
169
|
- lib/wavefront-cli/alert.rb
|
169
170
|
- lib/wavefront-cli/apitoken.rb
|
170
171
|
- lib/wavefront-cli/base.rb
|
@@ -172,6 +173,7 @@ files:
|
|
172
173
|
- lib/wavefront-cli/command_mixins/acl.rb
|
173
174
|
- lib/wavefront-cli/command_mixins/tag.rb
|
174
175
|
- lib/wavefront-cli/commands/.rubocop.yml
|
176
|
+
- lib/wavefront-cli/commands/account.rb
|
175
177
|
- lib/wavefront-cli/commands/alert.rb
|
176
178
|
- lib/wavefront-cli/commands/apitoken.rb
|
177
179
|
- lib/wavefront-cli/commands/base.rb
|
@@ -188,13 +190,13 @@ files:
|
|
188
190
|
- lib/wavefront-cli/commands/notificant.rb
|
189
191
|
- lib/wavefront-cli/commands/proxy.rb
|
190
192
|
- lib/wavefront-cli/commands/query.rb
|
193
|
+
- lib/wavefront-cli/commands/role.rb
|
191
194
|
- lib/wavefront-cli/commands/savedsearch.rb
|
192
195
|
- lib/wavefront-cli/commands/serviceaccount.rb
|
193
196
|
- lib/wavefront-cli/commands/settings.rb
|
194
197
|
- lib/wavefront-cli/commands/source.rb
|
195
198
|
- lib/wavefront-cli/commands/spy.rb
|
196
199
|
- lib/wavefront-cli/commands/usage.rb
|
197
|
-
- lib/wavefront-cli/commands/user.rb
|
198
200
|
- lib/wavefront-cli/commands/usergroup.rb
|
199
201
|
- lib/wavefront-cli/commands/webhook.rb
|
200
202
|
- lib/wavefront-cli/commands/window.rb
|
@@ -204,6 +206,7 @@ files:
|
|
204
206
|
- lib/wavefront-cli/controller.rb
|
205
207
|
- lib/wavefront-cli/dashboard.rb
|
206
208
|
- lib/wavefront-cli/derivedmetric.rb
|
209
|
+
- lib/wavefront-cli/display/account.rb
|
207
210
|
- lib/wavefront-cli/display/alert.rb
|
208
211
|
- lib/wavefront-cli/display/apitoken.rb
|
209
212
|
- lib/wavefront-cli/display/base.rb
|
@@ -224,18 +227,19 @@ files:
|
|
224
227
|
- lib/wavefront-cli/display/printer/terse.rb
|
225
228
|
- lib/wavefront-cli/display/proxy.rb
|
226
229
|
- lib/wavefront-cli/display/query.rb
|
230
|
+
- lib/wavefront-cli/display/role.rb
|
227
231
|
- lib/wavefront-cli/display/savedsearch.rb
|
228
232
|
- lib/wavefront-cli/display/serviceaccount.rb
|
229
233
|
- lib/wavefront-cli/display/settings.rb
|
230
234
|
- lib/wavefront-cli/display/source.rb
|
231
235
|
- lib/wavefront-cli/display/spy.rb
|
232
236
|
- lib/wavefront-cli/display/usage.rb
|
233
|
-
- lib/wavefront-cli/display/user.rb
|
234
237
|
- lib/wavefront-cli/display/usergroup.rb
|
235
238
|
- lib/wavefront-cli/display/webhook.rb
|
236
239
|
- lib/wavefront-cli/display/write.rb
|
237
240
|
- lib/wavefront-cli/event.rb
|
238
241
|
- lib/wavefront-cli/exception.rb
|
242
|
+
- lib/wavefront-cli/exception_handler.rb
|
239
243
|
- lib/wavefront-cli/externallink.rb
|
240
244
|
- lib/wavefront-cli/helpers/load_file.rb
|
241
245
|
- lib/wavefront-cli/ingestionpolicy.rb
|
@@ -263,6 +267,7 @@ files:
|
|
263
267
|
- lib/wavefront-cli/output/yaml.rb
|
264
268
|
- lib/wavefront-cli/proxy.rb
|
265
269
|
- lib/wavefront-cli/query.rb
|
270
|
+
- lib/wavefront-cli/role.rb
|
266
271
|
- lib/wavefront-cli/savedsearch.rb
|
267
272
|
- lib/wavefront-cli/serviceaccount.rb
|
268
273
|
- lib/wavefront-cli/settings.rb
|
@@ -272,7 +277,6 @@ files:
|
|
272
277
|
- lib/wavefront-cli/stdlib/string.rb
|
273
278
|
- lib/wavefront-cli/subcommands/import.rb
|
274
279
|
- lib/wavefront-cli/usage.rb
|
275
|
-
- lib/wavefront-cli/user.rb
|
276
280
|
- lib/wavefront-cli/usergroup.rb
|
277
281
|
- lib/wavefront-cli/version.rb
|
278
282
|
- lib/wavefront-cli/webhook.rb
|
@@ -296,6 +300,7 @@ files:
|
|
296
300
|
- spec/test_mixins/search.rb
|
297
301
|
- spec/test_mixins/set.rb
|
298
302
|
- spec/test_mixins/tag.rb
|
303
|
+
- spec/wavefront-cli/account_spec.rb
|
299
304
|
- spec/wavefront-cli/alert_spec.rb
|
300
305
|
- spec/wavefront-cli/apitoken_spec.rb
|
301
306
|
- spec/wavefront-cli/base_spec.rb
|
@@ -369,7 +374,6 @@ files:
|
|
369
374
|
- spec/wavefront-cli/resources/responses/query.json
|
370
375
|
- spec/wavefront-cli/resources/responses/savedsearch-list.json
|
371
376
|
- spec/wavefront-cli/resources/responses/usage-export-csv.json
|
372
|
-
- spec/wavefront-cli/resources/responses/user-list.json
|
373
377
|
- spec/wavefront-cli/resources/responses/user-validate.json
|
374
378
|
- spec/wavefront-cli/resources/responses/usergroup-list.json
|
375
379
|
- spec/wavefront-cli/resources/responses/webhook-list.json
|
@@ -379,6 +383,7 @@ files:
|
|
379
383
|
- spec/wavefront-cli/resources/updates/alert.json
|
380
384
|
- spec/wavefront-cli/resources/updates/dashboard.json
|
381
385
|
- spec/wavefront-cli/resources/wavefront.conf
|
386
|
+
- spec/wavefront-cli/role_spec.rb
|
382
387
|
- spec/wavefront-cli/savedsearch_spec.rb
|
383
388
|
- spec/wavefront-cli/serviceaccount_spec.rb
|
384
389
|
- spec/wavefront-cli/settings_spec.rb
|
@@ -387,7 +392,6 @@ files:
|
|
387
392
|
- spec/wavefront-cli/stdlib/array_spec.rb
|
388
393
|
- spec/wavefront-cli/stdlib/string_spec.rb
|
389
394
|
- spec/wavefront-cli/usage_spec.rb
|
390
|
-
- spec/wavefront-cli/user_spec.rb
|
391
395
|
- spec/wavefront-cli/usergroup_spec.rb
|
392
396
|
- spec/wavefront-cli/webhook_spec.rb
|
393
397
|
- spec/wavefront-cli/write_spec.rb
|
@@ -411,8 +415,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
411
415
|
- !ruby/object:Gem::Version
|
412
416
|
version: '0'
|
413
417
|
requirements: []
|
414
|
-
|
415
|
-
rubygems_version: 2.7.7
|
418
|
+
rubygems_version: 3.0.8
|
416
419
|
signing_key:
|
417
420
|
specification_version: 4
|
418
421
|
summary: CLI for Wavefront API v2
|
@@ -436,6 +439,7 @@ test_files:
|
|
436
439
|
- spec/test_mixins/search.rb
|
437
440
|
- spec/test_mixins/set.rb
|
438
441
|
- spec/test_mixins/tag.rb
|
442
|
+
- spec/wavefront-cli/account_spec.rb
|
439
443
|
- spec/wavefront-cli/alert_spec.rb
|
440
444
|
- spec/wavefront-cli/apitoken_spec.rb
|
441
445
|
- spec/wavefront-cli/base_spec.rb
|
@@ -509,7 +513,6 @@ test_files:
|
|
509
513
|
- spec/wavefront-cli/resources/responses/query.json
|
510
514
|
- spec/wavefront-cli/resources/responses/savedsearch-list.json
|
511
515
|
- spec/wavefront-cli/resources/responses/usage-export-csv.json
|
512
|
-
- spec/wavefront-cli/resources/responses/user-list.json
|
513
516
|
- spec/wavefront-cli/resources/responses/user-validate.json
|
514
517
|
- spec/wavefront-cli/resources/responses/usergroup-list.json
|
515
518
|
- spec/wavefront-cli/resources/responses/webhook-list.json
|
@@ -519,6 +522,7 @@ test_files:
|
|
519
522
|
- spec/wavefront-cli/resources/updates/alert.json
|
520
523
|
- spec/wavefront-cli/resources/updates/dashboard.json
|
521
524
|
- spec/wavefront-cli/resources/wavefront.conf
|
525
|
+
- spec/wavefront-cli/role_spec.rb
|
522
526
|
- spec/wavefront-cli/savedsearch_spec.rb
|
523
527
|
- spec/wavefront-cli/serviceaccount_spec.rb
|
524
528
|
- spec/wavefront-cli/settings_spec.rb
|
@@ -527,7 +531,6 @@ test_files:
|
|
527
531
|
- spec/wavefront-cli/stdlib/array_spec.rb
|
528
532
|
- spec/wavefront-cli/stdlib/string_spec.rb
|
529
533
|
- spec/wavefront-cli/usage_spec.rb
|
530
|
-
- spec/wavefront-cli/user_spec.rb
|
531
534
|
- spec/wavefront-cli/usergroup_spec.rb
|
532
535
|
- spec/wavefront-cli/webhook_spec.rb
|
533
536
|
- 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
|