3 # gen_api_schema_docs.py
5 # Generate Textile documentation pages for Arvados schema resources.
11 r = requests.get('https://localhost:9900/arvados/v1/schema',
13 if r.status_code != 200:
14 raise Exception('Bad status code %d: %s' % (r.status_code, r.text))
16 if 'application/json' not in r.headers.get('content-type', ''):
17 raise Exception('Unexpected content type: %s: %s' %
18 (r.headers.get('content-type', ''), r.text))
22 for resource in sorted(schema.keys()):
23 navorder = navorder + 1
24 properties = schema[resource]
25 res_api_endpoint = re.sub(r'([a-z])([A-Z])', r'\1_\2', resource).lower()
26 outfile = "{}.textile".format(resource)
27 if os.path.exists(outfile):
28 outfile = "{}_new.textile".format(resource)
30 with open(outfile, "w") as f:
40 A **{resource}** represents...
44 See "REST methods for working with Arvados resources":{{{{site.baseurl}}}}/api/methods.html
46 API endpoint base: @https://{{{{ site.arvados_api_host }}}}/arvados/v1/{res_api_endpoint}@
52 Prerequisites for creating a {resource}.
56 Side effects of creating a {resource}.
60 Each {resource} has, in addition to the usual "attributes of Arvados resources":resources.html:
62 table(table table-bordered table-condensed).
63 |_. Attribute|_. Type|_. Description|_. Example|
67 res_api_endpoint=res_api_endpoint))
69 for prop in properties:
70 if prop not in ['id', 'uuid', 'href', 'kind', 'etag', 'self_link',
71 'owner_uuid', 'created_at',
72 'modified_by_client_uuid',
73 'modified_by_user_uuid',
75 f.write('|{name}|{type}|||\n'.format(**prop))