Commit fc72a3a3 authored by Oleksiy Mishchenko's avatar Oleksiy Mishchenko
Browse files

RAPI: Implement /2 resource

Reviewed-by: iustinp
parent dc824c9f
......@@ -114,12 +114,47 @@ class R_root(baserlib.R_Generic):
return baserlib.BuildUriList(rootlist, "/%s")
def _getResources(id):
"""Return a list of resources underneath given id.
This is to generalize querying of version resources lists.
@return: a list of resources names.
r_pattern = re.compile('^R_%s_([a-zA-Z0-9]+)$' % id)
rlist = []
for handler in CONNECTOR.values():
m = r_pattern.match(handler.__name__)
if m:
name =
return rlist
class R_2(baserlib.R_Generic):
""" /2 resourse.
DOC_URI = "/2"
def GET(self):
"""Show the list of mapped resources.
@return: a dictionary with 'name' and 'uri' keys for each of them.
return baserlib.BuildUriList(_getResources("2"), "/2/%s")
"/": R_root,
"/version": rlib1.R_version,
"/2": R_2,
"/2/jobs": rlib2.R_2_jobs,
"/2/nodes": rlib2.R_2_nodes,
"/2/instances": rlib2.R_2_instances,
......@@ -76,7 +76,7 @@ class R_RootTests(unittest.TestCase):
def testGet(self):
expected = [
# TODO: {'name': 'info', 'uri': '/2'},
{'name': '2', 'uri': '/2'},
{'name': 'version', 'uri': '/version'},
self.assertEquals(self.root.GET(), expected)
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