Commit 80c03859 authored by Łukasz Nowak's avatar Łukasz Nowak

Support GET on /instance which return list of instances.

parent 99683ccb
...@@ -365,6 +365,23 @@ class InstancePublisher(GenericPublisher): ...@@ -365,6 +365,23 @@ class InstancePublisher(GenericPublisher):
self.REQUEST.response.setBody(json.dumps(d)) self.REQUEST.response.setBody(json.dumps(d))
return self.REQUEST.response return self.REQUEST.response
@requireHeader({'Accept': 'application/json'})
def __instance_list(self):
kw = dict(
portal_type=('Software Instance', 'Slave Instance'),
)
catalog = self.getPortalObject().portal_catalog
if catalog.countResults(**kw)[0][0] == 0:
self.REQUEST.response.setStatus(204)
return self.REQUEST.response
d = {"list": []}
a = d['list'].append
for si in catalog(**kw):
a('/'.join([self.absolute_url(), si.getRelativeUrl()]))
self.REQUEST.response.setStatus(200)
self.REQUEST.response.setBody(json.dumps(d))
return self.REQUEST.response
@responseSupport() @responseSupport()
def __call__(self): def __call__(self):
"""Instance GET/POST support""" """Instance GET/POST support"""
...@@ -374,9 +391,11 @@ class InstancePublisher(GenericPublisher): ...@@ -374,9 +391,11 @@ class InstancePublisher(GenericPublisher):
self.__bang() self.__bang()
else: else:
self.__request() self.__request()
elif self.REQUEST['REQUEST_METHOD'] == 'GET' and \ elif self.REQUEST['REQUEST_METHOD'] == 'GET':
self.REQUEST['traverse_subpath']: if self.REQUEST['traverse_subpath']:
self.__instance_info() self.__instance_info()
else:
self.__instance_list()
class VifibRestApiV1Tool(BaseTool): class VifibRestApiV1Tool(BaseTool):
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment