diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-03-23 15:09:47 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-03-23 15:09:47 +0300 |
commit | 8f9beefac3774b30e911fb00a68f4c7a5244cf27 (patch) | |
tree | 919c3a043f8c10bc3f78f3f6e029acfb6b972556 /app/serializers | |
parent | e4bf776a8829e5186a0f63603c0be627b891d80e (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app/serializers')
-rw-r--r-- | app/serializers/prometheus_alert_entity.rb | 26 | ||||
-rw-r--r-- | app/serializers/prometheus_alert_serializer.rb | 5 |
2 files changed, 31 insertions, 0 deletions
diff --git a/app/serializers/prometheus_alert_entity.rb b/app/serializers/prometheus_alert_entity.rb new file mode 100644 index 00000000000..413be511903 --- /dev/null +++ b/app/serializers/prometheus_alert_entity.rb @@ -0,0 +1,26 @@ +# frozen_string_literal: true + +class PrometheusAlertEntity < Grape::Entity + include RequestAwareEntity + + expose :id + expose :title + expose :query + expose :threshold + + expose :operator do |prometheus_alert| + prometheus_alert.computed_operator + end + + expose :alert_path do |prometheus_alert| + project_prometheus_alert_path(prometheus_alert.project, prometheus_alert.prometheus_metric_id, environment_id: prometheus_alert.environment.id, format: :json) + end + + private + + alias_method :prometheus_alert, :object + + def can_read_prometheus_alerts? + can?(request.current_user, :read_prometheus_alerts, prometheus_alert.project) + end +end diff --git a/app/serializers/prometheus_alert_serializer.rb b/app/serializers/prometheus_alert_serializer.rb new file mode 100644 index 00000000000..4dafb7216db --- /dev/null +++ b/app/serializers/prometheus_alert_serializer.rb @@ -0,0 +1,5 @@ +# frozen_string_literal: true + +class PrometheusAlertSerializer < BaseSerializer + entity PrometheusAlertEntity +end |