summaryrefslogtreecommitdiff
path: root/ick2/projectapi.py
diff options
context:
space:
mode:
authorLars Wirzenius <liw@liw.fi>2018-04-21 16:55:22 +0300
committerLars Wirzenius <liw@liw.fi>2018-04-21 17:47:48 +0300
commit115b2a48f32bca5939600a66767cce5069098bf8 (patch)
treedb439a31edc50984afd0f941740e67c89af7f308 /ick2/projectapi.py
parente9e51f252d8188821162ea859f86d6ee664978e7 (diff)
downloadick2-115b2a48f32bca5939600a66767cce5069098bf8.tar.gz
Add: /status endpoint for getting status of all projects
Also change icktool to use it, for speed.
Diffstat (limited to 'ick2/projectapi.py')
-rw-r--r--ick2/projectapi.py17
1 files changed, 17 insertions, 0 deletions
diff --git a/ick2/projectapi.py b/ick2/projectapi.py
index d689b4a..a1a4ac6 100644
--- a/ick2/projectapi.py
+++ b/ick2/projectapi.py
@@ -40,11 +40,17 @@ class ProjectAPI(ick2.ResourceApiBase):
return super().get_routes(path) + self.get_status_routes(path)
def get_status_routes(self, path): # pragma: no cover
+ all_statuses_path = '/status'
status_path = '{}/<project>/status'.format(path)
trigger_path = '{}/<project>/+trigger'.format(path)
return [
{
'method': 'GET',
+ 'path': all_statuses_path,
+ 'callback': self.GET(self.get_all_statuses),
+ },
+ {
+ 'method': 'GET',
'path': status_path,
'callback': self.GET(self.get_status),
},
@@ -61,7 +67,18 @@ class ProjectAPI(ick2.ResourceApiBase):
},
]
+ def get_all_statuses(self, **kwargs): # pragma: no cover
+ all_projects = self.list()
+ projects = all_projects['projects']
+ ick2.log.log(
+ 'trace', msg_text='get_all_statuses', projects=projects)
+ return {
+ project['project']: self.get_status(project['project'])
+ for project in projects
+ }
+
def get_status(self, project, **kwargs):
+ ick2.log.log('trace', msg_text='get_status', project=project)
_ = self._state.get_resource(self._type_name, project)
ps = self._ps.get_instance(project)
return {