summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobert Schilling <rschilling@student.tugraz.at>2019-02-13 21:18:40 +0100
committerRobert Schilling <rschilling@student.tugraz.at>2019-08-26 10:45:37 +0200
commit2e83665ed30259a7908350d316605a9c100f0876 (patch)
treefa5f9b9bbf82c3b054a9b174361ffe2fa4d84d43
parent6ba51d692c3a6bac2ae82daac8bfd354f1f92999 (diff)
downloadgitlab-ce-2e83665ed30259a7908350d316605a9c100f0876.tar.gz
API: Promote project labels to group labels
-rw-r--r--changelogs/unreleased/57657-promote-label-to-group-label-via-api-endpoint.yml5
-rw-r--r--lib/api/labels.rb25
2 files changed, 30 insertions, 0 deletions
diff --git a/changelogs/unreleased/57657-promote-label-to-group-label-via-api-endpoint.yml b/changelogs/unreleased/57657-promote-label-to-group-label-via-api-endpoint.yml
new file mode 100644
index 00000000000..572bce34f45
--- /dev/null
+++ b/changelogs/unreleased/57657-promote-label-to-group-label-via-api-endpoint.yml
@@ -0,0 +1,5 @@
+---
+title: 'API: Promote project labels to group labels'
+merge_request: 25218
+author: Robert Schilling
+type: added
diff --git a/lib/api/labels.rb b/lib/api/labels.rb
index 83d645ca07a..5079d95c2b4 100644
--- a/lib/api/labels.rb
+++ b/lib/api/labels.rb
@@ -62,6 +62,31 @@ module API
delete ':id/labels' do
delete_label(user_project)
end
+
+ desc 'Promote a label to a group label' do
+ detail 'This feature was added in GitLab 11.9'
+ success Entities::GroupLabel
+ end
+ params do
+ requires :name, type: String, desc: 'The name of the label to be promoted'
+ end
+ post ':id/labels/promote' do
+ authorize! :admin_label, parent
+
+ label = find_label(parent, params[:name], include_ancestor_groups: false)
+
+ begin
+ group_label = Labels::PromoteService.new(user_project, current_user).execute(label)
+
+ if group_label
+ present group_label, with: Entities::GroupLabel, current_user: current_user, parent: user_project.group
+ else
+ render_api_error!('Failed to promote project label to group label', 400)
+ end
+ rescue => error
+ render_api_error!(error.to_s, 400)
+ end
+ end
end
end
end