summaryrefslogtreecommitdiff
path: root/lib/api/v3/runners.rb
diff options
context:
space:
mode:
authorDouwe Maan <douwe@gitlab.com>2018-05-31 08:01:56 +0000
committerDouwe Maan <douwe@gitlab.com>2018-05-31 08:01:56 +0000
commitee3b5923a55b94631fa31bb1e8c1a5d7774bda71 (patch)
tree2a37dc381d2a8fc2384fa80ceca5bd222603379e /lib/api/v3/runners.rb
parent5116d11a6192e469ba09103507b1e0cb8d777326 (diff)
parent4d3f7ae1ef5881869140f0c4a5865f65569db26a (diff)
downloadgitlab-ce-ee3b5923a55b94631fa31bb1e8c1a5d7774bda71.tar.gz
Merge branch 'fj-36819-remove-v3-api' into 'master'
Removal of API v3 from the codebase Closes #36819 See merge request gitlab-org/gitlab-ce!18970
Diffstat (limited to 'lib/api/v3/runners.rb')
-rw-r--r--lib/api/v3/runners.rb66
1 files changed, 0 insertions, 66 deletions
diff --git a/lib/api/v3/runners.rb b/lib/api/v3/runners.rb
deleted file mode 100644
index 8a5c46805bd..00000000000
--- a/lib/api/v3/runners.rb
+++ /dev/null
@@ -1,66 +0,0 @@
-module API
- module V3
- class Runners < Grape::API
- include PaginationParams
-
- before { authenticate! }
-
- resource :runners do
- desc 'Remove a runner' do
- success ::API::Entities::Runner
- end
- params do
- requires :id, type: Integer, desc: 'The ID of the runner'
- end
- delete ':id' do
- runner = Ci::Runner.find(params[:id])
- not_found!('Runner') unless runner
-
- authenticate_delete_runner!(runner)
-
- status(200)
- runner.destroy
- end
- end
-
- params do
- requires :id, type: String, desc: 'The ID of a project'
- end
- resource :projects, requirements: { id: %r{[^/]+} } do
- before { authorize_admin_project }
-
- desc "Disable project's runner" do
- success ::API::Entities::Runner
- end
- params do
- requires :runner_id, type: Integer, desc: 'The ID of the runner'
- end
- delete ':id/runners/:runner_id' do
- runner_project = user_project.runner_projects.find_by(runner_id: params[:runner_id])
- not_found!('Runner') unless runner_project
-
- runner = runner_project.runner
- forbidden!("Only one project associated with the runner. Please remove the runner instead") if runner.projects.count == 1
-
- runner_project.destroy
-
- present runner, with: ::API::Entities::Runner
- end
- end
-
- helpers do
- def authenticate_delete_runner!(runner)
- return if current_user.admin?
-
- forbidden!("Runner is shared") if runner.is_shared?
- forbidden!("Runner associated with more than one project") if runner.projects.count > 1
- forbidden!("No access granted") unless user_can_access_runner?(runner)
- end
-
- def user_can_access_runner?(runner)
- current_user.ci_owned_runners.exists?(runner.id)
- end
- end
- end
- end
-end