summaryrefslogtreecommitdiff
path: root/lib/api
diff options
context:
space:
mode:
authorSytse Sijbrandij <sytse@dosire.com>2013-11-19 16:38:43 +0100
committerSytse Sijbrandij <sytse@dosire.com>2013-11-19 16:38:43 +0100
commit6413bfb5c640d44d38fe4054c7b33f1db285c687 (patch)
tree5e28e7be8806169ed21a0607c5b266124133d94a /lib/api
parent250a86d2787ae60aaf800a5ebfee69caa4d1a1d5 (diff)
parent6cc3cc515267712733d6dd1643080bd6b2cc6cdc (diff)
downloadgitlab-ce-6413bfb5c640d44d38fe4054c7b33f1db285c687.tar.gz
Merge branch 'master' into full-post-to-oss-security
Conflicts: doc/release/security.md
Diffstat (limited to 'lib/api')
-rw-r--r--lib/api/files.rb34
-rw-r--r--lib/api/projects.rb10
2 files changed, 41 insertions, 3 deletions
diff --git a/lib/api/files.rb b/lib/api/files.rb
index e467b0f8e9a..588c27d5692 100644
--- a/lib/api/files.rb
+++ b/lib/api/files.rb
@@ -40,8 +40,7 @@ module API
# Update existing file in repository
#
# Parameters:
- # file_name (required) - The name of new file. Ex. class.rb
- # file_path (optional) - The path to new file. Ex. lib/
+ # file_path (optional) - The path to file. Ex. lib/class.rb
# branch_name (required) - The name of branch
# content (required) - File content
# commit_message (required) - Commit message
@@ -67,7 +66,36 @@ module API
render_api_error!(result[:error], 400)
end
end
+
+ # Delete existing file in repository
+ #
+ # Parameters:
+ # file_path (optional) - The path to file. Ex. lib/class.rb
+ # branch_name (required) - The name of branch
+ # content (required) - File content
+ # commit_message (required) - Commit message
+ #
+ # Example Request:
+ # DELETE /projects/:id/repository/files
+ #
+ delete ":id/repository/files" do
+ required_attributes! [:file_path, :branch_name, :commit_message]
+ attrs = attributes_for_keys [:file_path, :branch_name, :commit_message]
+ branch_name = attrs.delete(:branch_name)
+ file_path = attrs.delete(:file_path)
+ result = ::Files::DeleteContext.new(user_project, current_user, attrs, branch_name, file_path).execute
+
+ if result[:status] == :success
+ status(200)
+
+ {
+ file_path: file_path,
+ branch_name: branch_name
+ }
+ else
+ render_api_error!(result[:error], 400)
+ end
+ end
end
end
end
-
diff --git a/lib/api/projects.rb b/lib/api/projects.rb
index 42560572046..b927e63f4a4 100644
--- a/lib/api/projects.rb
+++ b/lib/api/projects.rb
@@ -31,6 +31,16 @@ module API
present @projects, with: Entities::Project
end
+ # Get all projects for admin user
+ #
+ # Example Request:
+ # GET /projects/all
+ get '/all' do
+ authenticated_as_admin!
+ @projects = paginate Project
+ present @projects, with: Entities::Project
+ end
+
# Get a single project
#
# Parameters: