wavefront-cli 4.5.2 → 4.6.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/HISTORY.md +4 -0
- data/README.md +2 -0
- data/lib/wavefront-cli/base.rb +5 -1
- data/lib/wavefront-cli/commands/ingestionpolicy.rb +45 -0
- data/lib/wavefront-cli/commands/serviceaccount.rb +1 -0
- data/lib/wavefront-cli/commands/usage.rb +22 -0
- data/lib/wavefront-cli/commands/user.rb +1 -0
- data/lib/wavefront-cli/commands/window.rb +2 -2
- data/lib/wavefront-cli/controller.rb +1 -2
- data/lib/wavefront-cli/display/base.rb +1 -1
- data/lib/wavefront-cli/display/ingestionpolicy.rb +28 -0
- data/lib/wavefront-cli/display/serviceaccount.rb +5 -0
- data/lib/wavefront-cli/display/usage.rb +14 -0
- data/lib/wavefront-cli/display/user.rb +11 -0
- data/lib/wavefront-cli/externallink.rb +4 -0
- data/lib/wavefront-cli/ingestionpolicy.rb +67 -0
- data/lib/wavefront-cli/maintenancewindow.rb +4 -0
- data/lib/wavefront-cli/savedsearch.rb +4 -0
- data/lib/wavefront-cli/serviceaccount.rb +13 -0
- data/lib/wavefront-cli/usage.rb +24 -0
- data/lib/wavefront-cli/user.rb +4 -0
- data/lib/wavefront-cli/version.rb +1 -1
- data/spec/.rubocop.yml +1 -1
- data/spec/support/minitest_assertions.rb +1 -1
- data/spec/wavefront-cli/resources/responses/usage-export-csv.json +1 -0
- data/spec/wavefront-cli/resources/responses/user-validate.json +1 -0
- data/spec/wavefront-cli/usage_spec.rb +70 -0
- data/spec/wavefront-cli/user_spec.rb +16 -0
- data/wavefront-cli.gemspec +1 -1
- metadata +16 -10
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f6778585fb11ae1989c46feaf4e3ba7300e486f3893358216a33d3b331f0428a
|
4
|
+
data.tar.gz: 368623dfc6837757c38817bab28edb98aa869932905a7968feb6728f5ab4df19
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8bd581d185626b015fbb6fb4a3649d4e51b798335e9c7e3e715663b5cda6a23a46f61906b14e9cbc4c5769ee4ae524283e2b509f8613d059bc7702909456e7ef
|
7
|
+
data.tar.gz: b91f871b2caa0658337a01d54644fc2db7d597a37229328bed821e03e8793cbf681fa0ebca8ccf356d9ce2894ef36091f181788f7f6811dba781f19a0ad4f9ec
|
data/HISTORY.md
CHANGED
@@ -1,5 +1,9 @@
|
|
1
1
|
# Changelog
|
2
2
|
|
3
|
+
## 4.6.0
|
4
|
+
* Add `ingestionpolicy` and `usage` commands.
|
5
|
+
* Require 3.7.x of [the SDK](https://github.com/snltd/wavefront-sdk).
|
6
|
+
|
3
7
|
## 4.5.2 (2020-01-15)
|
4
8
|
* Test build against, and fix warning messages on, Ruby 2.7.0
|
5
9
|
* Bump SDK dependency to 3.6.1
|
data/README.md
CHANGED
@@ -37,6 +37,7 @@ Commands:
|
|
37
37
|
dashboard view and manage dashboards
|
38
38
|
derivedmetric view and manage derived metrics
|
39
39
|
event open, close, view, and manage events
|
40
|
+
ingestionpolicy view and manage ingestion policies
|
40
41
|
integration view and manage Wavefront integrations
|
41
42
|
link view and manage external links
|
42
43
|
message read and mark user messages
|
@@ -48,6 +49,7 @@ Commands:
|
|
48
49
|
serviceaccount view and manage service accounts
|
49
50
|
settings view and manage system preferences
|
50
51
|
source view and manage source tags and descriptions
|
52
|
+
usage view and manage usage reports
|
51
53
|
user view and manage Wavefront users
|
52
54
|
usergroup view and manage Wavefront user groups
|
53
55
|
webhook view and manage webhooks
|
data/lib/wavefront-cli/base.rb
CHANGED
@@ -116,7 +116,11 @@ module WavefrontCli
|
|
116
116
|
def failed_validation_message(input)
|
117
117
|
format("'%<value>s' is not a valid %<thing>s ID.",
|
118
118
|
value: input,
|
119
|
-
thing:
|
119
|
+
thing: descriptive_name)
|
120
|
+
end
|
121
|
+
|
122
|
+
def descriptive_name
|
123
|
+
klass_word
|
120
124
|
end
|
121
125
|
|
122
126
|
# Make a wavefront-sdk credentials object from standard
|
@@ -0,0 +1,45 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative 'base'
|
4
|
+
|
5
|
+
# Define the ingestionpolicy command.
|
6
|
+
#
|
7
|
+
class WavefrontCommandIngestionpolicy < WavefrontCommandBase
|
8
|
+
def thing
|
9
|
+
'ingestion policy'
|
10
|
+
end
|
11
|
+
|
12
|
+
def things
|
13
|
+
'ingestion policies'
|
14
|
+
end
|
15
|
+
|
16
|
+
def sdk_class
|
17
|
+
'IngestionPolicy'
|
18
|
+
end
|
19
|
+
|
20
|
+
def _commands
|
21
|
+
["list #{CMN} [-al] [-O fields] [-o offset] [-L limit]",
|
22
|
+
"create #{CMN} [-d description] <name>",
|
23
|
+
"describe #{CMN} <id>",
|
24
|
+
"delete #{CMN} <id>",
|
25
|
+
"dump #{CMN}",
|
26
|
+
"import #{CMN} [-u] <file>",
|
27
|
+
"set #{CMN} <key=value> <id>",
|
28
|
+
"add user #{CMN} <id> <user>...",
|
29
|
+
"remove user #{CMN} <id> <user>...",
|
30
|
+
"members #{CMN} <id>",
|
31
|
+
"for #{CMN} <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 list from nth #{thing}",
|
40
|
+
'-O, --fields=F1,F2,... only show given fields',
|
41
|
+
"-L, --limit=COUNT number of #{things} to list",
|
42
|
+
"-d, --desc=STRING reason for #{thing}",
|
43
|
+
"-u, --update update an existing #{thing}"]
|
44
|
+
end
|
45
|
+
end
|
@@ -23,6 +23,7 @@ class WavefrontCommandServiceaccount < WavefrontCommandBase
|
|
23
23
|
"create #{CMN} [-I] [-d description] [-p permission...] [-g group...] " \
|
24
24
|
'[-k usertoken...] <id>',
|
25
25
|
"activate #{CMN} <id>",
|
26
|
+
"delete #{CMN} <account>...",
|
26
27
|
"deactivate #{CMN} <id>",
|
27
28
|
"dump #{CMN}",
|
28
29
|
"groups #{CMN} <id>",
|
@@ -0,0 +1,22 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative 'base'
|
4
|
+
|
5
|
+
# Define the usage command.
|
6
|
+
#
|
7
|
+
class WavefrontCommandUsage < WavefrontCommandBase
|
8
|
+
def thing
|
9
|
+
'usage report'
|
10
|
+
end
|
11
|
+
|
12
|
+
def _commands
|
13
|
+
["export csv #{CMN} [-s time] [-e time] "]
|
14
|
+
end
|
15
|
+
|
16
|
+
def _options
|
17
|
+
[common_options,
|
18
|
+
"-s, --start=TIME time at which #{thing} begins " \
|
19
|
+
'(defaults to 24h ago)',
|
20
|
+
"-e, --end=TIME time at which #{thing} ends"]
|
21
|
+
end
|
22
|
+
end
|
@@ -28,6 +28,7 @@ class WavefrontCommandUser < WavefrontCommandBase
|
|
28
28
|
"grant #{CMN} <privilege> to <id>",
|
29
29
|
"revoke #{CMN} <privilege> from <id>",
|
30
30
|
"business functions #{CMN} <id>",
|
31
|
+
"validate #{CMN} [-l] <user>...",
|
31
32
|
"search #{CMN} [-al] [-o offset] [-L limit] [-O fields] <condition>..."]
|
32
33
|
end
|
33
34
|
|
@@ -20,8 +20,8 @@ class WavefrontCommandWindow < WavefrontCommandBase
|
|
20
20
|
def _commands
|
21
21
|
["list #{CMN} [-al] [-O fields] [-o offset] [-L limit]",
|
22
22
|
"describe #{CMN} <id>",
|
23
|
-
"create #{CMN}
|
24
|
-
'[-A alert_tag...] [-T host_tag...] [-H host...] <title>',
|
23
|
+
"create #{CMN} [-s time] [-e time] " \
|
24
|
+
'[-A alert_tag...] [-T host_tag...] [-H host...] -d reason <title>',
|
25
25
|
"close #{CMN} <id>",
|
26
26
|
"extend #{CMN} (by|to) <time> <id>",
|
27
27
|
"delete #{CMN} <id>",
|
@@ -0,0 +1,28 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative 'base'
|
4
|
+
|
5
|
+
module WavefrontDisplay
|
6
|
+
#
|
7
|
+
# Format human-readable output of ingestion policies.
|
8
|
+
#
|
9
|
+
class IngestionPolicy < Base
|
10
|
+
def do_add_user
|
11
|
+
puts format("Added %<quoted_user>s to '%<group_id>s'.",
|
12
|
+
quoted_user: quoted(options[:'<user>']),
|
13
|
+
group_id: options[:'<id>']).fold(TW, 0)
|
14
|
+
end
|
15
|
+
|
16
|
+
def do_remove_user
|
17
|
+
puts format("Removed %<quoted_user>s from '%<group_id>s'.",
|
18
|
+
quoted_user: quoted(options[:'<user>']),
|
19
|
+
group_id: options[:'<id>']).fold(TW, 0)
|
20
|
+
end
|
21
|
+
|
22
|
+
def do_for
|
23
|
+
puts data
|
24
|
+
end
|
25
|
+
|
26
|
+
alias do_members do_for
|
27
|
+
end
|
28
|
+
end
|
@@ -68,6 +68,11 @@ module WavefrontDisplay
|
|
68
68
|
puts format("Deleted API token '#{options[:'<token_id>']}'.")
|
69
69
|
end
|
70
70
|
|
71
|
+
def do_delete
|
72
|
+
puts format("Deleted #{friendly_name} %<quoted_account>s.",
|
73
|
+
quoted_account: quoted(options[:'<account>']))
|
74
|
+
end
|
75
|
+
|
71
76
|
def search_identifier_key
|
72
77
|
:identifier
|
73
78
|
end
|
@@ -88,5 +88,16 @@ module WavefrontDisplay
|
|
88
88
|
def do_business_functions
|
89
89
|
puts data.sort
|
90
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
|
91
102
|
end
|
92
103
|
end
|
@@ -0,0 +1,67 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'wavefront-sdk/support/mixins'
|
4
|
+
require_relative 'base'
|
5
|
+
|
6
|
+
module WavefrontCli
|
7
|
+
#
|
8
|
+
# CLI coverage for the ingestion policy part of the v2 'usage' API.
|
9
|
+
#
|
10
|
+
class IngestionPolicy < WavefrontCli::Base
|
11
|
+
include Wavefront::Mixins
|
12
|
+
|
13
|
+
def do_create
|
14
|
+
wf.create(create_body)
|
15
|
+
end
|
16
|
+
|
17
|
+
def do_add_user
|
18
|
+
account_hook.add_ingestion_policy(options[:'<id>'], options[:'<user>'])
|
19
|
+
end
|
20
|
+
|
21
|
+
def do_remove_user
|
22
|
+
account_hook.remove_ingestion_policy(options[:'<id>'],
|
23
|
+
options[:'<user>'])
|
24
|
+
end
|
25
|
+
|
26
|
+
def do_members
|
27
|
+
resp = do_describe
|
28
|
+
resp.response = resp.response[:sampledUserAccounts] +
|
29
|
+
resp.response[:sampledServiceAccounts]
|
30
|
+
resp
|
31
|
+
end
|
32
|
+
|
33
|
+
def do_for
|
34
|
+
resp = do_list
|
35
|
+
parent_policies = parent_policies(options[:'<user>'][0],
|
36
|
+
resp.response.items)
|
37
|
+
resp.response = parent_policies.map { |p| p[:id] }
|
38
|
+
resp
|
39
|
+
end
|
40
|
+
|
41
|
+
private
|
42
|
+
|
43
|
+
def parent_policies(user, items)
|
44
|
+
items.select do |p|
|
45
|
+
p[:sampledUserAccounts].include?(user) ||
|
46
|
+
p[:sampledServiceAccounts].include?(user)
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
def create_body
|
51
|
+
{ name: options[:'<name>'], description: options[:desc] }.compact
|
52
|
+
end
|
53
|
+
|
54
|
+
def account_hook
|
55
|
+
require 'wavefront-sdk/account'
|
56
|
+
Wavefront::Account.new(mk_creds, mk_opts)
|
57
|
+
end
|
58
|
+
|
59
|
+
def descriptive_name
|
60
|
+
'ingestion policy'
|
61
|
+
end
|
62
|
+
|
63
|
+
def validator_exception
|
64
|
+
Wavefront::Exception::InvalidIngestionPolicyId
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
@@ -46,6 +46,10 @@ module WavefrontCli
|
|
46
46
|
wf.update(options[:'<id>'], body)
|
47
47
|
end
|
48
48
|
|
49
|
+
def do_delete
|
50
|
+
account_hook.delete_accounts(options[:'<account>'])
|
51
|
+
end
|
52
|
+
|
49
53
|
def do_leave
|
50
54
|
cannot_noop!
|
51
55
|
options[:'<group>'].each { |g| wf_usergroup_id?(g) }
|
@@ -184,5 +188,14 @@ module WavefrontCli
|
|
184
188
|
rescue Wavefront::Exception::InvalidPermission => e
|
185
189
|
raise e, 'Invalid permission'
|
186
190
|
end
|
191
|
+
|
192
|
+
def descriptive_name
|
193
|
+
'service account'
|
194
|
+
end
|
195
|
+
|
196
|
+
def account_hook
|
197
|
+
require 'wavefront-sdk/account'
|
198
|
+
Wavefront::Account.new(mk_creds, mk_opts)
|
199
|
+
end
|
187
200
|
end
|
188
201
|
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'wavefront-sdk/support/mixins'
|
4
|
+
require_relative 'base'
|
5
|
+
|
6
|
+
module WavefrontCli
|
7
|
+
#
|
8
|
+
# CLI coverage for part of the v2 'usage' API. The rest is in the
|
9
|
+
# 'ingestionpolicy' command.
|
10
|
+
#
|
11
|
+
class Usage < WavefrontCli::Base
|
12
|
+
include Wavefront::Mixins
|
13
|
+
|
14
|
+
def do_export_csv
|
15
|
+
t_start = options[:start] ? parse_time(options[:start]) : default_start
|
16
|
+
t_end = options[:end] ? parse_time(options[:end]) : nil
|
17
|
+
wf.export_csv(t_start, t_end)
|
18
|
+
end
|
19
|
+
|
20
|
+
def default_start
|
21
|
+
parse_time(Time.now - 60 * 60 * 24)
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
data/lib/wavefront-cli/user.rb
CHANGED
@@ -49,6 +49,10 @@ module WavefrontCli
|
|
49
49
|
wf.business_functions(options[:'<id>'])
|
50
50
|
end
|
51
51
|
|
52
|
+
def do_validate
|
53
|
+
wf.validate_users(options[:'<user>'])
|
54
|
+
end
|
55
|
+
|
52
56
|
def import_to_create(raw)
|
53
57
|
{ emailAddress: raw['items']['identifier'],
|
54
58
|
groups: raw['items']['groups'] }.tap do |r|
|
data/spec/.rubocop.yml
CHANGED
@@ -0,0 +1 @@
|
|
1
|
+
{"message":"Usage reporting\nTime selected:\n01/19/2020 15:31:38 +0000,01/20/2020 15:31:39 +0000\n\nUsage by Ingestion Policy\nIngestion Policy ID,Ingestion Policy Name,Ingestion Policy Description\n\nDetailed information\nIngestion Policy ID,Ingestion Policy Name,Account ID,Ingestion Type,Ingestion Source,Timestamp,pps\nUnassociated,Unassociated,services@id264.net,TimeSeries,Proxy,1579446000,82.11666666666666\nUnassociated,Unassociated,services@id264.net,TimeSeries,Proxy,1579449600,72.45\nUnassociated,Unassociated,services@id264.net,TimeSeries,Proxy,1579453200,64.0\nUnassociated,Unassociated,services@id264.net,TimeSeries,Proxy,1579456800,54.67213114754098\nUnassociated,Unassociated,services@id264.net,TimeSeries,Proxy,1579460400,73.13333333333334\nUnassociated,Unassociated,services@id264.net,TimeSeries,Proxy,1579464000,50.90163934426229\nUnassociated,Unassociated,services@id264.net,TimeSeries,Proxy,1579467600,49.42622950819672\nUnassociated,Unassociated,services@id264.net,TimeSeries,Proxy,1579471200,73.1\nUnassociated,Unassociated,services@id264.net,TimeSeries,Proxy,1579474800,44.57377049180328\nUnassociated,Unassociated,services@id264.net,TimeSeries,Proxy,1579478400,64.40983606557377\nUnassociated,Unassociated,services@id264.net,TimeSeries,Proxy,1579482000,66.9\nUnassociated,Unassociated,services@id264.net,TimeSeries,Proxy,1579485600,62.032786885245905\nUnassociated,Unassociated,services@id264.net,TimeSeries,Proxy,1579489200,64.44262295081967\nUnassociated,Unassociated,services@id264.net,TimeSeries,Proxy,1579492800,57.0\nUnassociated,Unassociated,services@id264.net,TimeSeries,Proxy,1579496400,61.78333333333333\nUnassociated,Unassociated,services@id264.net,TimeSeries,Proxy,1579500000,63.21311475409836\nUnassociated,Unassociated,services@id264.net,TimeSeries,Proxy,1579503600,59.03333333333333\nUnassociated,Unassociated,services@id264.net,TimeSeries,Proxy,1579507200,63.68333333333333\nUnassociated,Unassociated,services@id264.net,TimeSeries,Proxy,1579510800,73.98333333333333\nUnassociated,Unassociated,services@id264.net,TimeSeries,Proxy,1579514400,83.18333333333334\nUnassociated,Unassociated,services@id264.net,TimeSeries,Proxy,1579518000,80.73015873015873\nUnassociated,Unassociated,services@id264.net,TimeSeries,Proxy,1579521600,62.18333333333333\nUnassociated,Unassociated,services@id264.net,TimeSeries,Proxy,1579525200,54.049180327868854\nUnassociated,Unassociated,services@id264.net,TimeSeries,Proxy,1579528800,97.16666666666667\nUnassociated,Unassociated,services@id264.net,TimeSeries,Proxy,1579532400,95.36666666666666\n","code":200}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"validUsers":[{"identifier":"rob@sysdef.xyz","customer":"sysdef","lastSuccessfulLogin":1579615042006,"groups":["derived_metrics_management","ingestion","events_management","embedded_charts","alerts_management","dashboard_management","application_management","user_management","agent_management","external_links_management","metrics_management","host_tag_management"],"userGroups":[{"id":"a7d2e651-cec1-4154-a5e8-1946f57ef5b3","name":"Everyone","permissions":[],"customer":"sysdef","properties":{"nameEditable":false,"permissionsEditable":true,"usersEditable":false},"description":"System group which contains all users"}],"ingestionPolicy":{"name":"example-policy","id":"example-policy-1579802191862","customer":"sysdef","description":"example ingestion policy","lastUpdatedMs":1579802191878,"lastUpdatedAccountId":"rob@sysdef.xyz"}},{"identifier":"services@id264.net","customer":"sysdef","lastSuccessfulLogin":1535978592119,"groups":["agent_management","ingestion"],"userGroups":[{"id":"a7d2e651-cec1-4154-a5e8-1946f57ef5b3","name":"Everyone","permissions":[],"customer":"sysdef","properties":{"nameEditable":false,"permissionsEditable":true,"usersEditable":false},"description":"System group which contains all users"}],"ingestionPolicy":{"name":"example-policy","id":"example-policy-1579802191862","customer":"sysdef","description":"example ingestion policy","lastUpdatedMs":1579802191878,"lastUpdatedAccountId":"rob@sysdef.xyz"}}],"invalidIdentifiers":["rob@id264.net","no-such-thing"]}
|
@@ -0,0 +1,70 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
require_relative '../support/command_base'
|
5
|
+
require_relative '../../lib/wavefront-cli/usage'
|
6
|
+
|
7
|
+
# Ensure 'usage' commands produce the correct API calls.
|
8
|
+
#
|
9
|
+
class UsageEndToEndTest < EndToEndTest
|
10
|
+
def test_export_csv_start_time
|
11
|
+
quietly do
|
12
|
+
assert_cmd_gets(
|
13
|
+
"export csv -s #{start_time}",
|
14
|
+
"/api/v2/usage/exportcsv?startTime=#{start_time}",
|
15
|
+
response
|
16
|
+
)
|
17
|
+
end
|
18
|
+
|
19
|
+
assert_abort_on_missing_creds('export csv')
|
20
|
+
assert_usage('export')
|
21
|
+
end
|
22
|
+
|
23
|
+
def test_export_csv_with_range
|
24
|
+
quietly do
|
25
|
+
assert_cmd_gets(
|
26
|
+
"export csv -s #{start_time} -e #{end_time}",
|
27
|
+
"/api/v2/usage/exportcsv?endTime=#{end_time}&startTime=#{start_time}",
|
28
|
+
response
|
29
|
+
)
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
private
|
34
|
+
|
35
|
+
def cmd_word
|
36
|
+
'usage'
|
37
|
+
end
|
38
|
+
|
39
|
+
def api_path
|
40
|
+
'usage'
|
41
|
+
end
|
42
|
+
|
43
|
+
def start_time
|
44
|
+
1_579_500_000
|
45
|
+
end
|
46
|
+
|
47
|
+
def end_time
|
48
|
+
1_579_533_333
|
49
|
+
end
|
50
|
+
|
51
|
+
def response
|
52
|
+
IO.read(RES_DIR + 'responses' + 'usage-export-csv.json')
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
# test class methods
|
57
|
+
#
|
58
|
+
class UsageTest < MiniTest::Test
|
59
|
+
attr_reader :wf
|
60
|
+
|
61
|
+
def setup
|
62
|
+
@wf = WavefrontCli::Usage.new({})
|
63
|
+
end
|
64
|
+
|
65
|
+
def test_default_start
|
66
|
+
calculated = Time.at(wf.default_start).to_date
|
67
|
+
expected = Date.today - 1
|
68
|
+
assert expected - calculated < 5
|
69
|
+
end
|
70
|
+
end
|
@@ -265,6 +265,15 @@ class UserEndToEndTest < EndToEndTest
|
|
265
265
|
assert_usage('business functions')
|
266
266
|
end
|
267
267
|
|
268
|
+
def test_validate
|
269
|
+
quietly do
|
270
|
+
assert_cmd_posts("validate #{user_list.join(' ')}",
|
271
|
+
'/api/v2/user/validateUsers',
|
272
|
+
user_list.to_json,
|
273
|
+
IO.read(RES_DIR + 'responses' + 'user-validate.json'))
|
274
|
+
end
|
275
|
+
end
|
276
|
+
|
268
277
|
private
|
269
278
|
|
270
279
|
def id
|
@@ -292,4 +301,11 @@ class UserEndToEndTest < EndToEndTest
|
|
292
301
|
def privilege
|
293
302
|
'alerts_management'
|
294
303
|
end
|
304
|
+
|
305
|
+
def user_list
|
306
|
+
%w[rob@somewhere.xyz
|
307
|
+
services@elsewhere.net
|
308
|
+
rob@elsewhere.net
|
309
|
+
no-such-thing]
|
310
|
+
end
|
295
311
|
end
|
data/wavefront-cli.gemspec
CHANGED
@@ -26,7 +26,7 @@ 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', '~> 3.
|
29
|
+
gem.add_runtime_dependency 'wavefront-sdk', '~> 3.7'
|
30
30
|
|
31
31
|
gem.add_development_dependency 'minitest', '~> 5.11', '>= 5.11.0'
|
32
32
|
gem.add_development_dependency 'rake', '~> 12.0'
|
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.
|
4
|
+
version: 4.6.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-01-
|
11
|
+
date: 2020-01-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: docopt
|
@@ -44,20 +44,14 @@ dependencies:
|
|
44
44
|
requirements:
|
45
45
|
- - "~>"
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version: '3.
|
48
|
-
- - ">="
|
49
|
-
- !ruby/object:Gem::Version
|
50
|
-
version: 3.6.1
|
47
|
+
version: '3.7'
|
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: '3.
|
58
|
-
- - ">="
|
59
|
-
- !ruby/object:Gem::Version
|
60
|
-
version: 3.6.1
|
54
|
+
version: '3.7'
|
61
55
|
- !ruby/object:Gem::Dependency
|
62
56
|
name: minitest
|
63
57
|
requirement: !ruby/object:Gem::Requirement
|
@@ -180,6 +174,7 @@ files:
|
|
180
174
|
- lib/wavefront-cli/commands/dashboard.rb
|
181
175
|
- lib/wavefront-cli/commands/derivedmetric.rb
|
182
176
|
- lib/wavefront-cli/commands/event.rb
|
177
|
+
- lib/wavefront-cli/commands/ingestionpolicy.rb
|
183
178
|
- lib/wavefront-cli/commands/integration.rb
|
184
179
|
- lib/wavefront-cli/commands/link.rb
|
185
180
|
- lib/wavefront-cli/commands/message.rb
|
@@ -191,6 +186,7 @@ files:
|
|
191
186
|
- lib/wavefront-cli/commands/serviceaccount.rb
|
192
187
|
- lib/wavefront-cli/commands/settings.rb
|
193
188
|
- lib/wavefront-cli/commands/source.rb
|
189
|
+
- lib/wavefront-cli/commands/usage.rb
|
194
190
|
- lib/wavefront-cli/commands/user.rb
|
195
191
|
- lib/wavefront-cli/commands/usergroup.rb
|
196
192
|
- lib/wavefront-cli/commands/webhook.rb
|
@@ -210,6 +206,7 @@ files:
|
|
210
206
|
- lib/wavefront-cli/display/distribution.rb
|
211
207
|
- lib/wavefront-cli/display/event.rb
|
212
208
|
- lib/wavefront-cli/display/externallink.rb
|
209
|
+
- lib/wavefront-cli/display/ingestionpolicy.rb
|
213
210
|
- lib/wavefront-cli/display/integration.rb
|
214
211
|
- lib/wavefront-cli/display/maintenancewindow.rb
|
215
212
|
- lib/wavefront-cli/display/message.rb
|
@@ -224,6 +221,7 @@ files:
|
|
224
221
|
- lib/wavefront-cli/display/serviceaccount.rb
|
225
222
|
- lib/wavefront-cli/display/settings.rb
|
226
223
|
- lib/wavefront-cli/display/source.rb
|
224
|
+
- lib/wavefront-cli/display/usage.rb
|
227
225
|
- lib/wavefront-cli/display/user.rb
|
228
226
|
- lib/wavefront-cli/display/usergroup.rb
|
229
227
|
- lib/wavefront-cli/display/webhook.rb
|
@@ -231,6 +229,7 @@ files:
|
|
231
229
|
- lib/wavefront-cli/event.rb
|
232
230
|
- lib/wavefront-cli/exception.rb
|
233
231
|
- lib/wavefront-cli/externallink.rb
|
232
|
+
- lib/wavefront-cli/ingestionpolicy.rb
|
234
233
|
- lib/wavefront-cli/integration.rb
|
235
234
|
- lib/wavefront-cli/maintenancewindow.rb
|
236
235
|
- lib/wavefront-cli/message.rb
|
@@ -261,6 +260,7 @@ files:
|
|
261
260
|
- lib/wavefront-cli/source.rb
|
262
261
|
- lib/wavefront-cli/stdlib/array.rb
|
263
262
|
- lib/wavefront-cli/stdlib/string.rb
|
263
|
+
- lib/wavefront-cli/usage.rb
|
264
264
|
- lib/wavefront-cli/user.rb
|
265
265
|
- lib/wavefront-cli/usergroup.rb
|
266
266
|
- lib/wavefront-cli/version.rb
|
@@ -357,7 +357,9 @@ files:
|
|
357
357
|
- spec/wavefront-cli/resources/responses/query-cpu.json
|
358
358
|
- spec/wavefront-cli/resources/responses/query.json
|
359
359
|
- spec/wavefront-cli/resources/responses/savedsearch-list.json
|
360
|
+
- spec/wavefront-cli/resources/responses/usage-export-csv.json
|
360
361
|
- spec/wavefront-cli/resources/responses/user-list.json
|
362
|
+
- spec/wavefront-cli/resources/responses/user-validate.json
|
361
363
|
- spec/wavefront-cli/resources/responses/usergroup-list.json
|
362
364
|
- spec/wavefront-cli/resources/responses/webhook-list.json
|
363
365
|
- spec/wavefront-cli/resources/responses/window-list.json
|
@@ -372,6 +374,7 @@ files:
|
|
372
374
|
- spec/wavefront-cli/source_spec.rb
|
373
375
|
- spec/wavefront-cli/stdlib/array_spec.rb
|
374
376
|
- spec/wavefront-cli/stdlib/string_spec.rb
|
377
|
+
- spec/wavefront-cli/usage_spec.rb
|
375
378
|
- spec/wavefront-cli/user_spec.rb
|
376
379
|
- spec/wavefront-cli/usergroup_spec.rb
|
377
380
|
- spec/wavefront-cli/webhook_spec.rb
|
@@ -493,7 +496,9 @@ test_files:
|
|
493
496
|
- spec/wavefront-cli/resources/responses/query-cpu.json
|
494
497
|
- spec/wavefront-cli/resources/responses/query.json
|
495
498
|
- spec/wavefront-cli/resources/responses/savedsearch-list.json
|
499
|
+
- spec/wavefront-cli/resources/responses/usage-export-csv.json
|
496
500
|
- spec/wavefront-cli/resources/responses/user-list.json
|
501
|
+
- spec/wavefront-cli/resources/responses/user-validate.json
|
497
502
|
- spec/wavefront-cli/resources/responses/usergroup-list.json
|
498
503
|
- spec/wavefront-cli/resources/responses/webhook-list.json
|
499
504
|
- spec/wavefront-cli/resources/responses/window-list.json
|
@@ -508,6 +513,7 @@ test_files:
|
|
508
513
|
- spec/wavefront-cli/source_spec.rb
|
509
514
|
- spec/wavefront-cli/stdlib/array_spec.rb
|
510
515
|
- spec/wavefront-cli/stdlib/string_spec.rb
|
516
|
+
- spec/wavefront-cli/usage_spec.rb
|
511
517
|
- spec/wavefront-cli/user_spec.rb
|
512
518
|
- spec/wavefront-cli/usergroup_spec.rb
|
513
519
|
- spec/wavefront-cli/webhook_spec.rb
|