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 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253
|
Metadata-Version: 2.1
Name: taskcluster-urls
Version: 11.0.0
Summary: Standardized url generator for taskcluster resources.
Home-page: https://github.com/taskcluster/taskcluster-lib-urls
Author: Brian Stack
Author-email: bstack@mozilla.com
License: MPL2
Description: # Taskcluster URL Building Library
[](http://mozilla.org/MPL/2.0)
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' document.
Changelog
---------
View the changelog on the [releases page](https://github.com/taskcluster/taskcluster-lib-urls/releases).
Requirements
------------
This is tested on and should run on any of Node.js `{8, 10}`.
JS Usage
--------
[](https://travis-ci.org/taskcluster/taskcluster-lib-urls)
[](https://www.npmjs.com/package/taskcluster-lib-urls)
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`
* `ui(rootUrl, path)` -> `String`
* `servicesManifest(rootUrl)` -> `String`
* `testRootUrl()` -> `String`
* `withRootUrl(rootUrl)` -> `Class` instance for above methods
When the `rootUrl` is `https://taskcluster.net`, the generated URLs will be to the Heroku cluster. Otherwise they will follow the
[spec defined in this project](https://github.com/taskcluster/taskcluster-lib-urls/tree/master/docs/urls-spec.md).
`testRootUrl()` is used to share a common fake `rootUrl` between various Taskcluster mocks in testing.
The URL does not resolve.
```js
// 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.servicesManifest(rootUrl);
libUrls.docs(rootUrl, 'foo/bar');
```
```js
// 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.servicesManifest();
urls.docs('foo/bar');
```
If you would like, you can set this up via [taskcluster-lib-loader](https://github.com/taskcluster/taskcluster-lib-loader) as follows:
```js
{
libUrlss: {
require: ['cfg'],
setup: ({cfg}) => withRootUrl(cfg.rootURl),
},
}
```
Test with:
```
yarn install
yarn test
```
Go Usage
--------
[](https://godoc.org/github.com/taskcluster/taskcluster-lib-urls)
The go package exports the following functions:
```go
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 UI(rootURL string, path string) string
func ServicesManifest(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`;
```python
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_reference(root_url, 'auth', 'v1')
taskcluster_urls.exchange_reference(root_url, 'auth', 'v1')
taskcluster_urls.ui(root_url, 'foo/bar')
taskcluster_urls.servicesManifest(root_url)
taskcluster_urls.docs(root_url, 'foo/bar')
And for testing,
```python
taskcluster_urls.test_root_url()
```
Test with:
```
tox
```
Java Usage
----------
[](http://taskcluster.github.io/taskcluster-lib-urls/apidocs)
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](http://central.sonatype.org/):
* [Search Results](http://search.maven.org/#search|gav|1|g%3A%22org.mozilla.taskcluster%22%20AND%20a%3A%22taskcluster-lib-urls%22)
* [Directory Listing](https://repo1.maven.org/maven2/org/mozilla/taskcluster/taskcluster-lib-urls/)
To use the library, do as follows:
```java
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 authAPIRef = urlProvider.apiReference("auth", "v1");
String authExchangesRef = urlProvider.exchangeReference("auth", "v1");
String uiFooBar = urlProvider.ui("foo/bar");
String servicesManifest = urlProvider.servicesManifest();
String docsFooBar = urlProvider.docs("foo/bar");
...
```
Install with:
```
mvn install
```
Test with:
```
mvn test
```
Releasing
---------
New releases should be tested on Travis and Taskcluster to allow for all supported versions of various languages to be tested. Once satisfied that it works, new versions should be created with
`npm version` rather than by manually editing `package.json` and tags should be pushed to Github.
Make the Node release first, as Python's version depends on its `package.json`. This follows the typical tag-and-push-to-publish approach:
```sh
$ npm version minor # or patch, or major
$ git push upstream
```
Once that's done, build the Python sdists (only possible by the [maintainers on pypi](https://pypi.org/project/taskcluster-urls/#files)):
```sh
rm -rf dist/*
python setup.py sdist bdist_wheel
python3 setup.py bdist_wheel
pip install twine
twine upload dist/*
```
Make sure to update [the changelog](https://github.com/taskcluster/taskcluster-lib-urls/releases)!
License
-------
[Mozilla Public License Version 2.0](https://github.com/taskcluster/taskcluster-lib-urls/blob/master/LICENSE)
Platform: UNKNOWN
Classifier: License :: OSI Approved :: Mozilla Public License 2.0 (MPL 2.0)
Classifier: Programming Language :: Python :: 2
Classifier: Programming Language :: Python :: 2.7
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.5
Classifier: Programming Language :: Python :: 3.6
Description-Content-Type: text/markdown
|