From 01ea65e0e9ea5e44fa653fb95e7ba8ca1668af98 Mon Sep 17 00:00:00 2001 From: Robert Schilling Date: Tue, 17 Jan 2017 05:45:07 +0100 Subject: Paginate all endpoints that return an array --- lib/api/deploy_keys.rb | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) (limited to 'lib/api/deploy_keys.rb') diff --git a/lib/api/deploy_keys.rb b/lib/api/deploy_keys.rb index 3f5183d46a2..982645c2f64 100644 --- a/lib/api/deploy_keys.rb +++ b/lib/api/deploy_keys.rb @@ -1,12 +1,17 @@ module API class DeployKeys < Grape::API + include PaginationParams + before { authenticate! } + desc 'Return all deploy keys' + params do + use :pagination + end get "deploy_keys" do authenticated_as_admin! - keys = DeployKey.all - present keys, with: Entities::SSHKey + present paginate(DeployKey.all), with: Entities::SSHKey end params do @@ -18,8 +23,11 @@ module API desc "Get a specific project's deploy keys" do success Entities::SSHKey end + params do + use :pagination + end get ":id/deploy_keys" do - present user_project.deploy_keys, with: Entities::SSHKey + present paginate(user_project.deploy_keys), with: Entities::SSHKey end desc 'Get single deploy key' do -- cgit v1.2.1 From e7551214f33eb722ad48a8749db743a20d5ff17d Mon Sep 17 00:00:00 2001 From: Robert Schilling Date: Mon, 20 Feb 2017 09:33:42 +0100 Subject: API: Remove `DELETE projects/:id/deploy_keys/:key_id/disable` --- lib/api/deploy_keys.rb | 22 +++------------------- 1 file changed, 3 insertions(+), 19 deletions(-) (limited to 'lib/api/deploy_keys.rb') diff --git a/lib/api/deploy_keys.rb b/lib/api/deploy_keys.rb index 982645c2f64..69e85c27a65 100644 --- a/lib/api/deploy_keys.rb +++ b/lib/api/deploy_keys.rb @@ -93,20 +93,6 @@ module API end end - desc 'Disable a deploy key for a project' do - detail 'This feature was added in GitLab 8.11' - success Entities::SSHKey - end - params do - requires :key_id, type: Integer, desc: 'The ID of the deploy key' - end - delete ":id/deploy_keys/:key_id/disable" do - key = user_project.deploy_keys_projects.find_by(deploy_key_id: params[:key_id]) - key.destroy - - present key.deploy_key, with: Entities::SSHKey - end - desc 'Delete deploy key for a project' do success Key end @@ -115,11 +101,9 @@ module API end delete ":id/deploy_keys/:key_id" do key = user_project.deploy_keys_projects.find_by(deploy_key_id: params[:key_id]) - if key - key.destroy - else - not_found!('Deploy Key') - end + not_found!('Deploy Key') unless key + + key.destroy end end end -- cgit v1.2.1