Repository API » History » Revision 17
« Previous |
Revision 17/25
(diff)
| Next »
koszko, 01/19/2022 09:27 AM
fix ToC link
Repository API¶
- Table of contents
- Repository API
Under current schema¶
Fetching script info¶
hydrilla.example.com/script?n=helloscript
returns:
{
"name": "helloscript",
"location": "somedirectory/hello.js",
"sha256": "e4dbe4dba40e8bd159fb987b0f0cf2c243d7e6b9b9dc792e58dedf1fae38b0a1"
}
or 404 Not Found in case "helloscript" script does not exist. hydrilla.example.com/content/somedirectory/hello.js
holds the actual script source.
Fetching bag info¶
hydrilla.example.com/bag?n=hellobag
returns:
{
"name": "hellobag",
"components": [["s", "helloscript"], ["s", "someotherscript"], ["b", "somebag"]]
}
or 404 Not Found in case "hellobag" bag does not exist.
Fetching pattern info¶
hydrilla.example.com/pattern?n=https://example.org/a/*
returns:
{
"pattern": "https://example.org/a/*",
"payload": ["b", "hellobag"]
}
or 404 Not Found in case requested pattern does not exist.
Querying patterns that match given URL¶
Finally, hydrilla.example.com/query?n=https://example.org/a/b
returns:
[{
"pattern": "https://example.org/a/*",
"payload": ["b", "hellobag"]
}, {
"pattern": "https://example.org/a/b",
"payload": ["b", "fix_by_mrcooldev"]
}, {
"pattern": "https://example.org/a/b",
"payload": ["b", "mod_by_missgreatskill"]
}]
or in case no patterns match the requested URL, it returns just:
[]
or in case the URL is of wrong format it returns some HTTP error.
Under the upcoming schema¶
Also, once we get to do the redesign discussed in this forum thread, current interface will be replaced with the following.
Fetching resource info¶
"resource" is now the equivalent of what we used to call "bag".
Let's assume we want to retrieve the definition of resource helloapple
. We can issue a GET to hydrilla.example.com/resources/helloapple.json
. It returns:
{
"api_schema_version": [1],
"api_schema_revision": 1,
"source_name": "hello",
"source_copyright": [
{
"file": "report.spdx",
"sha256": "d5f6e58c5d55cdea7872f3f672d3b68d6c364ee8cb7cb2af0efe7d50c7d40dc5"
}, {
"file": "LICENSES/CC0-1.0.txt",
"sha256": "a2010f343487d3f7618affe54f789f5487602331c0a8d03f49e9a7c547cf0499"
}
],
"type": "resource",
"identifier": "helloapple",
"long_name": "Hello Apple",
"uuid": "a6754dcb-58d8-4b7a-a245-24fd7ad4cd68",
"version": [2021, 11, 10],
"revision": 1,
"description": "greets an apple",
"dependencies": ["hello-message"],
"scripts": [
{
"file": "hello.js",
"sha256": "04d9c4e50c1ce40f9b7b7699a9202f23eaee31069e288502284dbbea7a38e468"
}, {
"file": "bye.js",
"sha256": "92ae552d06ef22b48cef926861b6adec522ea08906e3dc5ae2705c1175b8fc48"
}
]
}
or 404 Not Found in case resource "helloapple" does not exists. If multiple versions are available, newest version's JSON description gets returned. A different one can be retrieved by including version in the GET request. Requested path should then take the form /resources/<resource_name>/<version>.json
(e.g. GET hydrilla.example.com/resources/helloapple/2021.11.10.json
). Alternatively, a JSON list of all versions of a resource definition can be obtained by specifying ?ver=all
(e.g. GET hydrilla.example.com/resources/helloapple.json?ver=all
). File can be retrieved by issuing a GET request to hydrilla.example.com/files/sha256-<file's_sha256_sum>
. For example, requests to hydrilla.example.com/files/a2010f343487d3f7618affe54f789f5487602331c0a8d03f49e9a7c547cf0499
and hydrilla.example.com/files/04d9c4e50c1ce40f9b7b7699a9202f23eaee31069e288502284dbbea7a38e468
yield contents of "LICENSES/CC0-1.0.txt" and "hello.js", respectively.
Fetching mapping info¶
"mapping" is now a set of what we used to call "pattern".
Let's assume we want to retrieve the definition of mapping example-org-minimal
. We can issue a GET to hydrilla.example.com/mappings/example-org-minimal.json
. It returns:
{
"api_schema_version": [1],
"api_schema_revision": 1,
"source_name": "example-org-fixes-new",
"source_copyright": [
{
"file": "report.spdx",
"sha256": "d5f6e58c5d55cdea7872f3f672d3b68d6c364ee8cb7cb2af0efe7d50c7d40dc5"
}, {
"file": "LICENSES/CC0-1.0.txt",
"sha256": "a2010f343487d3f7618affe54f789f5487602331c0a8d03f49e9a7c547cf0499"
}
],
"type": "mapping",
"identifier": "example-org-minimal",
"long_name": "Example.org Minimal",
"uuid": "54d23bba-472e-42f5-9194-eaa24c0e3ee7",
"version": [2022, 5, 10],
"description": "suckless something something",
"payloads": {
"https://example.org/a/*": {
"identifier": "some-KISS-resource"
},
"https://example.org/t/*": {
"identifier": "another-KISS-resource"
}
}
}
or 404 Not Found in case "example-org-minimal" mapping does not exist. If multiple versions are available, newest version's JSON description gets returned. A different one can be retrieved by including version in the GET request. Requested path should then take the form /mappings/<mapping_name>/<version>.json
(e.g. GET hydrilla.example.com/mappings/example-org-minimal/2022.5.10.json
). Alternatively, a JSON list of all versions of a mapping definition can be obtained by specifying ?ver=all
(e.g. GET hydrilla.example.com/mappings/example-org-minimal.json?ver=all
). File can be retrieved by issuing a GET request to hydrilla.example.com/files/sha256-<file's_sha256_sum>
. For example, request to hydrilla.example.com/files/a2010f343487d3f7618affe54f789f5487602331c0a8d03f49e9a7c547cf0499
yields contents of "LICENSES/CC0-1.0.txt".
Querying mappings that match given URL¶
Assume we want to query mappings with patterns matching https://example.org/a/b
. We can issue a GET to hydrilla.example.com/query?url=https://example.org/a/b
. It returns:
{
"api_schema_version": [1],
"api_schema_revision": 1,
"mappings": [
{
"identifier": "example-org-minimal",
"version": [2022, 5, 10]
},
"identifier": "example-org-experimental",
"version": [0, 4]
}
]
}]
The value of "mappings" can be an empty array ([]
) in case no mappings match given URL. In case many versions of some mapping match the URL, only the most current of those versions that do is listed. In case the URL is of wrong format, 400 Bad Request is returned.
Fetching source info¶
By "source" we mean description of a source package used to build Hydrilla site content.
Assume we want to get description of source package hello
. We can issue a GET to hydrilla.example.com/sources/hello.json
. It returns:
{
"api_schema_version": [1],
"api_schema_revision": 1,
"source_name": "hello",
"source_copyright": [
{
"file": "report.spdx",
"sha256": "d5f6e58c5d55cdea7872f3f672d3b68d6c364ee8cb7cb2af0efe7d50c7d40dc5"
}, {
"file": "LICENSES/CC0-1.0.txt",
"sha256": "a2010f343487d3f7618affe54f789f5487602331c0a8d03f49e9a7c547cf0499"
}
],
"source_archives": [{
"extension": "zip",
"sha256": "688461da362ffe2fc8e85db73e709a5356d41c8aeb7d1eee7170c64ee21dd2a2"
}]
"upstream_url": "https://git.koszko.org/pydrilla/tree/src/test/example_content/hello",
"definitions": [
{
"type": "resource",
"identifier": "helloapple",
"version": [2021, 11, 10],
}, {
"type": "resource",
"identifier": "hello-message",
"version": [2021, 11, 10],
}, {
"type": "mapping",
"identifier": "helloapple",
"version": [2021, 11, 10],
}
]
}
Or 404 Not Found in case no such source package exists. Here "zip" was listed among available source archive extensions. It means we can download the zip archive of this source package by issuing GET to hydrilla.example.com/sources/hello.zip
.
With api_schema_version beginning with major number 1, zip archive is always guaranteed to be available.
Updated by koszko over 1 year ago · 17 revisions