dogapi 1.22.0 → 1.23.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/.rspec +1 -1
- data/.rubocop.yml +13 -0
- data/.travis.yml +3 -1
- data/CHANGELOG.md +16 -1
- data/Gemfile +6 -3
- data/README.rdoc +1 -1
- data/Rakefile +8 -15
- data/lib/capistrano/datadog.rb +12 -12
- data/lib/capistrano/datadog/v2.rb +5 -5
- data/lib/capistrano/datadog/v3.rb +9 -4
- data/lib/dogapi/common.rb +43 -39
- data/lib/dogapi/event.rb +4 -4
- data/lib/dogapi/facade.rb +57 -54
- data/lib/dogapi/metric.rb +2 -2
- data/lib/dogapi/v1/alert.rb +17 -80
- data/lib/dogapi/v1/comment.rb +8 -39
- data/lib/dogapi/v1/dash.rb +20 -67
- data/lib/dogapi/v1/embed.rb +11 -57
- data/lib/dogapi/v1/event.rb +37 -72
- data/lib/dogapi/v1/metric.rb +17 -46
- data/lib/dogapi/v1/monitor.rb +54 -194
- data/lib/dogapi/v1/screenboard.rb +8 -77
- data/lib/dogapi/v1/search.rb +5 -11
- data/lib/dogapi/v1/service_check.rb +6 -15
- data/lib/dogapi/v1/snapshot.rb +10 -15
- data/lib/dogapi/v1/tag.rb +39 -99
- data/lib/dogapi/v1/user.rb +15 -69
- data/lib/dogapi/version.rb +1 -1
- data/spec/integration/alert_spec.rb +48 -0
- data/spec/integration/comment_spec.rb +32 -0
- data/spec/integration/common_spec.rb +32 -0
- data/spec/integration/dash_spec.rb +60 -0
- data/spec/integration/embed_spec.rb +43 -0
- data/spec/integration/event_spec.rb +73 -0
- data/spec/integration/metric_spec.rb +96 -0
- data/spec/integration/monitor_spec.rb +106 -0
- data/spec/integration/screenboard_spec.rb +61 -0
- data/spec/integration/search_spec.rb +11 -0
- data/spec/integration/service_check_spec.rb +12 -0
- data/spec/integration/snapshot_spec.rb +24 -0
- data/spec/integration/tag_spec.rb +66 -0
- data/spec/integration/user_spec.rb +46 -0
- data/spec/spec_helper.rb +85 -16
- data/spec/unit/common_spec.rb +101 -0
- data/spec/unit/facade_spec.rb +79 -0
- metadata +55 -52
- data/spec/alerts_spec.rb +0 -33
- data/spec/common_spec.rb +0 -37
- data/spec/facade_spec.rb +0 -166
- data/spec/support/cassettes/Alerts/create/returns_HTTP_code_200.yml +0 -114
- data/spec/support/cassettes/Alerts/create/returns_a_valid_event_ID.yml +0 -114
- data/spec/support/cassettes/Alerts/create/returns_the_same_query_as_sent.yml +0 -114
- data/spec/support/cassettes/Facade/Events/emits_aggregate_events.yml +0 -193
- data/spec/support/cassettes/Facade/Events/emits_events_and_retrieves_them.yml +0 -100
- data/spec/support/cassettes/Facade/Events/emits_events_with_specified_priority.yml +0 -98
- data/spec/support/cassettes/Facade/Tags/adds_updates_and_detaches_tags.yml +0 -442
- data/tests/test_alerts.rb +0 -38
- data/tests/test_base.rb +0 -30
- data/tests/test_client.rb +0 -23
- data/tests/test_comments.rb +0 -39
- data/tests/test_dashes.rb +0 -85
- data/tests/test_embed.rb +0 -194
- data/tests/test_monitors.rb +0 -192
- data/tests/test_screenboard.rb +0 -90
- data/tests/test_search.rb +0 -20
- data/tests/test_snapshot.rb +0 -28
- data/tests/test_users.rb +0 -65
data/tests/test_screenboard.rb
DELETED
@@ -1,90 +0,0 @@
|
|
1
|
-
require 'dogapi'
|
2
|
-
require 'time'
|
3
|
-
require 'test_base.rb'
|
4
|
-
require 'open-uri'
|
5
|
-
|
6
|
-
class TestScreenboard < Minitest::Test
|
7
|
-
include TestBase
|
8
|
-
|
9
|
-
def test_screenboard
|
10
|
-
dog = Dogapi::Client.new(@api_key, @app_key)
|
11
|
-
|
12
|
-
board = {
|
13
|
-
"width" => 1024,
|
14
|
-
"height" => 768,
|
15
|
-
"board_title" => "dogapi-rb test",
|
16
|
-
"widgets" => [
|
17
|
-
{
|
18
|
-
"type" => "event_stream",
|
19
|
-
"title" => false,
|
20
|
-
"height" => 57,
|
21
|
-
"width" => 59,
|
22
|
-
"y" => 18,
|
23
|
-
"x" => 84,
|
24
|
-
"query" => "tags:release",
|
25
|
-
"timeframe" => "1w"
|
26
|
-
},
|
27
|
-
{
|
28
|
-
"type" => "image",
|
29
|
-
"height" => 20,
|
30
|
-
"width" => 32,
|
31
|
-
"y" => 7,
|
32
|
-
"x" => 32,
|
33
|
-
"url" => "http://path/to/image.jpg"
|
34
|
-
}
|
35
|
-
]
|
36
|
-
}
|
37
|
-
|
38
|
-
updated_board = {
|
39
|
-
"width" => 1024,
|
40
|
-
"height" => 768,
|
41
|
-
"board_title" => "dogapi test",
|
42
|
-
"widgets" => [
|
43
|
-
{
|
44
|
-
"type" => "image",
|
45
|
-
"height" => 20,
|
46
|
-
"width" => 32,
|
47
|
-
"y" => 7,
|
48
|
-
"x" => 32,
|
49
|
-
"url" => "http://path/to/image.jpg"
|
50
|
-
}
|
51
|
-
]
|
52
|
-
}
|
53
|
-
|
54
|
-
status, result = dog.create_screenboard(board)
|
55
|
-
assert_equal status, "200", "invalid HTTP response => #{status}"
|
56
|
-
assert result["widgets"] == board["widgets"]
|
57
|
-
|
58
|
-
status, result = dog.get_screenboard(result["id"])
|
59
|
-
assert_equal status, "200", "invalid HTTP response => #{status}"
|
60
|
-
assert result["widgets"] == board["widgets"]
|
61
|
-
|
62
|
-
status, result = dog.update_screenboard(result["id"], updated_board)
|
63
|
-
assert_equal status, "200", "invalid HTTP response => #{status}"
|
64
|
-
assert result["widgets"] == updated_board["widgets"]
|
65
|
-
|
66
|
-
status, share_result = dog.share_screenboard(result["id"])
|
67
|
-
assert_equal status, "200", "invalid HTTP response => #{status}"
|
68
|
-
assert share_result["board_id"] == result["id"]
|
69
|
-
|
70
|
-
open(share_result["public_url"]) do |f|
|
71
|
-
assert_equal f.status.first, "200", "invalid HTTP response => #{status}"
|
72
|
-
end
|
73
|
-
|
74
|
-
status, revoke_result = dog.revoke_screenboard(result["id"])
|
75
|
-
assert_equal status, "200", "invalid HTTP response => #{status}"
|
76
|
-
|
77
|
-
ex = assert_raises OpenURI::HTTPError do
|
78
|
-
open(share_result["public_url"])
|
79
|
-
end
|
80
|
-
assert_equal ex.message, "404 Not Found"
|
81
|
-
|
82
|
-
status, del_result = dog.delete_screenboard(result["id"])
|
83
|
-
assert_equal status, "200", "invalid HTTP response => #{status}"
|
84
|
-
assert del_result["id"] == result["id"]
|
85
|
-
|
86
|
-
status, result = dog.get_all_screenboards()
|
87
|
-
assert_equal status, "200", "invalid HTTP response => #{status}"
|
88
|
-
|
89
|
-
end
|
90
|
-
end
|
data/tests/test_search.rb
DELETED
@@ -1,20 +0,0 @@
|
|
1
|
-
require 'dogapi'
|
2
|
-
require 'time'
|
3
|
-
require 'test_base.rb'
|
4
|
-
|
5
|
-
class TestSearch < Minitest::Test
|
6
|
-
include TestBase
|
7
|
-
|
8
|
-
def test_search
|
9
|
-
dog = Dogapi::Client.new(@api_key, @app_key)
|
10
|
-
|
11
|
-
facets = ["hosts", "metrics"]
|
12
|
-
facets.each do |facet|
|
13
|
-
status, results_body = dog.search("#{facet}:foo")
|
14
|
-
results = results_body["results"]
|
15
|
-
assert_equal status, "200", "failed search #{facet} facet"
|
16
|
-
assert results[facet].kind_of?(Array), "#{facet} facet doesnt exist"
|
17
|
-
end
|
18
|
-
|
19
|
-
end
|
20
|
-
end
|
data/tests/test_snapshot.rb
DELETED
@@ -1,28 +0,0 @@
|
|
1
|
-
require 'dogapi'
|
2
|
-
require 'time'
|
3
|
-
require 'test_base.rb'
|
4
|
-
|
5
|
-
class TestSnapshot < Minitest::Test
|
6
|
-
include TestBase
|
7
|
-
|
8
|
-
def test_snapshot
|
9
|
-
dog = Dogapi::Client.new(@api_key, @app_key)
|
10
|
-
|
11
|
-
metric_query = "system.load.1{*}"
|
12
|
-
event_query = "*"
|
13
|
-
end_ts = Time.now().to_i
|
14
|
-
start_ts = end_ts - 60 * 60 # go back 1 hour
|
15
|
-
|
16
|
-
# Try without an event query
|
17
|
-
status, result = dog.graph_snapshot(metric_query, start_ts, end_ts)
|
18
|
-
assert_equal status, "200", "invalid HTTP response: #{status}"
|
19
|
-
assert result["metric_query"] = metric_query
|
20
|
-
|
21
|
-
# Try with an event query
|
22
|
-
status, result = dog.graph_snapshot(metric_query, start_ts, end_ts,
|
23
|
-
event_query=event_query)
|
24
|
-
assert_equal status, "200", "invalid HTTP response: #{status}"
|
25
|
-
assert result["metric_query"] = metric_query
|
26
|
-
assert result["event_query"] = event_query
|
27
|
-
end
|
28
|
-
end
|
data/tests/test_users.rb
DELETED
@@ -1,65 +0,0 @@
|
|
1
|
-
require 'dogapi'
|
2
|
-
require 'time'
|
3
|
-
require 'test_base.rb'
|
4
|
-
|
5
|
-
class TestUsers < Minitest::Test
|
6
|
-
include TestBase
|
7
|
-
|
8
|
-
def test_users
|
9
|
-
dog = Dogapi::Client.new(@api_key, @app_key)
|
10
|
-
|
11
|
-
# user invite (deprecated)
|
12
|
-
emails = ["notarealperson@datadoghq.com", "alsoreallyfake@datadoghq.com"]
|
13
|
-
|
14
|
-
invited = dog.invite(emails)
|
15
|
-
assert_equal emails, invited[1]["emails"], invited
|
16
|
-
|
17
|
-
# user CRUD
|
18
|
-
handle = 'user@test.com'
|
19
|
-
name = 'Test User'
|
20
|
-
alternate_name = 'Test User Alt'
|
21
|
-
alternate_email = 'user+1@test.com'
|
22
|
-
|
23
|
-
# test create user
|
24
|
-
# the user might already exist
|
25
|
-
dog.create_user({
|
26
|
-
'handle' => handle,
|
27
|
-
'name' => name,
|
28
|
-
})
|
29
|
-
|
30
|
-
# reset user to original status
|
31
|
-
status, res = dog.update_user(handle, {
|
32
|
-
'name' => name,
|
33
|
-
'email' => handle,
|
34
|
-
'disabled' => false,
|
35
|
-
})
|
36
|
-
assert_equal handle, res['user']['handle']
|
37
|
-
assert_equal name, res['user']['name']
|
38
|
-
assert_equal handle, res['user']['email']
|
39
|
-
|
40
|
-
# test get
|
41
|
-
status, res = dog.get_user(handle)
|
42
|
-
assert_equal handle, res['user']['handle']
|
43
|
-
|
44
|
-
# test update user
|
45
|
-
status, res = dog.update_user(handle, {
|
46
|
-
'name' => alternate_name,
|
47
|
-
'email' => alternate_email,
|
48
|
-
})
|
49
|
-
assert_equal handle, res['user']['handle']
|
50
|
-
assert_equal alternate_name, res['user']['name']
|
51
|
-
assert_equal alternate_email, res['user']['email']
|
52
|
-
|
53
|
-
# test disable user
|
54
|
-
status, res = dog.disable_user(handle)
|
55
|
-
assert_equal '200', status
|
56
|
-
|
57
|
-
# test get all users
|
58
|
-
status, res = dog.get_all_users()
|
59
|
-
assert_equal true, res['users'].length >= 1
|
60
|
-
|
61
|
-
end
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
end
|