summaryrefslogtreecommitdiff
path: root/lib/api/projects.rb
diff options
context:
space:
mode:
authorDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2012-09-12 12:16:35 -0700
committerDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2012-09-12 12:16:35 -0700
commit3643df1f7cbcc3734055b0d710fd21dd4426ca3b (patch)
tree2a1d223a7513813353d6dff5e7c9d8b7a0769807 /lib/api/projects.rb
parent6233fb6b5d4732729b5bd734357f47fa42d34ed3 (diff)
parent6d76e000d07300ab9e8e8c74b90db0abcdc48451 (diff)
downloadgitlab-ce-3643df1f7cbcc3734055b0d710fd21dd4426ca3b.tar.gz
Merge pull request #1411 from miks/project_hooks_api
Project hooks API
Diffstat (limited to 'lib/api/projects.rb')
-rw-r--r--lib/api/projects.rb43
1 files changed, 43 insertions, 0 deletions
diff --git a/lib/api/projects.rb b/lib/api/projects.rb
index 9d33323e5fb..cf23dc5f538 100644
--- a/lib/api/projects.rb
+++ b/lib/api/projects.rb
@@ -106,6 +106,49 @@ module Gitlab
nil
end
+ # Get project hooks
+ #
+ # Parameters:
+ # id (required) - The ID or code name of a project
+ # Example Request:
+ # GET /projects/:id/hooks
+ get ":id/hooks" do
+ authorize! :admin_project, user_project
+ @hooks = paginate user_project.hooks
+ present @hooks, with: Entities::Hook
+ end
+
+ # Add hook to project
+ #
+ # Parameters:
+ # id (required) - The ID or code name of a project
+ # url (required) - The hook URL
+ # Example Request:
+ # POST /projects/:id/hooks
+ post ":id/hooks" do
+ authorize! :admin_project, user_project
+ @hook = user_project.hooks.new({"url" => params[:url]})
+ if @hook.save
+ present @hook, with: Entities::Hook
+ else
+ error!({'message' => '404 Not found'}, 404)
+ end
+ end
+
+ # Delete project hook
+ #
+ # Parameters:
+ # id (required) - The ID or code name of a project
+ # hook_id (required) - The ID of hook to delete
+ # Example Request:
+ # DELETE /projects/:id/hooks
+ delete ":id/hooks" do
+ authorize! :admin_project, user_project
+ @hook = user_project.hooks.find(params[:hook_id])
+ @hook.destroy
+ nil
+ end
+
# Get a project repository branches
#
# Parameters: