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

prometheus_alert_entity.rb « serializers « app - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 92905d2b3896db1a5f948aac96c093585d6e3643 (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
# frozen_string_literal: true

class PrometheusAlertEntity < Grape::Entity
  include RequestAwareEntity

  expose :id
  expose :title
  expose :query
  expose :threshold
  expose :runbook_url

  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