Skip to content
Snippets Groups Projects
Commit 86c58687 authored by Robert Schilling's avatar Robert Schilling
Browse files

Return 204 for delete endpoints

parent 7733f285
No related branches found
No related tags found
No related merge requests found
Loading
Loading
@@ -68,7 +68,7 @@ gem 'gollum-rugged_adapter', '~> 0.4.2', require: false
gem 'github-linguist', '~> 4.7.0', require: 'linguist'
 
# API
gem 'grape', '~> 0.18.0'
gem 'grape', '~> 0.19.0'
gem 'grape-entity', '~> 0.6.0'
gem 'rack-cors', '~> 0.4.0', require: 'rack/cors'
 
Loading
Loading
Loading
Loading
@@ -304,7 +304,7 @@ GEM
multi_json (~> 1.11)
os (~> 0.9)
signet (~> 0.7)
grape (0.18.0)
grape (0.19.1)
activesupport
builder
hashie (>= 2.1.0)
Loading
Loading
@@ -353,8 +353,8 @@ GEM
json (~> 1.8)
multi_xml (>= 0.5.2)
httpclient (2.8.2)
i18n (0.8.0)
ice_nine (0.11.1)
i18n (0.8.1)
ice_nine (0.11.2)
influxdb (0.2.3)
cause
json
Loading
Loading
@@ -417,7 +417,7 @@ GEM
minitest (5.7.0)
mousetrap-rails (1.4.6)
multi_json (1.12.1)
multi_xml (0.5.5)
multi_xml (0.6.0)
multipart-post (2.0.0)
mustermann (0.4.0)
tool (~> 0.2)
Loading
Loading
@@ -758,7 +758,7 @@ GEM
eventmachine (~> 1.0, >= 1.0.4)
rack (>= 1, < 3)
thor (0.19.4)
thread_safe (0.3.5)
thread_safe (0.3.6)
tilt (2.0.6)
timecop (0.8.1)
timfel-krb5-auth (0.8.3)
Loading
Loading
@@ -886,7 +886,7 @@ DEPENDENCIES
gollum-rugged_adapter (~> 0.4.2)
gon (~> 6.1.0)
google-api-client (~> 0.8.6)
grape (~> 0.18.0)
grape (~> 0.19.0)
grape-entity (~> 0.6.0)
haml_lint (~> 0.21.0)
hamlit (~> 2.6.1)
Loading
Loading
@@ -1011,4 +1011,4 @@ DEPENDENCIES
wikicloth (= 0.8.1)
 
BUNDLED WITH
1.14.3
1.14.4
Loading
Loading
@@ -83,7 +83,6 @@ module API
unauthorized! unless award.user == current_user || current_user.admin?
 
award.destroy
present award, with: Entities::AwardEmoji
end
end
end
Loading
Loading
Loading
Loading
@@ -127,9 +127,7 @@ module API
 
service = ::Boards::Lists::DestroyService.new(user_project, current_user)
 
if service.execute(list)
present list, with: Entities::List
else
unless service.execute(list)
render_api_error!({ error: 'List could not be deleted!' }, 400)
end
end
Loading
Loading
Loading
Loading
@@ -124,11 +124,7 @@ module API
result = DeleteBranchService.new(user_project, current_user).
execute(params[:branch])
 
if result[:status] == :success
{
branch: params[:branch]
}
else
if result[:status] != :success
render_api_error!(result[:message], result[:return_code])
end
end
Loading
Loading
Loading
Loading
@@ -91,7 +91,7 @@ module API
delete ':id' do
message = find_message
 
present message.destroy, with: Entities::BroadcastMessage
message.destroy
end
end
end
Loading
Loading
Loading
Loading
@@ -79,7 +79,7 @@ module API
 
environment = user_project.environments.find(params[:environment_id])
 
present environment.destroy, with: Entities::Environment
environment.destroy
end
end
end
Loading
Loading
Loading
Loading
@@ -118,10 +118,7 @@ module API
file_params = declared_params(include_missing: false)
result = ::Files::DestroyService.new(user_project, current_user, commit_params(file_params)).execute
 
if result[:status] == :success
status(200)
commit_response(file_params)
else
if result[:status] != :success
render_api_error!(result[:message], 400)
end
end
Loading
Loading
module API
class Labels < Grape::API
include PaginationParams
before { authenticate! }
 
params do
Loading
Loading
@@ -56,7 +56,7 @@ module API
label = user_project.labels.find_by(title: params[:name])
not_found!('Label') unless label
 
present label.destroy, with: Entities::Label, current_user: current_user, project: user_project
label.destroy
end
 
desc 'Update an existing label. At least one optional parameter is required.' do
Loading
Loading
Loading
Loading
@@ -93,24 +93,10 @@ module API
end
delete ":id/members/:user_id" do
source = find_source(source_type, params[:id])
# Ensure that memeber exists
source.members.find_by!(user_id: params[:user_id])
 
# This is to ensure back-compatibility but find_by! should be used
# in that casse in 9.0!
member = source.members.find_by(user_id: params[:user_id])
# This is to ensure back-compatibility but this should be removed in
# favor of find_by! in 9.0!
not_found!("Member: user_id:#{params[:user_id]}") if source_type == 'group' && member.nil?
# This is to ensure back-compatibility but 204 behavior should be used
# for all DELETE endpoints in 9.0!
if member.nil?
{ message: "Access revoked", id: params[:user_id].to_i }
else
::Members::DestroyService.new(source, current_user, declared_params).execute
present member.user, with: Entities::Member, member: member
end
::Members::DestroyService.new(source, current_user, declared_params).execute
end
end
end
Loading
Loading
Loading
Loading
@@ -132,8 +132,6 @@ module API
authorize! :admin_note, note
 
::Notes::DestroyService.new(user_project, current_user).execute(note)
present note, with: Entities::Note
end
end
end
Loading
Loading
Loading
Loading
@@ -90,12 +90,9 @@ module API
requires :hook_id, type: Integer, desc: 'The ID of the hook to delete'
end
delete ":id/hooks/:hook_id" do
begin
present user_project.hooks.destroy(params[:hook_id]), with: Entities::ProjectHook
rescue
# ProjectHook can raise Error if hook_id not found
not_found!("Error deleting hook #{params[:hook_id]}")
end
hook = user_project.hooks.find(params.delete(:hook_id))
hook.destroy
end
end
end
Loading
Loading
Loading
Loading
@@ -353,7 +353,6 @@ module API
not_found!('Group Link') unless link
 
link.destroy
no_content!
end
 
desc 'Upload a file'
Loading
Loading
Loading
Loading
@@ -78,9 +78,8 @@ module API
delete ':id' do
runner = get_runner(params[:id])
authenticate_delete_runner!(runner)
runner.destroy!
 
present runner, with: Entities::Runner
runner.destroy!
end
end
 
Loading
Loading
@@ -136,8 +135,6 @@ module API
forbidden!("Only one project associated with the runner. Please remove the runner instead") if runner.projects.count == 1
 
runner_project.destroy
present runner, with: Entities::Runner
end
end
 
Loading
Loading
Loading
Loading
@@ -654,9 +654,7 @@ module API
hash.merge!(key => nil)
end
 
if service.update_attributes(attrs.merge(active: false))
true
else
unless service.update_attributes(attrs.merge(active: false))
render_api_error!('400 Bad Request', 400)
end
end
Loading
Loading
Loading
Loading
@@ -118,9 +118,10 @@ module API
delete ':id' do
snippet = snippets_for_current_user.find_by(id: params.delete(:id))
return not_found!('Snippet') unless snippet
authorize! :destroy_personal_snippet, snippet
snippet.destroy
no_content!
end
 
desc 'Get a raw snippet' do
Loading
Loading
Loading
Loading
@@ -66,7 +66,7 @@ module API
hook = SystemHook.find_by(id: params[:id])
not_found!('System hook') unless hook
 
present hook.destroy, with: Entities::Hook
hook.destroy
end
end
end
Loading
Loading
Loading
Loading
@@ -66,11 +66,7 @@ module API
result = ::Tags::DestroyService.new(user_project, current_user).
execute(params[:tag_name])
 
if result[:status] == :success
{
tag_name: params[:tag_name]
}
else
if result[:status] != :success
render_api_error!(result[:message], result[:return_code])
end
end
Loading
Loading
Loading
Loading
@@ -93,8 +93,6 @@ module API
return not_found!('Trigger') unless trigger
 
trigger.destroy
present trigger, with: Entities::Trigger
end
end
end
Loading
Loading
Loading
Loading
@@ -236,7 +236,7 @@ module API
key = user.keys.find_by(id: params[:key_id])
not_found!('Key') unless key
 
present key.destroy, with: Entities::SSHKey
key.destroy
end
 
desc 'Add an email address to a specified user. Available only for admins.' do
Loading
Loading
@@ -422,7 +422,7 @@ module API
key = current_user.keys.find_by(id: params[:key_id])
not_found!('Key') unless key
 
present key.destroy, with: Entities::SSHKey
key.destroy
end
 
desc "Get the currently authenticated user's email addresses" do
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment