/usr/share/pyshared/lazr/restful/example/multiversion/tests/wadl.txt is in python-lazr.restful 0.9.29-0ubuntu2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 | Multi-version WADL documents
****************************
A given version of the web service generates a WADL document which
describes that version only. Let's go through the WADL documents for
the different versions and see how they differ.
>>> from lazr.restful.testing.webservice import WebServiceCaller
>>> webservice = WebServiceCaller(domain='multiversion.dev')
We'll start with a helper function that retrieves the WADL description
for a given version of the key-value web service, and decomposes the
top-level tags in the WADL document into a dictionary for easy access
later. This works because all versions of the web service publish a
single top-level collection and a single entry type, so the document's
top-level structure is always the same.
>>> from lxml import etree
>>> from lxml.etree import _Comment
>>> def wadl_contents_for_version(version):
... """Parse the key-value service's WADL into a dictionary."""
... wadl = webservice.get(
... '/', media_type='application/vnd.sun.wadl+xml',
... api_version=version).body
... tree = etree.fromstring(wadl)
...
... keys = ("service_doc version_doc base service_root "
... "service_root_json pair_collection pair_entry"
... "pair_full_json pair_diff_jaon pair_page pair_page_json"
... "hosted_file hosted_file_representation"
... ).split()
...
... tags = [child for child in tree if not isinstance(child, _Comment)]
... contents = {}
... for i in range(0, len(keys)):
... contents[keys[i]] = tags[i]
... return contents
Let's take a look at the differences. In 'beta', the 'by_value' method
is not present at all.
>>> contents = wadl_contents_for_version('beta')
>>> print contents['version_doc'].attrib['title']
About version beta
>>> print contents['base'].attrib['base']
http://multiversion.dev/beta/
>>> pair_collection = contents['pair_collection']
>>> sorted([method.attrib['id'] for method in pair_collection])
['key_value_pairs-get']
As a side note, see that the service documentation and version
documentation tags are empty, because this service's configuration
doesn't specify that information:
>>> len(list(contents['service_doc']))
0
>>> len(list(contents['version_doc']))
0
In '2.0', the by_value method is called 'byValue'.
>>> contents = wadl_contents_for_version('2.0')
>>> print contents['version_doc'].attrib['title']
About version 2.0
>>> print contents['base'].attrib['base']
http://multiversion.dev/2.0/
>>> pair_collection = contents['pair_collection']
>>> sorted([method.attrib['id'] for method in pair_collection])
['key_value_pairs-byValue', 'key_value_pairs-get']
In '3.0', the method changes its name to 'by_value'.
>>> contents = wadl_contents_for_version('3.0')
>>> print contents['version_doc'].attrib['title']
About version 3.0
>>> print contents['base'].attrib['base']
http://multiversion.dev/3.0/
>>> pair_collection = contents['pair_collection']
>>> sorted([method.attrib['id'] for method in pair_collection])
['key_value_pairs-by_value', 'key_value_pairs-get']
In 'trunk', the method disappears.
>>> contents = wadl_contents_for_version('trunk')
>>> print contents['base'].attrib['base']
http://multiversion.dev/trunk/
>>> pair_collection = contents['pair_collection']
>>> sorted([method.attrib['id'] for method in pair_collection])
['key_value_pairs-get']
|