From c1173e27071b83399cd92406b229be7f0eca59f1 Mon Sep 17 00:00:00 2001 From: Alex Denisov <1101.debian@gmail.com> Date: Fri, 31 Aug 2012 10:15:37 +0300 Subject: API on Projects creation implemented --- lib/api/projects.rb | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'lib/api') diff --git a/lib/api/projects.rb b/lib/api/projects.rb index eb23641c605..7ac2fd4a249 100644 --- a/lib/api/projects.rb +++ b/lib/api/projects.rb @@ -23,6 +23,27 @@ module Gitlab present user_project, with: Entities::Project end + # Create new project + # + # Parameters: + # name (required) - name for new project + # code (optional) - code for new project, if not set used name + # path (optional) - oath for new project, if not set used name + # Example Request + # POST /projects + post do + project = {} + project[:name] = params[:name] + project[:code] = params[:code] || project[:name] + project[:path] = params[:path] || project[:name] + @project = Project.create_by_user(project, current_user) + if @project.saved? + present @project, with: Entities::Project + else + error!({'message' => '404 Not found'}, 404) + end + end + # Get a project repository branches # # Parameters: -- cgit v1.2.1 From 9811e64d71d050554c952221c4fdaf48ce1f06a6 Mon Sep 17 00:00:00 2001 From: Alex Denisov <1101.debian@gmail.com> Date: Fri, 31 Aug 2012 11:11:12 +0300 Subject: Typo and mistakes fixed --- lib/api/projects.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'lib/api') diff --git a/lib/api/projects.rb b/lib/api/projects.rb index 7ac2fd4a249..f42849cd2f2 100644 --- a/lib/api/projects.rb +++ b/lib/api/projects.rb @@ -27,8 +27,8 @@ module Gitlab # # Parameters: # name (required) - name for new project - # code (optional) - code for new project, if not set used name - # path (optional) - oath for new project, if not set used name + # code (optional) - code for new project, uses project name if not set + # path (optional) - path for new project, uses project name if not set # Example Request # POST /projects post do -- cgit v1.2.1