Skip to content

Commit 4e61657

Browse files
authored
Merge pull request #22 from djmitche/bug1505402
Bug 1505402 - RFC128 updates
2 parents 601b3c2 + 3a868d0 commit 4e61657

File tree

12 files changed

+437
-23
lines changed

12 files changed

+437
-23
lines changed

README.md

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,12 @@ 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`
36-
* `servicesManifest(rootUrl)` -> `String`
40+
* `apiManifest(rootUrl)` -> `String`
3741
* `testRootUrl()` -> `String`
3842
* `withRootUrl(rootUrl)` -> `Class` instance for above methods
3943

@@ -52,7 +56,7 @@ libUrls.schema(rootUrl, 'auth', 'v1/foo.yml'); // Note that schema names have ve
5256
libUrls.apiReference(rootUrl, 'auth', 'v1');
5357
libUrls.exchangeReference(rootUrl, 'auth', 'v1');
5458
libUrls.ui(rootUrl, 'foo/bar');
55-
libUrls.servicesManifest(rootUrl);
59+
libUrls.apiManifest(rootUrl);
5660
libUrls.docs(rootUrl, 'foo/bar');
5761
```
5862

@@ -67,7 +71,7 @@ urls.schema('auth', 'v1/foo.yml');
6771
urls.apiReference('auth', 'v1');
6872
urls.exchangeReference('auth', 'v1');
6973
urls.ui('foo/bar');
70-
urls.servicesManifest();
74+
urls.apiManifest();
7175
urls.docs('foo/bar');
7276
```
7377

@@ -103,8 +107,12 @@ 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
107-
func ServicesManifest(rootURL string) string
115+
func APIManifest(rootURL string) string
108116
```
109117

110118
Install with:
@@ -129,10 +137,14 @@ 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')
135-
taskcluster_urls.servicesManifest(root_url)
147+
taskcluster_urls.apiManifest(root_url)
136148
taskcluster_urls.docs(root_url, 'foo/bar')
137149

138150
And for testing,
@@ -183,10 +195,14 @@ 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");
189-
String servicesManifest = urlProvider.servicesManifest();
205+
String apiManifest = urlProvider.apiManifest();
190206
String docsFooBar = urlProvider.docs("foo/bar");
191207

192208
...

docs/urls-spec.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,12 @@ 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>` |
28-
| servicesManifest(rootUrl) | `<rootUrl>/references/manifest.json` |
32+
| apiManifest(rootUrl) | `<rootUrl>/references/manifest.json` |
2933

3034
*NOTE*: you should *always* use this library to generate URLs, rather than
3135
hard-coding any of the above patterns.

src/index.js

Lines changed: 88 additions & 4 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
*/
@@ -54,7 +82,7 @@ class LegacyUrls {
5482
/**
5583
* Returns a URL for the service manifest of a taskcluster deployment.
5684
*/
57-
servicesManifest() {
85+
apiManifest() {
5886
return 'https://references.taskcluster.net/manifest.json';
5987
}
6088
}
@@ -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
*/
@@ -110,7 +166,7 @@ class Urls {
110166
/**
111167
* Returns a URL for the service manifest of a taskcluster deployment.
112168
*/
113-
servicesManifest() {
169+
apiManifest() {
114170
return `${this.rootUrl}/references/manifest.json`;
115171
}
116172
}
@@ -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,
@@ -195,8 +279,8 @@ module.exports = {
195279
/**
196280
* Returns a URL for the service manifest of a taskcluster deployment.
197281
*/
198-
servicesManifest(rootUrl) {
199-
return withRootUrl(rootUrl).servicesManifest();
282+
apiManifest(rootUrl) {
283+
return withRootUrl(rootUrl).apiManifest();
200284
},
201285

202286
/**

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

Lines changed: 29 additions & 1 deletion
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
*/
@@ -51,7 +79,7 @@ public String ui(String path) {
5179
/**
5280
* Returns a URL for the service manifest of a taskcluster deployment.
5381
*/
54-
public String servicesManifest() {
82+
public String apiManifest() {
5583
return "https://references.taskcluster.net/manifest.json";
5684
}
5785
}

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

Lines changed: 29 additions & 1 deletion
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
*/
@@ -57,7 +85,7 @@ public String ui(String path) {
5785
/**
5886
* Returns a URL for the service manifest of a taskcluster deployment.
5987
*/
60-
public String servicesManifest() {
88+
public String apiManifest() {
6189
return this.rootURL + "/references/manifest.json";
6290
}
6391
}

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

Lines changed: 21 additions & 1 deletion
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,
@@ -43,5 +63,5 @@ public interface URLProvider {
4363
/**
4464
* Returns a URL for the service manifest of a taskcluster deployment.
4565
*/
46-
public String servicesManifest();
66+
public String apiManifest();
4767
}

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

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,10 +60,18 @@ 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]);
65-
case "servicesManifest":
66-
return urlProvider.servicesManifest();
73+
case "apiManifest":
74+
return urlProvider.apiManifest();
6775
default:
6876
throw new NoSuchMethodException("Unknown function type: " + function);
6977
}

0 commit comments

Comments
 (0)