summaryrefslogtreecommitdiff
path: root/lib/api/tags.rb
diff options
context:
space:
mode:
authorDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2015-11-12 15:41:13 +0100
committerDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2015-11-12 15:41:13 +0100
commita5ab56fd9191e23dfa60707fa42802342c1563f8 (patch)
treeb54ca2005609201b06af5acfda79e09087255ec7 /lib/api/tags.rb
parent2ac1193720907bccc1f321e9c56fb5ca2b0a3a1c (diff)
downloadgitlab-ce-a5ab56fd9191e23dfa60707fa42802342c1563f8.tar.gz
Move git tags API to separate file
Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
Diffstat (limited to 'lib/api/tags.rb')
-rw-r--r--lib/api/tags.rb44
1 files changed, 44 insertions, 0 deletions
diff --git a/lib/api/tags.rb b/lib/api/tags.rb
new file mode 100644
index 00000000000..da962bd402a
--- /dev/null
+++ b/lib/api/tags.rb
@@ -0,0 +1,44 @@
+module API
+ # Releases API
+ class Tags < Grape::API
+ before { authenticate! }
+ before { authorize! :download_code, user_project }
+
+ resource :projects do
+ # Get a project repository tags
+ #
+ # Parameters:
+ # id (required) - The ID of a project
+ # Example Request:
+ # GET /projects/:id/repository/tags
+ get ":id/repository/tags" do
+ present user_project.repo.tags.sort_by(&:name).reverse,
+ with: Entities::RepoTag, project: user_project
+ end
+
+ # Create tag
+ #
+ # Parameters:
+ # id (required) - The ID of a project
+ # tag_name (required) - The name of the tag
+ # ref (required) - Create tag from commit sha or branch
+ # message (optional) - Specifying a message creates an annotated tag.
+ # Example Request:
+ # POST /projects/:id/repository/tags
+ post ':id/repository/tags' do
+ authorize_push_project
+ message = params[:message] || nil
+ result = CreateTagService.new(user_project, current_user).
+ execute(params[:tag_name], params[:ref], message)
+
+ if result[:status] == :success
+ present result[:tag],
+ with: Entities::RepoTag,
+ project: user_project
+ else
+ render_api_error!(result[:message], 400)
+ end
+ end
+ end
+ end
+end