Skip to content

Commit 3a868d0

Browse files
committed
Bug 1505402 - add new methods for specific schemas
* apiReferenceSchema * exchangesReferenceSchema * apiManifestSchema * metadataMetaschema
1 parent 304eecf commit 3a868d0

File tree

11 files changed

+264
-0
lines changed

11 files changed

+264
-0
lines changed

README.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,10 @@ root URL:
3232
* `docs(rootUrl, path)` -> `String`
3333
* `exchangeReference(rootUrl, service, version)` -> `String`
3434
* `schema(rootUrl, service, schema)` -> `String`
35+
* `apiManifestSchema(rootUrl, version)` -> `String`
36+
* `apiReferenceSchema(rootUrl, version)` -> `String`
37+
* `exchangesReferenceSchema(rootUrl, version)` -> `String`
38+
* `metadataMetaschema(rootUrl)` -> `String`
3539
* `ui(rootUrl, path)` -> `String`
3640
* `apiManifest(rootUrl)` -> `String`
3741
* `testRootUrl()` -> `String`
@@ -103,6 +107,10 @@ func APIReference(rootURL string, service string, version string) string
103107
func Docs(rootURL string, path string) string
104108
func ExchangeReference(rootURL string, service string, version string) string
105109
func Schema(rootURL string, service string, name string) string
110+
func APIManifestSchema(rootURL string, version string) string
111+
func APIReferenceSchema(rootURL string, version string) string
112+
func ExchangesReferenceSchema(rootURL string, version string) string
113+
func MetadataMetaschema(rootURL string) string
106114
func UI(rootURL string, path string) string
107115
func APIManifest(rootURL string) string
108116
```
@@ -129,6 +137,10 @@ import taskcluster_urls
129137

130138
taskcluster_urls.api(root_url, 'auth', 'v1', 'foo/bar')
131139
taskcluster_urls.schema(root_url, 'auth', 'v1/foo.yml') # Note that schema names have versions in them
140+
taskcluster_urls.api_manifest_schema(root_url, 'v1')
141+
taskcluster_urls.api_reference_schema(root_url, 'v1')
142+
taskcluster_urls.exchanges_reference_schema(root_url, 'v1')
143+
taskcluster_urls.metadata_metaschema(root_url, 'v1')
132144
taskcluster_urls.api_reference(root_url, 'auth', 'v1')
133145
taskcluster_urls.exchange_reference(root_url, 'auth', 'v1')
134146
taskcluster_urls.ui(root_url, 'foo/bar')
@@ -183,6 +195,10 @@ import org.mozilla.taskcluster.urls.*;
183195

184196
String fooBarAPI = urlProvider.api("auth", "v1", "foo/bar");
185197
String fooSchema = urlProvider.schema("auth", "v1/foo.yml"); // Note that schema names have versions in them
198+
String apiSchema = urlProvider.apiReferenceSchema("v1");
199+
String exchangesSchema = urlProvider.exchangesReferenceSchema("v1");
200+
String manifestSchema = urlProvider.apiManifestSchema("v1");
201+
String metaschema = urlProvider.metadataMetaschema();
186202
String authAPIRef = urlProvider.apiReference("auth", "v1");
187203
String authExchangesRef = urlProvider.exchangeReference("auth", "v1");
188204
String uiFooBar = urlProvider.ui("foo/bar");

docs/urls-spec.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,10 @@ Taskcluster uses URLs with the following pattern:
2424
| docs(rootUrl, path) | `<rootUrl>/docs/<path>` |
2525
| exchangeReference(rootUrl, service, version) | `<rootUrl>/references/<service>/<version>/exchanges.json` |
2626
| schema(rootUrl, service, schema) | `<rootUrl>/schemas/<service>/<schema>` |
27+
| apiSchema(rootUrl, version) | `<rootUrl>/schemas/common/api-reference-<version>.json` |
28+
| exchangesSchema(rootUrl, version) | `<rootUrl>/schemas/common/exchanges-reference-<version>.json` |
29+
| apiManifestSchema(rootUrl, version) | `<rootUrl>/schemas/common/manifest-<version>.json` |
30+
| metadataMchema(rootUrl) | `<rootUrl>/schemas/common/metadata-metaschema.json` |
2731
| ui(rootUrl, path) | `<rootUrl>/<path>` |
2832
| apiManifest(rootUrl) | `<rootUrl>/references/manifest.json` |
2933

src/index.js

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,34 @@ class LegacyUrls {
4444
return `https://schemas.taskcluster.net/${service}/${cleanPath(schema)}`;
4545
}
4646

47+
/**
48+
* Generate URL for the api reference schema
49+
*/
50+
apiReferenceSchema(version) {
51+
return this.schema('common', `api-reference-${version}.json`);
52+
}
53+
54+
/**
55+
* Generate URL for the exchanges reference schema
56+
*/
57+
exchangesReferenceSchema(version) {
58+
return this.schema('common', `exchanges-reference-${version}.json`);
59+
}
60+
61+
/**
62+
* Generate URL for the api manifest schema
63+
*/
64+
apiManifestSchema(version) {
65+
return this.schema('common', `manifest-${version}.json`);
66+
}
67+
68+
/**
69+
* Generate URL for the metadata metaschema
70+
*/
71+
metadataMetaschema() {
72+
return this.schema('common', 'metadata-metaschema.json');
73+
}
74+
4775
/**
4876
* Generate URL for Taskcluser UI.
4977
*/
@@ -100,6 +128,34 @@ class Urls {
100128
return `${this.rootUrl}/schemas/${service}/${cleanPath(schema)}`;
101129
}
102130

131+
/**
132+
* Generate URL for the api reference schema
133+
*/
134+
apiReferenceSchema(version) {
135+
return this.schema('common', `api-reference-${version}.json`);
136+
}
137+
138+
/**
139+
* Generate URL for the exchanges reference schema
140+
*/
141+
exchangesReferenceSchema(version) {
142+
return this.schema('common', `exchanges-reference-${version}.json`);
143+
}
144+
145+
/**
146+
* Generate URL for the api manifest schema
147+
*/
148+
apiManifestSchema(version) {
149+
return this.schema('common', `manifest-${version}.json`);
150+
}
151+
152+
/**
153+
* Generate URL for the metadata metaschema
154+
*/
155+
metadataMetaschema() {
156+
return this.schema('common', 'metadata-metaschema.json');
157+
}
158+
103159
/**
104160
* Generate URL for Taskcluser UI.
105161
*/
@@ -174,6 +230,34 @@ module.exports = {
174230
return withRootUrl(rootUrl).schema(service, version, schema);
175231
},
176232

233+
/**
234+
* Generate URL for the api reference schema
235+
*/
236+
apiReferenceSchema(rootUrl, version) {
237+
return withRootUrl(rootUrl).apiReferenceSchema(version);
238+
},
239+
240+
/**
241+
* Generate URL for the exchanges reference schema
242+
*/
243+
exchangesReferenceSchema(rootUrl, version) {
244+
return withRootUrl(rootUrl).exchangesReferenceSchema(version);
245+
},
246+
247+
/**
248+
* Generate URL for the api manifest schema
249+
*/
250+
apiManifestSchema(rootUrl, version) {
251+
return withRootUrl(rootUrl).apiManifestSchema(version);
252+
},
253+
254+
/**
255+
* Generate URL for the metadata metaschema
256+
*/
257+
metadataMetaschema(rootUrl) {
258+
return withRootUrl(rootUrl).metadataMetaschema();
259+
},
260+
177261
/**
178262
* Generate URL for Taskcluser UI. The purpose of the function is to switch on rootUrl:
179263
* "The driver for having a ui method is so we can just call ui with a path and any root url,

src/main/java/org/mozilla/taskcluster/urls/LegacyURLs.java

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,34 @@ public String schema(String service, String schema) {
4141
return "https://schemas.taskcluster.net/" + service + "/" + Clean.path(schema);
4242
}
4343

44+
/**
45+
* Generate URL for the api reference schema
46+
*/
47+
public String apiReferenceSchema(String version) {
48+
return schema("common", "api-reference-" + version + ".json");
49+
}
50+
51+
/**
52+
* Generate URL for the exchanges reference schema
53+
*/
54+
public String exchangesReferenceSchema(String version) {
55+
return schema("common", "exchanges-reference-" + version + ".json");
56+
}
57+
58+
/**
59+
* Generate URL for the api manifest schema
60+
*/
61+
public String apiManifestSchema(String version) {
62+
return schema("common", "manifest-" + version + ".json");
63+
}
64+
65+
/**
66+
* Generate URL for the metadata metaschema
67+
*/
68+
public String metadataMetaschema() {
69+
return schema("common", "metadata-metaschema.json");
70+
}
71+
4472
/**
4573
* Generate URL for Taskcluser UI.
4674
*/

src/main/java/org/mozilla/taskcluster/urls/NewURLs.java

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,34 @@ public String schema(String service, String schema) {
4747
return this.rootURL + "/schemas/" + service + "/" + Clean.path(schema);
4848
}
4949

50+
/**
51+
* Generate URL for the api reference schema
52+
*/
53+
public String apiReferenceSchema(String version) {
54+
return schema("common", "api-reference-" + version + ".json");
55+
}
56+
57+
/**
58+
* Generate URL for the exchanges reference schema
59+
*/
60+
public String exchangesReferenceSchema(String version) {
61+
return schema("common", "exchanges-reference-" + version + ".json");
62+
}
63+
64+
/**
65+
* Generate URL for the api manifest schema
66+
*/
67+
public String apiManifestSchema(String version) {
68+
return schema("common", "manifest-" + version + ".json");
69+
}
70+
71+
/**
72+
* Generate URL for the metadata metaschema
73+
*/
74+
public String metadataMetaschema() {
75+
return schema("common", "metadata-metaschema.json");
76+
}
77+
5078
/**
5179
* Generate URL for Taskcluser UI.
5280
*/

src/main/java/org/mozilla/taskcluster/urls/URLProvider.java

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,26 @@ public interface URLProvider {
2828
*/
2929
public String schema(String service, String schema);
3030

31+
/**
32+
* Generate URL for the api reference schema
33+
*/
34+
public String apiReferenceSchema(String version);
35+
36+
/**
37+
* Generate URL for the exchanges reference schema
38+
*/
39+
public String exchangesReferenceSchema(String version);
40+
41+
/**
42+
* Generate URL for the api manifest schema
43+
*/
44+
public String apiManifestSchema(String version);
45+
46+
/**
47+
* Generate URL for the metadata metaschema
48+
*/
49+
public String metadataMetaschema();
50+
3151
/**
3252
* Generate URL for Taskcluser UI. The purpose of the function is to switch on rootUrl:
3353
* "The driver for having a ui method is so we can just call ui with a path and any root url,

src/test/java/org/mozilla/taskcluster/urls/URLsTest.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,14 @@ public static String testFunc(String function, URLProvider urlProvider, String[]
6060
return urlProvider.exchangeReference(args[0], args[1]);
6161
case "schema":
6262
return urlProvider.schema(args[0], args[1]);
63+
case "apiReferenceSchema":
64+
return urlProvider.apiReferenceSchema(args[0]);
65+
case "exchangesReferenceSchema":
66+
return urlProvider.exchangesReferenceSchema(args[0]);
67+
case "apiManifestSchema":
68+
return urlProvider.apiManifestSchema(args[0]);
69+
case "metadataMetaschema":
70+
return urlProvider.metadataMetaschema();
6371
case "ui":
6472
return urlProvider.ui(args[0]);
6573
case "apiManifest":

taskcluster_urls/__init__.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,22 @@ def schema(root_url, service, name):
4343
else:
4444
return '{}/schemas/{}/{}'.format(root_url, service, name)
4545

46+
def api_reference_schema(root_url, version):
47+
"""Generate URL for the api reference schema."""
48+
return schema(root_url, 'common', 'api-reference-{}.json'.format(version))
49+
50+
def exchanges_reference_schema(root_url, version):
51+
"""Generate URL for the exchanges reference schema."""
52+
return schema(root_url, 'common', 'exchanges-reference-{}.json'.format(version))
53+
54+
def api_manifest_schema(root_url, version):
55+
"""Generate URL for the api manifest schema"""
56+
return schema(root_url, 'common', 'manifest-{}.json'.format(version))
57+
58+
def metadata_metaschema(root_url, version):
59+
"""Generate URL for the metadata metaschema"""
60+
return schema(root_url, 'common', 'metadata-metaschema.json')
61+
4662
def ui(root_url, path):
4763
"""
4864
Generate URL for a path in the Taskcluster ui.

tcurls.go

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,26 @@ func Schema(rootURL string, service string, name string) string {
6060
}
6161
}
6262

63+
// APIReferenceSchema generates a url for the api reference schema
64+
func APIReferenceSchema(rootURL string, version string) string {
65+
return Schema(rootURL, "common", fmt.Sprintf("api-reference-%s.json", version))
66+
}
67+
68+
// ExchangesReferenceSchema generates a url for the exchanges reference schema
69+
func ExchangesReferenceSchema(rootURL string, version string) string {
70+
return Schema(rootURL, "common", fmt.Sprintf("exchanges-reference-%s.json", version))
71+
}
72+
73+
// APIManifestSchema generates a url for the api manifest schema
74+
func APIManifestSchema(rootURL string, version string) string {
75+
return Schema(rootURL, "common", fmt.Sprintf("manifest-%s.json", version))
76+
}
77+
78+
// MetadataMetaschema generates a url for the metadata metaschema
79+
func MetadataMetaschema(rootURL string) string {
80+
return Schema(rootURL, "common", "metadata-metaschema.json")
81+
}
82+
6383
// UI generates a url for a page in taskcluster tools site
6484
// The purpose of the function is to switch on rootUrl:
6585
// "The driver for having a ui method is so we can just call ui with a path and any root url,

tcurls_test.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,14 @@ func testFunc(t *testing.T, function string, expectedURL string, root string, ar
3232
actualURL = ExchangeReference(root, args[0], args[1])
3333
case "schema":
3434
actualURL = Schema(root, args[0], args[1])
35+
case "apiReferenceSchema":
36+
actualURL = APIReferenceSchema(root, args[0])
37+
case "exchangesReferenceSchema":
38+
actualURL = ExchangesReferenceSchema(root, args[0])
39+
case "apiManifestSchema":
40+
actualURL = APIManifestSchema(root, args[0])
41+
case "metadataMetaschema":
42+
actualURL = MetadataMetaschema(root)
3543
case "ui":
3644
actualURL = UI(root, args[0])
3745
case "apiManifest":

0 commit comments

Comments
 (0)