dogapi 1.37.1 → 1.38.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,55 @@
1
+ require_relative '../spec_helper'
2
+
3
+ describe Dogapi::Client do
4
+ CONFIG = {
5
+ account_id: '123456789101',
6
+ lambda_arn: 'arn:aws:lambda:us-east-1:123456789101:function:LogsCollectionAPITest'
7
+ }.freeze
8
+
9
+ SERVICES_CONFIG = {
10
+ account_id: '601427279990',
11
+ services: %w([s3] [elb] [elbv2] [cloudfront] [redshift] [lambda])
12
+ }.freeze
13
+
14
+ describe '#aws_logs_add_lambda' do
15
+ it_behaves_like 'an api method',
16
+ :aws_logs_add_lambda, [CONFIG],
17
+ :post, '/integration/aws/logs', CONFIG
18
+ end
19
+
20
+ describe '#aws_logs_save_services' do
21
+ it_behaves_like 'an api method',
22
+ :aws_logs_save_services, [SERVICES_CONFIG],
23
+ :post, '/integration/aws/logs/services', SERVICES_CONFIG
24
+ end
25
+
26
+ describe '#aws_logs_check_services' do
27
+ it_behaves_like 'an api method',
28
+ :aws_logs_check_services, [SERVICES_CONFIG],
29
+ :post, '/integration/aws/logs/services_async', SERVICES_CONFIG
30
+ end
31
+
32
+ describe '#aws_logs_check_lambda' do
33
+ it_behaves_like 'an api method',
34
+ :aws_logs_check_lambda, [CONFIG],
35
+ :post, '/integration/aws/logs/check_async', CONFIG
36
+ end
37
+
38
+ describe '#aws_logs_list_services' do
39
+ it_behaves_like 'an api method',
40
+ :aws_logs_list_services, nil,
41
+ :get, '/integration/aws/logs/services'
42
+ end
43
+
44
+ describe '#aws_logs_integrations_list' do
45
+ it_behaves_like 'an api method',
46
+ :aws_logs_integrations_list, nil,
47
+ :get, '/integration/aws/logs'
48
+ end
49
+
50
+ describe '#aws_logs_integration_delete' do
51
+ it_behaves_like 'an api method',
52
+ :aws_logs_integration_delete, [CONFIG],
53
+ :delete, '/integration/aws/logs', CONFIG
54
+ end
55
+ end
@@ -0,0 +1,59 @@
1
+ require_relative '../spec_helper'
2
+
3
+ describe Dogapi::Client do
4
+ CONFIG = {
5
+ tenant_name: 'testc44-1234-5678-9101-cc00736ftest',
6
+ client_id: 'testc7f6-1234-5678-9101-3fcbf464test'
7
+ }.freeze
8
+
9
+ CREATE_CONFIG = {
10
+ tenant_name: 'testc44-1234-5678-9101-cc00736ftest',
11
+ host_filters: 'api:test',
12
+ client_id: 'testc7f6-1234-5678-9101-3fcbf464test',
13
+ client_secret: 'testingx./Sw*g/Y33t..R1cH+hScMDt'
14
+ }.freeze
15
+
16
+ UPDATE_HF_CONFIG = {
17
+ tenant_name: 'testc44-1234-5678-9101-cc00736ftest',
18
+ host_filters: 'api:test1,api:test2',
19
+ client_id: 'testc7f6-1234-5678-9101-3fcbf464test'
20
+ }.freeze
21
+
22
+ UPDATE_CONFIG = {
23
+ tenant_name: 'testc44-1234-5678-9101-cc00736ftest',
24
+ new_tenant_name: '1234abcd-1234-5678-9101-abcd1234abcd',
25
+ host_filters: 'api:test3',
26
+ client_id: 'testc7f6-1234-5678-9101-3fcbf464test',
27
+ new_client_id: 'abcd1234-5678-1234-5678-1234abcd5678'
28
+ }.freeze
29
+
30
+ describe '#azure_integration_list' do
31
+ it_behaves_like 'an api method',
32
+ :azure_integration_list, nil,
33
+ :get, '/integration/azure'
34
+ end
35
+
36
+ describe '#azure_integration_create' do
37
+ it_behaves_like 'an api method',
38
+ :azure_integration_create, [CREATE_CONFIG],
39
+ :post, '/integration/azure', CREATE_CONFIG
40
+ end
41
+
42
+ describe '#azure_integration_update_host_filters' do
43
+ it_behaves_like 'an api method',
44
+ :azure_integration_update_host_filters, [UPDATE_HF_CONFIG],
45
+ :post, '/integration/azure/host_filters', UPDATE_HF_CONFIG
46
+ end
47
+
48
+ describe '#azure_integration_update' do
49
+ it_behaves_like 'an api method',
50
+ :azure_integration_update, [UPDATE_CONFIG],
51
+ :put, '/integration/azure', UPDATE_CONFIG
52
+ end
53
+
54
+ describe '#azure_integration_delete' do
55
+ it_behaves_like 'an api method',
56
+ :azure_integration_delete, [CONFIG],
57
+ :delete, '/integration/azure', CONFIG
58
+ end
59
+ end
@@ -0,0 +1,53 @@
1
+ require_relative '../spec_helper'
2
+
3
+ describe Dogapi::Client do
4
+ CONFIG = {
5
+ project_id: 'datadog-apitest',
6
+ client_email: 'email@example.com'
7
+ }.freeze
8
+
9
+ CREATE_CONFIG = {
10
+ type: 'service_account',
11
+ project_id: 'datadog-apitest',
12
+ private_key_id: '123456789abcdefghi123456789abcdefghijklm',
13
+ private_key: 'fake_key',
14
+ client_email: 'email@example.com',
15
+ client_id: '123456712345671234567',
16
+ auth_uri: 'fake_uri',
17
+ token_uri: 'fake_uri',
18
+ auth_provider_x509_cert_url: 'fake_url',
19
+ client_x509_cert_url: 'fake_url',
20
+ host_filters: 'api:test'
21
+ }.freeze
22
+
23
+ UPDATE_CONFIG = {
24
+ project_id: 'datadog-apitest',
25
+ client_email: 'email@example.com',
26
+ host_filters: 'api:test1,api:test2',
27
+ automute: false
28
+ }.freeze
29
+
30
+ describe '#gcp_integration_list' do
31
+ it_behaves_like 'an api method',
32
+ :gcp_integration_list, nil,
33
+ :get, '/integration/gcp'
34
+ end
35
+
36
+ describe '#gcp_integration_create' do
37
+ it_behaves_like 'an api method',
38
+ :gcp_integration_create, [CREATE_CONFIG],
39
+ :post, '/integration/gcp', CREATE_CONFIG
40
+ end
41
+
42
+ describe '#gcp_integration_update' do
43
+ it_behaves_like 'an api method',
44
+ :gcp_integration_update, [UPDATE_CONFIG],
45
+ :put, '/integration/gcp', UPDATE_CONFIG
46
+ end
47
+
48
+ describe '#gcp_integration_delete' do
49
+ it_behaves_like 'an api method',
50
+ :gcp_integration_delete, [CONFIG],
51
+ :delete, '/integration/gcp', CONFIG
52
+ end
53
+ end
@@ -27,6 +27,20 @@ describe Dogapi::Client do
27
27
  :get, "/monitor/#{MONITOR_ID}", group_states: %w(custom all)
28
28
  end
29
29
 
30
+ describe '#can_delete_monitors' do
31
+ context 'with one id' do
32
+ it_behaves_like 'an api method',
33
+ :can_delete_monitors, [MONITOR_ID],
34
+ :get, '/monitor/can_delete'
35
+ end
36
+
37
+ context 'with multiple ids' do
38
+ it_behaves_like 'an api method',
39
+ :can_delete_monitors, [[MONITOR_ID, MONITOR_ID + 1, MONITOR_ID + 2]],
40
+ :get, '/monitor/can_delete'
41
+ end
42
+ end
43
+
30
44
  describe '#delete_monitor' do
31
45
  it_behaves_like 'an api method',
32
46
  :delete_monitor, [MONITOR_ID],
@@ -102,7 +116,7 @@ describe Dogapi::Client do
102
116
  describe '#cancel_downtime_by_scope' do
103
117
  it_behaves_like 'an api method',
104
118
  :cancel_downtime_by_scope, [DOWNTIME_SCOPE],
105
- :post, '/downtime/cancel/by_scope'
119
+ :post, '/downtime/cancel/by_scope', 'scope' => DOWNTIME_SCOPE
106
120
  end
107
121
 
108
122
  describe '#get_all_downtimes' do
@@ -73,6 +73,23 @@ module SpecDog
73
73
  end
74
74
  end
75
75
 
76
+ shared_examples 'an api method with params and body' do |command, args, request, endpoint, params, body|
77
+ it 'queries the api with params and body' do
78
+ url = api_url + endpoint
79
+ stub_request(request, /#{url}/).to_return(body: '{}').then.to_raise(StandardError)
80
+ expect(dog.send(command, *args)).to eq ['200', {}]
81
+ params.each { |k, v| params[k] = v.join(',') if v.is_a? Array }
82
+ params = params
83
+
84
+ body = MultiJson.dump(body) if body
85
+
86
+ expect(WebMock).to have_requested(request, url).with(
87
+ query: params,
88
+ body: body
89
+ )
90
+ end
91
+ end
92
+
76
93
  shared_examples 'an api method with optional params' do |command, args, request, endpoint, opt_params|
77
94
  include_examples 'an api method', command, args, request, endpoint
78
95
  it 'queries the api with optional params' do
@@ -65,11 +65,12 @@ describe 'Common' do
65
65
  '/api/v1/screen']
66
66
 
67
67
  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
68
+ expect(service.should_set_api_and_app_keys_in_params?(url)).to be true
69
+ params = service.prepare_params(nil, url, true)
70
+ expect(params).to eq("?api_key=#{service.api_key}&application_key=#{service.application_key}")
71
+ req = service.prepare_request(Net::HTTP::Get, url, params, nil, false, true)
72
+ expect(req.key?('DD-API-KEY')).to be false
73
+ expect(req.key?('DD-APPLICATION-KEY')).to be false
73
74
  end
74
75
  end
75
76
 
@@ -82,8 +83,14 @@ describe 'Common' do
82
83
  '/api/v2/users']
83
84
 
84
85
  urls.each do |url|
85
- params = service.set_api_and_app_keys_in_params(url, true)
86
- expect(params).to eq({})
86
+ expect(service.should_set_api_and_app_keys_in_params?(url)).to be false
87
+ params = service.prepare_params(nil, url, true)
88
+ expect(params).to eq('?')
89
+ req = service.prepare_request(Net::HTTP::Get, url, params, nil, false, true)
90
+ expect(req.key?('DD-API-KEY')).to be true
91
+ expect(req['DD-API-KEY']).to eq service.api_key
92
+ expect(req.key?('DD-APPLICATION-KEY')).to be true
93
+ expect(req['DD-APPLICATION-KEY']).to eq service.application_key
87
94
  end
88
95
  end
89
96
  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.37.1
4
+ version: 1.38.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-05 00:00:00.000000000 Z
11
+ date: 2019-12-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: multi_json
@@ -82,6 +82,7 @@ files:
82
82
  - ".tailor"
83
83
  - CHANGELOG.md
84
84
  - Gemfile
85
+ - Gemfile_1.9
85
86
  - LICENSE
86
87
  - README.rdoc
87
88
  - Rakefile
@@ -100,12 +101,16 @@ files:
100
101
  - lib/dogapi/metric.rb
101
102
  - lib/dogapi/v1.rb
102
103
  - lib/dogapi/v1/alert.rb
104
+ - lib/dogapi/v1/aws_integration.rb
105
+ - lib/dogapi/v1/aws_logs.rb
106
+ - lib/dogapi/v1/azure_integration.rb
103
107
  - lib/dogapi/v1/comment.rb
104
108
  - lib/dogapi/v1/dash.rb
105
109
  - lib/dogapi/v1/dashboard.rb
106
110
  - lib/dogapi/v1/dashboard_list.rb
107
111
  - lib/dogapi/v1/embed.rb
108
112
  - lib/dogapi/v1/event.rb
113
+ - lib/dogapi/v1/gcp_integration.rb
109
114
  - lib/dogapi/v1/hosts.rb
110
115
  - lib/dogapi/v1/integration.rb
111
116
  - lib/dogapi/v1/metadata.rb
@@ -122,6 +127,9 @@ files:
122
127
  - lib/dogapi/v2/dashboard_list.rb
123
128
  - lib/dogapi/version.rb
124
129
  - spec/integration/alert_spec.rb
130
+ - spec/integration/aws_integration_spec.rb
131
+ - spec/integration/aws_logs_spec.rb
132
+ - spec/integration/azure_integration_spec.rb
125
133
  - spec/integration/comment_spec.rb
126
134
  - spec/integration/common_spec.rb
127
135
  - spec/integration/dash_spec.rb
@@ -129,6 +137,7 @@ files:
129
137
  - spec/integration/dashboard_spec.rb
130
138
  - spec/integration/embed_spec.rb
131
139
  - spec/integration/event_spec.rb
140
+ - spec/integration/gcp_integration_spec.rb
132
141
  - spec/integration/integration_spec.rb
133
142
  - spec/integration/metadata_spec.rb
134
143
  - spec/integration/metric_spec.rb
@@ -180,6 +189,9 @@ specification_version: 4
180
189
  summary: Ruby bindings for Datadog's API
181
190
  test_files:
182
191
  - spec/integration/alert_spec.rb
192
+ - spec/integration/aws_integration_spec.rb
193
+ - spec/integration/aws_logs_spec.rb
194
+ - spec/integration/azure_integration_spec.rb
183
195
  - spec/integration/comment_spec.rb
184
196
  - spec/integration/common_spec.rb
185
197
  - spec/integration/dash_spec.rb
@@ -187,6 +199,7 @@ test_files:
187
199
  - spec/integration/dashboard_spec.rb
188
200
  - spec/integration/embed_spec.rb
189
201
  - spec/integration/event_spec.rb
202
+ - spec/integration/gcp_integration_spec.rb
190
203
  - spec/integration/integration_spec.rb
191
204
  - spec/integration/metadata_spec.rb
192
205
  - spec/integration/metric_spec.rb