summaryrefslogtreecommitdiff
path: root/lib/api/triggers.rb
diff options
context:
space:
mode:
authorTomasz Maczukin <tomasz@maczukin.pl>2016-01-05 12:25:16 +0100
committerTomasz Maczukin <tomasz@maczukin.pl>2016-01-05 12:25:16 +0100
commit8675664655c4e0f1e043afa88ff1fd75ae5a6a9e (patch)
tree41a3cc4176cf0243fb5c54cead4f497f6b27b39a /lib/api/triggers.rb
parent49c8bf4e9b510be51859dcc301cb46b29b750cb0 (diff)
downloadgitlab-ce-8675664655c4e0f1e043afa88ff1fd75ae5a6a9e.tar.gz
Get show details feature to triggers API
Diffstat (limited to 'lib/api/triggers.rb')
-rw-r--r--lib/api/triggers.rb26
1 files changed, 26 insertions, 0 deletions
diff --git a/lib/api/triggers.rb b/lib/api/triggers.rb
index 38cf1e9a2e0..0e548b936cd 100644
--- a/lib/api/triggers.rb
+++ b/lib/api/triggers.rb
@@ -62,6 +62,32 @@ module API
present triggers, with: Entities::Trigger
end
+ # Get specific trigger of a project
+ #
+ # Parameters:
+ # id (required) - The ID of a project
+ # trigger_id (required) - The ID or `token` of a trigger to show; if trigger_id contains only digits it's
+ # treated as ID other ways it's reated as `key`
+ # Example Request:
+ # GET /projects/:id/triggers/:trigger_id
+ get ':id/triggers/:trigger_id' do
+ authenticate!
+ authorize_admin_project
+
+ trigger_id = params[:trigger_id]
+ triggers = user_project.triggers
+ triggers =
+ if trigger_id.match(/^\d+$/)
+ triggers.where(id: trigger_id.to_i)
+ else
+ triggers.where(token: trigger_id)
+ end
+
+ return not_found!('Trigger') if triggers.empty?
+
+ present triggers.first, with: Entities::Trigger
+ end
+
# Create trigger
#
# Parameters: