wavefront-cli 5.1.1 → 7.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (65) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +37 -1
  3. data/HISTORY.md +34 -2
  4. data/README.md +2 -4
  5. data/lib/wavefront-cli/account.rb +119 -0
  6. data/lib/wavefront-cli/alert.rb +29 -0
  7. data/lib/wavefront-cli/base.rb +0 -2
  8. data/lib/wavefront-cli/cloudintegration.rb +12 -0
  9. data/lib/wavefront-cli/commands/.rubocop.yml +34 -0
  10. data/lib/wavefront-cli/commands/account.rb +61 -0
  11. data/lib/wavefront-cli/commands/alert.rb +1 -0
  12. data/lib/wavefront-cli/commands/base.rb +1 -1
  13. data/lib/wavefront-cli/commands/cloudintegration.rb +4 -1
  14. data/lib/wavefront-cli/commands/proxy.rb +2 -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/controller.rb +5 -63
  21. data/lib/wavefront-cli/display/account.rb +122 -0
  22. data/lib/wavefront-cli/display/alert.rb +8 -0
  23. data/lib/wavefront-cli/display/base.rb +1 -1
  24. data/lib/wavefront-cli/display/cloudintegration.rb +15 -2
  25. data/lib/wavefront-cli/display/printer/long.rb +2 -1
  26. data/lib/wavefront-cli/display/proxy.rb +16 -0
  27. data/lib/wavefront-cli/display/role.rb +66 -0
  28. data/lib/wavefront-cli/display/settings.rb +1 -0
  29. data/lib/wavefront-cli/display/usergroup.rb +18 -14
  30. data/lib/wavefront-cli/exception_handler.rb +89 -0
  31. data/lib/wavefront-cli/output/hcl/base.rb +1 -1
  32. data/lib/wavefront-cli/output/hcl/dashboard.rb +1 -1
  33. data/lib/wavefront-cli/proxy.rb +5 -0
  34. data/lib/wavefront-cli/query.rb +13 -7
  35. data/lib/wavefront-cli/role.rb +54 -0
  36. data/lib/wavefront-cli/serviceaccount.rb +0 -6
  37. data/lib/wavefront-cli/spy.rb +0 -8
  38. data/lib/wavefront-cli/usergroup.rb +8 -8
  39. data/lib/wavefront-cli/version.rb +1 -1
  40. data/lib/wavefront-cli/write.rb +29 -5
  41. data/spec/.rubocop.yml +34 -0
  42. data/spec/test_mixins/delete.rb +1 -2
  43. data/spec/wavefront-cli/account_spec.rb +303 -0
  44. data/spec/wavefront-cli/alert_spec.rb +28 -0
  45. data/spec/wavefront-cli/cloudintegration_spec.rb +19 -6
  46. data/spec/wavefront-cli/commands/write_spec.rb +1 -1
  47. data/spec/wavefront-cli/event_spec.rb +1 -1
  48. data/spec/wavefront-cli/output/csv/query_spec.rb +1 -1
  49. data/spec/wavefront-cli/output/wavefront/query_spec.rb +2 -2
  50. data/spec/wavefront-cli/query_spec.rb +20 -3
  51. data/spec/wavefront-cli/role_spec.rb +187 -0
  52. data/spec/wavefront-cli/serviceaccount_spec.rb +3 -3
  53. data/spec/wavefront-cli/usergroup_spec.rb +48 -43
  54. data/spec/wavefront-cli/write_spec.rb +44 -0
  55. data/wavefront-cli.gemspec +3 -3
  56. metadata +28 -36
  57. data/lib/wavefront-cli/commands/cluster.rb +0 -44
  58. data/lib/wavefront-cli/commands/user.rb +0 -54
  59. data/lib/wavefront-cli/display/monitoredcluster.rb +0 -14
  60. data/lib/wavefront-cli/display/user.rb +0 -103
  61. data/lib/wavefront-cli/monitoredcluster.rb +0 -50
  62. data/lib/wavefront-cli/user.rb +0 -92
  63. data/spec/wavefront-cli/monitoredcluster_spec.rb +0 -85
  64. data/spec/wavefront-cli/resources/responses/user-list.json +0 -1
  65. data/spec/wavefront-cli/user_spec.rb +0 -311
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 44f481275247e98780e57065df2166e93158382c03dea0d9dbc627b2d1756777
4
- data.tar.gz: b225b2ba3668cc00c6e3e873064bcf54b79c1dbc6638009cba09cfb6de7874c8
3
+ metadata.gz: 65a2455065fbd4b69b42718f7789e4c01cb5245a0015ea7d2977b96581ad0b83
4
+ data.tar.gz: 2c01e8464589c804271a97dba24a19a62b3f4a1dba9af588216f1d0b911c9ec9
5
5
  SHA512:
6
- metadata.gz: 42c775a15f3a74a7ffbaa45ebff0d38755996c64afeca494496c4707a26734733e6f18f7469be9ac3b82786697e1d773748057c96789ea470e8a7d8022c851f1
7
- data.tar.gz: 1945c8a72ce0cc6fb6c4cdda8a8f8baabad6f020175d25f8109fb240f58c3cf175cd1b846c9fc7830c6bba31356f83975e69eac8736b3cf7aa0fbf7c88d8d7fb
6
+ metadata.gz: 392ea65a15b94665c5255da837abcaf3a8b69d38db9b675652c5c824627b3436b4b802174283bcdda6d2f95150cb3fce0a21de2dfcb449c64a0a73259d16357b
7
+ data.tar.gz: f55ffa3998170ee1a3d98f55cdefa9cd27d2f84e39f3c2fcbe3ffb649bcb34eeb96e93e1a486f4edfa030244e4640e3777865eef6f6119380dec7ff273637041
@@ -1,14 +1,50 @@
1
1
  ---
2
2
 
3
3
  AllCops:
4
- TargetRubyVersion: 2.3
4
+ TargetRubyVersion: 2.4
5
5
 
6
6
  Metrics/ClassLength:
7
7
  Max: 400
8
8
 
9
+ Style/IfUnlessModifier:
10
+ Enabled: false # because it wants to make lines >80 chars
9
11
  Style/HashEachMethods:
10
12
  Enabled: true
11
13
  Style/HashTransformKeys:
12
14
  Enabled: true
13
15
  Style/HashTransformValues:
14
16
  Enabled: true
17
+
18
+ # New compatabilities
19
+ Layout/EmptyLinesAroundAttributeAccessor:
20
+ Enabled: true
21
+ Layout/SpaceAroundMethodCallOperator:
22
+ Enabled: true
23
+ Lint/RaiseException:
24
+ Enabled: true
25
+ Lint/StructNewOverride:
26
+ Enabled: true
27
+ Style/ExponentialNotation:
28
+ Enabled: true
29
+ Style/SlicingWithRange:
30
+ Enabled: true
31
+ Lint/DeprecatedOpenSSLConstant:
32
+ Enabled: true
33
+ Lint/MixedRegexpCaptureTypes:
34
+ Enabled: true
35
+ Style/RedundantRegexpCharacterClass:
36
+ Enabled: true
37
+ Style/RedundantRegexpEscape:
38
+ Enabled: true
39
+ Style/AccessorGrouping:
40
+ Enabled: true
41
+ Style/BisectedAttrAccessor:
42
+ Enabled: true
43
+ Style/RedundantAssignment:
44
+ Enabled: true
45
+ Style/RedundantFetchBlock:
46
+ Enabled: true
47
+
48
+ # Is nothing sacred?
49
+ Layout/LineLength:
50
+ Max: 80
data/HISTORY.md CHANGED
@@ -1,7 +1,39 @@
1
1
  # Changelog
2
2
 
3
- ## 5.2.1 (2020-02-20)
4
- * Say whether `--upsert` did and update or an import.
3
+ ## 7.2.0 (2020-08-12)
4
+ * Add `cloudintegration awsid generate` command.
5
+ * Add `cloudintegration awsid delete <external_id>` command.
6
+ * Add `cloudintegration awsid validate <external_id>` command.
7
+ * Require 5.1.x of [the SDK](https://github.com/snltd/wavefront-sdk).
8
+
9
+ ## 7.1.0 (2020-08-07)
10
+ * Remove `user` command. (Breaking change.)
11
+ * Add `account` command.
12
+ * Complete coverage of roles and user groups.
13
+ * Add `alert affected hosts` command to show which hosts are affected by one
14
+ or all firing alerts.
15
+ * Remove obsolete `group` subcommands. (`grant` and `revoke`).
16
+ * Add `write noise` command to send a flow of random data to an endpoint.
17
+ * Better information when working with cloud integrations.
18
+
19
+ ## 7.0.0 (unreleased)
20
+
21
+ ## 6.1.0 (2020-06-02)
22
+ * Add `-A` flag to `proxy list` command, to only list active proxies
23
+
24
+ ## 6.0.0 (2020-04-07)
25
+ * Remove `cluster` command. (Breaking change.)
26
+ * Add `role` command.
27
+ * Add `--nocache`, `--nostrict` and `--histogram-view` options to `query`
28
+ command.
29
+ * Require 5.x of [the SDK](https://github.com/snltd/wavefront-sdk).
30
+
31
+ ## 5.1.2 (2020-02-28)
32
+ * Fix regression in HCL dashboard export.
33
+ * Properly handle unavailable port when sending distributions to a proxy.
34
+
35
+ ## 5.1.1 (2020-02-20)
36
+ * Say whether `--upsert` did an update or an import.
5
37
 
6
38
  ## 5.1.0 (2020-02-20)
7
39
  * Add `-U` (`--upsert`) option to `import` sub-commands.
data/README.md CHANGED
@@ -33,7 +33,6 @@ Commands:
33
33
  alert view and manage alerts
34
34
  apitoken view and your own API tokens
35
35
  cloudintegration view and manage cloud integrations
36
- cluster view and manage monitored clusters
37
36
  config create and manage local configuration
38
37
  dashboard view and manage dashboards
39
38
  derivedmetric view and manage derived metrics
@@ -52,7 +51,6 @@ Commands:
52
51
  source view and manage source tags and descriptions
53
52
  spy monitor traffic going into Wavefront
54
53
  usage view and manage usage reports
55
- user view and manage Wavefront users
56
54
  usergroup view and manage Wavefront user groups
57
55
  webhook view and manage webhooks
58
56
  window view and manage maintenance windows
@@ -104,7 +102,7 @@ $ wf proxy list
104
102
 
105
103
  You can get more verbose listings with the `-l` flag. Results may be
106
104
  paginated. You can progress through pages with the `-L` and `-o`
107
- options, or user `--all` to get everything in one go.
105
+ options, or use `--all` to get everything in one go.
108
106
 
109
107
  ### Describing Things
110
108
 
@@ -152,7 +150,7 @@ mentioned above, human-readable listings and desctiptions may omit
152
150
  data which is not likely to be useful, or which is extremely hard to
153
151
  present in a readable way.
154
152
 
155
- If you `describe` an object like a dashboard, user, webhook etc as
153
+ If you `describe` an object like a dashboard, account, webhook etc as
156
154
  `json` or `yaml`, and send the output to a file, you can re-import
157
155
  that data. The format of the file to be imported is automatically
158
156
  detected.
@@ -0,0 +1,119 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative 'base'
4
+
5
+ module WavefrontCli
6
+ #
7
+ # CLI coverage for the v2 'account' API.
8
+ #
9
+ class Account < WavefrontCli::Base
10
+ alias do_roles do_describe
11
+ alias do_groups do_describe
12
+ alias do_ingestionpolicy do_describe
13
+ alias do_permissions do_describe
14
+
15
+ def do_role_add_to
16
+ wf_account_id?(options[:'<id>'])
17
+ wf.add_roles(options[:'<id>'], options[:'<role>'])
18
+ end
19
+
20
+ def do_role_remove_from
21
+ wf_account_id?(options[:'<id>'])
22
+ wf.remove_roles(options[:'<id>'], options[:'<role>'])
23
+ end
24
+
25
+ def do_group_add_to
26
+ wf_account_id?(options[:'<id>'])
27
+ wf.add_user_groups(options[:'<id>'], options[:'<group>'])
28
+ end
29
+
30
+ def do_group_remove_from
31
+ wf_account_id?(options[:'<id>'])
32
+ wf.remove_user_groups(options[:'<id>'], options[:'<group>'])
33
+ end
34
+
35
+ def do_business_functions
36
+ wf_user_id?(options[:'<id>'])
37
+ wf.business_functions(options[:'<id>'])
38
+ end
39
+
40
+ def do_grant_to
41
+ wf.grant(options[:'<account>'], options[:'<permission>'])
42
+ end
43
+
44
+ def do_revoke_from
45
+ wf.revoke(options[:'<account>'], options[:'<permission>'])
46
+ end
47
+
48
+ def do_ingestionpolicy_add_to
49
+ wf_account_id?(options[:'<id>'])
50
+ wf.add_ingestion_policy(options[:'<policy>'], [options[:'<id>']])
51
+ end
52
+
53
+ def do_ingestionpolicy_remove_from
54
+ wf_account_id?(options[:'<id>'])
55
+ wf_ingestionpolicy_id?(options[:'<policy>'])
56
+ wf.remove_ingestion_policy(options[:'<policy>'], [options[:'<id>']])
57
+ end
58
+
59
+ def do_create_user
60
+ wf_user_id?(options[:'<id>'])
61
+ wf.user_create(user_body)
62
+ end
63
+
64
+ def do_invite_user
65
+ wf_user_id?(options[:'<id>'])
66
+ wf.user_invite([user_body])
67
+ end
68
+
69
+ def do_validate
70
+ wf.validate_accounts(options[:'<account>'])
71
+ end
72
+
73
+ def extra_validation
74
+ validate_policy
75
+ validate_permission
76
+ validate_roles
77
+ validate_groups
78
+ validate_accounts
79
+ end
80
+
81
+ private
82
+
83
+ def validate_policy
84
+ wf_ingestionpolicy_id?(options[:'<policy>']) if options[:'<policy>']
85
+ end
86
+
87
+ def validate_permission
88
+ wf_permission?(options[:'<permission>']) if options[:'<permission>']
89
+ end
90
+
91
+ def validate_roles
92
+ options[:'<role>'].each { |r| wf_role_id?(r) }
93
+ end
94
+
95
+ def validate_groups
96
+ options[:'<group>'].each { |g| wf_usergroup_id?(g) }
97
+ end
98
+
99
+ def validate_accounts
100
+ options[:'<account>'].each { |a| wf_account_id?(a) }
101
+ end
102
+
103
+ # Object used to create and invite users. We deal with the permissions
104
+ # seperately because if we don't supply any and they get compacted out,
105
+ # the user is created with a default set of perms, and we don't want that.
106
+ #
107
+ def user_body
108
+ raw = {
109
+ emailAddress: options[:'<id>'],
110
+ roles: options[:roleid],
111
+ ingestionPolicyId: options[:policyid],
112
+ userGroups: options[:groupid]
113
+ }.reject { |_k, v| v&.empty? }.compact
114
+
115
+ raw[:groups] = options[:permission]
116
+ raw
117
+ end
118
+ end
119
+ end
@@ -50,6 +50,14 @@ module WavefrontCli
50
50
  wf.history(options[:'<id>'], options[:offset], options[:limit])
51
51
  end
52
52
 
53
+ def do_affected_hosts
54
+ if options[:'<id>']
55
+ affected_hosts_for_id(options[:'<id>'])
56
+ else
57
+ all_affected_hosts
58
+ end
59
+ end
60
+
53
61
  def do_currently
54
62
  state = options[:'<state>'].to_s
55
63
 
@@ -146,5 +154,26 @@ module WavefrontCli
146
154
  end
147
155
  end.compact
148
156
  end
157
+
158
+ def all_affected_hosts
159
+ cannot_noop!
160
+ in_state(:firing).tap do |r|
161
+ r.response = r.response.items.each_with_object({}) do |alert, aggr|
162
+ aggr[alert[:id]] = affected_hosts_for_id(alert[:id]).response
163
+ end
164
+ end
165
+ end
166
+
167
+ def affected_hosts_for_id(id)
168
+ resp = wf.describe(id)
169
+
170
+ return if options[:noop]
171
+
172
+ return resp unless resp.ok? && resp.response.key?(:failingHostLabelPairs)
173
+
174
+ resp.tap do |r|
175
+ r.response = r.response[:failingHostLabelPairs].map { |h| h[:host] }
176
+ end
177
+ end
149
178
  end
150
179
  end
@@ -485,7 +485,6 @@ module WavefrontCli
485
485
  # @param cond [String] a search condition, like "key=value"
486
486
  # @return [Hash] of matchingMethod and negated
487
487
  #
488
- # rubocop:disable Metrics/CyclomaticComplexity
489
488
  # rubocop:disable Metrics/MethodLength
490
489
  def matching_method(cond)
491
490
  case cond
@@ -506,7 +505,6 @@ module WavefrontCli
506
505
  end
507
506
  end
508
507
  # rubocop:enable Metrics/MethodLength
509
- # rubocop:enable Metrics/CyclomaticComplexity
510
508
 
511
509
  # Return a detailed description of one item, if an ID has been
512
510
  # given, or all items if it has not.
@@ -22,5 +22,17 @@ module WavefrontCli
22
22
  def do_disable
23
23
  wf.disable(options[:'<id>'])
24
24
  end
25
+
26
+ def do_awsid_generate
27
+ wf.create_aws_external_id
28
+ end
29
+
30
+ def do_awsid_delete
31
+ wf.delete_aws_external_id(options[:'<external_id>'])
32
+ end
33
+
34
+ def do_awsid_confirm
35
+ wf.confirm_aws_external_id(options[:'<external_id>'])
36
+ end
25
37
  end
26
38
  end
@@ -11,3 +11,37 @@ Style/HashTransformKeys:
11
11
  Enabled: true
12
12
  Style/HashTransformValues:
13
13
  Enabled: true
14
+
15
+ # new compatabilities
16
+ Layout/EmptyLinesAroundAttributeAccessor:
17
+ Enabled: true
18
+ Layout/SpaceAroundMethodCallOperator:
19
+ Enabled: true
20
+ Lint/RaiseException:
21
+ Enabled: true
22
+ Lint/StructNewOverride:
23
+ Enabled: true
24
+ Style/ExponentialNotation:
25
+ Enabled: true
26
+ Style/SlicingWithRange:
27
+ Enabled: true
28
+ Lint/DeprecatedOpenSSLConstant:
29
+ Enabled: true
30
+ Lint/MixedRegexpCaptureTypes:
31
+ Enabled: true
32
+ Style/RedundantRegexpCharacterClass:
33
+ Enabled: true
34
+ Style/RedundantRegexpEscape:
35
+ Enabled: true
36
+ Style/AccessorGrouping:
37
+ Enabled: true
38
+ Style/BisectedAttrAccessor:
39
+ Enabled: true
40
+ Style/RedundantAssignment:
41
+ Enabled: true
42
+ Style/RedundantFetchBlock:
43
+ Enabled: true
44
+
45
+ # Is nothing sacred?
46
+ Layout/LineLength:
47
+ Max: 80
@@ -0,0 +1,61 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative 'base'
4
+
5
+ # Define the account command.
6
+ #
7
+ class WavefrontCommandAccount < WavefrontCommandBase
8
+ def description
9
+ "view and manage Wavefront #{things}"
10
+ end
11
+
12
+ def _commands
13
+ ["list #{CMN} [-sSal] [-O fields] [-o offset] [-L limit]",
14
+ "describe #{CMN} <id>",
15
+ "create user #{CMN} [-m permission...] [-g group-id...] " \
16
+ '[-r role-id...] [-i policy-id] <id>',
17
+ "invite user #{CMN} [-m permission...] [-g group-id...] " \
18
+ '[-r role-id...] [-i policy-id] <id>',
19
+ "delete #{CMN} <id>",
20
+ "dump #{CMN}",
21
+ "import #{CMN} [-uU] <file>",
22
+ "role #{CMN} add to <id> <role>...",
23
+ "role #{CMN} remove from <id> <role>...",
24
+ "roles #{CMN} <id>",
25
+ "ingestionpolicy #{CMN} add to <id> <policy>",
26
+ "ingestionpolicy #{CMN} remove from <id> <policy>",
27
+ "ingestionpolicy #{CMN} <id>",
28
+ "group #{CMN} add to <id> <group>...",
29
+ "group #{CMN} remove from <id> <group>...",
30
+ "groups #{CMN} <id>",
31
+ "grant #{CMN} <permission> to <account>...",
32
+ "revoke #{CMN} <permission> from <account>...",
33
+ "permissions #{CMN} <id>",
34
+ "business functions #{CMN} <id>",
35
+ "validate #{CMN} [-l] <account>...",
36
+ "search #{CMN} [-al] [-o offset] [-L limit] [-O fields] <condition>..."]
37
+ end
38
+
39
+ def _options
40
+ [common_options,
41
+ "-l, --long list #{things} in detail",
42
+ "-a, --all list all #{things}",
43
+ "-o, --offset=n start from nth #{thing}",
44
+ "-L, --limit=COUNT number of #{things} to list",
45
+ '-s, --service list only service accounts',
46
+ '-S, --user list only user accounts',
47
+ '-O, --fields=F1,F2,... only show given fields',
48
+ "-u, --update update an existing #{thing}",
49
+ "-U, --upsert import new or update existing #{thing}",
50
+ '-m, --permission=STRING Wavefront permission name',
51
+ '-g, --groupid=STRING Wavefront usergroup ID',
52
+ '-r, --roleid=STRING Wavefront role ID',
53
+ '-i, --policyid=STRING Wavefront ingestion policy ID']
54
+ end
55
+
56
+ def postscript
57
+ 'Service accounts can be partially managed with this command, but ' \
58
+ "'wf serviceaccount' has more features.\n\nFor a list of permissions, " \
59
+ "run 'wf settings list permissions'.".fold(TW, 0)
60
+ end
61
+ end
@@ -8,6 +8,7 @@ class WavefrontCommandAlert < WavefrontCommandBase
8
8
  def _commands
9
9
  ["list #{CMN} [-al] [-O fields] [-o offset] [-L limit]",
10
10
  "firing #{CMN} [-o offset] [-L limit]",
11
+ "affected #{CMN} hosts [<id>]",
11
12
  "snoozed #{CMN} [-o offset] [-L limit]",
12
13
  "describe #{CMN} [-v version] <id>",
13
14
  "delete #{CMN} <id>",
@@ -165,6 +165,6 @@ class WavefrontCommandBase
165
165
  # @return [String] a full options string which docopt understands
166
166
  #
167
167
  def docopt
168
- commands + "\n\n" + options + "\n" + postscript
168
+ commands + "\n\n" + options + "\n\n" + postscript
169
169
  end
170
170
  end