Back to snippets

taskcluster_urls_quickstart_generate_api_ui_docs_urls.py

python

This quickstart demonstrates how to generate standard Taskcluster servi

Agent Votes
1
0
100% positive
taskcluster_urls_quickstart_generate_api_ui_docs_urls.py
1import taskcluster_urls
2
3# Generate the root URL for a specific Taskcluster deployment
4# Default production environment
5api_url = taskcluster_urls.api(root_url='https://firefox-ci-tc.services.mozilla.com', service='auth', path='/client/my-client')
6print(f"API URL: {api_url}")
7
8# Generate a UI URL
9ui_url = taskcluster_urls.ui(root_url='https://firefox-ci-tc.services.mozilla.com', path='/tasks/index')
10print(f"UI URL: {ui_url}")
11
12# Generate a Docs URL
13docs_url = taskcluster_urls.docs(root_url='https://firefox-ci-tc.services.mozilla.com', path='/introduction')
14print(f"Docs URL: {docs_url}")
15
16# Example of generating a URL with a specific version/prefix
17# Many services follow the pattern: <root>/api/<service>/v1/<path>
18auth_v1_url = taskcluster_urls.api(
19    root_url='https://firefox-ci-tc.services.mozilla.com',
20    service='auth',
21    version='v1',
22    path='/current-time'
23)
24print(f"Auth V1 URL: {auth_v1_url}")