Welcome to mirror list, hosted at ThFree Co, Russian Federation.

prometheus_integration_base.rb « prometheus_integration « alert_management « mutations « graphql « app - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: cb243f49b33da2c9d09edce157a9861e2aafef14 (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
# frozen_string_literal: true

module Mutations
  module AlertManagement
    module PrometheusIntegration
      class PrometheusIntegrationBase < BaseMutation
        field :integration,
              Types::AlertManagement::PrometheusIntegrationType,
              null: true,
              description: "The newly created integration."

        authorize :admin_project

        private

        def find_object(id:)
          GitlabSchema.object_from_id(id, expected_class: ::PrometheusService)
        end

        def response(integration, result)
          {
            integration: integration,
            errors: Array(result[:message])
          }
        end

        def integration_attributes(args)
          {
            prometheus_integration_attributes: {
              manual_configuration: args[:active],
              api_url: args[:api_url]
            }.compact
          }
        end

        def token_attributes
          { alerting_setting_attributes: { regenerate_token: true } }
        end
      end
    end
  end
end