summaryrefslogtreecommitdiff
path: root/lib/api
diff options
context:
space:
mode:
authorRémy Coutable <remy@rymai.me>2017-06-07 14:37:50 +0000
committerRémy Coutable <remy@rymai.me>2017-06-07 14:37:50 +0000
commitee0e3ffc057d9a033dab3fcc9025e71a6e76bc74 (patch)
treef326227fa14deacbdd323378d58bd2f6ef86f6d0 /lib/api
parentd030393adb414a9264623f403d2b6f39adcf3b4e (diff)
parent3d70eeb5bb9dac8073a149547dc3b85c90d65e7d (diff)
downloadgitlab-ce-ee0e3ffc057d9a033dab3fcc9025e71a6e76bc74.tar.gz
Merge branch '3191-deploy-keys-update' into 'master'
Implement ability to update deploy keys Closes #3191 See merge request !10383
Diffstat (limited to 'lib/api')
-rw-r--r--lib/api/deploy_keys.rb21
1 files changed, 21 insertions, 0 deletions
diff --git a/lib/api/deploy_keys.rb b/lib/api/deploy_keys.rb
index 8a54f7f3f05..7cdee8aced7 100644
--- a/lib/api/deploy_keys.rb
+++ b/lib/api/deploy_keys.rb
@@ -76,6 +76,27 @@ module API
end
end
+ desc 'Update an existing deploy key for a project' do
+ success Entities::SSHKey
+ end
+ params do
+ requires :key_id, type: Integer, desc: 'The ID of the deploy key'
+ optional :title, type: String, desc: 'The name of the deploy key'
+ optional :can_push, type: Boolean, desc: "Can deploy key push to the project's repository"
+ at_least_one_of :title, :can_push
+ end
+ put ":id/deploy_keys/:key_id" do
+ key = user_project.deploy_keys.find(params.delete(:key_id))
+
+ authorize!(:update_deploy_key, key)
+
+ if key.update_attributes(declared_params(include_missing: false))
+ present key, with: Entities::SSHKey
+ else
+ render_validation_error!(key)
+ end
+ end
+
desc 'Enable a deploy key for a project' do
detail 'This feature was added in GitLab 8.11'
success Entities::SSHKey