diff options
author | Matt Humphrey <matt@tomatto.co.uk> | 2013-03-05 21:23:29 +0000 |
---|---|---|
committer | Matt Humphrey <matt@tomatto.co.uk> | 2013-03-05 21:23:29 +0000 |
commit | f411772e3395f569da893dd1fc0fd666dcbb5caa (patch) | |
tree | 5d1fd661d562208bf17d20631224a7125ec37aba /lib/api/projects.rb | |
parent | 6beae84ea37e03e68affd2b69fba25f45a4e5386 (diff) | |
download | gitlab-ce-f411772e3395f569da893dd1fc0fd666dcbb5caa.tar.gz |
Project deploy keys API
Diffstat (limited to 'lib/api/projects.rb')
-rw-r--r-- | lib/api/projects.rb | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/lib/api/projects.rb b/lib/api/projects.rb index 8f57e5ac79f..763f90015dd 100644 --- a/lib/api/projects.rb +++ b/lib/api/projects.rb @@ -424,6 +424,49 @@ module Gitlab present tree.data end + # Get a specific project's keys + # + # Example Request: + # GET /projects/:id/keys + get ":id/keys" do + present user_project.deploy_keys, with: Entities::SSHKey + end + + # Get single key owned by currently authenticated user + # + # Example Request: + # GET /projects/:id/keys/:id + get ":id/keys/:key_id" do + key = user_project.deploy_keys.find params[:key_id] + present key, with: Entities::SSHKey + end + + # Add new ssh key to currently authenticated user + # + # Parameters: + # key (required) - New SSH Key + # title (required) - New SSH Key's title + # Example Request: + # POST /projects/:id/keys + post ":id/keys" do + attrs = attributes_for_keys [:title, :key] + key = user_project.deploy_keys.new attrs + if key.save + present key, with: Entities::SSHKey + else + not_found! + end + end + + # Delete existed ssh key of currently authenticated user + # + # Example Request: + # DELETE /projects/:id/keys/:id + delete ":id/keys/:key_id" do + key = user_project.deploy_keys.find params[:key_id] + key.delete + end + end end end |