summaryrefslogtreecommitdiff
path: root/app/graphql/types/alert_management/prometheus_integration_type.rb
blob: f605e325b8bc527b5ed2a41b965cf566a0cfa8da (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 < BaseObject
      include ::Gitlab::Routing

      graphql_name 'AlertManagementPrometheusIntegration'
      description 'An endpoint and credentials used to accept Prometheus alerts for a project'

      implements(Types::AlertManagement::IntegrationType)

      authorize :admin_project

      alias_method :prometheus_service, :object

      def name
        prometheus_service.title
      end

      def type
        :prometheus
      end

      def token
        prometheus_service.project&.alerting_setting&.token
      end

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

      def active
        prometheus_service.manual_configuration?
      end
    end
  end
end