summaryrefslogtreecommitdiff
path: root/lib/api/snippets.rb
diff options
context:
space:
mode:
authorDouwe Maan <douwe@gitlab.com>2017-07-07 17:13:31 +0000
committerDouwe Maan <douwe@gitlab.com>2017-07-07 17:13:31 +0000
commit820aeb4e8d8df9ed5a197a4f9529e107a170e9de (patch)
tree8783945cd1a61351beb3a772c2cf51c082eb6b04 /lib/api/snippets.rb
parentc5e11d0405ce6f1b28af50e918af24cd330cfd65 (diff)
parent4c735e1bd4bd0d67dc6f5496e13346a8b5926cd0 (diff)
downloadgitlab-ce-820aeb4e8d8df9ed5a197a4f9529e107a170e9de.tar.gz
Merge branch 'feature/user-agent-details-api' into 'master'
Allow admins to retrieve user agent details for an issue or snippet Closes #29508 See merge request !12655
Diffstat (limited to 'lib/api/snippets.rb')
-rw-r--r--lib/api/snippets.rb16
1 files changed, 16 insertions, 0 deletions
diff --git a/lib/api/snippets.rb b/lib/api/snippets.rb
index c630c24c339..fd634037a77 100644
--- a/lib/api/snippets.rb
+++ b/lib/api/snippets.rb
@@ -140,6 +140,22 @@ module API
content_type 'text/plain'
present snippet.content
end
+
+ desc 'Get the user agent details for a snippet' do
+ success Entities::UserAgentDetail
+ end
+ params do
+ requires :id, type: Integer, desc: 'The ID of a snippet'
+ end
+ get ":id/user_agent_detail" do
+ authenticated_as_admin!
+
+ snippet = Snippet.find_by!(id: params[:id])
+
+ return not_found!('UserAgentDetail') unless snippet.user_agent_detail
+
+ present snippet.user_agent_detail, with: Entities::UserAgentDetail
+ end
end
end
end