summaryrefslogtreecommitdiff
path: root/app/graphql/types/alert_management/integration_type.rb
blob: bf5998855842818cf107f0601c0e4c79c206dd5e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
# frozen_string_literal: true

module Types
  module AlertManagement
    module IntegrationType
      include Types::BaseInterface
      graphql_name 'AlertManagementIntegration'

      field :id,
            GraphQL::ID_TYPE,
            null: false,
            description: 'ID of the integration'

      field :type,
            AlertManagement::IntegrationTypeEnum,
            null: false,
            description: 'Type of integration'

      field :name,
            GraphQL::STRING_TYPE,
            null: true,
            description: 'Name of the integration'

      field :active,
            GraphQL::BOOLEAN_TYPE,
            null: true,
            description: 'Whether the endpoint is currently accepting alerts'

      field :token,
            GraphQL::STRING_TYPE,
            null: true,
            description: 'Token used to authenticate alert notification requests'

      field :url,
            GraphQL::STRING_TYPE,
            null: true,
            description: 'Endpoint which accepts alert notifications'

      field :api_url,
            GraphQL::STRING_TYPE,
            null: true,
            description: 'URL at which Prometheus metrics can be queried to populate the metrics dashboard'

      definition_methods do
        def resolve_type(object, context)
          if object.is_a?(::PrometheusService)
            Types::AlertManagement::PrometheusIntegrationType
          else
            Types::AlertManagement::HttpIntegrationType
          end
        end
      end

      orphan_types Types::AlertManagement::PrometheusIntegrationType,
                   Types::AlertManagement::HttpIntegrationType
    end
  end
end