Project

General

Profile

Repository API » History » Version 7

koszko, 11/12/2021 03:58 PM
minor corrections

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 7 koszko
    "version": [2021, 11, 10],
79
    "revision": 1,
80 4 koszko
    "description": "greets an apple",
81
    "copyright": [{"years": ["2021"], "holder": "Wojtek Kosior"}],
82
    "licenses": "CC0-1.0",
83
    "dependencies": ["hello-message"],
84
    "scripts": [
85
	{
86
	    "name": "hello.js",
87
	    "copyright": [{"years": ["2021"], "holder": "Wojtek Kosior"}],
88
	    "licenses":  ["CC0-1.0", "or", "GPL-3.0-or-later"],
89
	    "sha256": "04d9c4e50c1ce40f9b7b7699a9202f23eaee31069e288502284dbbea7a38e468"
90
	}, {
91
	    "name": "bye.js",
92
	    "copyright": [{"years": ["2021"], "holder": "Wojtek Kosior"}],
93
	    "licenses":  "CC0-1.0",
94
	    "sha256": "92ae552d06ef22b48cef926861b6adec522ea08906e3dc5ae2705c1175b8fc48"
95
	}
96
    ]
97 1 jahoti
}
98
```
99
100 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).
101 1 jahoti
102 4 koszko
### Fetching mapping info
103 1 jahoti
"mapping" is now a set of what we used to call "pattern".
104 4 koszko
105 7 koszko
`hydrilla.example.com/mapping?n=example-org-minimal` returns:
106 4 koszko
``` javascript
107 1 jahoti
{
108 4 koszko
    "type": "mapping",
109 1 jahoti
    "identifier": "example-org-minimal",
110 4 koszko
    "long_name": "Example.org Minimal",
111
    "uuid": "54d23bba-472e-42f5-9194-eaa24c0e3ee7",
112 7 koszko
    "version": [2021, 11, 10],
113 1 jahoti
    "description": "suckless something something",
114 4 koszko
    "injctions": [
115
	{
116 1 jahoti
            "pattern":  "https://example.org/a/*",
117 4 koszko
            "payload":  "some-KISS-resource"
118 1 jahoti
        }, {
119
            "pattern":  "https://example.org/t/*",
120 4 koszko
            "payload":  "another-KISS-resource"
121
        }
122
    ]
123 1 jahoti
}
124
```
125 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).
126 1 jahoti
127
### Querying patterns that match given url
128
129
`hydrilla.example.com/query?n=https://example.org/a/b` returns:
130 4 koszko
``` javascript
131 1 jahoti
[{
132
    "type": "mapping",
133 4 koszko
    "identifier": "example_org_minimal",
134
    "long_name": "Example.org Minimal",
135
    "uuid": "54d23bba-472e-42f5-9194-eaa24c0e3ee7",
136 7 koszko
    "version": [2021, 11, 10],
137 1 jahoti
    "description": "suckless something something",
138
    "mappings": [{
139
            "pattern":  "https://example.org/a/*",
140 4 koszko
            "payload":  "some-KISS-resource"
141 1 jahoti
        }, {
142
            "pattern":  "https://example.org/t/*",
143 4 koszko
            "payload":  "another-KISS-resource"
144 1 jahoti
        }]
145
}, {
146 4 koszko
    "type": "mapping",
147
    "identifier": "example_org_experimantal",
148
    "long_name": "Example.org Experimantal"
149
    "uuid": "edc86a6a-2911-422f-901f-08edc00391b4",
150 7 koszko
    "version": [0, 4],
151 4 koszko
    "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.