dogapi 1.7.1 → 1.8.0
Sign up to get free protection for your applications and to get access to all the features.
- data/README.rdoc +5 -1
- data/lib/dogapi/facade.rb +24 -0
- data/lib/dogapi/v1.rb +1 -0
- data/lib/dogapi/v1/screenboard.rb +85 -0
- data/tests/test_screenboard.rb +74 -0
- metadata +6 -4
data/README.rdoc
CHANGED
@@ -1,9 +1,13 @@
|
|
1
|
-
= Ruby client for Datadog API v1.
|
1
|
+
= Ruby client for Datadog API v1.8.0
|
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.8.0
|
8
|
+
|
9
|
+
* Add an API for interacting with Screenboards
|
10
|
+
|
7
11
|
== v1.7.1
|
8
12
|
|
9
13
|
* Add an API for inviting users
|
data/lib/dogapi/facade.rb
CHANGED
@@ -35,6 +35,7 @@ module Dogapi
|
|
35
35
|
@alert_svc = Dogapi::V1::AlertService.new(@api_key, @application_key, silent)
|
36
36
|
@user_svc = Dogapi::V1::UserService.new(@api_key, @application_key, silent)
|
37
37
|
@snapshot_svc = Dogapi::V1::SnapshotService.new(@api_key, @application_key, silent)
|
38
|
+
@screenboard_svc = Dogapi::V1::ScreenboardService.new(@api_key, @application_key, silent)
|
38
39
|
|
39
40
|
@legacy_event_svc = Dogapi::EventService.new(@datadog_host)
|
40
41
|
end
|
@@ -285,6 +286,29 @@ module Dogapi
|
|
285
286
|
@snapshot_svc.snapshot(metric_query, start_ts, end_ts, event_query)
|
286
287
|
end
|
287
288
|
|
289
|
+
#
|
290
|
+
# SCREENBOARD
|
291
|
+
#
|
292
|
+
def create_screenboard(description)
|
293
|
+
@screenboard_svc.create_screenboard(description)
|
294
|
+
end
|
295
|
+
|
296
|
+
def update_screenboard(board_id, description)
|
297
|
+
@screenboard_svc.update_screenboard(board_id, description)
|
298
|
+
end
|
299
|
+
|
300
|
+
def get_screenboard(board_id)
|
301
|
+
@screenboard_svc.get_screenboard(board_id)
|
302
|
+
end
|
303
|
+
|
304
|
+
def delete_screenboard(board_id)
|
305
|
+
@screenboard_svc.delete_screenboard(board_id)
|
306
|
+
end
|
307
|
+
|
308
|
+
def share_screenboard(board_id)
|
309
|
+
@screenboard_svc.share_screenboard(board_id)
|
310
|
+
end
|
311
|
+
|
288
312
|
private
|
289
313
|
|
290
314
|
def override_scope(host, device)
|
data/lib/dogapi/v1.rb
CHANGED
@@ -0,0 +1,85 @@
|
|
1
|
+
require 'dogapi'
|
2
|
+
|
3
|
+
module Dogapi
|
4
|
+
class V1 # for namespacing
|
5
|
+
|
6
|
+
class ScreenboardService < Dogapi::APIService
|
7
|
+
|
8
|
+
API_VERSION = "v1"
|
9
|
+
|
10
|
+
def create_screenboard(description)
|
11
|
+
|
12
|
+
begin
|
13
|
+
params = {
|
14
|
+
:api_key => @api_key,
|
15
|
+
:application_key => @application_key
|
16
|
+
}
|
17
|
+
|
18
|
+
body = description
|
19
|
+
|
20
|
+
request(Net::HTTP::Post, "/api/#{API_VERSION}/screen", params, description, true)
|
21
|
+
rescue Exception => e
|
22
|
+
suppress_error_if_silent e
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
def update_screenboard(board_id, description)
|
27
|
+
|
28
|
+
begin
|
29
|
+
params = {
|
30
|
+
:api_key => @api_key,
|
31
|
+
:application_key => @application_key
|
32
|
+
}
|
33
|
+
|
34
|
+
body = description
|
35
|
+
|
36
|
+
request(Net::HTTP::Put, "/api/#{API_VERSION}/screen/#{board_id}", params, body, true)
|
37
|
+
rescue Exception => e
|
38
|
+
suppress_error_if_silent e
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
def get_screenboard(board_id)
|
43
|
+
begin
|
44
|
+
params = {
|
45
|
+
:api_key => @api_key,
|
46
|
+
:application_key => @application_key
|
47
|
+
}
|
48
|
+
|
49
|
+
request(Net::HTTP::Get, "/api/#{API_VERSION}/screen/#{board_id}", params, nil, false)
|
50
|
+
rescue Exception => e
|
51
|
+
suppress_error_if_silent e
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
def delete_screenboard(board_id)
|
56
|
+
begin
|
57
|
+
params = {
|
58
|
+
:api_key => @api_key,
|
59
|
+
:application_key => @application_key
|
60
|
+
}
|
61
|
+
|
62
|
+
request(Net::HTTP::Delete, "/api/#{API_VERSION}/screen/#{board_id}", params, nil, false)
|
63
|
+
rescue Exception => e
|
64
|
+
suppress_error_if_silent e
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
|
69
|
+
def share_screenboard(board_id)
|
70
|
+
begin
|
71
|
+
params = {
|
72
|
+
:api_key => @api_key,
|
73
|
+
:application_key => @application_key
|
74
|
+
}
|
75
|
+
|
76
|
+
request(Net::HTTP::Get, "/api/#{API_VERSION}/screen/share/#{board_id}", params, nil, false)
|
77
|
+
rescue Exception => e
|
78
|
+
suppress_error_if_silent e
|
79
|
+
end
|
80
|
+
end
|
81
|
+
|
82
|
+
end
|
83
|
+
|
84
|
+
end
|
85
|
+
end
|
@@ -0,0 +1,74 @@
|
|
1
|
+
require 'dogapi'
|
2
|
+
require 'time'
|
3
|
+
require 'test_base.rb'
|
4
|
+
|
5
|
+
class TestScreenboard < Test::Unit::TestCase
|
6
|
+
include TestBase
|
7
|
+
|
8
|
+
def test_screenboard
|
9
|
+
dog = Dogapi::Client.new(@api_key, @app_key)
|
10
|
+
|
11
|
+
board = {
|
12
|
+
"width" => 1024,
|
13
|
+
"height" => 768,
|
14
|
+
"board_title" => "dogapi-rb test",
|
15
|
+
"widgets" => [
|
16
|
+
{
|
17
|
+
"type" => "event_stream",
|
18
|
+
"title" => false,
|
19
|
+
"height" => 57,
|
20
|
+
"width" => 59,
|
21
|
+
"y" => 18,
|
22
|
+
"x" => 84,
|
23
|
+
"query" => "tags:release",
|
24
|
+
"timeframe" => "1w"
|
25
|
+
},
|
26
|
+
{
|
27
|
+
"type" => "image",
|
28
|
+
"height" => 20,
|
29
|
+
"width" => 32,
|
30
|
+
"y" => 7,
|
31
|
+
"x" => 32,
|
32
|
+
"url" => "http://path/to/image.jpg"
|
33
|
+
}
|
34
|
+
]
|
35
|
+
}
|
36
|
+
|
37
|
+
updated_board = {
|
38
|
+
"width" => 1024,
|
39
|
+
"height" => 768,
|
40
|
+
"board_title" => "dogapi test",
|
41
|
+
"widgets" => [
|
42
|
+
{
|
43
|
+
"type" => "image",
|
44
|
+
"height" => 20,
|
45
|
+
"width" => 32,
|
46
|
+
"y" => 7,
|
47
|
+
"x" => 32,
|
48
|
+
"url" => "http://path/to/image.jpg"
|
49
|
+
}
|
50
|
+
]
|
51
|
+
}
|
52
|
+
|
53
|
+
status, result = dog.create_screenboard(board)
|
54
|
+
assert_equal status, "200", "invalid HTTP response => #{status}"
|
55
|
+
assert result["widgets"] == board["widgets"]
|
56
|
+
|
57
|
+
status, result = dog.get_screenboard(result["id"])
|
58
|
+
assert_equal status, "200", "invalid HTTP response => #{status}"
|
59
|
+
assert result["widgets"] == board["widgets"]
|
60
|
+
|
61
|
+
status, result = dog.update_screenboard(result["id"], updated_board)
|
62
|
+
assert_equal status, "200", "invalid HTTP response => #{status}"
|
63
|
+
assert result["widgets"] == updated_board["widgets"]
|
64
|
+
|
65
|
+
status, share_result = dog.share_screenboard(result["id"])
|
66
|
+
assert_equal status, "200", "invalid HTTP response => #{status}"
|
67
|
+
assert share_result["board_id"] == result["id"]
|
68
|
+
|
69
|
+
status, del_result = dog.delete_screenboard(result["id"])
|
70
|
+
assert_equal status, "200", "invalid HTTP response => #{status}"
|
71
|
+
assert del_result["id"] == result["id"]
|
72
|
+
|
73
|
+
end
|
74
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dogapi
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.8.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-
|
12
|
+
date: 2013-07-16 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: json
|
16
|
-
requirement: &
|
16
|
+
requirement: &11482000 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,7 +21,7 @@ dependencies:
|
|
21
21
|
version: 1.5.1
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *11482000
|
25
25
|
description:
|
26
26
|
email: packages@datadoghq.com
|
27
27
|
executables: []
|
@@ -42,6 +42,7 @@ files:
|
|
42
42
|
- lib/dogapi/v1/dash.rb
|
43
43
|
- lib/dogapi/v1/event.rb
|
44
44
|
- lib/dogapi/v1/metric.rb
|
45
|
+
- lib/dogapi/v1/screenboard.rb
|
45
46
|
- lib/dogapi/v1/search.rb
|
46
47
|
- lib/dogapi/v1/snapshot.rb
|
47
48
|
- lib/dogapi/v1/tag.rb
|
@@ -51,6 +52,7 @@ files:
|
|
51
52
|
- tests/test_client.rb
|
52
53
|
- tests/test_comments.rb
|
53
54
|
- tests/test_dashes.rb
|
55
|
+
- tests/test_screenboard.rb
|
54
56
|
- tests/test_search.rb
|
55
57
|
- tests/test_snapshot.rb
|
56
58
|
- tests/test_users.rb
|