dogapi 1.44.0 → 1.45.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 +4 -4
- data/.rubocop_todo.yml +1 -0
- data/CHANGELOG.md +7 -0
- data/Gemfile_1.9 +1 -0
- data/lib/capistrano/datadog.rb +2 -2
- data/lib/capistrano/datadog/v2.rb +2 -2
- data/lib/capistrano/datadog/v3.rb +3 -2
- data/lib/dogapi/common.rb +2 -2
- data/lib/dogapi/facade.rb +25 -0
- data/lib/dogapi/v1.rb +1 -0
- data/lib/dogapi/v1/alert.rb +0 -2
- data/lib/dogapi/v1/aws_integration.rb +0 -2
- data/lib/dogapi/v1/aws_logs.rb +0 -2
- data/lib/dogapi/v1/azure_integration.rb +0 -2
- data/lib/dogapi/v1/comment.rb +0 -2
- data/lib/dogapi/v1/dash.rb +0 -2
- data/lib/dogapi/v1/dashboard.rb +0 -2
- data/lib/dogapi/v1/dashboard_list.rb +0 -2
- data/lib/dogapi/v1/embed.rb +0 -2
- data/lib/dogapi/v1/event.rb +0 -2
- data/lib/dogapi/v1/gcp_integration.rb +0 -2
- data/lib/dogapi/v1/hosts.rb +0 -2
- data/lib/dogapi/v1/integration.rb +0 -2
- data/lib/dogapi/v1/logs_pipeline.rb +41 -0
- data/lib/dogapi/v1/metadata.rb +0 -2
- data/lib/dogapi/v1/metric.rb +0 -2
- data/lib/dogapi/v1/monitor.rb +0 -2
- data/lib/dogapi/v1/screenboard.rb +0 -2
- data/lib/dogapi/v1/search.rb +0 -2
- data/lib/dogapi/v1/service_check.rb +0 -2
- data/lib/dogapi/v1/service_level_objective.rb +3 -1
- data/lib/dogapi/v1/snapshot.rb +0 -2
- data/lib/dogapi/v1/synthetics.rb +3 -1
- data/lib/dogapi/v1/tag.rb +0 -2
- data/lib/dogapi/v1/usage.rb +0 -2
- data/lib/dogapi/v1/user.rb +0 -2
- data/lib/dogapi/v2/dashboard_list.rb +0 -2
- data/lib/dogapi/version.rb +1 -1
- data/spec/integration/logs_pipeline_spec.rb +43 -0
- data/spec/unit/common_spec.rb +10 -10
- metadata +5 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1ef3fbebc71af23718db2e177c11400648e47e0e770c8783021a8e7a1b7df099
|
4
|
+
data.tar.gz: 59ef0c8d5c187e7161a25166b468fa91c640ab568dd22992aa037b38c7461ff1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 48239d6fd49a735c74eb4c95f97093c0e599a8d11d868e784cb08ce1a96ce0a6da6b942e78afadc870fcb7e09bf0b53205c0517d502029cc17d3c3a378d5bbfa
|
7
|
+
data.tar.gz: 658b9c7f91b18e7744b1d3761e6e1d5212e527f293d09ba4a00f3303602262c46cf0c5743ec317e4bdb353286a1c94a9de51b86285b9513f310e7f6e72f4ca0c
|
data/.rubocop_todo.yml
CHANGED
@@ -241,6 +241,7 @@ Style/AccessorMethodName:
|
|
241
241
|
- 'lib/dogapi/v1/dash.rb'
|
242
242
|
- 'lib/dogapi/v1/dashboard.rb'
|
243
243
|
- 'lib/dogapi/v1/embed.rb'
|
244
|
+
- 'lib/dogapi/v1/logs_pipeline.rb'
|
244
245
|
- 'lib/dogapi/v1/screenboard.rb'
|
245
246
|
- 'lib/dogapi/v1/synthetics.rb'
|
246
247
|
- 'lib/dogapi/v1/user.rb'
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,12 @@
|
|
1
1
|
# Changes
|
2
2
|
|
3
|
+
## 1.45.0 / 2021-01-27
|
4
|
+
|
5
|
+
* [Added] Read `datadog_host` cap variable for specifying Datadog API endpoint. See [#255](https://github.com/DataDog/dogapi-rb/pull/255).
|
6
|
+
* [Added] Added support for logs pipelines CRUD methods. See [#252](https://github.com/DataDog/dogapi-rb/pull/252). Thanks [hi-artem](https://github.com/hi-artem).
|
7
|
+
* [Fixed] Properly handle string response code. See [#254](https://github.com/DataDog/dogapi-rb/pull/254).
|
8
|
+
* [Fixed] Remove circular dependency. See [#253](https://github.com/DataDog/dogapi-rb/pull/253).
|
9
|
+
|
3
10
|
## 1.44.0 / 2020-12-10
|
4
11
|
|
5
12
|
* [Added] Allow skipping SSL verification. See [#246](https://github.com/DataDog/dogapi-rb/pull/246).
|
data/Gemfile_1.9
CHANGED
data/lib/capistrano/datadog.rb
CHANGED
@@ -28,10 +28,10 @@ module Capistrano
|
|
28
28
|
@cap_version
|
29
29
|
end
|
30
30
|
|
31
|
-
def self.submit(api_key, use_getlogin=true)
|
31
|
+
def self.submit(api_key, use_getlogin=true, endpoint=nil)
|
32
32
|
begin
|
33
33
|
if api_key
|
34
|
-
dog = Dogapi::Client.new(api_key)
|
34
|
+
dog = Dogapi::Client.new(api_key, nil, nil, nil, true, nil, endpoint, false)
|
35
35
|
reporter.report(use_getlogin).each do |event, hosts|
|
36
36
|
if hosts.size > 0
|
37
37
|
hosts.each do |host|
|
@@ -63,9 +63,9 @@ module Capistrano
|
|
63
63
|
desc 'Submit the tasks that have run to Datadog as events'
|
64
64
|
task :submit do |ns|
|
65
65
|
if variables[:use_getlogin].nil?
|
66
|
-
Capistrano::Datadog.submit variables[:datadog_api_key]
|
66
|
+
Capistrano::Datadog.submit variables[:datadog_api_key], true, variables[:datadog_host]
|
67
67
|
else
|
68
|
-
Capistrano::Datadog.submit variables[:datadog_api_key], variables[:use_getlogin]
|
68
|
+
Capistrano::Datadog.submit variables[:datadog_api_key], variables[:use_getlogin], variables[:datadog_host]
|
69
69
|
end
|
70
70
|
end
|
71
71
|
end
|
@@ -81,9 +81,10 @@ end
|
|
81
81
|
at_exit do
|
82
82
|
api_key = Capistrano::Configuration.env.fetch :datadog_api_key
|
83
83
|
use_getlogin = Capistrano::Configuration.env.fetch :use_getlogin
|
84
|
+
datadog_host = Capistrano::Configuration.env.fetch :datadog_host
|
84
85
|
if use_getlogin.nil?
|
85
|
-
Capistrano::Datadog.submit api_key
|
86
|
+
Capistrano::Datadog.submit api_key, true, datadog_host
|
86
87
|
else
|
87
|
-
Capistrano::Datadog.submit api_key, use_getlogin
|
88
|
+
Capistrano::Datadog.submit api_key, use_getlogin, datadog_host
|
88
89
|
end
|
89
90
|
end
|
data/lib/dogapi/common.rb
CHANGED
@@ -183,7 +183,7 @@ module Dogapi
|
|
183
183
|
end
|
184
184
|
|
185
185
|
def handle_response(resp)
|
186
|
-
if resp.code == 204 || resp.body == '' || resp.body == 'null' || resp.body.nil?
|
186
|
+
if resp.code.to_i == 204 || resp.body == '' || resp.body == 'null' || resp.body.nil?
|
187
187
|
return resp.code, {}
|
188
188
|
end
|
189
189
|
begin
|
@@ -198,7 +198,7 @@ module Dogapi
|
|
198
198
|
def handle_redirect(conn, req, resp, retries=10)
|
199
199
|
req.uri = URI.parse(resp.header['location'])
|
200
200
|
new_response = conn.request(req)
|
201
|
-
if retries > 1 && new_response.code / 100 == 3
|
201
|
+
if retries > 1 && new_response.code.to_i / 100 == 3
|
202
202
|
new_response = handle_redirect(conn, req, new_response, retries - 1)
|
203
203
|
end
|
204
204
|
new_response
|
data/lib/dogapi/facade.rb
CHANGED
@@ -108,6 +108,7 @@ module Dogapi
|
|
108
108
|
@gcp_integration_svc = Dogapi::V1::GcpIntegrationService.new(@api_key, @application_key, silent, timeout, @datadog_host, skip_ssl_validation)
|
109
109
|
@service_level_objective_svc = Dogapi::V1::ServiceLevelObjectiveService.new(@api_key, @application_key, silent,
|
110
110
|
timeout, @datadog_host, skip_ssl_validation)
|
111
|
+
@logs_pipeline_svc = Dogapi::V1::LogsPipelineService.new(@api_key, @application_key, silent, timeout, @datadog_host, skip_ssl_validation)
|
111
112
|
|
112
113
|
# Support for Dashboard List API v2.
|
113
114
|
@v2 = Dogapi::ClientV2.new(@api_key, @application_key, true, true, @datadog_host, skip_ssl_validation)
|
@@ -717,6 +718,30 @@ module Dogapi
|
|
717
718
|
@service_level_objective_svc.delete_timeframes_service_level_objective(ops)
|
718
719
|
end
|
719
720
|
|
721
|
+
#
|
722
|
+
# LOGS PIPELINES
|
723
|
+
#
|
724
|
+
|
725
|
+
def create_logs_pipeline(name, filter, options = {})
|
726
|
+
@logs_pipeline_svc.create_logs_pipeline(name, filter, options)
|
727
|
+
end
|
728
|
+
|
729
|
+
def get_logs_pipeline(pipeline_id)
|
730
|
+
@logs_pipeline_svc.get_logs_pipeline(pipeline_id)
|
731
|
+
end
|
732
|
+
|
733
|
+
def get_all_logs_pipelines
|
734
|
+
@logs_pipeline_svc.get_all_logs_pipelines
|
735
|
+
end
|
736
|
+
|
737
|
+
def update_logs_pipeline(pipeline_id, name, filter, options = {})
|
738
|
+
@logs_pipeline_svc.update_logs_pipeline(pipeline_id, name, filter, options)
|
739
|
+
end
|
740
|
+
|
741
|
+
def delete_logs_pipeline(pipeline_id)
|
742
|
+
@logs_pipeline_svc.delete_logs_pipeline(pipeline_id)
|
743
|
+
end
|
744
|
+
|
720
745
|
#
|
721
746
|
# SERVICE CHECKS
|
722
747
|
#
|
data/lib/dogapi/v1.rb
CHANGED
data/lib/dogapi/v1/alert.rb
CHANGED
data/lib/dogapi/v1/aws_logs.rb
CHANGED
data/lib/dogapi/v1/comment.rb
CHANGED
data/lib/dogapi/v1/dash.rb
CHANGED
data/lib/dogapi/v1/dashboard.rb
CHANGED
data/lib/dogapi/v1/embed.rb
CHANGED
data/lib/dogapi/v1/event.rb
CHANGED
data/lib/dogapi/v1/hosts.rb
CHANGED
@@ -0,0 +1,41 @@
|
|
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
|
+
|
5
|
+
module Dogapi
|
6
|
+
class V1 # for namespacing
|
7
|
+
class LogsPipelineService < Dogapi::APIService
|
8
|
+
API_VERSION = 'v1'
|
9
|
+
|
10
|
+
def create_logs_pipeline(name, filter, options = {})
|
11
|
+
body = {
|
12
|
+
'name' => name,
|
13
|
+
'filter' => filter
|
14
|
+
}.merge options
|
15
|
+
|
16
|
+
request(Net::HTTP::Post, "/api/#{API_VERSION}/logs/config/pipelines", nil, body, true)
|
17
|
+
end
|
18
|
+
|
19
|
+
def get_logs_pipeline(pipeline_id)
|
20
|
+
request(Net::HTTP::Get, "/api/#{API_VERSION}/logs/config/pipelines/#{pipeline_id}", nil, nil, false)
|
21
|
+
end
|
22
|
+
|
23
|
+
def get_all_logs_pipelines
|
24
|
+
request(Net::HTTP::Get, "/api/#{API_VERSION}/logs/config/pipelines", nil, nil, false)
|
25
|
+
end
|
26
|
+
|
27
|
+
def update_logs_pipeline(pipeline_id, name, filter, options = {})
|
28
|
+
body = {
|
29
|
+
'name' => name,
|
30
|
+
'filter' => filter
|
31
|
+
}.merge options
|
32
|
+
|
33
|
+
request(Net::HTTP::Put, "/api/#{API_VERSION}/logs/config/pipelines/#{pipeline_id}", nil, body, true)
|
34
|
+
end
|
35
|
+
|
36
|
+
def delete_logs_pipeline(pipeline_id)
|
37
|
+
request(Net::HTTP::Delete, "/api/#{API_VERSION}/logs/config/pipelines/#{pipeline_id}", nil, nil, false)
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
data/lib/dogapi/v1/metadata.rb
CHANGED
data/lib/dogapi/v1/metric.rb
CHANGED
data/lib/dogapi/v1/monitor.rb
CHANGED
data/lib/dogapi/v1/search.rb
CHANGED
@@ -1,4 +1,6 @@
|
|
1
|
-
|
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.
|
2
4
|
|
3
5
|
module Dogapi
|
4
6
|
class V1 # for namespacing
|
data/lib/dogapi/v1/snapshot.rb
CHANGED
data/lib/dogapi/v1/synthetics.rb
CHANGED
@@ -1,4 +1,6 @@
|
|
1
|
-
|
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.
|
2
4
|
|
3
5
|
module Dogapi
|
4
6
|
class V1 # for namespacing
|
data/lib/dogapi/v1/tag.rb
CHANGED
data/lib/dogapi/v1/usage.rb
CHANGED
data/lib/dogapi/v1/user.rb
CHANGED
data/lib/dogapi/version.rb
CHANGED
@@ -0,0 +1,43 @@
|
|
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
|
+
|
5
|
+
require_relative '../spec_helper'
|
6
|
+
|
7
|
+
describe Dogapi::Client do
|
8
|
+
LOGS_PIPELINE_ID = '42'
|
9
|
+
LOGS_PIPELINE_NAME = 'my logs pipeline'.freeze
|
10
|
+
LOGS_PIPELINE_FILTER = { 'query' => 'source:my-app' }.freeze
|
11
|
+
|
12
|
+
describe '#create_logs_pipeline' do
|
13
|
+
it_behaves_like 'an api method with options',
|
14
|
+
:create_logs_pipeline, [LOGS_PIPELINE_NAME, LOGS_PIPELINE_FILTER],
|
15
|
+
:post, '/logs/config/pipelines', 'name' => LOGS_PIPELINE_NAME,
|
16
|
+
'filter' => LOGS_PIPELINE_FILTER
|
17
|
+
end
|
18
|
+
|
19
|
+
describe '#get_logs_pipeline' do
|
20
|
+
it_behaves_like 'an api method',
|
21
|
+
:get_logs_pipeline, [LOGS_PIPELINE_ID],
|
22
|
+
:get, "/logs/config/pipelines/#{LOGS_PIPELINE_ID}"
|
23
|
+
end
|
24
|
+
|
25
|
+
describe '#get_all_logs_pipelines' do
|
26
|
+
it_behaves_like 'an api method',
|
27
|
+
:get_all_logs_pipelines, [],
|
28
|
+
:get, '/logs/config/pipelines'
|
29
|
+
end
|
30
|
+
|
31
|
+
describe '#update_logs_pipeline' do
|
32
|
+
it_behaves_like 'an api method with options',
|
33
|
+
:update_logs_pipeline, [LOGS_PIPELINE_ID, LOGS_PIPELINE_NAME, LOGS_PIPELINE_FILTER],
|
34
|
+
:put, "/logs/config/pipelines/#{LOGS_PIPELINE_ID}", 'name' => LOGS_PIPELINE_NAME,
|
35
|
+
'filter' => LOGS_PIPELINE_FILTER
|
36
|
+
end
|
37
|
+
|
38
|
+
describe '#delete_logs_pipeline' do
|
39
|
+
it_behaves_like 'an api method',
|
40
|
+
:delete_logs_pipeline, [LOGS_PIPELINE_ID],
|
41
|
+
:delete, "/logs/config/pipelines/#{LOGS_PIPELINE_ID}"
|
42
|
+
end
|
43
|
+
end
|
data/spec/unit/common_spec.rb
CHANGED
@@ -182,21 +182,21 @@ describe Dogapi::APIService do
|
|
182
182
|
context 'when receiving a correct reponse with valid json' do
|
183
183
|
it 'parses it and return code and parsed body' do
|
184
184
|
dog = dogapi_service
|
185
|
-
resp = FakeResponse.new 202, '{"test2": "test3"}'
|
186
|
-
expect(dog.handle_response(resp)).to eq([202, { 'test2' => 'test3' }])
|
185
|
+
resp = FakeResponse.new '202', '{"test2": "test3"}'
|
186
|
+
expect(dog.handle_response(resp)).to eq(['202', { 'test2' => 'test3' }])
|
187
187
|
end
|
188
188
|
end
|
189
189
|
context 'when receiving a response with invalid json' do
|
190
190
|
it 'raises an error' do
|
191
191
|
dog = dogapi_service
|
192
|
-
resp = FakeResponse.new 202, "{'test2': }"
|
192
|
+
resp = FakeResponse.new '202', "{'test2': }"
|
193
193
|
expect { dog.handle_response(resp) }.to raise_error(RuntimeError, "Invalid JSON Response: {'test2': }")
|
194
194
|
end
|
195
195
|
end
|
196
196
|
context 'when receiving a non json response' do
|
197
197
|
it 'raises an error indicating the response Content-Type' do
|
198
198
|
dog = dogapi_service
|
199
|
-
resp = FakeResponse.new 202, '<html><body><h1>403 Forbidden</h1>', 'text/html'
|
199
|
+
resp = FakeResponse.new '202', '<html><body><h1>403 Forbidden</h1>', 'text/html'
|
200
200
|
msg = 'Response Content-Type is not application/json but is text/html: <html><body><h1>403 Forbidden</h1>'
|
201
201
|
expect { dog.handle_response(resp) }.to raise_error(RuntimeError, msg)
|
202
202
|
end
|
@@ -204,12 +204,12 @@ describe Dogapi::APIService do
|
|
204
204
|
context 'when receiving a bad response' do
|
205
205
|
it 'returns the error code and an empty body' do
|
206
206
|
dog = dogapi_service
|
207
|
-
resp = FakeResponse.new 204, ''
|
208
|
-
expect(dog.handle_response(resp)).to eq([204, {}])
|
209
|
-
resp = FakeResponse.new 202, nil
|
210
|
-
expect(dog.handle_response(resp)).to eq([202, {}])
|
211
|
-
resp = FakeResponse.new 202, 'null'
|
212
|
-
expect(dog.handle_response(resp)).to eq([202, {}])
|
207
|
+
resp = FakeResponse.new '204', ''
|
208
|
+
expect(dog.handle_response(resp)).to eq(['204', {}])
|
209
|
+
resp = FakeResponse.new '202', nil
|
210
|
+
expect(dog.handle_response(resp)).to eq(['202', {}])
|
211
|
+
resp = FakeResponse.new '202', 'null'
|
212
|
+
expect(dog.handle_response(resp)).to eq(['202', {}])
|
213
213
|
end
|
214
214
|
end
|
215
215
|
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.
|
4
|
+
version: 1.45.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:
|
11
|
+
date: 2021-01-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: multi_json
|
@@ -125,6 +125,7 @@ files:
|
|
125
125
|
- lib/dogapi/v1/gcp_integration.rb
|
126
126
|
- lib/dogapi/v1/hosts.rb
|
127
127
|
- lib/dogapi/v1/integration.rb
|
128
|
+
- lib/dogapi/v1/logs_pipeline.rb
|
128
129
|
- lib/dogapi/v1/metadata.rb
|
129
130
|
- lib/dogapi/v1/metric.rb
|
130
131
|
- lib/dogapi/v1/monitor.rb
|
@@ -153,6 +154,7 @@ files:
|
|
153
154
|
- spec/integration/event_spec.rb
|
154
155
|
- spec/integration/gcp_integration_spec.rb
|
155
156
|
- spec/integration/integration_spec.rb
|
157
|
+
- spec/integration/logs_pipeline_spec.rb
|
156
158
|
- spec/integration/metadata_spec.rb
|
157
159
|
- spec/integration/metric_spec.rb
|
158
160
|
- spec/integration/monitor_spec.rb
|
@@ -216,6 +218,7 @@ test_files:
|
|
216
218
|
- spec/integration/event_spec.rb
|
217
219
|
- spec/integration/gcp_integration_spec.rb
|
218
220
|
- spec/integration/integration_spec.rb
|
221
|
+
- spec/integration/logs_pipeline_spec.rb
|
219
222
|
- spec/integration/metadata_spec.rb
|
220
223
|
- spec/integration/metric_spec.rb
|
221
224
|
- spec/integration/monitor_spec.rb
|