Debian Codegraph @

third_party/python/taskcluster_urls/taskcluster_urls/__init__.py

raw
1 def api(root_url, service, version, path):
2 """Generate URL for path in a Taskcluster service."""
3 root_url = normalize_root_url(root_url)
4 path = path.lstrip('/')
5 return '{}/api/{}/{}/{}'.format(root_url, service, version, path)
6
7 def api_reference(root_url, service, version):
8 """Generate URL for a Taskcluster api reference."""
9 root_url = normalize_root_url(root_url)
10 return '{}/references/{}/{}/api.json'.format(root_url, service, version)
11
12 def docs(root_url, path):
13 """Generate URL for path in the Taskcluster docs."""
14 root_url = normalize_root_url(root_url)
15 path = path.lstrip('/')
16 return '{}/docs/{}'.format(root_url, path)
17
18 def exchange_reference(root_url, service, version):
19 """Generate URL for a Taskcluster exchange reference."""
20 root_url = normalize_root_url(root_url)
21 return '{}/references/{}/{}/exchanges.json'.format(root_url, service, version)
22
23 def schema(root_url, service, name):
24 """Generate URL for a schema in a Taskcluster service."""
25 root_url = normalize_root_url(root_url)
26 name = name.lstrip('/')
27 return '{}/schemas/{}/{}'.format(root_url, service, name)
28
29 def api_reference_schema(root_url, version):
30 """Generate URL for the api reference schema."""
31 return schema(root_url, 'common', 'api-reference-{}.json'.format(version))
32
33 def exchanges_reference_schema(root_url, version):
34 """Generate URL for the exchanges reference schema."""
35 return schema(root_url, 'common', 'exchanges-reference-{}.json'.format(version))
36
37 def api_manifest_schema(root_url, version):
38 """Generate URL for the api manifest schema"""
39 return schema(root_url, 'common', 'manifest-{}.json'.format(version))
40
41 def metadata_metaschema(root_url, version):
42 """Generate URL for the metadata metaschema"""
43 return schema(root_url, 'common', 'metadata-metaschema.json')
44
45 def ui(root_url, path):
46 """Generate URL for a path in the Taskcluster ui."""
47 root_url = normalize_root_url(root_url)
48 path = path.lstrip('/')
49 return '{}/{}'.format(root_url, path)
50
51 def api_manifest(root_url):
52 """Returns a URL for the API manifest of a taskcluster deployment."""
53 root_url = normalize_root_url(root_url)
54 return '{}/references/manifest.json'.format(root_url)
55
56 def test_root_url():
57 """Returns a standardized "testing" rootUrl that does not resolve but
58 is easily recognizable in test failures."""
59 return 'https://tc-tests.example.com'
60
61 def normalize_root_url(root_url):
62 """Return the normal form of the given rootUrl"""
63 return root_url.rstrip('/')