From 8f7360f3901ae27a457f252b1a9a091a857434ee Mon Sep 17 00:00:00 2001 From: miks Date: Wed, 5 Sep 2012 23:01:03 +0300 Subject: API on adding users to project implemented --- lib/api/projects.rb | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'lib/api/projects.rb') diff --git a/lib/api/projects.rb b/lib/api/projects.rb index 3d4fde9270f..46e688e47f0 100644 --- a/lib/api/projects.rb +++ b/lib/api/projects.rb @@ -44,6 +44,18 @@ module Gitlab end end + # Add users to project with specified access level + # + # Parameters: + # id (required) - The ID or code name of a project + # user_ids (required) - The ID list of users to add + # project_access (required) - Project access level + # Example Request: + # PUT /projects/:id/add_users + put ":id/add_users" do + user_project.add_users_ids_to_team(params[:user_ids], params[:project_access]) + end + # Get a project repository branches # # Parameters: -- cgit v1.2.1 From e3b1f62c6b1fda0ea711f65c699d5025ab926c9d Mon Sep 17 00:00:00 2001 From: miks Date: Thu, 6 Sep 2012 00:13:25 +0300 Subject: convert params hash to array --- lib/api/projects.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib/api/projects.rb') diff --git a/lib/api/projects.rb b/lib/api/projects.rb index 46e688e47f0..9cd86d0b899 100644 --- a/lib/api/projects.rb +++ b/lib/api/projects.rb @@ -53,7 +53,7 @@ module Gitlab # Example Request: # PUT /projects/:id/add_users put ":id/add_users" do - user_project.add_users_ids_to_team(params[:user_ids], params[:project_access]) + user_project.add_users_ids_to_team(params[:user_ids].values, params[:project_access]) end # Get a project repository branches -- cgit v1.2.1 From 909c8c345dff0851e15d81917efe7817c7f89e22 Mon Sep 17 00:00:00 2001 From: miks Date: Thu, 6 Sep 2012 23:49:29 +0300 Subject: Make project users API more RESTful --- lib/api/projects.rb | 38 ++++++++++++++++++++++++++++++++++++-- 1 file changed, 36 insertions(+), 2 deletions(-) (limited to 'lib/api/projects.rb') diff --git a/lib/api/projects.rb b/lib/api/projects.rb index 9cd86d0b899..e56f894987c 100644 --- a/lib/api/projects.rb +++ b/lib/api/projects.rb @@ -44,6 +44,17 @@ module Gitlab end end + # Get project users + # + # Parameters: + # id (required) - The ID or code name of a project + # Example Request: + # GET /projects/:id/users + get ":id/users" do + @users_projects = paginate user_project.users_projects + present @users_projects, with: Entities::UsersProject + end + # Add users to project with specified access level # # Parameters: @@ -51,11 +62,34 @@ module Gitlab # user_ids (required) - The ID list of users to add # project_access (required) - Project access level # Example Request: - # PUT /projects/:id/add_users - put ":id/add_users" do + # POST /projects/:id/users + post ":id/users" do user_project.add_users_ids_to_team(params[:user_ids].values, params[:project_access]) end + # Update users to specified access level + # + # Parameters: + # id (required) - The ID or code name of a project + # user_ids (required) - The ID list of users to add + # project_access (required) - New project access level to + # Example Request: + # PUT /projects/:id/add_users + put ":id/users" do + user_project.update_users_ids_to_role(params[:user_ids].values, params[:project_access]) + end + + # Delete project users + # + # Parameters: + # id (required) - The ID or code name of a project + # user_ids (required) - The ID list of users to delete + # Example Request: + # DELETE /projects/:id/users + delete ":id/users" do + user_project.delete_users_ids_from_team(params[:user_ids].values) + end + # Get a project repository branches # # Parameters: -- cgit v1.2.1 From 27e443650746ddb7bf63d9a34d4afaa15350521d Mon Sep 17 00:00:00 2001 From: miks Date: Sat, 8 Sep 2012 20:01:08 +0300 Subject: Return empty body --- lib/api/projects.rb | 3 +++ 1 file changed, 3 insertions(+) (limited to 'lib/api/projects.rb') diff --git a/lib/api/projects.rb b/lib/api/projects.rb index 6e445b2aac7..7da83429dd4 100644 --- a/lib/api/projects.rb +++ b/lib/api/projects.rb @@ -75,6 +75,7 @@ module Gitlab # POST /projects/:id/users post ":id/users" do user_project.add_users_ids_to_team(params[:user_ids].values, params[:project_access]) + nil end # Update users to specified access level @@ -87,6 +88,7 @@ module Gitlab # PUT /projects/:id/add_users put ":id/users" do user_project.update_users_ids_to_role(params[:user_ids].values, params[:project_access]) + nil end # Delete project users @@ -98,6 +100,7 @@ module Gitlab # DELETE /projects/:id/users delete ":id/users" do user_project.delete_users_ids_from_team(params[:user_ids].values) + nil end # Get a project repository branches -- cgit v1.2.1 From 3b5a90bdf654f9715fd15c189d59bd56492bae8c Mon Sep 17 00:00:00 2001 From: miks Date: Sat, 8 Sep 2012 20:51:12 +0300 Subject: Projects hooks API implemented --- lib/api/projects.rb | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) (limited to 'lib/api/projects.rb') 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: -- cgit v1.2.1 From 6d76e000d07300ab9e8e8c74b90db0abcdc48451 Mon Sep 17 00:00:00 2001 From: miks Date: Mon, 10 Sep 2012 16:50:01 +0300 Subject: Add authorization to hooks requests --- lib/api/projects.rb | 3 +++ 1 file changed, 3 insertions(+) (limited to 'lib/api/projects.rb') diff --git a/lib/api/projects.rb b/lib/api/projects.rb index dfdd359c2b2..cf23dc5f538 100644 --- a/lib/api/projects.rb +++ b/lib/api/projects.rb @@ -113,6 +113,7 @@ module Gitlab # 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 @@ -125,6 +126,7 @@ module Gitlab # 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 @@ -141,6 +143,7 @@ module Gitlab # 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 -- cgit v1.2.1