Repository API » History » Version 4
koszko, 11/11/2021 07:25 PM
update the planned schema
1 | 1 | jahoti | # Repository API |
---|---|---|---|
2 | |||
3 | {{toc}} |
||
4 | |||
5 | ## Under current schema |
||
6 | |||
7 | ### Fetching script info |
||
8 | |||
9 | `hydrilla.example.com/script?n=helloscript` returns: |
||
10 | 4 | koszko | ``` javascript |
11 | 1 | jahoti | { |
12 | "name": "helloscript", |
||
13 | "location": "somedirectory/hello.js", |
||
14 | "sha256": "e4dbe4dba40e8bd159fb987b0f0cf2c243d7e6b9b9dc792e58dedf1fae38b0a1" |
||
15 | } |
||
16 | ``` |
||
17 | 2 | jahoti | or 404 Not Found in case "helloscript" script does not exist. `hydrilla.example.com/content/somedirectory/hello.js` holds the actual script source. |
18 | 1 | jahoti | |
19 | ### Fetching bag info |
||
20 | |||
21 | `hydrilla.example.com/bag?n=hellobag` returns: |
||
22 | 4 | koszko | ``` javascript |
23 | 1 | jahoti | { |
24 | "name": "hellobag", |
||
25 | "components": [["s", "helloscript"], ["s", "someotherscript"], ["b", "somebag"]] |
||
26 | } |
||
27 | ``` |
||
28 | or 404 Not Found in case "hellobag" bag does not exist. |
||
29 | |||
30 | ### Fetching pattern info |
||
31 | |||
32 | `hydrilla.example.com/pattern?n=https://example.org/a/*` returns: |
||
33 | 4 | koszko | ``` javascript |
34 | 1 | jahoti | { |
35 | "pattern": "https://example.org/a/*", |
||
36 | "payload": ["b", "hellobag"] |
||
37 | } |
||
38 | ``` |
||
39 | or 404 Not Found in case requested pattern does not exist. |
||
40 | |||
41 | ### Querying patterns that match given URL |
||
42 | |||
43 | Finally, `hydrilla.example.com/query?n=https://example.org/a/b` returns: |
||
44 | 4 | koszko | ``` javascript |
45 | 1 | jahoti | [{ |
46 | "pattern": "https://example.org/a/*", |
||
47 | "payload": ["b", "hellobag"] |
||
48 | }, { |
||
49 | "pattern": "https://example.org/a/b", |
||
50 | "payload": ["b", "fix_by_mrcooldev"] |
||
51 | }, { |
||
52 | "pattern": "https://example.org/a/b", |
||
53 | "payload": ["b", "mod_by_missgreatskill"] |
||
54 | }] |
||
55 | ``` |
||
56 | or in case no patterns match the requested URL, it returns just: |
||
57 | 4 | koszko | ``` javascript |
58 | 1 | jahoti | [] |
59 | ``` |
||
60 | or in case the URL is of wrong format it returns some HTTP error. |
||
61 | |||
62 | ## Under the upcoming schema |
||
63 | |||
64 | Also, once we get to do the redesign discussed in the <https://hydrillabugs.koszko.org/boards/1/topics/56>, the JSON will look more like the following. |
||
65 | |||
66 | 4 | koszko | ### Fetching resource info |
67 | "resource" is now the equivalent of what we used to call "bag". |
||
68 | |||
69 | `hydrilla.example.com/resource?n=helloapple` returns: |
||
70 | ``` javascript |
||
71 | 1 | jahoti | { |
72 | 4 | koszko | "type": "resource", |
73 | "name": "helloapple", |
||
74 | "uuid": "a6754dcb-58d8-4b7a-a245-24fd7ad4cd68", |
||
75 | "old_uuids": ["ad38dc5e-30b7-492d-9290-6c3ca658f1f3"], |
||
76 | "version": "2021.11.10-1", |
||
77 | "description": "greets an apple", |
||
78 | "copyright": [{"years": ["2021"], "holder": "Wojtek Kosior"}], |
||
79 | "licenses": "CC0-1.0", |
||
80 | "dependencies": ["hello-message"], |
||
81 | "scripts": [ |
||
82 | { |
||
83 | "name": "hello.js", |
||
84 | "copyright": [{"years": ["2021"], "holder": "Wojtek Kosior"}], |
||
85 | "licenses": ["CC0-1.0", "or", "GPL-3.0-or-later"], |
||
86 | "sha256": "04d9c4e50c1ce40f9b7b7699a9202f23eaee31069e288502284dbbea7a38e468" |
||
87 | }, { |
||
88 | "name": "bye.js", |
||
89 | "copyright": [{"years": ["2021"], "holder": "Wojtek Kosior"}], |
||
90 | "licenses": "CC0-1.0", |
||
91 | "sha256": "92ae552d06ef22b48cef926861b6adec522ea08906e3dc5ae2705c1175b8fc48" |
||
92 | } |
||
93 | ] |
||
94 | 1 | jahoti | } |
95 | ``` |
||
96 | |||
97 | 4 | koszko | or 404 Not Found in case resource "helloapple" does not exists. If multiple versions are available, newest version's JSON description gets returned. Another one can be retrieved by specifying a "ver" parameter to GET request (e.g. by appending `&ver=2021.11.2-2` to the URL). |
98 | 1 | jahoti | |
99 | 4 | koszko | ### Fetching mapping info |
100 | "mapping" is now a set of what we used to call "pattern". |
||
101 | |||
102 | `hydrilla.example.com/mapping?n=example_org_minimal` returns: |
||
103 | ``` javascript |
||
104 | 1 | jahoti | { |
105 | 4 | koszko | "type": "mapping", |
106 | "identifier": "example-org-minimal", |
||
107 | "long_name": "Example.org Minimal", |
||
108 | "uuid": "54d23bba-472e-42f5-9194-eaa24c0e3ee7", |
||
109 | "old_uuids": ["0525824d-f6e2-4ee2-8ac6-401e9dc79cdf"], |
||
110 | "version": "2021.11.10", |
||
111 | 1 | jahoti | "description": "suckless something something", |
112 | 4 | koszko | "injctions": [ |
113 | { |
||
114 | 1 | jahoti | "pattern": "https://example.org/a/*", |
115 | 4 | koszko | "payload": "some-KISS-resource" |
116 | 1 | jahoti | }, { |
117 | "pattern": "https://example.org/t/*", |
||
118 | 4 | koszko | "payload": "another-KISS-resource" |
119 | } |
||
120 | ] |
||
121 | 1 | jahoti | } |
122 | ``` |
||
123 | 4 | koszko | or 404 Not Found in case "example-org-minimal" resource does not exist. If multiple versions are available, newest version's JSON description gets returned. Another one can be retrieved by specifying a "ver" parameter to GET request (e.g. by appending `&ver=2021.11.2-2` to the URL). |
124 | 1 | jahoti | |
125 | ### Querying patterns that match given url |
||
126 | |||
127 | `hydrilla.example.com/query?n=https://example.org/a/b` returns: |
||
128 | 4 | koszko | ``` javascript |
129 | 1 | jahoti | [{ |
130 | 4 | koszko | "type": "mapping", |
131 | "identifier": "example_org_minimal", |
||
132 | "long_name": "Example.org Minimal", |
||
133 | "uuid": "54d23bba-472e-42f5-9194-eaa24c0e3ee7", |
||
134 | "old_uuids": ["0525824d-f6e2-4ee2-8ac6-401e9dc79cdf"], |
||
135 | "version": "2021.11.10", |
||
136 | 1 | jahoti | "description": "suckless something something", |
137 | "mappings": [{ |
||
138 | "pattern": "https://example.org/a/*", |
||
139 | 4 | koszko | "payload": "some-KISS-resource" |
140 | 1 | jahoti | }, { |
141 | "pattern": "https://example.org/t/*", |
||
142 | 4 | koszko | "payload": "another-KISS-resource" |
143 | 1 | jahoti | }] |
144 | }, { |
||
145 | 4 | koszko | "type": "mapping", |
146 | "identifier": "example_org_experimantal", |
||
147 | "long_name": "Example.org Experimantal" |
||
148 | "uuid": "edc86a6a-2911-422f-901f-08edc00391b4", |
||
149 | "old_uuids": [], |
||
150 | "version": "0.4", |
||
151 | "description": "[...]; patches are WANTED!", |
||
152 | 1 | jahoti | "mappings": [{ |
153 | "pattern": "https://example.org/**", |
||
154 | 4 | koszko | "payload": "quick-and-dirty-resource" |
155 | 1 | jahoti | }] |
156 | }] |
||
157 | ``` |
||
158 | 4 | koszko | |
159 | or `[]` in case no mappings match that URL. In case many versions of some mapping match the URL, only the most current of those versions that do is included. In case the URL is of wrong format, 400 Bad Request is returned. |