summaryrefslogtreecommitdiff
path: root/app/graphql/types/alert_management/prometheus_integration_type.rb
blob: 9a2ef78eca70bc5bd624c52450a1272589138790 (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
# frozen_string_literal: true

module Types
  module AlertManagement
    class PrometheusIntegrationType < ::Types::BaseObject
      graphql_name 'AlertManagementPrometheusIntegration'
      description 'An endpoint and credentials used to accept Prometheus alerts for a project'

      include ::Gitlab::Routing

      implements(Types::AlertManagement::IntegrationType)

      authorize :admin_project

      alias_method :prometheus_integration, :object

      def name
        prometheus_integration.title
      end

      def type
        :prometheus
      end

      def token
        prometheus_integration.project&.alerting_setting&.token
      end

      def url
        prometheus_integration.project && notify_project_prometheus_alerts_url(prometheus_integration.project, format: :json)
      end

      def active
        prometheus_integration.manual_configuration?
      end
    end
  end
end