summaryrefslogtreecommitdiff
path: root/app/graphql/resolvers/alert_management/integrations_resolver.rb
blob: 4d1fe367277594ecf1e228ec552ae77c713ed69f (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
# frozen_string_literal: true

module Resolvers
  module AlertManagement
    class IntegrationsResolver < BaseResolver
      alias_method :project, :synchronized_object

      type Types::AlertManagement::IntegrationType.connection_type, null: true

      def resolve(**args)
        http_integrations + prometheus_integrations
      end

      private

      def prometheus_integrations
        return [] unless Ability.allowed?(current_user, :admin_project, project)

        Array(project.prometheus_service)
      end

      def http_integrations
        return [] unless Ability.allowed?(current_user, :admin_operations, project)

        ::AlertManagement::HttpIntegrationsFinder.new(project, {}).execute
      end
    end
  end
end