dogapi 1.17.0 → 1.18.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: be1e947eab5207067682560c93fabcc7d9779b99
4
- data.tar.gz: 26b9e3109d438f8462d18d5200afa3890ddf0649
3
+ metadata.gz: 4a0168ec9732a98699a3c482343009150d400c12
4
+ data.tar.gz: c85ddc87c5fea88a8e33908200170edcce90462f
5
5
  SHA512:
6
- metadata.gz: 5057de8aa09b993a458580d79a6677e854cedf2838b7890268ff51baa2f9fd2ef49d67a6181a0c9015a48de58496496b7b3e0be2cff69a7a84ff234774992e6e
7
- data.tar.gz: 57de459aaa7d3a09f73bc9a9515ab12be75a865ee3690217faef11f6af6ace12e3422f9f5c2d2713d0e5b8032b8b43794276475e6b8b2c1d6eb8cba3265e41e9
6
+ metadata.gz: 6f5b5a3042667d4b4994381bea615c07cfe6d90aad63a8fb402c20c53e541c5e39318e74420155dccdc63afc159f17f1ada861ea1f99d59c473f7b81a3f25449
7
+ data.tar.gz: 4daad67757975dce8b26e21cb87066ef4613185c8a0f84d54a40e8f760eb9d3e80bbd79cef81b87e4e038519ce975be7cc2445535304ca8ad9bc19b4e770c40d
data/.travis.yml CHANGED
@@ -1,3 +1,4 @@
1
+ sudo: false
1
2
  language: ruby
2
3
  rvm:
3
4
  - 1.9.3
data/CHANGELOG.md CHANGED
@@ -1,5 +1,9 @@
1
1
  Changes
2
2
  =======
3
+
4
+ # 1.18.0 / 2015-06-01
5
+ * Add support for host muting.
6
+
3
7
  # 1.17.0 / 2015-03-26
4
8
  * Use MultiJSON for JSON handling. (thanks [@winebarrel][] [#64][])
5
9
 
@@ -129,4 +133,4 @@ Changes
129
133
  [@byroot]: https://github.com/byroot
130
134
  [@treeder]: https://github.com/treeder
131
135
  [@winebarrel]: https://github.com/winebarrel
132
- [@yyuu]: https://github.com/yyuu
136
+ [@yyuu]: https://github.com/yyuu
data/lib/dogapi/facade.rb CHANGED
@@ -386,6 +386,18 @@ module Dogapi
386
386
  @monitor_svc.get_all_downtimes(options)
387
387
  end
388
388
 
389
+ #
390
+ # HOST MUTING
391
+ #
392
+
393
+ def mute_host(hostname, options = {})
394
+ @monitor_svc.mute_host(hostname, options)
395
+ end
396
+
397
+ def unmute_host(hostname)
398
+ @monitor_svc.unmute_host(hostname)
399
+ end
400
+
389
401
  #
390
402
  # SERVICE CHECKS
391
403
  #
@@ -231,6 +231,33 @@ module Dogapi
231
231
  end
232
232
  end
233
233
 
234
+ #
235
+ # HOST MUTING
236
+
237
+ def mute_host(hostname, options = {})
238
+ begin
239
+ params = {
240
+ :api_key => @api_key,
241
+ :application_key => @application_key
242
+ }
243
+
244
+ request(Net::HTTP::Post, "/api/#{API_VERSION}/host/#{hostname}/mute", params, options, true)
245
+ rescue Exception => e
246
+ suppress_error_if_silent e
247
+ end
248
+ end
249
+ def unmute_host(hostname)
250
+ begin
251
+ params = {
252
+ :api_key => @api_key,
253
+ :application_key => @application_key
254
+ }
255
+
256
+ request(Net::HTTP::Post, "/api/#{API_VERSION}/host/#{hostname}/unmute", params, nil, true)
257
+ rescue Exception => e
258
+ suppress_error_if_silent e
259
+ end
260
+ end
234
261
  end
235
262
 
236
263
  end
@@ -1,3 +1,3 @@
1
1
  module Dogapi
2
- VERSION = "1.17.0"
2
+ VERSION = "1.18.0"
3
3
  end
@@ -148,6 +148,40 @@ class TestAlerts < Test::Unit::TestCase
148
148
  dog.cancel_downtime(downtime_id)
149
149
  end
150
150
 
151
+ def test_host_muting
152
+ dog = Dogapi::Client.new(@api_key, @app_key)
153
+ hostname = 'test.host'
154
+
155
+ # Reset test
156
+ dog.unmute_host(hostname)
157
+
158
+ message = "Muting this host for a test."
159
+ end_ts = Time.now.to_i + 60 * 60
160
+
161
+ res_code, res = dog.mute_host(hostname, :end => end_ts, :message => message)
162
+ assert_equal res_code, "200", res_code
163
+ assert_equal res["action"], "Muted", res["action"]
164
+ assert_equal res["hostname"], hostname, res["hostname"]
165
+ assert_equal res["message"], message, res["message"]
166
+ assert_equal res["end"], end_ts, res["end"]
167
+
168
+ # muting the same host multiple times should fail unless override is true
169
+ end_ts2 = end_ts + 60 * 15
170
+ res_code, res = dog.mute_host(hostname, :end => end_ts2)
171
+ assert_equal res_code, "400", res_code
172
+
173
+ res_code, res = dog.mute_host(hostname, :end => end_ts2, :override => true)
174
+ assert_equal res_code, "200", res_code
175
+ assert_equal res["action"], "Muted", res["action"]
176
+ assert_equal res["hostname"], hostname, res["hostname"]
177
+ assert_equal res["end"], end_ts2, res["end"]
178
+
179
+ res_code, res = dog.unmute_host(hostname)
180
+ assert_equal res_code, "200", res_code
181
+ assert_equal res["action"], "Unmuted", res["action"]
182
+ assert_equal res["hostname"], hostname, res["hostname"]
183
+ end
184
+
151
185
  def test_service_checks
152
186
  dog = Dogapi::Client.new(@api_key, @app_key)
153
187
  status, response = dog.service_check('app.ok', 'app1', 1)
metadata CHANGED
@@ -1,69 +1,69 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dogapi
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.17.0
4
+ version: 1.18.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Datadog, Inc.
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-03-26 00:00:00.000000000 Z
11
+ date: 2015-06-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: multi_json
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - '>='
17
+ - - ">="
18
18
  - !ruby/object:Gem::Version
19
19
  version: '0'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - '>='
24
+ - - ">="
25
25
  - !ruby/object:Gem::Version
26
26
  version: '0'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: bundler
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - ~>
31
+ - - "~>"
32
32
  - !ruby/object:Gem::Version
33
33
  version: '1.3'
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - ~>
38
+ - - "~>"
39
39
  - !ruby/object:Gem::Version
40
40
  version: '1.3'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: rake
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - ~>
45
+ - - "~>"
46
46
  - !ruby/object:Gem::Version
47
47
  version: '10'
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - ~>
52
+ - - "~>"
53
53
  - !ruby/object:Gem::Version
54
54
  version: '10'
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: rdoc
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
- - - '>='
59
+ - - ">="
60
60
  - !ruby/object:Gem::Version
61
61
  version: '0'
62
62
  type: :development
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
- - - '>='
66
+ - - ">="
67
67
  - !ruby/object:Gem::Version
68
68
  version: '0'
69
69
  description: Ruby bindings for Datadog's API
@@ -74,10 +74,10 @@ extensions: []
74
74
  extra_rdoc_files:
75
75
  - README.rdoc
76
76
  files:
77
- - .gitignore
78
- - .rspec
79
- - .tailor
80
- - .travis.yml
77
+ - ".gitignore"
78
+ - ".rspec"
79
+ - ".tailor"
80
+ - ".travis.yml"
81
81
  - CHANGELOG.md
82
82
  - Gemfile
83
83
  - LICENSE
@@ -142,27 +142,27 @@ licenses:
142
142
  metadata: {}
143
143
  post_install_message:
144
144
  rdoc_options:
145
- - --title
145
+ - "--title"
146
146
  - DogAPI -- Datadog Client
147
- - --main
147
+ - "--main"
148
148
  - README.rdoc
149
- - --line-numbers
150
- - --inline-source
149
+ - "--line-numbers"
150
+ - "--inline-source"
151
151
  require_paths:
152
152
  - lib
153
153
  required_ruby_version: !ruby/object:Gem::Requirement
154
154
  requirements:
155
- - - '>='
155
+ - - ">="
156
156
  - !ruby/object:Gem::Version
157
157
  version: '0'
158
158
  required_rubygems_version: !ruby/object:Gem::Requirement
159
159
  requirements:
160
- - - '>='
160
+ - - ">="
161
161
  - !ruby/object:Gem::Version
162
162
  version: '0'
163
163
  requirements: []
164
164
  rubyforge_project:
165
- rubygems_version: 2.0.14
165
+ rubygems_version: 2.2.2
166
166
  signing_key:
167
167
  specification_version: 4
168
168
  summary: Ruby bindings for Datadog's API
@@ -183,4 +183,3 @@ test_files:
183
183
  - spec/support/cassettes/Facade/Events/emits_events_and_retrieves_them.yml
184
184
  - spec/support/cassettes/Facade/Events/emits_events_with_specified_priority.yml
185
185
  - spec/support/cassettes/Facade/Tags/adds_updates_and_detaches_tags.yml
186
- has_rdoc: true