diff options
Diffstat (limited to 'lib/api/projects.rb')
-rw-r--r-- | lib/api/projects.rb | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/lib/api/projects.rb b/lib/api/projects.rb index 7f8b51e..b66e65e 100644 --- a/lib/api/projects.rb +++ b/lib/api/projects.rb @@ -14,6 +14,31 @@ module API project = Project.find(params[:id]) present project, with: Entities::Project end + + post do + required_attributes! [:name, :gitlab_id, :gitlab_url, :ssh_url_to_repo] + + # TODO: Check if this has automatic filtering of attributes + # via the Grape API + + filtered_params = { + :name => params[:name], + :gitlab_id => params[:gitlab_id], + :gitlab_url => params[:gitlab_url], + :scripts => params[:scripts] || 'ls -al', + :default_ref => params[:default_ref] || 'master', + :ssh_url_to_repo => params[:ssh_url_to_repo] + } + + project = Project.new(filtered_params) + + if project.save + present project, :with => Entities::Project + else + errors = project.errors.full_messages.join(", ") + render_api_error!(errors, 400) + end + end end end end |