dogapi 1.33.0 → 1.34.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: ec1cf46eb8ec6d3e512ac08b5385d62d70f6f28caa48a7681724cdacefc68b45
4
- data.tar.gz: 47ca869de7d878e680a8bf1f12c315a02a9075d452aa7f1bb69100c03e8ccb11
3
+ metadata.gz: cfe067279d23444bbc1c35c0978cab82aa5f2e24ec4fd989c392855f15063a9e
4
+ data.tar.gz: b8b74019176e0a732eb6800bb57693c54268f2b82a99acc0185b836d3e7cc379
5
5
  SHA512:
6
- metadata.gz: 54c9fe2f7463c547e96c769e0cfd9d8f30c4ebe4651c1d921d8737d4ba4c901b899d6b990e41ed221e008dc7d419ddac8e4f7a6989a2c39879763aa4c2d85fbb
7
- data.tar.gz: bbe2fb112fb558b719896153ad7016e787ca376cc40f68e22ab7fe2e24ae2957ee52c2868d148958e613d49e8e3e3abaeb85752ec7f404d3eb76d97ddf1ceccd
6
+ metadata.gz: b4f44f988385adaac78e4dff13d4f9dda996848097cc6ca62f445c87f4c4ce7858dd5164ec01f04bbb08ea4f60b12769187d4f818b6733a74dbae7a407a279eb
7
+ data.tar.gz: 54d88863dd12a3a1b4e7dd3ddeeb017dd9ba245b1d811c65e041608c7b30917fef333ec08204c8cb6f1f1ee870458c28a5a991594fddb21e721d9ad67b1697ab
data/.rubocop_todo.yml CHANGED
@@ -338,6 +338,7 @@ Style/Documentation:
338
338
  - 'lib/dogapi/v1/service_check.rb'
339
339
  - 'lib/dogapi/v1/snapshot.rb'
340
340
  - 'lib/dogapi/v1/user.rb'
341
+ - 'lib/dogapi/v1/integration.rb'
341
342
 
342
343
  # Offense count: 1
343
344
  # Cop supports --auto-correct.
data/CHANGELOG.md CHANGED
@@ -1,5 +1,9 @@
1
1
  # Changes
2
2
 
3
+ ## 1.34.0 / 2019-03-08
4
+
5
+ * [FEATURE] Add /integration endpoints. See [#170][], thanks [@davidcpell][].
6
+
3
7
  ## 1.33.0 / 2019-02-13
4
8
 
5
9
  * [IMPROVEMENT] Add submission types mentioned in the API documentation. See [#165][], thanks [@TaylURRE][]
@@ -225,6 +229,7 @@ This is the last release compatible with Ruby 1.8. ([EOL 2013-06-30](https://www
225
229
  [#163]: https://github.com/DataDog/dogapi-rb/issues/163
226
230
  [#165]: https://github.com/DataDog/dogapi-rb/issues/165
227
231
  [#167]: https://github.com/DataDog/dogapi-rb/issues/167
232
+ [#170]: https://github.com/DataDog/dogapi-rb/issues/170
228
233
  [@ArjenSchwarz]: https://github.com/ArjenSchwarz
229
234
  [@Kaixiang]: https://github.com/Kaixiang
230
235
  [@TaylURRE]: https://github.com/TaylURRE
@@ -234,6 +239,7 @@ This is the last release compatible with Ruby 1.8. ([EOL 2013-06-30](https://www
234
239
  [@blakehilscher]: https://github.com/blakehilscher
235
240
  [@byroot]: https://github.com/byroot
236
241
  [@casperisfine]: https://github.com/casperisfine
242
+ [@davidcpell]: https://github.com/davidcpell
237
243
  [@edwardkenfox]: https://github.com/edwardkenfox
238
244
  [@enbashi]: https://github.com/enbashi
239
245
  [@haohcraft]: https://github.com/haohcraft
data/lib/dogapi/facade.rb CHANGED
@@ -48,6 +48,7 @@ module Dogapi
48
48
  @metadata_svc = Dogapi::V1::MetadataService.new(@api_key, @application_key, silent, timeout, @datadog_host)
49
49
  @legacy_event_svc = Dogapi::EventService.new(@datadog_host)
50
50
  @hosts_svc = Dogapi::V1::HostsService.new(@api_key, @application_key, silent, timeout, @datadog_host)
51
+ @integration_svc = Dogapi::V1::IntegrationService.new(@api_key, @application_key, silent, timeout, @datadog_host)
51
52
  end
52
53
 
53
54
  #
@@ -595,6 +596,26 @@ module Dogapi
595
596
  @hosts_svc.totals()
596
597
  end
597
598
 
599
+ #
600
+ # INTEGRATIONS
601
+ #
602
+
603
+ def create_integration(source_type_name, config)
604
+ @integration_svc.create_integration(source_type_name, config)
605
+ end
606
+
607
+ def update_integration(source_type_name, config)
608
+ @integration_svc.update_integration(source_type_name, config)
609
+ end
610
+
611
+ def get_integration(source_type_name)
612
+ @integration_svc.get_integration(source_type_name)
613
+ end
614
+
615
+ def delete_integration(source_type_name)
616
+ @integration_svc.delete_integration(source_type_name)
617
+ end
618
+
598
619
  private
599
620
 
600
621
  def override_scope(options= {})
data/lib/dogapi/v1.rb CHANGED
@@ -15,3 +15,4 @@ require 'dogapi/v1/snapshot'
15
15
  require 'dogapi/v1/tag'
16
16
  require 'dogapi/v1/user'
17
17
  require 'dogapi/v1/hosts'
18
+ require 'dogapi/v1/integration'
@@ -0,0 +1,45 @@
1
+ require 'dogapi'
2
+
3
+ module Dogapi
4
+ class V1 # for namespacing
5
+
6
+ class IntegrationService < Dogapi::APIService
7
+
8
+ API_VERSION = 'v1'
9
+
10
+ # Create an integration
11
+ #
12
+ # :source_type_name => String: the name of an integration source
13
+ # :config => Hash: integration config that varies based on the source type.
14
+ # See https://docs.datadoghq.com/api/#integrations.
15
+ def create_integration(source_type_name, config)
16
+ request(Net::HTTP::Post, "/api/#{API_VERSION}/integration/#{source_type_name}", nil, config, true)
17
+ end
18
+
19
+ # Update an integration
20
+ #
21
+ # :source_type_name => String: the name of an integration source
22
+ # :config => Hash: integration config that varies based on the source type.
23
+ # source type (https://docs.datadoghq.com/api/#integrations)
24
+ def update_integration(source_type_name, config)
25
+ request(Net::HTTP::Put, "/api/#{API_VERSION}/integration/#{source_type_name}", nil, config, true)
26
+ end
27
+
28
+ # Retrieve integration information
29
+ #
30
+ # :source_type_name => String: the name of an integration source
31
+ def get_integration(source_type_name)
32
+ request(Net::HTTP::Get, "/api/#{API_VERSION}/integration/#{source_type_name}", nil, nil, false)
33
+ end
34
+
35
+ # Delete an integration
36
+ #
37
+ # :source_type_name => String: the name of an integration source
38
+ def delete_integration(source_type_name)
39
+ request(Net::HTTP::Delete, "/api/#{API_VERSION}/integration/#{source_type_name}", nil, nil, false)
40
+ end
41
+
42
+ end
43
+
44
+ end
45
+ end
@@ -1,3 +1,3 @@
1
1
  module Dogapi
2
- VERSION = '1.33.0'
2
+ VERSION = '1.34.0'
3
3
  end
@@ -0,0 +1,44 @@
1
+ require_relative '../spec_helper'
2
+
3
+ describe Dogapi::Client do
4
+ SOURCE_TYPE_NAME = 'pagerduty'.freeze
5
+ PAGERDUTY_SERVICES = {
6
+ services: [
7
+ {
8
+ service_name: 'test_00',
9
+ service_key: '<PAGERDUTY_SERVICE_KEY>'
10
+ },
11
+ {
12
+ service_name: 'test_01',
13
+ service_key: '<PAGERDUTY_SERVICE_KEY>'
14
+ }
15
+ ],
16
+ subdomain: '<PAGERDUTY_SUB_DOMAIN>',
17
+ schedules: ['<SCHEDULE_1>', '<SCHEDULE_2>'],
18
+ api_token: '<PAGERDUTY_TOKEN>'
19
+ }.freeze
20
+
21
+ describe '#create_integration' do
22
+ it_behaves_like 'an api method',
23
+ :create_integration, [SOURCE_TYPE_NAME, PAGERDUTY_SERVICES],
24
+ :post, "/integration/#{SOURCE_TYPE_NAME}", PAGERDUTY_SERVICES
25
+ end
26
+
27
+ describe '#get_integration' do
28
+ it_behaves_like 'an api method',
29
+ :get_integration, [SOURCE_TYPE_NAME],
30
+ :get, "/integration/#{SOURCE_TYPE_NAME}"
31
+ end
32
+
33
+ describe '#update_integration' do
34
+ it_behaves_like 'an api method',
35
+ :update_integration, [SOURCE_TYPE_NAME, PAGERDUTY_SERVICES],
36
+ :put, "/integration/#{SOURCE_TYPE_NAME}", PAGERDUTY_SERVICES
37
+ end
38
+
39
+ describe '#delete_integration' do
40
+ it_behaves_like 'an api method',
41
+ :delete_integration, [SOURCE_TYPE_NAME],
42
+ :delete, "/integration/#{SOURCE_TYPE_NAME}"
43
+ end
44
+ 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.33.0
4
+ version: 1.34.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-02-13 00:00:00.000000000 Z
11
+ date: 2019-03-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: multi_json
@@ -107,6 +107,7 @@ files:
107
107
  - lib/dogapi/v1/embed.rb
108
108
  - lib/dogapi/v1/event.rb
109
109
  - lib/dogapi/v1/hosts.rb
110
+ - lib/dogapi/v1/integration.rb
110
111
  - lib/dogapi/v1/metadata.rb
111
112
  - lib/dogapi/v1/metric.rb
112
113
  - lib/dogapi/v1/monitor.rb
@@ -125,6 +126,7 @@ files:
125
126
  - spec/integration/dashboard_spec.rb
126
127
  - spec/integration/embed_spec.rb
127
128
  - spec/integration/event_spec.rb
129
+ - spec/integration/integration_spec.rb
128
130
  - spec/integration/metadata_spec.rb
129
131
  - spec/integration/metric_spec.rb
130
132
  - spec/integration/monitor_spec.rb
@@ -180,6 +182,7 @@ test_files:
180
182
  - spec/integration/dashboard_spec.rb
181
183
  - spec/integration/embed_spec.rb
182
184
  - spec/integration/event_spec.rb
185
+ - spec/integration/integration_spec.rb
183
186
  - spec/integration/metadata_spec.rb
184
187
  - spec/integration/metric_spec.rb
185
188
  - spec/integration/monitor_spec.rb