JSON API (reading results)

These methods support listing jobs and reading result:

opendir readdir fopen

List all job directories (opendir)

This method takes no arguments. The listing consists of job identities that can be used to stat a single job or list the directory content.

curl -XPOST "http://chemgps.bmc.uu.se/batchelor/api/json/opendir?pretty=1"
{
    "status": "success",
    "result": [
        {
            "jobid": "00a0cacb-fcce-4e96-ae1f-b6e2ceddbb3d",
            "result": "15419047559485"
        },
        {
            "jobid": "d55a7da0-5e90-4667-8633-df7a59200c37",
            "result": "15419330338516"
        },
        {
            "jobid": "096c85f9-0e9a-4572-8ec1-6dfd558257bb",
            "result": "15419335129351"
        },
                ...
        {
            "jobid": "3c980fc7-5807-4dc5-b2a4-861c20c63906",
            "result": "15423131243894"
        }
    ]
}

Get job directory listing (readdir)

Use this method to read all directories and files from a single job directory. The listing contains the necessary information for implementing explorer like file browsing on client side.

curl -XPOST "http://chemgps.bmc.uu.se/batchelor/api/json/readdir?pretty=1" -d '{"jobid":"34f95c954-09ce-46b7-bb59-820386cc9c89","result":"15421967654378"}'
{
    "status": "success",
    "result": [
        {
            "name": "result",
            "size": 4096,
            "mime": "directory",
            "type": "dir",
            "lang": ""
        },
        {
            "name": "result/output-reverse.txt",
            "size": 13,
            "mime": "text/plain",
            "type": "file",
            "lang": "text"
        },
        {
            "name": "task-reverse.log",
            "size": 354,
            "mime": "text/plain",
            "type": "file",
            "lang": "log"
        },
        {
            "name": "result.zip",
            "size": 284,
            "mime": "application/zip",
            "type": "file",
            "lang": "zip"
        },
                ...
        {
            "name": "default/indata.ser",
            "size": 243,
            "mime": "text/plain",
            "type": "file",
            "lang": "ser"
        },
        {
            "name": "task-counter.log",
            "size": 354,
            "mime": "text/plain",
            "type": "file",
            "lang": "log"
        }
    ]
}

The complete input data is:

{
    "jobid": "6633e06c-deaf-4222-bbdf-036e4be4f0a0",
    "result": "f52764d624db129b32c21fbca0cb8d6"
}

Read file from job directory (fopen)

Use this method for reading a file or directory inside the job directory. This method will output HTTP headers that should trigger the save file dialog to open. The native MIME type of the target file will be used.

curl -XPOST "http://chemgps.bmc.uu.se/batchelor/api/json/fopen?pretty=1" -d '{"job":{"jobid":"34f95c954-09ce-46b7-bb59-820386cc9c89","result":"15421967654378"},"file":"result/output-normal.txt"}' -i
HTTP/1.1 200 OK
Date: Fri, 16 Nov 2018 02:17:54 GMT
Server: Apache
X-Powered-By: PHP/7.1.22
Set-Cookie: PHPSESSID=cf9kf7ijoqatvhi3kptfhhmpi3; path=/
Expires: Thu, 19 Nov 1981 08:52:00 GMT
Cache-Control: no-store, no-cache, must-revalidate
Pragma: no-cache
Content-Disposition: attachment; filename="output-reverse.txt"
Content-Length: 13
ETag: d7c7fb2372f26b9345090b6ec62ed1a5
Content-Type: text/plain;charset=UTF-8

hello world!!

The complete input data is:

{
    "job": {
        "jobid": "6633e06c-deaf-4222-bbdf-036e4be4f0a0",
        "result": "f52764d624db129b32c21fbca0cb8d6"
    },
    "file": "filename",
    "send": true
}

Reading a directory will return the content as a ZIP-file.

curl -XPOST "http://chemgps.bmc.uu.se/batchelor/api/json/fopen?pretty=1" -d '{"job":{"jobid":"34f95c954-09ce-46b7-bb59-820386cc9c89","result":"15421967654378"},"file":"result"}' -i
HTTP/1.1 200 OK
Date: Fri, 16 Nov 2018 02:19:57 GMT
Server: Apache
X-Powered-By: PHP/7.1.22
Set-Cookie: PHPSESSID=o9dada7m36dlq2a83872gov4u3; path=/
Expires: Thu, 19 Nov 1981 08:52:00 GMT
Cache-Control: no-store, no-cache, must-revalidate
Pragma: no-cache
Content-Disposition: attachment; filename="result.zip"
Content-Length: 284
ETag: af9a273f3e21f4d92ce6df370ba1d0e6
Content-Type: application/zip

Warning: Binary output can mess up your terminal. Use "--output -" to tell 
Warning: curl to output it to your terminal anyway, or consider "--output 
Warning: " to save to a file.

Pass false as send value to download the file as JSON data. The file content will be base64 encoded.

curl -XPOST "http://chemgps.bmc.uu.se/batchelor/api/json/fopen?pretty=1" -d '{"job":{"jobid":"34f95c954-09ce-46b7-bb59-820386cc9c89","result":"15421967654378"},"file":"result/output-normal.txt","send":false}' -i
HTTP/1.1 200 OK
Date: Fri, 16 Nov 2018 02:37:09 GMT
Server: Apache
X-Powered-By: PHP/7.1.22
Set-Cookie: PHPSESSID=pnrq4ffuad6dbhrrqf5lsp7fc3; path=/
Expires: Thu, 19 Nov 1981 08:52:00 GMT
Cache-Control: no-store, no-cache, must-revalidate
Pragma: no-cache
Content-Length: 65
Content-Type: application/json

{
    "status": "success",
    "result": "ISFkbHJvdyBvbGxlaA=="
}