Merge pull request #3146 from amacarthur/AdminAPIs

Additional Admin APIs
This commit is contained in:
Dmitriy Zaporozhets 2013-03-06 22:57:24 -08:00
commit 7c408960ce
9 changed files with 201 additions and 1 deletions

View file

@ -51,6 +51,24 @@ module Gitlab
not_found!
end
end
# Transfer a project to the Group namespace
#
# Parameters:
# id - group id
# project_id - project id
# Example Request:
# POST /groups/:id/projects/:project_id
post ":id/projects/:project_id" do
authenticated_as_admin!
@group = Group.find(params[:id])
project = Project.find(params[:project_id])
if project.transfer(@group)
present @group
else
not_found!
end
end
end
end
end

View file

@ -52,6 +52,38 @@ module Gitlab
end
end
# Create new project for a specified user. Only available to admin users.
#
# Parameters:
# user_id (required) - The ID of a user
# name (required) - name for new project
# description (optional) - short project description
# default_branch (optional) - 'master' by default
# issues_enabled (optional) - enabled by default
# wall_enabled (optional) - enabled by default
# merge_requests_enabled (optional) - enabled by default
# wiki_enabled (optional) - enabled by default
# Example Request
# POST /projects/user/:user_id
post "user/:user_id" do
authenticated_as_admin!
user = User.find(params[:user_id])
attrs = attributes_for_keys [:name,
:description,
:default_branch,
:issues_enabled,
:wall_enabled,
:merge_requests_enabled,
:wiki_enabled]
@project = ::Projects::CreateContext.new(user, attrs).execute
if @project.saved?
present @project, with: Entities::Project
else
not_found!
end
end
# Get a project team members
#
# Parameters:

View file

@ -77,6 +77,26 @@ module Gitlab
end
end
# Add ssh key to a specified user. Only available to admin users.
#
# Parameters:
# id (required) - The ID of a user
# key (required) - New SSH Key
# title (required) - New SSH Key's title
# Example Request:
# POST /users/:id/keys
post ":id/keys" do
authenticated_as_admin!
user = User.find(params[:id])
attrs = attributes_for_keys [:title, :key]
key = user.keys.new attrs
if key.save
present key, with: Entities::SSHKey
else
not_found!
end
end
# Delete user. Available only for admin
#
# Example Request: