During a discussion in July 2010 it was decided that we'll stabilize on /2. See
message ID <[email protected]> for reference.
---
lib/rapi/connector.py | 8 ++++++--
test/docs_unittest.py | 15 ++++++++++++---
2 files changed, 18 insertions(+), 5 deletions(-)
diff --git a/lib/rapi/connector.py b/lib/rapi/connector.py
index ff61d14..d0b18eb 100644
--- a/lib/rapi/connector.py
+++ b/lib/rapi/connector.py
@@ -159,6 +159,10 @@ def GetHandlers(node_name_pattern, instance_name_pattern,
job_id_pattern):
"""Returns all supported resources and their handlers.
"""
+ # Important note: New resources should always be added under /2. During a
+ # discussion in July 2010 it was decided that having per-resource versions
+ # is more flexible and future-compatible than versioning the whole remote
+ # API.
return {
"/": R_root,
@@ -213,9 +217,9 @@ def GetHandlers(node_name_pattern, instance_name_pattern,
job_id_pattern):
rlib2.R_2_instances_name_migrate,
"/2/jobs": rlib2.R_2_jobs,
- re.compile(r'/2/jobs/(%s)$' % job_id_pattern):
+ re.compile(r"^/2/jobs/(%s)$" % job_id_pattern):
rlib2.R_2_jobs_id,
- re.compile(r'/2/jobs/(%s)/wait$' % job_id_pattern):
+ re.compile(r"^/2/jobs/(%s)/wait$" % job_id_pattern):
rlib2.R_2_jobs_id_wait,
"/2/tags": rlib2.R_2_tags,
diff --git a/test/docs_unittest.py b/test/docs_unittest.py
index 95d81a8..03278d3 100755
--- a/test/docs_unittest.py
+++ b/test/docs_unittest.py
@@ -92,11 +92,16 @@ class TestDocs(unittest.TestCase):
prevline = line
+ prefix_exception = frozenset(["/", "/version", "/2"])
+
undocumented = []
for key, handler in resources.iteritems():
# Regex objects
if hasattr(key, "match"):
+ self.assert_(key.pattern.startswith("^/2/"),
+ msg="Pattern %r does not start with '^/2/'" % key.pattern)
+
found = False
for title in titles:
if (title.startswith("``") and
@@ -107,10 +112,14 @@ class TestDocs(unittest.TestCase):
if not found:
# TODO: Find better way of identifying resource
- undocumented.append(str(handler))
+ undocumented.append(key.pattern)
+
+ else:
+ self.assert_(key.startswith("/2/") or key in prefix_exception,
+ msg="Path %r does not start with '/2/'" % key)
- elif ("``%s``" % key) not in titles:
- undocumented.append(key)
+ if ("``%s``" % key) not in titles:
+ undocumented.append(key)
self.failIf(undocumented,
msg=("Missing RAPI resource documentation for %s" %
--
1.7.0.4