dogapi 1.6.0 → 1.7.1
Sign up to get free protection for your applications and to get access to all the features.
- data/README.rdoc +11 -1
- data/lib/capistrano/datadog.rb +1 -1
- data/lib/dogapi/facade.rb +12 -0
- data/lib/dogapi/v1.rb +2 -0
- data/lib/dogapi/v1/snapshot.rb +30 -0
- data/lib/dogapi/v1/user.rb +29 -0
- data/tests/test_snapshot.rb +28 -0
- data/tests/test_users.rb +16 -0
- metadata +42 -57
data/README.rdoc
CHANGED
@@ -1,9 +1,19 @@
|
|
1
|
-
= Ruby client for Datadog API v1.
|
1
|
+
= Ruby client for Datadog API v1.7.1
|
2
2
|
|
3
3
|
The Ruby client is a library suitable for inclusion in existing Ruby projects or for development of standalone scripts. It provides an abstraction on top of Datadog's raw HTTP interface for reporting events and metrics.
|
4
4
|
|
5
5
|
= What's new?
|
6
6
|
|
7
|
+
== v1.7.1
|
8
|
+
|
9
|
+
* Add an API for inviting users
|
10
|
+
* Add an API for taking graph snapshots
|
11
|
+
* Fix bug in capistrano integration with logging of nil (thanks @arielo)
|
12
|
+
|
13
|
+
== v1.7.0
|
14
|
+
|
15
|
+
* Not released.
|
16
|
+
|
7
17
|
== v1.6.0
|
8
18
|
|
9
19
|
* Support for setting `source` type when submitting host tags
|
data/lib/capistrano/datadog.rb
CHANGED
@@ -97,7 +97,7 @@ module Capistrano
|
|
97
97
|
type = "deploy"
|
98
98
|
alert_type = "success"
|
99
99
|
source_type = "capistrano"
|
100
|
-
message = "@@@" + "\n" + @logging_output[name].join('') + "@@@"
|
100
|
+
message = "@@@" + "\n" + (@logging_output[name] || []).join('') + "@@@"
|
101
101
|
|
102
102
|
Dogapi::Event.new(message,
|
103
103
|
:msg_title => title,
|
data/lib/dogapi/facade.rb
CHANGED
@@ -33,6 +33,8 @@ module Dogapi
|
|
33
33
|
@search_svc = Dogapi::V1::SearchService.new(@api_key, @application_key, silent)
|
34
34
|
@dash_service = Dogapi::V1::DashService.new(@api_key, @application_key, silent)
|
35
35
|
@alert_svc = Dogapi::V1::AlertService.new(@api_key, @application_key, silent)
|
36
|
+
@user_svc = Dogapi::V1::UserService.new(@api_key, @application_key, silent)
|
37
|
+
@snapshot_svc = Dogapi::V1::SnapshotService.new(@api_key, @application_key, silent)
|
36
38
|
|
37
39
|
@legacy_event_svc = Dogapi::EventService.new(@datadog_host)
|
38
40
|
end
|
@@ -273,6 +275,16 @@ module Dogapi
|
|
273
275
|
@alert_svc.unmute_alerts()
|
274
276
|
end
|
275
277
|
|
278
|
+
# User invite
|
279
|
+
def invite(emails, options={})
|
280
|
+
@user_svc.invite(emails, options)
|
281
|
+
end
|
282
|
+
|
283
|
+
# Graph snapshot
|
284
|
+
def graph_snapshot(metric_query, start_ts, end_ts, event_query=nil)
|
285
|
+
@snapshot_svc.snapshot(metric_query, start_ts, end_ts, event_query)
|
286
|
+
end
|
287
|
+
|
276
288
|
private
|
277
289
|
|
278
290
|
def override_scope(host, device)
|
data/lib/dogapi/v1.rb
CHANGED
@@ -0,0 +1,30 @@
|
|
1
|
+
require 'dogapi'
|
2
|
+
|
3
|
+
module Dogapi
|
4
|
+
class V1 # for namespacing
|
5
|
+
|
6
|
+
class SnapshotService < Dogapi::APIService
|
7
|
+
|
8
|
+
API_VERSION = "v1"
|
9
|
+
|
10
|
+
def snapshot(metric_query, start_ts, end_ts, event_query=nil)
|
11
|
+
begin
|
12
|
+
params = {
|
13
|
+
:api_key => @api_key,
|
14
|
+
:application_key => @application_key,
|
15
|
+
:metric_query => metric_query,
|
16
|
+
:start => start_ts,
|
17
|
+
:end => end_ts,
|
18
|
+
:event_query => event_query
|
19
|
+
}
|
20
|
+
|
21
|
+
request(Net::HTTP::Get, "/api/#{API_VERSION}/graph/snapshot", params, nil, false)
|
22
|
+
rescue Exception => e
|
23
|
+
suppress_error_if_silent e
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
end
|
28
|
+
|
29
|
+
end
|
30
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
require 'dogapi'
|
2
|
+
|
3
|
+
module Dogapi
|
4
|
+
class V1 # for namespacing
|
5
|
+
|
6
|
+
class UserService < Dogapi::APIService
|
7
|
+
|
8
|
+
API_VERSION = "v1"
|
9
|
+
|
10
|
+
def invite(emails, options={})
|
11
|
+
begin
|
12
|
+
params = {
|
13
|
+
:api_key => @api_key,
|
14
|
+
:application_key => @application_key
|
15
|
+
}
|
16
|
+
|
17
|
+
body = {
|
18
|
+
'emails' => emails,
|
19
|
+
}.merge options
|
20
|
+
|
21
|
+
request(Net::HTTP::Post, "/api/#{API_VERSION}/invite_users", params, body, true)
|
22
|
+
rescue Exception => e
|
23
|
+
suppress_error_if_silent e
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
require 'dogapi'
|
2
|
+
require 'time'
|
3
|
+
require 'test_base.rb'
|
4
|
+
|
5
|
+
class TestSnapshot < Test::Unit::TestCase
|
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
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
require 'dogapi'
|
2
|
+
require 'time'
|
3
|
+
require 'test_base.rb'
|
4
|
+
|
5
|
+
class TestUsers < Test::Unit::TestCase
|
6
|
+
include TestBase
|
7
|
+
|
8
|
+
def test_users
|
9
|
+
dog = Dogapi::Client.new(@api_key, @app_key)
|
10
|
+
|
11
|
+
emails = ["notarealperson@datadoghq.com", "alsoreallyfake@datadoghq.com"]
|
12
|
+
|
13
|
+
invited = dog.invite(emails)
|
14
|
+
assert_equal emails, invited[1]["emails"], invited
|
15
|
+
end
|
16
|
+
end
|
metadata
CHANGED
@@ -1,105 +1,90 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: dogapi
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
|
5
|
-
|
6
|
-
- 1
|
7
|
-
- 6
|
8
|
-
- 0
|
9
|
-
segments_generated: true
|
10
|
-
version: 1.6.0
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.7.1
|
5
|
+
prerelease:
|
11
6
|
platform: ruby
|
12
|
-
authors:
|
7
|
+
authors:
|
13
8
|
- Datadog, Inc.
|
14
9
|
autorequire:
|
15
10
|
bindir: bin
|
16
11
|
cert_chain: []
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
dependencies:
|
21
|
-
- !ruby/object:Gem::Dependency
|
22
|
-
type: :runtime
|
23
|
-
version_requirements: &id001 !ruby/object:Gem::Requirement
|
24
|
-
requirements:
|
25
|
-
- - ">="
|
26
|
-
- !ruby/object:Gem::Version
|
27
|
-
segments:
|
28
|
-
- 1
|
29
|
-
- 5
|
30
|
-
- 1
|
31
|
-
segments_generated: true
|
32
|
-
version: 1.5.1
|
12
|
+
date: 2013-06-27 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
33
15
|
name: json
|
34
|
-
requirement:
|
16
|
+
requirement: &6638840 !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: 1.5.1
|
22
|
+
type: :runtime
|
35
23
|
prerelease: false
|
24
|
+
version_requirements: *6638840
|
36
25
|
description:
|
37
26
|
email: packages@datadoghq.com
|
38
27
|
executables: []
|
39
|
-
|
40
28
|
extensions: []
|
41
|
-
|
42
|
-
extra_rdoc_files:
|
29
|
+
extra_rdoc_files:
|
43
30
|
- README.rdoc
|
44
|
-
files:
|
45
|
-
- lib/capistrano/datadog.rb
|
31
|
+
files:
|
46
32
|
- lib/capistrano/README.md
|
33
|
+
- lib/capistrano/datadog.rb
|
34
|
+
- lib/dogapi.rb
|
47
35
|
- lib/dogapi/common.rb
|
48
36
|
- lib/dogapi/event.rb
|
49
37
|
- lib/dogapi/facade.rb
|
50
38
|
- lib/dogapi/metric.rb
|
39
|
+
- lib/dogapi/v1.rb
|
51
40
|
- lib/dogapi/v1/alert.rb
|
52
41
|
- lib/dogapi/v1/comment.rb
|
53
42
|
- lib/dogapi/v1/dash.rb
|
54
43
|
- lib/dogapi/v1/event.rb
|
55
44
|
- lib/dogapi/v1/metric.rb
|
56
45
|
- lib/dogapi/v1/search.rb
|
46
|
+
- lib/dogapi/v1/snapshot.rb
|
57
47
|
- lib/dogapi/v1/tag.rb
|
58
|
-
- lib/dogapi/v1.rb
|
59
|
-
- lib/dogapi.rb
|
48
|
+
- lib/dogapi/v1/user.rb
|
60
49
|
- tests/test_alerts.rb
|
61
50
|
- tests/test_base.rb
|
62
51
|
- tests/test_client.rb
|
63
52
|
- tests/test_comments.rb
|
64
53
|
- tests/test_dashes.rb
|
65
54
|
- tests/test_search.rb
|
55
|
+
- tests/test_snapshot.rb
|
56
|
+
- tests/test_users.rb
|
66
57
|
- README.rdoc
|
67
|
-
has_rdoc: true
|
68
58
|
homepage: http://datadoghq.com/
|
69
|
-
licenses:
|
59
|
+
licenses:
|
70
60
|
- BSD
|
71
61
|
post_install_message:
|
72
|
-
rdoc_options:
|
62
|
+
rdoc_options:
|
73
63
|
- --title
|
74
64
|
- DogAPI -- DataDog Client
|
75
65
|
- --main
|
76
66
|
- README.rdoc
|
77
67
|
- --line-numbers
|
78
68
|
- --inline-source
|
79
|
-
require_paths:
|
69
|
+
require_paths:
|
80
70
|
- lib
|
81
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
segments:
|
94
|
-
- 0
|
95
|
-
segments_generated: true
|
96
|
-
version: "0"
|
71
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
72
|
+
none: false
|
73
|
+
requirements:
|
74
|
+
- - ! '>='
|
75
|
+
- !ruby/object:Gem::Version
|
76
|
+
version: '0'
|
77
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
78
|
+
none: false
|
79
|
+
requirements:
|
80
|
+
- - ! '>='
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
97
83
|
requirements: []
|
98
|
-
|
99
84
|
rubyforge_project:
|
100
|
-
rubygems_version: 1.
|
85
|
+
rubygems_version: 1.8.11
|
101
86
|
signing_key:
|
102
87
|
specification_version: 3
|
103
88
|
summary: Ruby bindings for Datadog's API
|
104
|
-
test_files:
|
89
|
+
test_files:
|
105
90
|
- tests/test_client.rb
|