diff options
author | miks <miks@cubesystems.lv> | 2012-09-08 20:51:12 +0300 |
---|---|---|
committer | miks <miks@cubesystems.lv> | 2012-09-08 20:51:12 +0300 |
commit | 3b5a90bdf654f9715fd15c189d59bd56492bae8c (patch) | |
tree | 6546b525c43688aa3a25d4679d8244be03c3a4ed /lib/api | |
parent | 27e443650746ddb7bf63d9a34d4afaa15350521d (diff) | |
download | gitlab-ce-3b5a90bdf654f9715fd15c189d59bd56492bae8c.tar.gz |
Projects hooks API implemented
Diffstat (limited to 'lib/api')
-rw-r--r-- | lib/api/entities.rb | 4 | ||||
-rw-r--r-- | lib/api/projects.rb | 40 |
2 files changed, 44 insertions, 0 deletions
diff --git a/lib/api/entities.rb b/lib/api/entities.rb index fef5328d093..b50d683f940 100644 --- a/lib/api/entities.rb +++ b/lib/api/entities.rb @@ -9,6 +9,10 @@ module Gitlab expose :id, :email, :name, :blocked, :created_at end + class Hook < Grape::Entity + expose :id, :url + end + class Project < Grape::Entity expose :id, :code, :name, :description, :path, :default_branch expose :owner, using: Entities::UserBasic 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: |