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
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: ce656ccaf788e435189fc8eb6c7fb12e948cca86e689624e7d26877c8c5cdd6a
4
+ data.tar.gz: 842b834a51a6e0eb79c1797a7d20e741a773f39660d1d6fe2256ee8c421ce073
5
+ SHA512:
6
+ metadata.gz: 52dfafa4209ea9c3a6297e33567a51afdad9007c3227c162fb31582838c96400249241d926a339379abef63ffc28f14cc47bc95d6ab1ee343819485207045c66
7
+ data.tar.gz: 1f42b39b83e1d41cbb192c45a009ce0a687a0ee0181ed90509d8374cc4e63665c8bd57d0d60d3e7e2bcb1727fe5a3577a49954132c21c0ef8620dd218efa87b0
@@ -0,0 +1,34 @@
1
+ name: CI
2
+ on:
3
+ push:
4
+ branches: [main]
5
+ pull_request:
6
+ schedule:
7
+ - cron: '0 9 * * 1'
8
+
9
+ jobs:
10
+ ci:
11
+ uses: LegionIO/.github/.github/workflows/ci.yml@main
12
+
13
+ lint:
14
+ uses: LegionIO/.github/.github/workflows/lint-patterns.yml@main
15
+
16
+ security:
17
+ uses: LegionIO/.github/.github/workflows/security-scan.yml@main
18
+
19
+ version-changelog:
20
+ uses: LegionIO/.github/.github/workflows/version-changelog.yml@main
21
+
22
+ dependency-review:
23
+ uses: LegionIO/.github/.github/workflows/dependency-review.yml@main
24
+
25
+ stale:
26
+ if: github.event_name == 'schedule'
27
+ uses: LegionIO/.github/.github/workflows/stale.yml@main
28
+
29
+ release:
30
+ needs: [ci, lint]
31
+ if: github.event_name == 'push' && github.ref == 'refs/heads/main'
32
+ uses: LegionIO/.github/.github/workflows/release.yml@main
33
+ secrets:
34
+ rubygems-api-key: ${{ secrets.RUBYGEMS_API_KEY }}
data/.rubocop.yml ADDED
@@ -0,0 +1,31 @@
1
+ AllCops:
2
+ TargetRubyVersion: 3.4
3
+ NewCops: enable
4
+ SuggestExtensions: false
5
+
6
+ Metrics/BlockLength:
7
+ Exclude:
8
+ - 'spec/**/*'
9
+ - '*.gemspec'
10
+
11
+ Style/Documentation:
12
+ Enabled: false
13
+
14
+ Metrics/ParameterLists:
15
+ Max: 10
16
+ CountKeywordArgs: false
17
+
18
+ Metrics/MethodLength:
19
+ Max: 25
20
+
21
+ Metrics/AbcSize:
22
+ Max: 25
23
+
24
+ Metrics/CyclomaticComplexity:
25
+ Max: 12
26
+
27
+ Metrics/PerceivedComplexity:
28
+ Max: 12
29
+
30
+ Layout/LineLength:
31
+ Max: 120
data/CHANGELOG.md ADDED
@@ -0,0 +1,24 @@
1
+ # Changelog
2
+
3
+ ## [0.1.0] - 2026-03-27
4
+
5
+ ### Added
6
+ - Initial release with 16 sub-modules covering Dynatrace Environment API v2
7
+ - Metrics: list descriptors, get descriptor, query data points, ingest custom metrics
8
+ - Entities: list/get entities, list/get entity types
9
+ - Problems: list/get/close problems, list/create comments
10
+ - Events: list/get events, ingest custom events
11
+ - Logs: search and aggregate log data
12
+ - Audit Logs: list/get audit log entries
13
+ - ActiveGates: list/get ActiveGate instances
14
+ - Extensions 2.0: full extension lifecycle, environment config, monitoring configurations
15
+ - SLOs: CRUD for service level objectives
16
+ - Synthetic: monitor CRUD, locations, execution reports
17
+ - Security Problems: list/get/mute/unmute, remediations
18
+ - Settings Objects: CRUD for settings objects and schemas
19
+ - Network Zones: CRUD for network zones
20
+ - Tags: get/add/delete entity tags
21
+ - API Tokens: CRUD, lookup
22
+ - Releases: list/get release information
23
+ - Standalone Client class per sub-module (lex-cloudflare multi-module pattern)
24
+ - 66 specs with WebMock stubs
data/Gemfile ADDED
@@ -0,0 +1,13 @@
1
+ # frozen_string_literal: true
2
+
3
+ source 'https://rubygems.org'
4
+
5
+ gemspec
6
+
7
+ group :development, :test do
8
+ gem 'rspec', '~> 3.12'
9
+ gem 'rubocop', '~> 1.50'
10
+ gem 'rubocop-rspec', '~> 2.22'
11
+ gem 'simplecov', '~> 0.22'
12
+ gem 'webmock', '~> 3.18'
13
+ end
data/README.md ADDED
@@ -0,0 +1,92 @@
1
+ # lex-dynatrace
2
+
3
+ Legion Extension for the [Dynatrace Environment API v2](https://docs.dynatrace.com/docs/dynatrace-api/environment-api). Multi-module monolith covering 16 API areas with standalone clients.
4
+
5
+ ## Installation
6
+
7
+ ```ruby
8
+ gem 'lex-dynatrace'
9
+ ```
10
+
11
+ ## Authentication
12
+
13
+ All sub-modules authenticate via `Api-Token` header. Generate a token in **Dynatrace > Access tokens** with the scopes you need.
14
+
15
+ ## Usage
16
+
17
+ Each sub-module has its own `Client` class that can be used standalone (no Legion runtime required):
18
+
19
+ ```ruby
20
+ require 'legion/extensions/dynatrace'
21
+
22
+ # Metrics
23
+ metrics = Legion::Extensions::Dynatrace::Metrics::Client.new(
24
+ environment_url: 'https://abc12345.live.dynatrace.com',
25
+ api_token: 'dt0c01.xxxx'
26
+ )
27
+ metrics.query(metric_selector: 'builtin:host.cpu.usage', from: 'now-1h')
28
+ metrics.list_descriptors
29
+ metrics.ingest(lines: ['custom.metric 42'])
30
+
31
+ # Problems
32
+ problems = Legion::Extensions::Dynatrace::Problems::Client.new(
33
+ environment_url: 'https://abc12345.live.dynatrace.com',
34
+ api_token: 'dt0c01.xxxx'
35
+ )
36
+ problems.list_problems(from: 'now-24h')
37
+ problems.close_problem(problem_id: 'P-123', message: 'resolved')
38
+
39
+ # Entities
40
+ entities = Legion::Extensions::Dynatrace::Entities::Client.new(
41
+ environment_url: 'https://abc12345.live.dynatrace.com',
42
+ api_token: 'dt0c01.xxxx'
43
+ )
44
+ entities.list_entities(entity_selector: 'type(HOST)')
45
+ entities.get_entity(entity_id: 'HOST-ABC123')
46
+ ```
47
+
48
+ ## Sub-Modules
49
+
50
+ | Module | API Path | Methods |
51
+ |--------|----------|---------|
52
+ | **Metrics** | `/api/v2/metrics` | `list_descriptors`, `get_descriptor`, `query`, `ingest` |
53
+ | **Entities** | `/api/v2/entities` | `list_entities`, `get_entity`, `list_entity_types`, `get_entity_type` |
54
+ | **Problems** | `/api/v2/problems` | `list_problems`, `get_problem`, `close_problem`, `list_comments`, `create_comment` |
55
+ | **Events** | `/api/v2/events` | `list_events`, `get_event`, `ingest_event` |
56
+ | **Logs** | `/api/v2/logs` | `search_logs`, `aggregate_logs` |
57
+ | **AuditLogs** | `/api/v2/auditlogs` | `list_audit_logs`, `get_audit_log` |
58
+ | **ActiveGates** | `/api/v2/activeGates` | `list_active_gates`, `get_active_gate` |
59
+ | **Extensions20** | `/api/v2/extensions` | `list_extensions`, `get_extension`, `delete_extension`, `get_extension_version`, `delete_extension_version`, `get_environment_config`, `update_environment_config`, `delete_environment_config`, `list_monitoring_configs`, `get_monitoring_config`, `create_monitoring_config`, `update_monitoring_config`, `delete_monitoring_config` |
60
+ | **Slos** | `/api/v2/slo` | `list_slos`, `get_slo`, `create_slo`, `update_slo`, `delete_slo` |
61
+ | **Synthetic** | `/api/v2/synthetic` | `list_monitors`, `get_monitor`, `create_monitor`, `update_monitor`, `delete_monitor`, `get_execution`, `list_locations`, `get_location` |
62
+ | **SecurityProblems** | `/api/v2/securityProblems` | `list_security_problems`, `get_security_problem`, `mute_security_problem`, `unmute_security_problem`, `list_remediations` |
63
+ | **SettingsObjects** | `/api/v2/settings` | `list_objects`, `get_object`, `create_objects`, `update_object`, `delete_object`, `list_schemas`, `get_schema` |
64
+ | **NetworkZones** | `/api/v2/networkZones` | `list_network_zones`, `get_network_zone`, `create_network_zone`, `update_network_zone`, `delete_network_zone` |
65
+ | **Tags** | `/api/v2/tags` | `get_tags`, `add_tags`, `delete_tag` |
66
+ | **Tokens** | `/api/v2/apiTokens` | `list_tokens`, `get_token`, `create_token`, `update_token`, `delete_token`, `lookup_token` |
67
+ | **Releases** | `/api/v2/releases` | `list_releases`, `get_release` |
68
+
69
+ ## Legion Settings
70
+
71
+ When running inside the Legion framework, credentials resolve from settings:
72
+
73
+ ```json
74
+ {
75
+ "lex-dynatrace": {
76
+ "environment_url": "https://abc12345.live.dynatrace.com",
77
+ "api_token": "vault://secret/dynatrace#api_token"
78
+ }
79
+ }
80
+ ```
81
+
82
+ ## Development
83
+
84
+ ```bash
85
+ bundle install
86
+ bundle exec rspec # 66 specs
87
+ bundle exec rubocop # 0 offenses
88
+ ```
89
+
90
+ ## License
91
+
92
+ MIT
@@ -0,0 +1,37 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative 'lib/legion/extensions/dynatrace/version'
4
+
5
+ Gem::Specification.new do |spec|
6
+ spec.name = 'lex-dynatrace'
7
+ spec.version = Legion::Extensions::Dynatrace::VERSION
8
+ spec.authors = ['Esity']
9
+ spec.email = ['matthewdiverson@gmail.com']
10
+
11
+ spec.summary = 'LEX::Dynatrace'
12
+ spec.description = 'Used to connect Legion to Dynatrace SaaS Environment API v2'
13
+ spec.homepage = 'https://github.com/LegionIO/lex-dynatrace'
14
+ spec.license = 'MIT'
15
+ spec.required_ruby_version = '>= 3.4'
16
+
17
+ spec.metadata['homepage_uri'] = spec.homepage
18
+ spec.metadata['source_code_uri'] = 'https://github.com/LegionIO/lex-dynatrace'
19
+ spec.metadata['changelog_uri'] = 'https://github.com/LegionIO/lex-dynatrace/blob/main/CHANGELOG.md'
20
+ spec.metadata['rubygems_mfa_required'] = 'true'
21
+
22
+ spec.files = Dir.chdir(File.expand_path(__dir__)) do
23
+ `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
24
+ end
25
+ spec.bindir = 'exe'
26
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
27
+ spec.require_paths = ['lib']
28
+
29
+ spec.add_dependency 'faraday', '>= 2.0'
30
+ spec.add_dependency 'legion-cache', '>= 1.3.11'
31
+ spec.add_dependency 'legion-crypt', '>= 1.4.9'
32
+ spec.add_dependency 'legion-data', '>= 1.4.17'
33
+ spec.add_dependency 'legion-json', '>= 1.2.1'
34
+ spec.add_dependency 'legion-logging', '>= 1.3.2'
35
+ spec.add_dependency 'legion-settings', '>= 1.3.14'
36
+ spec.add_dependency 'legion-transport', '>= 1.3.9'
37
+ 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/active_gates'
6
+
7
+ module Legion
8
+ module Extensions
9
+ module Dynatrace
10
+ module ActiveGates
11
+ class Client < Legion::Extensions::Dynatrace::BaseClient
12
+ include Runners::ActiveGates
13
+ end
14
+ end
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,35 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Legion
4
+ module Extensions
5
+ module Dynatrace
6
+ module ActiveGates
7
+ module Runners
8
+ module ActiveGates
9
+ def list_active_gates(hostname: nil, os_type: nil, network_zone: nil, update_status: nil,
10
+ version_compare_type: nil, version: nil, group: nil,
11
+ page_size: nil, next_page_key: nil, **opts)
12
+ conn = opts[:connection] || connection(**opts)
13
+ params = {}
14
+ params[:hostname] = hostname if hostname
15
+ params[:osType] = os_type if os_type
16
+ params[:networkZone] = network_zone if network_zone
17
+ params[:updateStatus] = update_status if update_status
18
+ params[:versionCompareType] = version_compare_type if version_compare_type
19
+ params[:version] = version if version
20
+ params[:group] = group if group
21
+ params[:pageSize] = page_size if page_size
22
+ params[:nextPageKey] = next_page_key if next_page_key
23
+ conn.get('api/v2/activeGates', params).body
24
+ end
25
+
26
+ def get_active_gate(ag_id:, **opts)
27
+ conn = opts[:connection] || connection(**opts)
28
+ conn.get("api/v2/activeGates/#{ag_id}").body
29
+ end
30
+ end
31
+ end
32
+ end
33
+ end
34
+ end
35
+ end
@@ -0,0 +1,13 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative 'active_gates/runners/active_gates'
4
+ require_relative 'active_gates/client'
5
+
6
+ module Legion
7
+ module Extensions
8
+ module Dynatrace
9
+ module ActiveGates
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/attacks'
6
+
7
+ module Legion
8
+ module Extensions
9
+ module Dynatrace
10
+ module Attacks
11
+ class Client < Legion::Extensions::Dynatrace::BaseClient
12
+ include Runners::Attacks
13
+ end
14
+ end
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,34 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Legion
4
+ module Extensions
5
+ module Dynatrace
6
+ module Attacks
7
+ module Runners
8
+ module Attacks
9
+ def list_attacks(attack_selector: nil, from: nil, to: nil, fields: nil, sort: nil,
10
+ page_size: nil, next_page_key: nil, **opts)
11
+ conn = opts[:connection] || connection(**opts)
12
+ params = {}
13
+ params[:attackSelector] = attack_selector if attack_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/attacks', params).body
21
+ end
22
+
23
+ def get_attack(attack_id:, fields: nil, **opts)
24
+ conn = opts[:connection] || connection(**opts)
25
+ params = {}
26
+ params[:fields] = fields if fields
27
+ conn.get("api/v2/attacks/#{attack_id}", 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 'attacks/runners/attacks'
4
+ require_relative 'attacks/client'
5
+
6
+ module Legion
7
+ module Extensions
8
+ module Dynatrace
9
+ module Attacks
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/audit_logs'
6
+
7
+ module Legion
8
+ module Extensions
9
+ module Dynatrace
10
+ module AuditLogs
11
+ class Client < Legion::Extensions::Dynatrace::BaseClient
12
+ include Runners::AuditLogs
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 AuditLogs
7
+ module Runners
8
+ module AuditLogs
9
+ def list_audit_logs(filter: 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[:filter] = filter if filter
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/auditlogs', params).body
20
+ end
21
+
22
+ def get_audit_log(log_id:, **opts)
23
+ conn = opts[:connection] || connection(**opts)
24
+ conn.get("api/v2/auditlogs/#{log_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 'audit_logs/runners/audit_logs'
4
+ require_relative 'audit_logs/client'
5
+
6
+ module Legion
7
+ module Extensions
8
+ module Dynatrace
9
+ module AuditLogs
10
+ end
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,25 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Legion
4
+ module Extensions
5
+ module Dynatrace
6
+ class BaseClient
7
+ include Helpers::Client
8
+
9
+ attr_reader :opts
10
+
11
+ def initialize(environment_url:, api_token: nil, **extra)
12
+ @opts = { environment_url: environment_url, api_token: api_token, **extra }.compact
13
+ end
14
+
15
+ def settings
16
+ { options: @opts }
17
+ end
18
+
19
+ def connection(**override)
20
+ super(**@opts, **override)
21
+ end
22
+ end
23
+ end
24
+ end
25
+ 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/business_events'
6
+
7
+ module Legion
8
+ module Extensions
9
+ module Dynatrace
10
+ module BusinessEvents
11
+ class Client < Legion::Extensions::Dynatrace::BaseClient
12
+ include Runners::BusinessEvents
13
+ end
14
+ end
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,37 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Legion
4
+ module Extensions
5
+ module Dynatrace
6
+ module BusinessEvents
7
+ module Runners
8
+ module BusinessEvents
9
+ def ingest_business_event(data:, **opts)
10
+ env_url = opts[:environment_url] || self.opts[:environment_url]
11
+ token = opts[:api_token] || self.opts[:api_token]
12
+ json_conn = Faraday.new(url: env_url) do |f|
13
+ f.headers['Authorization'] = "Api-Token #{token}" if token
14
+ f.headers['Content-Type'] = 'application/cloudevents+json'
15
+ f.response :json
16
+ f.adapter Faraday.default_adapter
17
+ end
18
+ json_conn.post('api/v2/bizevents/ingest', data.to_json).body
19
+ end
20
+
21
+ def ingest_business_events_batch(events:, **opts)
22
+ env_url = opts[:environment_url] || self.opts[:environment_url]
23
+ token = opts[:api_token] || self.opts[:api_token]
24
+ batch_conn = Faraday.new(url: env_url) do |f|
25
+ f.headers['Authorization'] = "Api-Token #{token}" if token
26
+ f.headers['Content-Type'] = 'application/cloudevents-batch+json'
27
+ f.response :json
28
+ f.adapter Faraday.default_adapter
29
+ end
30
+ batch_conn.post('api/v2/bizevents/ingest', events.to_json).body
31
+ end
32
+ end
33
+ end
34
+ end
35
+ end
36
+ end
37
+ end
@@ -0,0 +1,13 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative 'business_events/runners/business_events'
4
+ require_relative 'business_events/client'
5
+
6
+ module Legion
7
+ module Extensions
8
+ module Dynatrace
9
+ module BusinessEvents
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/credentials'
6
+
7
+ module Legion
8
+ module Extensions
9
+ module Dynatrace
10
+ module Credentials
11
+ class Client < Legion::Extensions::Dynatrace::BaseClient
12
+ include Runners::Credentials
13
+ end
14
+ end
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,45 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Legion
4
+ module Extensions
5
+ module Dynatrace
6
+ module Credentials
7
+ module Runners
8
+ module Credentials
9
+ def list_credentials(name: nil, type: nil, scope: nil,
10
+ page_size: nil, next_page_key: nil, **opts)
11
+ conn = opts[:connection] || connection(**opts)
12
+ params = {}
13
+ params[:name] = name if name
14
+ params[:type] = type if type
15
+ params[:scope] = scope if scope
16
+ params[:pageSize] = page_size if page_size
17
+ params[:nextPageKey] = next_page_key if next_page_key
18
+ conn.get('api/v2/credentials', params).body
19
+ end
20
+
21
+ def get_credential(credential_id:, **opts)
22
+ conn = opts[:connection] || connection(**opts)
23
+ conn.get("api/v2/credentials/#{credential_id}").body
24
+ end
25
+
26
+ def create_credential(credential:, **opts)
27
+ conn = opts[:connection] || connection(**opts)
28
+ conn.post('api/v2/credentials', credential).body
29
+ end
30
+
31
+ def update_credential(credential_id:, credential:, **opts)
32
+ conn = opts[:connection] || connection(**opts)
33
+ conn.put("api/v2/credentials/#{credential_id}", credential).body
34
+ end
35
+
36
+ def delete_credential(credential_id:, **opts)
37
+ conn = opts[:connection] || connection(**opts)
38
+ conn.delete("api/v2/credentials/#{credential_id}").body
39
+ end
40
+ end
41
+ end
42
+ end
43
+ end
44
+ end
45
+ end
@@ -0,0 +1,13 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative 'credentials/runners/credentials'
4
+ require_relative 'credentials/client'
5
+
6
+ module Legion
7
+ module Extensions
8
+ module Dynatrace
9
+ module Credentials
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/deployment'
6
+
7
+ module Legion
8
+ module Extensions
9
+ module Dynatrace
10
+ module Deployment
11
+ class Client < Legion::Extensions::Dynatrace::BaseClient
12
+ include Runners::Deployment
13
+ end
14
+ end
15
+ end
16
+ end
17
+ end