Projects hooks API implemented
This commit is contained in:
parent
27e4436507
commit
3b5a90bdf6
4 changed files with 119 additions and 0 deletions
|
@ -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:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue