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
@@ -0,0 +1,63 @@
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
+ CONFIG = {
9
+ tenant_name: 'testc44-1234-5678-9101-cc00736ftest',
10
+ client_id: 'testc7f6-1234-5678-9101-3fcbf464test'
11
+ }.freeze
12
+
13
+ CREATE_CONFIG = {
14
+ tenant_name: 'testc44-1234-5678-9101-cc00736ftest',
15
+ host_filters: 'api:test',
16
+ client_id: 'testc7f6-1234-5678-9101-3fcbf464test',
17
+ client_secret: 'testingx./Sw*g/Y33t..R1cH+hScMDt'
18
+ }.freeze
19
+
20
+ UPDATE_HF_CONFIG = {
21
+ tenant_name: 'testc44-1234-5678-9101-cc00736ftest',
22
+ host_filters: 'api:test1,api:test2',
23
+ client_id: 'testc7f6-1234-5678-9101-3fcbf464test'
24
+ }.freeze
25
+
26
+ UPDATE_CONFIG = {
27
+ tenant_name: 'testc44-1234-5678-9101-cc00736ftest',
28
+ new_tenant_name: '1234abcd-1234-5678-9101-abcd1234abcd',
29
+ host_filters: 'api:test3',
30
+ client_id: 'testc7f6-1234-5678-9101-3fcbf464test',
31
+ new_client_id: 'abcd1234-5678-1234-5678-1234abcd5678'
32
+ }.freeze
33
+
34
+ describe '#azure_integration_list' do
35
+ it_behaves_like 'an api method',
36
+ :azure_integration_list, nil,
37
+ :get, '/integration/azure'
38
+ end
39
+
40
+ describe '#azure_integration_create' do
41
+ it_behaves_like 'an api method',
42
+ :azure_integration_create, [CREATE_CONFIG],
43
+ :post, '/integration/azure', CREATE_CONFIG
44
+ end
45
+
46
+ describe '#azure_integration_update_host_filters' do
47
+ it_behaves_like 'an api method',
48
+ :azure_integration_update_host_filters, [UPDATE_HF_CONFIG],
49
+ :post, '/integration/azure/host_filters', UPDATE_HF_CONFIG
50
+ end
51
+
52
+ describe '#azure_integration_update' do
53
+ it_behaves_like 'an api method',
54
+ :azure_integration_update, [UPDATE_CONFIG],
55
+ :put, '/integration/azure', UPDATE_CONFIG
56
+ end
57
+
58
+ describe '#azure_integration_delete' do
59
+ it_behaves_like 'an api method',
60
+ :azure_integration_delete, [CONFIG],
61
+ :delete, '/integration/azure', CONFIG
62
+ end
63
+ end
@@ -1,4 +1,9 @@
1
1
  # encoding: utf-8
2
+
3
+ # Unless explicitly stated otherwise all files in this repository are licensed under the BSD-3-Clause License.
4
+ # This product includes software developed at Datadog (https://www.datadoghq.com/).
5
+ # Copyright 2011-Present Datadog, Inc.
6
+
2
7
  require_relative '../spec_helper'
3
8
 
4
9
  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::APIService 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
@@ -19,12 +23,14 @@ describe Dogapi::Client do
19
23
  'prefix' => 'host',
20
24
  'default' => 'host:my-host'
21
25
  }].freeze
26
+ READ_ONLY = false
22
27
 
23
28
  DASH_BODY = {
24
29
  title: TITLE,
25
30
  description: DESCRIPTION,
26
31
  graphs: GRAPHS,
27
- template_variables: TEMPLATE_VARIABLES
32
+ template_variables: TEMPLATE_VARIABLES,
33
+ read_only: READ_ONLY
28
34
  }.freeze
29
35
  DASH_ARGS = DASH_BODY.values
30
36
 
@@ -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,4 +1,9 @@
1
1
  # encoding: utf-8
2
+
3
+ # Unless explicitly stated otherwise all files in this repository are licensed under the BSD-3-Clause License.
4
+ # This product includes software developed at Datadog (https://www.datadoghq.com/).
5
+ # Copyright 2011-Present Datadog, Inc.
6
+
2
7
  require_relative '../spec_helper'
3
8
 
4
9
  describe Dogapi::Client do
@@ -0,0 +1,57 @@
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
+ CONFIG = {
9
+ project_id: 'datadog-apitest',
10
+ client_email: 'email@example.com'
11
+ }.freeze
12
+
13
+ CREATE_CONFIG = {
14
+ type: 'service_account',
15
+ project_id: 'datadog-apitest',
16
+ private_key_id: '123456789abcdefghi123456789abcdefghijklm',
17
+ private_key: 'fake_key',
18
+ client_email: 'email@example.com',
19
+ client_id: '123456712345671234567',
20
+ auth_uri: 'fake_uri',
21
+ token_uri: 'fake_uri',
22
+ auth_provider_x509_cert_url: 'fake_url',
23
+ client_x509_cert_url: 'fake_url',
24
+ host_filters: 'api:test'
25
+ }.freeze
26
+
27
+ UPDATE_CONFIG = {
28
+ project_id: 'datadog-apitest',
29
+ client_email: 'email@example.com',
30
+ host_filters: 'api:test1,api:test2',
31
+ automute: false
32
+ }.freeze
33
+
34
+ describe '#gcp_integration_list' do
35
+ it_behaves_like 'an api method',
36
+ :gcp_integration_list, nil,
37
+ :get, '/integration/gcp'
38
+ end
39
+
40
+ describe '#gcp_integration_create' do
41
+ it_behaves_like 'an api method',
42
+ :gcp_integration_create, [CREATE_CONFIG],
43
+ :post, '/integration/gcp', CREATE_CONFIG
44
+ end
45
+
46
+ describe '#gcp_integration_update' do
47
+ it_behaves_like 'an api method',
48
+ :gcp_integration_update, [UPDATE_CONFIG],
49
+ :put, '/integration/gcp', UPDATE_CONFIG
50
+ end
51
+
52
+ describe '#gcp_integration_delete' do
53
+ it_behaves_like 'an api method',
54
+ :gcp_integration_delete, [CONFIG],
55
+ :delete, '/integration/gcp', CONFIG
56
+ end
57
+ 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_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_relative '../spec_helper'
2
6
 
3
7
  describe Dogapi::Client do
@@ -27,12 +31,37 @@ describe Dogapi::Client do
27
31
  :get, "/monitor/#{MONITOR_ID}", group_states: %w(custom all)
28
32
  end
29
33
 
34
+ describe '#can_delete_monitors' do
35
+ context 'with one id' do
36
+ it_behaves_like 'an api method',
37
+ :can_delete_monitors, [MONITOR_ID],
38
+ :get, '/monitor/can_delete'
39
+ end
40
+
41
+ context 'with multiple ids' do
42
+ it_behaves_like 'an api method',
43
+ :can_delete_monitors, [[MONITOR_ID, MONITOR_ID + 1, MONITOR_ID + 2]],
44
+ :get, '/monitor/can_delete'
45
+ end
46
+ end
47
+
30
48
  describe '#delete_monitor' do
31
49
  it_behaves_like 'an api method',
32
50
  :delete_monitor, [MONITOR_ID],
33
51
  :delete, "/monitor/#{MONITOR_ID}"
34
52
  end
35
53
 
54
+ describe '#delete_monitor with options' do
55
+ it 'queries the api with options' do
56
+ url = api_url + "/monitor/#{MONITOR_ID}?force=true"
57
+ options = { 'force' => true }
58
+ stub_request(:delete, url).to_return(body: '{}').then.to_raise(StandardError)
59
+ expect(dog.send(:delete_monitor, MONITOR_ID, options)).to eq ['200', {}]
60
+
61
+ expect(WebMock).to have_requested(:delete, url)
62
+ end
63
+ end
64
+
36
65
  describe '#get_all_monitors' do
37
66
  it_behaves_like 'an api method with optional params',
38
67
  :get_all_monitors, [],
@@ -102,7 +131,7 @@ describe Dogapi::Client do
102
131
  describe '#cancel_downtime_by_scope' do
103
132
  it_behaves_like 'an api method',
104
133
  :cancel_downtime_by_scope, [DOWNTIME_SCOPE],
105
- :post, '/downtime/cancel/by_scope'
134
+ :post, '/downtime/cancel/by_scope', 'scope' => DOWNTIME_SCOPE
106
135
  end
107
136
 
108
137
  describe '#get_all_downtimes' 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_relative '../spec_helper'
2
6
 
3
7
  describe Dogapi::Client do
@@ -11,19 +11,21 @@ describe Dogapi::Client do
11
11
  SLO_THRESHOLDS = [{ timeframe: '7d', target: 90 }, { timeframe: '30d', target: 95 }].freeze
12
12
 
13
13
  describe '#create_service_level_objective' do
14
- it_behaves_like 'an api method with named args',
15
- :create_service_level_objective, {type: SLO_TYPE, name: SLO_NAME, description: SLO_DESCRIPTION,
16
- tags: SLO_TAGS, thresholds: SLO_THRESHOLDS,
17
- numerator: SLO_QUERY_NUMERATOR,
18
- denominator: SLO_QUERY_DENOMINATOR},
14
+ it_behaves_like 'an api method',
15
+ :create_service_level_objective, [SLO_TYPE, SLO_NAME, SLO_THRESHOLDS, {
16
+ description: SLO_DESCRIPTION,
17
+ tags: SLO_TAGS,
18
+ numerator: SLO_QUERY_NUMERATOR,
19
+ denominator: SLO_QUERY_DENOMINATOR
20
+ }],
19
21
  :post, '/slo', 'type' => SLO_TYPE, 'name' => SLO_NAME, 'thresholds' => SLO_THRESHOLDS,
20
22
  'query' => { numerator: SLO_QUERY_NUMERATOR, denominator: SLO_QUERY_DENOMINATOR },
21
23
  'tags' => SLO_TAGS, 'description' => SLO_DESCRIPTION
22
24
  end
23
25
 
24
26
  describe '#update_service_level_objective' do
25
- it_behaves_like 'an api method with named args',
26
- :update_service_level_objective, {slo_id: SLO_ID, type: SLO_TYPE, name: SLO_NAME},
27
+ it_behaves_like 'an api method',
28
+ :update_service_level_objective, [SLO_ID, SLO_TYPE, { name: SLO_NAME }],
27
29
  :put, "/slo/#{SLO_ID}", 'type' => SLO_TYPE, 'name' => SLO_NAME
28
30
  end
29
31
 
@@ -36,18 +38,18 @@ describe Dogapi::Client do
36
38
  describe '#get_service_level_objective_history' do
37
39
  it_behaves_like 'an api method with params',
38
40
  :get_service_level_objective_history, [SLO_ID],
39
- :get, "/slo/#{SLO_ID}/history", 'from_ts' => 0, 'to_ts' => 1000000
41
+ :get, "/slo/#{SLO_ID}/history", 'from_ts' => 0, 'to_ts' => 1_000_000
40
42
  end
41
43
 
42
44
  describe '#can_delete_service_level_objective' do
43
45
  it_behaves_like 'an api method with params',
44
46
  :can_delete_service_level_objective, [],
45
- :get, "/slo/can_delete", 'ids' => [SLO_ID]
47
+ :get, '/slo/can_delete', 'ids' => [SLO_ID]
46
48
  end
47
49
 
48
50
  describe '#search_service_level_objective' do
49
- it_behaves_like 'an api method with named args making params',
50
- :search_service_level_objective, {slo_ids: [SLO_ID]},
51
+ it_behaves_like 'an api method with optional params',
52
+ :search_service_level_objective, [[SLO_ID]],
51
53
  :get, '/slo/', 'ids' => SLO_ID
52
54
  end
53
55
 
@@ -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
@@ -0,0 +1,131 @@
1
+ require_relative '../spec_helper'
2
+
3
+ describe Dogapi::Client do
4
+ SYNTHETICS_TEST_PUBLIC_ID = '84r-szk-xpt'
5
+ SYNTHETICS_TESTS_PUBLIC_IDS = ['84r-szk-xpt', 'sti-s2m-ciz']
6
+ NEW_STATUS = 'paused'
7
+ SYNTHETICS_RESULT_ID = 123_456
8
+
9
+ SYNTHETICS_TEST_TYPE = 'api'.freeze
10
+ SYNTHETICS_TEST_CONFIG = {
11
+ 'assertions' => [
12
+ {
13
+ 'operator' => 'is',
14
+ 'type' => 'statusCode',
15
+ 'target' => 403
16
+ },
17
+ {
18
+ 'operator' => 'is',
19
+ 'property' => 'content-type',
20
+ 'type' => 'header',
21
+ 'target' => 'text/html'
22
+ },
23
+ {
24
+ 'operator' => 'lessThan',
25
+ 'type' => 'responseTime',
26
+ 'target' => 2000
27
+ }
28
+ ],
29
+ 'request' => {
30
+ 'method' => 'GET',
31
+ 'url' => 'https://datadoghq.com',
32
+ 'timeout' => 30,
33
+ 'headers' => {
34
+ 'header1' => 'value1',
35
+ 'header2' => 'value2'
36
+ },
37
+ 'body' => 'body to send with the request'
38
+ }
39
+ }.freeze
40
+
41
+ SYNTHETICS_TEST_OPTIONS = {
42
+ 'locations' => [
43
+ 'aws:us-east-2',
44
+ 'aws:eu-central-1',
45
+ 'aws:ca-central-1'
46
+ ],
47
+ 'options' => {
48
+ 'tick_every' => 60,
49
+ 'min_failure_duration' => 0,
50
+ 'min_location_failed' => 1,
51
+ 'follow_redirects' => true
52
+ },
53
+ 'message' => 'Test with API',
54
+ 'name' => 'Test with API',
55
+ 'tags' => ['key1:value1', 'key2:value2']
56
+ }.freeze
57
+
58
+ describe '#create_synthetics_test' do
59
+ it 'queries the api' do
60
+ url = api_url + '/synthetics/tests'
61
+ stub_request(:post, /#{url}/).to_return(body: '{}').then.to_raise(StandardError)
62
+ expect(dog.send(:create_synthetics_test, SYNTHETICS_TEST_TYPE, SYNTHETICS_TEST_CONFIG,
63
+ SYNTHETICS_TEST_OPTIONS)).to eq ['200', {}]
64
+
65
+ expect(WebMock).to have_requested(:post, url)
66
+ end
67
+ end
68
+
69
+ describe '#update_synthetics_test' do
70
+ it 'queries the api' do
71
+ url = api_url + "/synthetics/tests/#{SYNTHETICS_TEST_PUBLIC_ID}"
72
+ stub_request(:put, /#{url}/).to_return(body: '{}').then.to_raise(StandardError)
73
+ expect(dog.send(:update_synthetics_test, SYNTHETICS_TEST_PUBLIC_ID, SYNTHETICS_TEST_TYPE,
74
+ SYNTHETICS_TEST_CONFIG, SYNTHETICS_TEST_OPTIONS)).to eq ['200', {}]
75
+
76
+ expect(WebMock).to have_requested(:put, url)
77
+ end
78
+ end
79
+
80
+ describe '#delete_synthetics_tests' do
81
+ it_behaves_like 'an api method',
82
+ :delete_synthetics_tests, [SYNTHETICS_TESTS_PUBLIC_IDS],
83
+ :post, '/synthetics/tests/delete', 'public_ids' => SYNTHETICS_TESTS_PUBLIC_IDS
84
+ end
85
+
86
+ describe '#start_pause_synthetics_test' do
87
+ it_behaves_like 'an api method',
88
+ :start_pause_synthetics_test, [SYNTHETICS_TEST_PUBLIC_ID, NEW_STATUS],
89
+ :put, "/synthetics/tests/#{SYNTHETICS_TEST_PUBLIC_ID}/status", 'new_status' => NEW_STATUS
90
+ end
91
+
92
+ describe '#get_all_synthetics_tests' do
93
+ it_behaves_like 'an api method',
94
+ :get_all_synthetics_tests, [],
95
+ :get, '/synthetics/tests'
96
+ end
97
+
98
+ describe '#get_synthetics_test' do
99
+ it_behaves_like 'an api method',
100
+ :get_synthetics_test, [SYNTHETICS_TEST_PUBLIC_ID],
101
+ :get, "/synthetics/tests/#{SYNTHETICS_TEST_PUBLIC_ID}"
102
+ end
103
+
104
+ describe '#get_synthetics_results' do
105
+ it_behaves_like 'an api method',
106
+ :get_synthetics_results, [SYNTHETICS_TEST_PUBLIC_ID],
107
+ :get, "/synthetics/tests/#{SYNTHETICS_TEST_PUBLIC_ID}/results"
108
+ end
109
+
110
+ describe '#get_synthetics_result' do
111
+ it 'queries the api' do
112
+ url = api_url + "/synthetics/tests/#{SYNTHETICS_TEST_PUBLIC_ID}/results/#{SYNTHETICS_RESULT_ID}"
113
+ stub_request(:get, /#{url}/).to_return(body: '{}').then.to_raise(StandardError)
114
+ expect(dog.send(:get_synthetics_result, SYNTHETICS_TEST_PUBLIC_ID, SYNTHETICS_RESULT_ID)).to eq ['200', {}]
115
+
116
+ expect(WebMock).to have_requested(:get, url)
117
+ end
118
+ end
119
+
120
+ describe '#get_synthetics_devices' do
121
+ it_behaves_like 'an api method',
122
+ :get_synthetics_devices, [],
123
+ :get, '/synthetics/browser/devices'
124
+ end
125
+
126
+ describe '#get_synthetics_locations' do
127
+ it_behaves_like 'an api method',
128
+ :get_synthetics_locations, [],
129
+ :get, '/synthetics/locations'
130
+ end
131
+ end