Project

General

Profile

Repository API » History » Version 6

koszko, 11/12/2021 02:22 PM
minor corrections - reflect changes to on-disk format 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 5 koszko
*(note: this API schema somewhat resembles the [[Hydrilla on-disk data format]])*
67
68 4 koszko
### Fetching resource info
69
"resource" is now the equivalent of what we used to call "bag".
70
71
`hydrilla.example.com/resource?n=helloapple` returns:
72
``` javascript
73
{
74 1 jahoti
    "type": "resource",
75 5 koszko
    "identifier": "helloapple",
76
    "long_name": "Hello Apple",
77 4 koszko
    "uuid": "a6754dcb-58d8-4b7a-a245-24fd7ad4cd68",
78
    "version": "2021.11.10-1",
79
    "description": "greets an apple",
80
    "copyright": [{"years": ["2021"], "holder": "Wojtek Kosior"}],
81
    "licenses": "CC0-1.0",
82
    "dependencies": ["hello-message"],
83
    "scripts": [
84
	{
85
	    "name": "hello.js",
86
	    "copyright": [{"years": ["2021"], "holder": "Wojtek Kosior"}],
87
	    "licenses":  ["CC0-1.0", "or", "GPL-3.0-or-later"],
88
	    "sha256": "04d9c4e50c1ce40f9b7b7699a9202f23eaee31069e288502284dbbea7a38e468"
89
	}, {
90
	    "name": "bye.js",
91
	    "copyright": [{"years": ["2021"], "holder": "Wojtek Kosior"}],
92
	    "licenses":  "CC0-1.0",
93
	    "sha256": "92ae552d06ef22b48cef926861b6adec522ea08906e3dc5ae2705c1175b8fc48"
94
	}
95
    ]
96 1 jahoti
}
97
```
98
99 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).
100 1 jahoti
101 4 koszko
### Fetching mapping info
102
"mapping" is now a set of what we used to call "pattern".
103
104
`hydrilla.example.com/mapping?n=example_org_minimal` returns:
105
``` javascript
106 1 jahoti
{
107 4 koszko
    "type": "mapping",
108
    "identifier": "example-org-minimal",
109
    "long_name": "Example.org Minimal",
110
    "uuid": "54d23bba-472e-42f5-9194-eaa24c0e3ee7",
111
    "version": "2021.11.10",
112 1 jahoti
    "description": "suckless something something",
113 4 koszko
    "injctions": [
114
	{
115 1 jahoti
            "pattern":  "https://example.org/a/*",
116 4 koszko
            "payload":  "some-KISS-resource"
117 1 jahoti
        }, {
118
            "pattern":  "https://example.org/t/*",
119 4 koszko
            "payload":  "another-KISS-resource"
120
        }
121
    ]
122 1 jahoti
}
123
```
124 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).
125 1 jahoti
126
### Querying patterns that match given url
127
128
`hydrilla.example.com/query?n=https://example.org/a/b` returns:
129 4 koszko
``` javascript
130 1 jahoti
[{
131 4 koszko
    "type": "mapping",
132
    "identifier": "example_org_minimal",
133
    "long_name": "Example.org Minimal",
134
    "uuid": "54d23bba-472e-42f5-9194-eaa24c0e3ee7",
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
    "version": "0.4",
150
    "description": "[...]; patches are WANTED!",
151 1 jahoti
    "mappings": [{
152
            "pattern":  "https://example.org/**",
153 4 koszko
            "payload":  "quick-and-dirty-resource"
154 1 jahoti
        }]
155
}]
156
```
157 4 koszko
158
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.