dogapi 1.37.0 → 1.41.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.
Files changed (90) hide show
  1. checksums.yaml +4 -4
  2. data/.azure-pipelines/all.yml +16 -7
  3. data/.github/CODEOWNERS +10 -0
  4. data/.github/ISSUE_TEMPLATE/bug_report.md +36 -0
  5. data/.github/ISSUE_TEMPLATE/feature_request.md +23 -0
  6. data/.github/PULL_REQUEST_TEMPLATE.md +77 -0
  7. data/.github/labeler.yml +5 -0
  8. data/.github/workflows/labeler.yml +11 -0
  9. data/.github/workflows/stale.yml +39 -0
  10. data/.rubocop_todo.yml +44 -75
  11. data/CHANGELOG.md +39 -1
  12. data/CONTRIBUTING.md +111 -0
  13. data/DEVELOPMENT.md +11 -0
  14. data/Gemfile +2 -0
  15. data/Gemfile_1.9 +13 -0
  16. data/LICENSE +21 -20
  17. data/LICENSE-3rdparty.csv +6 -0
  18. data/README.rdoc +14 -0
  19. data/RELEASING.md +46 -0
  20. data/SUPPORT.md +9 -0
  21. data/dogapi.gemspec +2 -0
  22. data/examples/custom_metric.rb +1 -1
  23. data/lib/capistrano/README.md +4 -1
  24. data/lib/capistrano/datadog.rb +8 -4
  25. data/lib/capistrano/datadog/v2.rb +9 -1
  26. data/lib/capistrano/datadog/v3.rb +10 -1
  27. data/lib/dogapi.rb +4 -0
  28. data/lib/dogapi/common.rb +90 -35
  29. data/lib/dogapi/event.rb +4 -0
  30. data/lib/dogapi/facade.rb +176 -28
  31. data/lib/dogapi/metric.rb +4 -0
  32. data/lib/dogapi/v1.rb +9 -0
  33. data/lib/dogapi/v1/alert.rb +4 -0
  34. data/lib/dogapi/v1/aws_integration.rb +117 -0
  35. data/lib/dogapi/v1/aws_logs.rb +107 -0
  36. data/lib/dogapi/v1/azure_integration.rb +85 -0
  37. data/lib/dogapi/v1/comment.rb +4 -0
  38. data/lib/dogapi/v1/dash.rb +10 -4
  39. data/lib/dogapi/v1/dashboard.rb +4 -0
  40. data/lib/dogapi/v1/dashboard_list.rb +4 -0
  41. data/lib/dogapi/v1/embed.rb +4 -0
  42. data/lib/dogapi/v1/event.rb +4 -0
  43. data/lib/dogapi/v1/gcp_integration.rb +76 -0
  44. data/lib/dogapi/v1/hosts.rb +4 -0
  45. data/lib/dogapi/v1/integration.rb +4 -0
  46. data/lib/dogapi/v1/metadata.rb +4 -0
  47. data/lib/dogapi/v1/metric.rb +4 -0
  48. data/lib/dogapi/v1/monitor.rb +20 -7
  49. data/lib/dogapi/v1/screenboard.rb +4 -0
  50. data/lib/dogapi/v1/search.rb +4 -0
  51. data/lib/dogapi/v1/service_check.rb +4 -0
  52. data/lib/dogapi/v1/service_level_objective.rb +31 -35
  53. data/lib/dogapi/v1/snapshot.rb +4 -0
  54. data/lib/dogapi/v1/synthetics.rb +80 -0
  55. data/lib/dogapi/v1/tag.rb +4 -0
  56. data/lib/dogapi/v1/usage.rb +4 -0
  57. data/lib/dogapi/v1/user.rb +4 -0
  58. data/lib/dogapi/v2.rb +4 -0
  59. data/lib/dogapi/v2/dashboard_list.rb +4 -0
  60. data/lib/dogapi/version.rb +5 -1
  61. data/spec/integration/alert_spec.rb +4 -0
  62. data/spec/integration/aws_integration_spec.rb +55 -0
  63. data/spec/integration/aws_logs_spec.rb +59 -0
  64. data/spec/integration/azure_integration_spec.rb +63 -0
  65. data/spec/integration/comment_spec.rb +5 -0
  66. data/spec/integration/common_spec.rb +4 -0
  67. data/spec/integration/dash_spec.rb +7 -1
  68. data/spec/integration/dashboard_list_spec.rb +4 -0
  69. data/spec/integration/dashboard_spec.rb +4 -0
  70. data/spec/integration/embed_spec.rb +4 -0
  71. data/spec/integration/event_spec.rb +5 -0
  72. data/spec/integration/gcp_integration_spec.rb +57 -0
  73. data/spec/integration/integration_spec.rb +4 -0
  74. data/spec/integration/metadata_spec.rb +4 -0
  75. data/spec/integration/metric_spec.rb +4 -0
  76. data/spec/integration/monitor_spec.rb +30 -1
  77. data/spec/integration/screenboard_spec.rb +4 -0
  78. data/spec/integration/search_spec.rb +4 -0
  79. data/spec/integration/service_check_spec.rb +4 -0
  80. data/spec/integration/service_level_objective_spec.rb +13 -11
  81. data/spec/integration/snapshot_spec.rb +4 -0
  82. data/spec/integration/synthetics_spec.rb +131 -0
  83. data/spec/integration/tag_spec.rb +4 -0
  84. data/spec/integration/usage_spec.rb +4 -0
  85. data/spec/integration/user_spec.rb +4 -0
  86. data/spec/spec_helper.rb +12 -21
  87. data/spec/unit/capistrano_spec.rb +4 -0
  88. data/spec/unit/common_spec.rb +64 -7
  89. data/spec/unit/facade_spec.rb +4 -0
  90. metadata +31 -4
@@ -1,3 +1,7 @@
1
+ # Unless explicitly stated otherwise all files in this repository are licensed under the BSD-3-Clause License.
2
+ # This product includes software developed at Datadog (https://www.datadoghq.com/).
3
+ # Copyright 2011-Present Datadog, Inc.
4
+
1
5
  require_relative '../spec_helper'
2
6
 
3
7
  describe Dogapi::Client do
@@ -1,3 +1,7 @@
1
+ # Unless explicitly stated otherwise all files in this repository are licensed under the BSD-3-Clause License.
2
+ # This product includes software developed at Datadog (https://www.datadoghq.com/).
3
+ # Copyright 2011-Present Datadog, Inc.
4
+
1
5
  require_relative '../spec_helper'
2
6
 
3
7
  describe Dogapi::Client do
@@ -1,3 +1,7 @@
1
+ # Unless explicitly stated otherwise all files in this repository are licensed under the BSD-3-Clause License.
2
+ # This product includes software developed at Datadog (https://www.datadoghq.com/).
3
+ # Copyright 2011-Present Datadog, Inc.
4
+
1
5
  require_relative '../spec_helper'
2
6
 
3
7
  describe Dogapi::Client do
@@ -1,3 +1,7 @@
1
+ # Unless explicitly stated otherwise all files in this repository are licensed under the BSD-3-Clause License.
2
+ # This product includes software developed at Datadog (https://www.datadoghq.com/).
3
+ # Copyright 2011-Present Datadog, Inc.
4
+
1
5
  require 'rspec'
2
6
  require 'simplecov'
3
7
  require 'webmock/rspec'
@@ -42,22 +46,6 @@ module SpecDog
42
46
  end
43
47
  end
44
48
 
45
- shared_examples 'an api method with named args' do |command, args, request, endpoint, body|
46
- it 'queries the api' do
47
- url = api_url + endpoint
48
- old_url = old_api_url + endpoint
49
- stub_request(request, /#{url}|#{old_url}/).to_return(body: '{}').then.to_raise(StandardError)
50
- expect(dog.send(command, **args)).to eq ['200', {}]
51
-
52
- body = MultiJson.dump(body) if body
53
-
54
- expect(WebMock).to have_requested(request, /#{url}|#{old_url}/).with(
55
- # ignore query: default_query -- here as in the test it's never properly included
56
- body: body
57
- )
58
- end
59
- end
60
-
61
49
  shared_examples 'an api method with options' do |command, args, request, endpoint, body|
62
50
  include_examples 'an api method', command, args, request, endpoint, body
63
51
  it 'queries the api with options' do
@@ -89,16 +77,19 @@ module SpecDog
89
77
  end
90
78
  end
91
79
 
92
- shared_examples 'an api method with named args making params' do |command, args, request, endpoint, params|
93
- it 'queries the api with params' do
80
+ shared_examples 'an api method with params and body' do |command, args, request, endpoint, params, body|
81
+ it 'queries the api with params and body' do
94
82
  url = api_url + endpoint
95
83
  stub_request(request, /#{url}/).to_return(body: '{}').then.to_raise(StandardError)
96
- expect(dog.send(command, **args)).to eq ['200', {}]
84
+ expect(dog.send(command, *args)).to eq ['200', {}]
97
85
  params.each { |k, v| params[k] = v.join(',') if v.is_a? Array }
98
- # hack/note: do not merge with default_query for this test case
86
+ params = params
87
+
88
+ body = MultiJson.dump(body) if body
99
89
 
100
90
  expect(WebMock).to have_requested(request, url).with(
101
- query: params
91
+ query: params,
92
+ body: body
102
93
  )
103
94
  end
104
95
  end
@@ -1,3 +1,7 @@
1
+ # Unless explicitly stated otherwise all files in this repository are licensed under the BSD-3-Clause License.
2
+ # This product includes software developed at Datadog (https://www.datadoghq.com/).
3
+ # Copyright 2011-Present Datadog, Inc.
4
+
1
5
  require 'spec_helper'
2
6
  require 'capistrano/datadog'
3
7
  require 'benchmark'
@@ -1,6 +1,27 @@
1
+ # Unless explicitly stated otherwise all files in this repository are licensed under the BSD-3-Clause License.
2
+ # This product includes software developed at Datadog (https://www.datadoghq.com/).
3
+ # Copyright 2011-Present Datadog, Inc.
4
+
1
5
  require_relative '../spec_helper'
2
6
 
3
7
  describe 'Common' do
8
+ describe 'validate_tags' do
9
+ it 'raises if tags is not an array' do
10
+ tags = 'foo:bar'
11
+ expect { Dogapi.validate_tags(tags) }.to raise_error(ArgumentError)
12
+ tags = nil
13
+ expect { Dogapi.validate_tags(tags) }.to raise_error(ArgumentError)
14
+ end
15
+ it 'raises if elements of tags are not strings' do
16
+ tags = ['toto:tata', { foo: 'bar' }]
17
+ expect { Dogapi.validate_tags(tags) }.to raise_error(ArgumentError)
18
+ end
19
+ it 'passes if tags are correct' do
20
+ tags = ['foo:bar', 'baz']
21
+ Dogapi.validate_tags(tags)
22
+ end
23
+ end
24
+
4
25
  describe Dogapi.find_datadog_host do
5
26
  it 'gives precedence to DATADOG_HOST env var' do
6
27
  allow(ENV).to receive(:[]).with('DATADOG_HOST').and_return('example.com')
@@ -40,6 +61,26 @@ describe 'Common' do
40
61
  ENV['http_proxy'] = nil
41
62
  end
42
63
 
64
+ it 'uses-the dogapi specific proxy if set' do
65
+ service = Dogapi::APIService.new('api_key', 'app_key')
66
+
67
+ service.connect do |conn|
68
+ expect(conn.proxy_address).to be(nil)
69
+ expect(conn.proxy_port).to be(nil)
70
+ end
71
+
72
+ ENV['https_proxy'] = 'https://www.proxy.com:443'
73
+ ENV['dd_proxy_https'] = 'https://www.otherproxy.com:443'
74
+
75
+ service.connect do |conn|
76
+ expect(conn.proxy_address).to eq 'www.otherproxy.com'
77
+ expect(conn.proxy_port).to eq 443
78
+ end
79
+
80
+ ENV['https_proxy'] = nil
81
+ ENV['dd_proxy_https'] = nil
82
+ end
83
+
43
84
  it 'respects the endpoint configuration' do
44
85
  service = Dogapi::APIService.new('api_key', 'app_key', true, nil, 'https://app.example.com')
45
86
 
@@ -65,11 +106,12 @@ describe 'Common' do
65
106
  '/api/v1/screen']
66
107
 
67
108
  urls.each do |url|
68
- params = service.set_api_and_app_keys_in_params(url, true)
69
- expect(params).to have_key(:api_key)
70
- expect(params[:api_key]).to eq service.api_key
71
- expect(params).to have_key(:application_key)
72
- expect(params[:application_key]).to eq service.application_key
109
+ expect(service.should_set_api_and_app_keys_in_params?(url)).to be true
110
+ params = service.prepare_params(nil, url, true)
111
+ expect(params).to eq("?api_key=#{service.api_key}&application_key=#{service.application_key}")
112
+ req = service.prepare_request(Net::HTTP::Get, url, params, nil, false, true)
113
+ expect(req.key?('DD-API-KEY')).to be false
114
+ expect(req.key?('DD-APPLICATION-KEY')).to be false
73
115
  end
74
116
  end
75
117
 
@@ -82,10 +124,25 @@ describe 'Common' do
82
124
  '/api/v2/users']
83
125
 
84
126
  urls.each do |url|
85
- params = service.set_api_and_app_keys_in_params(url, true)
86
- expect(params).to eq({})
127
+ expect(service.should_set_api_and_app_keys_in_params?(url)).to be false
128
+ params = service.prepare_params(nil, url, true)
129
+ expect(params).to eq('?')
130
+ req = service.prepare_request(Net::HTTP::Get, url, params, nil, false, true)
131
+ expect(req.key?('DD-API-KEY')).to be true
132
+ expect(req['DD-API-KEY']).to eq service.api_key
133
+ expect(req.key?('DD-APPLICATION-KEY')).to be true
134
+ expect(req['DD-APPLICATION-KEY']).to eq service.application_key
87
135
  end
88
136
  end
137
+
138
+ it 'properly sets User-Agent header' do
139
+ service = Dogapi::APIService.new('api_key', 'app_key', true, nil, 'https://app.example.com')
140
+ params = service.prepare_params(nil, '/api/v1/validate', true)
141
+ req = service.prepare_request(Net::HTTP::Get, '/api/v1/validate', params, nil, false, true)
142
+
143
+ expect(req.key?('User-Agent')).to be true
144
+ expect(req['User-Agent']).to match(%r{dogapi-rb\/[^\s]+ \(ruby [^\s]+; os [^\s]+; arch [^\s]+\)})
145
+ end
89
146
  end
90
147
  end
91
148
 
@@ -1,3 +1,7 @@
1
+ # Unless explicitly stated otherwise all files in this repository are licensed under the BSD-3-Clause License.
2
+ # This product includes software developed at Datadog (https://www.datadoghq.com/).
3
+ # Copyright 2011-Present Datadog, Inc.
4
+
1
5
  require 'spec_helper'
2
6
 
3
7
  describe Dogapi::Client do
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.37.0
4
+ version: 1.41.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: 2019-11-04 00:00:00.000000000 Z
11
+ date: 2020-07-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: multi_json
@@ -75,16 +75,29 @@ extra_rdoc_files:
75
75
  - README.rdoc
76
76
  files:
77
77
  - ".azure-pipelines/all.yml"
78
+ - ".github/CODEOWNERS"
79
+ - ".github/ISSUE_TEMPLATE/bug_report.md"
80
+ - ".github/ISSUE_TEMPLATE/feature_request.md"
81
+ - ".github/PULL_REQUEST_TEMPLATE.md"
82
+ - ".github/labeler.yml"
83
+ - ".github/workflows/labeler.yml"
84
+ - ".github/workflows/stale.yml"
78
85
  - ".gitignore"
79
86
  - ".rspec"
80
87
  - ".rubocop.yml"
81
88
  - ".rubocop_todo.yml"
82
89
  - ".tailor"
83
90
  - CHANGELOG.md
91
+ - CONTRIBUTING.md
92
+ - DEVELOPMENT.md
84
93
  - Gemfile
94
+ - Gemfile_1.9
85
95
  - LICENSE
96
+ - LICENSE-3rdparty.csv
86
97
  - README.rdoc
98
+ - RELEASING.md
87
99
  - Rakefile
100
+ - SUPPORT.md
88
101
  - dogapi.gemspec
89
102
  - examples/Capfile
90
103
  - examples/custom_event.rb
@@ -100,12 +113,16 @@ files:
100
113
  - lib/dogapi/metric.rb
101
114
  - lib/dogapi/v1.rb
102
115
  - lib/dogapi/v1/alert.rb
116
+ - lib/dogapi/v1/aws_integration.rb
117
+ - lib/dogapi/v1/aws_logs.rb
118
+ - lib/dogapi/v1/azure_integration.rb
103
119
  - lib/dogapi/v1/comment.rb
104
120
  - lib/dogapi/v1/dash.rb
105
121
  - lib/dogapi/v1/dashboard.rb
106
122
  - lib/dogapi/v1/dashboard_list.rb
107
123
  - lib/dogapi/v1/embed.rb
108
124
  - lib/dogapi/v1/event.rb
125
+ - lib/dogapi/v1/gcp_integration.rb
109
126
  - lib/dogapi/v1/hosts.rb
110
127
  - lib/dogapi/v1/integration.rb
111
128
  - lib/dogapi/v1/metadata.rb
@@ -116,6 +133,7 @@ files:
116
133
  - lib/dogapi/v1/service_check.rb
117
134
  - lib/dogapi/v1/service_level_objective.rb
118
135
  - lib/dogapi/v1/snapshot.rb
136
+ - lib/dogapi/v1/synthetics.rb
119
137
  - lib/dogapi/v1/tag.rb
120
138
  - lib/dogapi/v1/usage.rb
121
139
  - lib/dogapi/v1/user.rb
@@ -123,6 +141,9 @@ files:
123
141
  - lib/dogapi/v2/dashboard_list.rb
124
142
  - lib/dogapi/version.rb
125
143
  - spec/integration/alert_spec.rb
144
+ - spec/integration/aws_integration_spec.rb
145
+ - spec/integration/aws_logs_spec.rb
146
+ - spec/integration/azure_integration_spec.rb
126
147
  - spec/integration/comment_spec.rb
127
148
  - spec/integration/common_spec.rb
128
149
  - spec/integration/dash_spec.rb
@@ -130,6 +151,7 @@ files:
130
151
  - spec/integration/dashboard_spec.rb
131
152
  - spec/integration/embed_spec.rb
132
153
  - spec/integration/event_spec.rb
154
+ - spec/integration/gcp_integration_spec.rb
133
155
  - spec/integration/integration_spec.rb
134
156
  - spec/integration/metadata_spec.rb
135
157
  - spec/integration/metric_spec.rb
@@ -139,6 +161,7 @@ files:
139
161
  - spec/integration/service_check_spec.rb
140
162
  - spec/integration/service_level_objective_spec.rb
141
163
  - spec/integration/snapshot_spec.rb
164
+ - spec/integration/synthetics_spec.rb
142
165
  - spec/integration/tag_spec.rb
143
166
  - spec/integration/usage_spec.rb
144
167
  - spec/integration/user_spec.rb
@@ -175,13 +198,15 @@ required_rubygems_version: !ruby/object:Gem::Requirement
175
198
  - !ruby/object:Gem::Version
176
199
  version: '0'
177
200
  requirements: []
178
- rubyforge_project:
179
- rubygems_version: 2.7.6
201
+ rubygems_version: 3.0.3
180
202
  signing_key:
181
203
  specification_version: 4
182
204
  summary: Ruby bindings for Datadog's API
183
205
  test_files:
184
206
  - spec/integration/alert_spec.rb
207
+ - spec/integration/aws_integration_spec.rb
208
+ - spec/integration/aws_logs_spec.rb
209
+ - spec/integration/azure_integration_spec.rb
185
210
  - spec/integration/comment_spec.rb
186
211
  - spec/integration/common_spec.rb
187
212
  - spec/integration/dash_spec.rb
@@ -189,6 +214,7 @@ test_files:
189
214
  - spec/integration/dashboard_spec.rb
190
215
  - spec/integration/embed_spec.rb
191
216
  - spec/integration/event_spec.rb
217
+ - spec/integration/gcp_integration_spec.rb
192
218
  - spec/integration/integration_spec.rb
193
219
  - spec/integration/metadata_spec.rb
194
220
  - spec/integration/metric_spec.rb
@@ -198,6 +224,7 @@ test_files:
198
224
  - spec/integration/service_check_spec.rb
199
225
  - spec/integration/service_level_objective_spec.rb
200
226
  - spec/integration/snapshot_spec.rb
227
+ - spec/integration/synthetics_spec.rb
201
228
  - spec/integration/tag_spec.rb
202
229
  - spec/integration/usage_spec.rb
203
230
  - spec/integration/user_spec.rb