diff options
author | Mika Mäenpää <mika.j.maenpaa@tut.fi> | 2014-10-15 09:57:35 +0300 |
---|---|---|
committer | Hannes Rosenögger <Hannes.Rosenoegger@bva.bund.de> | 2015-01-22 16:58:01 +0100 |
commit | 7dd5656a5b352dd5df5dabeeebdb21d7ffd9ef03 (patch) | |
tree | 52b0642a3a910c333609c7c2da6fb434447a8f81 /lib | |
parent | 1050f5230eec21cf47d5af262a1b3e62c07fec5d (diff) | |
download | gitlab-ce-7dd5656a5b352dd5df5dabeeebdb21d7ffd9ef03.tar.gz |
Implement edit via API for projects
Diffstat (limited to 'lib')
-rw-r--r-- | lib/api/projects.rb | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/lib/api/projects.rb b/lib/api/projects.rb index 5b0c31f1898..d96288bb982 100644 --- a/lib/api/projects.rb +++ b/lib/api/projects.rb @@ -200,6 +200,49 @@ module API end end + # Update an existing project + # + # Parameters: + # id (required) - the id of a project + # name (optional) - name of a project + # path (optional) - path of a project + # description (optional) - short project description + # issues_enabled (optional) + # merge_requests_enabled (optional) + # wiki_enabled (optional) + # snippets_enabled (optional) + # public (optional) - if true same as setting visibility_level = 20 + # visibility_level (optional) - visibility level of a project + # Example Request + # PUT /projects/:id + put ':id' do + attrs = attributes_for_keys [:name, + :path, + :description, + :default_branch, + :issues_enabled, + :merge_requests_enabled, + :wiki_enabled, + :snippets_enabled, + :public, + :visibility_level] + attrs = map_public_to_visibility_level(attrs) + authorize_admin_project + authorize! :rename_project, user_project if attrs[:name].present? + if attrs[:visibility_level].present? + authorize! :change_visibility_level, user_project + end + + ::Projects::UpdateService.new(user_project, + current_user, attrs).execute + + if user_project.valid? + present user_project, with: Entities::Project + else + render_validation_error!(user_project) + end + end + # Remove project # # Parameters: |