summaryrefslogtreecommitdiff
path: root/lib/api/projects.rb
diff options
context:
space:
mode:
authormiks <miks@cubesystems.lv>2012-09-08 20:51:12 +0300
committermiks <miks@cubesystems.lv>2012-09-08 20:51:12 +0300
commit3b5a90bdf654f9715fd15c189d59bd56492bae8c (patch)
tree6546b525c43688aa3a25d4679d8244be03c3a4ed /lib/api/projects.rb
parent27e443650746ddb7bf63d9a34d4afaa15350521d (diff)
downloadgitlab-ce-3b5a90bdf654f9715fd15c189d59bd56492bae8c.tar.gz
Projects hooks API implemented
Diffstat (limited to 'lib/api/projects.rb')
-rw-r--r--lib/api/projects.rb40
1 files changed, 40 insertions, 0 deletions
diff --git a/lib/api/projects.rb b/lib/api/projects.rb
index 7da83429dd4..876de321c9c 100644
--- a/lib/api/projects.rb
+++ b/lib/api/projects.rb
@@ -103,6 +103,46 @@ 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
+ @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
+ @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
+ @hook = user_project.hooks.find(params[:hook_id])
+ @hook.destroy
+ nil
+ end
+
# Get a project repository branches
#
# Parameters: