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.
Files changed (41) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop_todo.yml +1 -0
  3. data/CHANGELOG.md +7 -0
  4. data/Gemfile_1.9 +1 -0
  5. data/lib/capistrano/datadog.rb +2 -2
  6. data/lib/capistrano/datadog/v2.rb +2 -2
  7. data/lib/capistrano/datadog/v3.rb +3 -2
  8. data/lib/dogapi/common.rb +2 -2
  9. data/lib/dogapi/facade.rb +25 -0
  10. data/lib/dogapi/v1.rb +1 -0
  11. data/lib/dogapi/v1/alert.rb +0 -2
  12. data/lib/dogapi/v1/aws_integration.rb +0 -2
  13. data/lib/dogapi/v1/aws_logs.rb +0 -2
  14. data/lib/dogapi/v1/azure_integration.rb +0 -2
  15. data/lib/dogapi/v1/comment.rb +0 -2
  16. data/lib/dogapi/v1/dash.rb +0 -2
  17. data/lib/dogapi/v1/dashboard.rb +0 -2
  18. data/lib/dogapi/v1/dashboard_list.rb +0 -2
  19. data/lib/dogapi/v1/embed.rb +0 -2
  20. data/lib/dogapi/v1/event.rb +0 -2
  21. data/lib/dogapi/v1/gcp_integration.rb +0 -2
  22. data/lib/dogapi/v1/hosts.rb +0 -2
  23. data/lib/dogapi/v1/integration.rb +0 -2
  24. data/lib/dogapi/v1/logs_pipeline.rb +41 -0
  25. data/lib/dogapi/v1/metadata.rb +0 -2
  26. data/lib/dogapi/v1/metric.rb +0 -2
  27. data/lib/dogapi/v1/monitor.rb +0 -2
  28. data/lib/dogapi/v1/screenboard.rb +0 -2
  29. data/lib/dogapi/v1/search.rb +0 -2
  30. data/lib/dogapi/v1/service_check.rb +0 -2
  31. data/lib/dogapi/v1/service_level_objective.rb +3 -1
  32. data/lib/dogapi/v1/snapshot.rb +0 -2
  33. data/lib/dogapi/v1/synthetics.rb +3 -1
  34. data/lib/dogapi/v1/tag.rb +0 -2
  35. data/lib/dogapi/v1/usage.rb +0 -2
  36. data/lib/dogapi/v1/user.rb +0 -2
  37. data/lib/dogapi/v2/dashboard_list.rb +0 -2
  38. data/lib/dogapi/version.rb +1 -1
  39. data/spec/integration/logs_pipeline_spec.rb +43 -0
  40. data/spec/unit/common_spec.rb +10 -10
  41. metadata +5 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c64317943c656727e705f3ba310961de9fa8b3fda8fbcb976095d634d7311ecd
4
- data.tar.gz: bb3f1977f9bd6bcd6d22779e23e247803b7800a1a0770e266d461878b68d574c
3
+ metadata.gz: 1ef3fbebc71af23718db2e177c11400648e47e0e770c8783021a8e7a1b7df099
4
+ data.tar.gz: 59ef0c8d5c187e7161a25166b468fa91c640ab568dd22992aa037b38c7461ff1
5
5
  SHA512:
6
- metadata.gz: f2814b96964abfc35ade6827652aed52c0b2795aa71f47a4a8a9152d7f97a013bb18680060657df015aeb0cb925cce58a16780c67df56397256d9e4c10aa8fcc
7
- data.tar.gz: f9b7cb7ec7486d40af67d12ad68e44787e3e890efb0a98a9a5093875eba00eb0c19556a6b4fd35246611ffdc4cfe3b1aa2750750d001f6e145a8fe52085aac46
6
+ metadata.gz: 48239d6fd49a735c74eb4c95f97093c0e599a8d11d868e784cb08ce1a96ce0a6da6b942e78afadc870fcb7e09bf0b53205c0517d502029cc17d3c3a378d5bbfa
7
+ data.tar.gz: 658b9c7f91b18e7744b1d3761e6e1d5212e527f293d09ba4a00f3303602262c46cf0c5743ec317e4bdb353286a1c94a9de51b86285b9513f310e7f6e72f4ca0c
@@ -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'
@@ -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).
@@ -7,4 +7,5 @@ group :test do
7
7
  gem 'rspec'
8
8
  gem 'simplecov', "~> 0.11.2"
9
9
  gem 'webmock'
10
+ gem 'crack', '<= 0.4.4'
10
11
  end
@@ -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
@@ -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
@@ -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
  #
@@ -9,6 +9,7 @@ require 'dogapi/v1/dashboard'
9
9
  require 'dogapi/v1/dashboard_list'
10
10
  require 'dogapi/v1/embed'
11
11
  require 'dogapi/v1/event'
12
+ require 'dogapi/v1/logs_pipeline'
12
13
  require 'dogapi/v1/metadata'
13
14
  require 'dogapi/v1/metric'
14
15
  require 'dogapi/v1/monitor'
@@ -2,8 +2,6 @@
2
2
  # This product includes software developed at Datadog (https://www.datadoghq.com/).
3
3
  # Copyright 2011-Present Datadog, Inc.
4
4
 
5
- require 'dogapi'
6
-
7
5
  module Dogapi
8
6
  class V1 # for namespacing
9
7
 
@@ -2,8 +2,6 @@
2
2
  # This product includes software developed at Datadog (https://www.datadoghq.com/).
3
3
  # Copyright 2011-Present Datadog, Inc.
4
4
 
5
- require 'dogapi'
6
-
7
5
  module Dogapi
8
6
  class V1 # for namespacing
9
7
 
@@ -2,8 +2,6 @@
2
2
  # This product includes software developed at Datadog (https://www.datadoghq.com/).
3
3
  # Copyright 2011-Present Datadog, Inc.
4
4
 
5
- require 'dogapi'
6
-
7
5
  module Dogapi
8
6
  class V1 # for namespacing
9
7
 
@@ -2,8 +2,6 @@
2
2
  # This product includes software developed at Datadog (https://www.datadoghq.com/).
3
3
  # Copyright 2011-Present Datadog, Inc.
4
4
 
5
- require 'dogapi'
6
-
7
5
  module Dogapi
8
6
  class V1 # for namespacing
9
7
 
@@ -2,8 +2,6 @@
2
2
  # This product includes software developed at Datadog (https://www.datadoghq.com/).
3
3
  # Copyright 2011-Present Datadog, Inc.
4
4
 
5
- require 'dogapi'
6
-
7
5
  module Dogapi
8
6
  class V1 # for namespacing
9
7
 
@@ -2,8 +2,6 @@
2
2
  # This product includes software developed at Datadog (https://www.datadoghq.com/).
3
3
  # Copyright 2011-Present Datadog, Inc.
4
4
 
5
- require 'dogapi'
6
-
7
5
  module Dogapi
8
6
  class V1 # for namespacing
9
7
 
@@ -2,8 +2,6 @@
2
2
  # This product includes software developed at Datadog (https://www.datadoghq.com/).
3
3
  # Copyright 2011-Present Datadog, Inc.
4
4
 
5
- require 'dogapi'
6
-
7
5
  module Dogapi
8
6
  class V1 # for namespacing
9
7
 
@@ -2,8 +2,6 @@
2
2
  # This product includes software developed at Datadog (https://www.datadoghq.com/).
3
3
  # Copyright 2011-Present Datadog, Inc.
4
4
 
5
- require 'dogapi'
6
-
7
5
  module Dogapi
8
6
  class V1 # for namespacing
9
7
 
@@ -2,8 +2,6 @@
2
2
  # This product includes software developed at Datadog (https://www.datadoghq.com/).
3
3
  # Copyright 2011-Present Datadog, Inc.
4
4
 
5
- require 'dogapi'
6
-
7
5
  module Dogapi
8
6
  class V1 # for namespacing
9
7
 
@@ -2,8 +2,6 @@
2
2
  # This product includes software developed at Datadog (https://www.datadoghq.com/).
3
3
  # Copyright 2011-Present Datadog, Inc.
4
4
 
5
- require 'dogapi'
6
-
7
5
  module Dogapi
8
6
  class V1 # for namespacing
9
7
 
@@ -2,8 +2,6 @@
2
2
  # This product includes software developed at Datadog (https://www.datadoghq.com/).
3
3
  # Copyright 2011-Present Datadog, Inc.
4
4
 
5
- require 'dogapi'
6
-
7
5
  module Dogapi
8
6
  class V1 # for namespacing
9
7
 
@@ -2,8 +2,6 @@
2
2
  # This product includes software developed at Datadog (https://www.datadoghq.com/).
3
3
  # Copyright 2011-Present Datadog, Inc.
4
4
 
5
- require 'dogapi'
6
-
7
5
  module Dogapi
8
6
  class V1 # for namespacing
9
7
 
@@ -2,8 +2,6 @@
2
2
  # This product includes software developed at Datadog (https://www.datadoghq.com/).
3
3
  # Copyright 2011-Present Datadog, Inc.
4
4
 
5
- require 'dogapi'
6
-
7
5
  module Dogapi
8
6
  class V1 # for namespacing
9
7
 
@@ -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
@@ -2,8 +2,6 @@
2
2
  # This product includes software developed at Datadog (https://www.datadoghq.com/).
3
3
  # Copyright 2011-Present Datadog, Inc.
4
4
 
5
- require 'dogapi'
6
-
7
5
  module Dogapi
8
6
  class V1
9
7
 
@@ -2,8 +2,6 @@
2
2
  # This product includes software developed at Datadog (https://www.datadoghq.com/).
3
3
  # Copyright 2011-Present Datadog, Inc.
4
4
 
5
- require 'dogapi'
6
-
7
5
  module Dogapi
8
6
  class V1 # for namespacing
9
7
 
@@ -2,8 +2,6 @@
2
2
  # This product includes software developed at Datadog (https://www.datadoghq.com/).
3
3
  # Copyright 2011-Present Datadog, Inc.
4
4
 
5
- require 'dogapi'
6
-
7
5
  module Dogapi
8
6
  class V1 # for namespacing
9
7
  class MonitorService < Dogapi::APIService
@@ -2,8 +2,6 @@
2
2
  # This product includes software developed at Datadog (https://www.datadoghq.com/).
3
3
  # Copyright 2011-Present Datadog, Inc.
4
4
 
5
- require 'dogapi'
6
-
7
5
  module Dogapi
8
6
  class V1 # for namespacing
9
7
 
@@ -2,8 +2,6 @@
2
2
  # This product includes software developed at Datadog (https://www.datadoghq.com/).
3
3
  # Copyright 2011-Present Datadog, Inc.
4
4
 
5
- require 'dogapi'
6
-
7
5
  module Dogapi
8
6
  class V1 # for namespacing
9
7
 
@@ -2,8 +2,6 @@
2
2
  # This product includes software developed at Datadog (https://www.datadoghq.com/).
3
3
  # Copyright 2011-Present Datadog, Inc.
4
4
 
5
- require 'dogapi'
6
-
7
5
  module Dogapi
8
6
  class V1
9
7
 
@@ -1,4 +1,6 @@
1
- require 'dogapi'
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
@@ -2,8 +2,6 @@
2
2
  # This product includes software developed at Datadog (https://www.datadoghq.com/).
3
3
  # Copyright 2011-Present Datadog, Inc.
4
4
 
5
- require 'dogapi'
6
-
7
5
  module Dogapi
8
6
  class V1 # for namespacing
9
7
 
@@ -1,4 +1,6 @@
1
- require 'dogapi'
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
@@ -2,8 +2,6 @@
2
2
  # This product includes software developed at Datadog (https://www.datadoghq.com/).
3
3
  # Copyright 2011-Present Datadog, Inc.
4
4
 
5
- require 'dogapi'
6
-
7
5
  module Dogapi
8
6
  class V1 # for namespacing
9
7
 
@@ -2,8 +2,6 @@
2
2
  # This product includes software developed at Datadog (https://www.datadoghq.com/).
3
3
  # Copyright 2011-Present Datadog, Inc.
4
4
 
5
- require 'dogapi'
6
-
7
5
  module Dogapi
8
6
  class V1 # for namespacing
9
7
 
@@ -2,8 +2,6 @@
2
2
  # This product includes software developed at Datadog (https://www.datadoghq.com/).
3
3
  # Copyright 2011-Present Datadog, Inc.
4
4
 
5
- require 'dogapi'
6
-
7
5
  module Dogapi
8
6
  class V1 # for namespacing
9
7
 
@@ -2,8 +2,6 @@
2
2
  # This product includes software developed at Datadog (https://www.datadoghq.com/).
3
3
  # Copyright 2011-Present Datadog, Inc.
4
4
 
5
- require 'dogapi'
6
-
7
5
  module Dogapi
8
6
  class V2 # for namespacing
9
7
 
@@ -3,5 +3,5 @@
3
3
  # Copyright 2011-Present Datadog, Inc.
4
4
 
5
5
  module Dogapi
6
- VERSION = '1.44.0'
6
+ VERSION = '1.45.0'
7
7
  end
@@ -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
@@ -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.44.0
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: 2020-12-10 00:00:00.000000000 Z
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