Zudoku
Unikraft Cloud Sandbox Plugin API

CommandLineArgs

​string[]

The command as an argument vector, executed directly without a shell.

CommandLineShell

string

The command line, interpreted by the shell.

CommandLogStream

string · enum
Enum values:
stdout
stderr

The output stream to read raw bytes from.

CommandLogsData

The collected output of a command.
stdout
​string · required

The requested part of the standard output stream, base64-encoded: from the offset asked for, or from stdout_first when none was (the same for stderr).

Example: aGVsbG8K
stderr
​string · required

The requested part of the standard error stream, base64-encoded.

stdout_available
​integer · uint64 · required

The total number of bytes the standard output stream has produced so far, released ones included: what is still available starts at stdout_first.

stderr_available
​integer · uint64 · required

The same for the standard error stream.

stdout_first
​integer · uint64 · required

The first byte of the standard output stream still available: everything before it was released. 0 unless something was; kept once the output is a file, and across a restart.

stderr_first
​integer · uint64 · required

The same for the standard error stream.

CommandLogsRange

The byte range of a single output stream to return.
offset
​integer · uint64

The first byte of the stream to return. Omitted, the stream from where it starts: byte 0, or what is still available once some was released. Given, it may not be below what was released: that is a 416.

limit
​integer · uint64

The maximum number of bytes to return; omitted, the rest of the stream. A stream comes whole up to what memory can hold, a little over 18 MiB; one longer than that, which only a volume allows, is answered in pages of that size, limit or not.

CommandLogsReleaseRequest

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.

CommandLogsRequest

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.

CommandLogsResponse

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.

CommandResizeRequest

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

CommandSignalRequest

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

CommandStdinRequest

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.

CommandWaitRequest

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

CommandWaitTimeoutRequest

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

EmptyResponse

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.

FileEncoding

string · enum
Enum values:
utf-8
base64

The encoding of the data written to a file.

GetCommandData

The state of a single command.
uuid
​string · uuid · required

The UUID of the command.

​required

The command the command was started with, in the form it was supplied in: a shell command line, or an argument vector.

cwd
​string | null · required

The current working directory, if supplied at startup, else null

​object | null · required

Environment variables, if supplied at startup, else null

pty
​boolean · required

Whether the command runs on a pseudo-terminal.

duration_ms
​integer | null · uint64 · required

Milliseconds from start to exit, or to now while the command runs. null for a command restored from a status file written before it was recorded.

exitcode
​integer | null · int32 · required

The exit code of the command. It is null while the command is still running.

capped
​boolean · required

Whether the command is held at the output ceiling: the memory for output, its own share of it (at most 16 MiB) or the sandbox's whole budget across commands, is full of output nothing has released, so nothing more of it is read and it blocks in its next write. Releasing some (see POST .../logs/release) lets it carry on. With persistence, output at the ceiling goes to the log file instead and the command carries on, which is not capped: it is only once the volume's share for unread output is used up or the volume will not take a spill. Either way true means a release is the way on. false once it has finished.

GetCommandResponse

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.

ListCommandsData

The known commands.
commands
​string[] · required

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

ListCommandsResponse

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.

MkdirRequest

The request to create a directory in the sandbox filesystem.
path
​string · required

The absolute path of the directory to create.

Example: /tmp/demo
parents
​boolean · required

Whether to create missing parent directories.

ReadFileData

The contents of a file.
contents
​string · required

The contents of the file, base64-encoded.

Example: SGVsbG8gV29ybGQhCg==

ReadFileRequest

The request to read a file from the sandbox filesystem.
path
​string · required

The absolute path of the file to read.

Example: /tmp/demo/file.txt

ReadFileResponse

The response to reading a file. `500` is returned when the file could not be read.
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.

ResponseError

The error response message for an API request.
status
​integer · uint64 · required

The HTTP status code of the error.

ResponseStatus

string · enum
Enum values:
success
error
partial_success

The response status of an API request.

RunCommandData

The command that was started, as `GET .../{uuid}` describes it.
uuid
​string · uuid · required

The UUID of the command.

​required

The command the command was started with, in the form it was supplied in: a shell command line, or an argument vector.

cwd
​string | null · required

The current working directory, if supplied at startup, else null

​object | null · required

Environment variables, if supplied at startup, else null

pty
​boolean · required

Whether the command runs on a pseudo-terminal.

duration_ms
​integer | null · uint64 · required

Milliseconds from start to exit, or to now while the command runs. null for a command restored from a status file written before it was recorded.

exitcode
​integer | null · int32 · required

The exit code of the command. It is null while the command is still running.

capped
​boolean · required

Whether the command is held at the output ceiling: the memory for output, its own share of it (at most 16 MiB) or the sandbox's whole budget across commands, is full of output nothing has released, so nothing more of it is read and it blocks in its next write. Releasing some (see POST .../logs/release) lets it carry on. With persistence, output at the ceiling goes to the log file instead and the command carries on, which is not capped: it is only once the volume's share for unread output is used up or the volume will not take a spill. Either way true means a release is the way on. false once it has finished.

​object

Only with req_timeout_s: the output, as GET .../logs returns it. Absent if the logs were deleted while the request waited.

RunCommandRequest

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.

RunCommandResponse

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.

UploadFileRequest

The request to upload a file to the sandbox filesystem.
path
​string · required

Path where to upload the file.

Example: /tmp/demo
filename
​string · required

Name of uploaded file; will be used if path is a directory.

Example: file.txt
parents
​boolean · required

Whether to create parent directories of path.

encoding
​string · enum · required

The encoding of data.

Enum values:
utf-8
base64
data
​string · required

The data to write, in the given encoding

Example: hello

WriteFileRequest

The request to write a file in the sandbox filesystem.
path
​string · required

The absolute path of the file to write. It is created if missing.

Example: /tmp/demo/file.txt
append
​boolean · required

Whether to append to the file instead of truncating it.

encoding
​string · enum · required

The encoding of data.

Enum values:
utf-8
base64
data
​string · required

The data to write, in the given encoding.

Example: hello