Zudoku
Unikraft Cloud Sandbox Plugin API

Commands

Server

List Commands

GET
http://localhost:7263
/commands

List the UUIDs of all commands, in the order they were started.

This operation is also the plugin's readiness probe: it takes no parameters, changes nothing, and answers on an empty sandbox, so a client can call it to establish that the plugin is serving before it sends any real work. Hence x-unikraft-plugin-readiness, which the SDK generators read to render their readiness helpers against this operation.

List Commands › Responses

The UUIDs of all known commands.

The response to listing the commands known to the sandbox.
status
​string · enum · required

The status of the response.

Enum values:
success
error
partial_success
​object · required

The response data for this request.

op_time_us
​integer · uint64 · required

The operation time in microseconds.

message
​string

An optional message providing additional information about the status.

A list of errors which may have occurred during the request.


Start Command

POST
http://localhost:7263
/commands

Start a command in the sandbox, and with req_timeout_s wait for it, so that starting, waiting, inspecting and fetching the output take one request. 500 is returned when the command could not be spawned, and 400 when cols or rows are given without pty or are zero, when req_timeout_s is not between 0 (exclusive) and 55 seconds, or when logs_limit or forget are given without req_timeout_s.

Start Command › Request Body

The request to start a command in the sandbox.
​required

The command to run: a command line interpreted by the shell, or an argument vector executed directly. A bare program name in a vector is looked up in the PATH of env, falling back to the sandbox's own PATH. 400 is returned if the vector is empty, the program cannot be resolved or run, cwd is not a directory, an environment variable name is empty or has a = in it, or the request holds what exec will not take (NUL bytes, an argument list past the kernel's limit).

Example: echo hello
cwd
​string

(OPTIONAL) Current working directory

Example: /tmp
​object

(OPTIONAL) Environment variables: the command's whole environment, unless the sandbox is configured with inherit_env, when they are laid over the environment the sandbox itself was started with.

pty
​boolean

(OPTIONAL) Run the command on a pseudo-terminal instead of pipes. Its output, stdout and stderr merged as a terminal shows them, is served as stdout; input fed to it is echoed by the terminal; an eof on stdin types the terminal's end-of-input character rather than closing anything; and deleting the logs hangs the terminal up, which ends most commands. TERM is set to xterm-256color unless env provides one.

cols
​integer · uint16

(OPTIONAL) The terminal's width in columns. Needs pty; 80 by default.

rows
​integer · uint16

(OPTIONAL) The terminal's height in rows. Needs pty; 24 by default.

stdin
​string

(OPTIONAL) Bytes to feed into standard input before anything else, base64-encoded, exactly as a POST .../stdin right after the start would.

Example: aGVsbG8K
stdin_eof
​boolean

(OPTIONAL) Whether to close standard input after stdin (at once when there is none). Defaults to true when req_timeout_s is given, since nothing can be fed until the request answers, and to false otherwise.

req_timeout_s
​number · double

(OPTIONAL) Block until the command exits or this many seconds have passed, then answer with the command's state and output (logs). More than 0 and at most 55: a proxy in front cuts a silent request at about a minute. A timeout is not an error: the answer has exitcode: null, the output so far, and the command keeps running, addressable by UUID as any other. Absent: answer as soon as the command has started.

Example: 30
logs_limit
​integer · uint64

(OPTIONAL) With req_timeout_s: at most this many bytes of each stream in the answer, the rest staying at GET .../logs. Whole streams by default.

forget
​boolean

(OPTIONAL) With req_timeout_s: forget the command once it has finished, as DELETE .../{uuid} would, so that one request is the whole exchange. Does nothing on a timeout, when the UUID is still needed, nor when the answer had to leave output behind short of what was asked (no logs_limit, or one past the bound): a persisted log that spilled past the ceiling is answered up to what memory could have held (a little over 18 MiB), and the command then stays for GET .../logs, stdout_available/stderr_available past what the answer carries showing it.

Start Command › Responses

The command that was started, as GET .../{uuid} describes it, plus its output (logs) when req_timeout_s was given.

The response to starting a command. `500` is returned when the command could not be spawned.
status
​string · enum · required

The status of the response.

Enum values:
success
error
partial_success
​object · required

The response data for this request.

op_time_us
​integer · uint64 · required

The operation time in microseconds.

message
​string

An optional message providing additional information about the status.

A list of errors which may have occurred during the request.


Get Command by UUID

GET
http://localhost:7263
/commands/{uuid}

Inspect a command by UUID. 404 is returned, with an empty body, when no such command exists.

Get Command by UUID › path Parameters

uuid
​string · uuid · required

Get Command by UUID › Responses

The command line and exit status of the command.

The response to inspecting a command. `404` is returned, with an empty body, when no command with the given UUID exists.
status
​string · enum · required

The status of the response.

Enum values:
success
error
partial_success
​object · required

The response data for this request.

op_time_us
​integer · uint64 · required

The operation time in microseconds.

message
​string

An optional message providing additional information about the status.

A list of errors which may have occurred during the request.


Delete Command by UUID

DELETE
http://localhost:7263
/commands/{uuid}

Forget a command by UUID. 404 is returned, with an empty body, when no such command exists, and 409 when the command has not finished executing: commands which are still running cannot be forgotten.

Delete Command by UUID › path Parameters

uuid
​string · uuid · required

Delete Command by UUID › Responses

The outcome of forgetting the command.

A response which carries no data of its own. `data` is `null`; the outcome of the request is the HTTP status code.
status
​string · enum · required

The status of the response.

Enum values:
success
error
partial_success
data
​required

The response data for this request.

op_time_us
​integer · uint64 · required

The operation time in microseconds.

message
​string

An optional message providing additional information about the status.

A list of errors which may have occurred during the request.


Get Command Logs

GET
http://localhost:7263
/commands/{uuid}/logs

Fetch the collected output of a command; this changes nothing, releasing is POST .../logs/release. Both streams are base64-encoded; use the raw log endpoint for binary output. 404 is returned, with an empty body, when no such command exists. 410 is returned, with an empty body, if the command's logs have been deleted. 416 is returned, with a message naming the first byte still available, when an offset is below what was released. With persistence, output past the ceiling is in the log file while the command runs, read as one stream with memory; unread output there is bounded (a quarter of the volume, 4 GiB at most, never into its last quarter), past which the command is held as without a volume.

Get Command Logs › path Parameters

uuid
​string · uuid · required

Get Command Logs › Request Body optional

The (optional) request body limiting which parts of the output streams are returned. When omitted, both streams are returned in their entirety.
​object · required

The part of the standard output stream to return.

​object · required

The part of the standard error stream to return.

Get Command Logs › Responses

The requested parts of the two output streams.

The response to fetching the output of a command. `404` is returned, with an empty body, when no command with the given UUID exists. `410` is returned, with an empty body, if the command's logs have been deleted.
status
​string · enum · required

The status of the response.

Enum values:
success
error
partial_success
​object · required

The response data for this request.

op_time_us
​integer · uint64 · required

The operation time in microseconds.

message
​string

An optional message providing additional information about the status.

A list of errors which may have occurred during the request.


Delete Command Logs

DELETE
http://localhost:7263
/commands/{uuid}/logs

Forget the output logs of an existing command, freeing up memory. The stdin/out/err pipes of running commands will be closed. Idempotent. 404 is returned, with an empty body, when no such command exists. With persistence, the log files go first; should neither go (500), nothing is deleted and the logs stay.

Delete Command Logs › path Parameters

uuid
​string · uuid · required

Delete Command Logs › Responses

The outcome of forgetting command logs.

A response which carries no data of its own. `data` is `null`; the outcome of the request is the HTTP status code.
status
​string · enum · required

The status of the response.

Enum values:
success
error
partial_success
data
​required

The response data for this request.

op_time_us
​integer · uint64 · required

The operation time in microseconds.

message
​string

An optional message providing additional information about the status.

A list of errors which may have occurred during the request.


Get Raw Command Log

GET
http://localhost:7263
/commands/{uuid}/logs/raw/{stream}

Fetch an output stream of a command as raw bytes. A single contiguous Range header is honoured, as described in RFC 9110. Once part of the stream was released (see POST .../logs/release), a request without a Range is answered with 206 and what is still available, or 416 once all of it was released, and a Range into the released part with 416. A stream longer than what memory can hold, on a volume while the command runs, is answered a page of that size at a time, 206 with a Content-Range.

Get Raw Command Log › path Parameters

uuid
​string · uuid · required
stream
​CommandLogStream · enum · required

The output stream to read raw bytes from.

Enum values:
stdout
stderr

Get Raw Command Log › Headers

Range
​string

A single contiguous byte range, e.g. bytes=0-1023.

Get Raw Command Log › Responses

An output stream of a command, returned verbatim and unenveloped. A request carrying no Range header is answered with 200 and the whole stream (or, once part of it was released, with 206 and what is still available, and with 416 once all of it was); a satisfiable Range is answered with 206, the requested bytes and a Content-Range header. 404 is returned when the command or the stream does not exist, 410 is returned, with an empty body, if the command's logs have been deleted, and 416 — with a Content-Range header reporting the total length — when the range cannot be satisfied.

binary · application/octet-stream

Release Command Logs

POST
http://localhost:7263
/commands/{uuid}/logs/release

Release what the client has of a command's output; a read never does. 404 is returned, with an empty body, when no such command exists, 410 if the command's logs have been deleted, and 400 when the body is not offsets. With persistence, output past the ceiling is in the log file while the command runs, and a release frees it there too.

Release Command Logs › path Parameters

uuid
​string · uuid · required

Release Command Logs › Request Body

What the client has of each output stream, to release.
stdout
​integer · uint64

Free the standard output stream below this byte: the client has it and will not ask for it again. A command held at its output ceiling (capped) carries on once there is room. More than there is frees what there is; no more than was released already does nothing, so a retry is harmless. Released bytes are gone, from memory and from the log file where some had spilled to it: a read's stdout_first says where what is left starts, and an offset below it is a 416. Once the command has exited and its log is a file, a release does nothing: the file is the archive, and stdout_first stays where releases left it while it ran.

stderr
​integer · uint64

The same for the standard error stream.

Release Command Logs › Responses

The outcome of releasing the output.

A response which carries no data of its own. `data` is `null`; the outcome of the request is the HTTP status code.
status
​string · enum · required

The status of the response.

Enum values:
success
error
partial_success
data
​required

The response data for this request.

op_time_us
​integer · uint64 · required

The operation time in microseconds.

message
​string

An optional message providing additional information about the status.

A list of errors which may have occurred during the request.


Resize Command Terminal

POST
http://localhost:7263
/commands/{uuid}/resize

Resize a command's terminal; the foreground job is told with SIGWINCH. 404 is returned, with an empty body, when no such command exists, 400 when the command has no terminal or the size is zero, and 409 once the command has finished.

Resize Command Terminal › path Parameters

uuid
​string · uuid · required

Resize Command Terminal › Request Body

The request to resize a command's terminal.
cols
​integer · uint16 · required

The new width, in columns.

Example: 120
rows
​integer · uint16 · required

The new height, in rows.

Example: 40

Resize Command Terminal › Responses

The outcome of resizing the terminal.

A response which carries no data of its own. `data` is `null`; the outcome of the request is the HTTP status code.
status
​string · enum · required

The status of the response.

Enum values:
success
error
partial_success
data
​required

The response data for this request.

op_time_us
​integer · uint64 · required

The operation time in microseconds.

message
​string

An optional message providing additional information about the status.

A list of errors which may have occurred during the request.


Signal Command

POST
http://localhost:7263
/commands/{uuid}/signal

Send a signal to a command. 404 is returned, with an empty body, when no such command exists, and 400 when the signal is not one: a number the kernel does not have, or a name that is not a signal's.

Signal Command › path Parameters

uuid
​string · uuid · required

Signal Command › Request Body

The request to send a signal to a command.
​required

The signal to send, either as a number or as a name, with or without the SIG prefix, e.g. 15, TERM or SIGTERM. 0 sends nothing and only checks that the command can be signalled. Real-time signals go by number: where SIGRTMIN sits is up to the program's libc (34 on glibc, 35 on musl), so they have no names here.

Example: 15

Signal Command › Responses

The outcome of sending the signal.

A response which carries no data of its own. `data` is `null`; the outcome of the request is the HTTP status code.
status
​string · enum · required

The status of the response.

Enum values:
success
error
partial_success
data
​required

The response data for this request.

op_time_us
​integer · uint64 · required

The operation time in microseconds.

message
​string

An optional message providing additional information about the status.

A list of errors which may have occurred during the request.


Write Command Stdin

POST
http://localhost:7263
/commands/{uuid}/stdin

Feed data into the standard input of a command. 404 is returned, with an empty body, when no such command exists, 410 if the command's logs have been deleted, 400 when data is not valid base64, 409 when the command has finished or its standard input is closed (an eof alone is still fine), and 429 when the command has not yet read what it was already given (its stdin queue holds 8 MiB; on a terminal an eof counts as the byte it types).

Write Command Stdin › path Parameters

uuid
​string · uuid · required

Write Command Stdin › Request Body

The request to feed data into a command's standard input.
data
​string · required

The bytes to feed into standard input, base64-encoded.

Example: aGVsbG8K
eof
​boolean

Whether to close standard input after injecting data.

Write Command Stdin › Responses

The outcome of feeding the data into standard input.

A response which carries no data of its own. `data` is `null`; the outcome of the request is the HTTP status code.
status
​string · enum · required

The status of the response.

Enum values:
success
error
partial_success
data
​required

The response data for this request.

op_time_us
​integer · uint64 · required

The operation time in microseconds.

message
​string

An optional message providing additional information about the status.

A list of errors which may have occurred during the request.


Wait for Command

POST
http://localhost:7263
/commands/{uuid}/wait

Wait for a command to finish, for up to timeout_s seconds, 55 when absent, which is the most there is. 408 is returned when the time is up with the command still running, 404, with an empty body, when no such command exists, and 400 when timeout_s is not between 0 and 55 or the body does not parse.

Wait for Command › path Parameters

uuid
​string · uuid · required

Wait for Command › Request Body optional

The request to wait for a command to finish.
timeout_s
​number · double

The longest to wait, in seconds; decimals are accepted, 0 only asks. At most 55, and 55 when absent: a proxy in front cuts a silent request at about a minute, so a longer wait is a loop on 408.

Example: 5

Wait for Command › Responses

Returned once the command has finished, within the timeout.

A response which carries no data of its own. `data` is `null`; the outcome of the request is the HTTP status code.
status
​string · enum · required

The status of the response.

Enum values:
success
error
partial_success
data
​required

The response data for this request.

op_time_us
​integer · uint64 · required

The operation time in microseconds.

message
​string

An optional message providing additional information about the status.

A list of errors which may have occurred during the request.


deprecated

Wait for Command with Timeout

POST
http://localhost:7263
/commands/{uuid}/wait_timeout

The old name for POST .../wait with a body: the same wait, 408 when the time is up with the command still running, 404, with an empty body, when no such command exists, and 400 when timeout_s is not between 0 and 55.

Wait for Command with Timeout › path Parameters

uuid
​string · uuid · required

Wait for Command with Timeout › Request Body

The request to wait for a command to finish, up to a timeout.
timeout_s
​number · double · required

The maximum time to wait, in seconds, at most 55. Decimals are accepted.

Example: 1

Wait for Command with Timeout › Responses

Returned once the command has finished, within the timeout.

A response which carries no data of its own. `data` is `null`; the outcome of the request is the HTTP status code.
status
​string · enum · required

The status of the response.

Enum values:
success
error
partial_success
data
​required

The response data for this request.

op_time_us
​integer · uint64 · required

The operation time in microseconds.

message
​string

An optional message providing additional information about the status.

A list of errors which may have occurred during the request.