Skip to main content

Taskcluster URL Building Library

License

A simple library to generate URLs for various Taskcluster resources across our various deployment methods.

This serves as both a simple shim for projects that use JavaScript but also is the reference implementation for how we define these paths.

URLs are defined in the 'Taskcluster URL Format.

Changelog

View the changelog on the releases page.

Requirements

This is tested on and should run on any of Node.js {8, 10}.

General Usage

While the capitalization and punctunation of the function names varies depending on the language, each language provides the following methods:

method result
api(rootUrl, service, version, path) -> <rootUrl>/api/<service>/<version>/<path>
apiReference(rootUrl, service, version) -> <rootUrl>/references/<service>/<version>/api.json
docs(rootUrl, path) -> <rootUrl>/docs/<path>
exchangeReference(rootUrl, service, version) -> <rootUrl>/references/<service>/<version>/exchanges.json
schema(rootUrl, service, schema) -> <rootUrl>/schemas/<service>/<schema>
apiSchema(rootUrl, version) -> <rootUrl>/schemas/common/api-reference-<version>.json
exchangesSchema(rootUrl, version) -> <rootUrl>/schemas/common/exchanges-reference-<version>.json
apiManifestSchema(rootUrl, version) -> <rootUrl>/schemas/common/manifest-<version>.json
metadataMchema(rootUrl) -> <rootUrl>/schemas/common/metadata-metaschema.json
ui(rootUrl, path) -> <rootUrl>/<path>
apiManifest(rootUrl) -> <rootUrl>/references/manifest.json
normalizeRootUrl(rootUrl) -> the normal form of the given rootUrl
testRootUrl() -> https://tc-tests.example.com

testRootUrl() is used to share a common fake rootUrl between various Taskcluster mocks in testing. The URL does not resolve.

JS Usage

Node.js Build Status npm

This package exports several methods for generating URLs conditionally based on a root URL, as well as a few helper classes for generating URLs for a pre-determined root URL:

  • api(rootUrl, service, version, path) -> String
  • apiReference(rootUrl, service, version) -> String
  • docs(rootUrl, path) -> String
  • exchangeReference(rootUrl, service, version) -> String
  • schema(rootUrl, service, schema) -> String
  • apiManifestSchema(rootUrl, version) -> String
  • apiReferenceSchema(rootUrl, version) -> String
  • exchangesReferenceSchema(rootUrl, version) -> String
  • metadataMetaschema(rootUrl) -> String
  • ui(rootUrl, path) -> String
  • apiManifest(rootUrl) -> String
  • testRootUrl() -> String
  • withRootUrl(rootUrl) -> Class instance for above methods
  • normalizeRootUrl(rootUrl) -> String (the "normalized" form of the given rootUrl)
// Specifying root URL every time:
const libUrls = require('taskcluster-lib-urls');

libUrls.api(rootUrl, 'auth', 'v1', 'foo/bar');
libUrls.schema(rootUrl, 'auth', 'v1/foo.yml'); // Note that schema names have versions in them
libUrls.apiReference(rootUrl, 'auth', 'v1');
libUrls.exchangeReference(rootUrl, 'auth', 'v1');
libUrls.ui(rootUrl, 'foo/bar');
libUrls.apiManifest(rootUrl);
libUrls.docs(rootUrl, 'foo/bar');
// Specifying root URL in advance:
const libUrls = require('taskcluster-lib-urls');

const urls = libUrls.withRoot(rootUrl);

urls.api('auth', 'v1', 'foo/bar');
urls.schema('auth', 'v1/foo.yml');
urls.apiReference('auth', 'v1');
urls.exchangeReference('auth', 'v1');
urls.ui('foo/bar');
urls.apiManifest();
urls.docs('foo/bar');

If you would like, you can set this up via taskcluster-lib-loader as follows:

{
  libUrlss: {
    require: ['cfg'],
    setup: ({cfg}) => withRootUrl(cfg.rootURl),
  },
}

Test with:

yarn install
yarn test

Go Usage

GoDoc

Add it to your project with:

go get github.com/taskcluster/taskcluster-lib-urls/v13
import tcurls "github.com/taskcluster/taskcluster-lib-urls/v13"

Note the /v13 suffix: Go requires the module path to carry the major version for v2 and above.

The go package exports the following functions:

func API(rootURL string, service string, version string, path string) string
func APIReference(rootURL string, service string, version string) string
func Docs(rootURL string, path string) string
func ExchangeReference(rootURL string, service string, version string) string
func Schema(rootURL string, service string, name string) string
func APIManifestSchema(rootURL string, version string) string
func APIReferenceSchema(rootURL string, version string) string
func ExchangesReferenceSchema(rootURL string, version string) string
func MetadataMetaschema(rootURL string) string
func UI(rootURL string, path string) string
func APIManifest(rootURL string) string
func NormalizeRootURL(rootURL string) string

Install with:

go install ./..

Test with:

go test -v ./...

Python Usage

You can install the python client with pip install taskcluster-urls;

import taskcluster_urls

taskcluster_urls.api(root_url, 'auth', 'v1', 'foo/bar')
taskcluster_urls.schema(root_url, 'auth', 'v1/foo.yml') # Note that schema names have versions in them
taskcluster_urls.api_manifest_schema(root_url, 'v1')
taskcluster_urls.api_reference_schema(root_url, 'v1')
taskcluster_urls.exchanges_reference_schema(root_url, 'v1')
taskcluster_urls.metadata_metaschema(root_url, 'v1')
taskcluster_urls.api_reference(root_url, 'auth', 'v1')
taskcluster_urls.exchange_reference(root_url, 'auth', 'v1')
taskcluster_urls.ui(root_url, 'foo/bar')
taskcluster_urls.apiManifest(root_url)
taskcluster_urls.docs(root_url, 'foo/bar')
taskcluster_urls.normalize_root_url(root_url)
taskcluster_urls.test_root_url()

Test with:

tox

Java Usage

JavaDoc

In order to use this library from your maven project, simply include it as a project dependency:

<project>
  ...
  <dependencies>
    ...
    <dependency>
      <groupId>org.mozilla.taskcluster</groupId>
      <artifactId>taskcluster-lib-urls</artifactId>
      <version>1.0.0</version>
    </dependency>
  </dependencies>
</project>

The taskcluster-lib-urls artifacts are now available from the maven central repository:

To use the library, do as follows:

import org.mozilla.taskcluster.urls.*;

...

    URLProvider urlProvider = URLs.provider("https://mytaskcluster.acme.org");

    String fooBarAPI        = urlProvider.api("auth", "v1", "foo/bar");
    String fooSchema        = urlProvider.schema("auth", "v1/foo.yml"); // Note that schema names have versions in them
    String apiSchema        = urlProvider.apiReferenceSchema("v1");
    String exchangesSchema  = urlProvider.exchangesReferenceSchema("v1");
    String manifestSchema   = urlProvider.apiManifestSchema("v1");
    String metaschema       = urlProvider.metadataMetaschema();
    String authAPIRef       = urlProvider.apiReference("auth", "v1");
    String authExchangesRef = urlProvider.exchangeReference("auth", "v1");
    String uiFooBar         = urlProvider.ui("foo/bar");
    String apiManifest      = urlProvider.apiManifest();
    String docsFooBar       = urlProvider.docs("foo/bar");

...

Install with:

mvn install

Test with:

mvn test

Releasing

There is no publish automation — .taskcluster.yml only runs the test tasks. Every step below is manual, and each ecosystem is published separately.

Make the Node release first, as Python reads its version from package.json.

Node / npm

npm version minor  # or patch, or major
git push upstream --follow-tags
npm publish

Use npm version rather than editing package.json by hand. --follow-tags matters: a plain git push will not push the tag npm version just created, and both the GitHub release and Go consumers depend on that tag.

Go

Go consumers resolve the pushed git tag directly, so there is no separate publish step. When making a major version bump you must also update the module path in go.mod to match (.../v13 -> .../v14) in the same commit, or Go will reject the new tag with module path must match major version.

Python / PyPI

Requires being one of the maintainers on PyPI. The version is read from package.json, so there is nothing to bump here.

rm -rf dist build *.egg-info
python3 -m pip install --upgrade build twine
python3 -m build
twine check dist/*
twine upload dist/*

Java / Maven

Versioned independently in pom.xml and released to Maven Central on its own schedule; it does not track the npm version.

Make sure to update the changelog!

License

Mozilla Public License Version 2.0

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

taskcluster_urls-13.1.0.tar.gz (11.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

taskcluster_urls-13.1.0-py3-none-any.whl (10.6 kB view details)

Uploaded Python 3

File details

Details for the file taskcluster_urls-13.1.0.tar.gz.

File metadata

  • Download URL: taskcluster_urls-13.1.0.tar.gz
  • Upload date:
  • Size: 11.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.14.6

File hashes

Hashes for taskcluster_urls-13.1.0.tar.gz
Algorithm Hash digest
SHA256 ccd88e569c32b906faa93a7950756c9ddec96d83081f6f04f75319753f668f8d
MD5 5c03c2332a3bf768dc4f688598a45303
BLAKE2b-256 3ae88d1d563406366b22861c596927e3740bc69c242629881ff99d27eff2f6b5

See more details on using hashes here.

File details

Details for the file taskcluster_urls-13.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for taskcluster_urls-13.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 056c7a1607af4b011ace56c20e3af4f525c02d6323eab401fc186b625bbb7ba8
MD5 da1446fbde4f737d5b3d9d3db67304cb
BLAKE2b-256 3ad1df3bac5dd5afe2ca618ac3a0339bb6875243f4c95213315048791bc7e906

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

13.1.0 This release

2 files

13.0.2

2 files

13.0.1

3 files

12.1.0

2 files

11.0.0

3 files

10.1.0

3 files

1.1.0

3 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page