summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGauvain Pocentek <gauvain@pocentek.net>2018-05-29 09:08:52 +0200
committerGauvain Pocentek <gauvain@pocentek.net>2018-05-29 09:08:52 +0200
commit0be81cb8f48b7497a05ec7d1e7cf0a1b6eb045a1 (patch)
tree57703ceac720467ecede42c9679d1286ff890b2a
parent096d9ecde6390a4d2795d0347280ccb2c1517143 (diff)
downloadgitlab-0be81cb8f48b7497a05ec7d1e7cf0a1b6eb045a1.tar.gz
Implement runner jobs listing
-rw-r--r--docs/gl_objects/runners.rst26
-rw-r--r--gitlab/v4/objects.py17
2 files changed, 41 insertions, 2 deletions
diff --git a/docs/gl_objects/runners.rst b/docs/gl_objects/runners.rst
index 70bd60f..1e6f81b 100644
--- a/docs/gl_objects/runners.rst
+++ b/docs/gl_objects/runners.rst
@@ -94,3 +94,29 @@ Enable a specific runner for a project::
Disable a specific runner for a project::
project.runners.delete(runner.id)
+
+Runner jobs
+===========
+
+Reference
+---------
+
+* v4 API:
+
+ + :class:`gitlab.v4.objects.RunnerJob`
+ + :class:`gitlab.v4.objects.RunnerJobManager`
+ + :attr:`gitlab.v4.objects.Runner.jobs`
+
+* GitLab API: https://docs.gitlab.com/ce/api/runners.html
+
+Examples
+--------
+
+List for jobs for a runner::
+
+ jobs = runner.jobs.list()
+
+Filter the list using the jobs status::
+
+ # status can be 'running', 'success', 'failed' or 'canceled'
+ active_jobs = runner.jobs.list(status='running')
diff --git a/gitlab/v4/objects.py b/gitlab/v4/objects.py
index a5ddd84..3ac83aa 100644
--- a/gitlab/v4/objects.py
+++ b/gitlab/v4/objects.py
@@ -3237,14 +3237,27 @@ class ProjectManager(CRUDMixin, RESTManager):
files=files, **kwargs)
-class Runner(SaveMixin, ObjectDeleteMixin, RESTObject):
+class RunnerJob(RESTObject):
pass
+class RunnerJobManager(ListMixin, RESTManager):
+ _path = '/runners/%(runner_id)s/jobs'
+ _obj_cls = RunnerJob
+ _from_parent_attrs = {'runner_id': 'id'}
+ _list_filters = ('status',)
+
+
+class Runner(SaveMixin, ObjectDeleteMixin, RESTObject):
+ _managers = (('jobs', 'RunnerJobManager'),)
+
+
class RunnerManager(RetrieveMixin, UpdateMixin, DeleteMixin, RESTManager):
_path = '/runners'
_obj_cls = Runner
- _update_attrs = (tuple(), ('description', 'active', 'tag_list'))
+ _update_attrs = (tuple(), ('description', 'active', 'tag_list',
+ 'run_untagged', 'locked', 'access_level',
+ 'maximum_timeout'))
_list_filters = ('scope', )
@cli.register_custom_action('RunnerManager', tuple(), ('scope', ))