lex-dynatrace 0.1.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 (80) hide show
  1. checksums.yaml +7 -0
  2. data/.github/workflows/ci.yml +34 -0
  3. data/.rubocop.yml +31 -0
  4. data/CHANGELOG.md +24 -0
  5. data/Gemfile +13 -0
  6. data/README.md +92 -0
  7. data/lex-dynatrace.gemspec +37 -0
  8. data/lib/legion/extensions/dynatrace/active_gates/client.rb +17 -0
  9. data/lib/legion/extensions/dynatrace/active_gates/runners/active_gates.rb +35 -0
  10. data/lib/legion/extensions/dynatrace/active_gates.rb +13 -0
  11. data/lib/legion/extensions/dynatrace/attacks/client.rb +17 -0
  12. data/lib/legion/extensions/dynatrace/attacks/runners/attacks.rb +34 -0
  13. data/lib/legion/extensions/dynatrace/attacks.rb +13 -0
  14. data/lib/legion/extensions/dynatrace/audit_logs/client.rb +17 -0
  15. data/lib/legion/extensions/dynatrace/audit_logs/runners/audit_logs.rb +31 -0
  16. data/lib/legion/extensions/dynatrace/audit_logs.rb +13 -0
  17. data/lib/legion/extensions/dynatrace/base_client.rb +25 -0
  18. data/lib/legion/extensions/dynatrace/business_events/client.rb +17 -0
  19. data/lib/legion/extensions/dynatrace/business_events/runners/business_events.rb +37 -0
  20. data/lib/legion/extensions/dynatrace/business_events.rb +13 -0
  21. data/lib/legion/extensions/dynatrace/credentials/client.rb +17 -0
  22. data/lib/legion/extensions/dynatrace/credentials/runners/credentials.rb +45 -0
  23. data/lib/legion/extensions/dynatrace/credentials.rb +13 -0
  24. data/lib/legion/extensions/dynatrace/deployment/client.rb +17 -0
  25. data/lib/legion/extensions/dynatrace/deployment/runners/deployment.rb +33 -0
  26. data/lib/legion/extensions/dynatrace/deployment.rb +13 -0
  27. data/lib/legion/extensions/dynatrace/entities/client.rb +17 -0
  28. data/lib/legion/extensions/dynatrace/entities/runners/entities.rb +48 -0
  29. data/lib/legion/extensions/dynatrace/entities.rb +13 -0
  30. data/lib/legion/extensions/dynatrace/events/client.rb +17 -0
  31. data/lib/legion/extensions/dynatrace/events/runners/events.rb +42 -0
  32. data/lib/legion/extensions/dynatrace/events.rb +13 -0
  33. data/lib/legion/extensions/dynatrace/extensions20/client.rb +17 -0
  34. data/lib/legion/extensions/dynatrace/extensions20/runners/extensions.rb +87 -0
  35. data/lib/legion/extensions/dynatrace/extensions20.rb +13 -0
  36. data/lib/legion/extensions/dynatrace/geographic_regions/client.rb +17 -0
  37. data/lib/legion/extensions/dynatrace/geographic_regions/runners/geographic_regions.rb +26 -0
  38. data/lib/legion/extensions/dynatrace/geographic_regions.rb +13 -0
  39. data/lib/legion/extensions/dynatrace/helpers/client.rb +24 -0
  40. data/lib/legion/extensions/dynatrace/logs/client.rb +17 -0
  41. data/lib/legion/extensions/dynatrace/logs/runners/logs.rb +37 -0
  42. data/lib/legion/extensions/dynatrace/logs.rb +13 -0
  43. data/lib/legion/extensions/dynatrace/metrics/client.rb +17 -0
  44. data/lib/legion/extensions/dynatrace/metrics/runners/metrics.rb +48 -0
  45. data/lib/legion/extensions/dynatrace/metrics.rb +13 -0
  46. data/lib/legion/extensions/dynatrace/network_zones/client.rb +17 -0
  47. data/lib/legion/extensions/dynatrace/network_zones/runners/network_zones.rb +38 -0
  48. data/lib/legion/extensions/dynatrace/network_zones.rb +13 -0
  49. data/lib/legion/extensions/dynatrace/problems/client.rb +17 -0
  50. data/lib/legion/extensions/dynatrace/problems/runners/problems.rb +54 -0
  51. data/lib/legion/extensions/dynatrace/problems.rb +13 -0
  52. data/lib/legion/extensions/dynatrace/releases/client.rb +17 -0
  53. data/lib/legion/extensions/dynatrace/releases/runners/releases.rb +31 -0
  54. data/lib/legion/extensions/dynatrace/releases.rb +13 -0
  55. data/lib/legion/extensions/dynatrace/security_problems/client.rb +17 -0
  56. data/lib/legion/extensions/dynatrace/security_problems/runners/security_problems.rb +55 -0
  57. data/lib/legion/extensions/dynatrace/security_problems.rb +13 -0
  58. data/lib/legion/extensions/dynatrace/settings_objects/client.rb +19 -0
  59. data/lib/legion/extensions/dynatrace/settings_objects/runners/objects.rb +45 -0
  60. data/lib/legion/extensions/dynatrace/settings_objects/runners/schemas.rb +26 -0
  61. data/lib/legion/extensions/dynatrace/settings_objects.rb +14 -0
  62. data/lib/legion/extensions/dynatrace/slos/client.rb +17 -0
  63. data/lib/legion/extensions/dynatrace/slos/runners/slos.rb +54 -0
  64. data/lib/legion/extensions/dynatrace/slos.rb +13 -0
  65. data/lib/legion/extensions/dynatrace/synthetic/client.rb +19 -0
  66. data/lib/legion/extensions/dynatrace/synthetic/runners/locations.rb +25 -0
  67. data/lib/legion/extensions/dynatrace/synthetic/runners/monitors.rb +46 -0
  68. data/lib/legion/extensions/dynatrace/synthetic.rb +14 -0
  69. data/lib/legion/extensions/dynatrace/tags/client.rb +17 -0
  70. data/lib/legion/extensions/dynatrace/tags/runners/tags.rb +34 -0
  71. data/lib/legion/extensions/dynatrace/tags.rb +13 -0
  72. data/lib/legion/extensions/dynatrace/tokens/client.rb +17 -0
  73. data/lib/legion/extensions/dynatrace/tokens/runners/tokens.rb +54 -0
  74. data/lib/legion/extensions/dynatrace/tokens.rb +13 -0
  75. data/lib/legion/extensions/dynatrace/units/client.rb +17 -0
  76. data/lib/legion/extensions/dynatrace/units/runners/units.rb +32 -0
  77. data/lib/legion/extensions/dynatrace/units.rb +13 -0
  78. data/lib/legion/extensions/dynatrace/version.rb +9 -0
  79. data/lib/legion/extensions/dynatrace.rb +35 -0
  80. metadata +234 -0
@@ -0,0 +1,54 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Legion
4
+ module Extensions
5
+ module Dynatrace
6
+ module Problems
7
+ module Runners
8
+ module Problems
9
+ def list_problems(problem_selector: nil, fields: nil, from: nil, to: nil, sort: nil,
10
+ page_size: nil, next_page_key: nil, **opts)
11
+ conn = opts[:connection] || connection(**opts)
12
+ params = {}
13
+ params[:problemSelector] = problem_selector if problem_selector
14
+ params[:fields] = fields if fields
15
+ params[:from] = from if from
16
+ params[:to] = to if to
17
+ params[:sort] = sort if sort
18
+ params[:pageSize] = page_size if page_size
19
+ params[:nextPageKey] = next_page_key if next_page_key
20
+ conn.get('api/v2/problems', params).body
21
+ end
22
+
23
+ def get_problem(problem_id:, fields: nil, **opts)
24
+ conn = opts[:connection] || connection(**opts)
25
+ params = {}
26
+ params[:fields] = fields if fields
27
+ conn.get("api/v2/problems/#{problem_id}", params).body
28
+ end
29
+
30
+ def close_problem(problem_id:, message:, **opts)
31
+ conn = opts[:connection] || connection(**opts)
32
+ conn.post("api/v2/problems/#{problem_id}/close", { message: message }).body
33
+ end
34
+
35
+ def list_comments(problem_id:, page_size: nil, next_page_key: nil, **opts)
36
+ conn = opts[:connection] || connection(**opts)
37
+ params = {}
38
+ params[:pageSize] = page_size if page_size
39
+ params[:nextPageKey] = next_page_key if next_page_key
40
+ conn.get("api/v2/problems/#{problem_id}/comments", params).body
41
+ end
42
+
43
+ def create_comment(problem_id:, message:, context: nil, **opts)
44
+ conn = opts[:connection] || connection(**opts)
45
+ payload = { message: message }
46
+ payload[:context] = context if context
47
+ conn.post("api/v2/problems/#{problem_id}/comments", payload).body
48
+ end
49
+ end
50
+ end
51
+ end
52
+ end
53
+ end
54
+ end
@@ -0,0 +1,13 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative 'problems/runners/problems'
4
+ require_relative 'problems/client'
5
+
6
+ module Legion
7
+ module Extensions
8
+ module Dynatrace
9
+ module Problems
10
+ end
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,17 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative '../helpers/client'
4
+ require_relative '../base_client'
5
+ require_relative 'runners/releases'
6
+
7
+ module Legion
8
+ module Extensions
9
+ module Dynatrace
10
+ module Releases
11
+ class Client < Legion::Extensions::Dynatrace::BaseClient
12
+ include Runners::Releases
13
+ end
14
+ end
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,31 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Legion
4
+ module Extensions
5
+ module Dynatrace
6
+ module Releases
7
+ module Runners
8
+ module Releases
9
+ def list_releases(release_selector: nil, from: nil, to: nil, sort: nil,
10
+ page_size: nil, next_page_key: nil, **opts)
11
+ conn = opts[:connection] || connection(**opts)
12
+ params = {}
13
+ params[:releaseSelector] = release_selector if release_selector
14
+ params[:from] = from if from
15
+ params[:to] = to if to
16
+ params[:sort] = sort if sort
17
+ params[:pageSize] = page_size if page_size
18
+ params[:nextPageKey] = next_page_key if next_page_key
19
+ conn.get('api/v2/releases', params).body
20
+ end
21
+
22
+ def get_release(release_id:, **opts)
23
+ conn = opts[:connection] || connection(**opts)
24
+ conn.get("api/v2/releases/#{release_id}").body
25
+ end
26
+ end
27
+ end
28
+ end
29
+ end
30
+ end
31
+ end
@@ -0,0 +1,13 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative 'releases/runners/releases'
4
+ require_relative 'releases/client'
5
+
6
+ module Legion
7
+ module Extensions
8
+ module Dynatrace
9
+ module Releases
10
+ end
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,17 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative '../helpers/client'
4
+ require_relative '../base_client'
5
+ require_relative 'runners/security_problems'
6
+
7
+ module Legion
8
+ module Extensions
9
+ module Dynatrace
10
+ module SecurityProblems
11
+ class Client < Legion::Extensions::Dynatrace::BaseClient
12
+ include Runners::SecurityProblems
13
+ end
14
+ end
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,55 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Legion
4
+ module Extensions
5
+ module Dynatrace
6
+ module SecurityProblems
7
+ module Runners
8
+ module SecurityProblems
9
+ def list_security_problems(security_problem_selector: nil, from: nil, to: nil, fields: nil,
10
+ sort: nil, page_size: nil, next_page_key: nil, **opts)
11
+ conn = opts[:connection] || connection(**opts)
12
+ params = {}
13
+ params[:securityProblemSelector] = security_problem_selector if security_problem_selector
14
+ params[:from] = from if from
15
+ params[:to] = to if to
16
+ params[:fields] = fields if fields
17
+ params[:sort] = sort if sort
18
+ params[:pageSize] = page_size if page_size
19
+ params[:nextPageKey] = next_page_key if next_page_key
20
+ conn.get('api/v2/securityProblems', params).body
21
+ end
22
+
23
+ def get_security_problem(security_problem_id:, fields: nil, **opts)
24
+ conn = opts[:connection] || connection(**opts)
25
+ params = {}
26
+ params[:fields] = fields if fields
27
+ conn.get("api/v2/securityProblems/#{security_problem_id}", params).body
28
+ end
29
+
30
+ def mute_security_problem(security_problem_id:, reason:, comment: nil, **opts)
31
+ conn = opts[:connection] || connection(**opts)
32
+ payload = { reason: reason }
33
+ payload[:comment] = comment if comment
34
+ conn.post("api/v2/securityProblems/#{security_problem_id}/mute", payload).body
35
+ end
36
+
37
+ def unmute_security_problem(security_problem_id:, reason:, comment: nil, **opts)
38
+ conn = opts[:connection] || connection(**opts)
39
+ payload = { reason: reason }
40
+ payload[:comment] = comment if comment
41
+ conn.post("api/v2/securityProblems/#{security_problem_id}/unmute", payload).body
42
+ end
43
+
44
+ def list_remediations(security_problem_id:, remediation_type: nil, **opts)
45
+ conn = opts[:connection] || connection(**opts)
46
+ params = {}
47
+ params[:remediationType] = remediation_type if remediation_type
48
+ conn.get("api/v2/securityProblems/#{security_problem_id}/remediationItems", params).body
49
+ end
50
+ end
51
+ end
52
+ end
53
+ end
54
+ end
55
+ end
@@ -0,0 +1,13 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative 'security_problems/runners/security_problems'
4
+ require_relative 'security_problems/client'
5
+
6
+ module Legion
7
+ module Extensions
8
+ module Dynatrace
9
+ module SecurityProblems
10
+ end
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,19 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative '../helpers/client'
4
+ require_relative '../base_client'
5
+ require_relative 'runners/objects'
6
+ require_relative 'runners/schemas'
7
+
8
+ module Legion
9
+ module Extensions
10
+ module Dynatrace
11
+ module SettingsObjects
12
+ class Client < Legion::Extensions::Dynatrace::BaseClient
13
+ include Runners::Objects
14
+ include Runners::Schemas
15
+ end
16
+ end
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,45 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Legion
4
+ module Extensions
5
+ module Dynatrace
6
+ module SettingsObjects
7
+ module Runners
8
+ module Objects
9
+ def list_objects(schema_ids: nil, scopes: nil, fields: nil,
10
+ page_size: nil, next_page_key: nil, **opts)
11
+ conn = opts[:connection] || connection(**opts)
12
+ params = {}
13
+ params[:schemaIds] = schema_ids if schema_ids
14
+ params[:scopes] = scopes if scopes
15
+ params[:fields] = fields if fields
16
+ params[:pageSize] = page_size if page_size
17
+ params[:nextPageKey] = next_page_key if next_page_key
18
+ conn.get('api/v2/settings/objects', params).body
19
+ end
20
+
21
+ def get_object(object_id:, **opts)
22
+ conn = opts[:connection] || connection(**opts)
23
+ conn.get("api/v2/settings/objects/#{object_id}").body
24
+ end
25
+
26
+ def create_objects(body:, **opts)
27
+ conn = opts[:connection] || connection(**opts)
28
+ conn.post('api/v2/settings/objects', body).body
29
+ end
30
+
31
+ def update_object(object_id:, body:, **opts)
32
+ conn = opts[:connection] || connection(**opts)
33
+ conn.put("api/v2/settings/objects/#{object_id}", body).body
34
+ end
35
+
36
+ def delete_object(object_id:, **opts)
37
+ conn = opts[:connection] || connection(**opts)
38
+ conn.delete("api/v2/settings/objects/#{object_id}").body
39
+ end
40
+ end
41
+ end
42
+ end
43
+ end
44
+ end
45
+ end
@@ -0,0 +1,26 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Legion
4
+ module Extensions
5
+ module Dynatrace
6
+ module SettingsObjects
7
+ module Runners
8
+ module Schemas
9
+ def list_schemas(page_size: nil, next_page_key: nil, **opts)
10
+ conn = opts[:connection] || connection(**opts)
11
+ params = {}
12
+ params[:pageSize] = page_size if page_size
13
+ params[:nextPageKey] = next_page_key if next_page_key
14
+ conn.get('api/v2/settings/schemas', params).body
15
+ end
16
+
17
+ def get_schema(schema_id:, **opts)
18
+ conn = opts[:connection] || connection(**opts)
19
+ conn.get("api/v2/settings/schemas/#{schema_id}").body
20
+ end
21
+ end
22
+ end
23
+ end
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,14 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative 'settings_objects/runners/objects'
4
+ require_relative 'settings_objects/runners/schemas'
5
+ require_relative 'settings_objects/client'
6
+
7
+ module Legion
8
+ module Extensions
9
+ module Dynatrace
10
+ module SettingsObjects
11
+ end
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,17 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative '../helpers/client'
4
+ require_relative '../base_client'
5
+ require_relative 'runners/slos'
6
+
7
+ module Legion
8
+ module Extensions
9
+ module Dynatrace
10
+ module Slos
11
+ class Client < Legion::Extensions::Dynatrace::BaseClient
12
+ include Runners::Slos
13
+ end
14
+ end
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,54 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Legion
4
+ module Extensions
5
+ module Dynatrace
6
+ module Slos
7
+ module Runners
8
+ module Slos
9
+ def list_slos(slo_selector: nil, from: nil, to: nil, page_size: nil,
10
+ next_page_key: nil, sort: nil, time_frame: nil,
11
+ demo: nil, evaluate: nil, **opts)
12
+ conn = opts[:connection] || connection(**opts)
13
+ params = {}
14
+ params[:sloSelector] = slo_selector if slo_selector
15
+ params[:from] = from if from
16
+ params[:to] = to if to
17
+ params[:pageSize] = page_size if page_size
18
+ params[:nextPageKey] = next_page_key if next_page_key
19
+ params[:sort] = sort if sort
20
+ params[:timeFrame] = time_frame if time_frame
21
+ params[:demo] = demo unless demo.nil?
22
+ params[:evaluate] = evaluate unless evaluate.nil?
23
+ conn.get('api/v2/slo', params).body
24
+ end
25
+
26
+ def get_slo(slo_id:, from: nil, to: nil, time_frame: nil, **opts)
27
+ conn = opts[:connection] || connection(**opts)
28
+ params = {}
29
+ params[:from] = from if from
30
+ params[:to] = to if to
31
+ params[:timeFrame] = time_frame if time_frame
32
+ conn.get("api/v2/slo/#{slo_id}", params).body
33
+ end
34
+
35
+ def create_slo(slo:, **opts)
36
+ conn = opts[:connection] || connection(**opts)
37
+ conn.post('api/v2/slo', slo).body
38
+ end
39
+
40
+ def update_slo(slo_id:, slo:, **opts)
41
+ conn = opts[:connection] || connection(**opts)
42
+ conn.put("api/v2/slo/#{slo_id}", slo).body
43
+ end
44
+
45
+ def delete_slo(slo_id:, **opts)
46
+ conn = opts[:connection] || connection(**opts)
47
+ conn.delete("api/v2/slo/#{slo_id}").body
48
+ end
49
+ end
50
+ end
51
+ end
52
+ end
53
+ end
54
+ end
@@ -0,0 +1,13 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative 'slos/runners/slos'
4
+ require_relative 'slos/client'
5
+
6
+ module Legion
7
+ module Extensions
8
+ module Dynatrace
9
+ module Slos
10
+ end
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,19 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative '../helpers/client'
4
+ require_relative '../base_client'
5
+ require_relative 'runners/monitors'
6
+ require_relative 'runners/locations'
7
+
8
+ module Legion
9
+ module Extensions
10
+ module Dynatrace
11
+ module Synthetic
12
+ class Client < Legion::Extensions::Dynatrace::BaseClient
13
+ include Runners::Monitors
14
+ include Runners::Locations
15
+ end
16
+ end
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,25 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Legion
4
+ module Extensions
5
+ module Dynatrace
6
+ module Synthetic
7
+ module Runners
8
+ module Locations
9
+ def list_locations(location_type: nil, **opts)
10
+ conn = opts[:connection] || connection(**opts)
11
+ params = {}
12
+ params[:locationType] = location_type if location_type
13
+ conn.get('api/v2/synthetic/locations', params).body
14
+ end
15
+
16
+ def get_location(location_id:, **opts)
17
+ conn = opts[:connection] || connection(**opts)
18
+ conn.get("api/v2/synthetic/locations/#{location_id}").body
19
+ end
20
+ end
21
+ end
22
+ end
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,46 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Legion
4
+ module Extensions
5
+ module Dynatrace
6
+ module Synthetic
7
+ module Runners
8
+ module Monitors
9
+ def list_monitors(page_size: nil, next_page_key: nil, **opts)
10
+ conn = opts[:connection] || connection(**opts)
11
+ params = {}
12
+ params[:pageSize] = page_size if page_size
13
+ params[:nextPageKey] = next_page_key if next_page_key
14
+ conn.get('api/v2/synthetic/monitors', params).body
15
+ end
16
+
17
+ def get_monitor(monitor_id:, **opts)
18
+ conn = opts[:connection] || connection(**opts)
19
+ conn.get("api/v2/synthetic/monitors/#{monitor_id}").body
20
+ end
21
+
22
+ def create_monitor(monitor:, **opts)
23
+ conn = opts[:connection] || connection(**opts)
24
+ conn.post('api/v2/synthetic/monitors', monitor).body
25
+ end
26
+
27
+ def update_monitor(monitor_id:, monitor:, **opts)
28
+ conn = opts[:connection] || connection(**opts)
29
+ conn.put("api/v2/synthetic/monitors/#{monitor_id}", monitor).body
30
+ end
31
+
32
+ def delete_monitor(monitor_id:, **opts)
33
+ conn = opts[:connection] || connection(**opts)
34
+ conn.delete("api/v2/synthetic/monitors/#{monitor_id}").body
35
+ end
36
+
37
+ def get_execution(execution_id:, **opts)
38
+ conn = opts[:connection] || connection(**opts)
39
+ conn.get("api/v2/synthetic/executions/#{execution_id}/fullReport").body
40
+ end
41
+ end
42
+ end
43
+ end
44
+ end
45
+ end
46
+ end
@@ -0,0 +1,14 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative 'synthetic/runners/monitors'
4
+ require_relative 'synthetic/runners/locations'
5
+ require_relative 'synthetic/client'
6
+
7
+ module Legion
8
+ module Extensions
9
+ module Dynatrace
10
+ module Synthetic
11
+ end
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,17 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative '../helpers/client'
4
+ require_relative '../base_client'
5
+ require_relative 'runners/tags'
6
+
7
+ module Legion
8
+ module Extensions
9
+ module Dynatrace
10
+ module Tags
11
+ class Client < Legion::Extensions::Dynatrace::BaseClient
12
+ include Runners::Tags
13
+ end
14
+ end
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,34 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'cgi'
4
+
5
+ module Legion
6
+ module Extensions
7
+ module Dynatrace
8
+ module Tags
9
+ module Runners
10
+ module Tags
11
+ def get_tags(entity_selector:, **opts)
12
+ conn = opts[:connection] || connection(**opts)
13
+ conn.get('api/v2/tags', entitySelector: entity_selector).body
14
+ end
15
+
16
+ def add_tags(entity_selector:, tags:, **opts)
17
+ conn = opts[:connection] || connection(**opts)
18
+ conn.post("api/v2/tags?entitySelector=#{CGI.escape(entity_selector)}",
19
+ { tags: tags }).body
20
+ end
21
+
22
+ def delete_tag(key:, entity_selector:, value: nil, delete_all_with_key: nil, **opts)
23
+ conn = opts[:connection] || connection(**opts)
24
+ params = { entitySelector: entity_selector }
25
+ params[:value] = value if value
26
+ params[:deleteAllWithKey] = delete_all_with_key unless delete_all_with_key.nil?
27
+ conn.delete("api/v2/tags/#{key}") { |req| req.params = params }.body
28
+ end
29
+ end
30
+ end
31
+ end
32
+ end
33
+ end
34
+ end
@@ -0,0 +1,13 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative 'tags/runners/tags'
4
+ require_relative 'tags/client'
5
+
6
+ module Legion
7
+ module Extensions
8
+ module Dynatrace
9
+ module Tags
10
+ end
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,17 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative '../helpers/client'
4
+ require_relative '../base_client'
5
+ require_relative 'runners/tokens'
6
+
7
+ module Legion
8
+ module Extensions
9
+ module Dynatrace
10
+ module Tokens
11
+ class Client < Legion::Extensions::Dynatrace::BaseClient
12
+ include Runners::Tokens
13
+ end
14
+ end
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,54 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Legion
4
+ module Extensions
5
+ module Dynatrace
6
+ module Tokens
7
+ module Runners
8
+ module Tokens
9
+ def list_tokens(page_size: nil, next_page_key: nil, sort: nil, fields: nil, **opts)
10
+ conn = opts[:connection] || connection(**opts)
11
+ params = {}
12
+ params[:pageSize] = page_size if page_size
13
+ params[:nextPageKey] = next_page_key if next_page_key
14
+ params[:sort] = sort if sort
15
+ params[:fields] = fields if fields
16
+ conn.get('api/v2/apiTokens', params).body
17
+ end
18
+
19
+ def get_token(token_id:, **opts)
20
+ conn = opts[:connection] || connection(**opts)
21
+ conn.get("api/v2/apiTokens/#{token_id}").body
22
+ end
23
+
24
+ def create_token(name:, scopes:, expiration_date: nil, personal_access_token: nil, **opts)
25
+ conn = opts[:connection] || connection(**opts)
26
+ payload = { name: name, scopes: scopes }
27
+ payload[:expirationDate] = expiration_date if expiration_date
28
+ payload[:personalAccessToken] = personal_access_token unless personal_access_token.nil?
29
+ conn.post('api/v2/apiTokens', payload).body
30
+ end
31
+
32
+ def update_token(token_id:, name: nil, enabled: nil, **opts)
33
+ conn = opts[:connection] || connection(**opts)
34
+ payload = {}
35
+ payload[:name] = name if name
36
+ payload[:enabled] = enabled unless enabled.nil?
37
+ conn.put("api/v2/apiTokens/#{token_id}", payload).body
38
+ end
39
+
40
+ def delete_token(token_id:, **opts)
41
+ conn = opts[:connection] || connection(**opts)
42
+ conn.delete("api/v2/apiTokens/#{token_id}").body
43
+ end
44
+
45
+ def lookup_token(token:, **opts)
46
+ conn = opts[:connection] || connection(**opts)
47
+ conn.post('api/v2/apiTokens/lookup', { token: token }).body
48
+ end
49
+ end
50
+ end
51
+ end
52
+ end
53
+ end
54
+ end