diff options
author | Alex Denisov <1101.debian@gmail.com> | 2012-09-16 17:52:06 +0300 |
---|---|---|
committer | Alex Denisov <1101.debian@gmail.com> | 2012-09-16 17:52:06 +0300 |
commit | c23eb4082948322a1b690e0850c09bfc8df81589 (patch) | |
tree | b8fa0b5cff6e69176aec2b5398f508f81733f5d4 /lib/api/keys.rb | |
parent | caef9ed1121a16ca0cc78715695daaa974271bfd (diff) | |
download | gitlab-ce-c23eb4082948322a1b690e0850c09bfc8df81589.tar.gz |
SSH Keys API implemented
Diffstat (limited to 'lib/api/keys.rb')
-rw-r--r-- | lib/api/keys.rb | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/lib/api/keys.rb b/lib/api/keys.rb new file mode 100644 index 00000000000..96ab7029fe5 --- /dev/null +++ b/lib/api/keys.rb @@ -0,0 +1,44 @@ +module Gitlab + # Keys API + class Keys < Grape::API + before { authenticate! } + resource :keys do + # Get currently authenticated user's keys + # + # Example Request: + # GET /keys + get do + present current_user.keys, with: Entities::Key + 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 /keys + post do + key = current_user.keys.new( + title: params[:title], + key: params[:key] + ) + if key.save + present key, with: Entities::Key + else + not_found! + end + end + # Delete existed ssh key of currently authenticated user + # + # Parameters: + # id (required) - SSH Key ID + # Example Request: + # DELETE /keys/:id + delete "/:id" do + key = current_user.keys.find params[:id] + key.delete + end + end + end +end + |