diff options
author | Douwe Maan <me@douwe.me> | 2015-09-03 15:18:28 +0100 |
---|---|---|
committer | Douwe Maan <me@douwe.me> | 2015-09-03 15:18:28 +0100 |
commit | aaef30aaec710160b26328bb82cb5206a3ba5016 (patch) | |
tree | b6e864657b04ff2ca69fbb3741130650bfe77a48 /lib/api | |
parent | 6630a06c40b8e69e0fac8cf018b3071e57ae1a9e (diff) | |
parent | 1be79e8e7cd20abaec7d2efcbbf7d7fe4e2a0760 (diff) | |
download | gitlab-ce-aaef30aaec710160b26328bb82cb5206a3ba5016.tar.gz |
Merge pull request #9591 from bozaro/user-by-key
Add API method for get user by ID of an SSH key
Diffstat (limited to 'lib/api')
-rw-r--r-- | lib/api/api.rb | 1 | ||||
-rw-r--r-- | lib/api/entities.rb | 4 | ||||
-rw-r--r-- | lib/api/keys.rb | 20 |
3 files changed, 25 insertions, 0 deletions
diff --git a/lib/api/api.rb b/lib/api/api.rb index eebd44ea5b6..c09488d3547 100644 --- a/lib/api/api.rb +++ b/lib/api/api.rb @@ -50,5 +50,6 @@ module API mount Branches mount Labels mount Settings + mount Keys end end diff --git a/lib/api/entities.rb b/lib/api/entities.rb index 1f9dd6bc152..8dddcd7ccc3 100644 --- a/lib/api/entities.rb +++ b/lib/api/entities.rb @@ -199,6 +199,10 @@ module API expose :id, :title, :key, :created_at end + class SSHKeyWithUser < SSHKey + expose :user, using: Entities::UserFull + end + class Note < Grape::Entity expose :id expose :note, as: :body diff --git a/lib/api/keys.rb b/lib/api/keys.rb new file mode 100644 index 00000000000..2b723b79504 --- /dev/null +++ b/lib/api/keys.rb @@ -0,0 +1,20 @@ +module API + # Keys API + class Keys < Grape::API + before { authenticate! } + + resource :keys do + # Get single ssh key by id. Only available to admin users. + # + # Example Request: + # GET /keys/:id + get ":id" do + authenticated_as_admin! + + key = Key.find(params[:id]) + + present key, with: Entities::SSHKeyWithUser + end + end + end +end |