dogapi 1.32.0 → 1.33.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: bb35c84da1609020a097b950e0b5ed81425ffee7b4891f723541e97f9b10777b
4
- data.tar.gz: dd495d053ac3704d69512bdca0ed25db64e68cf8ce400143ebb27533d8261728
3
+ metadata.gz: ec1cf46eb8ec6d3e512ac08b5385d62d70f6f28caa48a7681724cdacefc68b45
4
+ data.tar.gz: 47ca869de7d878e680a8bf1f12c315a02a9075d452aa7f1bb69100c03e8ccb11
5
5
  SHA512:
6
- metadata.gz: cafcc7e0883a743adbfa82c1fce713e5b6e6bebf67c4337c8c7cca91a10d7c844a58280e9adbaf120de09984a1b05462b31b0c5391629fe5d6b926358c0ae6ef
7
- data.tar.gz: 732984573605a233f81de6f17d6f8b2cbe3d4d1e158dbe2206a2b0ef2c443266c0b31f8a71995369a41e8aafff2164187b0c7fcd9166e11a3b683d3d43919481
6
+ metadata.gz: 54c9fe2f7463c547e96c769e0cfd9d8f30c4ebe4651c1d921d8737d4ba4c901b899d6b990e41ed221e008dc7d419ddac8e4f7a6989a2c39879763aa4c2d85fbb
7
+ data.tar.gz: bbe2fb112fb558b719896153ad7016e787ca376cc40f68e22ab7fe2e24ae2957ee52c2868d148958e613d49e8e3e3abaeb85752ec7f404d3eb76d97ddf1ceccd
@@ -1,4 +1,3 @@
1
- sudo: false
2
1
  language: ruby
3
2
  rvm:
4
3
  - 2.0
@@ -1,9 +1,14 @@
1
1
  # Changes
2
2
 
3
+ ## 1.33.0 / 2019-02-13
4
+
5
+ * [IMPROVEMENT] Add submission types mentioned in the API documentation. See [#165][], thanks [@TaylURRE][]
6
+ * [FEATURE] Add support for the new Dashboard API. See [#167][], thanks [@enbashi][]
7
+
3
8
  ## 1.32.0 / 2018-10-23
4
9
 
5
- * [FEATURE] Added [monitor search](https://docs.datadoghq.com/api/?lang=ruby#monitors-search) and [monitor groups search](https://docs.datadoghq.com/api/?lang=ruby#monitors-group-search) API endpoints. See #163.
6
- * [FIX] Add project metadata to the gemspec. See #162, thanks @orien.
10
+ * [FEATURE] Added [monitor search](https://docs.datadoghq.com/api/?lang=ruby#monitors-search) and [monitor groups search](https://docs.datadoghq.com/api/?lang=ruby#monitors-group-search) API endpoints. See [#163][].
11
+ * [FIX] Add project metadata to the gemspec. See [#162][], thanks [@orien][].
7
12
 
8
13
  ## 1.31.0 / 2018-10-01
9
14
 
@@ -216,8 +221,13 @@ This is the last release compatible with Ruby 1.8. ([EOL 2013-06-30](https://www
216
221
  [#152]: https://github.com/DataDog/dogapi-rb/issues/152
217
222
  [#159]: https://github.com/DataDog/dogapi-rb/issues/159
218
223
  [#160]: https://github.com/DataDog/dogapi-rb/issues/160
224
+ [#162]: https://github.com/DataDog/dogapi-rb/issues/162
225
+ [#163]: https://github.com/DataDog/dogapi-rb/issues/163
226
+ [#165]: https://github.com/DataDog/dogapi-rb/issues/165
227
+ [#167]: https://github.com/DataDog/dogapi-rb/issues/167
219
228
  [@ArjenSchwarz]: https://github.com/ArjenSchwarz
220
229
  [@Kaixiang]: https://github.com/Kaixiang
230
+ [@TaylURRE]: https://github.com/TaylURRE
221
231
  [@acroos]: https://github.com/acroos
222
232
  [@ansel1]: https://github.com/ansel1
223
233
  [@arielo]: https://github.com/arielo
@@ -225,13 +235,15 @@ This is the last release compatible with Ruby 1.8. ([EOL 2013-06-30](https://www
225
235
  [@byroot]: https://github.com/byroot
226
236
  [@casperisfine]: https://github.com/casperisfine
227
237
  [@edwardkenfox]: https://github.com/edwardkenfox
238
+ [@enbashi]: https://github.com/enbashi
228
239
  [@haohcraft]: https://github.com/haohcraft
229
240
  [@hnovikov]: https://github.com/hnovikov
230
241
  [@jimmyngo]: https://github.com/jimmyngo
231
242
  [@martinisoft]: https://github.com/martinisoft
232
243
  [@miknight]: https://github.com/miknight
233
244
  [@nots]: https://github.com/nots
245
+ [@orien]: https://github.com/orien
234
246
  [@rmoriz]: https://github.com/rmoriz
235
247
  [@treeder]: https://github.com/treeder
236
248
  [@winebarrel]: https://github.com/winebarrel
237
- [@yyuu]: https://github.com/yyuu
249
+ [@yyuu]: https://github.com/yyuu
@@ -25,7 +25,6 @@ Gem::Specification.new do |spec|
25
25
  spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
26
26
  spec.require_paths = ["lib"]
27
27
 
28
- spec.has_rdoc = true
29
28
  spec.extra_rdoc_files = ['README.rdoc']
30
29
  spec.rdoc_options << '--title' << 'DogAPI -- Datadog Client' <<
31
30
  '--main' << 'README.rdoc' <<
@@ -33,7 +32,7 @@ Gem::Specification.new do |spec|
33
32
 
34
33
  spec.add_dependency 'multi_json'
35
34
 
36
- spec.add_development_dependency 'bundler', '~> 1.3'
35
+ spec.add_development_dependency 'bundler', '>= 1.3'
37
36
  spec.add_development_dependency 'rake', '~> 10'
38
37
  spec.add_development_dependency 'rdoc'
39
38
  end
@@ -34,6 +34,7 @@ module Dogapi
34
34
  @comment_svc = Dogapi::V1::CommentService.new(@api_key, @application_key, silent, timeout, @datadog_host)
35
35
  @search_svc = Dogapi::V1::SearchService.new(@api_key, @application_key, silent, timeout, @datadog_host)
36
36
  @dash_service = Dogapi::V1::DashService.new(@api_key, @application_key, silent, timeout, @datadog_host)
37
+ @dashboard_service = Dogapi::V1::DashboardService.new(@api_key, @application_key, silent, timeout, @datadog_host)
37
38
  @dashboard_list_service = Dogapi::V1::DashboardListService.new(
38
39
  @api_key, @application_key, silent, timeout, @datadog_host
39
40
  )
@@ -276,6 +277,30 @@ module Dogapi
276
277
  @dash_service.delete_dashboard(dash_id)
277
278
  end
278
279
 
280
+ #
281
+ # DASHBOARDS
282
+ #
283
+
284
+ # Create a dashboard.
285
+ def create_board(title, widgets, layout_type, options= {})
286
+ @dashboard_service.create_board(title, widgets, layout_type, options)
287
+ end
288
+
289
+ # Update a dashboard.
290
+ def update_board(dashboard_id, title, widgets, layout_type, options= {})
291
+ @dashboard_service.update_board(dashboard_id, title, widgets, layout_type, options)
292
+ end
293
+
294
+ # Fetch the given dashboard.
295
+ def get_board(dashboard_id)
296
+ @dashboard_service.get_board(dashboard_id)
297
+ end
298
+
299
+ # Delete the given dashboard.
300
+ def delete_board(dashboard_id)
301
+ @dashboard_service.delete_board(dashboard_id)
302
+ end
303
+
279
304
  #
280
305
  # DASHBOARD LISTS
281
306
  #
@@ -1,6 +1,7 @@
1
1
  require 'dogapi/v1/alert'
2
2
  require 'dogapi/v1/comment'
3
3
  require 'dogapi/v1/dash'
4
+ require 'dogapi/v1/dashboard'
4
5
  require 'dogapi/v1/dashboard_list'
5
6
  require 'dogapi/v1/embed'
6
7
  require 'dogapi/v1/event'
@@ -0,0 +1,92 @@
1
+ require 'dogapi'
2
+
3
+ module Dogapi
4
+ class V1 # for namespacing
5
+
6
+ # Dashboard API
7
+ class DashboardService < Dogapi::APIService
8
+
9
+ API_VERSION = 'v1'
10
+ RESOURCE_NAME = 'dashboard'
11
+
12
+ # Create new dashboard
13
+ #
14
+ # Required arguments:
15
+ # :title => String: Title of the dashboard
16
+ # :widgets => JSON: List of widgets to display on the dashboard
17
+ # :layout_type => String: Layout type of the dashboard
18
+ # (for now, only "ordered" layout - current timeboard layout - is supported)
19
+ # Optional arguments:
20
+ # :description => String: Description of the dashboard
21
+ # :is_read_only => Boolean: Whether this dashboard is read-only.
22
+ # If True, only the author and admins can make changes to it.
23
+ # :notify_list => JSON: List of handles of users to notify when changes are made to this dashboard
24
+ # e.g. '["user1@domain.com", "user2@domain.com"]'
25
+ # :template_variables => JSON: List of template variables for this dashboard.
26
+ # e.g. [{"name": "host", "prefix": "host", "default": "my-host"}]
27
+ def create_board(title, widgets, layout_type, options)
28
+ # Required arguments
29
+ body = {
30
+ title: title,
31
+ widgets: widgets,
32
+ layout_type: layout_type
33
+ }
34
+ # Optional arguments
35
+ body[:description] = options[:description] if options[:description]
36
+ body[:is_read_only] = options[:is_read_only] if options[:is_read_only]
37
+ body[:notify_list] = options[:notify_list] if options[:notify_list]
38
+ body[:template_variables] = options[:template_variables] if options[:template_variables]
39
+
40
+ request(Net::HTTP::Post, "/api/#{API_VERSION}/#{RESOURCE_NAME}", nil, body, true)
41
+ end
42
+
43
+ # Update a dashboard
44
+ #
45
+ # Required arguments:
46
+ # :dashboard_id => String: ID of the dashboard
47
+ # :title => String: Title of the dashboard
48
+ # :widgets => JSON: List of widgets to display on the dashboard
49
+ # :layout_type => String: Layout type of the dashboard
50
+ # (for now, only "ordered" layout - current timeboard layout - is supported)
51
+ # Optional arguments:
52
+ # :description => String: Description of the dashboard
53
+ # :is_read_only => Boolean: Whether this dashboard is read-only.
54
+ # If True, only the author and admins can make changes to it.
55
+ # :notify_list => JSON: List of handles of users to notify when changes are made to this dashboard
56
+ # e.g. '["user1@domain.com", "user2@domain.com"]'
57
+ # :template_variables => JSON: List of template variables for this dashboard.
58
+ # e.g. [{"name": "host", "prefix": "host", "default": "my-host"}]
59
+ def update_board(dashboard_id, title, widgets, layout_type, options)
60
+ # Required arguments
61
+ body = {
62
+ title: title,
63
+ widgets: widgets,
64
+ layout_type: layout_type
65
+ }
66
+ # Optional arguments
67
+ body[:description] = options[:description] if options[:description]
68
+ body[:is_read_only] = options[:is_read_only] if options[:is_read_only]
69
+ body[:notify_list] = options[:notify_list] if options[:notify_list]
70
+ body[:template_variables] = options[:template_variables] if options[:template_variables]
71
+
72
+ request(Net::HTTP::Put, "/api/#{API_VERSION}/#{RESOURCE_NAME}/#{dashboard_id}", nil, body, true)
73
+ end
74
+
75
+ # Fetch the given dashboard
76
+ #
77
+ # :dashboard_id => String: ID of the dashboard
78
+ def get_board(dashboard_id)
79
+ request(Net::HTTP::Get, "/api/#{API_VERSION}/#{RESOURCE_NAME}/#{dashboard_id}", nil, nil, false)
80
+ end
81
+
82
+ # Delete the given dashboard
83
+ #
84
+ # :dashboard_id => String: ID of the dashboard
85
+ def delete_board(dashboard_id)
86
+ request(Net::HTTP::Delete, "/api/#{API_VERSION}/#{RESOURCE_NAME}/#{dashboard_id}", nil, nil, false)
87
+ end
88
+
89
+ end
90
+
91
+ end
92
+ end
@@ -61,8 +61,8 @@ module Dogapi
61
61
  begin
62
62
  typ = options[:type] || 'gauge'
63
63
 
64
- if typ != 'gauge' && typ != 'counter'
65
- raise ArgumentError, 'metric type must be gauge or counter'
64
+ if typ != 'gauge' && typ != 'counter' && typ != 'count' && typ != 'rate'
65
+ raise ArgumentError, 'metric type must be gauge or counter or count or rate'
66
66
  end
67
67
 
68
68
  metric_payload = {
@@ -1,3 +1,3 @@
1
1
  module Dogapi
2
- VERSION = '1.32.0'
2
+ VERSION = '1.33.0'
3
3
  end
@@ -0,0 +1,64 @@
1
+ require_relative '../spec_helper'
2
+
3
+ describe Dogapi::Client do
4
+ DASHBOARD_ID = '3er-f8j-eus'.freeze
5
+ TITLE = 'My awesome dashboard'.freeze
6
+ WIDGETS = [{
7
+ 'definition' => {
8
+ 'requests ' => [
9
+ { 'q' => 'avg:system.mem.free{*}' }
10
+ ],
11
+ 'title' => 'Average Memory Free',
12
+ 'type' => 'timeseries'
13
+ },
14
+ 'id' => 1234
15
+ }].freeze
16
+ LAYOUT_TYPE = 'ordered'.freeze
17
+ DESCRIPTION = 'Lorem ipsum'.freeze
18
+ IS_READ_ONLY = true
19
+ NOTIFY_LIST = ['user@domain.com'].freeze
20
+ TEMPLATE_VARIABLES = [{
21
+ 'name' => 'host1',
22
+ 'prefix' => 'host',
23
+ 'default' => 'my-host'
24
+ }].freeze
25
+
26
+ REQUIRED_ARGS = {
27
+ title: TITLE,
28
+ widgets: WIDGETS,
29
+ layout_type: LAYOUT_TYPE
30
+ }.freeze
31
+
32
+ OPTIONS = {
33
+ description: DESCRIPTION,
34
+ is_read_only: IS_READ_ONLY,
35
+ notify_list: NOTIFY_LIST,
36
+ template_variables: TEMPLATE_VARIABLES
37
+ }
38
+ DASHBOARD_ARGS = REQUIRED_ARGS.values + [OPTIONS]
39
+ DASHBOARD_PAYLOAD = REQUIRED_ARGS.merge(OPTIONS)
40
+
41
+ describe '#create_board' do
42
+ it_behaves_like 'an api method',
43
+ :create_board, DASHBOARD_ARGS,
44
+ :post, '/dashboard', DASHBOARD_PAYLOAD
45
+ end
46
+
47
+ describe '#update_board' do
48
+ it_behaves_like 'an api method',
49
+ :update_board, [DASHBOARD_ID] + DASHBOARD_ARGS,
50
+ :put, "/dashboard/#{DASHBOARD_ID}", DASHBOARD_PAYLOAD
51
+ end
52
+
53
+ describe '#get_board' do
54
+ it_behaves_like 'an api method',
55
+ :get_board, [DASHBOARD_ID],
56
+ :get, "/dashboard/#{DASHBOARD_ID}"
57
+ end
58
+
59
+ describe '#delete_board' do
60
+ it_behaves_like 'an api method',
61
+ :delete_board, [DASHBOARD_ID],
62
+ :delete, "/dashboard/#{DASHBOARD_ID}"
63
+ end
64
+ 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.32.0
4
+ version: 1.33.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: 2018-10-23 00:00:00.000000000 Z
11
+ date: 2019-02-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: multi_json
@@ -28,14 +28,14 @@ dependencies:
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
@@ -102,6 +102,7 @@ files:
102
102
  - lib/dogapi/v1/alert.rb
103
103
  - lib/dogapi/v1/comment.rb
104
104
  - lib/dogapi/v1/dash.rb
105
+ - lib/dogapi/v1/dashboard.rb
105
106
  - lib/dogapi/v1/dashboard_list.rb
106
107
  - lib/dogapi/v1/embed.rb
107
108
  - lib/dogapi/v1/event.rb
@@ -121,6 +122,7 @@ files:
121
122
  - spec/integration/common_spec.rb
122
123
  - spec/integration/dash_spec.rb
123
124
  - spec/integration/dashboard_list_spec.rb
125
+ - spec/integration/dashboard_spec.rb
124
126
  - spec/integration/embed_spec.rb
125
127
  - spec/integration/event_spec.rb
126
128
  - spec/integration/metadata_spec.rb
@@ -165,8 +167,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
165
167
  - !ruby/object:Gem::Version
166
168
  version: '0'
167
169
  requirements: []
168
- rubyforge_project:
169
- rubygems_version: 2.7.1
170
+ rubygems_version: 3.0.2
170
171
  signing_key:
171
172
  specification_version: 4
172
173
  summary: Ruby bindings for Datadog's API
@@ -176,6 +177,7 @@ test_files:
176
177
  - spec/integration/common_spec.rb
177
178
  - spec/integration/dash_spec.rb
178
179
  - spec/integration/dashboard_list_spec.rb
180
+ - spec/integration/dashboard_spec.rb
179
181
  - spec/integration/embed_spec.rb
180
182
  - spec/integration/event_spec.rb
181
183
  - spec/integration/metadata_spec.rb