summaryrefslogtreecommitdiff
path: root/app/graphql/mutations/alert_management/prometheus_integration/prometheus_integration_base.rb
diff options
context:
space:
mode:
Diffstat (limited to 'app/graphql/mutations/alert_management/prometheus_integration/prometheus_integration_base.rb')
-rw-r--r--app/graphql/mutations/alert_management/prometheus_integration/prometheus_integration_base.rb42
1 files changed, 42 insertions, 0 deletions
diff --git a/app/graphql/mutations/alert_management/prometheus_integration/prometheus_integration_base.rb b/app/graphql/mutations/alert_management/prometheus_integration/prometheus_integration_base.rb
new file mode 100644
index 00000000000..6b690ac239a
--- /dev/null
+++ b/app/graphql/mutations/alert_management/prometheus_integration/prometheus_integration_base.rb
@@ -0,0 +1,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