dogapi 1.24.0 → 1.25.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: b8af26835da807d734048331e326f41734ad0d43
4
- data.tar.gz: f7adbdd5a2a4afa6ae81d39a8250ad74692656ef
3
+ metadata.gz: 75fa2cad892972518ea3174bb4422c9d60462aa6
4
+ data.tar.gz: c7856800aaf8f41a50a51930d28f2f6726bdcd96
5
5
  SHA512:
6
- metadata.gz: 9c679456882e5e7babf2cee567f0cdd1f4bf67c477b07a7e3195c0103b704fd9131569564df1c43583832635ffcb794c8ebe91952d2ecee5353f58f28f062f8f
7
- data.tar.gz: 54df8543e2c6b0fb4d771b323d01c3190ac1204fb7cf138c83f16b3579dea6003712f46723f7b481399053ea807ada33ef23a6717edfe789afee309af16b7b9b
6
+ metadata.gz: 14b6376e95b9c4090dbd91f860c9b3dd7c51d119e516416d8fbbd3d2bf999024d382c170e46d6fec688cfd274116dd1b585bc6da6844bf40f62ca8535d30263a
7
+ data.tar.gz: dd880166b4ec0a3aa8fd7e3943374cf635f0cf0341eefa28c52a9742bab9f1e526947611b180e8855f5ef5a5d6445eaa25ef0ac027cd50703403328468bc0d26
data/.gitignore CHANGED
@@ -9,3 +9,6 @@ coverage
9
9
  doc/
10
10
  pkg/
11
11
  .idea
12
+ vendor/
13
+ .bundle/
14
+ *.gem
data/.tailor CHANGED
@@ -89,7 +89,7 @@ Tailor.config do |config|
89
89
  style.allow_invalid_ruby false, level: :warn
90
90
  style.indentation_spaces 2, level: :error
91
91
  style.max_code_lines_in_class 300, level: :error
92
- style.max_code_lines_in_method 33, level: :error
92
+ style.max_code_lines_in_method 34, level: :error
93
93
  style.max_line_length 160, level: :warn
94
94
  style.spaces_after_comma 1, level: :error
95
95
  style.spaces_after_lbrace 1, level: :error
@@ -1,6 +1,10 @@
1
1
  Changes
2
2
  =======
3
3
 
4
+ # 1.25.0 / UNRELEASED
5
+
6
+ * [FEATURE] Add Datadog endpoint for metrics metadata. See [#120][]
7
+
4
8
  # 1.24.0 / 2017-01-12
5
9
 
6
10
  * [FEATURE] Add the ability to record events per host and to filter events. See [#115][] (thanks [@hnovikov][])
@@ -168,6 +172,7 @@ This is the last release compatible with Ruby 1.8. ([EOL 2013-06-30](https://www
168
172
  [#113]: https://github.com/DataDog/dogapi-rb/issues/113
169
173
  [#114]: https://github.com/DataDog/dogapi-rb/issues/114
170
174
  [#115]: https://github.com/DataDog/dogapi-rb/issues/115
175
+ [#120]: https://github.com/DataDog/dogapi-rb/issues/120
171
176
  [@ArjenSchwarz]: https://github.com/ArjenSchwarz
172
177
  [@Kaixiang]: https://github.com/Kaixiang
173
178
  [@ansel1]: https://github.com/ansel1
@@ -181,4 +186,4 @@ This is the last release compatible with Ruby 1.8. ([EOL 2013-06-30](https://www
181
186
  [@rmoriz]: https://github.com/rmoriz
182
187
  [@treeder]: https://github.com/treeder
183
188
  [@winebarrel]: https://github.com/winebarrel
184
- [@yyuu]: https://github.com/yyuu
189
+ [@yyuu]: https://github.com/yyuu
@@ -37,6 +37,7 @@ module Dogapi
37
37
  @screenboard_svc = Dogapi::V1::ScreenboardService.new(@api_key, @application_key, silent, timeout, @datadog_host)
38
38
  @monitor_svc = Dogapi::V1::MonitorService.new(@api_key, @application_key, silent, timeout, @datadog_host)
39
39
  @service_check_svc = Dogapi::V1::ServiceCheckService.new(@api_key, @application_key, silent, timeout, @datadog_host)
40
+ @metadata_svc = Dogapi::V1::MetadataService.new(@api_key, @application_key, silent, timeout, @datadog_host)
40
41
  @legacy_event_svc = Dogapi::EventService.new(@datadog_host)
41
42
  end
42
43
 
@@ -467,6 +468,32 @@ module Dogapi
467
468
  @service_check_svc.service_check(check, host, status, options)
468
469
  end
469
470
 
471
+ #
472
+ # METADATA
473
+ #
474
+
475
+ # Get metadata information on an existing Datadog metric
476
+ def get_metadata(metric)
477
+ @metadata_svc.get(metric)
478
+ end
479
+
480
+ # Update metadata fields for an existing Datadog metric.
481
+ # If the metadata does not exist for the metric it is created by
482
+ # the update.
483
+ # Optional arguments:
484
+ # :type => String, type of the metric (ex. "gauge", "rate", etc.)
485
+ # see http://docs.datadoghq.com/metrictypes/
486
+ # :description => String, description of the metric
487
+ # :short_name => String, short name of the metric
488
+ # :unit => String, unit type associated with the metric (ex. "byte", "operation")
489
+ # see http://docs.datadoghq.com/units/ for full list
490
+ # :per_unit => String, per unit type (ex. "second" as in "queries per second")
491
+ # see http://docs.datadoghq.com/units/ for full
492
+ # :statsd_interval => Integer, statsd flush interval for metric in seconds (if applicable)
493
+ def update_metadata(metric, options= {})
494
+ @metadata_svc.update(metric, options)
495
+ end
496
+
470
497
  private
471
498
 
472
499
  def override_scope(options= {})
@@ -1,13 +1,14 @@
1
- require 'dogapi/v1/event'
2
- require 'dogapi/v1/metric'
3
- require 'dogapi/v1/tag'
1
+ require 'dogapi/v1/alert'
4
2
  require 'dogapi/v1/comment'
5
- require 'dogapi/v1/search'
6
3
  require 'dogapi/v1/dash'
7
- require 'dogapi/v1/alert'
8
- require 'dogapi/v1/user'
9
- require 'dogapi/v1/snapshot'
10
4
  require 'dogapi/v1/embed'
11
- require 'dogapi/v1/screenboard'
5
+ require 'dogapi/v1/event'
6
+ require 'dogapi/v1/metadata'
7
+ require 'dogapi/v1/metric'
12
8
  require 'dogapi/v1/monitor'
9
+ require 'dogapi/v1/screenboard'
10
+ require 'dogapi/v1/search'
13
11
  require 'dogapi/v1/service_check'
12
+ require 'dogapi/v1/snapshot'
13
+ require 'dogapi/v1/tag'
14
+ require 'dogapi/v1/user'
@@ -0,0 +1,20 @@
1
+ require 'dogapi'
2
+
3
+ module Dogapi
4
+ class V1
5
+
6
+ class MetadataService < Dogapi::APIService
7
+
8
+ API_VERSION = 'v1'
9
+
10
+ def get(metric_name)
11
+ request(Net::HTTP::Get, "/api/#{API_VERSION}/metrics/#{metric_name}", nil, nil, false)
12
+ end
13
+
14
+ def update(metric_name, options = {})
15
+ request(Net::HTTP::Put, "/api/#{API_VERSION}/metrics/#{metric_name}", nil, options, true)
16
+ end
17
+ end
18
+
19
+ end
20
+ end
@@ -1,3 +1,3 @@
1
1
  module Dogapi
2
- VERSION = '1.24.0'
2
+ VERSION = '1.25.0'
3
3
  end
@@ -0,0 +1,17 @@
1
+ require_relative '../spec_helper'
2
+
3
+ describe Dogapi::Client do
4
+ METRIC_NAME = 'my.metric'.freeze
5
+
6
+ describe '#get_metadata' do
7
+ it_behaves_like 'an api method',
8
+ :get_metadata, [METRIC_NAME],
9
+ :get, '/metrics/' + METRIC_NAME
10
+ end
11
+
12
+ describe '#update_metadata' do
13
+ it_behaves_like 'an api method with options',
14
+ :update_metadata, [METRIC_NAME],
15
+ :put, '/metrics/' + METRIC_NAME, {}
16
+ end
17
+ end
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.24.0
4
+ version: 1.25.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: 2017-01-12 00:00:00.000000000 Z
11
+ date: 2017-02-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: multi_json
@@ -103,6 +103,7 @@ files:
103
103
  - lib/dogapi/v1/dash.rb
104
104
  - lib/dogapi/v1/embed.rb
105
105
  - lib/dogapi/v1/event.rb
106
+ - lib/dogapi/v1/metadata.rb
106
107
  - lib/dogapi/v1/metric.rb
107
108
  - lib/dogapi/v1/monitor.rb
108
109
  - lib/dogapi/v1/screenboard.rb
@@ -118,6 +119,7 @@ files:
118
119
  - spec/integration/dash_spec.rb
119
120
  - spec/integration/embed_spec.rb
120
121
  - spec/integration/event_spec.rb
122
+ - spec/integration/metadata_spec.rb
121
123
  - spec/integration/metric_spec.rb
122
124
  - spec/integration/monitor_spec.rb
123
125
  - spec/integration/screenboard_spec.rb
@@ -166,6 +168,7 @@ test_files:
166
168
  - spec/integration/dash_spec.rb
167
169
  - spec/integration/embed_spec.rb
168
170
  - spec/integration/event_spec.rb
171
+ - spec/integration/metadata_spec.rb
169
172
  - spec/integration/metric_spec.rb
170
173
  - spec/integration/monitor_spec.rb
171
174
  - spec/integration/screenboard_spec.rb