This document outlines the web service API for the DAISY Pipeline.
RESTful web services describe a system in terms of its resources. Generally speaking, resources can be created, retrieved, modified, and deleted.
The main resources in this web service are scripts, jobs, clients and data-types.
A script is a Pipeline XProc script. The script is identified with a unique URI. It is described in terms of its functionality and all of its inputs and options.
A job is the execution of a script. Jobs have unique IDs and are created using input and option values. Jobs produce downloadable results.
A client is an application using the Pipeline via its API. Examples of clients are web applications and command line utilities. A client is not a human user.
A data type determines the possible values a script option can take. It is defined in an XML syntax (a subset of RelaxNG).
RESTful applications communicate via HTTP and use standard methods and status codes to create, get, and delete resources.
The following HTTP methods are used here:
GET
POST
PUT
DELETE
Every method is not implemented for every resource because in some cases, the method wouldn’t be relevant. Any unimplemented methods will respond with HTTP 405 “Method Not Allowed”.
GET
/alive
HTTP 200 OK
: Response body contains XML data. See a
sample response document.GET
/scripts
HTTP 200 OK
: Response body contains XML data. See a
sample response document.HTTP 401 Unauthorized
: Client was not authorized to perform request.GET
/scripts/$ID
HTTP 200 OK
: Response body contains XML data. See a
sample response document.HTTP 401 Unauthorized
: Client was not authorized to perform request.HTTP 404 Not Found
: Resource not foundPOST
/jobs
HTTP 201 Created
: Response body contains XML data about the new
resource. See a
sample document.HTTP 400 Bad Request
: The request was invalidHTTP 401 Unauthorized
: Client was not authorized to perform request.Read more about creating jobs.
GET
/jobs
HTTP 200 OK
: Response body contains XML data. See a
sample response document.HTTP 401 Unauthorized
: Client was not authorized to perform request.GET
/jobs/$ID
msgSeq
(optional): Returned job status messages will be a
subset of messages where the sequence values are greater than
that provided. The default is 0. This parameter allows
incremental reporting on job status; i.e. “only return messages
newer than X”.HTTP 200 OK
: Response body contains XML data. See a
sample response document.HTTP 401 Unauthorized
: Client was not authorized to perform request.HTTP 404 Not Found
: Resource not foundDELETE
/jobs/$ID
HTTP 204 No Content
: Successfully processed the request, no content being returnedHTTP 401 Unauthorized
: Client was not authorized to perform request.HTTP 404 Not Found
: Resource not foundGET
/jobs/$ID/result[/$TYPE/$NAME[/idx/$IDX]]
HTTP 200 OK
: Response body contains Zip dataHTTP 401 Unauthorized
: Client was not authorized to perform request.HTTP 404 Not Found
: Resource not foundGET
/jobs/$ID/log
HTTP 200 OK
: Response body contains a plain text representation of the log fileHTTP 401 Unauthorized
: Client was not authorized to perform request.HTTP 404 Not Found
: Resource not foundGET
/datatypes
HTTP 200 OK
: Response body contains XML data. The datatypes
root element has a href
attribute, and a datatype
child for
every existing data type. Each datatype
element has a href
atrtibute and an id
attribute containing the data type’s unique
ID.HTTP 401 Unauthorized
: Client was not authorized to perform request.GET
/datatypes/$ID
HTTP 200 OK
: Response body contains the definition of the data type in XML.HTTP 401 Unauthorized
: Client was not authorized to perform request.HTTP 404 Not Found
: Resource not foundIn addition to managing scripts and jobs, the web service also
provides an administrative interface. Use of this API is restricted
to use by authorized clients; i.e. those with ADMIN
permissions.
GET
/admin/halt/$KEY
HTTP 204 No Content
: Successfully processed the request, no content being returnedHTTP 401 Unauthorized
: Client was not authorized to perform request.HTTP 403 Forbidden
: The service could not be halted. This error would be caused by an invalid key.GET
/admin/clients
HTTP 200 OK
: Response body contains XML data. See a
sample response document.HTTP 401 Unauthorized
: Client was not authorized to perform request.HTTP 404 Not Found
: Resource not foundPOST
/admin/clients
HTTP 201 Created
: Response body contains XML data about the new
resource. See a
sample document.HTTP 400 Bad Request
: The request was invalidHTTP 401 Unauthorized
: Client was not authorized to perform request.GET
/admin/clients/$ID
HTTP 200 OK
: Response body contains XML data. See a
sample response document.HTTP 401 Unauthorized
: Client was not authorized to perform request.HTTP 404 Not Found
: Resource not foundDELETE
/admin/clients/$ID
HTTP 204 No Content
: Successfully processed the request, no content being returnedHTTP 401 Unauthorized
: Client was not authorized to perform request.HTTP 404 Not Found
: Resource not foundPUT
/admin/clients/$ID
HTTP 200 OK
: Response body contains XML data about the modified
resource. See a
sample response document.HTTP 400 Bad Request
: The request was invalidHTTP 401 Unauthorized
: Client was not authorized to perform request.HTTP 404 Not Found
: Resource not foundSchema for all the XML formats used in this API can be found here.
When authentication is enabled, the Pipeline only accepts requests from authorized clients. In order to become authorized, a client must be added to the database of clients using the admin API described in [#Admin].
The client must add the following query parameters to each request:
authid
: Identifies the client applicationtime
: Timestamp (UTC)nonce
: A unique string generated by the clientsign
: Hash of the URI string including all query params except this oneNote that it is possible to start the web service with authentication disabled. This is appropriate when the web service is running only locally or in other similarly controlled environments. In this case, none of the authentication parameters are required, and any that are sent are ignored.
Read more about authentication.
The web service is by default run in what is referred to as local FS
mode. The property org.daisy.pipeline.ws.localfs
must be set to
change it. In local mode, the web service assumes read/write access to
the disk. Documents that would normally be sent as part of a zip
archive or inline request can be referred to by their local file path
instead. Output options are enabled and output is written to disk
instead of being zipped up for download.
See a sample document.
In the unlikely but not impossible case that the Pipeline WS suffered from an internal error, a descriptive xml is returned along with the HTTP 500 header.
See the xml sample document.