diff options
author | Tomasz Maczukin <tomasz@maczukin.pl> | 2017-11-16 19:12:33 +0300 |
---|---|---|
committer | Tomasz Maczukin <tomasz@maczukin.pl> | 2017-11-28 02:36:48 +0300 |
commit | 623eb68195d51ea50e09970771442d992ff19a4a (patch) | |
tree | b8778abd2aabd5a80867f9250884f39b506fa861 /lib/api/runners.rb | |
parent | 8e7e2aeb4f0f9e1e61366a62e41fd15936593cfd (diff) |
Add new API endpoint - list jobs of a specified runner
Diffstat (limited to 'lib/api/runners.rb')
-rw-r--r-- | lib/api/runners.rb | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/lib/api/runners.rb b/lib/api/runners.rb index e816fcdd928..56b70681852 100644 --- a/lib/api/runners.rb +++ b/lib/api/runners.rb @@ -84,6 +84,18 @@ module API destroy_conditionally!(runner) end + + desc 'List jobs running on a runner' + params do + requires :id, type: Integer, desc: 'The ID of the runner' + use :pagination + end + get ':id/jobs' do + runner = get_runner(params[:id]) + authenticate_list_runners_jobs!(runner) + + present paginate(runner.builds.running), with: Entities::Job + end end params do @@ -192,6 +204,12 @@ module API forbidden!("No access granted") unless user_can_access_runner?(runner) end + def authenticate_list_runners_jobs!(runner) + return if current_user.admin? + + forbidden!("No access granted") unless user_can_access_runner?(runner) + end + def user_can_access_runner?(runner) current_user.ci_authorized_runners.exists?(runner.id) end |