From f49ebd90e1d16b51da1523c9767c387e59771b41 Mon Sep 17 00:00:00 2001 From: Lars Wirzenius Date: Sun, 5 Nov 2017 14:52:40 +0100 Subject: Add: get pipeline status for a project --- ick2/controllerapi.py | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'ick2/controllerapi.py') diff --git a/ick2/controllerapi.py b/ick2/controllerapi.py index 09d14bc..63daa94 100644 --- a/ick2/controllerapi.py +++ b/ick2/controllerapi.py @@ -226,6 +226,28 @@ class ProjectAPI(ResourceApiBase): def get_resource_name(self, resource): return resource['project'] + def get_routes(self, path): # pragma: no cover + return super().get_routes(path) + self.get_pipeline_routes(path) + + def get_pipeline_routes(self, path): # pragma: no cover + pipeline_path = '{}//pipelines/'.format(path) + return [ + { + 'method': 'GET', + 'path': pipeline_path, + 'callback': self.GET(self.get_pipeline), + }, + ] + + def get_pipeline(self, project, pipeline): + p = self._state.get_resource(self._type_name, project) + for pl in p['pipelines']: + if pl['name'] == pipeline: + return { + 'status': pl.get('status', 'idle'), + } + raise ick2.NotFound() + def response(status_code, body, headers): # pragma: no cover obj = { -- cgit v1.2.1