dogapi 1.29.0 → 1.30
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +53 -44
- data/lib/dogapi/common.rb +3 -1
- data/lib/dogapi/facade.rb +13 -0
- data/lib/dogapi/v1.rb +1 -0
- data/lib/dogapi/v1/hosts.rb +21 -0
- data/lib/dogapi/v1/search.rb +7 -0
- data/lib/dogapi/version.rb +1 -1
- data/spec/spec_helper.rb +1 -1
- data/spec/unit/common_spec.rb +11 -2
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ebee611bd7522efe9456a959522706572585e27cd7a7c702749584318bfc291b
|
4
|
+
data.tar.gz: 8d3fedc656c9443618b164fdcb0a9dd601f88dee81d000fc210f7338aacb3a34
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c4be6b9543da77c590ba0e155f2b92bb9c52befa16825d835d81721a3792cc7fd58e4a1a888a46a0856d7f099c124fd49eafa2674133660b3bda2ce0e6ab5bbf
|
7
|
+
data.tar.gz: 32e79e62b507f2c2d514bcd28449f1eb5d1c4856c8a8ebcb6b7a2204299f552b4e83fe0ff0b90be30fd21882ffdebed775a4806015681986d52866b0dd45038e
|
data/CHANGELOG.md
CHANGED
@@ -1,162 +1,167 @@
|
|
1
|
-
Changes
|
2
|
-
=======
|
1
|
+
# Changes
|
3
2
|
|
4
|
-
|
3
|
+
## 1.30 / 2018-06-05
|
4
|
+
|
5
|
+
* [FIX] Change API endpoint. See [#147][].
|
6
|
+
* [FIX] Show more friendly error message with non JSON responses. See [#151][], thanks [@edwardkenfox][].
|
7
|
+
* [FEATURE] Add hosts endpoints. See [#152][].
|
8
|
+
|
9
|
+
## 1.29.0 / 2018-03-23
|
5
10
|
|
6
11
|
* [FEATURE] Add new endpoints for dashboard lists.
|
7
12
|
* [IMPROVEMENT] change http-method GET to POST on api.Screenboard#share. See [#136][] (thanks [@haohcraft][])
|
8
13
|
|
9
|
-
|
14
|
+
## 1.28.0 / 2017-08-16
|
10
15
|
|
11
16
|
* [FEATURE] Accept `group_states` strings for `get_monitor` function. See [#132][] (thanks [@acroos][])
|
12
17
|
* [FEATURE] Add cancel\_by\_scope endpoint. See [#133][] (thanks [@martinisoft][])
|
13
18
|
|
14
|
-
|
19
|
+
## 1.27.0 / 2017-05-01
|
15
20
|
|
16
21
|
* [FEATURE] Add monitor validation endpoint. See [#127][]
|
17
22
|
|
18
|
-
|
23
|
+
## 1.26.0 / 2017-04-10
|
19
24
|
|
20
25
|
* [IMPROVEMENT] Allow additional options to be passed to monitor API calls. See [#125][] (thanks [@jimmyngo][])
|
21
26
|
|
22
|
-
|
27
|
+
## 1.25.0 / 2017-02-14
|
23
28
|
|
24
29
|
* [FEATURE] Add Datadog endpoint for metrics metadata. See [#120][]
|
25
30
|
|
26
|
-
|
31
|
+
## 1.24.0 / 2017-01-12
|
27
32
|
|
28
33
|
* [FEATURE] Add the ability to record events per host and to filter events. See [#115][] (thanks [@hnovikov][])
|
29
34
|
* [BUGFIX] Encode extra\_params to handle spaces. See [#113][] (thanks [@miknight][])
|
30
35
|
* [BUGFIX] Fix CaptureIO delegation and output with Capistrano >= 3.5. See [#114][] (thanks [@casperisfine][])
|
31
36
|
|
32
|
-
|
37
|
+
## 1.23.0 / 2016-08-24
|
33
38
|
|
34
39
|
* [FEATURE] Add Datadog endpoint to configuration. See [#108][]
|
35
40
|
* [FEATURE] Add delete method for events. See [#99][], [#109][]
|
36
41
|
* [IMPROVEMENT] Add Capistrano 3.5+ compatibility. See [#96][]
|
37
42
|
* [OTHER] Code style fixes. See [#106][] (thanks [@nots][])
|
38
43
|
|
39
|
-
|
44
|
+
## 1.22.0 / 2016-04-14
|
40
45
|
This release breaks compatibility with Ruby 1.8.
|
41
46
|
* [FEATURE] Metric query API. See [#88][], [#90][] (thanks [@blakehilscher][])
|
42
47
|
|
43
|
-
|
48
|
+
## 1.21.0 / 2015-10-30
|
44
49
|
This is the last release compatible with Ruby 1.8. ([EOL 2013-06-30](https://www.ruby-lang.org/en/news/2013/06/30/we-retire-1-8-7/))
|
45
50
|
* [FEATURE] User CRUD API. See [#82][]
|
46
51
|
* [IMPROVEMENT] Support capistrano SimpleTextFormatter (thanks [@rmoriz][] [#81][])
|
47
52
|
|
48
|
-
|
53
|
+
## 1.20.0 / 2015-07-29
|
49
54
|
* [FEATURE] Embeddable graphs API. See [#73][]
|
50
55
|
|
51
|
-
|
56
|
+
## 1.19.0 / 2015-06-22
|
52
57
|
* [FEATURE] Revoke a shared a Screenboard. See [#69][]
|
53
58
|
|
54
|
-
|
59
|
+
## 1.18.0 / 2015-06-01
|
55
60
|
* [FEATURE] Add support for host muting.
|
56
61
|
|
57
|
-
|
62
|
+
## 1.17.0 / 2015-03-26
|
58
63
|
* [IMPROVEMENT] Use MultiJSON for JSON handling. (thanks [@winebarrel][] [#64][])
|
59
64
|
|
60
|
-
|
65
|
+
## 1.16.0 / 2015-03-06
|
61
66
|
* [IMPROVEMENT] Return response from API when metrics are sent as a batch. (thanks [@yyuu][] [#62](https://github.com/DataDog/dogapi-rb/pull/62))
|
62
67
|
|
63
|
-
|
68
|
+
## 1.15.0 / 2015-02-03
|
64
69
|
* [BUGFIX] Add open_timeout to avoid stuck HTTP calls (thanks [@Kaixiang][] [#55](https://github.com/DataDog/dogapi-rb/pull/55))
|
65
70
|
* [BUGFIX] Encode capistrano output messages to UTF-8 before manipulating them. (thanks [@byroot][] [#52](https://github.com/DataDog/dogapi-rb/pull/52))
|
66
71
|
|
67
|
-
|
72
|
+
## 1.14.0 / 2015-01-09
|
68
73
|
* [FEATURE] Add get_all_screenboards [#61](https://github.com/DataDog/dogapi-rb/pull/61)
|
69
74
|
* [IMPROVEMENT] Remove required start argument from schedule_downtime [#60](https://github.com/DataDog/dogapi-rb/pull/60)
|
70
75
|
|
71
|
-
|
76
|
+
## 1.13.0 / 2014-12-10
|
72
77
|
* [FEATURE] Add tag filter to get_all_monitors [#58](https://github.com/DataDog/dogapi-rb/pull/58)
|
73
78
|
* [FEATURE] Add update downtime method [#59](https://github.com/DataDog/dogapi-rb/pull/59)
|
74
79
|
|
75
|
-
|
80
|
+
## 1.12.0 / 2014-11-17
|
76
81
|
* [FEATURE] Add support for the Monitor API [#51](https://github.com/DataDog/dogapi-rb/pull/51)
|
77
82
|
* [IMPROVEMENT] Truncate event title and text before submission [#53](https://github.com/DataDog/dogapi-rb/pull/53)
|
78
83
|
|
79
|
-
|
84
|
+
## 1.11.0 / 2014-07-03
|
80
85
|
* [IMPROVEMENT] Add support for HTTP proxy defined by the environment variables
|
81
86
|
* [IMPROVEMENT] Allow to send several metrics in the same HTTP request
|
82
87
|
|
83
|
-
|
88
|
+
## 1.10.0 / 2014-05-13
|
84
89
|
* [IMPROVEMENT] Make HTTP timeout configurable ([#29](https://github.com/DataDog/dogapi-rb/issues/29))
|
85
90
|
* [IMPROVEMENT] Re-enable SSL verification ([#37](https://github.com/DataDog/dogapi-rb/issues/37))
|
86
91
|
* [IMPROVEMENT] Report application name when deploy with Capistrano (thanks [@ArjenSchwarz][] [#46](https://github.com/DataDog/dogapi-rb/pull/46))
|
87
92
|
|
88
|
-
|
93
|
+
## 1.9.2 / 2014-02-13
|
89
94
|
* [IMPROVEMENT] Fully support for capistrano v3 ([#43](https://github.com/DataDog/dogapi-rb/pull/43))
|
90
95
|
* [IMPROVEMENT] Strip control characters from capistrano messages ([#36](https://github.com/DataDog/dogapi-rb/issues/36))
|
91
96
|
* [IMPROVEMENT] Tag capistrano events by stage (thanks [@arielo][] [#25](https://github.com/DataDog/dogapi-rb/pull/25))
|
92
97
|
|
93
|
-
|
98
|
+
## 1.9.1 / 2014-01-06
|
94
99
|
* [IMPROVEMENT] Log a warning instead of crashing when trying to integration with capistrano v3
|
95
100
|
|
96
|
-
|
101
|
+
## 1.9.0 / 2013-09-06
|
97
102
|
* [IMPROVEMENT] When emitting a metric without an explicit host, default to local hostname.
|
98
103
|
|
99
|
-
|
104
|
+
## 1.8.1 / 2013-08-22
|
100
105
|
* [FEATURE] Update Dash API to support template variables.
|
101
106
|
|
102
|
-
|
107
|
+
## 1.8.0 / 2013-07-16
|
103
108
|
* [FEATURE] Add an API for interacting with Screenboards
|
104
109
|
|
105
|
-
|
110
|
+
## 1.7.1 / 2013-06-23
|
106
111
|
* [BUGFIX] Fix bug in capistrano integration with logging of nil (thanks [@arielo][])
|
107
112
|
* [FEATURE] Add an API for inviting users
|
108
113
|
* [FEATURE] Add an API for taking graph snapshots
|
109
114
|
|
110
|
-
|
115
|
+
## 1.7.0
|
111
116
|
* Not released.
|
112
117
|
|
113
|
-
|
118
|
+
## 1.6.0 / 2013-02-19
|
114
119
|
* [FEATURE] Support for setting `source` type when submitting host tags
|
115
120
|
|
116
|
-
|
121
|
+
## 1.5.2 / 2013-02-13
|
117
122
|
* [BUGFIX] Fix a bug in hashing the Event object when the instance variables are symbols.
|
118
123
|
|
119
|
-
|
124
|
+
## 1.5.0 / 2012-11-06
|
120
125
|
* [FEATURE] Alerting API
|
121
126
|
|
122
|
-
|
127
|
+
## 1.4.3
|
123
128
|
* [BUGFIX] Fix bug with capistrano integration for capistrano 2.13.5 (thanks [@ansel1][])
|
124
129
|
|
125
|
-
|
130
|
+
## 1.4.2
|
126
131
|
* [BUGFIX] Added missing dashboards endpoint.
|
127
132
|
|
128
|
-
|
133
|
+
## 1.4.1
|
129
134
|
* [BUGFIX] Fixed searching for events with tags.
|
130
135
|
|
131
|
-
|
136
|
+
## 1.4.0
|
132
137
|
* [FEATURE] Added support for the dashboard, search and comment API endpoints.
|
133
138
|
|
134
|
-
|
139
|
+
## 1.3.6
|
135
140
|
* [BUGFIX] Small fix for capistrano integration
|
136
141
|
|
137
|
-
|
142
|
+
## 1.3.4
|
138
143
|
* [BUGFIX] Various bug fixes (event.to_hash, md5 import, capistrano lambda roles)
|
139
144
|
|
140
|
-
|
145
|
+
## 1.3.3
|
141
146
|
* [BUGFIX] Bug fix for submitting counters
|
142
147
|
|
143
|
-
|
148
|
+
## 1.3.2
|
144
149
|
* [IMPROVEMENT] Support an aggregation key to aggregate events together
|
145
150
|
|
146
|
-
|
151
|
+
## 1.3.1
|
147
152
|
* [FEATURE] Metrics can be counters, rather than just gauges (thanks to [@treeder][])
|
148
153
|
* [FEATURE] Metrics can be tagged.
|
149
154
|
|
150
|
-
|
155
|
+
## 1.3.0
|
151
156
|
* [FEATURE] Capistrano integration. See https://github.com/DataDog/dogapi-rb/tree/master/lib/capistrano
|
152
157
|
|
153
|
-
|
158
|
+
## 1.2.x
|
154
159
|
* [FEATURE] You can now manage host tags
|
155
160
|
* [IMPROVEMENT] Functionality relating to events with a duration has been deprecated
|
156
161
|
* [IMPROVEMENT] The underlying clients have been updated to use Datadog's new public HTTP API[https://github.com/DataDog/dogapi/wiki]
|
157
162
|
* [IMPROVEMENT] You can now get event details and query the stream in addition to posting events
|
158
163
|
|
159
|
-
|
164
|
+
## 1.1.x
|
160
165
|
* [IMPROVEMENT] You do not need to use environment variables anymore to use the client.
|
161
166
|
|
162
167
|
<!--- The following link definition list is generated by PimpMyChangelog --->
|
@@ -196,6 +201,9 @@ This is the last release compatible with Ruby 1.8. ([EOL 2013-06-30](https://www
|
|
196
201
|
[#132]: https://github.com/DataDog/dogapi-rb/issues/132
|
197
202
|
[#133]: https://github.com/DataDog/dogapi-rb/issues/133
|
198
203
|
[#136]: https://github.com/DataDog/dogapi-rb/issues/136
|
204
|
+
[#147]: https://github.com/DataDog/dogapi-rb/issues/147
|
205
|
+
[#151]: https://github.com/DataDog/dogapi-rb/issues/151
|
206
|
+
[#152]: https://github.com/DataDog/dogapi-rb/issues/152
|
199
207
|
[@ArjenSchwarz]: https://github.com/ArjenSchwarz
|
200
208
|
[@Kaixiang]: https://github.com/Kaixiang
|
201
209
|
[@acroos]: https://github.com/acroos
|
@@ -204,6 +212,7 @@ This is the last release compatible with Ruby 1.8. ([EOL 2013-06-30](https://www
|
|
204
212
|
[@blakehilscher]: https://github.com/blakehilscher
|
205
213
|
[@byroot]: https://github.com/byroot
|
206
214
|
[@casperisfine]: https://github.com/casperisfine
|
215
|
+
[@edwardkenfox]: https://github.com/edwardkenfox
|
207
216
|
[@haohcraft]: https://github.com/haohcraft
|
208
217
|
[@hnovikov]: https://github.com/hnovikov
|
209
218
|
[@jimmyngo]: https://github.com/jimmyngo
|
data/lib/dogapi/common.rb
CHANGED
@@ -148,6 +148,8 @@ module Dogapi
|
|
148
148
|
begin
|
149
149
|
return resp.code, MultiJson.load(resp.body)
|
150
150
|
rescue
|
151
|
+
is_json = resp.content_type == 'application/json'
|
152
|
+
raise "Response Content-Type is not application/json but is #{resp.content_type}: " + resp.body unless is_json
|
151
153
|
raise 'Invalid JSON Response: ' + resp.body
|
152
154
|
end
|
153
155
|
end
|
@@ -155,7 +157,7 @@ module Dogapi
|
|
155
157
|
|
156
158
|
def Dogapi.find_datadog_host
|
157
159
|
# allow env-based overriding, useful for tests
|
158
|
-
ENV['DATADOG_HOST'] || 'https://
|
160
|
+
ENV['DATADOG_HOST'] || 'https://api.datadoghq.com'
|
159
161
|
end
|
160
162
|
|
161
163
|
# Memoize the hostname as a module variable
|
data/lib/dogapi/facade.rb
CHANGED
@@ -45,6 +45,7 @@ module Dogapi
|
|
45
45
|
@service_check_svc = Dogapi::V1::ServiceCheckService.new(@api_key, @application_key, silent, timeout, @datadog_host)
|
46
46
|
@metadata_svc = Dogapi::V1::MetadataService.new(@api_key, @application_key, silent, timeout, @datadog_host)
|
47
47
|
@legacy_event_svc = Dogapi::EventService.new(@datadog_host)
|
48
|
+
@hosts_svc = Dogapi::V1::HostsService.new(@api_key, @application_key, silent, timeout, @datadog_host)
|
48
49
|
end
|
49
50
|
|
50
51
|
#
|
@@ -548,6 +549,18 @@ module Dogapi
|
|
548
549
|
@metadata_svc.update(metric, options)
|
549
550
|
end
|
550
551
|
|
552
|
+
#
|
553
|
+
# HOSTS
|
554
|
+
#
|
555
|
+
|
556
|
+
def search_hosts(options = {})
|
557
|
+
@hosts_svc.search(options)
|
558
|
+
end
|
559
|
+
|
560
|
+
def host_totals()
|
561
|
+
@hosts_svc.totals()
|
562
|
+
end
|
563
|
+
|
551
564
|
private
|
552
565
|
|
553
566
|
def override_scope(options= {})
|
data/lib/dogapi/v1.rb
CHANGED
@@ -0,0 +1,21 @@
|
|
1
|
+
require 'dogapi'
|
2
|
+
|
3
|
+
module Dogapi
|
4
|
+
class V1 # for namespacing
|
5
|
+
|
6
|
+
# Hosts API
|
7
|
+
class HostsService < Dogapi::APIService
|
8
|
+
|
9
|
+
API_VERSION = 'v1'
|
10
|
+
|
11
|
+
def search(options = {})
|
12
|
+
request(Net::HTTP::Get, "/api/#{API_VERSION}/hosts", nil, options, true)
|
13
|
+
end
|
14
|
+
|
15
|
+
def totals
|
16
|
+
request(Net::HTTP::Get, "/api/#{API_VERSION}/hosts/totals", nil, nil, true)
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
end
|
21
|
+
end
|
data/lib/dogapi/v1/search.rb
CHANGED
@@ -8,6 +8,13 @@ module Dogapi
|
|
8
8
|
API_VERSION = 'v1'
|
9
9
|
|
10
10
|
def search(query)
|
11
|
+
# Deprecating search for hosts
|
12
|
+
split_query = query.split(':')
|
13
|
+
if split_query.length > 1 && split_query[0] == 'hosts'
|
14
|
+
warn '[DEPRECATION] Dogapi::V1::SearchService::search has been '\
|
15
|
+
'deprecated for hosts in favor of Dogapi::V1::HostsService::search'
|
16
|
+
end
|
17
|
+
|
11
18
|
extra_params = {
|
12
19
|
:q => query
|
13
20
|
}
|
data/lib/dogapi/version.rb
CHANGED
data/spec/spec_helper.rb
CHANGED
@@ -11,7 +11,7 @@ WebMock.disable_net_connect!(allow_localhost: false)
|
|
11
11
|
# include our code and methods
|
12
12
|
require 'dogapi'
|
13
13
|
|
14
|
-
DATADOG_HOST = '
|
14
|
+
DATADOG_HOST = 'api.datadoghq.com'.freeze
|
15
15
|
ENV['DATADOG_HOST'] = 'http://' + DATADOG_HOST
|
16
16
|
|
17
17
|
module SpecDog
|
data/spec/unit/common_spec.rb
CHANGED
@@ -41,11 +41,12 @@ describe 'Common' do
|
|
41
41
|
end
|
42
42
|
|
43
43
|
class FakeResponse
|
44
|
-
attr_accessor :code, :body
|
45
|
-
def initialize(code, body)
|
44
|
+
attr_accessor :code, :body, :content_type
|
45
|
+
def initialize(code, body, content_type = 'application/json')
|
46
46
|
# Instance variables
|
47
47
|
@code = code
|
48
48
|
@body = body
|
49
|
+
@content_type = content_type
|
49
50
|
end
|
50
51
|
end
|
51
52
|
|
@@ -86,6 +87,14 @@ describe Dogapi::APIService do
|
|
86
87
|
expect { dog.handle_response(resp) }.to raise_error(RuntimeError, "Invalid JSON Response: {'test2': }")
|
87
88
|
end
|
88
89
|
end
|
90
|
+
context 'when receiving a non json response' do
|
91
|
+
it 'raises an error indicating the response Content-Type' do
|
92
|
+
dog = dogapi_service
|
93
|
+
resp = FakeResponse.new 202, '<html><body><h1>403 Forbidden</h1>', 'text/html'
|
94
|
+
msg = 'Response Content-Type is not application/json but is text/html: <html><body><h1>403 Forbidden</h1>'
|
95
|
+
expect { dog.handle_response(resp) }.to raise_error(RuntimeError, msg)
|
96
|
+
end
|
97
|
+
end
|
89
98
|
context 'when receiving a bad response' do
|
90
99
|
it 'returns the error code and an empty body' do
|
91
100
|
dog = dogapi_service
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dogapi
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: '1.30'
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Datadog, Inc.
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-
|
11
|
+
date: 2018-06-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: multi_json
|
@@ -105,6 +105,7 @@ files:
|
|
105
105
|
- lib/dogapi/v1/dashboard_list.rb
|
106
106
|
- lib/dogapi/v1/embed.rb
|
107
107
|
- lib/dogapi/v1/event.rb
|
108
|
+
- lib/dogapi/v1/hosts.rb
|
108
109
|
- lib/dogapi/v1/metadata.rb
|
109
110
|
- lib/dogapi/v1/metric.rb
|
110
111
|
- lib/dogapi/v1/monitor.rb
|