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

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2020-03-20 18:09:17 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2020-03-20 18:09:17 +0300
commit194b499aa8e26df26ff70a1e1ce0396587bd5243 (patch)
treec873ac9c3096faf4a5da43d6670107461da2a7d7 /app/services/projects
parent43b4b3e2d2ddebc0a89b94a8251c162ec5719780 (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app/services/projects')
-rw-r--r--app/services/projects/prometheus/alerts/alert_params.rb17
-rw-r--r--app/services/projects/prometheus/alerts/create_service.rb15
-rw-r--r--app/services/projects/prometheus/alerts/destroy_service.rb13
-rw-r--r--app/services/projects/prometheus/alerts/update_service.rb15
4 files changed, 60 insertions, 0 deletions
diff --git a/app/services/projects/prometheus/alerts/alert_params.rb b/app/services/projects/prometheus/alerts/alert_params.rb
new file mode 100644
index 00000000000..1c39ed36b12
--- /dev/null
+++ b/app/services/projects/prometheus/alerts/alert_params.rb
@@ -0,0 +1,17 @@
+# frozen_string_literal: true
+
+module Projects
+ module Prometheus
+ module Alerts
+ module AlertParams
+ def alert_params
+ return params if params[:operator].blank?
+
+ params.merge(
+ operator: PrometheusAlert.operator_to_enum(params[:operator])
+ )
+ end
+ end
+ end
+ end
+end
diff --git a/app/services/projects/prometheus/alerts/create_service.rb b/app/services/projects/prometheus/alerts/create_service.rb
new file mode 100644
index 00000000000..dc0cacf49f3
--- /dev/null
+++ b/app/services/projects/prometheus/alerts/create_service.rb
@@ -0,0 +1,15 @@
+# frozen_string_literal: true
+
+module Projects
+ module Prometheus
+ module Alerts
+ class CreateService < BaseService
+ include AlertParams
+
+ def execute
+ project.prometheus_alerts.create(alert_params)
+ end
+ end
+ end
+ end
+end
diff --git a/app/services/projects/prometheus/alerts/destroy_service.rb b/app/services/projects/prometheus/alerts/destroy_service.rb
new file mode 100644
index 00000000000..14e88a2e356
--- /dev/null
+++ b/app/services/projects/prometheus/alerts/destroy_service.rb
@@ -0,0 +1,13 @@
+# frozen_string_literal: true
+
+module Projects
+ module Prometheus
+ module Alerts
+ class DestroyService < BaseService
+ def execute(alert)
+ alert.destroy
+ end
+ end
+ end
+ end
+end
diff --git a/app/services/projects/prometheus/alerts/update_service.rb b/app/services/projects/prometheus/alerts/update_service.rb
new file mode 100644
index 00000000000..a0c8a5ccc2d
--- /dev/null
+++ b/app/services/projects/prometheus/alerts/update_service.rb
@@ -0,0 +1,15 @@
+# frozen_string_literal: true
+
+module Projects
+ module Prometheus
+ module Alerts
+ class UpdateService < BaseService
+ include AlertParams
+
+ def execute(alert)
+ alert.update(alert_params)
+ end
+ end
+ end
+ end
+end