diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-04-29 15:10:00 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-04-29 15:10:00 +0300 |
commit | 4233d3aa86fe94e6288279aa55d42ed95bfe753c (patch) | |
tree | 7b97b519371f6df1fa6a0f2ffe69535207a73754 /lib | |
parent | e357d4951c53a3ce4f696cf533ce24a4c6350a7e (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'lib')
-rw-r--r-- | lib/api/entities/branch.rb | 6 | ||||
-rw-r--r-- | lib/gitlab/alert_management/alert_params.rb | 23 |
2 files changed, 29 insertions, 0 deletions
diff --git a/lib/api/entities/branch.rb b/lib/api/entities/branch.rb index 1d5017ac702..f9d06082ad6 100644 --- a/lib/api/entities/branch.rb +++ b/lib/api/entities/branch.rb @@ -3,6 +3,8 @@ module API module Entities class Branch < Grape::Entity + include Gitlab::Routing + expose :name expose :commit, using: Entities::Commit do |repo_branch, options| @@ -36,6 +38,10 @@ module API expose :default do |repo_branch, options| options[:project].default_branch == repo_branch.name end + + expose :web_url do |repo_branch| + project_tree_url(options[:project], repo_branch.name) + end end end end diff --git a/lib/gitlab/alert_management/alert_params.rb b/lib/gitlab/alert_management/alert_params.rb new file mode 100644 index 00000000000..014eba6326d --- /dev/null +++ b/lib/gitlab/alert_management/alert_params.rb @@ -0,0 +1,23 @@ +# frozen_string_literal: true + +module Gitlab + module AlertManagement + class AlertParams + def self.from_generic_alert(project:, payload:) + parsed_payload = Gitlab::Alerting::NotificationPayloadParser.call(payload).with_indifferent_access + annotations = parsed_payload[:annotations] + + { + project_id: project.id, + title: annotations[:title], + description: annotations[:description], + monitoring_tool: annotations[:monitoring_tool], + service: annotations[:service], + hosts: Array(annotations[:hosts]), + payload: payload, + started_at: parsed_payload['startsAt'] + } + end + end + end +end |