generated

package
v2.3.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 2, 2026 License: Apache-2.0 Imports: 24 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package generated is the SDK core made from the API's spec: every product's client over one transport.

Index

Constants

View Source
const APIVersion = "2026-10-27"

APIVersion is the API version this client is written for, sent as Runtime-Version.

View Source
const GitHubAudience = "withruntime.com"

GitHubAudience is the audience a GitHub Actions job asks its OpenID Connect token for, to assume a key.

Variables

View Source
var (
	// ErrInvalidRequest is `invalid_request` (400): Fix the field named in param and send the request again.
	ErrInvalidRequest = &Error{Code: "invalid_request", Status: 400}
	// ErrUnauthorized is `unauthorized` (401): Send Authorization: Bearer <key>; create a key at https://withruntime.com/account/keys.
	ErrUnauthorized = &Error{Code: "unauthorized", Status: 401}
	// ErrPaymentRequired is `payment_required` (402): Add a card in the console; the work paused for payment resumes. Nothing was deleted.
	ErrPaymentRequired = &Error{Code: "payment_required", Status: 402}
	// ErrCardRequired is `card_required` (402): Add a card at https://withruntime.com/account/start to start the trial, then send the request again.
	ErrCardRequired = &Error{Code: "card_required", Status: 402}
	// ErrForbidden is `forbidden` (403): Use a key whose grants include this action, or ask an owner of the organization.
	ErrForbidden = &Error{Code: "forbidden", Status: 403}
	// ErrLimitExceeded is `limit_exceeded` (403): Stay within the limit details names: delete what you no longer need, ask for less, or raise the limit.
	ErrLimitExceeded = &Error{Code: "limit_exceeded", Status: 403}
	// ErrNotFound is `not_found` (404): Check the ID or path; list the resources to find it.
	ErrNotFound = &Error{Code: "not_found", Status: 404}
	// ErrMethodNotAllowed is `method_not_allowed` (405): Send it with a method the Allow header names.
	ErrMethodNotAllowed = &Error{Code: "method_not_allowed", Status: 405}
	// ErrAlreadyExists is `already_exists` (409): Use another name, or get the one that exists.
	ErrAlreadyExists = &Error{Code: "already_exists", Status: 409}
	// ErrConflict is `conflict` (409): Get it again and send the request once it is in a state the call takes.
	ErrConflict = &Error{Code: "conflict", Status: 409}
	// ErrTooLarge is `too_large` (413): Send less; a larger file goes as an upload in parts.
	ErrTooLarge = &Error{Code: "too_large", Status: 413}
	// ErrRateLimited is `rate_limited` (429): Send it again after Retry-After (RateLimit-Reset).
	ErrRateLimited = &Error{Code: "rate_limited", Status: 429}
	// ErrInternal is `internal` (500): Get it to see what was done, or send it again with the same Idempotency-Key; if it fails again, contact support with the requestId.
	ErrInternal = &Error{Code: "internal", Status: 500}
	// ErrNotImplemented is `not_implemented` (501): This call is not served yet.
	ErrNotImplemented = &Error{Code: "not_implemented", Status: 501}
	// ErrUnavailable is `unavailable` (503): Send it again after Retry-After; nothing was done.
	ErrUnavailable = &Error{Code: "unavailable", Status: 503}
	// ErrCapacityUnavailable is `capacity_unavailable` (503): Send it again after Retry-After, or ask for a smaller size.
	ErrCapacityUnavailable = &Error{Code: "capacity_unavailable", Status: 503}
	// ErrTimeout is `timeout` (504): It ran past its time: raise timeoutSeconds, or run it as a process.
	ErrTimeout = &Error{Code: "timeout", Status: 504}
)

Each error family, for errors.Is(err, ErrNotFound).

Functions

func AnswerField

func AnswerField(answer any, field string) any

AnswerField is field of an answer decoded as JSON; nil when it has none.

func CallRoute

func CallRoute(ctx context.Context, t *Transport, r Route, args map[string]any, opts *RequestOptions) (any, error)

CallRoute sends a verb's call from its arguments by name: its path's parts, its query's fields, and the rest its body (data, bytes or base64, for a verb whose body is bytes). A raw answer is []byte.

func Ptr

func Ptr[T any](v T) *T

Ptr is a pointer to v, for optional fields.

func RoutesOf

func RoutesOf(doc map[string]any) map[string]Route

RoutesOf is every route an OpenAPI document of this API names, by product.verb: how a verb newer than this SDK is found in the API's served one.

Types

type ActRequest

type ActRequest struct {
	// Actions The steps, in order; the act stops at the first that fails. At least 1 item. At most 100 items.
	Actions []Action `json:"actions"`
}

ActRequest Steps of the mouse and keyboard, run in order as one command.

type Acted

type Acted struct {
	// Cursor Where the mouse is.
	Cursor Point `json:"cursor"`
	// Screen The screen's size.
	Screen ScreenSize `json:"screen"`
}

Acted The screen once an act's steps ran.

type Action

type Action struct {
	// Type What it does: `move` to `x`,`y`; `click` (at `x`,`y` when given, `count` times, with `keys` held); `mouseDown` and `mouseUp` of `button`; `drag` from `x`,`y` to `toX`,`toY`; `scroll` by `dx`,`dy` wheel clicks (at `x`,`y` when given); `type` `text`; `key` the chords in `keys`; `wait` `ms`.
	Type string `json:"type"`
	// X Pixels from the screen's left edge. At least 0. At most 16384.
	X *int64 `json:"x,omitempty"`
	// Y Pixels from the screen's top edge. At least 0. At most 16384.
	Y *int64 `json:"y,omitempty"`
	// ToX A drag's end, from the left edge. At least 0. At most 16384.
	ToX *int64 `json:"toX,omitempty"`
	// ToY A drag's end, from the top edge. At least 0. At most 16384.
	ToY *int64 `json:"toY,omitempty"`
	// Button The mouse button of a click, a drag, a mouseDown or a mouseUp. Default: "left".
	Button *string `json:"button,omitempty"`
	// Count A click's count: 2 a double click, 3 a triple click. At least 1. At most 3. Default: 1.
	Count *int64 `json:"count,omitempty"`
	// Dx A scroll's wheel clicks to the right (negative to the left). At least -100. At most 100.
	Dx *int64 `json:"dx,omitempty"`
	// Dy A scroll's wheel clicks down (negative up). At least -100. At most 100.
	Dy *int64 `json:"dy,omitempty"`
	// Text The text a `type` types, as it is: any Unicode, newlines and tabs. At most 8192 characters.
	Text *string `json:"text,omitempty"`
	// Keys For `key`, chords pressed in turn, space-separated, each keys joined by `+` in X keysym names (`ctrl+l`, `Return`, `ctrl+shift+t`); for `click` and `scroll`, the modifiers held during it (`shift`, `ctrl+alt`). At most 1000 characters.
	Keys *string `json:"keys,omitempty"`
	// Ms A wait's milliseconds. At least 0. At most 10000.
	Ms *int64 `json:"ms,omitempty"`
}

Action One step of an act: a mouse move, click, drag or scroll, typed text, a key chord, or a wait.

type Agent

type Agent struct {

	// Info is what it was when last read.
	Info *AgentInfo
	// contains filtered or unexported fields
}

Agent is one of agents: A stored, versioned definition of an agent: its harness (Claude Code, Codex or an image of your own), model, model accounts, instructions, tools and machine. Each start makes a session, a machine of its own that runs the harness, billed as any machine is; model use is billed by the account's provider. An update makes a new version; a session keeps the version it started on.

func (*Agent) Delete

func (s *Agent) Delete(ctx context.Context, opts *RequestOptions) (*AgentInfo, error)

Delete Deletes an agent: no session is started from it from then on. Its open sessions run on until they are deleted.

func (*Agent) ID

func (s *Agent) ID() string

ID is its id.

func (*Agent) Refresh

func (s *Agent) Refresh(ctx context.Context, q *AgentGetQuery, opts *RequestOptions) error

Refresh Returns an agent at its current version.

func (*Agent) Start

func (s *Agent) Start(ctx context.Context, in *AgentStart, opts *RequestOptions) (*SandboxInfo, error)

Start Starts a session: a machine that runs the agent's harness on its model account with the most room left, sent `message` as its first. With the `key` of an open session, sends `message` to that session and returns it. Refused 429 at the agent's maxConcurrent. Asked again with the same Idempotency-Key, it starts nothing more.

func (*Agent) Update

func (s *Agent) Update(ctx context.Context, in *AgentSettings, opts *RequestOptions) error

Update Changes an agent's settings and makes its next version: each setting named replaces its own, the rest are kept. Sessions started from then on use it; an open session keeps its version.

type AgentCreate

type AgentCreate struct {
	AgentSettings
	// Name Its name, unique in its project.
	Name string `json:"name"`
	// Labels Labels to find it by; each session carries them.
	Labels map[string]string `json:"labels,omitempty"`
}

AgentCreate An agent to create.

type AgentGetQuery

type AgentGetQuery struct {
	// Wait Seconds to wait, at most 60, for its state to differ from `ifState`; it answers once it does, or as it is when the wait ends. At least 0. At most 60.
	Wait *float64
	// IfState The state the caller last read, which `wait` waits for it to leave.
	IfState *string
}

AgentGetQuery is what Get takes in its query.

type AgentInfo

type AgentInfo struct {
	AgentSettings
	// ID Its ID.
	ID string `json:"id"`
	// Object Always `agent`.
	Object string `json:"object"`
	// Name Its name, unique in its project.
	Name string `json:"name"`
	// Version Its version, from 1: each update makes the next. A session keeps the version it was started on.
	Version int64 `json:"version"`
	// State `active`, or `deleted` in a delete's answer.
	State string `json:"state"`
	// Labels Its labels.
	Labels map[string]string `json:"labels"`
	// CreatedAt When it was created.
	CreatedAt *string `json:"createdAt,omitempty"`
	// UpdatedAt When its current version was made.
	UpdatedAt *string `json:"updatedAt,omitempty"`
	// DeletedAt When it was deleted: a delete's answer, its state `deleted`.
	DeletedAt *string `json:"deletedAt,omitempty"`
}

AgentInfo An agent: a stored, versioned definition its sessions are made from.

type AgentListQuery

type AgentListQuery struct {
	// Label Only those with every label given (repeat it for several): key:value, or a key for any value.
	Label []string
	// Cursor Where the page starts: a page's `next`.
	Cursor *string
	// Limit The most items the page holds. At least 1. At most 200. Default: 50.
	Limit *int64
}

AgentListQuery is what List takes in its query.

type AgentSessionDownloadFolderQuery

type AgentSessionDownloadFolderQuery struct {
	// Path The folder, absolute, such as `/workspace/app`.
	Path string
	// Gzip Compress the archive with gzip. Default: false.
	Gzip *bool
	// User Who packs it: `runtime` or `root`; the agent.session's `user` when omitted.
	User *string
	// Exclude Paths in the folder to leave out, relative to it and comma-separated (`node_modules,.cache`): plain names, no wildcards, at most 32.
	Exclude *string
}

AgentSessionDownloadFolderQuery is what DownloadFolder takes in its query.

type AgentSessionGetQuery

type AgentSessionGetQuery struct {
	// Wait Seconds to wait, at most 60, for its state to differ from `ifState`; it answers once it does, or as it is when the wait ends. At least 0. At most 60.
	Wait *float64
	// IfState The state the caller last read, which `wait` waits for it to leave.
	IfState *string
}

AgentSessionGetQuery is what Get takes in its query.

type AgentSessionListFilesQuery

type AgentSessionListFilesQuery struct {
	// Path The directory. Default: "/workspace".
	Path *string
	// Depth How deep to list. At least 1. At most 10. Default: 1.
	Depth *int64
	// Limit At most this many entries. At least 1. At most 2000. Default: 2000.
	Limit *int64
	// Hidden List entries whose names start with a dot. Default: true.
	Hidden *bool
	// Glob Only entries whose path relative to the directory matches: `*` within a name, `**` across folders, `?` one character, `{a,b}` either (`**/*.py`); at most 512 characters, 32 wildcards and 64 texts in braces. The listing then reaches as deep as the glob does (10 folders for `**`) unless depth says, and is searched past its first 2,000 entries, up to 50,000. At most 512 characters.
	Glob *string
}

AgentSessionListFilesQuery is what ListFiles takes in its query.

type AgentSessionListQuery

type AgentSessionListQuery struct {
	// State Only those in these states, comma-separated.
	State *string
	// Name Only the agent.session of this name.
	Name *string
	// Label Only those with every label given (repeat it for several): key:value, or a key for any value.
	Label []string
	// Cursor Where the page starts: a page's `next`.
	Cursor *string
	// Limit The most items the page holds. At least 1. At most 200. Default: 50.
	Limit *int64
}

AgentSessionListQuery is what List takes in its query.

type AgentSessionMetricsQuery

type AgentSessionMetricsQuery struct {
	// Range The window: `15m`, `1h`, `6h`, `24h`, `7d` or `30d`. Default: "1h".
	Range *string
}

AgentSessionMetricsQuery is what Metrics takes in its query.

type AgentSessionProcessOutputQuery

type AgentSessionProcessOutputQuery struct {
	// Cursor Output after this byte. At least 0. Default: 0.
	Cursor *int64
	// WaitSeconds Seconds to wait for output past the cursor or its exit, at most 8. At least 0. At most 8.
	WaitSeconds *float64
	// MaxBytes At most this many bytes. At least 4096. At most 196608. Default: 65536.
	MaxBytes *int64
	// Follow Answer as NDJSON events from the cursor until it exits (stdout, stderr, truncated, exit; continue with the cursor to follow on from), as `Accept: application/x-ndjson` does.
	Follow *bool
}

AgentSessionProcessOutputQuery is what ProcessOutput takes in its query.

type AgentSessionReadQuery

type AgentSessionReadQuery struct {
	// Path The file's path in the machine.
	Path string
}

AgentSessionReadQuery is what Read takes in its query.

type AgentSessionScreenshotQuery

type AgentSessionScreenshotQuery struct {
	// Format `png`, or `jpeg`: smaller and quicker to send, for a model that reads it. Default: "png".
	Format *string
	// Quality A jpeg's quality, 1 to 100. At least 1. At most 100. Default: 80.
	Quality *int64
}

AgentSessionScreenshotQuery is what Screenshot takes in its query.

type AgentSessionStatQuery

type AgentSessionStatQuery struct {
	// Path The file's path in the machine.
	Path string
	// Sha256 Also return a file's SHA-256, read from its bytes: to check a file you put in place (files:rename with sha256) is whole. Default: false.
	Sha256 *bool
}

AgentSessionStatQuery is what Stat takes in its query.

type AgentSessionUploadFolderQuery

type AgentSessionUploadFolderQuery struct {
	// Path The folder, absolute, such as `/workspace/app`: made with its parents.
	Path string
	// User Who unpacks it: `runtime` or `root`; the agent.session's `user` when omitted.
	User *string
}

AgentSessionUploadFolderQuery is what UploadFolder takes in its query.

type AgentSessionWriteFolderUploadQuery

type AgentSessionWriteFolderUploadQuery struct {
	// Offset Where the part starts in the archive: at most the bytes received so far. Bytes before them were taken already and are skipped, so a part sent again is never unpacked twice. At least 0. Default: 0.
	Offset *int64
}

AgentSessionWriteFolderUploadQuery is what WriteFolderUpload takes in its query.

type AgentSessionWriteQuery

type AgentSessionWriteQuery struct {
	// Path The file's path in the machine.
	Path string
	// Mode Its mode, in octal (`644`).
	Mode *string
	// Offset Write the bytes into the file in place from this byte, keeping the bytes before and after them (the file is made when there is none); one that fails part way may leave its range written in part, so send it again. Parts of one file may be written so at once and in any order: write them to a new path, then rename it with its size and sha256 to put it in place whole. At least 0.
	Offset *int64
	// Sha256 The bytes' SHA-256 in hex: refused 409 `checksum_mismatch`, the file as it was, when they differ. Not with offset.
	Sha256 *string
}

AgentSessionWriteQuery is what Write takes in its query.

type AgentSessions

type AgentSessions struct {
	// contains filtered or unexported fields
}

AgentSessions A machine that runs an agent's harness: made by an agent's start, with the agent's machine, secrets and model accounts. Every machine call works on it: run a command, read its files, open its desktop, fork it to try again from where it is. Its conversation is its messages. It pauses when idle, its memory and disk kept, and a message sent to it wakes it.

func (*AgentSessions) AbortFolderUpload

func (c *AgentSessions) AbortFolderUpload(ctx context.Context, id string, upload string, opts *RequestOptions) (*FolderUploadAborted, error)

AbortFolderUpload Stops a folder upload's tar; what it unpacked so far stays.

func (*AgentSessions) Act

func (c *AgentSessions) Act(ctx context.Context, id string, in ActRequest, opts *RequestOptions) (*Acted, error)

Act Moves, clicks, drags and scrolls the mouse and types on the keyboard of an agent session's screen (its X display `:1`), each step in turn as one command, and returns where the mouse is then. It stops at the first step that fails, refused 409 `act_failed` naming it; refused 409 `display_not_running` when no display runs. A paused agent.session is resumed first.

func (*AgentSessions) BeginFolderUpload

func (c *AgentSessions) BeginFolderUpload(ctx context.Context, id string, in FolderUploadBegin, opts *RequestOptions) (*FolderUpload, error)

BeginFolderUpload Begins a folder's upload in parts: tar starts in the agent.session, unpacking into the folder each part as it arrives. Send the parts in order by offset (writeFolderUpload), then commitFolderUpload; an upload no call names for 10 minutes is ended. A paused agent.session is woken first.

func (*AgentSessions) CommitFolderUpload

func (c *AgentSessions) CommitFolderUpload(ctx context.Context, id string, upload string, opts *RequestOptions) (*FolderUnpacked, error)

CommitFolderUpload Ends a folder upload's input and returns once tar has ended, as an exec returns once its command has: the folder, or 400 `invalid_archive` with what tar said. Sent again, it returns how tar ended. An upload no call has named for 10 minutes since its last part or commit is ended.

func (*AgentSessions) Create

Create Creates an agent session. Asked again with the same Idempotency-Key, it returns the same agent.session.

func (*AgentSessions) Delete

func (c *AgentSessions) Delete(ctx context.Context, id string, opts *RequestOptions) (*SandboxInfo, error)

Delete Deletes an agent session, its memory and its disk.

func (*AgentSessions) DownloadFolder

func (c *AgentSessions) DownloadFolder(ctx context.Context, id string, q AgentSessionDownloadFolderQuery, opts *RequestOptions) ([]byte, error)

DownloadFolder Returns a folder as a tar archive (`application/x-tar`, or `application/gzip` with gzip), packed by tar in the agent.session as it streams, of any size; its entries are relative to the folder (`./a.txt`). A folder that fails part way (a file it may not read, or one that changes as it is read) ends as an archive every tar reader refuses, never as a short one that reads whole. At most 4 at once in an agent session. A paused agent.session is woken first.

func (*AgentSessions) Exec

func (c *AgentSessions) Exec(ctx context.Context, id string, in ExecRequest, opts *RequestOptions) (*Process, error)

Exec Runs a command as a process and returns it once it ended, with its output; with wait false, at once, while it runs. A paused agent.session is resumed first. Asked again with the same Idempotency-Key, it runs nothing more: it returns the first run's process, waiting for its end while it runs.

func (*AgentSessions) Fork

func (c *AgentSessions) Fork(ctx context.Context, id string, in ForkRequest, opts *RequestOptions) (*Forked, error)

Fork Copies an agent session as it is now, memory and disk, into `count` copies of its own, each running on its host. Asked again with the same Idempotency-Key, it returns the same copies.

func (*AgentSessions) Get

Get Returns an agent session.

func (*AgentSessions) GetNetwork

func (c *AgentSessions) GetNetwork(ctx context.Context, id string, opts *RequestOptions) (*SandboxNetwork, error)

GetNetwork Returns where an agent session may connect out.

Link Makes an expiring address for one file that anyone may open with no API key, from a browser, curl or another service: GET downloads it (Range works, so videos play and downloads resume; archive: true downloads a folder as .tar.gz), PUT with the raw body uploads it (up to maxBytes, written whole; Content-Length required). The link acts as the key that made it: an upload link needs write, and the link ends with its key, with revokeLinks or with its agent.session. A paused agent.session is woken for it unless wake is false. A port it serves is shared by a preview (previews.create), not a link.

func (*AgentSessions) List

List Lists the project's agent-sessions, newest first.

func (*AgentSessions) ListAll

ListAll is every item of every page List reads from q.Cursor (none: the first page), each page read as the last is used up.

func (*AgentSessions) ListFiles

ListFiles Lists a directory's entries in path order, to a depth.

func (*AgentSessions) ListProcesses

func (c *AgentSessions) ListProcesses(ctx context.Context, id string, opts *RequestOptions) (*ProcessList, error)

ListProcesses Lists an agent session's processes, newest first: those running and those that ended lately.

func (*AgentSessions) Metrics

Metrics Returns an agent session's CPU, memory, disks and pressure, as its host reads them from the agent.session's own cgroup over a fifth of a second: never a call into the agent.session, so it does not wake a paused one nor keep one from its idle pause. One that is not running has no reading.

func (*AgentSessions) Mkdir

func (c *AgentSessions) Mkdir(ctx context.Context, id string, in FileMkdir, opts *RequestOptions) (*FileMade, error)

Mkdir Makes a directory, and its parents unless parents is false. One there already is success, created false.

func (*AgentSessions) Pause

func (c *AgentSessions) Pause(ctx context.Context, id string, opts *RequestOptions) (*SandboxInfo, error)

Pause Pauses an agent session with its memory and disk kept. A call to it resumes it.

func (*AgentSessions) ProcessOutput

ProcessOutput Returns a process's output after a cursor, and the cursor to read on from. The latest 1 MiB is kept; truncated says when the cursor fell behind.

func (*AgentSessions) Read

Read Returns a file's bytes.

func (*AgentSessions) Remove

func (c *AgentSessions) Remove(ctx context.Context, id string, in FileRemove, opts *RequestOptions) (*FileRemoved, error)

Remove Removes a file, a link or a directory (recursive for one with contents). One missing is success, removed false.

func (*AgentSessions) Rename

func (c *AgentSessions) Rename(ctx context.Context, id string, in FileRename, opts *RequestOptions) (*FileRenamed, error)

Rename Moves a file, a link or a directory; refused 409 when something is at its new path, unless overwrite. With sha256 or size, a file written in parts is put in place once whole: its writes ended, then only a file of that size with every byte written and whose bytes hash to it moves; refused 409 `upload_incomplete` or `checksum_mismatch`, nothing moved. With sha256, it is safe to send again: once moved, it returns the same answer while `from` is gone and `to` holds those bytes.

func (*AgentSessions) ResizeProcess

func (c *AgentSessions) ResizeProcess(ctx context.Context, id string, process string, in Terminal, opts *RequestOptions) (*Process, error)

ResizeProcess Resizes the terminal of a process started with a pty (its window's columns and rows, which the process is told by SIGWINCH), and returns the process; refused 409 for a process without one. A process that ended is left as it is, so a retry is safe.

func (*AgentSessions) Resume

func (c *AgentSessions) Resume(ctx context.Context, id string, opts *RequestOptions) (*SandboxInfo, error)

Resume Resumes a paused agent.session where it was, its memory and processes as they were.

func (c *AgentSessions) RevokeLinks(ctx context.Context, id string, opts *RequestOptions) (*FileLinksRevoked, error)

RevokeLinks Ends every file link made for an agent session so far; links made after work.

func (*AgentSessions) RunCode

func (c *AgentSessions) RunCode(ctx context.Context, id string, in RunCode, opts *RequestOptions) (*CodeRun, error)

RunCode Runs a cell of Python in an agent session as a notebook does, in a Jupyter kernel it keeps running for the cell's `context`: variables, imports and functions stay for the next cell. Returns what it printed, its values and displays (text, HTML, images such as charts), and its exception with its traceback. The context's kernel starts on its first cell. A cell past `timeoutSeconds` is interrupted and its context kept. Refused 409 `kernel_not_installed` when the image has no ipykernel. A paused agent.session is resumed first.

func (*AgentSessions) Screenshot

Screenshot Returns what an agent session's screen shows now, as `image/png` (or `image/jpeg`): its X display `:1`, whole. Refused 409 `display_not_running` when no display runs. A paused agent.session is resumed first.

func (*AgentSessions) SetNetwork

func (c *AgentSessions) SetNetwork(ctx context.Context, id string, in NetworkRules, opts *RequestOptions) (*SandboxNetwork, error)

SetNetwork Replaces where an agent session may connect out, for its next connection and within a second for its open ones: those the new rules refuse are cut.

func (*AgentSessions) SignalProcess

func (c *AgentSessions) SignalProcess(ctx context.Context, id string, process string, in ProcessSignal, opts *RequestOptions) (*Process, error)

SignalProcess Sends a signal to a process and its group; a process that ended is not signalled, so a retry is safe.

func (*AgentSessions) Snapshot

func (c *AgentSessions) Snapshot(ctx context.Context, id string, in SnapshotRequest, opts *RequestOptions) (*Stored, error)

Snapshot Keeps an agent session's memory and disk as they are now, a snapshot to start agent-sessions from; with `image`, its disk alone as that image's next version. The agent.session runs on. Asked again with the same Idempotency-Key, it returns the same snapshot.

func (*AgentSessions) Stat

Stat Returns what is at a path: a file, a directory or a link, or nothing (exists false). With sha256=true, a file's SHA-256 too.

func (*AgentSessions) Update

Update Changes its name, labels, idle pause, maxCost, autoWake, lifetime, delete protection, environment or sizes; each field left out stays as it is. A lifetime (`deleteAfterSeconds`) sent again before its end moves the end to that many seconds from now; 0 takes it off. A lifetime is refused (409 `delete_protected`) while `deleteProtection` is true. A running one holds a changed environment before this answers (a paused one's at its wake): each process it starts after the answer has it, and its running processes keep the one they started with. Its vCPUs, memory and disk grow while it runs, its commands running on. One paused or stopped is not woken for it: judged at once as a live resize is (past the vCPUs it was made with 409, over its organization's limits `quota_exceeded`), its new sizes are returned at once, and its next wake grows it to them before the call that woke it runs. A smaller size, or a machine starting or failed, is refused 409 naming why, and nothing is changed. With If-Match, made only while its revision is that one, else 412. Sent again with the same Idempotency-Key and body while it is the latest change, it returns the current state and changes nothing; the same key with a different body returns 409 idempotency_key_reused.

func (*AgentSessions) UploadFolder

UploadFolder Unpacks the request's tar archive (gzip-compressed or not, told by its first bytes) into a folder, made with its parents, by tar in the agent.session as the bytes arrive, of any size, nothing of it kept on disk but what tar writes; returns once tar has ended, or 400 `invalid_archive` with what tar said. A paused agent.session is woken first.

func (*AgentSessions) Write

Write Writes the request's bytes to a file as they come, of any size (Content-Length required), its folders made: the file whole when they all came, or as it was. With offset, they are written into it in place.

func (*AgentSessions) WriteFolderUpload

func (c *AgentSessions) WriteFolderUpload(ctx context.Context, id string, upload string, data []byte, q AgentSessionWriteFolderUploadQuery, opts *RequestOptions) (*FolderUploadReceived, error)

WriteFolderUpload Sends the request's bytes, a part of the archive at its offset, into tar's input as they arrive, of any size, and returns the bytes received in all once tar took them. A part past them is refused 409 `upload_incomplete`, naming them: send the parts in order.

func (*AgentSessions) WriteProcess

func (c *AgentSessions) WriteProcess(ctx context.Context, id string, process string, in ProcessInput, opts *RequestOptions) (*ProcessWritten, error)

WriteProcess Sends input to a process started with stdinOpen or a pty, and returns how much of its input it has taken.

type AgentSettings

type AgentSettings struct {
	// Harness The harness each session runs: `claude-code`, `codex`, or `custom` (the `start` of `image`); `claude-code` when omitted. Default: "claude-code".
	Harness *string `json:"harness,omitempty"`
	// Image The image each session boots, by name (its newest version), `name:version` or ID; the harness's image when omitted. Required for `custom`.
	Image *string `json:"image,omitempty"`
	// Model The model, as its provider names it (`claude-opus-5-5`); the harness's default when omitted.
	Model *string `json:"model,omitempty"`
	// Accounts The model accounts each session may use, by secret name, 1 to 16: an API key or a subscription's token. A session takes the one with the most room left and moves to the next when a provider refuses it for its limit. At least 1 item. At most 16 items.
	Accounts []string `json:"accounts,omitempty"`
	// Instructions The instructions each session starts with: its system prompt.
	Instructions *string `json:"instructions,omitempty"`
	// Tools Each tool's policy, by name; a tool none names is allowed. At most 128 items.
	Tools []AgentTool `json:"tools,omitempty"`
	// McpServers The MCP servers each session connects to. At most 32 items.
	McpServers []McpServer `json:"mcpServers,omitempty"`
	// Secrets The other secrets each session may get, by name, at most 64: only those of them whose scope admits it; [] none. At most 64 items.
	Secrets []string `json:"secrets,omitempty"`
	// Vcpu Each session's vCPUs. At least 2. Default: 2.
	Vcpu *int64 `json:"vcpu,omitempty"`
	// MemoryGb Each session's memory in GB (1 GB is 1,024 MiB); a fraction is taken to the MiB (`1.5`). At least 1. Default: 4.
	MemoryGb *float64 `json:"memoryGB,omitempty"`
	// DiskGb Each session's disk in GB, to the MiB. At least 1. Default: 20.
	DiskGb *float64 `json:"diskGB,omitempty"`
	// Network Where each session may connect out; the open internet behind every machine's walls when omitted.
	Network *NetworkRules `json:"network,omitempty"`
	// IdlePauseSeconds Seconds with nothing happening before a session pauses, 60 to 86400; 0 never; 300 when omitted. A paused session costs no CPU and wakes when a message is sent to it. At least 0. At most 86400. Default: 300.
	IdlePauseSeconds *int64 `json:"idlePauseSeconds,omitempty"`
	// MaxCost The most one session may cost in machine time, in US dollars (`"1.00"`): a session pauses once it has cost that. Model use is billed by the account's provider.
	MaxCost *string `json:"maxCost,omitempty"`
	// MaxConcurrent The most sessions open at once; a start past it is refused 429. At least 1. At most 10000.
	MaxConcurrent *int64 `json:"maxConcurrent,omitempty"`
}

AgentSettings An agent's settings: what each of its sessions is made with.

type AgentStart

type AgentStart struct {
	// Message The first message: what the session is asked.
	Message *string `json:"message,omitempty"`
	// Key A key the caller names the conversation by (`ticket-4812`): a start with the key of a session that is open sends its message to that session instead of making one. At least 1 character. At most 256 characters.
	Key *string `json:"key,omitempty"`
	// Version The agent's version to start on; its current one when omitted. At least 1.
	Version *int64 `json:"version,omitempty"`
	// Name The session's name, unique in its project.
	Name *string `json:"name,omitempty"`
	// Labels Labels to find the session by, beside the agent's.
	Labels map[string]string `json:"labels,omitempty"`
	// Volumes Volumes the session attaches and mounts, at most one: a volume is one machine's at a time, so it is each session's own, never its agent's. Its work kept there outlives the session, for the next to attach.
	Volumes []VolumeMount `json:"volumes,omitempty"`
}

AgentStart A session to start from an agent.

type AgentTool

type AgentTool struct {
	// Name The tool's name, as its harness names it (`Bash`, `WebFetch`), or `mcp:<server>` for every tool of one of its MCP servers.
	Name string `json:"name"`
	// Policy `allow` (it runs), `ask` (it waits for an answer to its ask), or `deny` (it never runs); `allow` when omitted. Default: "allow".
	Policy *string `json:"policy,omitempty"`
}

AgentTool A tool's policy in an agent's sessions.

type Agents

type Agents struct {
	// contains filtered or unexported fields
}

Agents A stored, versioned definition of an agent: its harness (Claude Code, Codex or an image of your own), model, model accounts, instructions, tools and machine. Each start makes a session, a machine of its own that runs the harness, billed as any machine is; model use is billed by the account's provider. An update makes a new version; a session keeps the version it started on.

func (*Agents) Create

func (c *Agents) Create(ctx context.Context, in AgentCreate, opts *RequestOptions) (*Agent, error)

Create Creates an agent at version 1. Asked again with the same Idempotency-Key, it returns the same agent.

func (*Agents) Delete

func (c *Agents) Delete(ctx context.Context, id string, opts *RequestOptions) (*AgentInfo, error)

Delete Deletes an agent: no session is started from it from then on. Its open sessions run on until they are deleted.

func (*Agents) Get

func (c *Agents) Get(ctx context.Context, id string, q AgentGetQuery, opts *RequestOptions) (*Agent, error)

Get Returns an agent at its current version.

func (*Agents) List

func (c *Agents) List(ctx context.Context, q AgentListQuery, opts *RequestOptions) (*Page[AgentInfo], error)

List Lists the project's agents, newest first.

func (*Agents) ListAll

ListAll is every item of every page List reads from q.Cursor (none: the first page), each page read as the last is used up.

func (*Agents) Start

func (c *Agents) Start(ctx context.Context, id string, in AgentStart, opts *RequestOptions) (*SandboxInfo, error)

Start Starts a session: a machine that runs the agent's harness on its model account with the most room left, sent `message` as its first. With the `key` of an open session, sends `message` to that session and returns it. Refused 429 at the agent's maxConcurrent. Asked again with the same Idempotency-Key, it starts nothing more.

func (*Agents) Update

func (c *Agents) Update(ctx context.Context, id string, in AgentSettings, opts *RequestOptions) (*AgentInfo, error)

Update Changes an agent's settings and makes its next version: each setting named replaces its own, the rest are kept. Sessions started from then on use it; an open session keeps its version.

type App

type App struct {

	// Info is what it was when last read.
	Info      *SandboxInfo
	Files     *AppFiles
	Processes *AppProcesses
	Network   *AppNetwork
	// contains filtered or unexported fields
}

App is one of apps: A machine that keeps a web app in /app running on port 8080 (its Procfile's `web:`, else `npm start`, else `python3 app.py`, as Render and Heroku start one), reached at its preview. It never pauses for being idle.

func (*App) Act

func (s *App) Act(ctx context.Context, actions []Action, in *ActRequest, opts *RequestOptions) (*Acted, error)

Act Moves, clicks, drags and scrolls the mouse and types on the keyboard of an app's screen (its X display `:1`), each step in turn as one command, and returns where the mouse is then. It stops at the first step that fails, refused 409 `act_failed` naming it; refused 409 `display_not_running` when no display runs. A paused app is resumed first.

func (*App) Delete

func (s *App) Delete(ctx context.Context, opts *RequestOptions) (*SandboxInfo, error)

Delete Deletes an app, its memory and its disk.

func (*App) Exec

func (s *App) Exec(ctx context.Context, cmd string, in *ExecRequest, opts *RequestOptions) (*Process, error)

Exec Runs a command as a process and returns it once it ended, with its output; with wait false, at once, while it runs. A paused app is resumed first. Asked again with the same Idempotency-Key, it runs nothing more: it returns the first run's process, waiting for its end while it runs.

func (*App) Fork

func (s *App) Fork(ctx context.Context, in *ForkRequest, opts *RequestOptions) (*Forked, error)

Fork Copies an app as it is now, memory and disk, into `count` copies of its own, each running on its host. Asked again with the same Idempotency-Key, it returns the same copies.

func (*App) ID

func (s *App) ID() string

ID is its id.

func (*App) Metrics

func (s *App) Metrics(ctx context.Context, q *AppMetricsQuery, opts *RequestOptions) (*SandboxMetrics, error)

Metrics Returns an app's CPU, memory, disks and pressure, as its host reads them from the app's own cgroup over a fifth of a second: never a call into the app, so it does not wake a paused one nor keep one from its idle pause. One that is not running has no reading.

func (*App) Pause

func (s *App) Pause(ctx context.Context, opts *RequestOptions) error

Pause Pauses an app with its memory and disk kept. A call to it resumes it.

func (*App) Refresh

func (s *App) Refresh(ctx context.Context, q *AppGetQuery, opts *RequestOptions) error

Refresh Returns an app.

func (*App) Resume

func (s *App) Resume(ctx context.Context, opts *RequestOptions) error

Resume Resumes a paused app where it was, its memory and processes as they were.

func (*App) RunCode

func (s *App) RunCode(ctx context.Context, code string, in *RunCode, opts *RequestOptions) (*CodeRun, error)

RunCode Runs a cell of Python in an app as a notebook does, in a Jupyter kernel it keeps running for the cell's `context`: variables, imports and functions stay for the next cell. Returns what it printed, its values and displays (text, HTML, images such as charts), and its exception with its traceback. The context's kernel starts on its first cell. A cell past `timeoutSeconds` is interrupted and its context kept. Refused 409 `kernel_not_installed` when the image has no ipykernel. A paused app is resumed first.

func (*App) Screenshot

func (s *App) Screenshot(ctx context.Context, q *AppScreenshotQuery, opts *RequestOptions) ([]byte, error)

Screenshot Returns what an app's screen shows now, as `image/png` (or `image/jpeg`): its X display `:1`, whole. Refused 409 `display_not_running` when no display runs. A paused app is resumed first.

func (*App) Snapshot

func (s *App) Snapshot(ctx context.Context, in *SnapshotRequest, opts *RequestOptions) (*Stored, error)

Snapshot Keeps an app's memory and disk as they are now, a snapshot to start apps from; with `image`, its disk alone as that image's next version. The app runs on. Asked again with the same Idempotency-Key, it returns the same snapshot.

func (*App) Update

func (s *App) Update(ctx context.Context, in *MachineUpdate, opts *RequestOptions) error

Update Changes its name, labels, idle pause, maxCost, autoWake, lifetime, delete protection, environment or sizes; each field left out stays as it is. A lifetime (`deleteAfterSeconds`) sent again before its end moves the end to that many seconds from now; 0 takes it off. A lifetime is refused (409 `delete_protected`) while `deleteProtection` is true. A running one holds a changed environment before this answers (a paused one's at its wake): each process it starts after the answer has it, and its running processes keep the one they started with. Its vCPUs, memory and disk grow while it runs, its commands running on. One paused or stopped is not woken for it: judged at once as a live resize is (past the vCPUs it was made with 409, over its organization's limits `quota_exceeded`), its new sizes are returned at once, and its next wake grows it to them before the call that woke it runs. A smaller size, or a machine starting or failed, is refused 409 naming why, and nothing is changed. With If-Match, made only while its revision is that one, else 412. Sent again with the same Idempotency-Key and body while it is the latest change, it returns the current state and changes nothing; the same key with a different body returns 409 idempotency_key_reused.

type AppDownloadFolderQuery

type AppDownloadFolderQuery struct {
	// Path The folder, absolute, such as `/workspace/app`.
	Path string
	// Gzip Compress the archive with gzip. Default: false.
	Gzip *bool
	// User Who packs it: `runtime` or `root`; the app's `user` when omitted.
	User *string
	// Exclude Paths in the folder to leave out, relative to it and comma-separated (`node_modules,.cache`): plain names, no wildcards, at most 32.
	Exclude *string
}

AppDownloadFolderQuery is what DownloadFolder takes in its query.

type AppFiles

type AppFiles struct {
	// contains filtered or unexported fields
}

AppFiles is a app's files.

func (*AppFiles) AbortFolderUpload

func (g *AppFiles) AbortFolderUpload(ctx context.Context, upload string, opts *RequestOptions) (*FolderUploadAborted, error)

AbortFolderUpload Stops a folder upload's tar; what it unpacked so far stays.

func (*AppFiles) BeginFolderUpload

func (g *AppFiles) BeginFolderUpload(ctx context.Context, path string, in *FolderUploadBegin, opts *RequestOptions) (*FolderUpload, error)

BeginFolderUpload Begins a folder's upload in parts: tar starts in the app, unpacking into the folder each part as it arrives. Send the parts in order by offset (writeFolderUpload), then commitFolderUpload; an upload no call names for 10 minutes is ended. A paused app is woken first.

func (*AppFiles) CommitFolderUpload

func (g *AppFiles) CommitFolderUpload(ctx context.Context, upload string, opts *RequestOptions) (*FolderUnpacked, error)

CommitFolderUpload Ends a folder upload's input and returns once tar has ended, as an exec returns once its command has: the folder, or 400 `invalid_archive` with what tar said. Sent again, it returns how tar ended. An upload no call has named for 10 minutes since its last part or commit is ended.

func (*AppFiles) DownloadFolder

func (g *AppFiles) DownloadFolder(ctx context.Context, path string, q *AppDownloadFolderQuery, opts *RequestOptions) ([]byte, error)

DownloadFolder Returns a folder as a tar archive (`application/x-tar`, or `application/gzip` with gzip), packed by tar in the app as it streams, of any size; its entries are relative to the folder (`./a.txt`). A folder that fails part way (a file it may not read, or one that changes as it is read) ends as an archive every tar reader refuses, never as a short one that reads whole. At most 4 at once in an app. A paused app is woken first.

func (g *AppFiles) Link(ctx context.Context, path string, in *FileLinkCreate, opts *RequestOptions) (*FileLink, error)

Link Makes an expiring address for one file that anyone may open with no API key, from a browser, curl or another service: GET downloads it (Range works, so videos play and downloads resume; archive: true downloads a folder as .tar.gz), PUT with the raw body uploads it (up to maxBytes, written whole; Content-Length required). The link acts as the key that made it: an upload link needs write, and the link ends with its key, with revokeLinks or with its app. A paused app is woken for it unless wake is false. A port it serves is shared by a preview (previews.create), not a link.

func (*AppFiles) List

List Lists a directory's entries in path order, to a depth.

func (*AppFiles) Mkdir

func (g *AppFiles) Mkdir(ctx context.Context, path string, in *FileMkdir, opts *RequestOptions) (*FileMade, error)

Mkdir Makes a directory, and its parents unless parents is false. One there already is success, created false.

func (*AppFiles) Read

func (g *AppFiles) Read(ctx context.Context, path string, q *AppReadQuery, opts *RequestOptions) ([]byte, error)

Read Returns a file's bytes.

func (*AppFiles) Remove

func (g *AppFiles) Remove(ctx context.Context, path string, in *FileRemove, opts *RequestOptions) (*FileRemoved, error)

Remove Removes a file, a link or a directory (recursive for one with contents). One missing is success, removed false.

func (*AppFiles) Rename

func (g *AppFiles) Rename(ctx context.Context, in *FileRename, opts *RequestOptions) (*FileRenamed, error)

Rename Moves a file, a link or a directory; refused 409 when something is at its new path, unless overwrite. With sha256 or size, a file written in parts is put in place once whole: its writes ended, then only a file of that size with every byte written and whose bytes hash to it moves; refused 409 `upload_incomplete` or `checksum_mismatch`, nothing moved. With sha256, it is safe to send again: once moved, it returns the same answer while `from` is gone and `to` holds those bytes.

func (g *AppFiles) RevokeLinks(ctx context.Context, opts *RequestOptions) (*FileLinksRevoked, error)

RevokeLinks Ends every file link made for an app so far; links made after work.

func (*AppFiles) Stat

func (g *AppFiles) Stat(ctx context.Context, path string, q *AppStatQuery, opts *RequestOptions) (*FileInfo, error)

Stat Returns what is at a path: a file, a directory or a link, or nothing (exists false). With sha256=true, a file's SHA-256 too.

func (*AppFiles) UploadFolder

func (g *AppFiles) UploadFolder(ctx context.Context, path string, data []byte, q *AppUploadFolderQuery, opts *RequestOptions) (*FolderUnpacked, error)

UploadFolder Unpacks the request's tar archive (gzip-compressed or not, told by its first bytes) into a folder, made with its parents, by tar in the app as the bytes arrive, of any size, nothing of it kept on disk but what tar writes; returns once tar has ended, or 400 `invalid_archive` with what tar said. A paused app is woken first.

func (*AppFiles) Write

func (g *AppFiles) Write(ctx context.Context, path string, data []byte, q *AppWriteQuery, opts *RequestOptions) (*FileWritten, error)

Write Writes the request's bytes to a file as they come, of any size (Content-Length required), its folders made: the file whole when they all came, or as it was. With offset, they are written into it in place.

func (*AppFiles) WriteFolderUpload

func (g *AppFiles) WriteFolderUpload(ctx context.Context, upload string, data []byte, q *AppWriteFolderUploadQuery, opts *RequestOptions) (*FolderUploadReceived, error)

WriteFolderUpload Sends the request's bytes, a part of the archive at its offset, into tar's input as they arrive, of any size, and returns the bytes received in all once tar took them. A part past them is refused 409 `upload_incomplete`, naming them: send the parts in order.

type AppGetQuery

type AppGetQuery struct {
	// Wait Seconds to wait, at most 60, for its state to differ from `ifState`; it answers once it does, or as it is when the wait ends. At least 0. At most 60.
	Wait *float64
	// IfState The state the caller last read, which `wait` waits for it to leave.
	IfState *string
}

AppGetQuery is what Get takes in its query.

type AppListFilesQuery

type AppListFilesQuery struct {
	// Path The directory. Default: "/workspace".
	Path *string
	// Depth How deep to list. At least 1. At most 10. Default: 1.
	Depth *int64
	// Limit At most this many entries. At least 1. At most 2000. Default: 2000.
	Limit *int64
	// Hidden List entries whose names start with a dot. Default: true.
	Hidden *bool
	// Glob Only entries whose path relative to the directory matches: `*` within a name, `**` across folders, `?` one character, `{a,b}` either (`**/*.py`); at most 512 characters, 32 wildcards and 64 texts in braces. The listing then reaches as deep as the glob does (10 folders for `**`) unless depth says, and is searched past its first 2,000 entries, up to 50,000. At most 512 characters.
	Glob *string
}

AppListFilesQuery is what ListFiles takes in its query.

type AppListQuery

type AppListQuery struct {
	// State Only those in these states, comma-separated.
	State *string
	// Name Only the app of this name.
	Name *string
	// Label Only those with every label given (repeat it for several): key:value, or a key for any value.
	Label []string
	// Cursor Where the page starts: a page's `next`.
	Cursor *string
	// Limit The most items the page holds. At least 1. At most 200. Default: 50.
	Limit *int64
}

AppListQuery is what List takes in its query.

type AppMetricsQuery

type AppMetricsQuery struct {
	// Range The window: `15m`, `1h`, `6h`, `24h`, `7d` or `30d`. Default: "1h".
	Range *string
}

AppMetricsQuery is what Metrics takes in its query.

type AppNetwork

type AppNetwork struct {
	// contains filtered or unexported fields
}

AppNetwork is a app's network.

func (*AppNetwork) Get

Get Returns where an app may connect out.

func (*AppNetwork) Set

Set Replaces where an app may connect out, for its next connection and within a second for its open ones: those the new rules refuse are cut.

type AppProcessOutputQuery

type AppProcessOutputQuery struct {
	// Cursor Output after this byte. At least 0. Default: 0.
	Cursor *int64
	// WaitSeconds Seconds to wait for output past the cursor or its exit, at most 8. At least 0. At most 8.
	WaitSeconds *float64
	// MaxBytes At most this many bytes. At least 4096. At most 196608. Default: 65536.
	MaxBytes *int64
	// Follow Answer as NDJSON events from the cursor until it exits (stdout, stderr, truncated, exit; continue with the cursor to follow on from), as `Accept: application/x-ndjson` does.
	Follow *bool
}

AppProcessOutputQuery is what ProcessOutput takes in its query.

type AppProcesses

type AppProcesses struct {
	// contains filtered or unexported fields
}

AppProcesses is a app's processes.

func (*AppProcesses) List

func (g *AppProcesses) List(ctx context.Context, opts *RequestOptions) (*ProcessList, error)

List Lists an app's processes, newest first: those running and those that ended lately.

func (*AppProcesses) Output

Output Returns a process's output after a cursor, and the cursor to read on from. The latest 1 MiB is kept; truncated says when the cursor fell behind.

func (*AppProcesses) Resize

func (g *AppProcesses) Resize(ctx context.Context, process string, in *Terminal, opts *RequestOptions) (*Process, error)

Resize Resizes the terminal of a process started with a pty (its window's columns and rows, which the process is told by SIGWINCH), and returns the process; refused 409 for a process without one. A process that ended is left as it is, so a retry is safe.

func (*AppProcesses) Signal

func (g *AppProcesses) Signal(ctx context.Context, process string, in *ProcessSignal, opts *RequestOptions) (*Process, error)

Signal Sends a signal to a process and its group; a process that ended is not signalled, so a retry is safe.

func (*AppProcesses) Write

func (g *AppProcesses) Write(ctx context.Context, process string, in *ProcessInput, opts *RequestOptions) (*ProcessWritten, error)

Write Sends input to a process started with stdinOpen or a pty, and returns how much of its input it has taken.

type AppReadQuery

type AppReadQuery struct {
	// Path The file's path in the machine.
	Path string
}

AppReadQuery is what Read takes in its query.

type AppScreenshotQuery

type AppScreenshotQuery struct {
	// Format `png`, or `jpeg`: smaller and quicker to send, for a model that reads it. Default: "png".
	Format *string
	// Quality A jpeg's quality, 1 to 100. At least 1. At most 100. Default: 80.
	Quality *int64
}

AppScreenshotQuery is what Screenshot takes in its query.

type AppStatQuery

type AppStatQuery struct {
	// Path The file's path in the machine.
	Path string
	// Sha256 Also return a file's SHA-256, read from its bytes: to check a file you put in place (files:rename with sha256) is whole. Default: false.
	Sha256 *bool
}

AppStatQuery is what Stat takes in its query.

type AppUploadFolderQuery

type AppUploadFolderQuery struct {
	// Path The folder, absolute, such as `/workspace/app`: made with its parents.
	Path string
	// User Who unpacks it: `runtime` or `root`; the app's `user` when omitted.
	User *string
}

AppUploadFolderQuery is what UploadFolder takes in its query.

type AppWriteFolderUploadQuery

type AppWriteFolderUploadQuery struct {
	// Offset Where the part starts in the archive: at most the bytes received so far. Bytes before them were taken already and are skipped, so a part sent again is never unpacked twice. At least 0. Default: 0.
	Offset *int64
}

AppWriteFolderUploadQuery is what WriteFolderUpload takes in its query.

type AppWriteQuery

type AppWriteQuery struct {
	// Path The file's path in the machine.
	Path string
	// Mode Its mode, in octal (`644`).
	Mode *string
	// Offset Write the bytes into the file in place from this byte, keeping the bytes before and after them (the file is made when there is none); one that fails part way may leave its range written in part, so send it again. Parts of one file may be written so at once and in any order: write them to a new path, then rename it with its size and sha256 to put it in place whole. At least 0.
	Offset *int64
	// Sha256 The bytes' SHA-256 in hex: refused 409 `checksum_mismatch`, the file as it was, when they differ. Not with offset.
	Sha256 *string
}

AppWriteQuery is what Write takes in its query.

type Apps

type Apps struct {
	// contains filtered or unexported fields
}

Apps A machine that keeps a web app in /app running on port 8080 (its Procfile's `web:`, else `npm start`, else `python3 app.py`, as Render and Heroku start one), reached at its preview. It never pauses for being idle.

func (*Apps) AbortFolderUpload

func (c *Apps) AbortFolderUpload(ctx context.Context, id string, upload string, opts *RequestOptions) (*FolderUploadAborted, error)

AbortFolderUpload Stops a folder upload's tar; what it unpacked so far stays.

func (*Apps) Act

func (c *Apps) Act(ctx context.Context, id string, in ActRequest, opts *RequestOptions) (*Acted, error)

Act Moves, clicks, drags and scrolls the mouse and types on the keyboard of an app's screen (its X display `:1`), each step in turn as one command, and returns where the mouse is then. It stops at the first step that fails, refused 409 `act_failed` naming it; refused 409 `display_not_running` when no display runs. A paused app is resumed first.

func (*Apps) BeginFolderUpload

func (c *Apps) BeginFolderUpload(ctx context.Context, id string, in FolderUploadBegin, opts *RequestOptions) (*FolderUpload, error)

BeginFolderUpload Begins a folder's upload in parts: tar starts in the app, unpacking into the folder each part as it arrives. Send the parts in order by offset (writeFolderUpload), then commitFolderUpload; an upload no call names for 10 minutes is ended. A paused app is woken first.

func (*Apps) CommitFolderUpload

func (c *Apps) CommitFolderUpload(ctx context.Context, id string, upload string, opts *RequestOptions) (*FolderUnpacked, error)

CommitFolderUpload Ends a folder upload's input and returns once tar has ended, as an exec returns once its command has: the folder, or 400 `invalid_archive` with what tar said. Sent again, it returns how tar ended. An upload no call has named for 10 minutes since its last part or commit is ended.

func (*Apps) Create

func (c *Apps) Create(ctx context.Context, in SandboxCreate, opts *RequestOptions) (*App, error)

Create Creates an app. Asked again with the same Idempotency-Key, it returns the same app.

func (*Apps) Delete

func (c *Apps) Delete(ctx context.Context, id string, opts *RequestOptions) (*SandboxInfo, error)

Delete Deletes an app, its memory and its disk.

func (*Apps) DownloadFolder

func (c *Apps) DownloadFolder(ctx context.Context, id string, q AppDownloadFolderQuery, opts *RequestOptions) ([]byte, error)

DownloadFolder Returns a folder as a tar archive (`application/x-tar`, or `application/gzip` with gzip), packed by tar in the app as it streams, of any size; its entries are relative to the folder (`./a.txt`). A folder that fails part way (a file it may not read, or one that changes as it is read) ends as an archive every tar reader refuses, never as a short one that reads whole. At most 4 at once in an app. A paused app is woken first.

func (*Apps) Exec

func (c *Apps) Exec(ctx context.Context, id string, in ExecRequest, opts *RequestOptions) (*Process, error)

Exec Runs a command as a process and returns it once it ended, with its output; with wait false, at once, while it runs. A paused app is resumed first. Asked again with the same Idempotency-Key, it runs nothing more: it returns the first run's process, waiting for its end while it runs.

func (*Apps) Fork

func (c *Apps) Fork(ctx context.Context, id string, in ForkRequest, opts *RequestOptions) (*Forked, error)

Fork Copies an app as it is now, memory and disk, into `count` copies of its own, each running on its host. Asked again with the same Idempotency-Key, it returns the same copies.

func (*Apps) Get

func (c *Apps) Get(ctx context.Context, id string, q AppGetQuery, opts *RequestOptions) (*App, error)

Get Returns an app.

func (*Apps) GetNetwork

func (c *Apps) GetNetwork(ctx context.Context, id string, opts *RequestOptions) (*SandboxNetwork, error)

GetNetwork Returns where an app may connect out.

func (c *Apps) Link(ctx context.Context, id string, in FileLinkCreate, opts *RequestOptions) (*FileLink, error)

Link Makes an expiring address for one file that anyone may open with no API key, from a browser, curl or another service: GET downloads it (Range works, so videos play and downloads resume; archive: true downloads a folder as .tar.gz), PUT with the raw body uploads it (up to maxBytes, written whole; Content-Length required). The link acts as the key that made it: an upload link needs write, and the link ends with its key, with revokeLinks or with its app. A paused app is woken for it unless wake is false. A port it serves is shared by a preview (previews.create), not a link.

func (*Apps) List

func (c *Apps) List(ctx context.Context, q AppListQuery, opts *RequestOptions) (*Page[SandboxInfo], error)

List Lists the project's apps, newest first.

func (*Apps) ListAll

ListAll is every item of every page List reads from q.Cursor (none: the first page), each page read as the last is used up.

func (*Apps) ListFiles

func (c *Apps) ListFiles(ctx context.Context, id string, q AppListFilesQuery, opts *RequestOptions) (*FileList, error)

ListFiles Lists a directory's entries in path order, to a depth.

func (*Apps) ListProcesses

func (c *Apps) ListProcesses(ctx context.Context, id string, opts *RequestOptions) (*ProcessList, error)

ListProcesses Lists an app's processes, newest first: those running and those that ended lately.

func (*Apps) Metrics

func (c *Apps) Metrics(ctx context.Context, id string, q AppMetricsQuery, opts *RequestOptions) (*SandboxMetrics, error)

Metrics Returns an app's CPU, memory, disks and pressure, as its host reads them from the app's own cgroup over a fifth of a second: never a call into the app, so it does not wake a paused one nor keep one from its idle pause. One that is not running has no reading.

func (*Apps) Mkdir

func (c *Apps) Mkdir(ctx context.Context, id string, in FileMkdir, opts *RequestOptions) (*FileMade, error)

Mkdir Makes a directory, and its parents unless parents is false. One there already is success, created false.

func (*Apps) Pause

func (c *Apps) Pause(ctx context.Context, id string, opts *RequestOptions) (*SandboxInfo, error)

Pause Pauses an app with its memory and disk kept. A call to it resumes it.

func (*Apps) ProcessOutput

func (c *Apps) ProcessOutput(ctx context.Context, id string, process string, q AppProcessOutputQuery, opts *RequestOptions) (*ProcessOutput, error)

ProcessOutput Returns a process's output after a cursor, and the cursor to read on from. The latest 1 MiB is kept; truncated says when the cursor fell behind.

func (*Apps) Read

func (c *Apps) Read(ctx context.Context, id string, q AppReadQuery, opts *RequestOptions) ([]byte, error)

Read Returns a file's bytes.

func (*Apps) Remove

func (c *Apps) Remove(ctx context.Context, id string, in FileRemove, opts *RequestOptions) (*FileRemoved, error)

Remove Removes a file, a link or a directory (recursive for one with contents). One missing is success, removed false.

func (*Apps) Rename

func (c *Apps) Rename(ctx context.Context, id string, in FileRename, opts *RequestOptions) (*FileRenamed, error)

Rename Moves a file, a link or a directory; refused 409 when something is at its new path, unless overwrite. With sha256 or size, a file written in parts is put in place once whole: its writes ended, then only a file of that size with every byte written and whose bytes hash to it moves; refused 409 `upload_incomplete` or `checksum_mismatch`, nothing moved. With sha256, it is safe to send again: once moved, it returns the same answer while `from` is gone and `to` holds those bytes.

func (*Apps) ResizeProcess

func (c *Apps) ResizeProcess(ctx context.Context, id string, process string, in Terminal, opts *RequestOptions) (*Process, error)

ResizeProcess Resizes the terminal of a process started with a pty (its window's columns and rows, which the process is told by SIGWINCH), and returns the process; refused 409 for a process without one. A process that ended is left as it is, so a retry is safe.

func (*Apps) Resume

func (c *Apps) Resume(ctx context.Context, id string, opts *RequestOptions) (*SandboxInfo, error)

Resume Resumes a paused app where it was, its memory and processes as they were.

func (c *Apps) RevokeLinks(ctx context.Context, id string, opts *RequestOptions) (*FileLinksRevoked, error)

RevokeLinks Ends every file link made for an app so far; links made after work.

func (*Apps) RunCode

func (c *Apps) RunCode(ctx context.Context, id string, in RunCode, opts *RequestOptions) (*CodeRun, error)

RunCode Runs a cell of Python in an app as a notebook does, in a Jupyter kernel it keeps running for the cell's `context`: variables, imports and functions stay for the next cell. Returns what it printed, its values and displays (text, HTML, images such as charts), and its exception with its traceback. The context's kernel starts on its first cell. A cell past `timeoutSeconds` is interrupted and its context kept. Refused 409 `kernel_not_installed` when the image has no ipykernel. A paused app is resumed first.

func (*Apps) Screenshot

func (c *Apps) Screenshot(ctx context.Context, id string, q AppScreenshotQuery, opts *RequestOptions) ([]byte, error)

Screenshot Returns what an app's screen shows now, as `image/png` (or `image/jpeg`): its X display `:1`, whole. Refused 409 `display_not_running` when no display runs. A paused app is resumed first.

func (*Apps) SetNetwork

func (c *Apps) SetNetwork(ctx context.Context, id string, in NetworkRules, opts *RequestOptions) (*SandboxNetwork, error)

SetNetwork Replaces where an app may connect out, for its next connection and within a second for its open ones: those the new rules refuse are cut.

func (*Apps) SignalProcess

func (c *Apps) SignalProcess(ctx context.Context, id string, process string, in ProcessSignal, opts *RequestOptions) (*Process, error)

SignalProcess Sends a signal to a process and its group; a process that ended is not signalled, so a retry is safe.

func (*Apps) Snapshot

func (c *Apps) Snapshot(ctx context.Context, id string, in SnapshotRequest, opts *RequestOptions) (*Stored, error)

Snapshot Keeps an app's memory and disk as they are now, a snapshot to start apps from; with `image`, its disk alone as that image's next version. The app runs on. Asked again with the same Idempotency-Key, it returns the same snapshot.

func (*Apps) Stat

func (c *Apps) Stat(ctx context.Context, id string, q AppStatQuery, opts *RequestOptions) (*FileInfo, error)

Stat Returns what is at a path: a file, a directory or a link, or nothing (exists false). With sha256=true, a file's SHA-256 too.

func (*Apps) Update

func (c *Apps) Update(ctx context.Context, id string, in MachineUpdate, opts *RequestOptions) (*SandboxInfo, error)

Update Changes its name, labels, idle pause, maxCost, autoWake, lifetime, delete protection, environment or sizes; each field left out stays as it is. A lifetime (`deleteAfterSeconds`) sent again before its end moves the end to that many seconds from now; 0 takes it off. A lifetime is refused (409 `delete_protected`) while `deleteProtection` is true. A running one holds a changed environment before this answers (a paused one's at its wake): each process it starts after the answer has it, and its running processes keep the one they started with. Its vCPUs, memory and disk grow while it runs, its commands running on. One paused or stopped is not woken for it: judged at once as a live resize is (past the vCPUs it was made with 409, over its organization's limits `quota_exceeded`), its new sizes are returned at once, and its next wake grows it to them before the call that woke it runs. A smaller size, or a machine starting or failed, is refused 409 naming why, and nothing is changed. With If-Match, made only while its revision is that one, else 412. Sent again with the same Idempotency-Key and body while it is the latest change, it returns the current state and changes nothing; the same key with a different body returns 409 idempotency_key_reused.

func (*Apps) UploadFolder

func (c *Apps) UploadFolder(ctx context.Context, id string, data []byte, q AppUploadFolderQuery, opts *RequestOptions) (*FolderUnpacked, error)

UploadFolder Unpacks the request's tar archive (gzip-compressed or not, told by its first bytes) into a folder, made with its parents, by tar in the app as the bytes arrive, of any size, nothing of it kept on disk but what tar writes; returns once tar has ended, or 400 `invalid_archive` with what tar said. A paused app is woken first.

func (*Apps) Write

func (c *Apps) Write(ctx context.Context, id string, data []byte, q AppWriteQuery, opts *RequestOptions) (*FileWritten, error)

Write Writes the request's bytes to a file as they come, of any size (Content-Length required), its folders made: the file whole when they all came, or as it was. With offset, they are written into it in place.

func (*Apps) WriteFolderUpload

func (c *Apps) WriteFolderUpload(ctx context.Context, id string, upload string, data []byte, q AppWriteFolderUploadQuery, opts *RequestOptions) (*FolderUploadReceived, error)

WriteFolderUpload Sends the request's bytes, a part of the archive at its offset, into tar's input as they arrive, of any size, and returns the bytes received in all once tar took them. A part past them is refused 409 `upload_incomplete`, naming them: send the parts in order.

func (*Apps) WriteProcess

func (c *Apps) WriteProcess(ctx context.Context, id string, process string, in ProcessInput, opts *RequestOptions) (*ProcessWritten, error)

WriteProcess Sends input to a process started with stdinOpen or a pty, and returns how much of its input it has taken.

type AskAnswer

type AskAnswer struct {
	// Ask The ask's ID (its message's `ref`).
	Ask string `json:"ask"`
	// Choice One of its choices, or free text.
	Choice string `json:"choice"`
}

AskAnswer An answer to an ask.

type Audit

type Audit struct {
	// contains filtered or unexported fields
}

Audit The organization's audit log: every write and every refused call, with who asked, from where, and what it committed. On the Scale and Enterprise plans.

func (*Audit) List

List Lists the organization's audit log, newest first, paginated: each write and each refused call, over the days the plan keeps (365 on Scale). On other plans it returns 403.

func (*Audit) ListAll

ListAll is every item of every page List reads from q.Cursor (none: the first page), each page read as the last is used up.

type AuditLine

type AuditLine struct {
	// ID Its ID.
	ID string `json:"id"`
	// Object Always `audit`.
	Object string `json:"object"`
	// Action What was asked (`sandboxes:create`, `keys:delete`).
	Action string `json:"action"`
	// Allowed Whether it was allowed.
	Allowed bool `json:"allowed"`
	// Reason Why it was refused, or what it changed, when it says.
	Reason *string `json:"reason,omitempty"`
	// Target What it acted on: a resource's ID, when it names one.
	Target *string `json:"target,omitempty"`
	// AccountID The person who asked, or for whom an agent asked.
	AccountID *string `json:"accountId,omitempty"`
	// AgentID The agent or CI pipeline that asked.
	AgentID *string `json:"agentId,omitempty"`
	// KeyID The key it was asked with; none for the console.
	KeyID *string `json:"keyId,omitempty"`
	// ProjectID The project it acted in.
	ProjectID *string `json:"projectId,omitempty"`
	// Cost What it committed, in US dollars.
	Cost *string `json:"cost,omitempty"`
	// Address The client address it came from.
	Address *string `json:"address,omitempty"`
	// RequestID The request's ID.
	RequestID *string `json:"requestId,omitempty"`
	// CreatedAt When it was asked.
	CreatedAt string `json:"createdAt"`
}

AuditLine One line of the audit log: a call Access judged, allowed or refused.

type AuditLineListQuery

type AuditLineListQuery struct {
	// Cursor Where the page starts: a page's `next`.
	Cursor *string
	// Limit The most items the page holds. At least 1. At most 200. Default: 50.
	Limit *int64
	// Action Only lines of this action (`keys:create`), or of every action of a product (`keys:`).
	Action *string
}

AuditLineListQuery is what List takes in its query.

type Browser

type Browser struct {

	// Info is what it was when last read.
	Info      *SandboxInfo
	Files     *BrowserFiles
	Processes *BrowserProcesses
	Network   *BrowserNetwork
	// contains filtered or unexported fields
}

Browser is one of browsers: A machine running headless Chromium, driven over the Chrome DevTools Protocol at its preview on port 9222: one WebSocket address for Playwright's `connectOverCDP` and Puppeteer's `connect`, as Browserbase gives one. It pauses after 60 seconds with nothing happening, its memory kept, and a connection resumes it.

func (*Browser) Act

func (s *Browser) Act(ctx context.Context, actions []Action, in *ActRequest, opts *RequestOptions) (*Acted, error)

Act Moves, clicks, drags and scrolls the mouse and types on the keyboard of a browser's screen (its page, read and driven by the browser itself over the Chrome DevTools Protocol), each step in turn as one command, and returns where the mouse is then. It stops at the first step that fails, refused 409 `act_failed` naming it; refused 409 `browser_not_running` when its Chromium does not answer. A paused browser is resumed first.

func (*Browser) Delete

func (s *Browser) Delete(ctx context.Context, opts *RequestOptions) (*SandboxInfo, error)

Delete Deletes a browser, its memory and its disk.

func (*Browser) Exec

func (s *Browser) Exec(ctx context.Context, cmd string, in *ExecRequest, opts *RequestOptions) (*Process, error)

Exec Runs a command as a process and returns it once it ended, with its output; with wait false, at once, while it runs. A paused browser is resumed first. Asked again with the same Idempotency-Key, it runs nothing more: it returns the first run's process, waiting for its end while it runs.

func (*Browser) Fork

func (s *Browser) Fork(ctx context.Context, in *ForkRequest, opts *RequestOptions) (*Forked, error)

Fork Copies a browser as it is now, memory and disk, into `count` copies of its own, each running on its host. Asked again with the same Idempotency-Key, it returns the same copies.

func (*Browser) ID

func (s *Browser) ID() string

ID is its id.

func (*Browser) Metrics

Metrics Returns a browser's CPU, memory, disks and pressure, as its host reads them from the browser's own cgroup over a fifth of a second: never a call into the browser, so it does not wake a paused one nor keep one from its idle pause. One that is not running has no reading.

func (*Browser) Pause

func (s *Browser) Pause(ctx context.Context, opts *RequestOptions) error

Pause Pauses a browser with its memory and disk kept. A call to it resumes it.

func (*Browser) Refresh

func (s *Browser) Refresh(ctx context.Context, q *BrowserGetQuery, opts *RequestOptions) error

Refresh Returns a browser.

func (*Browser) Resume

func (s *Browser) Resume(ctx context.Context, opts *RequestOptions) error

Resume Resumes a paused browser where it was, its memory and processes as they were.

func (*Browser) RunCode

func (s *Browser) RunCode(ctx context.Context, code string, in *RunCode, opts *RequestOptions) (*CodeRun, error)

RunCode Runs a cell of Python in a browser as a notebook does, in a Jupyter kernel it keeps running for the cell's `context`: variables, imports and functions stay for the next cell. Returns what it printed, its values and displays (text, HTML, images such as charts), and its exception with its traceback. The context's kernel starts on its first cell. A cell past `timeoutSeconds` is interrupted and its context kept. Refused 409 `kernel_not_installed` when the image has no ipykernel. A paused browser is resumed first.

func (*Browser) Screenshot

func (s *Browser) Screenshot(ctx context.Context, q *BrowserScreenshotQuery, opts *RequestOptions) ([]byte, error)

Screenshot Returns what a browser's screen shows now, as `image/png` (or `image/jpeg`): its page, read and driven by the browser itself over the Chrome DevTools Protocol, whole. Refused 409 `browser_not_running` when its Chromium does not answer. A paused browser is resumed first.

func (*Browser) Snapshot

func (s *Browser) Snapshot(ctx context.Context, in *SnapshotRequest, opts *RequestOptions) (*Stored, error)

Snapshot Keeps a browser's memory and disk as they are now, a snapshot to start browsers from; with `image`, its disk alone as that image's next version. The browser runs on. Asked again with the same Idempotency-Key, it returns the same snapshot.

func (*Browser) Update

func (s *Browser) Update(ctx context.Context, in *MachineUpdate, opts *RequestOptions) error

Update Changes its name, labels, idle pause, maxCost, autoWake, lifetime, delete protection, environment or sizes; each field left out stays as it is. A lifetime (`deleteAfterSeconds`) sent again before its end moves the end to that many seconds from now; 0 takes it off. A lifetime is refused (409 `delete_protected`) while `deleteProtection` is true. A running one holds a changed environment before this answers (a paused one's at its wake): each process it starts after the answer has it, and its running processes keep the one they started with. Its vCPUs, memory and disk grow while it runs, its commands running on. One paused or stopped is not woken for it: judged at once as a live resize is (past the vCPUs it was made with 409, over its organization's limits `quota_exceeded`), its new sizes are returned at once, and its next wake grows it to them before the call that woke it runs. A smaller size, or a machine starting or failed, is refused 409 naming why, and nothing is changed. With If-Match, made only while its revision is that one, else 412. Sent again with the same Idempotency-Key and body while it is the latest change, it returns the current state and changes nothing; the same key with a different body returns 409 idempotency_key_reused.

type BrowserDownloadFolderQuery

type BrowserDownloadFolderQuery struct {
	// Path The folder, absolute, such as `/workspace/app`.
	Path string
	// Gzip Compress the archive with gzip. Default: false.
	Gzip *bool
	// User Who packs it: `runtime` or `root`; the browser's `user` when omitted.
	User *string
	// Exclude Paths in the folder to leave out, relative to it and comma-separated (`node_modules,.cache`): plain names, no wildcards, at most 32.
	Exclude *string
}

BrowserDownloadFolderQuery is what DownloadFolder takes in its query.

type BrowserFiles

type BrowserFiles struct {
	// contains filtered or unexported fields
}

BrowserFiles is a browser's files.

func (*BrowserFiles) AbortFolderUpload

func (g *BrowserFiles) AbortFolderUpload(ctx context.Context, upload string, opts *RequestOptions) (*FolderUploadAborted, error)

AbortFolderUpload Stops a folder upload's tar; what it unpacked so far stays.

func (*BrowserFiles) BeginFolderUpload

func (g *BrowserFiles) BeginFolderUpload(ctx context.Context, path string, in *FolderUploadBegin, opts *RequestOptions) (*FolderUpload, error)

BeginFolderUpload Begins a folder's upload in parts: tar starts in the browser, unpacking into the folder each part as it arrives. Send the parts in order by offset (writeFolderUpload), then commitFolderUpload; an upload no call names for 10 minutes is ended. A paused browser is woken first.

func (*BrowserFiles) CommitFolderUpload

func (g *BrowserFiles) CommitFolderUpload(ctx context.Context, upload string, opts *RequestOptions) (*FolderUnpacked, error)

CommitFolderUpload Ends a folder upload's input and returns once tar has ended, as an exec returns once its command has: the folder, or 400 `invalid_archive` with what tar said. Sent again, it returns how tar ended. An upload no call has named for 10 minutes since its last part or commit is ended.

func (*BrowserFiles) DownloadFolder

func (g *BrowserFiles) DownloadFolder(ctx context.Context, path string, q *BrowserDownloadFolderQuery, opts *RequestOptions) ([]byte, error)

DownloadFolder Returns a folder as a tar archive (`application/x-tar`, or `application/gzip` with gzip), packed by tar in the browser as it streams, of any size; its entries are relative to the folder (`./a.txt`). A folder that fails part way (a file it may not read, or one that changes as it is read) ends as an archive every tar reader refuses, never as a short one that reads whole. At most 4 at once in a browser. A paused browser is woken first.

func (g *BrowserFiles) Link(ctx context.Context, path string, in *FileLinkCreate, opts *RequestOptions) (*FileLink, error)

Link Makes an expiring address for one file that anyone may open with no API key, from a browser, curl or another service: GET downloads it (Range works, so videos play and downloads resume; archive: true downloads a folder as .tar.gz), PUT with the raw body uploads it (up to maxBytes, written whole; Content-Length required). The link acts as the key that made it: an upload link needs write, and the link ends with its key, with revokeLinks or with its browser. A paused browser is woken for it unless wake is false. A port it serves is shared by a preview (previews.create), not a link.

func (*BrowserFiles) List

List Lists a directory's entries in path order, to a depth.

func (*BrowserFiles) Mkdir

func (g *BrowserFiles) Mkdir(ctx context.Context, path string, in *FileMkdir, opts *RequestOptions) (*FileMade, error)

Mkdir Makes a directory, and its parents unless parents is false. One there already is success, created false.

func (*BrowserFiles) Read

func (g *BrowserFiles) Read(ctx context.Context, path string, q *BrowserReadQuery, opts *RequestOptions) ([]byte, error)

Read Returns a file's bytes.

func (*BrowserFiles) Remove

func (g *BrowserFiles) Remove(ctx context.Context, path string, in *FileRemove, opts *RequestOptions) (*FileRemoved, error)

Remove Removes a file, a link or a directory (recursive for one with contents). One missing is success, removed false.

func (*BrowserFiles) Rename

func (g *BrowserFiles) Rename(ctx context.Context, in *FileRename, opts *RequestOptions) (*FileRenamed, error)

Rename Moves a file, a link or a directory; refused 409 when something is at its new path, unless overwrite. With sha256 or size, a file written in parts is put in place once whole: its writes ended, then only a file of that size with every byte written and whose bytes hash to it moves; refused 409 `upload_incomplete` or `checksum_mismatch`, nothing moved. With sha256, it is safe to send again: once moved, it returns the same answer while `from` is gone and `to` holds those bytes.

func (g *BrowserFiles) RevokeLinks(ctx context.Context, opts *RequestOptions) (*FileLinksRevoked, error)

RevokeLinks Ends every file link made for a browser so far; links made after work.

func (*BrowserFiles) Stat

func (g *BrowserFiles) Stat(ctx context.Context, path string, q *BrowserStatQuery, opts *RequestOptions) (*FileInfo, error)

Stat Returns what is at a path: a file, a directory or a link, or nothing (exists false). With sha256=true, a file's SHA-256 too.

func (*BrowserFiles) UploadFolder

func (g *BrowserFiles) UploadFolder(ctx context.Context, path string, data []byte, q *BrowserUploadFolderQuery, opts *RequestOptions) (*FolderUnpacked, error)

UploadFolder Unpacks the request's tar archive (gzip-compressed or not, told by its first bytes) into a folder, made with its parents, by tar in the browser as the bytes arrive, of any size, nothing of it kept on disk but what tar writes; returns once tar has ended, or 400 `invalid_archive` with what tar said. A paused browser is woken first.

func (*BrowserFiles) Write

func (g *BrowserFiles) Write(ctx context.Context, path string, data []byte, q *BrowserWriteQuery, opts *RequestOptions) (*FileWritten, error)

Write Writes the request's bytes to a file as they come, of any size (Content-Length required), its folders made: the file whole when they all came, or as it was. With offset, they are written into it in place.

func (*BrowserFiles) WriteFolderUpload

func (g *BrowserFiles) WriteFolderUpload(ctx context.Context, upload string, data []byte, q *BrowserWriteFolderUploadQuery, opts *RequestOptions) (*FolderUploadReceived, error)

WriteFolderUpload Sends the request's bytes, a part of the archive at its offset, into tar's input as they arrive, of any size, and returns the bytes received in all once tar took them. A part past them is refused 409 `upload_incomplete`, naming them: send the parts in order.

type BrowserGetQuery

type BrowserGetQuery struct {
	// Wait Seconds to wait, at most 60, for its state to differ from `ifState`; it answers once it does, or as it is when the wait ends. At least 0. At most 60.
	Wait *float64
	// IfState The state the caller last read, which `wait` waits for it to leave.
	IfState *string
}

BrowserGetQuery is what Get takes in its query.

type BrowserListFilesQuery

type BrowserListFilesQuery struct {
	// Path The directory. Default: "/workspace".
	Path *string
	// Depth How deep to list. At least 1. At most 10. Default: 1.
	Depth *int64
	// Limit At most this many entries. At least 1. At most 2000. Default: 2000.
	Limit *int64
	// Hidden List entries whose names start with a dot. Default: true.
	Hidden *bool
	// Glob Only entries whose path relative to the directory matches: `*` within a name, `**` across folders, `?` one character, `{a,b}` either (`**/*.py`); at most 512 characters, 32 wildcards and 64 texts in braces. The listing then reaches as deep as the glob does (10 folders for `**`) unless depth says, and is searched past its first 2,000 entries, up to 50,000. At most 512 characters.
	Glob *string
}

BrowserListFilesQuery is what ListFiles takes in its query.

type BrowserListQuery

type BrowserListQuery struct {
	// State Only those in these states, comma-separated.
	State *string
	// Name Only the browser of this name.
	Name *string
	// Label Only those with every label given (repeat it for several): key:value, or a key for any value.
	Label []string
	// Cursor Where the page starts: a page's `next`.
	Cursor *string
	// Limit The most items the page holds. At least 1. At most 200. Default: 50.
	Limit *int64
}

BrowserListQuery is what List takes in its query.

type BrowserMetricsQuery

type BrowserMetricsQuery struct {
	// Range The window: `15m`, `1h`, `6h`, `24h`, `7d` or `30d`. Default: "1h".
	Range *string
}

BrowserMetricsQuery is what Metrics takes in its query.

type BrowserNetwork

type BrowserNetwork struct {
	// contains filtered or unexported fields
}

BrowserNetwork is a browser's network.

func (*BrowserNetwork) Get

Get Returns where a browser may connect out.

func (*BrowserNetwork) Set

Set Replaces where a browser may connect out, for its next connection and within a second for its open ones: those the new rules refuse are cut.

type BrowserProcessOutputQuery

type BrowserProcessOutputQuery struct {
	// Cursor Output after this byte. At least 0. Default: 0.
	Cursor *int64
	// WaitSeconds Seconds to wait for output past the cursor or its exit, at most 8. At least 0. At most 8.
	WaitSeconds *float64
	// MaxBytes At most this many bytes. At least 4096. At most 196608. Default: 65536.
	MaxBytes *int64
	// Follow Answer as NDJSON events from the cursor until it exits (stdout, stderr, truncated, exit; continue with the cursor to follow on from), as `Accept: application/x-ndjson` does.
	Follow *bool
}

BrowserProcessOutputQuery is what ProcessOutput takes in its query.

type BrowserProcesses

type BrowserProcesses struct {
	// contains filtered or unexported fields
}

BrowserProcesses is a browser's processes.

func (*BrowserProcesses) List

List Lists a browser's processes, newest first: those running and those that ended lately.

func (*BrowserProcesses) Output

Output Returns a process's output after a cursor, and the cursor to read on from. The latest 1 MiB is kept; truncated says when the cursor fell behind.

func (*BrowserProcesses) Resize

func (g *BrowserProcesses) Resize(ctx context.Context, process string, in *Terminal, opts *RequestOptions) (*Process, error)

Resize Resizes the terminal of a process started with a pty (its window's columns and rows, which the process is told by SIGWINCH), and returns the process; refused 409 for a process without one. A process that ended is left as it is, so a retry is safe.

func (*BrowserProcesses) Signal

func (g *BrowserProcesses) Signal(ctx context.Context, process string, in *ProcessSignal, opts *RequestOptions) (*Process, error)

Signal Sends a signal to a process and its group; a process that ended is not signalled, so a retry is safe.

func (*BrowserProcesses) Write

func (g *BrowserProcesses) Write(ctx context.Context, process string, in *ProcessInput, opts *RequestOptions) (*ProcessWritten, error)

Write Sends input to a process started with stdinOpen or a pty, and returns how much of its input it has taken.

type BrowserReadQuery

type BrowserReadQuery struct {
	// Path The file's path in the machine.
	Path string
}

BrowserReadQuery is what Read takes in its query.

type BrowserScreenshotQuery

type BrowserScreenshotQuery struct {
	// Format `png`, or `jpeg`: smaller and quicker to send, for a model that reads it. Default: "png".
	Format *string
	// Quality A jpeg's quality, 1 to 100. At least 1. At most 100. Default: 80.
	Quality *int64
}

BrowserScreenshotQuery is what Screenshot takes in its query.

type BrowserStatQuery

type BrowserStatQuery struct {
	// Path The file's path in the machine.
	Path string
	// Sha256 Also return a file's SHA-256, read from its bytes: to check a file you put in place (files:rename with sha256) is whole. Default: false.
	Sha256 *bool
}

BrowserStatQuery is what Stat takes in its query.

type BrowserUploadFolderQuery

type BrowserUploadFolderQuery struct {
	// Path The folder, absolute, such as `/workspace/app`: made with its parents.
	Path string
	// User Who unpacks it: `runtime` or `root`; the browser's `user` when omitted.
	User *string
}

BrowserUploadFolderQuery is what UploadFolder takes in its query.

type BrowserWriteFolderUploadQuery

type BrowserWriteFolderUploadQuery struct {
	// Offset Where the part starts in the archive: at most the bytes received so far. Bytes before them were taken already and are skipped, so a part sent again is never unpacked twice. At least 0. Default: 0.
	Offset *int64
}

BrowserWriteFolderUploadQuery is what WriteFolderUpload takes in its query.

type BrowserWriteQuery

type BrowserWriteQuery struct {
	// Path The file's path in the machine.
	Path string
	// Mode Its mode, in octal (`644`).
	Mode *string
	// Offset Write the bytes into the file in place from this byte, keeping the bytes before and after them (the file is made when there is none); one that fails part way may leave its range written in part, so send it again. Parts of one file may be written so at once and in any order: write them to a new path, then rename it with its size and sha256 to put it in place whole. At least 0.
	Offset *int64
	// Sha256 The bytes' SHA-256 in hex: refused 409 `checksum_mismatch`, the file as it was, when they differ. Not with offset.
	Sha256 *string
}

BrowserWriteQuery is what Write takes in its query.

type Browsers

type Browsers struct {
	// contains filtered or unexported fields
}

Browsers A machine running headless Chromium, driven over the Chrome DevTools Protocol at its preview on port 9222: one WebSocket address for Playwright's `connectOverCDP` and Puppeteer's `connect`, as Browserbase gives one. It pauses after 60 seconds with nothing happening, its memory kept, and a connection resumes it.

func (*Browsers) AbortFolderUpload

func (c *Browsers) AbortFolderUpload(ctx context.Context, id string, upload string, opts *RequestOptions) (*FolderUploadAborted, error)

AbortFolderUpload Stops a folder upload's tar; what it unpacked so far stays.

func (*Browsers) Act

func (c *Browsers) Act(ctx context.Context, id string, in ActRequest, opts *RequestOptions) (*Acted, error)

Act Moves, clicks, drags and scrolls the mouse and types on the keyboard of a browser's screen (its page, read and driven by the browser itself over the Chrome DevTools Protocol), each step in turn as one command, and returns where the mouse is then. It stops at the first step that fails, refused 409 `act_failed` naming it; refused 409 `browser_not_running` when its Chromium does not answer. A paused browser is resumed first.

func (*Browsers) BeginFolderUpload

func (c *Browsers) BeginFolderUpload(ctx context.Context, id string, in FolderUploadBegin, opts *RequestOptions) (*FolderUpload, error)

BeginFolderUpload Begins a folder's upload in parts: tar starts in the browser, unpacking into the folder each part as it arrives. Send the parts in order by offset (writeFolderUpload), then commitFolderUpload; an upload no call names for 10 minutes is ended. A paused browser is woken first.

func (*Browsers) CommitFolderUpload

func (c *Browsers) CommitFolderUpload(ctx context.Context, id string, upload string, opts *RequestOptions) (*FolderUnpacked, error)

CommitFolderUpload Ends a folder upload's input and returns once tar has ended, as an exec returns once its command has: the folder, or 400 `invalid_archive` with what tar said. Sent again, it returns how tar ended. An upload no call has named for 10 minutes since its last part or commit is ended.

func (*Browsers) Create

func (c *Browsers) Create(ctx context.Context, in SandboxCreate, opts *RequestOptions) (*Browser, error)

Create Creates a browser. Asked again with the same Idempotency-Key, it returns the same browser.

func (*Browsers) Delete

func (c *Browsers) Delete(ctx context.Context, id string, opts *RequestOptions) (*SandboxInfo, error)

Delete Deletes a browser, its memory and its disk.

func (*Browsers) DownloadFolder

func (c *Browsers) DownloadFolder(ctx context.Context, id string, q BrowserDownloadFolderQuery, opts *RequestOptions) ([]byte, error)

DownloadFolder Returns a folder as a tar archive (`application/x-tar`, or `application/gzip` with gzip), packed by tar in the browser as it streams, of any size; its entries are relative to the folder (`./a.txt`). A folder that fails part way (a file it may not read, or one that changes as it is read) ends as an archive every tar reader refuses, never as a short one that reads whole. At most 4 at once in a browser. A paused browser is woken first.

func (*Browsers) Exec

func (c *Browsers) Exec(ctx context.Context, id string, in ExecRequest, opts *RequestOptions) (*Process, error)

Exec Runs a command as a process and returns it once it ended, with its output; with wait false, at once, while it runs. A paused browser is resumed first. Asked again with the same Idempotency-Key, it runs nothing more: it returns the first run's process, waiting for its end while it runs.

func (*Browsers) Fork

func (c *Browsers) Fork(ctx context.Context, id string, in ForkRequest, opts *RequestOptions) (*Forked, error)

Fork Copies a browser as it is now, memory and disk, into `count` copies of its own, each running on its host. Asked again with the same Idempotency-Key, it returns the same copies.

func (*Browsers) Get

func (c *Browsers) Get(ctx context.Context, id string, q BrowserGetQuery, opts *RequestOptions) (*Browser, error)

Get Returns a browser.

func (*Browsers) GetNetwork

func (c *Browsers) GetNetwork(ctx context.Context, id string, opts *RequestOptions) (*SandboxNetwork, error)

GetNetwork Returns where a browser may connect out.

func (c *Browsers) Link(ctx context.Context, id string, in FileLinkCreate, opts *RequestOptions) (*FileLink, error)

Link Makes an expiring address for one file that anyone may open with no API key, from a browser, curl or another service: GET downloads it (Range works, so videos play and downloads resume; archive: true downloads a folder as .tar.gz), PUT with the raw body uploads it (up to maxBytes, written whole; Content-Length required). The link acts as the key that made it: an upload link needs write, and the link ends with its key, with revokeLinks or with its browser. A paused browser is woken for it unless wake is false. A port it serves is shared by a preview (previews.create), not a link.

func (*Browsers) List

List Lists the project's browsers, newest first.

func (*Browsers) ListAll

ListAll is every item of every page List reads from q.Cursor (none: the first page), each page read as the last is used up.

func (*Browsers) ListFiles

func (c *Browsers) ListFiles(ctx context.Context, id string, q BrowserListFilesQuery, opts *RequestOptions) (*FileList, error)

ListFiles Lists a directory's entries in path order, to a depth.

func (*Browsers) ListProcesses

func (c *Browsers) ListProcesses(ctx context.Context, id string, opts *RequestOptions) (*ProcessList, error)

ListProcesses Lists a browser's processes, newest first: those running and those that ended lately.

func (*Browsers) Metrics

Metrics Returns a browser's CPU, memory, disks and pressure, as its host reads them from the browser's own cgroup over a fifth of a second: never a call into the browser, so it does not wake a paused one nor keep one from its idle pause. One that is not running has no reading.

func (*Browsers) Mkdir

func (c *Browsers) Mkdir(ctx context.Context, id string, in FileMkdir, opts *RequestOptions) (*FileMade, error)

Mkdir Makes a directory, and its parents unless parents is false. One there already is success, created false.

func (*Browsers) Pause

func (c *Browsers) Pause(ctx context.Context, id string, opts *RequestOptions) (*SandboxInfo, error)

Pause Pauses a browser with its memory and disk kept. A call to it resumes it.

func (*Browsers) ProcessOutput

func (c *Browsers) ProcessOutput(ctx context.Context, id string, process string, q BrowserProcessOutputQuery, opts *RequestOptions) (*ProcessOutput, error)

ProcessOutput Returns a process's output after a cursor, and the cursor to read on from. The latest 1 MiB is kept; truncated says when the cursor fell behind.

func (*Browsers) Read

func (c *Browsers) Read(ctx context.Context, id string, q BrowserReadQuery, opts *RequestOptions) ([]byte, error)

Read Returns a file's bytes.

func (*Browsers) Remove

func (c *Browsers) Remove(ctx context.Context, id string, in FileRemove, opts *RequestOptions) (*FileRemoved, error)

Remove Removes a file, a link or a directory (recursive for one with contents). One missing is success, removed false.

func (*Browsers) Rename

func (c *Browsers) Rename(ctx context.Context, id string, in FileRename, opts *RequestOptions) (*FileRenamed, error)

Rename Moves a file, a link or a directory; refused 409 when something is at its new path, unless overwrite. With sha256 or size, a file written in parts is put in place once whole: its writes ended, then only a file of that size with every byte written and whose bytes hash to it moves; refused 409 `upload_incomplete` or `checksum_mismatch`, nothing moved. With sha256, it is safe to send again: once moved, it returns the same answer while `from` is gone and `to` holds those bytes.

func (*Browsers) ResizeProcess

func (c *Browsers) ResizeProcess(ctx context.Context, id string, process string, in Terminal, opts *RequestOptions) (*Process, error)

ResizeProcess Resizes the terminal of a process started with a pty (its window's columns and rows, which the process is told by SIGWINCH), and returns the process; refused 409 for a process without one. A process that ended is left as it is, so a retry is safe.

func (*Browsers) Resume

func (c *Browsers) Resume(ctx context.Context, id string, opts *RequestOptions) (*SandboxInfo, error)

Resume Resumes a paused browser where it was, its memory and processes as they were.

func (c *Browsers) RevokeLinks(ctx context.Context, id string, opts *RequestOptions) (*FileLinksRevoked, error)

RevokeLinks Ends every file link made for a browser so far; links made after work.

func (*Browsers) RunCode

func (c *Browsers) RunCode(ctx context.Context, id string, in RunCode, opts *RequestOptions) (*CodeRun, error)

RunCode Runs a cell of Python in a browser as a notebook does, in a Jupyter kernel it keeps running for the cell's `context`: variables, imports and functions stay for the next cell. Returns what it printed, its values and displays (text, HTML, images such as charts), and its exception with its traceback. The context's kernel starts on its first cell. A cell past `timeoutSeconds` is interrupted and its context kept. Refused 409 `kernel_not_installed` when the image has no ipykernel. A paused browser is resumed first.

func (*Browsers) Screenshot

func (c *Browsers) Screenshot(ctx context.Context, id string, q BrowserScreenshotQuery, opts *RequestOptions) ([]byte, error)

Screenshot Returns what a browser's screen shows now, as `image/png` (or `image/jpeg`): its page, read and driven by the browser itself over the Chrome DevTools Protocol, whole. Refused 409 `browser_not_running` when its Chromium does not answer. A paused browser is resumed first.

func (*Browsers) SetNetwork

func (c *Browsers) SetNetwork(ctx context.Context, id string, in NetworkRules, opts *RequestOptions) (*SandboxNetwork, error)

SetNetwork Replaces where a browser may connect out, for its next connection and within a second for its open ones: those the new rules refuse are cut.

func (*Browsers) SignalProcess

func (c *Browsers) SignalProcess(ctx context.Context, id string, process string, in ProcessSignal, opts *RequestOptions) (*Process, error)

SignalProcess Sends a signal to a process and its group; a process that ended is not signalled, so a retry is safe.

func (*Browsers) Snapshot

func (c *Browsers) Snapshot(ctx context.Context, id string, in SnapshotRequest, opts *RequestOptions) (*Stored, error)

Snapshot Keeps a browser's memory and disk as they are now, a snapshot to start browsers from; with `image`, its disk alone as that image's next version. The browser runs on. Asked again with the same Idempotency-Key, it returns the same snapshot.

func (*Browsers) Stat

Stat Returns what is at a path: a file, a directory or a link, or nothing (exists false). With sha256=true, a file's SHA-256 too.

func (*Browsers) Update

func (c *Browsers) Update(ctx context.Context, id string, in MachineUpdate, opts *RequestOptions) (*SandboxInfo, error)

Update Changes its name, labels, idle pause, maxCost, autoWake, lifetime, delete protection, environment or sizes; each field left out stays as it is. A lifetime (`deleteAfterSeconds`) sent again before its end moves the end to that many seconds from now; 0 takes it off. A lifetime is refused (409 `delete_protected`) while `deleteProtection` is true. A running one holds a changed environment before this answers (a paused one's at its wake): each process it starts after the answer has it, and its running processes keep the one they started with. Its vCPUs, memory and disk grow while it runs, its commands running on. One paused or stopped is not woken for it: judged at once as a live resize is (past the vCPUs it was made with 409, over its organization's limits `quota_exceeded`), its new sizes are returned at once, and its next wake grows it to them before the call that woke it runs. A smaller size, or a machine starting or failed, is refused 409 naming why, and nothing is changed. With If-Match, made only while its revision is that one, else 412. Sent again with the same Idempotency-Key and body while it is the latest change, it returns the current state and changes nothing; the same key with a different body returns 409 idempotency_key_reused.

func (*Browsers) UploadFolder

func (c *Browsers) UploadFolder(ctx context.Context, id string, data []byte, q BrowserUploadFolderQuery, opts *RequestOptions) (*FolderUnpacked, error)

UploadFolder Unpacks the request's tar archive (gzip-compressed or not, told by its first bytes) into a folder, made with its parents, by tar in the browser as the bytes arrive, of any size, nothing of it kept on disk but what tar writes; returns once tar has ended, or 400 `invalid_archive` with what tar said. A paused browser is woken first.

func (*Browsers) Write

func (c *Browsers) Write(ctx context.Context, id string, data []byte, q BrowserWriteQuery, opts *RequestOptions) (*FileWritten, error)

Write Writes the request's bytes to a file as they come, of any size (Content-Length required), its folders made: the file whole when they all came, or as it was. With offset, they are written into it in place.

func (*Browsers) WriteFolderUpload

func (c *Browsers) WriteFolderUpload(ctx context.Context, id string, upload string, data []byte, q BrowserWriteFolderUploadQuery, opts *RequestOptions) (*FolderUploadReceived, error)

WriteFolderUpload Sends the request's bytes, a part of the archive at its offset, into tar's input as they arrive, of any size, and returns the bytes received in all once tar took them. A part past them is refused 409 `upload_incomplete`, naming them: send the parts in order.

func (*Browsers) WriteProcess

func (c *Browsers) WriteProcess(ctx context.Context, id string, process string, in ProcessInput, opts *RequestOptions) (*ProcessWritten, error)

WriteProcess Sends input to a process started with stdinOpen or a pty, and returns how much of its input it has taken.

type Build

type Build struct {

	// Info is what it was when last read.
	Info      *SandboxInfo
	Files     *BuildFiles
	Processes *BuildProcesses
	Network   *BuildNetwork
	// contains filtered or unexported fields
}

Build is one of builds: The machine an image's build runs on: Docker's own builder (BuildKit), its run `runtime-image-build`, deleted once its image is made. Made by an image's create, and billed as any machine is, for the CPU it uses and the memory it holds while it builds.

func (*Build) Act

func (s *Build) Act(ctx context.Context, actions []Action, in *ActRequest, opts *RequestOptions) (*Acted, error)

Act Moves, clicks, drags and scrolls the mouse and types on the keyboard of a build's screen (its X display `:1`), each step in turn as one command, and returns where the mouse is then. It stops at the first step that fails, refused 409 `act_failed` naming it; refused 409 `display_not_running` when no display runs. A paused build is resumed first.

func (*Build) Delete

func (s *Build) Delete(ctx context.Context, opts *RequestOptions) (*SandboxInfo, error)

Delete Deletes a build, its memory and its disk.

func (*Build) Exec

func (s *Build) Exec(ctx context.Context, cmd string, in *ExecRequest, opts *RequestOptions) (*Process, error)

Exec Runs a command as a process and returns it once it ended, with its output; with wait false, at once, while it runs. A paused build is resumed first. Asked again with the same Idempotency-Key, it runs nothing more: it returns the first run's process, waiting for its end while it runs.

func (*Build) Fork

func (s *Build) Fork(ctx context.Context, in *ForkRequest, opts *RequestOptions) (*Forked, error)

Fork Copies a build as it is now, memory and disk, into `count` copies of its own, each running on its host. Asked again with the same Idempotency-Key, it returns the same copies.

func (*Build) ID

func (s *Build) ID() string

ID is its id.

func (*Build) Metrics

func (s *Build) Metrics(ctx context.Context, q *BuildMetricsQuery, opts *RequestOptions) (*SandboxMetrics, error)

Metrics Returns a build's CPU, memory, disks and pressure, as its host reads them from the build's own cgroup over a fifth of a second: never a call into the build, so it does not wake a paused one nor keep one from its idle pause. One that is not running has no reading.

func (*Build) Pause

func (s *Build) Pause(ctx context.Context, opts *RequestOptions) error

Pause Pauses a build with its memory and disk kept. A call to it resumes it.

func (*Build) Refresh

func (s *Build) Refresh(ctx context.Context, q *BuildGetQuery, opts *RequestOptions) error

Refresh Returns a build.

func (*Build) Resume

func (s *Build) Resume(ctx context.Context, opts *RequestOptions) error

Resume Resumes a paused build where it was, its memory and processes as they were.

func (*Build) RunCode

func (s *Build) RunCode(ctx context.Context, code string, in *RunCode, opts *RequestOptions) (*CodeRun, error)

RunCode Runs a cell of Python in a build as a notebook does, in a Jupyter kernel it keeps running for the cell's `context`: variables, imports and functions stay for the next cell. Returns what it printed, its values and displays (text, HTML, images such as charts), and its exception with its traceback. The context's kernel starts on its first cell. A cell past `timeoutSeconds` is interrupted and its context kept. Refused 409 `kernel_not_installed` when the image has no ipykernel. A paused build is resumed first.

func (*Build) Screenshot

func (s *Build) Screenshot(ctx context.Context, q *BuildScreenshotQuery, opts *RequestOptions) ([]byte, error)

Screenshot Returns what a build's screen shows now, as `image/png` (or `image/jpeg`): its X display `:1`, whole. Refused 409 `display_not_running` when no display runs. A paused build is resumed first.

func (*Build) Snapshot

func (s *Build) Snapshot(ctx context.Context, in *SnapshotRequest, opts *RequestOptions) (*Stored, error)

Snapshot Keeps a build's memory and disk as they are now, a snapshot to start builds from; with `image`, its disk alone as that image's next version. The build runs on. Asked again with the same Idempotency-Key, it returns the same snapshot.

func (*Build) Update

func (s *Build) Update(ctx context.Context, in *MachineUpdate, opts *RequestOptions) error

Update Changes its name, labels, idle pause, maxCost, autoWake, lifetime, delete protection, environment or sizes; each field left out stays as it is. A lifetime (`deleteAfterSeconds`) sent again before its end moves the end to that many seconds from now; 0 takes it off. A lifetime is refused (409 `delete_protected`) while `deleteProtection` is true. A running one holds a changed environment before this answers (a paused one's at its wake): each process it starts after the answer has it, and its running processes keep the one they started with. Its vCPUs, memory and disk grow while it runs, its commands running on. One paused or stopped is not woken for it: judged at once as a live resize is (past the vCPUs it was made with 409, over its organization's limits `quota_exceeded`), its new sizes are returned at once, and its next wake grows it to them before the call that woke it runs. A smaller size, or a machine starting or failed, is refused 409 naming why, and nothing is changed. With If-Match, made only while its revision is that one, else 412. Sent again with the same Idempotency-Key and body while it is the latest change, it returns the current state and changes nothing; the same key with a different body returns 409 idempotency_key_reused.

type BuildDownloadFolderQuery

type BuildDownloadFolderQuery struct {
	// Path The folder, absolute, such as `/workspace/app`.
	Path string
	// Gzip Compress the archive with gzip. Default: false.
	Gzip *bool
	// User Who packs it: `runtime` or `root`; the build's `user` when omitted.
	User *string
	// Exclude Paths in the folder to leave out, relative to it and comma-separated (`node_modules,.cache`): plain names, no wildcards, at most 32.
	Exclude *string
}

BuildDownloadFolderQuery is what DownloadFolder takes in its query.

type BuildFiles

type BuildFiles struct {
	// contains filtered or unexported fields
}

BuildFiles is a build's files.

func (*BuildFiles) AbortFolderUpload

func (g *BuildFiles) AbortFolderUpload(ctx context.Context, upload string, opts *RequestOptions) (*FolderUploadAborted, error)

AbortFolderUpload Stops a folder upload's tar; what it unpacked so far stays.

func (*BuildFiles) BeginFolderUpload

func (g *BuildFiles) BeginFolderUpload(ctx context.Context, path string, in *FolderUploadBegin, opts *RequestOptions) (*FolderUpload, error)

BeginFolderUpload Begins a folder's upload in parts: tar starts in the build, unpacking into the folder each part as it arrives. Send the parts in order by offset (writeFolderUpload), then commitFolderUpload; an upload no call names for 10 minutes is ended. A paused build is woken first.

func (*BuildFiles) CommitFolderUpload

func (g *BuildFiles) CommitFolderUpload(ctx context.Context, upload string, opts *RequestOptions) (*FolderUnpacked, error)

CommitFolderUpload Ends a folder upload's input and returns once tar has ended, as an exec returns once its command has: the folder, or 400 `invalid_archive` with what tar said. Sent again, it returns how tar ended. An upload no call has named for 10 minutes since its last part or commit is ended.

func (*BuildFiles) DownloadFolder

func (g *BuildFiles) DownloadFolder(ctx context.Context, path string, q *BuildDownloadFolderQuery, opts *RequestOptions) ([]byte, error)

DownloadFolder Returns a folder as a tar archive (`application/x-tar`, or `application/gzip` with gzip), packed by tar in the build as it streams, of any size; its entries are relative to the folder (`./a.txt`). A folder that fails part way (a file it may not read, or one that changes as it is read) ends as an archive every tar reader refuses, never as a short one that reads whole. At most 4 at once in a build. A paused build is woken first.

func (g *BuildFiles) Link(ctx context.Context, path string, in *FileLinkCreate, opts *RequestOptions) (*FileLink, error)

Link Makes an expiring address for one file that anyone may open with no API key, from a browser, curl or another service: GET downloads it (Range works, so videos play and downloads resume; archive: true downloads a folder as .tar.gz), PUT with the raw body uploads it (up to maxBytes, written whole; Content-Length required). The link acts as the key that made it: an upload link needs write, and the link ends with its key, with revokeLinks or with its build. A paused build is woken for it unless wake is false. A port it serves is shared by a preview (previews.create), not a link.

func (*BuildFiles) List

List Lists a directory's entries in path order, to a depth.

func (*BuildFiles) Mkdir

func (g *BuildFiles) Mkdir(ctx context.Context, path string, in *FileMkdir, opts *RequestOptions) (*FileMade, error)

Mkdir Makes a directory, and its parents unless parents is false. One there already is success, created false.

func (*BuildFiles) Read

func (g *BuildFiles) Read(ctx context.Context, path string, q *BuildReadQuery, opts *RequestOptions) ([]byte, error)

Read Returns a file's bytes.

func (*BuildFiles) Remove

func (g *BuildFiles) Remove(ctx context.Context, path string, in *FileRemove, opts *RequestOptions) (*FileRemoved, error)

Remove Removes a file, a link or a directory (recursive for one with contents). One missing is success, removed false.

func (*BuildFiles) Rename

func (g *BuildFiles) Rename(ctx context.Context, in *FileRename, opts *RequestOptions) (*FileRenamed, error)

Rename Moves a file, a link or a directory; refused 409 when something is at its new path, unless overwrite. With sha256 or size, a file written in parts is put in place once whole: its writes ended, then only a file of that size with every byte written and whose bytes hash to it moves; refused 409 `upload_incomplete` or `checksum_mismatch`, nothing moved. With sha256, it is safe to send again: once moved, it returns the same answer while `from` is gone and `to` holds those bytes.

func (g *BuildFiles) RevokeLinks(ctx context.Context, opts *RequestOptions) (*FileLinksRevoked, error)

RevokeLinks Ends every file link made for a build so far; links made after work.

func (*BuildFiles) Stat

func (g *BuildFiles) Stat(ctx context.Context, path string, q *BuildStatQuery, opts *RequestOptions) (*FileInfo, error)

Stat Returns what is at a path: a file, a directory or a link, or nothing (exists false). With sha256=true, a file's SHA-256 too.

func (*BuildFiles) UploadFolder

func (g *BuildFiles) UploadFolder(ctx context.Context, path string, data []byte, q *BuildUploadFolderQuery, opts *RequestOptions) (*FolderUnpacked, error)

UploadFolder Unpacks the request's tar archive (gzip-compressed or not, told by its first bytes) into a folder, made with its parents, by tar in the build as the bytes arrive, of any size, nothing of it kept on disk but what tar writes; returns once tar has ended, or 400 `invalid_archive` with what tar said. A paused build is woken first.

func (*BuildFiles) Write

func (g *BuildFiles) Write(ctx context.Context, path string, data []byte, q *BuildWriteQuery, opts *RequestOptions) (*FileWritten, error)

Write Writes the request's bytes to a file as they come, of any size (Content-Length required), its folders made: the file whole when they all came, or as it was. With offset, they are written into it in place.

func (*BuildFiles) WriteFolderUpload

func (g *BuildFiles) WriteFolderUpload(ctx context.Context, upload string, data []byte, q *BuildWriteFolderUploadQuery, opts *RequestOptions) (*FolderUploadReceived, error)

WriteFolderUpload Sends the request's bytes, a part of the archive at its offset, into tar's input as they arrive, of any size, and returns the bytes received in all once tar took them. A part past them is refused 409 `upload_incomplete`, naming them: send the parts in order.

type BuildGetQuery

type BuildGetQuery struct {
	// Wait Seconds to wait, at most 60, for its state to differ from `ifState`; it answers once it does, or as it is when the wait ends. At least 0. At most 60.
	Wait *float64
	// IfState The state the caller last read, which `wait` waits for it to leave.
	IfState *string
}

BuildGetQuery is what Get takes in its query.

type BuildListFilesQuery

type BuildListFilesQuery struct {
	// Path The directory. Default: "/workspace".
	Path *string
	// Depth How deep to list. At least 1. At most 10. Default: 1.
	Depth *int64
	// Limit At most this many entries. At least 1. At most 2000. Default: 2000.
	Limit *int64
	// Hidden List entries whose names start with a dot. Default: true.
	Hidden *bool
	// Glob Only entries whose path relative to the directory matches: `*` within a name, `**` across folders, `?` one character, `{a,b}` either (`**/*.py`); at most 512 characters, 32 wildcards and 64 texts in braces. The listing then reaches as deep as the glob does (10 folders for `**`) unless depth says, and is searched past its first 2,000 entries, up to 50,000. At most 512 characters.
	Glob *string
}

BuildListFilesQuery is what ListFiles takes in its query.

type BuildListQuery

type BuildListQuery struct {
	// State Only those in these states, comma-separated.
	State *string
	// Name Only the build of this name.
	Name *string
	// Label Only those with every label given (repeat it for several): key:value, or a key for any value.
	Label []string
	// Cursor Where the page starts: a page's `next`.
	Cursor *string
	// Limit The most items the page holds. At least 1. At most 200. Default: 50.
	Limit *int64
}

BuildListQuery is what List takes in its query.

type BuildMetricsQuery

type BuildMetricsQuery struct {
	// Range The window: `15m`, `1h`, `6h`, `24h`, `7d` or `30d`. Default: "1h".
	Range *string
}

BuildMetricsQuery is what Metrics takes in its query.

type BuildNetwork

type BuildNetwork struct {
	// contains filtered or unexported fields
}

BuildNetwork is a build's network.

func (*BuildNetwork) Get

Get Returns where a build may connect out.

func (*BuildNetwork) Set

Set Replaces where a build may connect out, for its next connection and within a second for its open ones: those the new rules refuse are cut.

type BuildProcessOutputQuery

type BuildProcessOutputQuery struct {
	// Cursor Output after this byte. At least 0. Default: 0.
	Cursor *int64
	// WaitSeconds Seconds to wait for output past the cursor or its exit, at most 8. At least 0. At most 8.
	WaitSeconds *float64
	// MaxBytes At most this many bytes. At least 4096. At most 196608. Default: 65536.
	MaxBytes *int64
	// Follow Answer as NDJSON events from the cursor until it exits (stdout, stderr, truncated, exit; continue with the cursor to follow on from), as `Accept: application/x-ndjson` does.
	Follow *bool
}

BuildProcessOutputQuery is what ProcessOutput takes in its query.

type BuildProcesses

type BuildProcesses struct {
	// contains filtered or unexported fields
}

BuildProcesses is a build's processes.

func (*BuildProcesses) List

List Lists a build's processes, newest first: those running and those that ended lately.

func (*BuildProcesses) Output

Output Returns a process's output after a cursor, and the cursor to read on from. The latest 1 MiB is kept; truncated says when the cursor fell behind.

func (*BuildProcesses) Resize

func (g *BuildProcesses) Resize(ctx context.Context, process string, in *Terminal, opts *RequestOptions) (*Process, error)

Resize Resizes the terminal of a process started with a pty (its window's columns and rows, which the process is told by SIGWINCH), and returns the process; refused 409 for a process without one. A process that ended is left as it is, so a retry is safe.

func (*BuildProcesses) Signal

func (g *BuildProcesses) Signal(ctx context.Context, process string, in *ProcessSignal, opts *RequestOptions) (*Process, error)

Signal Sends a signal to a process and its group; a process that ended is not signalled, so a retry is safe.

func (*BuildProcesses) Write

func (g *BuildProcesses) Write(ctx context.Context, process string, in *ProcessInput, opts *RequestOptions) (*ProcessWritten, error)

Write Sends input to a process started with stdinOpen or a pty, and returns how much of its input it has taken.

type BuildReadQuery

type BuildReadQuery struct {
	// Path The file's path in the machine.
	Path string
}

BuildReadQuery is what Read takes in its query.

type BuildScreenshotQuery

type BuildScreenshotQuery struct {
	// Format `png`, or `jpeg`: smaller and quicker to send, for a model that reads it. Default: "png".
	Format *string
	// Quality A jpeg's quality, 1 to 100. At least 1. At most 100. Default: 80.
	Quality *int64
}

BuildScreenshotQuery is what Screenshot takes in its query.

type BuildStatQuery

type BuildStatQuery struct {
	// Path The file's path in the machine.
	Path string
	// Sha256 Also return a file's SHA-256, read from its bytes: to check a file you put in place (files:rename with sha256) is whole. Default: false.
	Sha256 *bool
}

BuildStatQuery is what Stat takes in its query.

type BuildUploadFolderQuery

type BuildUploadFolderQuery struct {
	// Path The folder, absolute, such as `/workspace/app`: made with its parents.
	Path string
	// User Who unpacks it: `runtime` or `root`; the build's `user` when omitted.
	User *string
}

BuildUploadFolderQuery is what UploadFolder takes in its query.

type BuildWriteFolderUploadQuery

type BuildWriteFolderUploadQuery struct {
	// Offset Where the part starts in the archive: at most the bytes received so far. Bytes before them were taken already and are skipped, so a part sent again is never unpacked twice. At least 0. Default: 0.
	Offset *int64
}

BuildWriteFolderUploadQuery is what WriteFolderUpload takes in its query.

type BuildWriteQuery

type BuildWriteQuery struct {
	// Path The file's path in the machine.
	Path string
	// Mode Its mode, in octal (`644`).
	Mode *string
	// Offset Write the bytes into the file in place from this byte, keeping the bytes before and after them (the file is made when there is none); one that fails part way may leave its range written in part, so send it again. Parts of one file may be written so at once and in any order: write them to a new path, then rename it with its size and sha256 to put it in place whole. At least 0.
	Offset *int64
	// Sha256 The bytes' SHA-256 in hex: refused 409 `checksum_mismatch`, the file as it was, when they differ. Not with offset.
	Sha256 *string
}

BuildWriteQuery is what Write takes in its query.

type Builds

type Builds struct {
	// contains filtered or unexported fields
}

Builds The machine an image's build runs on: Docker's own builder (BuildKit), its run `runtime-image-build`, deleted once its image is made. Made by an image's create, and billed as any machine is, for the CPU it uses and the memory it holds while it builds.

func (*Builds) AbortFolderUpload

func (c *Builds) AbortFolderUpload(ctx context.Context, id string, upload string, opts *RequestOptions) (*FolderUploadAborted, error)

AbortFolderUpload Stops a folder upload's tar; what it unpacked so far stays.

func (*Builds) Act

func (c *Builds) Act(ctx context.Context, id string, in ActRequest, opts *RequestOptions) (*Acted, error)

Act Moves, clicks, drags and scrolls the mouse and types on the keyboard of a build's screen (its X display `:1`), each step in turn as one command, and returns where the mouse is then. It stops at the first step that fails, refused 409 `act_failed` naming it; refused 409 `display_not_running` when no display runs. A paused build is resumed first.

func (*Builds) BeginFolderUpload

func (c *Builds) BeginFolderUpload(ctx context.Context, id string, in FolderUploadBegin, opts *RequestOptions) (*FolderUpload, error)

BeginFolderUpload Begins a folder's upload in parts: tar starts in the build, unpacking into the folder each part as it arrives. Send the parts in order by offset (writeFolderUpload), then commitFolderUpload; an upload no call names for 10 minutes is ended. A paused build is woken first.

func (*Builds) CommitFolderUpload

func (c *Builds) CommitFolderUpload(ctx context.Context, id string, upload string, opts *RequestOptions) (*FolderUnpacked, error)

CommitFolderUpload Ends a folder upload's input and returns once tar has ended, as an exec returns once its command has: the folder, or 400 `invalid_archive` with what tar said. Sent again, it returns how tar ended. An upload no call has named for 10 minutes since its last part or commit is ended.

func (*Builds) Create

func (c *Builds) Create(ctx context.Context, in SandboxCreate, opts *RequestOptions) (*Build, error)

Create Creates a build. Asked again with the same Idempotency-Key, it returns the same build.

func (*Builds) Delete

func (c *Builds) Delete(ctx context.Context, id string, opts *RequestOptions) (*SandboxInfo, error)

Delete Deletes a build, its memory and its disk.

func (*Builds) DownloadFolder

func (c *Builds) DownloadFolder(ctx context.Context, id string, q BuildDownloadFolderQuery, opts *RequestOptions) ([]byte, error)

DownloadFolder Returns a folder as a tar archive (`application/x-tar`, or `application/gzip` with gzip), packed by tar in the build as it streams, of any size; its entries are relative to the folder (`./a.txt`). A folder that fails part way (a file it may not read, or one that changes as it is read) ends as an archive every tar reader refuses, never as a short one that reads whole. At most 4 at once in a build. A paused build is woken first.

func (*Builds) Exec

func (c *Builds) Exec(ctx context.Context, id string, in ExecRequest, opts *RequestOptions) (*Process, error)

Exec Runs a command as a process and returns it once it ended, with its output; with wait false, at once, while it runs. A paused build is resumed first. Asked again with the same Idempotency-Key, it runs nothing more: it returns the first run's process, waiting for its end while it runs.

func (*Builds) Fork

func (c *Builds) Fork(ctx context.Context, id string, in ForkRequest, opts *RequestOptions) (*Forked, error)

Fork Copies a build as it is now, memory and disk, into `count` copies of its own, each running on its host. Asked again with the same Idempotency-Key, it returns the same copies.

func (*Builds) Get

func (c *Builds) Get(ctx context.Context, id string, q BuildGetQuery, opts *RequestOptions) (*Build, error)

Get Returns a build.

func (*Builds) GetNetwork

func (c *Builds) GetNetwork(ctx context.Context, id string, opts *RequestOptions) (*SandboxNetwork, error)

GetNetwork Returns where a build may connect out.

func (c *Builds) Link(ctx context.Context, id string, in FileLinkCreate, opts *RequestOptions) (*FileLink, error)

Link Makes an expiring address for one file that anyone may open with no API key, from a browser, curl or another service: GET downloads it (Range works, so videos play and downloads resume; archive: true downloads a folder as .tar.gz), PUT with the raw body uploads it (up to maxBytes, written whole; Content-Length required). The link acts as the key that made it: an upload link needs write, and the link ends with its key, with revokeLinks or with its build. A paused build is woken for it unless wake is false. A port it serves is shared by a preview (previews.create), not a link.

func (*Builds) List

List Lists the project's builds, newest first.

func (*Builds) ListAll

ListAll is every item of every page List reads from q.Cursor (none: the first page), each page read as the last is used up.

func (*Builds) ListFiles

func (c *Builds) ListFiles(ctx context.Context, id string, q BuildListFilesQuery, opts *RequestOptions) (*FileList, error)

ListFiles Lists a directory's entries in path order, to a depth.

func (*Builds) ListProcesses

func (c *Builds) ListProcesses(ctx context.Context, id string, opts *RequestOptions) (*ProcessList, error)

ListProcesses Lists a build's processes, newest first: those running and those that ended lately.

func (*Builds) Metrics

Metrics Returns a build's CPU, memory, disks and pressure, as its host reads them from the build's own cgroup over a fifth of a second: never a call into the build, so it does not wake a paused one nor keep one from its idle pause. One that is not running has no reading.

func (*Builds) Mkdir

func (c *Builds) Mkdir(ctx context.Context, id string, in FileMkdir, opts *RequestOptions) (*FileMade, error)

Mkdir Makes a directory, and its parents unless parents is false. One there already is success, created false.

func (*Builds) Pause

func (c *Builds) Pause(ctx context.Context, id string, opts *RequestOptions) (*SandboxInfo, error)

Pause Pauses a build with its memory and disk kept. A call to it resumes it.

func (*Builds) ProcessOutput

func (c *Builds) ProcessOutput(ctx context.Context, id string, process string, q BuildProcessOutputQuery, opts *RequestOptions) (*ProcessOutput, error)

ProcessOutput Returns a process's output after a cursor, and the cursor to read on from. The latest 1 MiB is kept; truncated says when the cursor fell behind.

func (*Builds) Read

func (c *Builds) Read(ctx context.Context, id string, q BuildReadQuery, opts *RequestOptions) ([]byte, error)

Read Returns a file's bytes.

func (*Builds) Remove

func (c *Builds) Remove(ctx context.Context, id string, in FileRemove, opts *RequestOptions) (*FileRemoved, error)

Remove Removes a file, a link or a directory (recursive for one with contents). One missing is success, removed false.

func (*Builds) Rename

func (c *Builds) Rename(ctx context.Context, id string, in FileRename, opts *RequestOptions) (*FileRenamed, error)

Rename Moves a file, a link or a directory; refused 409 when something is at its new path, unless overwrite. With sha256 or size, a file written in parts is put in place once whole: its writes ended, then only a file of that size with every byte written and whose bytes hash to it moves; refused 409 `upload_incomplete` or `checksum_mismatch`, nothing moved. With sha256, it is safe to send again: once moved, it returns the same answer while `from` is gone and `to` holds those bytes.

func (*Builds) ResizeProcess

func (c *Builds) ResizeProcess(ctx context.Context, id string, process string, in Terminal, opts *RequestOptions) (*Process, error)

ResizeProcess Resizes the terminal of a process started with a pty (its window's columns and rows, which the process is told by SIGWINCH), and returns the process; refused 409 for a process without one. A process that ended is left as it is, so a retry is safe.

func (*Builds) Resume

func (c *Builds) Resume(ctx context.Context, id string, opts *RequestOptions) (*SandboxInfo, error)

Resume Resumes a paused build where it was, its memory and processes as they were.

func (c *Builds) RevokeLinks(ctx context.Context, id string, opts *RequestOptions) (*FileLinksRevoked, error)

RevokeLinks Ends every file link made for a build so far; links made after work.

func (*Builds) RunCode

func (c *Builds) RunCode(ctx context.Context, id string, in RunCode, opts *RequestOptions) (*CodeRun, error)

RunCode Runs a cell of Python in a build as a notebook does, in a Jupyter kernel it keeps running for the cell's `context`: variables, imports and functions stay for the next cell. Returns what it printed, its values and displays (text, HTML, images such as charts), and its exception with its traceback. The context's kernel starts on its first cell. A cell past `timeoutSeconds` is interrupted and its context kept. Refused 409 `kernel_not_installed` when the image has no ipykernel. A paused build is resumed first.

func (*Builds) Screenshot

func (c *Builds) Screenshot(ctx context.Context, id string, q BuildScreenshotQuery, opts *RequestOptions) ([]byte, error)

Screenshot Returns what a build's screen shows now, as `image/png` (or `image/jpeg`): its X display `:1`, whole. Refused 409 `display_not_running` when no display runs. A paused build is resumed first.

func (*Builds) SetNetwork

func (c *Builds) SetNetwork(ctx context.Context, id string, in NetworkRules, opts *RequestOptions) (*SandboxNetwork, error)

SetNetwork Replaces where a build may connect out, for its next connection and within a second for its open ones: those the new rules refuse are cut.

func (*Builds) SignalProcess

func (c *Builds) SignalProcess(ctx context.Context, id string, process string, in ProcessSignal, opts *RequestOptions) (*Process, error)

SignalProcess Sends a signal to a process and its group; a process that ended is not signalled, so a retry is safe.

func (*Builds) Snapshot

func (c *Builds) Snapshot(ctx context.Context, id string, in SnapshotRequest, opts *RequestOptions) (*Stored, error)

Snapshot Keeps a build's memory and disk as they are now, a snapshot to start builds from; with `image`, its disk alone as that image's next version. The build runs on. Asked again with the same Idempotency-Key, it returns the same snapshot.

func (*Builds) Stat

func (c *Builds) Stat(ctx context.Context, id string, q BuildStatQuery, opts *RequestOptions) (*FileInfo, error)

Stat Returns what is at a path: a file, a directory or a link, or nothing (exists false). With sha256=true, a file's SHA-256 too.

func (*Builds) Update

func (c *Builds) Update(ctx context.Context, id string, in MachineUpdate, opts *RequestOptions) (*SandboxInfo, error)

Update Changes its name, labels, idle pause, maxCost, autoWake, lifetime, delete protection, environment or sizes; each field left out stays as it is. A lifetime (`deleteAfterSeconds`) sent again before its end moves the end to that many seconds from now; 0 takes it off. A lifetime is refused (409 `delete_protected`) while `deleteProtection` is true. A running one holds a changed environment before this answers (a paused one's at its wake): each process it starts after the answer has it, and its running processes keep the one they started with. Its vCPUs, memory and disk grow while it runs, its commands running on. One paused or stopped is not woken for it: judged at once as a live resize is (past the vCPUs it was made with 409, over its organization's limits `quota_exceeded`), its new sizes are returned at once, and its next wake grows it to them before the call that woke it runs. A smaller size, or a machine starting or failed, is refused 409 naming why, and nothing is changed. With If-Match, made only while its revision is that one, else 412. Sent again with the same Idempotency-Key and body while it is the latest change, it returns the current state and changes nothing; the same key with a different body returns 409 idempotency_key_reused.

func (*Builds) UploadFolder

func (c *Builds) UploadFolder(ctx context.Context, id string, data []byte, q BuildUploadFolderQuery, opts *RequestOptions) (*FolderUnpacked, error)

UploadFolder Unpacks the request's tar archive (gzip-compressed or not, told by its first bytes) into a folder, made with its parents, by tar in the build as the bytes arrive, of any size, nothing of it kept on disk but what tar writes; returns once tar has ended, or 400 `invalid_archive` with what tar said. A paused build is woken first.

func (*Builds) Write

func (c *Builds) Write(ctx context.Context, id string, data []byte, q BuildWriteQuery, opts *RequestOptions) (*FileWritten, error)

Write Writes the request's bytes to a file as they come, of any size (Content-Length required), its folders made: the file whole when they all came, or as it was. With offset, they are written into it in place.

func (*Builds) WriteFolderUpload

func (c *Builds) WriteFolderUpload(ctx context.Context, id string, upload string, data []byte, q BuildWriteFolderUploadQuery, opts *RequestOptions) (*FolderUploadReceived, error)

WriteFolderUpload Sends the request's bytes, a part of the archive at its offset, into tar's input as they arrive, of any size, and returns the bytes received in all once tar took them. A part past them is refused 409 `upload_incomplete`, naming them: send the parts in order.

func (*Builds) WriteProcess

func (c *Builds) WriteProcess(ctx context.Context, id string, process string, in ProcessInput, opts *RequestOptions) (*ProcessWritten, error)

WriteProcess Sends input to a process started with stdinOpen or a pty, and returns how much of its input it has taken.

type Call

type Call struct {
	// Idempotent calls are sent again after a lost connection or a timeout:
	// the verb reads, or dedupes.
	Idempotent bool
	// Runs is set for a verb that runs as long as its caller lets it:
	// RunsSeconds, or to its end when nil or 0. Its answer begins at once; an error
	// after that is said in its body, and a cut one is followed on by
	// sending it again under the same idempotency key.
	Runs        bool
	RunsSeconds *float64
}

Call is what a verb's call tells its transport.

type ChunkStored

type ChunkStored struct {
	// Sha256 Its SHA-256.
	Sha256 string `json:"sha256"`
	// Size Its size in bytes.
	Size int64 `json:"size"`
	// Stored Stored by this call: false when the build context held it already.
	Stored bool `json:"stored"`
}

ChunkStored A chunk of a build's context, uploaded.

type Ci

type Ci struct {
	// contains filtered or unexported fields
}

Ci A machine that runs a repository's checks to their end (its `run`) with git, Docker, Node, Bun, Python and a compiler, and is stopped then. As an Actions runner, it starts GitHub's runner for the one job of its just-in-time configuration (`run` `runtime-runner`, `RUNNER_JITCONFIG` in its environment) and stops with it; a job of a GitHub account connected through Runtime's GitHub App gets one by itself.

func (*Ci) AbortFolderUpload

func (c *Ci) AbortFolderUpload(ctx context.Context, id string, upload string, opts *RequestOptions) (*FolderUploadAborted, error)

AbortFolderUpload Stops a folder upload's tar; what it unpacked so far stays.

func (*Ci) Act

func (c *Ci) Act(ctx context.Context, id string, in ActRequest, opts *RequestOptions) (*Acted, error)

Act Moves, clicks, drags and scrolls the mouse and types on the keyboard of a CI machine's screen (its X display `:1`), each step in turn as one command, and returns where the mouse is then. It stops at the first step that fails, refused 409 `act_failed` naming it; refused 409 `display_not_running` when no display runs. A paused ci is resumed first.

func (*Ci) BeginFolderUpload

func (c *Ci) BeginFolderUpload(ctx context.Context, id string, in FolderUploadBegin, opts *RequestOptions) (*FolderUpload, error)

BeginFolderUpload Begins a folder's upload in parts: tar starts in the ci, unpacking into the folder each part as it arrives. Send the parts in order by offset (writeFolderUpload), then commitFolderUpload; an upload no call names for 10 minutes is ended. A paused ci is woken first.

func (*Ci) CommitFolderUpload

func (c *Ci) CommitFolderUpload(ctx context.Context, id string, upload string, opts *RequestOptions) (*FolderUnpacked, error)

CommitFolderUpload Ends a folder upload's input and returns once tar has ended, as an exec returns once its command has: the folder, or 400 `invalid_archive` with what tar said. Sent again, it returns how tar ended. An upload no call has named for 10 minutes since its last part or commit is ended.

func (*Ci) Connect added in v2.1.0

func (c *Ci) Connect(ctx context.Context, in CiConnect, opts *RequestOptions) (*CiConnection, error)

Connect Runs a GitHub repository's Actions jobs on Runtime, by a pull request "Run CI on Runtime" that changes each `runs-on` line of a GitHub-hosted Linux x64 runner to the Runtime size of its vCPUs, and nothing else, so its own checks run on Runtime. Until Runtime's GitHub App is installed on the repository and connected to this organization, it answers `next`: a page a person opens, then the call is made again. Then it answers `push`, the change as a patch, which the caller's own git commits and pushes as its branch (Runtime's App never writes a workflow); called again, it opens the pull request from that branch. Asked again, it returns the same pull request while it is open. Refused for a public repository: Runtime runs Actions jobs for private repositories only.

func (*Ci) Create

func (c *Ci) Create(ctx context.Context, in SandboxCreate, opts *RequestOptions) (*CiMachine, error)

Create Creates a CI machine. Asked again with the same Idempotency-Key, it returns the same ci.

func (*Ci) Delete

func (c *Ci) Delete(ctx context.Context, id string, opts *RequestOptions) (*SandboxInfo, error)

Delete Deletes a CI machine, its memory and its disk.

func (*Ci) DownloadFolder

func (c *Ci) DownloadFolder(ctx context.Context, id string, q CiDownloadFolderQuery, opts *RequestOptions) ([]byte, error)

DownloadFolder Returns a folder as a tar archive (`application/x-tar`, or `application/gzip` with gzip), packed by tar in the ci as it streams, of any size; its entries are relative to the folder (`./a.txt`). A folder that fails part way (a file it may not read, or one that changes as it is read) ends as an archive every tar reader refuses, never as a short one that reads whole. At most 4 at once in a CI machine. A paused ci is woken first.

func (*Ci) Exec

func (c *Ci) Exec(ctx context.Context, id string, in ExecRequest, opts *RequestOptions) (*Process, error)

Exec Runs a command as a process and returns it once it ended, with its output; with wait false, at once, while it runs. A paused ci is resumed first. Asked again with the same Idempotency-Key, it runs nothing more: it returns the first run's process, waiting for its end while it runs.

func (*Ci) Fork

func (c *Ci) Fork(ctx context.Context, id string, in ForkRequest, opts *RequestOptions) (*Forked, error)

Fork Copies a CI machine as it is now, memory and disk, into `count` copies of its own, each running on its host. Asked again with the same Idempotency-Key, it returns the same copies.

func (*Ci) Get

func (c *Ci) Get(ctx context.Context, id string, q CiGetQuery, opts *RequestOptions) (*CiMachine, error)

Get Returns a CI machine.

func (*Ci) GetNetwork

func (c *Ci) GetNetwork(ctx context.Context, id string, opts *RequestOptions) (*SandboxNetwork, error)

GetNetwork Returns where a CI machine may connect out.

func (c *Ci) Link(ctx context.Context, id string, in FileLinkCreate, opts *RequestOptions) (*FileLink, error)

Link Makes an expiring address for one file that anyone may open with no API key, from a browser, curl or another service: GET downloads it (Range works, so videos play and downloads resume; archive: true downloads a folder as .tar.gz), PUT with the raw body uploads it (up to maxBytes, written whole; Content-Length required). The link acts as the key that made it: an upload link needs write, and the link ends with its key, with revokeLinks or with its ci. A paused ci is woken for it unless wake is false. A port it serves is shared by a preview (previews.create), not a link.

func (*Ci) List

func (c *Ci) List(ctx context.Context, q CiListQuery, opts *RequestOptions) (*Page[SandboxInfo], error)

List Lists the project's ci, newest first.

func (*Ci) ListAll

func (c *Ci) ListAll(ctx context.Context, q CiListQuery, opts *RequestOptions) iter.Seq2[SandboxInfo, error]

ListAll is every item of every page List reads from q.Cursor (none: the first page), each page read as the last is used up.

func (*Ci) ListFiles

func (c *Ci) ListFiles(ctx context.Context, id string, q CiListFilesQuery, opts *RequestOptions) (*FileList, error)

ListFiles Lists a directory's entries in path order, to a depth.

func (*Ci) ListProcesses

func (c *Ci) ListProcesses(ctx context.Context, id string, opts *RequestOptions) (*ProcessList, error)

ListProcesses Lists a CI machine's processes, newest first: those running and those that ended lately.

func (*Ci) Metrics

func (c *Ci) Metrics(ctx context.Context, id string, q CiMetricsQuery, opts *RequestOptions) (*SandboxMetrics, error)

Metrics Returns a CI machine's CPU, memory, disks and pressure, as its host reads them from the ci's own cgroup over a fifth of a second: never a call into the ci, so it does not wake a paused one nor keep one from its idle pause. One that is not running has no reading.

func (*Ci) Mkdir

func (c *Ci) Mkdir(ctx context.Context, id string, in FileMkdir, opts *RequestOptions) (*FileMade, error)

Mkdir Makes a directory, and its parents unless parents is false. One there already is success, created false.

func (*Ci) Pause

func (c *Ci) Pause(ctx context.Context, id string, opts *RequestOptions) (*SandboxInfo, error)

Pause Pauses a CI machine with its memory and disk kept. A call to it resumes it.

func (*Ci) ProcessOutput

func (c *Ci) ProcessOutput(ctx context.Context, id string, process string, q CiProcessOutputQuery, opts *RequestOptions) (*ProcessOutput, error)

ProcessOutput Returns a process's output after a cursor, and the cursor to read on from. The latest 1 MiB is kept; truncated says when the cursor fell behind.

func (*Ci) Read

func (c *Ci) Read(ctx context.Context, id string, q CiReadQuery, opts *RequestOptions) ([]byte, error)

Read Returns a file's bytes.

func (*Ci) Remove

func (c *Ci) Remove(ctx context.Context, id string, in FileRemove, opts *RequestOptions) (*FileRemoved, error)

Remove Removes a file, a link or a directory (recursive for one with contents). One missing is success, removed false.

func (*Ci) Rename

func (c *Ci) Rename(ctx context.Context, id string, in FileRename, opts *RequestOptions) (*FileRenamed, error)

Rename Moves a file, a link or a directory; refused 409 when something is at its new path, unless overwrite. With sha256 or size, a file written in parts is put in place once whole: its writes ended, then only a file of that size with every byte written and whose bytes hash to it moves; refused 409 `upload_incomplete` or `checksum_mismatch`, nothing moved. With sha256, it is safe to send again: once moved, it returns the same answer while `from` is gone and `to` holds those bytes.

func (*Ci) ResizeProcess

func (c *Ci) ResizeProcess(ctx context.Context, id string, process string, in Terminal, opts *RequestOptions) (*Process, error)

ResizeProcess Resizes the terminal of a process started with a pty (its window's columns and rows, which the process is told by SIGWINCH), and returns the process; refused 409 for a process without one. A process that ended is left as it is, so a retry is safe.

func (*Ci) Resume

func (c *Ci) Resume(ctx context.Context, id string, opts *RequestOptions) (*SandboxInfo, error)

Resume Resumes a paused ci where it was, its memory and processes as they were.

func (c *Ci) RevokeLinks(ctx context.Context, id string, opts *RequestOptions) (*FileLinksRevoked, error)

RevokeLinks Ends every file link made for a CI machine so far; links made after work.

func (*Ci) RunCode

func (c *Ci) RunCode(ctx context.Context, id string, in RunCode, opts *RequestOptions) (*CodeRun, error)

RunCode Runs a cell of Python in a CI machine as a notebook does, in a Jupyter kernel it keeps running for the cell's `context`: variables, imports and functions stay for the next cell. Returns what it printed, its values and displays (text, HTML, images such as charts), and its exception with its traceback. The context's kernel starts on its first cell. A cell past `timeoutSeconds` is interrupted and its context kept. Refused 409 `kernel_not_installed` when the image has no ipykernel. A paused ci is resumed first.

func (*Ci) Screenshot

func (c *Ci) Screenshot(ctx context.Context, id string, q CiScreenshotQuery, opts *RequestOptions) ([]byte, error)

Screenshot Returns what a CI machine's screen shows now, as `image/png` (or `image/jpeg`): its X display `:1`, whole. Refused 409 `display_not_running` when no display runs. A paused ci is resumed first.

func (*Ci) SetNetwork

func (c *Ci) SetNetwork(ctx context.Context, id string, in NetworkRules, opts *RequestOptions) (*SandboxNetwork, error)

SetNetwork Replaces where a CI machine may connect out, for its next connection and within a second for its open ones: those the new rules refuse are cut.

func (*Ci) SignalProcess

func (c *Ci) SignalProcess(ctx context.Context, id string, process string, in ProcessSignal, opts *RequestOptions) (*Process, error)

SignalProcess Sends a signal to a process and its group; a process that ended is not signalled, so a retry is safe.

func (*Ci) Snapshot

func (c *Ci) Snapshot(ctx context.Context, id string, in SnapshotRequest, opts *RequestOptions) (*Stored, error)

Snapshot Keeps a CI machine's memory and disk as they are now, a snapshot to start ci from; with `image`, its disk alone as that image's next version. The ci runs on. Asked again with the same Idempotency-Key, it returns the same snapshot.

func (*Ci) Stat

func (c *Ci) Stat(ctx context.Context, id string, q CiStatQuery, opts *RequestOptions) (*FileInfo, error)

Stat Returns what is at a path: a file, a directory or a link, or nothing (exists false). With sha256=true, a file's SHA-256 too.

func (*Ci) Update

func (c *Ci) Update(ctx context.Context, id string, in MachineUpdate, opts *RequestOptions) (*SandboxInfo, error)

Update Changes its name, labels, idle pause, maxCost, autoWake, lifetime, delete protection, environment or sizes; each field left out stays as it is. A lifetime (`deleteAfterSeconds`) sent again before its end moves the end to that many seconds from now; 0 takes it off. A lifetime is refused (409 `delete_protected`) while `deleteProtection` is true. A running one holds a changed environment before this answers (a paused one's at its wake): each process it starts after the answer has it, and its running processes keep the one they started with. Its vCPUs, memory and disk grow while it runs, its commands running on. One paused or stopped is not woken for it: judged at once as a live resize is (past the vCPUs it was made with 409, over its organization's limits `quota_exceeded`), its new sizes are returned at once, and its next wake grows it to them before the call that woke it runs. A smaller size, or a machine starting or failed, is refused 409 naming why, and nothing is changed. With If-Match, made only while its revision is that one, else 412. Sent again with the same Idempotency-Key and body while it is the latest change, it returns the current state and changes nothing; the same key with a different body returns 409 idempotency_key_reused.

func (*Ci) UploadFolder

func (c *Ci) UploadFolder(ctx context.Context, id string, data []byte, q CiUploadFolderQuery, opts *RequestOptions) (*FolderUnpacked, error)

UploadFolder Unpacks the request's tar archive (gzip-compressed or not, told by its first bytes) into a folder, made with its parents, by tar in the ci as the bytes arrive, of any size, nothing of it kept on disk but what tar writes; returns once tar has ended, or 400 `invalid_archive` with what tar said. A paused ci is woken first.

func (*Ci) Write

func (c *Ci) Write(ctx context.Context, id string, data []byte, q CiWriteQuery, opts *RequestOptions) (*FileWritten, error)

Write Writes the request's bytes to a file as they come, of any size (Content-Length required), its folders made: the file whole when they all came, or as it was. With offset, they are written into it in place.

func (*Ci) WriteFolderUpload

func (c *Ci) WriteFolderUpload(ctx context.Context, id string, upload string, data []byte, q CiWriteFolderUploadQuery, opts *RequestOptions) (*FolderUploadReceived, error)

WriteFolderUpload Sends the request's bytes, a part of the archive at its offset, into tar's input as they arrive, of any size, and returns the bytes received in all once tar took them. A part past them is refused 409 `upload_incomplete`, naming them: send the parts in order.

func (*Ci) WriteProcess

func (c *Ci) WriteProcess(ctx context.Context, id string, process string, in ProcessInput, opts *RequestOptions) (*ProcessWritten, error)

WriteProcess Sends input to a process started with stdinOpen or a pty, and returns how much of its input it has taken.

type CiCheck added in v2.1.0

type CiCheck struct {
	// Name The job's name.
	Name string `json:"name"`
	// Url Its page on GitHub, with its log as it runs.
	Url string `json:"url"`
}

CiCheck A check of the pull request, on GitHub.

type CiConnect added in v2.1.0

type CiConnect struct {
	// Repository The GitHub repository, `owner/name`. At least 3 characters. At most 200 characters.
	Repository string `json:"repository"`
}

CiConnect A repository to run GitHub Actions jobs on Runtime.

type CiConnection added in v2.1.0

type CiConnection struct {
	// Object Always `ci_connection`.
	Object string `json:"object"`
	// Repository The repository, `owner/name`.
	Repository string `json:"repository"`
	// Status Where it stands: `needs_card`, `needs_install` or `needs_authorization` until a person acts at `next.url`; `needs_push` until the caller's git pushes `push`; then `opened`, or `up_to_date` when nothing is left to change.
	Status string `json:"status"`
	// Message What it tells a person, with the links they open.
	Message string `json:"message"`
	// Next What a person does next, while one must.
	Next *CiNextStep `json:"next,omitempty"`
	// Push The change the caller's git commits and pushes, then calls again.
	Push *CiPush `json:"push,omitempty"`
	// PullRequest The pull request that changes the `runs-on` lines.
	PullRequest *CiPullRequest `json:"pullRequest,omitempty"`
	// Check Its first check, once GitHub has started one.
	Check *CiCheck `json:"check,omitempty"`
	// Changed Each line the pull request changes.
	Changed []CiRunsOn `json:"changed"`
	// Unchanged Each `runs-on` line it leaves as it is, and why.
	Unchanged []CiRunsOn `json:"unchanged"`
	// Usage The last 30 days of the repository's jobs, priced on GitHub and on Runtime.
	Usage *CiUsage `json:"usage,omitempty"`
}

CiConnection A repository's connect: where it stands, and once done, its pull request.

type CiDownloadFolderQuery

type CiDownloadFolderQuery struct {
	// Path The folder, absolute, such as `/workspace/app`.
	Path string
	// Gzip Compress the archive with gzip. Default: false.
	Gzip *bool
	// User Who packs it: `runtime` or `root`; the ci's `user` when omitted.
	User *string
	// Exclude Paths in the folder to leave out, relative to it and comma-separated (`node_modules,.cache`): plain names, no wildcards, at most 32.
	Exclude *string
}

CiDownloadFolderQuery is what DownloadFolder takes in its query.

type CiGetQuery

type CiGetQuery struct {
	// Wait Seconds to wait, at most 60, for its state to differ from `ifState`; it answers once it does, or as it is when the wait ends. At least 0. At most 60.
	Wait *float64
	// IfState The state the caller last read, which `wait` waits for it to leave.
	IfState *string
}

CiGetQuery is what Get takes in its query.

type CiListFilesQuery

type CiListFilesQuery struct {
	// Path The directory. Default: "/workspace".
	Path *string
	// Depth How deep to list. At least 1. At most 10. Default: 1.
	Depth *int64
	// Limit At most this many entries. At least 1. At most 2000. Default: 2000.
	Limit *int64
	// Hidden List entries whose names start with a dot. Default: true.
	Hidden *bool
	// Glob Only entries whose path relative to the directory matches: `*` within a name, `**` across folders, `?` one character, `{a,b}` either (`**/*.py`); at most 512 characters, 32 wildcards and 64 texts in braces. The listing then reaches as deep as the glob does (10 folders for `**`) unless depth says, and is searched past its first 2,000 entries, up to 50,000. At most 512 characters.
	Glob *string
}

CiListFilesQuery is what ListFiles takes in its query.

type CiListQuery

type CiListQuery struct {
	// State Only those in these states, comma-separated.
	State *string
	// Name Only the ci of this name.
	Name *string
	// Label Only those with every label given (repeat it for several): key:value, or a key for any value.
	Label []string
	// Cursor Where the page starts: a page's `next`.
	Cursor *string
	// Limit The most items the page holds. At least 1. At most 200. Default: 50.
	Limit *int64
}

CiListQuery is what List takes in its query.

type CiMachine

type CiMachine struct {

	// Info is what it was when last read.
	Info      *SandboxInfo
	Files     *CiMachineFiles
	Processes *CiMachineProcesses
	Network   *CiMachineNetwork
	// contains filtered or unexported fields
}

CiMachine is one of ci: A machine that runs a repository's checks to their end (its `run`) with git, Docker, Node, Bun, Python and a compiler, and is stopped then. As an Actions runner, it starts GitHub's runner for the one job of its just-in-time configuration (`run` `runtime-runner`, `RUNNER_JITCONFIG` in its environment) and stops with it; a job of a GitHub account connected through Runtime's GitHub App gets one by itself.

func (*CiMachine) Act

func (s *CiMachine) Act(ctx context.Context, actions []Action, in *ActRequest, opts *RequestOptions) (*Acted, error)

Act Moves, clicks, drags and scrolls the mouse and types on the keyboard of a CI machine's screen (its X display `:1`), each step in turn as one command, and returns where the mouse is then. It stops at the first step that fails, refused 409 `act_failed` naming it; refused 409 `display_not_running` when no display runs. A paused ci is resumed first.

func (*CiMachine) Delete

func (s *CiMachine) Delete(ctx context.Context, opts *RequestOptions) (*SandboxInfo, error)

Delete Deletes a CI machine, its memory and its disk.

func (*CiMachine) Exec

func (s *CiMachine) Exec(ctx context.Context, cmd string, in *ExecRequest, opts *RequestOptions) (*Process, error)

Exec Runs a command as a process and returns it once it ended, with its output; with wait false, at once, while it runs. A paused ci is resumed first. Asked again with the same Idempotency-Key, it runs nothing more: it returns the first run's process, waiting for its end while it runs.

func (*CiMachine) Fork

func (s *CiMachine) Fork(ctx context.Context, in *ForkRequest, opts *RequestOptions) (*Forked, error)

Fork Copies a CI machine as it is now, memory and disk, into `count` copies of its own, each running on its host. Asked again with the same Idempotency-Key, it returns the same copies.

func (*CiMachine) ID

func (s *CiMachine) ID() string

ID is its id.

func (*CiMachine) Metrics

Metrics Returns a CI machine's CPU, memory, disks and pressure, as its host reads them from the ci's own cgroup over a fifth of a second: never a call into the ci, so it does not wake a paused one nor keep one from its idle pause. One that is not running has no reading.

func (*CiMachine) Pause

func (s *CiMachine) Pause(ctx context.Context, opts *RequestOptions) error

Pause Pauses a CI machine with its memory and disk kept. A call to it resumes it.

func (*CiMachine) Refresh

func (s *CiMachine) Refresh(ctx context.Context, q *CiGetQuery, opts *RequestOptions) error

Refresh Returns a CI machine.

func (*CiMachine) Resume

func (s *CiMachine) Resume(ctx context.Context, opts *RequestOptions) error

Resume Resumes a paused ci where it was, its memory and processes as they were.

func (*CiMachine) RunCode

func (s *CiMachine) RunCode(ctx context.Context, code string, in *RunCode, opts *RequestOptions) (*CodeRun, error)

RunCode Runs a cell of Python in a CI machine as a notebook does, in a Jupyter kernel it keeps running for the cell's `context`: variables, imports and functions stay for the next cell. Returns what it printed, its values and displays (text, HTML, images such as charts), and its exception with its traceback. The context's kernel starts on its first cell. A cell past `timeoutSeconds` is interrupted and its context kept. Refused 409 `kernel_not_installed` when the image has no ipykernel. A paused ci is resumed first.

func (*CiMachine) Screenshot

func (s *CiMachine) Screenshot(ctx context.Context, q *CiScreenshotQuery, opts *RequestOptions) ([]byte, error)

Screenshot Returns what a CI machine's screen shows now, as `image/png` (or `image/jpeg`): its X display `:1`, whole. Refused 409 `display_not_running` when no display runs. A paused ci is resumed first.

func (*CiMachine) Snapshot

func (s *CiMachine) Snapshot(ctx context.Context, in *SnapshotRequest, opts *RequestOptions) (*Stored, error)

Snapshot Keeps a CI machine's memory and disk as they are now, a snapshot to start ci from; with `image`, its disk alone as that image's next version. The ci runs on. Asked again with the same Idempotency-Key, it returns the same snapshot.

func (*CiMachine) Update

func (s *CiMachine) Update(ctx context.Context, in *MachineUpdate, opts *RequestOptions) error

Update Changes its name, labels, idle pause, maxCost, autoWake, lifetime, delete protection, environment or sizes; each field left out stays as it is. A lifetime (`deleteAfterSeconds`) sent again before its end moves the end to that many seconds from now; 0 takes it off. A lifetime is refused (409 `delete_protected`) while `deleteProtection` is true. A running one holds a changed environment before this answers (a paused one's at its wake): each process it starts after the answer has it, and its running processes keep the one they started with. Its vCPUs, memory and disk grow while it runs, its commands running on. One paused or stopped is not woken for it: judged at once as a live resize is (past the vCPUs it was made with 409, over its organization's limits `quota_exceeded`), its new sizes are returned at once, and its next wake grows it to them before the call that woke it runs. A smaller size, or a machine starting or failed, is refused 409 naming why, and nothing is changed. With If-Match, made only while its revision is that one, else 412. Sent again with the same Idempotency-Key and body while it is the latest change, it returns the current state and changes nothing; the same key with a different body returns 409 idempotency_key_reused.

type CiMachineFiles

type CiMachineFiles struct {
	// contains filtered or unexported fields
}

CiMachineFiles is a cimachine's files.

func (*CiMachineFiles) AbortFolderUpload

func (g *CiMachineFiles) AbortFolderUpload(ctx context.Context, upload string, opts *RequestOptions) (*FolderUploadAborted, error)

AbortFolderUpload Stops a folder upload's tar; what it unpacked so far stays.

func (*CiMachineFiles) BeginFolderUpload

func (g *CiMachineFiles) BeginFolderUpload(ctx context.Context, path string, in *FolderUploadBegin, opts *RequestOptions) (*FolderUpload, error)

BeginFolderUpload Begins a folder's upload in parts: tar starts in the ci, unpacking into the folder each part as it arrives. Send the parts in order by offset (writeFolderUpload), then commitFolderUpload; an upload no call names for 10 minutes is ended. A paused ci is woken first.

func (*CiMachineFiles) CommitFolderUpload

func (g *CiMachineFiles) CommitFolderUpload(ctx context.Context, upload string, opts *RequestOptions) (*FolderUnpacked, error)

CommitFolderUpload Ends a folder upload's input and returns once tar has ended, as an exec returns once its command has: the folder, or 400 `invalid_archive` with what tar said. Sent again, it returns how tar ended. An upload no call has named for 10 minutes since its last part or commit is ended.

func (*CiMachineFiles) DownloadFolder

func (g *CiMachineFiles) DownloadFolder(ctx context.Context, path string, q *CiDownloadFolderQuery, opts *RequestOptions) ([]byte, error)

DownloadFolder Returns a folder as a tar archive (`application/x-tar`, or `application/gzip` with gzip), packed by tar in the ci as it streams, of any size; its entries are relative to the folder (`./a.txt`). A folder that fails part way (a file it may not read, or one that changes as it is read) ends as an archive every tar reader refuses, never as a short one that reads whole. At most 4 at once in a CI machine. A paused ci is woken first.

func (g *CiMachineFiles) Link(ctx context.Context, path string, in *FileLinkCreate, opts *RequestOptions) (*FileLink, error)

Link Makes an expiring address for one file that anyone may open with no API key, from a browser, curl or another service: GET downloads it (Range works, so videos play and downloads resume; archive: true downloads a folder as .tar.gz), PUT with the raw body uploads it (up to maxBytes, written whole; Content-Length required). The link acts as the key that made it: an upload link needs write, and the link ends with its key, with revokeLinks or with its ci. A paused ci is woken for it unless wake is false. A port it serves is shared by a preview (previews.create), not a link.

func (*CiMachineFiles) List

List Lists a directory's entries in path order, to a depth.

func (*CiMachineFiles) Mkdir

func (g *CiMachineFiles) Mkdir(ctx context.Context, path string, in *FileMkdir, opts *RequestOptions) (*FileMade, error)

Mkdir Makes a directory, and its parents unless parents is false. One there already is success, created false.

func (*CiMachineFiles) Read

func (g *CiMachineFiles) Read(ctx context.Context, path string, q *CiReadQuery, opts *RequestOptions) ([]byte, error)

Read Returns a file's bytes.

func (*CiMachineFiles) Remove

func (g *CiMachineFiles) Remove(ctx context.Context, path string, in *FileRemove, opts *RequestOptions) (*FileRemoved, error)

Remove Removes a file, a link or a directory (recursive for one with contents). One missing is success, removed false.

func (*CiMachineFiles) Rename

func (g *CiMachineFiles) Rename(ctx context.Context, in *FileRename, opts *RequestOptions) (*FileRenamed, error)

Rename Moves a file, a link or a directory; refused 409 when something is at its new path, unless overwrite. With sha256 or size, a file written in parts is put in place once whole: its writes ended, then only a file of that size with every byte written and whose bytes hash to it moves; refused 409 `upload_incomplete` or `checksum_mismatch`, nothing moved. With sha256, it is safe to send again: once moved, it returns the same answer while `from` is gone and `to` holds those bytes.

func (g *CiMachineFiles) RevokeLinks(ctx context.Context, opts *RequestOptions) (*FileLinksRevoked, error)

RevokeLinks Ends every file link made for a CI machine so far; links made after work.

func (*CiMachineFiles) Stat

func (g *CiMachineFiles) Stat(ctx context.Context, path string, q *CiStatQuery, opts *RequestOptions) (*FileInfo, error)

Stat Returns what is at a path: a file, a directory or a link, or nothing (exists false). With sha256=true, a file's SHA-256 too.

func (*CiMachineFiles) UploadFolder

func (g *CiMachineFiles) UploadFolder(ctx context.Context, path string, data []byte, q *CiUploadFolderQuery, opts *RequestOptions) (*FolderUnpacked, error)

UploadFolder Unpacks the request's tar archive (gzip-compressed or not, told by its first bytes) into a folder, made with its parents, by tar in the ci as the bytes arrive, of any size, nothing of it kept on disk but what tar writes; returns once tar has ended, or 400 `invalid_archive` with what tar said. A paused ci is woken first.

func (*CiMachineFiles) Write

func (g *CiMachineFiles) Write(ctx context.Context, path string, data []byte, q *CiWriteQuery, opts *RequestOptions) (*FileWritten, error)

Write Writes the request's bytes to a file as they come, of any size (Content-Length required), its folders made: the file whole when they all came, or as it was. With offset, they are written into it in place.

func (*CiMachineFiles) WriteFolderUpload

func (g *CiMachineFiles) WriteFolderUpload(ctx context.Context, upload string, data []byte, q *CiWriteFolderUploadQuery, opts *RequestOptions) (*FolderUploadReceived, error)

WriteFolderUpload Sends the request's bytes, a part of the archive at its offset, into tar's input as they arrive, of any size, and returns the bytes received in all once tar took them. A part past them is refused 409 `upload_incomplete`, naming them: send the parts in order.

type CiMachineNetwork

type CiMachineNetwork struct {
	// contains filtered or unexported fields
}

CiMachineNetwork is a cimachine's network.

func (*CiMachineNetwork) Get

Get Returns where a CI machine may connect out.

func (*CiMachineNetwork) Set

Set Replaces where a CI machine may connect out, for its next connection and within a second for its open ones: those the new rules refuse are cut.

type CiMachineProcesses

type CiMachineProcesses struct {
	// contains filtered or unexported fields
}

CiMachineProcesses is a cimachine's processes.

func (*CiMachineProcesses) List

List Lists a CI machine's processes, newest first: those running and those that ended lately.

func (*CiMachineProcesses) Output

Output Returns a process's output after a cursor, and the cursor to read on from. The latest 1 MiB is kept; truncated says when the cursor fell behind.

func (*CiMachineProcesses) Resize

func (g *CiMachineProcesses) Resize(ctx context.Context, process string, in *Terminal, opts *RequestOptions) (*Process, error)

Resize Resizes the terminal of a process started with a pty (its window's columns and rows, which the process is told by SIGWINCH), and returns the process; refused 409 for a process without one. A process that ended is left as it is, so a retry is safe.

func (*CiMachineProcesses) Signal

func (g *CiMachineProcesses) Signal(ctx context.Context, process string, in *ProcessSignal, opts *RequestOptions) (*Process, error)

Signal Sends a signal to a process and its group; a process that ended is not signalled, so a retry is safe.

func (*CiMachineProcesses) Write

Write Sends input to a process started with stdinOpen or a pty, and returns how much of its input it has taken.

type CiMetricsQuery

type CiMetricsQuery struct {
	// Range The window: `15m`, `1h`, `6h`, `24h`, `7d` or `30d`. Default: "1h".
	Range *string
}

CiMetricsQuery is what Metrics takes in its query.

type CiNextStep added in v2.1.0

type CiNextStep struct {
	// Url The page to open, on Runtime's site.
	Url string `json:"url"`
	// Message What the page asks of them.
	Message string `json:"message"`
	// AgainSeconds Seconds to wait before calling again.
	AgainSeconds int64 `json:"againSeconds"`
}

CiNextStep What a person does before the connect goes on: open the page, then call again.

type CiProcessOutputQuery

type CiProcessOutputQuery struct {
	// Cursor Output after this byte. At least 0. Default: 0.
	Cursor *int64
	// WaitSeconds Seconds to wait for output past the cursor or its exit, at most 8. At least 0. At most 8.
	WaitSeconds *float64
	// MaxBytes At most this many bytes. At least 4096. At most 196608. Default: 65536.
	MaxBytes *int64
	// Follow Answer as NDJSON events from the cursor until it exits (stdout, stderr, truncated, exit; continue with the cursor to follow on from), as `Accept: application/x-ndjson` does.
	Follow *bool
}

CiProcessOutputQuery is what ProcessOutput takes in its query.

type CiPullRequest added in v2.1.0

type CiPullRequest struct {
	// Number Its number in the repository.
	Number int64 `json:"number"`
	// Url Its page on GitHub.
	Url string `json:"url"`
}

CiPullRequest A pull request on GitHub.

type CiPush added in v2.1.0

type CiPush struct {
	// Branch The branch to push it as.
	Branch string `json:"branch"`
	// Base The default branch it is made on.
	Base string `json:"base"`
	// Commit The default branch's commit it applies to, the new commit's parent.
	Commit string `json:"commit"`
	// Message The commit's message.
	Message string `json:"message"`
	// Patch The change, a unified diff of the workflow files against `commit` (`git apply` takes it).
	Patch string `json:"patch"`
}

CiPush The `runs-on` change, for the caller's own git to commit and push.

type CiReadQuery

type CiReadQuery struct {
	// Path The file's path in the machine.
	Path string
}

CiReadQuery is what Read takes in its query.

type CiRunsOn added in v2.1.0

type CiRunsOn struct {
	// File The workflow's file, from the repository's root.
	File string `json:"file"`
	// Line Its line number, from 1.
	Line int64 `json:"line"`
	// From Its labels as written.
	From string `json:"from"`
	// To Its labels in the pull request; omitted when it is left unchanged.
	To *string `json:"to,omitempty"`
	// Why Why it is left unchanged.
	Why *string `json:"why,omitempty"`
}

CiRunsOn One `runs-on` line of a workflow.

type CiScreenshotQuery

type CiScreenshotQuery struct {
	// Format `png`, or `jpeg`: smaller and quicker to send, for a model that reads it. Default: "png".
	Format *string
	// Quality A jpeg's quality, 1 to 100. At least 1. At most 100. Default: 80.
	Quality *int64
}

CiScreenshotQuery is what Screenshot takes in its query.

type CiStatQuery

type CiStatQuery struct {
	// Path The file's path in the machine.
	Path string
	// Sha256 Also return a file's SHA-256, read from its bytes: to check a file you put in place (files:rename with sha256) is whole. Default: false.
	Sha256 *bool
}

CiStatQuery is what Stat takes in its query.

type CiUploadFolderQuery

type CiUploadFolderQuery struct {
	// Path The folder, absolute, such as `/workspace/app`: made with its parents.
	Path string
	// User Who unpacks it: `runtime` or `root`; the ci's `user` when omitted.
	User *string
}

CiUploadFolderQuery is what UploadFolder takes in its query.

type CiUsage added in v2.1.0

type CiUsage struct {
	// Days The days read, up to today.
	Days int64 `json:"days"`
	// Runs The workflow runs in those days.
	Runs int64 `json:"runs"`
	// Read The runs whose jobs were read: the newest, when there were more than are read.
	Read int64 `json:"read"`
	// Minutes Minutes GitHub billed for the jobs this pull request moves (each job rounded up to a minute), counted over the runs read and scaled to every run.
	Minutes int64 `json:"minutes"`
	// GithubCost What those minutes cost on GitHub, at its published per-minute rates.
	GithubCost string `json:"githubCost"`
	// RuntimeCost What they cost on Runtime, by the second, at its per-vCPU-minute rate for each runner's size.
	RuntimeCost string `json:"runtimeCost"`
	// OtherMinutes Minutes of jobs that stay where they run (macOS, Windows, ARM, other runners).
	OtherMinutes int64 `json:"otherMinutes"`
}

CiUsage The repository's GitHub Actions jobs over the last days, priced on GitHub and on Runtime.

type CiWriteFolderUploadQuery

type CiWriteFolderUploadQuery struct {
	// Offset Where the part starts in the archive: at most the bytes received so far. Bytes before them were taken already and are skipped, so a part sent again is never unpacked twice. At least 0. Default: 0.
	Offset *int64
}

CiWriteFolderUploadQuery is what WriteFolderUpload takes in its query.

type CiWriteQuery

type CiWriteQuery struct {
	// Path The file's path in the machine.
	Path string
	// Mode Its mode, in octal (`644`).
	Mode *string
	// Offset Write the bytes into the file in place from this byte, keeping the bytes before and after them (the file is made when there is none); one that fails part way may leave its range written in part, so send it again. Parts of one file may be written so at once and in any order: write them to a new path, then rename it with its size and sha256 to put it in place whole. At least 0.
	Offset *int64
	// Sha256 The bytes' SHA-256 in hex: refused 409 `checksum_mismatch`, the file as it was, when they differ. Not with offset.
	Sha256 *string
}

CiWriteQuery is what Write takes in its query.

type CodeError

type CodeError struct {
	// Name Its name (`ZeroDivisionError`).
	Name string `json:"name"`
	// Value Its message.
	Value string `json:"value"`
	// Traceback Its traceback, as text.
	Traceback string `json:"traceback"`
}

CodeError The exception a cell raised.

type CodeResult

type CodeResult struct {
	// Main The cell's own value (its last expression), rather than a display.
	Main bool `json:"main"`
	// Text As plain text (`text/plain`).
	Text *string `json:"text,omitempty"`
	// Html As HTML (`text/html`): a table, for a DataFrame.
	Html *string `json:"html,omitempty"`
	// Markdown As Markdown (`text/markdown`).
	Markdown *string `json:"markdown,omitempty"`
	// Json As JSON text (`application/json`).
	Json *string `json:"json,omitempty"`
	// Png As a PNG image (`image/png`): a chart.
	Png *string `json:"png,omitempty"`
	// Jpeg As a JPEG image (`image/jpeg`).
	Jpeg *string `json:"jpeg,omitempty"`
	// Svg As an SVG image (`image/svg+xml`).
	Svg *string `json:"svg,omitempty"`
	// Latex As LaTeX (`text/latex`).
	Latex *string `json:"latex,omitempty"`
}

CodeResult One value a cell returned or displayed, in each form it gave.

type CodeRun

type CodeRun struct {
	// Context The context it ran in.
	Context string `json:"context"`
	// Language Its language.
	Language string `json:"language"`
	// Status `ok`; `error`, an exception (`error`); `timeout`, interrupted at its time, its context kept.
	Status string `json:"status"`
	// ExecutionCount Its number in its context, as a notebook counts cells.
	ExecutionCount *int64 `json:"executionCount,omitempty"`
	// Stdout What it printed.
	Stdout string `json:"stdout"`
	// Stderr What it wrote to standard error.
	Stderr string `json:"stderr"`
	// Results The values it returned and displayed, in order.
	Results []CodeResult `json:"results"`
	// Error The exception it raised.
	Error *CodeError `json:"error,omitempty"`
	// Started Whether its context's kernel was started for it: its first cell, or one after the kernel ended.
	Started bool `json:"started"`
	// DurationSeconds How long it ran, in seconds.
	DurationSeconds float64 `json:"durationSeconds"`
}

CodeRun A cell that ran.

type Container

type Container struct {

	// Info is what it was when last read.
	Info      *SandboxInfo
	Files     *ContainerFiles
	Processes *ContainerProcesses
	Network   *ContainerNetwork
	// contains filtered or unexported fields
}

Container is one of containers: A machine that runs one OCI image from any registry under Docker on its own network (`start` `runtime-container <image>`), the port it listens on reached at its preview, as Cloud Run and Fly Machines run one.

func (*Container) Act

func (s *Container) Act(ctx context.Context, actions []Action, in *ActRequest, opts *RequestOptions) (*Acted, error)

Act Moves, clicks, drags and scrolls the mouse and types on the keyboard of a container's screen (its X display `:1`), each step in turn as one command, and returns where the mouse is then. It stops at the first step that fails, refused 409 `act_failed` naming it; refused 409 `display_not_running` when no display runs. A paused container is resumed first.

func (*Container) Delete

func (s *Container) Delete(ctx context.Context, opts *RequestOptions) (*SandboxInfo, error)

Delete Deletes a container, its memory and its disk.

func (*Container) Exec

func (s *Container) Exec(ctx context.Context, cmd string, in *ExecRequest, opts *RequestOptions) (*Process, error)

Exec Runs a command as a process and returns it once it ended, with its output; with wait false, at once, while it runs. A paused container is resumed first. Asked again with the same Idempotency-Key, it runs nothing more: it returns the first run's process, waiting for its end while it runs.

func (*Container) Fork

func (s *Container) Fork(ctx context.Context, in *ForkRequest, opts *RequestOptions) (*Forked, error)

Fork Copies a container as it is now, memory and disk, into `count` copies of its own, each running on its host. Asked again with the same Idempotency-Key, it returns the same copies.

func (*Container) ID

func (s *Container) ID() string

ID is its id.

func (*Container) Metrics

Metrics Returns a container's CPU, memory, disks and pressure, as its host reads them from the container's own cgroup over a fifth of a second: never a call into the container, so it does not wake a paused one nor keep one from its idle pause. One that is not running has no reading.

func (*Container) Pause

func (s *Container) Pause(ctx context.Context, opts *RequestOptions) error

Pause Pauses a container with its memory and disk kept. A call to it resumes it.

func (*Container) Refresh

func (s *Container) Refresh(ctx context.Context, q *ContainerGetQuery, opts *RequestOptions) error

Refresh Returns a container.

func (*Container) Resume

func (s *Container) Resume(ctx context.Context, opts *RequestOptions) error

Resume Resumes a paused container where it was, its memory and processes as they were.

func (*Container) RunCode

func (s *Container) RunCode(ctx context.Context, code string, in *RunCode, opts *RequestOptions) (*CodeRun, error)

RunCode Runs a cell of Python in a container as a notebook does, in a Jupyter kernel it keeps running for the cell's `context`: variables, imports and functions stay for the next cell. Returns what it printed, its values and displays (text, HTML, images such as charts), and its exception with its traceback. The context's kernel starts on its first cell. A cell past `timeoutSeconds` is interrupted and its context kept. Refused 409 `kernel_not_installed` when the image has no ipykernel. A paused container is resumed first.

func (*Container) Screenshot

func (s *Container) Screenshot(ctx context.Context, q *ContainerScreenshotQuery, opts *RequestOptions) ([]byte, error)

Screenshot Returns what a container's screen shows now, as `image/png` (or `image/jpeg`): its X display `:1`, whole. Refused 409 `display_not_running` when no display runs. A paused container is resumed first.

func (*Container) Snapshot

func (s *Container) Snapshot(ctx context.Context, in *SnapshotRequest, opts *RequestOptions) (*Stored, error)

Snapshot Keeps a container's memory and disk as they are now, a snapshot to start containers from; with `image`, its disk alone as that image's next version. The container runs on. Asked again with the same Idempotency-Key, it returns the same snapshot.

func (*Container) Update

func (s *Container) Update(ctx context.Context, in *MachineUpdate, opts *RequestOptions) error

Update Changes its name, labels, idle pause, maxCost, autoWake, lifetime, delete protection, environment or sizes; each field left out stays as it is. A lifetime (`deleteAfterSeconds`) sent again before its end moves the end to that many seconds from now; 0 takes it off. A lifetime is refused (409 `delete_protected`) while `deleteProtection` is true. A running one holds a changed environment before this answers (a paused one's at its wake): each process it starts after the answer has it, and its running processes keep the one they started with. Its vCPUs, memory and disk grow while it runs, its commands running on. One paused or stopped is not woken for it: judged at once as a live resize is (past the vCPUs it was made with 409, over its organization's limits `quota_exceeded`), its new sizes are returned at once, and its next wake grows it to them before the call that woke it runs. A smaller size, or a machine starting or failed, is refused 409 naming why, and nothing is changed. With If-Match, made only while its revision is that one, else 412. Sent again with the same Idempotency-Key and body while it is the latest change, it returns the current state and changes nothing; the same key with a different body returns 409 idempotency_key_reused.

type ContainerDownloadFolderQuery

type ContainerDownloadFolderQuery struct {
	// Path The folder, absolute, such as `/workspace/app`.
	Path string
	// Gzip Compress the archive with gzip. Default: false.
	Gzip *bool
	// User Who packs it: `runtime` or `root`; the container's `user` when omitted.
	User *string
	// Exclude Paths in the folder to leave out, relative to it and comma-separated (`node_modules,.cache`): plain names, no wildcards, at most 32.
	Exclude *string
}

ContainerDownloadFolderQuery is what DownloadFolder takes in its query.

type ContainerFiles

type ContainerFiles struct {
	// contains filtered or unexported fields
}

ContainerFiles is a container's files.

func (*ContainerFiles) AbortFolderUpload

func (g *ContainerFiles) AbortFolderUpload(ctx context.Context, upload string, opts *RequestOptions) (*FolderUploadAborted, error)

AbortFolderUpload Stops a folder upload's tar; what it unpacked so far stays.

func (*ContainerFiles) BeginFolderUpload

func (g *ContainerFiles) BeginFolderUpload(ctx context.Context, path string, in *FolderUploadBegin, opts *RequestOptions) (*FolderUpload, error)

BeginFolderUpload Begins a folder's upload in parts: tar starts in the container, unpacking into the folder each part as it arrives. Send the parts in order by offset (writeFolderUpload), then commitFolderUpload; an upload no call names for 10 minutes is ended. A paused container is woken first.

func (*ContainerFiles) CommitFolderUpload

func (g *ContainerFiles) CommitFolderUpload(ctx context.Context, upload string, opts *RequestOptions) (*FolderUnpacked, error)

CommitFolderUpload Ends a folder upload's input and returns once tar has ended, as an exec returns once its command has: the folder, or 400 `invalid_archive` with what tar said. Sent again, it returns how tar ended. An upload no call has named for 10 minutes since its last part or commit is ended.

func (*ContainerFiles) DownloadFolder

func (g *ContainerFiles) DownloadFolder(ctx context.Context, path string, q *ContainerDownloadFolderQuery, opts *RequestOptions) ([]byte, error)

DownloadFolder Returns a folder as a tar archive (`application/x-tar`, or `application/gzip` with gzip), packed by tar in the container as it streams, of any size; its entries are relative to the folder (`./a.txt`). A folder that fails part way (a file it may not read, or one that changes as it is read) ends as an archive every tar reader refuses, never as a short one that reads whole. At most 4 at once in a container. A paused container is woken first.

func (g *ContainerFiles) Link(ctx context.Context, path string, in *FileLinkCreate, opts *RequestOptions) (*FileLink, error)

Link Makes an expiring address for one file that anyone may open with no API key, from a browser, curl or another service: GET downloads it (Range works, so videos play and downloads resume; archive: true downloads a folder as .tar.gz), PUT with the raw body uploads it (up to maxBytes, written whole; Content-Length required). The link acts as the key that made it: an upload link needs write, and the link ends with its key, with revokeLinks or with its container. A paused container is woken for it unless wake is false. A port it serves is shared by a preview (previews.create), not a link.

func (*ContainerFiles) List

List Lists a directory's entries in path order, to a depth.

func (*ContainerFiles) Mkdir

func (g *ContainerFiles) Mkdir(ctx context.Context, path string, in *FileMkdir, opts *RequestOptions) (*FileMade, error)

Mkdir Makes a directory, and its parents unless parents is false. One there already is success, created false.

func (*ContainerFiles) Read

func (g *ContainerFiles) Read(ctx context.Context, path string, q *ContainerReadQuery, opts *RequestOptions) ([]byte, error)

Read Returns a file's bytes.

func (*ContainerFiles) Remove

func (g *ContainerFiles) Remove(ctx context.Context, path string, in *FileRemove, opts *RequestOptions) (*FileRemoved, error)

Remove Removes a file, a link or a directory (recursive for one with contents). One missing is success, removed false.

func (*ContainerFiles) Rename

func (g *ContainerFiles) Rename(ctx context.Context, in *FileRename, opts *RequestOptions) (*FileRenamed, error)

Rename Moves a file, a link or a directory; refused 409 when something is at its new path, unless overwrite. With sha256 or size, a file written in parts is put in place once whole: its writes ended, then only a file of that size with every byte written and whose bytes hash to it moves; refused 409 `upload_incomplete` or `checksum_mismatch`, nothing moved. With sha256, it is safe to send again: once moved, it returns the same answer while `from` is gone and `to` holds those bytes.

func (g *ContainerFiles) RevokeLinks(ctx context.Context, opts *RequestOptions) (*FileLinksRevoked, error)

RevokeLinks Ends every file link made for a container so far; links made after work.

func (*ContainerFiles) Stat

Stat Returns what is at a path: a file, a directory or a link, or nothing (exists false). With sha256=true, a file's SHA-256 too.

func (*ContainerFiles) UploadFolder

func (g *ContainerFiles) UploadFolder(ctx context.Context, path string, data []byte, q *ContainerUploadFolderQuery, opts *RequestOptions) (*FolderUnpacked, error)

UploadFolder Unpacks the request's tar archive (gzip-compressed or not, told by its first bytes) into a folder, made with its parents, by tar in the container as the bytes arrive, of any size, nothing of it kept on disk but what tar writes; returns once tar has ended, or 400 `invalid_archive` with what tar said. A paused container is woken first.

func (*ContainerFiles) Write

func (g *ContainerFiles) Write(ctx context.Context, path string, data []byte, q *ContainerWriteQuery, opts *RequestOptions) (*FileWritten, error)

Write Writes the request's bytes to a file as they come, of any size (Content-Length required), its folders made: the file whole when they all came, or as it was. With offset, they are written into it in place.

func (*ContainerFiles) WriteFolderUpload

func (g *ContainerFiles) WriteFolderUpload(ctx context.Context, upload string, data []byte, q *ContainerWriteFolderUploadQuery, opts *RequestOptions) (*FolderUploadReceived, error)

WriteFolderUpload Sends the request's bytes, a part of the archive at its offset, into tar's input as they arrive, of any size, and returns the bytes received in all once tar took them. A part past them is refused 409 `upload_incomplete`, naming them: send the parts in order.

type ContainerGetQuery

type ContainerGetQuery struct {
	// Wait Seconds to wait, at most 60, for its state to differ from `ifState`; it answers once it does, or as it is when the wait ends. At least 0. At most 60.
	Wait *float64
	// IfState The state the caller last read, which `wait` waits for it to leave.
	IfState *string
}

ContainerGetQuery is what Get takes in its query.

type ContainerListFilesQuery

type ContainerListFilesQuery struct {
	// Path The directory. Default: "/workspace".
	Path *string
	// Depth How deep to list. At least 1. At most 10. Default: 1.
	Depth *int64
	// Limit At most this many entries. At least 1. At most 2000. Default: 2000.
	Limit *int64
	// Hidden List entries whose names start with a dot. Default: true.
	Hidden *bool
	// Glob Only entries whose path relative to the directory matches: `*` within a name, `**` across folders, `?` one character, `{a,b}` either (`**/*.py`); at most 512 characters, 32 wildcards and 64 texts in braces. The listing then reaches as deep as the glob does (10 folders for `**`) unless depth says, and is searched past its first 2,000 entries, up to 50,000. At most 512 characters.
	Glob *string
}

ContainerListFilesQuery is what ListFiles takes in its query.

type ContainerListQuery

type ContainerListQuery struct {
	// State Only those in these states, comma-separated.
	State *string
	// Name Only the container of this name.
	Name *string
	// Label Only those with every label given (repeat it for several): key:value, or a key for any value.
	Label []string
	// Cursor Where the page starts: a page's `next`.
	Cursor *string
	// Limit The most items the page holds. At least 1. At most 200. Default: 50.
	Limit *int64
}

ContainerListQuery is what List takes in its query.

type ContainerMetricsQuery

type ContainerMetricsQuery struct {
	// Range The window: `15m`, `1h`, `6h`, `24h`, `7d` or `30d`. Default: "1h".
	Range *string
}

ContainerMetricsQuery is what Metrics takes in its query.

type ContainerNetwork

type ContainerNetwork struct {
	// contains filtered or unexported fields
}

ContainerNetwork is a container's network.

func (*ContainerNetwork) Get

Get Returns where a container may connect out.

func (*ContainerNetwork) Set

Set Replaces where a container may connect out, for its next connection and within a second for its open ones: those the new rules refuse are cut.

type ContainerProcessOutputQuery

type ContainerProcessOutputQuery struct {
	// Cursor Output after this byte. At least 0. Default: 0.
	Cursor *int64
	// WaitSeconds Seconds to wait for output past the cursor or its exit, at most 8. At least 0. At most 8.
	WaitSeconds *float64
	// MaxBytes At most this many bytes. At least 4096. At most 196608. Default: 65536.
	MaxBytes *int64
	// Follow Answer as NDJSON events from the cursor until it exits (stdout, stderr, truncated, exit; continue with the cursor to follow on from), as `Accept: application/x-ndjson` does.
	Follow *bool
}

ContainerProcessOutputQuery is what ProcessOutput takes in its query.

type ContainerProcesses

type ContainerProcesses struct {
	// contains filtered or unexported fields
}

ContainerProcesses is a container's processes.

func (*ContainerProcesses) List

List Lists a container's processes, newest first: those running and those that ended lately.

func (*ContainerProcesses) Output

Output Returns a process's output after a cursor, and the cursor to read on from. The latest 1 MiB is kept; truncated says when the cursor fell behind.

func (*ContainerProcesses) Resize

func (g *ContainerProcesses) Resize(ctx context.Context, process string, in *Terminal, opts *RequestOptions) (*Process, error)

Resize Resizes the terminal of a process started with a pty (its window's columns and rows, which the process is told by SIGWINCH), and returns the process; refused 409 for a process without one. A process that ended is left as it is, so a retry is safe.

func (*ContainerProcesses) Signal

func (g *ContainerProcesses) Signal(ctx context.Context, process string, in *ProcessSignal, opts *RequestOptions) (*Process, error)

Signal Sends a signal to a process and its group; a process that ended is not signalled, so a retry is safe.

func (*ContainerProcesses) Write

Write Sends input to a process started with stdinOpen or a pty, and returns how much of its input it has taken.

type ContainerReadQuery

type ContainerReadQuery struct {
	// Path The file's path in the machine.
	Path string
}

ContainerReadQuery is what Read takes in its query.

type ContainerScreenshotQuery

type ContainerScreenshotQuery struct {
	// Format `png`, or `jpeg`: smaller and quicker to send, for a model that reads it. Default: "png".
	Format *string
	// Quality A jpeg's quality, 1 to 100. At least 1. At most 100. Default: 80.
	Quality *int64
}

ContainerScreenshotQuery is what Screenshot takes in its query.

type ContainerStatQuery

type ContainerStatQuery struct {
	// Path The file's path in the machine.
	Path string
	// Sha256 Also return a file's SHA-256, read from its bytes: to check a file you put in place (files:rename with sha256) is whole. Default: false.
	Sha256 *bool
}

ContainerStatQuery is what Stat takes in its query.

type ContainerUploadFolderQuery

type ContainerUploadFolderQuery struct {
	// Path The folder, absolute, such as `/workspace/app`: made with its parents.
	Path string
	// User Who unpacks it: `runtime` or `root`; the container's `user` when omitted.
	User *string
}

ContainerUploadFolderQuery is what UploadFolder takes in its query.

type ContainerWriteFolderUploadQuery

type ContainerWriteFolderUploadQuery struct {
	// Offset Where the part starts in the archive: at most the bytes received so far. Bytes before them were taken already and are skipped, so a part sent again is never unpacked twice. At least 0. Default: 0.
	Offset *int64
}

ContainerWriteFolderUploadQuery is what WriteFolderUpload takes in its query.

type ContainerWriteQuery

type ContainerWriteQuery struct {
	// Path The file's path in the machine.
	Path string
	// Mode Its mode, in octal (`644`).
	Mode *string
	// Offset Write the bytes into the file in place from this byte, keeping the bytes before and after them (the file is made when there is none); one that fails part way may leave its range written in part, so send it again. Parts of one file may be written so at once and in any order: write them to a new path, then rename it with its size and sha256 to put it in place whole. At least 0.
	Offset *int64
	// Sha256 The bytes' SHA-256 in hex: refused 409 `checksum_mismatch`, the file as it was, when they differ. Not with offset.
	Sha256 *string
}

ContainerWriteQuery is what Write takes in its query.

type Containers

type Containers struct {
	// contains filtered or unexported fields
}

Containers A machine that runs one OCI image from any registry under Docker on its own network (`start` `runtime-container <image>`), the port it listens on reached at its preview, as Cloud Run and Fly Machines run one.

func (*Containers) AbortFolderUpload

func (c *Containers) AbortFolderUpload(ctx context.Context, id string, upload string, opts *RequestOptions) (*FolderUploadAborted, error)

AbortFolderUpload Stops a folder upload's tar; what it unpacked so far stays.

func (*Containers) Act

func (c *Containers) Act(ctx context.Context, id string, in ActRequest, opts *RequestOptions) (*Acted, error)

Act Moves, clicks, drags and scrolls the mouse and types on the keyboard of a container's screen (its X display `:1`), each step in turn as one command, and returns where the mouse is then. It stops at the first step that fails, refused 409 `act_failed` naming it; refused 409 `display_not_running` when no display runs. A paused container is resumed first.

func (*Containers) BeginFolderUpload

func (c *Containers) BeginFolderUpload(ctx context.Context, id string, in FolderUploadBegin, opts *RequestOptions) (*FolderUpload, error)

BeginFolderUpload Begins a folder's upload in parts: tar starts in the container, unpacking into the folder each part as it arrives. Send the parts in order by offset (writeFolderUpload), then commitFolderUpload; an upload no call names for 10 minutes is ended. A paused container is woken first.

func (*Containers) CommitFolderUpload

func (c *Containers) CommitFolderUpload(ctx context.Context, id string, upload string, opts *RequestOptions) (*FolderUnpacked, error)

CommitFolderUpload Ends a folder upload's input and returns once tar has ended, as an exec returns once its command has: the folder, or 400 `invalid_archive` with what tar said. Sent again, it returns how tar ended. An upload no call has named for 10 minutes since its last part or commit is ended.

func (*Containers) Create

func (c *Containers) Create(ctx context.Context, in SandboxCreate, opts *RequestOptions) (*Container, error)

Create Creates a container. Asked again with the same Idempotency-Key, it returns the same container.

func (*Containers) Delete

func (c *Containers) Delete(ctx context.Context, id string, opts *RequestOptions) (*SandboxInfo, error)

Delete Deletes a container, its memory and its disk.

func (*Containers) DownloadFolder

func (c *Containers) DownloadFolder(ctx context.Context, id string, q ContainerDownloadFolderQuery, opts *RequestOptions) ([]byte, error)

DownloadFolder Returns a folder as a tar archive (`application/x-tar`, or `application/gzip` with gzip), packed by tar in the container as it streams, of any size; its entries are relative to the folder (`./a.txt`). A folder that fails part way (a file it may not read, or one that changes as it is read) ends as an archive every tar reader refuses, never as a short one that reads whole. At most 4 at once in a container. A paused container is woken first.

func (*Containers) Exec

func (c *Containers) Exec(ctx context.Context, id string, in ExecRequest, opts *RequestOptions) (*Process, error)

Exec Runs a command as a process and returns it once it ended, with its output; with wait false, at once, while it runs. A paused container is resumed first. Asked again with the same Idempotency-Key, it runs nothing more: it returns the first run's process, waiting for its end while it runs.

func (*Containers) Fork

func (c *Containers) Fork(ctx context.Context, id string, in ForkRequest, opts *RequestOptions) (*Forked, error)

Fork Copies a container as it is now, memory and disk, into `count` copies of its own, each running on its host. Asked again with the same Idempotency-Key, it returns the same copies.

func (*Containers) Get

Get Returns a container.

func (*Containers) GetNetwork

func (c *Containers) GetNetwork(ctx context.Context, id string, opts *RequestOptions) (*SandboxNetwork, error)

GetNetwork Returns where a container may connect out.

func (c *Containers) Link(ctx context.Context, id string, in FileLinkCreate, opts *RequestOptions) (*FileLink, error)

Link Makes an expiring address for one file that anyone may open with no API key, from a browser, curl or another service: GET downloads it (Range works, so videos play and downloads resume; archive: true downloads a folder as .tar.gz), PUT with the raw body uploads it (up to maxBytes, written whole; Content-Length required). The link acts as the key that made it: an upload link needs write, and the link ends with its key, with revokeLinks or with its container. A paused container is woken for it unless wake is false. A port it serves is shared by a preview (previews.create), not a link.

func (*Containers) List

List Lists the project's containers, newest first.

func (*Containers) ListAll

ListAll is every item of every page List reads from q.Cursor (none: the first page), each page read as the last is used up.

func (*Containers) ListFiles

ListFiles Lists a directory's entries in path order, to a depth.

func (*Containers) ListProcesses

func (c *Containers) ListProcesses(ctx context.Context, id string, opts *RequestOptions) (*ProcessList, error)

ListProcesses Lists a container's processes, newest first: those running and those that ended lately.

func (*Containers) Metrics

Metrics Returns a container's CPU, memory, disks and pressure, as its host reads them from the container's own cgroup over a fifth of a second: never a call into the container, so it does not wake a paused one nor keep one from its idle pause. One that is not running has no reading.

func (*Containers) Mkdir

func (c *Containers) Mkdir(ctx context.Context, id string, in FileMkdir, opts *RequestOptions) (*FileMade, error)

Mkdir Makes a directory, and its parents unless parents is false. One there already is success, created false.

func (*Containers) Pause

func (c *Containers) Pause(ctx context.Context, id string, opts *RequestOptions) (*SandboxInfo, error)

Pause Pauses a container with its memory and disk kept. A call to it resumes it.

func (*Containers) ProcessOutput

func (c *Containers) ProcessOutput(ctx context.Context, id string, process string, q ContainerProcessOutputQuery, opts *RequestOptions) (*ProcessOutput, error)

ProcessOutput Returns a process's output after a cursor, and the cursor to read on from. The latest 1 MiB is kept; truncated says when the cursor fell behind.

func (*Containers) Read

func (c *Containers) Read(ctx context.Context, id string, q ContainerReadQuery, opts *RequestOptions) ([]byte, error)

Read Returns a file's bytes.

func (*Containers) Remove

func (c *Containers) Remove(ctx context.Context, id string, in FileRemove, opts *RequestOptions) (*FileRemoved, error)

Remove Removes a file, a link or a directory (recursive for one with contents). One missing is success, removed false.

func (*Containers) Rename

func (c *Containers) Rename(ctx context.Context, id string, in FileRename, opts *RequestOptions) (*FileRenamed, error)

Rename Moves a file, a link or a directory; refused 409 when something is at its new path, unless overwrite. With sha256 or size, a file written in parts is put in place once whole: its writes ended, then only a file of that size with every byte written and whose bytes hash to it moves; refused 409 `upload_incomplete` or `checksum_mismatch`, nothing moved. With sha256, it is safe to send again: once moved, it returns the same answer while `from` is gone and `to` holds those bytes.

func (*Containers) ResizeProcess

func (c *Containers) ResizeProcess(ctx context.Context, id string, process string, in Terminal, opts *RequestOptions) (*Process, error)

ResizeProcess Resizes the terminal of a process started with a pty (its window's columns and rows, which the process is told by SIGWINCH), and returns the process; refused 409 for a process without one. A process that ended is left as it is, so a retry is safe.

func (*Containers) Resume

func (c *Containers) Resume(ctx context.Context, id string, opts *RequestOptions) (*SandboxInfo, error)

Resume Resumes a paused container where it was, its memory and processes as they were.

func (c *Containers) RevokeLinks(ctx context.Context, id string, opts *RequestOptions) (*FileLinksRevoked, error)

RevokeLinks Ends every file link made for a container so far; links made after work.

func (*Containers) RunCode

func (c *Containers) RunCode(ctx context.Context, id string, in RunCode, opts *RequestOptions) (*CodeRun, error)

RunCode Runs a cell of Python in a container as a notebook does, in a Jupyter kernel it keeps running for the cell's `context`: variables, imports and functions stay for the next cell. Returns what it printed, its values and displays (text, HTML, images such as charts), and its exception with its traceback. The context's kernel starts on its first cell. A cell past `timeoutSeconds` is interrupted and its context kept. Refused 409 `kernel_not_installed` when the image has no ipykernel. A paused container is resumed first.

func (*Containers) Screenshot

func (c *Containers) Screenshot(ctx context.Context, id string, q ContainerScreenshotQuery, opts *RequestOptions) ([]byte, error)

Screenshot Returns what a container's screen shows now, as `image/png` (or `image/jpeg`): its X display `:1`, whole. Refused 409 `display_not_running` when no display runs. A paused container is resumed first.

func (*Containers) SetNetwork

func (c *Containers) SetNetwork(ctx context.Context, id string, in NetworkRules, opts *RequestOptions) (*SandboxNetwork, error)

SetNetwork Replaces where a container may connect out, for its next connection and within a second for its open ones: those the new rules refuse are cut.

func (*Containers) SignalProcess

func (c *Containers) SignalProcess(ctx context.Context, id string, process string, in ProcessSignal, opts *RequestOptions) (*Process, error)

SignalProcess Sends a signal to a process and its group; a process that ended is not signalled, so a retry is safe.

func (*Containers) Snapshot

func (c *Containers) Snapshot(ctx context.Context, id string, in SnapshotRequest, opts *RequestOptions) (*Stored, error)

Snapshot Keeps a container's memory and disk as they are now, a snapshot to start containers from; with `image`, its disk alone as that image's next version. The container runs on. Asked again with the same Idempotency-Key, it returns the same snapshot.

func (*Containers) Stat

Stat Returns what is at a path: a file, a directory or a link, or nothing (exists false). With sha256=true, a file's SHA-256 too.

func (*Containers) Update

func (c *Containers) Update(ctx context.Context, id string, in MachineUpdate, opts *RequestOptions) (*SandboxInfo, error)

Update Changes its name, labels, idle pause, maxCost, autoWake, lifetime, delete protection, environment or sizes; each field left out stays as it is. A lifetime (`deleteAfterSeconds`) sent again before its end moves the end to that many seconds from now; 0 takes it off. A lifetime is refused (409 `delete_protected`) while `deleteProtection` is true. A running one holds a changed environment before this answers (a paused one's at its wake): each process it starts after the answer has it, and its running processes keep the one they started with. Its vCPUs, memory and disk grow while it runs, its commands running on. One paused or stopped is not woken for it: judged at once as a live resize is (past the vCPUs it was made with 409, over its organization's limits `quota_exceeded`), its new sizes are returned at once, and its next wake grows it to them before the call that woke it runs. A smaller size, or a machine starting or failed, is refused 409 naming why, and nothing is changed. With If-Match, made only while its revision is that one, else 412. Sent again with the same Idempotency-Key and body while it is the latest change, it returns the current state and changes nothing; the same key with a different body returns 409 idempotency_key_reused.

func (*Containers) UploadFolder

func (c *Containers) UploadFolder(ctx context.Context, id string, data []byte, q ContainerUploadFolderQuery, opts *RequestOptions) (*FolderUnpacked, error)

UploadFolder Unpacks the request's tar archive (gzip-compressed or not, told by its first bytes) into a folder, made with its parents, by tar in the container as the bytes arrive, of any size, nothing of it kept on disk but what tar writes; returns once tar has ended, or 400 `invalid_archive` with what tar said. A paused container is woken first.

func (*Containers) Write

func (c *Containers) Write(ctx context.Context, id string, data []byte, q ContainerWriteQuery, opts *RequestOptions) (*FileWritten, error)

Write Writes the request's bytes to a file as they come, of any size (Content-Length required), its folders made: the file whole when they all came, or as it was. With offset, they are written into it in place.

func (*Containers) WriteFolderUpload

func (c *Containers) WriteFolderUpload(ctx context.Context, id string, upload string, data []byte, q ContainerWriteFolderUploadQuery, opts *RequestOptions) (*FolderUploadReceived, error)

WriteFolderUpload Sends the request's bytes, a part of the archive at its offset, into tar's input as they arrive, of any size, and returns the bytes received in all once tar took them. A part past them is refused 409 `upload_incomplete`, naming them: send the parts in order.

func (*Containers) WriteProcess

func (c *Containers) WriteProcess(ctx context.Context, id string, process string, in ProcessInput, opts *RequestOptions) (*ProcessWritten, error)

WriteProcess Sends input to a process started with stdinOpen or a pty, and returns how much of its input it has taken.

type ContextAsked

type ContextAsked struct {
	// Digests At most 10,000 SHA-256 digests, each 64 lowercase hex digits.
	Digests []string `json:"digests"`
}

ContextAsked Chunks of a build's context, by their SHA-256.

type ContextMissing

type ContextMissing struct {
	// Missing The digests asked for that the organization's build context does not hold, sorted, each once.
	Missing []string `json:"missing"`
}

ContextMissing Which chunks of a build's context still need uploading.

type Desktop

type Desktop struct {

	// Info is what it was when last read.
	Info      *SandboxInfo
	Files     *DesktopFiles
	Processes *DesktopProcesses
	Network   *DesktopNetwork
	// contains filtered or unexported fields
}

Desktop is one of desktops: A machine running a Linux desktop with Chromium, for agents that use a computer: screenshot returns what its screen shows and act moves and clicks its mouse and types on its keyboard. It is shown in the browser through noVNC at its preview on port 6080; its VNC server answers only inside the machine, so a link signed for that preview is the one way to watch it. It pauses after 300 seconds with nothing happening, its memory kept.

func (*Desktop) Act

func (s *Desktop) Act(ctx context.Context, actions []Action, in *ActRequest, opts *RequestOptions) (*Acted, error)

Act Moves, clicks, drags and scrolls the mouse and types on the keyboard of a desktop's screen (its X display `:1`), each step in turn as one command, and returns where the mouse is then. It stops at the first step that fails, refused 409 `act_failed` naming it; refused 409 `display_not_running` when no display runs. A paused desktop is resumed first.

func (*Desktop) Delete

func (s *Desktop) Delete(ctx context.Context, opts *RequestOptions) (*SandboxInfo, error)

Delete Deletes a desktop, its memory and its disk.

func (*Desktop) Exec

func (s *Desktop) Exec(ctx context.Context, cmd string, in *ExecRequest, opts *RequestOptions) (*Process, error)

Exec Runs a command as a process and returns it once it ended, with its output; with wait false, at once, while it runs. A paused desktop is resumed first. Asked again with the same Idempotency-Key, it runs nothing more: it returns the first run's process, waiting for its end while it runs.

func (*Desktop) Fork

func (s *Desktop) Fork(ctx context.Context, in *ForkRequest, opts *RequestOptions) (*Forked, error)

Fork Copies a desktop as it is now, memory and disk, into `count` copies of its own, each running on its host. Asked again with the same Idempotency-Key, it returns the same copies.

func (*Desktop) ID

func (s *Desktop) ID() string

ID is its id.

func (*Desktop) Metrics

Metrics Returns a desktop's CPU, memory, disks and pressure, as its host reads them from the desktop's own cgroup over a fifth of a second: never a call into the desktop, so it does not wake a paused one nor keep one from its idle pause. One that is not running has no reading.

func (*Desktop) Pause

func (s *Desktop) Pause(ctx context.Context, opts *RequestOptions) error

Pause Pauses a desktop with its memory and disk kept. A call to it resumes it.

func (*Desktop) Refresh

func (s *Desktop) Refresh(ctx context.Context, q *DesktopGetQuery, opts *RequestOptions) error

Refresh Returns a desktop.

func (*Desktop) Resume

func (s *Desktop) Resume(ctx context.Context, opts *RequestOptions) error

Resume Resumes a paused desktop where it was, its memory and processes as they were.

func (*Desktop) RunCode

func (s *Desktop) RunCode(ctx context.Context, code string, in *RunCode, opts *RequestOptions) (*CodeRun, error)

RunCode Runs a cell of Python in a desktop as a notebook does, in a Jupyter kernel it keeps running for the cell's `context`: variables, imports and functions stay for the next cell. Returns what it printed, its values and displays (text, HTML, images such as charts), and its exception with its traceback. The context's kernel starts on its first cell. A cell past `timeoutSeconds` is interrupted and its context kept. Refused 409 `kernel_not_installed` when the image has no ipykernel. A paused desktop is resumed first.

func (*Desktop) Screenshot

func (s *Desktop) Screenshot(ctx context.Context, q *DesktopScreenshotQuery, opts *RequestOptions) ([]byte, error)

Screenshot Returns what a desktop's screen shows now, as `image/png` (or `image/jpeg`): its X display `:1`, whole. Refused 409 `display_not_running` when no display runs. A paused desktop is resumed first.

func (*Desktop) Snapshot

func (s *Desktop) Snapshot(ctx context.Context, in *SnapshotRequest, opts *RequestOptions) (*Stored, error)

Snapshot Keeps a desktop's memory and disk as they are now, a snapshot to start desktops from; with `image`, its disk alone as that image's next version. The desktop runs on. Asked again with the same Idempotency-Key, it returns the same snapshot.

func (*Desktop) Update

func (s *Desktop) Update(ctx context.Context, in *MachineUpdate, opts *RequestOptions) error

Update Changes its name, labels, idle pause, maxCost, autoWake, lifetime, delete protection, environment or sizes; each field left out stays as it is. A lifetime (`deleteAfterSeconds`) sent again before its end moves the end to that many seconds from now; 0 takes it off. A lifetime is refused (409 `delete_protected`) while `deleteProtection` is true. A running one holds a changed environment before this answers (a paused one's at its wake): each process it starts after the answer has it, and its running processes keep the one they started with. Its vCPUs, memory and disk grow while it runs, its commands running on. One paused or stopped is not woken for it: judged at once as a live resize is (past the vCPUs it was made with 409, over its organization's limits `quota_exceeded`), its new sizes are returned at once, and its next wake grows it to them before the call that woke it runs. A smaller size, or a machine starting or failed, is refused 409 naming why, and nothing is changed. With If-Match, made only while its revision is that one, else 412. Sent again with the same Idempotency-Key and body while it is the latest change, it returns the current state and changes nothing; the same key with a different body returns 409 idempotency_key_reused.

type DesktopDownloadFolderQuery

type DesktopDownloadFolderQuery struct {
	// Path The folder, absolute, such as `/workspace/app`.
	Path string
	// Gzip Compress the archive with gzip. Default: false.
	Gzip *bool
	// User Who packs it: `runtime` or `root`; the desktop's `user` when omitted.
	User *string
	// Exclude Paths in the folder to leave out, relative to it and comma-separated (`node_modules,.cache`): plain names, no wildcards, at most 32.
	Exclude *string
}

DesktopDownloadFolderQuery is what DownloadFolder takes in its query.

type DesktopFiles

type DesktopFiles struct {
	// contains filtered or unexported fields
}

DesktopFiles is a desktop's files.

func (*DesktopFiles) AbortFolderUpload

func (g *DesktopFiles) AbortFolderUpload(ctx context.Context, upload string, opts *RequestOptions) (*FolderUploadAborted, error)

AbortFolderUpload Stops a folder upload's tar; what it unpacked so far stays.

func (*DesktopFiles) BeginFolderUpload

func (g *DesktopFiles) BeginFolderUpload(ctx context.Context, path string, in *FolderUploadBegin, opts *RequestOptions) (*FolderUpload, error)

BeginFolderUpload Begins a folder's upload in parts: tar starts in the desktop, unpacking into the folder each part as it arrives. Send the parts in order by offset (writeFolderUpload), then commitFolderUpload; an upload no call names for 10 minutes is ended. A paused desktop is woken first.

func (*DesktopFiles) CommitFolderUpload

func (g *DesktopFiles) CommitFolderUpload(ctx context.Context, upload string, opts *RequestOptions) (*FolderUnpacked, error)

CommitFolderUpload Ends a folder upload's input and returns once tar has ended, as an exec returns once its command has: the folder, or 400 `invalid_archive` with what tar said. Sent again, it returns how tar ended. An upload no call has named for 10 minutes since its last part or commit is ended.

func (*DesktopFiles) DownloadFolder

func (g *DesktopFiles) DownloadFolder(ctx context.Context, path string, q *DesktopDownloadFolderQuery, opts *RequestOptions) ([]byte, error)

DownloadFolder Returns a folder as a tar archive (`application/x-tar`, or `application/gzip` with gzip), packed by tar in the desktop as it streams, of any size; its entries are relative to the folder (`./a.txt`). A folder that fails part way (a file it may not read, or one that changes as it is read) ends as an archive every tar reader refuses, never as a short one that reads whole. At most 4 at once in a desktop. A paused desktop is woken first.

func (g *DesktopFiles) Link(ctx context.Context, path string, in *FileLinkCreate, opts *RequestOptions) (*FileLink, error)

Link Makes an expiring address for one file that anyone may open with no API key, from a browser, curl or another service: GET downloads it (Range works, so videos play and downloads resume; archive: true downloads a folder as .tar.gz), PUT with the raw body uploads it (up to maxBytes, written whole; Content-Length required). The link acts as the key that made it: an upload link needs write, and the link ends with its key, with revokeLinks or with its desktop. A paused desktop is woken for it unless wake is false. A port it serves is shared by a preview (previews.create), not a link.

func (*DesktopFiles) List

List Lists a directory's entries in path order, to a depth.

func (*DesktopFiles) Mkdir

func (g *DesktopFiles) Mkdir(ctx context.Context, path string, in *FileMkdir, opts *RequestOptions) (*FileMade, error)

Mkdir Makes a directory, and its parents unless parents is false. One there already is success, created false.

func (*DesktopFiles) Read

func (g *DesktopFiles) Read(ctx context.Context, path string, q *DesktopReadQuery, opts *RequestOptions) ([]byte, error)

Read Returns a file's bytes.

func (*DesktopFiles) Remove

func (g *DesktopFiles) Remove(ctx context.Context, path string, in *FileRemove, opts *RequestOptions) (*FileRemoved, error)

Remove Removes a file, a link or a directory (recursive for one with contents). One missing is success, removed false.

func (*DesktopFiles) Rename

func (g *DesktopFiles) Rename(ctx context.Context, in *FileRename, opts *RequestOptions) (*FileRenamed, error)

Rename Moves a file, a link or a directory; refused 409 when something is at its new path, unless overwrite. With sha256 or size, a file written in parts is put in place once whole: its writes ended, then only a file of that size with every byte written and whose bytes hash to it moves; refused 409 `upload_incomplete` or `checksum_mismatch`, nothing moved. With sha256, it is safe to send again: once moved, it returns the same answer while `from` is gone and `to` holds those bytes.

func (g *DesktopFiles) RevokeLinks(ctx context.Context, opts *RequestOptions) (*FileLinksRevoked, error)

RevokeLinks Ends every file link made for a desktop so far; links made after work.

func (*DesktopFiles) Stat

func (g *DesktopFiles) Stat(ctx context.Context, path string, q *DesktopStatQuery, opts *RequestOptions) (*FileInfo, error)

Stat Returns what is at a path: a file, a directory or a link, or nothing (exists false). With sha256=true, a file's SHA-256 too.

func (*DesktopFiles) UploadFolder

func (g *DesktopFiles) UploadFolder(ctx context.Context, path string, data []byte, q *DesktopUploadFolderQuery, opts *RequestOptions) (*FolderUnpacked, error)

UploadFolder Unpacks the request's tar archive (gzip-compressed or not, told by its first bytes) into a folder, made with its parents, by tar in the desktop as the bytes arrive, of any size, nothing of it kept on disk but what tar writes; returns once tar has ended, or 400 `invalid_archive` with what tar said. A paused desktop is woken first.

func (*DesktopFiles) Write

func (g *DesktopFiles) Write(ctx context.Context, path string, data []byte, q *DesktopWriteQuery, opts *RequestOptions) (*FileWritten, error)

Write Writes the request's bytes to a file as they come, of any size (Content-Length required), its folders made: the file whole when they all came, or as it was. With offset, they are written into it in place.

func (*DesktopFiles) WriteFolderUpload

func (g *DesktopFiles) WriteFolderUpload(ctx context.Context, upload string, data []byte, q *DesktopWriteFolderUploadQuery, opts *RequestOptions) (*FolderUploadReceived, error)

WriteFolderUpload Sends the request's bytes, a part of the archive at its offset, into tar's input as they arrive, of any size, and returns the bytes received in all once tar took them. A part past them is refused 409 `upload_incomplete`, naming them: send the parts in order.

type DesktopGetQuery

type DesktopGetQuery struct {
	// Wait Seconds to wait, at most 60, for its state to differ from `ifState`; it answers once it does, or as it is when the wait ends. At least 0. At most 60.
	Wait *float64
	// IfState The state the caller last read, which `wait` waits for it to leave.
	IfState *string
}

DesktopGetQuery is what Get takes in its query.

type DesktopListFilesQuery

type DesktopListFilesQuery struct {
	// Path The directory. Default: "/workspace".
	Path *string
	// Depth How deep to list. At least 1. At most 10. Default: 1.
	Depth *int64
	// Limit At most this many entries. At least 1. At most 2000. Default: 2000.
	Limit *int64
	// Hidden List entries whose names start with a dot. Default: true.
	Hidden *bool
	// Glob Only entries whose path relative to the directory matches: `*` within a name, `**` across folders, `?` one character, `{a,b}` either (`**/*.py`); at most 512 characters, 32 wildcards and 64 texts in braces. The listing then reaches as deep as the glob does (10 folders for `**`) unless depth says, and is searched past its first 2,000 entries, up to 50,000. At most 512 characters.
	Glob *string
}

DesktopListFilesQuery is what ListFiles takes in its query.

type DesktopListQuery

type DesktopListQuery struct {
	// State Only those in these states, comma-separated.
	State *string
	// Name Only the desktop of this name.
	Name *string
	// Label Only those with every label given (repeat it for several): key:value, or a key for any value.
	Label []string
	// Cursor Where the page starts: a page's `next`.
	Cursor *string
	// Limit The most items the page holds. At least 1. At most 200. Default: 50.
	Limit *int64
}

DesktopListQuery is what List takes in its query.

type DesktopMetricsQuery

type DesktopMetricsQuery struct {
	// Range The window: `15m`, `1h`, `6h`, `24h`, `7d` or `30d`. Default: "1h".
	Range *string
}

DesktopMetricsQuery is what Metrics takes in its query.

type DesktopNetwork

type DesktopNetwork struct {
	// contains filtered or unexported fields
}

DesktopNetwork is a desktop's network.

func (*DesktopNetwork) Get

Get Returns where a desktop may connect out.

func (*DesktopNetwork) Set

Set Replaces where a desktop may connect out, for its next connection and within a second for its open ones: those the new rules refuse are cut.

type DesktopProcessOutputQuery

type DesktopProcessOutputQuery struct {
	// Cursor Output after this byte. At least 0. Default: 0.
	Cursor *int64
	// WaitSeconds Seconds to wait for output past the cursor or its exit, at most 8. At least 0. At most 8.
	WaitSeconds *float64
	// MaxBytes At most this many bytes. At least 4096. At most 196608. Default: 65536.
	MaxBytes *int64
	// Follow Answer as NDJSON events from the cursor until it exits (stdout, stderr, truncated, exit; continue with the cursor to follow on from), as `Accept: application/x-ndjson` does.
	Follow *bool
}

DesktopProcessOutputQuery is what ProcessOutput takes in its query.

type DesktopProcesses

type DesktopProcesses struct {
	// contains filtered or unexported fields
}

DesktopProcesses is a desktop's processes.

func (*DesktopProcesses) List

List Lists a desktop's processes, newest first: those running and those that ended lately.

func (*DesktopProcesses) Output

Output Returns a process's output after a cursor, and the cursor to read on from. The latest 1 MiB is kept; truncated says when the cursor fell behind.

func (*DesktopProcesses) Resize

func (g *DesktopProcesses) Resize(ctx context.Context, process string, in *Terminal, opts *RequestOptions) (*Process, error)

Resize Resizes the terminal of a process started with a pty (its window's columns and rows, which the process is told by SIGWINCH), and returns the process; refused 409 for a process without one. A process that ended is left as it is, so a retry is safe.

func (*DesktopProcesses) Signal

func (g *DesktopProcesses) Signal(ctx context.Context, process string, in *ProcessSignal, opts *RequestOptions) (*Process, error)

Signal Sends a signal to a process and its group; a process that ended is not signalled, so a retry is safe.

func (*DesktopProcesses) Write

func (g *DesktopProcesses) Write(ctx context.Context, process string, in *ProcessInput, opts *RequestOptions) (*ProcessWritten, error)

Write Sends input to a process started with stdinOpen or a pty, and returns how much of its input it has taken.

type DesktopReadQuery

type DesktopReadQuery struct {
	// Path The file's path in the machine.
	Path string
}

DesktopReadQuery is what Read takes in its query.

type DesktopScreenshotQuery

type DesktopScreenshotQuery struct {
	// Format `png`, or `jpeg`: smaller and quicker to send, for a model that reads it. Default: "png".
	Format *string
	// Quality A jpeg's quality, 1 to 100. At least 1. At most 100. Default: 80.
	Quality *int64
}

DesktopScreenshotQuery is what Screenshot takes in its query.

type DesktopStatQuery

type DesktopStatQuery struct {
	// Path The file's path in the machine.
	Path string
	// Sha256 Also return a file's SHA-256, read from its bytes: to check a file you put in place (files:rename with sha256) is whole. Default: false.
	Sha256 *bool
}

DesktopStatQuery is what Stat takes in its query.

type DesktopUploadFolderQuery

type DesktopUploadFolderQuery struct {
	// Path The folder, absolute, such as `/workspace/app`: made with its parents.
	Path string
	// User Who unpacks it: `runtime` or `root`; the desktop's `user` when omitted.
	User *string
}

DesktopUploadFolderQuery is what UploadFolder takes in its query.

type DesktopWriteFolderUploadQuery

type DesktopWriteFolderUploadQuery struct {
	// Offset Where the part starts in the archive: at most the bytes received so far. Bytes before them were taken already and are skipped, so a part sent again is never unpacked twice. At least 0. Default: 0.
	Offset *int64
}

DesktopWriteFolderUploadQuery is what WriteFolderUpload takes in its query.

type DesktopWriteQuery

type DesktopWriteQuery struct {
	// Path The file's path in the machine.
	Path string
	// Mode Its mode, in octal (`644`).
	Mode *string
	// Offset Write the bytes into the file in place from this byte, keeping the bytes before and after them (the file is made when there is none); one that fails part way may leave its range written in part, so send it again. Parts of one file may be written so at once and in any order: write them to a new path, then rename it with its size and sha256 to put it in place whole. At least 0.
	Offset *int64
	// Sha256 The bytes' SHA-256 in hex: refused 409 `checksum_mismatch`, the file as it was, when they differ. Not with offset.
	Sha256 *string
}

DesktopWriteQuery is what Write takes in its query.

type Desktops

type Desktops struct {
	// contains filtered or unexported fields
}

Desktops A machine running a Linux desktop with Chromium, for agents that use a computer: screenshot returns what its screen shows and act moves and clicks its mouse and types on its keyboard. It is shown in the browser through noVNC at its preview on port 6080; its VNC server answers only inside the machine, so a link signed for that preview is the one way to watch it. It pauses after 300 seconds with nothing happening, its memory kept.

func (*Desktops) AbortFolderUpload

func (c *Desktops) AbortFolderUpload(ctx context.Context, id string, upload string, opts *RequestOptions) (*FolderUploadAborted, error)

AbortFolderUpload Stops a folder upload's tar; what it unpacked so far stays.

func (*Desktops) Act

func (c *Desktops) Act(ctx context.Context, id string, in ActRequest, opts *RequestOptions) (*Acted, error)

Act Moves, clicks, drags and scrolls the mouse and types on the keyboard of a desktop's screen (its X display `:1`), each step in turn as one command, and returns where the mouse is then. It stops at the first step that fails, refused 409 `act_failed` naming it; refused 409 `display_not_running` when no display runs. A paused desktop is resumed first.

func (*Desktops) BeginFolderUpload

func (c *Desktops) BeginFolderUpload(ctx context.Context, id string, in FolderUploadBegin, opts *RequestOptions) (*FolderUpload, error)

BeginFolderUpload Begins a folder's upload in parts: tar starts in the desktop, unpacking into the folder each part as it arrives. Send the parts in order by offset (writeFolderUpload), then commitFolderUpload; an upload no call names for 10 minutes is ended. A paused desktop is woken first.

func (*Desktops) CommitFolderUpload

func (c *Desktops) CommitFolderUpload(ctx context.Context, id string, upload string, opts *RequestOptions) (*FolderUnpacked, error)

CommitFolderUpload Ends a folder upload's input and returns once tar has ended, as an exec returns once its command has: the folder, or 400 `invalid_archive` with what tar said. Sent again, it returns how tar ended. An upload no call has named for 10 minutes since its last part or commit is ended.

func (*Desktops) Create

func (c *Desktops) Create(ctx context.Context, in SandboxCreate, opts *RequestOptions) (*Desktop, error)

Create Creates a desktop. Asked again with the same Idempotency-Key, it returns the same desktop.

func (*Desktops) Delete

func (c *Desktops) Delete(ctx context.Context, id string, opts *RequestOptions) (*SandboxInfo, error)

Delete Deletes a desktop, its memory and its disk.

func (*Desktops) DownloadFolder

func (c *Desktops) DownloadFolder(ctx context.Context, id string, q DesktopDownloadFolderQuery, opts *RequestOptions) ([]byte, error)

DownloadFolder Returns a folder as a tar archive (`application/x-tar`, or `application/gzip` with gzip), packed by tar in the desktop as it streams, of any size; its entries are relative to the folder (`./a.txt`). A folder that fails part way (a file it may not read, or one that changes as it is read) ends as an archive every tar reader refuses, never as a short one that reads whole. At most 4 at once in a desktop. A paused desktop is woken first.

func (*Desktops) Exec

func (c *Desktops) Exec(ctx context.Context, id string, in ExecRequest, opts *RequestOptions) (*Process, error)

Exec Runs a command as a process and returns it once it ended, with its output; with wait false, at once, while it runs. A paused desktop is resumed first. Asked again with the same Idempotency-Key, it runs nothing more: it returns the first run's process, waiting for its end while it runs.

func (*Desktops) Fork

func (c *Desktops) Fork(ctx context.Context, id string, in ForkRequest, opts *RequestOptions) (*Forked, error)

Fork Copies a desktop as it is now, memory and disk, into `count` copies of its own, each running on its host. Asked again with the same Idempotency-Key, it returns the same copies.

func (*Desktops) Get

func (c *Desktops) Get(ctx context.Context, id string, q DesktopGetQuery, opts *RequestOptions) (*Desktop, error)

Get Returns a desktop.

func (*Desktops) GetNetwork

func (c *Desktops) GetNetwork(ctx context.Context, id string, opts *RequestOptions) (*SandboxNetwork, error)

GetNetwork Returns where a desktop may connect out.

func (c *Desktops) Link(ctx context.Context, id string, in FileLinkCreate, opts *RequestOptions) (*FileLink, error)

Link Makes an expiring address for one file that anyone may open with no API key, from a browser, curl or another service: GET downloads it (Range works, so videos play and downloads resume; archive: true downloads a folder as .tar.gz), PUT with the raw body uploads it (up to maxBytes, written whole; Content-Length required). The link acts as the key that made it: an upload link needs write, and the link ends with its key, with revokeLinks or with its desktop. A paused desktop is woken for it unless wake is false. A port it serves is shared by a preview (previews.create), not a link.

func (*Desktops) List

List Lists the project's desktops, newest first.

func (*Desktops) ListAll

ListAll is every item of every page List reads from q.Cursor (none: the first page), each page read as the last is used up.

func (*Desktops) ListFiles

func (c *Desktops) ListFiles(ctx context.Context, id string, q DesktopListFilesQuery, opts *RequestOptions) (*FileList, error)

ListFiles Lists a directory's entries in path order, to a depth.

func (*Desktops) ListProcesses

func (c *Desktops) ListProcesses(ctx context.Context, id string, opts *RequestOptions) (*ProcessList, error)

ListProcesses Lists a desktop's processes, newest first: those running and those that ended lately.

func (*Desktops) Metrics

Metrics Returns a desktop's CPU, memory, disks and pressure, as its host reads them from the desktop's own cgroup over a fifth of a second: never a call into the desktop, so it does not wake a paused one nor keep one from its idle pause. One that is not running has no reading.

func (*Desktops) Mkdir

func (c *Desktops) Mkdir(ctx context.Context, id string, in FileMkdir, opts *RequestOptions) (*FileMade, error)

Mkdir Makes a directory, and its parents unless parents is false. One there already is success, created false.

func (*Desktops) Pause

func (c *Desktops) Pause(ctx context.Context, id string, opts *RequestOptions) (*SandboxInfo, error)

Pause Pauses a desktop with its memory and disk kept. A call to it resumes it.

func (*Desktops) ProcessOutput

func (c *Desktops) ProcessOutput(ctx context.Context, id string, process string, q DesktopProcessOutputQuery, opts *RequestOptions) (*ProcessOutput, error)

ProcessOutput Returns a process's output after a cursor, and the cursor to read on from. The latest 1 MiB is kept; truncated says when the cursor fell behind.

func (*Desktops) Read

func (c *Desktops) Read(ctx context.Context, id string, q DesktopReadQuery, opts *RequestOptions) ([]byte, error)

Read Returns a file's bytes.

func (*Desktops) Remove

func (c *Desktops) Remove(ctx context.Context, id string, in FileRemove, opts *RequestOptions) (*FileRemoved, error)

Remove Removes a file, a link or a directory (recursive for one with contents). One missing is success, removed false.

func (*Desktops) Rename

func (c *Desktops) Rename(ctx context.Context, id string, in FileRename, opts *RequestOptions) (*FileRenamed, error)

Rename Moves a file, a link or a directory; refused 409 when something is at its new path, unless overwrite. With sha256 or size, a file written in parts is put in place once whole: its writes ended, then only a file of that size with every byte written and whose bytes hash to it moves; refused 409 `upload_incomplete` or `checksum_mismatch`, nothing moved. With sha256, it is safe to send again: once moved, it returns the same answer while `from` is gone and `to` holds those bytes.

func (*Desktops) ResizeProcess

func (c *Desktops) ResizeProcess(ctx context.Context, id string, process string, in Terminal, opts *RequestOptions) (*Process, error)

ResizeProcess Resizes the terminal of a process started with a pty (its window's columns and rows, which the process is told by SIGWINCH), and returns the process; refused 409 for a process without one. A process that ended is left as it is, so a retry is safe.

func (*Desktops) Resume

func (c *Desktops) Resume(ctx context.Context, id string, opts *RequestOptions) (*SandboxInfo, error)

Resume Resumes a paused desktop where it was, its memory and processes as they were.

func (c *Desktops) RevokeLinks(ctx context.Context, id string, opts *RequestOptions) (*FileLinksRevoked, error)

RevokeLinks Ends every file link made for a desktop so far; links made after work.

func (*Desktops) RunCode

func (c *Desktops) RunCode(ctx context.Context, id string, in RunCode, opts *RequestOptions) (*CodeRun, error)

RunCode Runs a cell of Python in a desktop as a notebook does, in a Jupyter kernel it keeps running for the cell's `context`: variables, imports and functions stay for the next cell. Returns what it printed, its values and displays (text, HTML, images such as charts), and its exception with its traceback. The context's kernel starts on its first cell. A cell past `timeoutSeconds` is interrupted and its context kept. Refused 409 `kernel_not_installed` when the image has no ipykernel. A paused desktop is resumed first.

func (*Desktops) Screenshot

func (c *Desktops) Screenshot(ctx context.Context, id string, q DesktopScreenshotQuery, opts *RequestOptions) ([]byte, error)

Screenshot Returns what a desktop's screen shows now, as `image/png` (or `image/jpeg`): its X display `:1`, whole. Refused 409 `display_not_running` when no display runs. A paused desktop is resumed first.

func (*Desktops) SetNetwork

func (c *Desktops) SetNetwork(ctx context.Context, id string, in NetworkRules, opts *RequestOptions) (*SandboxNetwork, error)

SetNetwork Replaces where a desktop may connect out, for its next connection and within a second for its open ones: those the new rules refuse are cut.

func (*Desktops) SignalProcess

func (c *Desktops) SignalProcess(ctx context.Context, id string, process string, in ProcessSignal, opts *RequestOptions) (*Process, error)

SignalProcess Sends a signal to a process and its group; a process that ended is not signalled, so a retry is safe.

func (*Desktops) Snapshot

func (c *Desktops) Snapshot(ctx context.Context, id string, in SnapshotRequest, opts *RequestOptions) (*Stored, error)

Snapshot Keeps a desktop's memory and disk as they are now, a snapshot to start desktops from; with `image`, its disk alone as that image's next version. The desktop runs on. Asked again with the same Idempotency-Key, it returns the same snapshot.

func (*Desktops) Stat

Stat Returns what is at a path: a file, a directory or a link, or nothing (exists false). With sha256=true, a file's SHA-256 too.

func (*Desktops) Update

func (c *Desktops) Update(ctx context.Context, id string, in MachineUpdate, opts *RequestOptions) (*SandboxInfo, error)

Update Changes its name, labels, idle pause, maxCost, autoWake, lifetime, delete protection, environment or sizes; each field left out stays as it is. A lifetime (`deleteAfterSeconds`) sent again before its end moves the end to that many seconds from now; 0 takes it off. A lifetime is refused (409 `delete_protected`) while `deleteProtection` is true. A running one holds a changed environment before this answers (a paused one's at its wake): each process it starts after the answer has it, and its running processes keep the one they started with. Its vCPUs, memory and disk grow while it runs, its commands running on. One paused or stopped is not woken for it: judged at once as a live resize is (past the vCPUs it was made with 409, over its organization's limits `quota_exceeded`), its new sizes are returned at once, and its next wake grows it to them before the call that woke it runs. A smaller size, or a machine starting or failed, is refused 409 naming why, and nothing is changed. With If-Match, made only while its revision is that one, else 412. Sent again with the same Idempotency-Key and body while it is the latest change, it returns the current state and changes nothing; the same key with a different body returns 409 idempotency_key_reused.

func (*Desktops) UploadFolder

func (c *Desktops) UploadFolder(ctx context.Context, id string, data []byte, q DesktopUploadFolderQuery, opts *RequestOptions) (*FolderUnpacked, error)

UploadFolder Unpacks the request's tar archive (gzip-compressed or not, told by its first bytes) into a folder, made with its parents, by tar in the desktop as the bytes arrive, of any size, nothing of it kept on disk but what tar writes; returns once tar has ended, or 400 `invalid_archive` with what tar said. A paused desktop is woken first.

func (*Desktops) Write

func (c *Desktops) Write(ctx context.Context, id string, data []byte, q DesktopWriteQuery, opts *RequestOptions) (*FileWritten, error)

Write Writes the request's bytes to a file as they come, of any size (Content-Length required), its folders made: the file whole when they all came, or as it was. With offset, they are written into it in place.

func (*Desktops) WriteFolderUpload

func (c *Desktops) WriteFolderUpload(ctx context.Context, id string, upload string, data []byte, q DesktopWriteFolderUploadQuery, opts *RequestOptions) (*FolderUploadReceived, error)

WriteFolderUpload Sends the request's bytes, a part of the archive at its offset, into tar's input as they arrive, of any size, and returns the bytes received in all once tar took them. A part past them is refused 409 `upload_incomplete`, naming them: send the parts in order.

func (*Desktops) WriteProcess

func (c *Desktops) WriteProcess(ctx context.Context, id string, process string, in ProcessInput, opts *RequestOptions) (*ProcessWritten, error)

WriteProcess Sends input to a process started with stdinOpen or a pty, and returns how much of its input it has taken.

type Domain

type Domain struct {

	// Info is what it was when last read.
	Info *DomainInfo
	// contains filtered or unexported fields
}

Domain is one of domains: Your own hostname serving a machine's port, with HTTPS.

func (*Domain) Delete

func (s *Domain) Delete(ctx context.Context, opts *RequestOptions) (*DomainInfo, error)

Delete Stops serving the hostname. Remove its DNS records too.

func (*Domain) Hostname

func (s *Domain) Hostname() string

Hostname is its hostname.

func (*Domain) ID

func (s *Domain) ID() string

ID is its id.

func (*Domain) Refresh

func (s *Domain) Refresh(ctx context.Context, q *DomainGetQuery, opts *RequestOptions) error

Refresh Returns a custom domain and the DNS records it needs.

func (*Domain) Verify

func (s *Domain) Verify(ctx context.Context, opts *RequestOptions) error

Verify Checks the TXT record now; the name is served once it matches.

type DomainCreate

type DomainCreate struct {
	// Hostname The hostname, at most 253 characters.
	Hostname string `json:"hostname"`
	// SandboxID The machine to serve.
	SandboxID string `json:"sandboxId"`
	// Port The port inside the machine, 1 to 65535.
	Port int64 `json:"port"`
}

DomainCreate A custom domain to add, or to point at another machine or port.

type DomainGetQuery

type DomainGetQuery struct {
	// Wait Seconds to wait, at most 60, for its state to differ from `ifState`; it answers once it does, or as it is when the wait ends. At least 0. At most 60.
	Wait *float64
	// IfState The state the caller last read, which `wait` waits for it to leave.
	IfState *string
}

DomainGetQuery is what Get takes in its query.

type DomainInfo

type DomainInfo struct {
	DomainSettings
	// ID Its ID.
	ID string `json:"id"`
	// Object Always `domain`.
	Object string `json:"object"`
	// Hostname The hostname, lower case.
	Hostname string `json:"hostname"`
	// SandboxID The machine it serves.
	SandboxID string `json:"sandboxId"`
	// State Its state: `ready` once every serving host routes it.
	State string `json:"state"`
	// Disabled Turned off by Runtime.
	Disabled bool `json:"disabled"`
	// CreatedAt When it was added.
	CreatedAt string `json:"createdAt"`
	// Records The DNS records to set: the TXT record that proves the name, and the CNAME that sends visitors here.
	Records []map[string]string `json:"records,omitempty"`
	// DeletedAt When it was deleted: a delete's answer, its state `deleted`.
	DeletedAt *string `json:"deletedAt,omitempty"`
}

DomainInfo A custom domain: your own hostname serving a machine's port.

type DomainListQuery

type DomainListQuery struct {
	// Cursor Where the page starts: a page's `next`.
	Cursor *string
	// Limit The most items the page holds. At least 1. At most 200. Default: 50.
	Limit *int64
}

DomainListQuery is what List takes in its query.

type DomainSettings

type DomainSettings struct {
	// Port The port inside the machine. At least 1. At most 65535.
	Port int64 `json:"port"`
	// Token The token the TXT record at `_runtime-challenge.<hostname>` holds as `runtime-verify=<token>`.
	Token string `json:"token"`
	// VerifiedAt When the TXT record was last found to hold the token; none until it is.
	VerifiedAt *string `json:"verifiedAt,omitempty"`
	// CheckedAt When the TXT record was last looked up.
	CheckedAt *string `json:"checkedAt,omitempty"`
	// CheckError What the last lookup found wrong; none when it proved the name.
	CheckError *string `json:"checkError,omitempty"`
}

DomainSettings A custom domain's settings, as it keeps them: the port it serves, and its proof of ownership as facts.

type Domains

type Domains struct {
	// contains filtered or unexported fields
}

Domains Your own hostname serving a machine's port, with HTTPS.

func (*Domains) Create

func (c *Domains) Create(ctx context.Context, in DomainCreate, opts *RequestOptions) (*Domain, error)

Create Adds a hostname to serve a machine's port, checks its TXT record, and returns the DNS records to set. Asked again with another machine or port, it points the name there.

func (*Domains) Delete

func (c *Domains) Delete(ctx context.Context, hostname string, opts *RequestOptions) (*DomainInfo, error)

Delete Stops serving the hostname. Remove its DNS records too.

func (*Domains) Get

func (c *Domains) Get(ctx context.Context, hostname string, q DomainGetQuery, opts *RequestOptions) (*Domain, error)

Get Returns a custom domain and the DNS records it needs.

func (*Domains) List

List Lists the org's custom domains, by hostname.

func (*Domains) ListAll

ListAll is every item of every page List reads from q.Cursor (none: the first page), each page read as the last is used up.

func (*Domains) Verify

func (c *Domains) Verify(ctx context.Context, hostname string, opts *RequestOptions) (*DomainInfo, error)

Verify Checks the TXT record now; the name is served once it matches.

type EgressIp

type EgressIp struct {
	EgressIpSettings
	// ID Its ID.
	ID string `json:"id"`
	// Object Always `ip`.
	Object string `json:"object"`
	// Address The address.
	Address string `json:"address"`
	// State Its state: `ready` once machines send from it.
	State string `json:"state"`
	// Disabled Turned off: its machines send from the shared addresses.
	Disabled bool `json:"disabled"`
	// CreatedAt When it was reserved.
	CreatedAt string `json:"createdAt"`
}

EgressIp A static egress IP: every machine of the org sends from it.

type EgressIpListQuery

type EgressIpListQuery struct {
	// Cursor Where the page starts: a page's `next`.
	Cursor *string
	// Limit The most items the page holds. At least 1. At most 200. Default: 50.
	Limit *int64
}

EgressIpListQuery is what List takes in its query.

type EgressIpSettings

type EgressIpSettings struct {
	// Family 4 or 6.
	Family int64 `json:"family"`
	// Rate Its monthly price when it was reserved, in US dollars (`"5.00"`); it does not change.
	Rate string `json:"rate"`
}

EgressIpSettings A static egress IP's settings, as it keeps them.

type EgressIps

type EgressIps struct {
	// contains filtered or unexported fields
}

EgressIps Deprecated: static egress IPs are no longer offered, and the list is always empty.

func (*EgressIps) List

List Deprecated: always answers an empty page, as static egress IPs are no longer offered.

func (*EgressIps) ListAll

ListAll is every item of every page List reads from q.Cursor (none: the first page), each page read as the last is used up.

type Error

type Error struct {
	Code         string         `json:"code"`
	Message      string         `json:"message"`
	RequestID    string         `json:"requestId"`
	Hint         string         `json:"hint,omitempty"`
	DocURL       string         `json:"docUrl,omitempty"`
	Param        string         `json:"param,omitempty"`
	Details      map[string]any `json:"details,omitempty"`
	Status       int            `json:"-"`
	Retryable    bool           `json:"-"`
	RetryAfterMs *int64         `json:"-"`
}

Error is an error the API returned: its body ({code, message, requestId, hint, docUrl}), the answer's status and Retry-After, and whether the client sends it again. DocURL is where the code is explained.

func (*Error) Error

func (e *Error) Error() string

func (*Error) Is

func (e *Error) Is(target error) bool

Is matches an error of the same family: errors.Is(err, ErrNotFound).

type Event

type Event struct {
	// ID Its ID (`evt_...`), the `runtime-webhook-id` of its webhook delivery.
	ID string `json:"id"`
	// Object Always `event`.
	Object string `json:"object"`
	// Type What happened (`sandbox.created`, `sandbox.paused`), a webhook's `runtime-event-type`.
	Type string `json:"type"`
	// ResourceID The ID of the resource it happened to.
	ResourceID string `json:"resourceId"`
	// State The resource's state after it, when it says one.
	State *string `json:"state,omitempty"`
	// Reason Why, when it says why (a stop's or a failure's).
	Reason *string `json:"reason,omitempty"`
	// ExitCode The exit code of a run that ended.
	ExitCode *int64 `json:"exitCode,omitempty"`
	// PausedAt When the resource's pause began (or its run ended), on an event of it paused or stopped.
	PausedAt *string `json:"pausedAt,omitempty"`
	// CreatedAt When it happened.
	CreatedAt string `json:"createdAt"`
}

Event A lifecycle event: what changed, as a webhook is sent it.

type EventListQuery

type EventListQuery struct {
	// Cursor Where the page starts: a page's `next`.
	Cursor *string
	// Limit The most items the page holds. At least 1. At most 200. Default: 50.
	Limit *int64
	// Type Only events of this type (`sandbox.created`).
	Type *string
	// ResourceID Only the events of this resource, by its ID.
	ResourceID *string
}

EventListQuery is what List takes in its query.

type Events

type Events struct {
	// contains filtered or unexported fields
}

Events What changed in the organization, as it changed: each event a webhook or an OpenTelemetry export is sent, kept 14 days.

func (*Events) List

func (c *Events) List(ctx context.Context, q EventListQuery, opts *RequestOptions) (*Page[Event], error)

List Lists the organization's lifecycle events of the last 14 days, newest first, paginated: each one a webhook is sent, with the same `id` and `type`.

func (*Events) ListAll

func (c *Events) ListAll(ctx context.Context, q EventListQuery, opts *RequestOptions) iter.Seq2[Event, error]

ListAll is every item of every page List reads from q.Cursor (none: the first page), each page read as the last is used up.

type ExecEvent

type ExecEvent struct {
	// Type `start`, `stdout`, `stderr`, `truncated`, `exit`, `continue` or `error`.
	Type string `json:"type"`
	// ProcessID The process: `start` and `continue`.
	ProcessID *string `json:"processId,omitempty"`
	// Replayed `start`: this Idempotency-Key ran it before, and these are that run's events again.
	Replayed *bool `json:"replayed,omitempty"`
	// Data `stdout` and `stderr`: the output, as text.
	Data *string `json:"data,omitempty"`
	// Base64 `stdout` and `stderr`: the output's bytes, in base64, with outputEncoding `base64`.
	Base64 *string `json:"base64,omitempty"`
	// Offset `stdout` and `stderr`: where in the process's output these bytes start.
	Offset *int64 `json:"offset,omitempty"`
	// DroppedBytes `truncated`: how many bytes were dropped.
	DroppedBytes *int64 `json:"droppedBytes,omitempty"`
	// ResumeAt `truncated`: where the output read on from.
	ResumeAt *int64 `json:"resumeAt,omitempty"`
	// ExitCode `exit`: its exit code.
	ExitCode *int64 `json:"exitCode,omitempty"`
	// State `exit`: how it ended.
	State *string `json:"state,omitempty"`
	// TimedOut `exit`: it was stopped at its timeout.
	TimedOut *bool `json:"timedOut,omitempty"`
	// DurationSeconds `exit`: how long it ran.
	DurationSeconds *float64 `json:"durationSeconds,omitempty"`
	// Cursor `continue`: the cursor to follow its output on from (processes.output).
	Cursor *int64 `json:"cursor,omitempty"`
	// Error `error`: what failed.
	Error *ExecEventError `json:"error,omitempty"`
}

ExecEvent One event of an exec asked for its events (`stream: true`, or `Accept: application/x-ndjson`), one JSON object a line: `start`, then `stdout` and `stderr` as the output comes, `truncated` when output was dropped before it was read, and `exit`; or `continue` (follow on with processes.output from `cursor`) or `error`.

type ExecEventError

type ExecEventError struct {
	// Code The error's code.
	Code string `json:"code"`
	// Message What went wrong.
	Message *string `json:"message,omitempty"`
	// Status The status the API answered.
	Status *int64 `json:"status,omitempty"`
	// ProcessID The process.
	ProcessID *string `json:"processId,omitempty"`
	// Cursor The cursor to follow its output on from (processes.output).
	Cursor *int64 `json:"cursor,omitempty"`
}

ExecEventError A failed read of an exec's events: the error the API would have answered, and where to follow on from.

type ExecRequest

type ExecRequest struct {
	// Cmd The command: text, run by `bash -lc` (`sh -lc` in an image without bash; `"npm test"`), or a list, the program and its arguments run without a shell (`["npm", "test"]`).
	Cmd any `json:"cmd"`
	// Cwd The directory it runs in; the user's home when omitted.
	Cwd *string `json:"cwd,omitempty"`
	// Env Environment variables to add.
	Env map[string]string `json:"env,omitempty"`
	// Stdin Bytes sent to its standard input.
	Stdin *string `json:"stdin,omitempty"`
	// TimeoutSeconds Seconds it may run before it is stopped (`1.5` for 1,500 ms); it runs to its end when omitted or 0. At least 0.
	TimeoutSeconds *float64 `json:"timeoutSeconds,omitempty"`
	// Stream Answer as NDJSON events while it runs (start, stdout, stderr, exit), as `Accept: application/x-ndjson` does.
	Stream *bool `json:"stream,omitempty"`
	// Wait Wait for it to end and return it with its output. False returns it at once, running: read its output with processes.output, send it input with processes.write and signals with processes.signal. Default: true.
	Wait *bool `json:"wait,omitempty"`
	// StdinOpen Keep its standard input open for processes.write; not with stdin, and not with a wait for its end.
	StdinOpen *bool `json:"stdinOpen,omitempty"`
	// OutputEncoding How processes.output answers its output. Default: "utf8".
	OutputEncoding *string `json:"outputEncoding,omitempty"`
	// Pty Run it on a terminal of this size: its input, output and controlling terminal; not with a wait for its end.
	Pty *Terminal `json:"pty,omitempty"`
	// User Who it runs as: `runtime` (uid 1000, with passwordless sudo) or `root`; the machine's `user` when omitted.
	User *string `json:"user,omitempty"`
}

ExecRequest A command to run: to its end, or started and answered at once (`wait: false`).

type Export

type Export struct {
	// ID Its ID.
	ID string `json:"id"`
	// Object Always `otel`.
	Object string `json:"object"`
	// Endpoint The OTLP/HTTP endpoint's base URL (https); in a list, its origin alone.
	Endpoint string `json:"endpoint"`
	// HeaderNames The names of the headers sent with each request; their values are never shown.
	HeaderNames []string `json:"headerNames"`
	// Events The events it is sent; `*` for every one.
	Events []string `json:"events"`
	// State `active` while it is sent to; `deleted` once deleted: a delete's answer.
	State string `json:"state"`
	// CreatedAt When it was made.
	CreatedAt string `json:"createdAt"`
	// DeletedAt When it was deleted: a delete's answer, its state `deleted`.
	DeletedAt *string `json:"deletedAt,omitempty"`
}

Export An OpenTelemetry export: the events as OTLP logs, POSTed to `<endpoint>/v1/logs`.

type ExportCreate

type ExportCreate struct {
	// Endpoint The OTLP/HTTP endpoint's base URL (https).
	Endpoint string `json:"endpoint"`
	// Headers Headers sent with each request (an API key), at most 16.
	Headers map[string]string `json:"headers,omitempty"`
	// Events The events to send it; `["*"]` (every one) when omitted.
	Events []string `json:"events,omitempty"`
}

ExportCreate An OpenTelemetry export to make.

type ExportListQuery

type ExportListQuery struct {
	// Cursor Where the page starts: a page's `next`.
	Cursor *string
	// Limit The most items the page holds. At least 1. At most 200. Default: 50.
	Limit *int64
}

ExportListQuery is what List takes in its query.

type Feedback

type Feedback struct {
	// ID Its ID.
	ID string `json:"id"`
	// Object Always `feedback`.
	Object string `json:"object"`
	// Kind What it is about.
	Kind string `json:"kind"`
	// Summary Its one line.
	Summary string `json:"summary"`
	// CreatedAt When it was received.
	CreatedAt string `json:"createdAt"`
}

Feedback A report as it was received.

type FeedbackClient

type FeedbackClient struct {
	// contains filtered or unexported fields
}

FeedbackClient A report to Runtime's team: a bug, a missing feature, a gap against another provider, a migration blocker, unclear docs, a price, or praise. Every report is read.

func (*FeedbackClient) Create

Create Sends a report to Runtime's team. Quote the requestId of an error you hit; never send credentials, private files or user data.

type FeedbackCreate

type FeedbackCreate struct {
	// Kind `bug`, `missing_feature`, `competitor_gap` (something another provider does better), `migration_blocker` (what stops a move to Runtime), `docs`, `pricing`, `praise` or `other`.
	Kind string `json:"kind"`
	// Summary One line. At least 1 character. At most 200 characters.
	Summary string `json:"summary"`
	// Detail What happened, what you expected, how to reproduce. At most 8000 characters.
	Detail *string `json:"detail,omitempty"`
	// Competitor The other provider, for a gap or a migration (E2B, Daytona, Modal). At most 80 characters.
	Competitor *string `json:"competitor,omitempty"`
	// ResourceID The resource it is about. At most 64 characters.
	ResourceID *string `json:"resourceId,omitempty"`
	// RequestID The requestId of the error you are reporting. At most 64 characters.
	RequestID *string `json:"requestId,omitempty"`
	// Page The page it is about, for a report from the site. At most 300 characters.
	Page *string `json:"page,omitempty"`
	// Rating A page's rating: 1 helpful, -1 not. At least -1. At most 1.
	Rating *int64 `json:"rating,omitempty"`
	// ContactEmail An address to reply to, for a report from someone not signed in. At most 254 characters.
	ContactEmail *string `json:"contactEmail,omitempty"`
	// Context Anything else useful, at most 16 entries of text.
	Context map[string]string `json:"context,omitempty"`
}

FeedbackCreate A report to send.

type FileInfo

type FileInfo struct {
	// Path Its path.
	Path string `json:"path"`
	// Exists Something is there.
	Exists bool `json:"exists"`
	// Name Its last part.
	Name *string `json:"name,omitempty"`
	// Type What it is: `file`, `directory`, `symlink` or `other`.
	Type *string `json:"type,omitempty"`
	// Size Its size in bytes.
	Size *int64 `json:"size,omitempty"`
	// Mode Its permissions, in octal (`0644`).
	Mode *string `json:"mode,omitempty"`
	// ModifiedAt When it last changed.
	ModifiedAt *string `json:"modifiedAt,omitempty"`
	// Uid Its owner's user ID.
	Uid *int64 `json:"uid,omitempty"`
	// Gid Its group's ID.
	Gid *int64 `json:"gid,omitempty"`
	// SymlinkTarget Where a link points.
	SymlinkTarget *string `json:"symlinkTarget,omitempty"`
	// Sha256 A file's SHA-256 in hex, read from its bytes: given when asked (`sha256=true`).
	Sha256 *string `json:"sha256,omitempty"`
}

FileInfo A path in a machine: what is there, if anything.

type FileLink struct {
	// Url Its address, opened with no key: GET to download, PUT the file's bytes to upload.
	Url string `json:"url"`
	// Method `GET` or `PUT`.
	Method string `json:"method"`
	// Path The file's path in the machine.
	Path string `json:"path"`
	// SandboxID The machine.
	SandboxID string `json:"sandboxId"`
	// ExpiresAt When it stops working.
	ExpiresAt string `json:"expiresAt"`
	// Filename The name it downloads as.
	Filename *string `json:"filename,omitempty"`
	// MaxBytes The largest body an upload link takes.
	MaxBytes *int64 `json:"maxBytes,omitempty"`
	// Archive It downloads a folder as a `.tar.gz`.
	Archive *bool `json:"archive,omitempty"`
}

FileLink A file link.

type FileLinkCreate

type FileLinkCreate struct {
	// Path The file's absolute path in the machine. For GET it must exist when the link is made.
	Path string `json:"path"`
	// Method `GET` (default): a download link. `PUT`: an upload link; the request's body becomes the file.
	Method *string `json:"method,omitempty"`
	// ExpiresInSeconds How long the link works, in seconds. At least 60. At most 604800. Default: 3600.
	ExpiresInSeconds *int64 `json:"expiresInSeconds,omitempty"`
	// Filename Download as this name (`Content-Disposition: attachment`). Without it a picture, video, sound or plain text shows in the browser; anything else downloads.
	Filename *string `json:"filename,omitempty"`
	// MaxBytes PUT only: the largest body the link takes, in bytes; 5 GiB by default and at most. At least 0. At most 5368709120.
	MaxBytes *int64 `json:"maxBytes,omitempty"`
	// Wake false: a paused machine is not woken for the link, which answers 409 `sandbox_paused`. Unset or true: it is woken.
	Wake *bool `json:"wake,omitempty"`
	// Archive GET only: `path` is a folder, downloaded as a `.tar.gz`. Default: false.
	Archive *bool `json:"archive,omitempty"`
}

FileLinkCreate A file link to make: an expiring address for one file of a machine (or, with `archive`, a folder) that anyone may open with no API key.

type FileLinksRevoked

type FileLinksRevoked struct {
	// SandboxID The machine.
	SandboxID string `json:"sandboxId"`
	// RevokedAt When they ended: every link made before it.
	RevokedAt string `json:"revokedAt"`
}

FileLinksRevoked A machine's file links ended.

type FileList

type FileList struct {
	// Items Each entry.
	Items []FileInfo `json:"items"`
	// Truncated There were more entries than limit.
	Truncated bool `json:"truncated"`
}

FileList What a directory holds, in path order.

type FileMade

type FileMade struct {
	// Path Its path.
	Path string `json:"path"`
	// Created It was made; false when it was there already.
	Created bool `json:"created"`
}

FileMade A directory made.

type FileMkdir

type FileMkdir struct {
	// Path Its path.
	Path string `json:"path"`
	// Parents Its parents are made too; true when omitted.
	Parents *bool `json:"parents,omitempty"`
}

FileMkdir A directory to make.

type FileRemove

type FileRemove struct {
	// Path Its path.
	Path string `json:"path"`
	// Recursive A directory with its contents; refused for a directory with contents when omitted.
	Recursive *bool `json:"recursive,omitempty"`
}

FileRemove A file, a link or a directory to remove.

type FileRemoved

type FileRemoved struct {
	// Path Its path.
	Path string `json:"path"`
	// Removed It was there and is removed; false when it was missing.
	Removed bool `json:"removed"`
}

FileRemoved A file, a link or a directory removed.

type FileRename

type FileRename struct {
	// From Where it is.
	From string `json:"from"`
	// To Where it goes.
	To string `json:"to"`
	// Overwrite Replace what is at `to`; refused 409 when something is there and this is omitted.
	Overwrite *bool `json:"overwrite,omitempty"`
	// Sha256 The file's SHA-256 in hex: only a file whose bytes hash to it moves. With it, a rename sent again after it moved returns the same answer.
	Sha256 *string `json:"sha256,omitempty"`
	// Size The file's size in bytes: only a file of this size, every byte of it written, moves. At least 0.
	Size *int64 `json:"size,omitempty"`
}

FileRename A file, a link or a directory to move.

type FileRenamed

type FileRenamed struct {
	// From Where it was.
	From string `json:"from"`
	// To Where it is now.
	To string `json:"to"`
	// Size Its size in bytes: given for a move checked by sha256.
	Size *int64 `json:"size,omitempty"`
	// Sha256 Its SHA-256 in hex: given for a move checked by sha256.
	Sha256 *string `json:"sha256,omitempty"`
}

FileRenamed A file, a link or a directory moved.

type FileWritten

type FileWritten struct {
	// Path Its path.
	Path string `json:"path"`
	// Size Its size in bytes, after the write.
	Size int64 `json:"size"`
	// Sha256 Its SHA-256 in hex: given for a file written whole.
	Sha256 *string `json:"sha256,omitempty"`
	// Offset Where the bytes were written: given for a write at an offset.
	Offset *int64 `json:"offset,omitempty"`
}

FileWritten A file written.

type FolderUnpacked

type FolderUnpacked struct {
	// Path The folder.
	Path string `json:"path"`
	// Received The archive's bytes tar took.
	Received int64 `json:"received"`
}

FolderUnpacked A folder unpacked.

type FolderUpload

type FolderUpload struct {
	// UploadID Its ID, which its parts, its commit and its abort name.
	UploadID string `json:"uploadId"`
	// Path The folder it unpacks into.
	Path string `json:"path"`
	// Gzip The archive is gzip-compressed.
	Gzip bool `json:"gzip"`
	// ChunkBytes The most bytes a part should carry.
	ChunkBytes int64 `json:"chunkBytes"`
}

FolderUpload A folder upload begun: its parts go to it in order, then its commit.

type FolderUploadAborted

type FolderUploadAborted struct {
	// Aborted Always true: tar was stopped; what it unpacked stays.
	Aborted bool `json:"aborted"`
}

FolderUploadAborted A folder upload ended unfinished.

type FolderUploadBegin

type FolderUploadBegin struct {
	// Path The folder, absolute and plain, such as `/workspace/app`: made with its parents.
	Path string `json:"path"`
	// Gzip The archive is gzip-compressed (`.tar.gz`). Default: false.
	Gzip *bool `json:"gzip,omitempty"`
	// User Who unpacks it: `runtime` or `root`; the machine's `user` when omitted.
	User *string `json:"user,omitempty"`
}

FolderUploadBegin A folder upload to begin: a tar archive sent in parts, unpacked into a folder as they arrive.

type FolderUploadReceived

type FolderUploadReceived struct {
	// Received The archive's bytes tar has taken so far: the next part's offset.
	Received int64 `json:"received"`
}

FolderUploadReceived A folder upload's part taken.

type ForkRequest

type ForkRequest struct {
	// Count How many. At least 1. At most 100. Default: 1.
	Count *int64 `json:"count,omitempty"`
	// Name Its name, for a fork of one.
	Name *string `json:"name,omitempty"`
	// Labels Labels each copy gets.
	Labels map[string]string `json:"labels,omitempty"`
	// Secrets The secrets each copy gets, by name: only these, never one its source may not use; its source's when omitted. At most 64 items.
	Secrets []string `json:"secrets,omitempty"`
	// MaxCost The most each may cost in all, in US dollars (`"5.00"`): once one has cost that it pauses, as a create's maxCost. When omitted, the least of its key's caps and its source's maxCost.
	MaxCost *string `json:"maxCost,omitempty"`
	// IdlePauseSeconds Seconds with nothing happening before each copy pauses, 60 to 86400; 0 never. When omitted, its source's, unless its source never pauses (0): then its product's default, 300 for a sandbox. At least 0. At most 86400.
	IdlePauseSeconds *int64 `json:"idlePauseSeconds,omitempty"`
	// Vcpu The vCPUs each copy runs, at most its source's; its source's when omitted. A copy with fewer has only this many CPUs online (the rest of its source's are taken offline, so `nproc` in it is this number) and is held to this many vCPUs of CPU time, which it is placed and billed by. Its memory is its source's. At least 2.
	Vcpu *int64 `json:"vcpu,omitempty"`
	// DeleteAfterSeconds Seconds until Runtime deletes each copy, as its delete does: final, and it can't be undone. 0 or omitted: kept until deleted; a copy never takes its source's. At least 0. At most 315360000.
	DeleteAfterSeconds *int64 `json:"deleteAfterSeconds,omitempty"`
	// DeleteProtection Whether each copy's delete is refused (409 `delete_protected`) until an update turns this off; false when omitted. Not with `deleteAfterSeconds`; a copy never takes its source's.
	DeleteProtection *bool `json:"deleteProtection,omitempty"`
}

ForkRequest Copies of a machine to make, as it is now.

type Forked

type Forked struct {
	// Sandboxes The copies, in the order made.
	Sandboxes []SandboxInfo `json:"sandboxes"`
}

Forked The copies a fork made, each running.

type FunctionDownloadFolderQuery

type FunctionDownloadFolderQuery struct {
	// Path The folder, absolute, such as `/workspace/app`.
	Path string
	// Gzip Compress the archive with gzip. Default: false.
	Gzip *bool
	// User Who packs it: `runtime` or `root`; the function's `user` when omitted.
	User *string
	// Exclude Paths in the folder to leave out, relative to it and comma-separated (`node_modules,.cache`): plain names, no wildcards, at most 32.
	Exclude *string
}

FunctionDownloadFolderQuery is what DownloadFolder takes in its query.

type FunctionGetQuery

type FunctionGetQuery struct {
	// Wait Seconds to wait, at most 60, for its state to differ from `ifState`; it answers once it does, or as it is when the wait ends. At least 0. At most 60.
	Wait *float64
	// IfState The state the caller last read, which `wait` waits for it to leave.
	IfState *string
}

FunctionGetQuery is what Get takes in its query.

type FunctionListFilesQuery

type FunctionListFilesQuery struct {
	// Path The directory. Default: "/workspace".
	Path *string
	// Depth How deep to list. At least 1. At most 10. Default: 1.
	Depth *int64
	// Limit At most this many entries. At least 1. At most 2000. Default: 2000.
	Limit *int64
	// Hidden List entries whose names start with a dot. Default: true.
	Hidden *bool
	// Glob Only entries whose path relative to the directory matches: `*` within a name, `**` across folders, `?` one character, `{a,b}` either (`**/*.py`); at most 512 characters, 32 wildcards and 64 texts in braces. The listing then reaches as deep as the glob does (10 folders for `**`) unless depth says, and is searched past its first 2,000 entries, up to 50,000. At most 512 characters.
	Glob *string
}

FunctionListFilesQuery is what ListFiles takes in its query.

type FunctionListQuery

type FunctionListQuery struct {
	// State Only those in these states, comma-separated.
	State *string
	// Name Only the function of this name.
	Name *string
	// Label Only those with every label given (repeat it for several): key:value, or a key for any value.
	Label []string
	// Cursor Where the page starts: a page's `next`.
	Cursor *string
	// Limit The most items the page holds. At least 1. At most 200. Default: 50.
	Limit *int64
}

FunctionListQuery is what List takes in its query.

type FunctionMachine

type FunctionMachine struct {

	// Info is what it was when last read.
	Info      *SandboxInfo
	Files     *FunctionMachineFiles
	Processes *FunctionMachineProcesses
	Network   *FunctionMachineNetwork
	// contains filtered or unexported fields
}

FunctionMachine is one of functions: A machine that answers HTTP with a handler in /app/index.ts (`export default { fetch(request) }`, as Cloudflare Workers and Vercel take one) on port 8080, reached at its preview. It pauses after 60 seconds with nothing happening, its memory kept, and a request resumes it.

func (*FunctionMachine) Act

func (s *FunctionMachine) Act(ctx context.Context, actions []Action, in *ActRequest, opts *RequestOptions) (*Acted, error)

Act Moves, clicks, drags and scrolls the mouse and types on the keyboard of a function's screen (its X display `:1`), each step in turn as one command, and returns where the mouse is then. It stops at the first step that fails, refused 409 `act_failed` naming it; refused 409 `display_not_running` when no display runs. A paused function is resumed first.

func (*FunctionMachine) Delete

func (s *FunctionMachine) Delete(ctx context.Context, opts *RequestOptions) (*SandboxInfo, error)

Delete Deletes a function, its memory and its disk.

func (*FunctionMachine) Exec

func (s *FunctionMachine) Exec(ctx context.Context, cmd string, in *ExecRequest, opts *RequestOptions) (*Process, error)

Exec Runs a command as a process and returns it once it ended, with its output; with wait false, at once, while it runs. A paused function is resumed first. Asked again with the same Idempotency-Key, it runs nothing more: it returns the first run's process, waiting for its end while it runs.

func (*FunctionMachine) Fork

func (s *FunctionMachine) Fork(ctx context.Context, in *ForkRequest, opts *RequestOptions) (*Forked, error)

Fork Copies a function as it is now, memory and disk, into `count` copies of its own, each running on its host. Asked again with the same Idempotency-Key, it returns the same copies.

func (*FunctionMachine) ID

func (s *FunctionMachine) ID() string

ID is its id.

func (*FunctionMachine) Metrics

Metrics Returns a function's CPU, memory, disks and pressure, as its host reads them from the function's own cgroup over a fifth of a second: never a call into the function, so it does not wake a paused one nor keep one from its idle pause. One that is not running has no reading.

func (*FunctionMachine) Pause

func (s *FunctionMachine) Pause(ctx context.Context, opts *RequestOptions) error

Pause Pauses a function with its memory and disk kept. A call to it resumes it.

func (*FunctionMachine) Refresh

Refresh Returns a function.

func (*FunctionMachine) Resume

func (s *FunctionMachine) Resume(ctx context.Context, opts *RequestOptions) error

Resume Resumes a paused function where it was, its memory and processes as they were.

func (*FunctionMachine) RunCode

func (s *FunctionMachine) RunCode(ctx context.Context, code string, in *RunCode, opts *RequestOptions) (*CodeRun, error)

RunCode Runs a cell of Python in a function as a notebook does, in a Jupyter kernel it keeps running for the cell's `context`: variables, imports and functions stay for the next cell. Returns what it printed, its values and displays (text, HTML, images such as charts), and its exception with its traceback. The context's kernel starts on its first cell. A cell past `timeoutSeconds` is interrupted and its context kept. Refused 409 `kernel_not_installed` when the image has no ipykernel. A paused function is resumed first.

func (*FunctionMachine) Screenshot

func (s *FunctionMachine) Screenshot(ctx context.Context, q *FunctionScreenshotQuery, opts *RequestOptions) ([]byte, error)

Screenshot Returns what a function's screen shows now, as `image/png` (or `image/jpeg`): its X display `:1`, whole. Refused 409 `display_not_running` when no display runs. A paused function is resumed first.

func (*FunctionMachine) Snapshot

func (s *FunctionMachine) Snapshot(ctx context.Context, in *SnapshotRequest, opts *RequestOptions) (*Stored, error)

Snapshot Keeps a function's memory and disk as they are now, a snapshot to start functions from; with `image`, its disk alone as that image's next version. The function runs on. Asked again with the same Idempotency-Key, it returns the same snapshot.

func (*FunctionMachine) Update

func (s *FunctionMachine) Update(ctx context.Context, in *MachineUpdate, opts *RequestOptions) error

Update Changes its name, labels, idle pause, maxCost, autoWake, lifetime, delete protection, environment or sizes; each field left out stays as it is. A lifetime (`deleteAfterSeconds`) sent again before its end moves the end to that many seconds from now; 0 takes it off. A lifetime is refused (409 `delete_protected`) while `deleteProtection` is true. A running one holds a changed environment before this answers (a paused one's at its wake): each process it starts after the answer has it, and its running processes keep the one they started with. Its vCPUs, memory and disk grow while it runs, its commands running on. One paused or stopped is not woken for it: judged at once as a live resize is (past the vCPUs it was made with 409, over its organization's limits `quota_exceeded`), its new sizes are returned at once, and its next wake grows it to them before the call that woke it runs. A smaller size, or a machine starting or failed, is refused 409 naming why, and nothing is changed. With If-Match, made only while its revision is that one, else 412. Sent again with the same Idempotency-Key and body while it is the latest change, it returns the current state and changes nothing; the same key with a different body returns 409 idempotency_key_reused.

type FunctionMachineFiles

type FunctionMachineFiles struct {
	// contains filtered or unexported fields
}

FunctionMachineFiles is a functionmachine's files.

func (*FunctionMachineFiles) AbortFolderUpload

func (g *FunctionMachineFiles) AbortFolderUpload(ctx context.Context, upload string, opts *RequestOptions) (*FolderUploadAborted, error)

AbortFolderUpload Stops a folder upload's tar; what it unpacked so far stays.

func (*FunctionMachineFiles) BeginFolderUpload

func (g *FunctionMachineFiles) BeginFolderUpload(ctx context.Context, path string, in *FolderUploadBegin, opts *RequestOptions) (*FolderUpload, error)

BeginFolderUpload Begins a folder's upload in parts: tar starts in the function, unpacking into the folder each part as it arrives. Send the parts in order by offset (writeFolderUpload), then commitFolderUpload; an upload no call names for 10 minutes is ended. A paused function is woken first.

func (*FunctionMachineFiles) CommitFolderUpload

func (g *FunctionMachineFiles) CommitFolderUpload(ctx context.Context, upload string, opts *RequestOptions) (*FolderUnpacked, error)

CommitFolderUpload Ends a folder upload's input and returns once tar has ended, as an exec returns once its command has: the folder, or 400 `invalid_archive` with what tar said. Sent again, it returns how tar ended. An upload no call has named for 10 minutes since its last part or commit is ended.

func (*FunctionMachineFiles) DownloadFolder

func (g *FunctionMachineFiles) DownloadFolder(ctx context.Context, path string, q *FunctionDownloadFolderQuery, opts *RequestOptions) ([]byte, error)

DownloadFolder Returns a folder as a tar archive (`application/x-tar`, or `application/gzip` with gzip), packed by tar in the function as it streams, of any size; its entries are relative to the folder (`./a.txt`). A folder that fails part way (a file it may not read, or one that changes as it is read) ends as an archive every tar reader refuses, never as a short one that reads whole. At most 4 at once in a function. A paused function is woken first.

Link Makes an expiring address for one file that anyone may open with no API key, from a browser, curl or another service: GET downloads it (Range works, so videos play and downloads resume; archive: true downloads a folder as .tar.gz), PUT with the raw body uploads it (up to maxBytes, written whole; Content-Length required). The link acts as the key that made it: an upload link needs write, and the link ends with its key, with revokeLinks or with its function. A paused function is woken for it unless wake is false. A port it serves is shared by a preview (previews.create), not a link.

func (*FunctionMachineFiles) List

List Lists a directory's entries in path order, to a depth.

func (*FunctionMachineFiles) Mkdir

func (g *FunctionMachineFiles) Mkdir(ctx context.Context, path string, in *FileMkdir, opts *RequestOptions) (*FileMade, error)

Mkdir Makes a directory, and its parents unless parents is false. One there already is success, created false.

func (*FunctionMachineFiles) Read

Read Returns a file's bytes.

func (*FunctionMachineFiles) Remove

Remove Removes a file, a link or a directory (recursive for one with contents). One missing is success, removed false.

func (*FunctionMachineFiles) Rename

Rename Moves a file, a link or a directory; refused 409 when something is at its new path, unless overwrite. With sha256 or size, a file written in parts is put in place once whole: its writes ended, then only a file of that size with every byte written and whose bytes hash to it moves; refused 409 `upload_incomplete` or `checksum_mismatch`, nothing moved. With sha256, it is safe to send again: once moved, it returns the same answer while `from` is gone and `to` holds those bytes.

RevokeLinks Ends every file link made for a function so far; links made after work.

func (*FunctionMachineFiles) Stat

Stat Returns what is at a path: a file, a directory or a link, or nothing (exists false). With sha256=true, a file's SHA-256 too.

func (*FunctionMachineFiles) UploadFolder

UploadFolder Unpacks the request's tar archive (gzip-compressed or not, told by its first bytes) into a folder, made with its parents, by tar in the function as the bytes arrive, of any size, nothing of it kept on disk but what tar writes; returns once tar has ended, or 400 `invalid_archive` with what tar said. A paused function is woken first.

func (*FunctionMachineFiles) Write

Write Writes the request's bytes to a file as they come, of any size (Content-Length required), its folders made: the file whole when they all came, or as it was. With offset, they are written into it in place.

func (*FunctionMachineFiles) WriteFolderUpload

WriteFolderUpload Sends the request's bytes, a part of the archive at its offset, into tar's input as they arrive, of any size, and returns the bytes received in all once tar took them. A part past them is refused 409 `upload_incomplete`, naming them: send the parts in order.

type FunctionMachineNetwork

type FunctionMachineNetwork struct {
	// contains filtered or unexported fields
}

FunctionMachineNetwork is a functionmachine's network.

func (*FunctionMachineNetwork) Get

Get Returns where a function may connect out.

func (*FunctionMachineNetwork) Set

Set Replaces where a function may connect out, for its next connection and within a second for its open ones: those the new rules refuse are cut.

type FunctionMachineProcesses

type FunctionMachineProcesses struct {
	// contains filtered or unexported fields
}

FunctionMachineProcesses is a functionmachine's processes.

func (*FunctionMachineProcesses) List

List Lists a function's processes, newest first: those running and those that ended lately.

func (*FunctionMachineProcesses) Output

Output Returns a process's output after a cursor, and the cursor to read on from. The latest 1 MiB is kept; truncated says when the cursor fell behind.

func (*FunctionMachineProcesses) Resize

func (g *FunctionMachineProcesses) Resize(ctx context.Context, process string, in *Terminal, opts *RequestOptions) (*Process, error)

Resize Resizes the terminal of a process started with a pty (its window's columns and rows, which the process is told by SIGWINCH), and returns the process; refused 409 for a process without one. A process that ended is left as it is, so a retry is safe.

func (*FunctionMachineProcesses) Signal

func (g *FunctionMachineProcesses) Signal(ctx context.Context, process string, in *ProcessSignal, opts *RequestOptions) (*Process, error)

Signal Sends a signal to a process and its group; a process that ended is not signalled, so a retry is safe.

func (*FunctionMachineProcesses) Write

Write Sends input to a process started with stdinOpen or a pty, and returns how much of its input it has taken.

type FunctionMetricsQuery

type FunctionMetricsQuery struct {
	// Range The window: `15m`, `1h`, `6h`, `24h`, `7d` or `30d`. Default: "1h".
	Range *string
}

FunctionMetricsQuery is what Metrics takes in its query.

type FunctionProcessOutputQuery

type FunctionProcessOutputQuery struct {
	// Cursor Output after this byte. At least 0. Default: 0.
	Cursor *int64
	// WaitSeconds Seconds to wait for output past the cursor or its exit, at most 8. At least 0. At most 8.
	WaitSeconds *float64
	// MaxBytes At most this many bytes. At least 4096. At most 196608. Default: 65536.
	MaxBytes *int64
	// Follow Answer as NDJSON events from the cursor until it exits (stdout, stderr, truncated, exit; continue with the cursor to follow on from), as `Accept: application/x-ndjson` does.
	Follow *bool
}

FunctionProcessOutputQuery is what ProcessOutput takes in its query.

type FunctionReadQuery

type FunctionReadQuery struct {
	// Path The file's path in the machine.
	Path string
}

FunctionReadQuery is what Read takes in its query.

type FunctionScreenshotQuery

type FunctionScreenshotQuery struct {
	// Format `png`, or `jpeg`: smaller and quicker to send, for a model that reads it. Default: "png".
	Format *string
	// Quality A jpeg's quality, 1 to 100. At least 1. At most 100. Default: 80.
	Quality *int64
}

FunctionScreenshotQuery is what Screenshot takes in its query.

type FunctionStatQuery

type FunctionStatQuery struct {
	// Path The file's path in the machine.
	Path string
	// Sha256 Also return a file's SHA-256, read from its bytes: to check a file you put in place (files:rename with sha256) is whole. Default: false.
	Sha256 *bool
}

FunctionStatQuery is what Stat takes in its query.

type FunctionUploadFolderQuery

type FunctionUploadFolderQuery struct {
	// Path The folder, absolute, such as `/workspace/app`: made with its parents.
	Path string
	// User Who unpacks it: `runtime` or `root`; the function's `user` when omitted.
	User *string
}

FunctionUploadFolderQuery is what UploadFolder takes in its query.

type FunctionWriteFolderUploadQuery

type FunctionWriteFolderUploadQuery struct {
	// Offset Where the part starts in the archive: at most the bytes received so far. Bytes before them were taken already and are skipped, so a part sent again is never unpacked twice. At least 0. Default: 0.
	Offset *int64
}

FunctionWriteFolderUploadQuery is what WriteFolderUpload takes in its query.

type FunctionWriteQuery

type FunctionWriteQuery struct {
	// Path The file's path in the machine.
	Path string
	// Mode Its mode, in octal (`644`).
	Mode *string
	// Offset Write the bytes into the file in place from this byte, keeping the bytes before and after them (the file is made when there is none); one that fails part way may leave its range written in part, so send it again. Parts of one file may be written so at once and in any order: write them to a new path, then rename it with its size and sha256 to put it in place whole. At least 0.
	Offset *int64
	// Sha256 The bytes' SHA-256 in hex: refused 409 `checksum_mismatch`, the file as it was, when they differ. Not with offset.
	Sha256 *string
}

FunctionWriteQuery is what Write takes in its query.

type Functions

type Functions struct {
	// contains filtered or unexported fields
}

Functions A machine that answers HTTP with a handler in /app/index.ts (`export default { fetch(request) }`, as Cloudflare Workers and Vercel take one) on port 8080, reached at its preview. It pauses after 60 seconds with nothing happening, its memory kept, and a request resumes it.

func (*Functions) AbortFolderUpload

func (c *Functions) AbortFolderUpload(ctx context.Context, id string, upload string, opts *RequestOptions) (*FolderUploadAborted, error)

AbortFolderUpload Stops a folder upload's tar; what it unpacked so far stays.

func (*Functions) Act

func (c *Functions) Act(ctx context.Context, id string, in ActRequest, opts *RequestOptions) (*Acted, error)

Act Moves, clicks, drags and scrolls the mouse and types on the keyboard of a function's screen (its X display `:1`), each step in turn as one command, and returns where the mouse is then. It stops at the first step that fails, refused 409 `act_failed` naming it; refused 409 `display_not_running` when no display runs. A paused function is resumed first.

func (*Functions) BeginFolderUpload

func (c *Functions) BeginFolderUpload(ctx context.Context, id string, in FolderUploadBegin, opts *RequestOptions) (*FolderUpload, error)

BeginFolderUpload Begins a folder's upload in parts: tar starts in the function, unpacking into the folder each part as it arrives. Send the parts in order by offset (writeFolderUpload), then commitFolderUpload; an upload no call names for 10 minutes is ended. A paused function is woken first.

func (*Functions) CommitFolderUpload

func (c *Functions) CommitFolderUpload(ctx context.Context, id string, upload string, opts *RequestOptions) (*FolderUnpacked, error)

CommitFolderUpload Ends a folder upload's input and returns once tar has ended, as an exec returns once its command has: the folder, or 400 `invalid_archive` with what tar said. Sent again, it returns how tar ended. An upload no call has named for 10 minutes since its last part or commit is ended.

func (*Functions) Create

Create Creates a function. Asked again with the same Idempotency-Key, it returns the same function.

func (*Functions) Delete

func (c *Functions) Delete(ctx context.Context, id string, opts *RequestOptions) (*SandboxInfo, error)

Delete Deletes a function, its memory and its disk.

func (*Functions) DownloadFolder

func (c *Functions) DownloadFolder(ctx context.Context, id string, q FunctionDownloadFolderQuery, opts *RequestOptions) ([]byte, error)

DownloadFolder Returns a folder as a tar archive (`application/x-tar`, or `application/gzip` with gzip), packed by tar in the function as it streams, of any size; its entries are relative to the folder (`./a.txt`). A folder that fails part way (a file it may not read, or one that changes as it is read) ends as an archive every tar reader refuses, never as a short one that reads whole. At most 4 at once in a function. A paused function is woken first.

func (*Functions) Exec

func (c *Functions) Exec(ctx context.Context, id string, in ExecRequest, opts *RequestOptions) (*Process, error)

Exec Runs a command as a process and returns it once it ended, with its output; with wait false, at once, while it runs. A paused function is resumed first. Asked again with the same Idempotency-Key, it runs nothing more: it returns the first run's process, waiting for its end while it runs.

func (*Functions) Fork

func (c *Functions) Fork(ctx context.Context, id string, in ForkRequest, opts *RequestOptions) (*Forked, error)

Fork Copies a function as it is now, memory and disk, into `count` copies of its own, each running on its host. Asked again with the same Idempotency-Key, it returns the same copies.

func (*Functions) Get

Get Returns a function.

func (*Functions) GetNetwork

func (c *Functions) GetNetwork(ctx context.Context, id string, opts *RequestOptions) (*SandboxNetwork, error)

GetNetwork Returns where a function may connect out.

func (c *Functions) Link(ctx context.Context, id string, in FileLinkCreate, opts *RequestOptions) (*FileLink, error)

Link Makes an expiring address for one file that anyone may open with no API key, from a browser, curl or another service: GET downloads it (Range works, so videos play and downloads resume; archive: true downloads a folder as .tar.gz), PUT with the raw body uploads it (up to maxBytes, written whole; Content-Length required). The link acts as the key that made it: an upload link needs write, and the link ends with its key, with revokeLinks or with its function. A paused function is woken for it unless wake is false. A port it serves is shared by a preview (previews.create), not a link.

func (*Functions) List

List Lists the project's functions, newest first.

func (*Functions) ListAll

ListAll is every item of every page List reads from q.Cursor (none: the first page), each page read as the last is used up.

func (*Functions) ListFiles

func (c *Functions) ListFiles(ctx context.Context, id string, q FunctionListFilesQuery, opts *RequestOptions) (*FileList, error)

ListFiles Lists a directory's entries in path order, to a depth.

func (*Functions) ListProcesses

func (c *Functions) ListProcesses(ctx context.Context, id string, opts *RequestOptions) (*ProcessList, error)

ListProcesses Lists a function's processes, newest first: those running and those that ended lately.

func (*Functions) Metrics

Metrics Returns a function's CPU, memory, disks and pressure, as its host reads them from the function's own cgroup over a fifth of a second: never a call into the function, so it does not wake a paused one nor keep one from its idle pause. One that is not running has no reading.

func (*Functions) Mkdir

func (c *Functions) Mkdir(ctx context.Context, id string, in FileMkdir, opts *RequestOptions) (*FileMade, error)

Mkdir Makes a directory, and its parents unless parents is false. One there already is success, created false.

func (*Functions) Pause

func (c *Functions) Pause(ctx context.Context, id string, opts *RequestOptions) (*SandboxInfo, error)

Pause Pauses a function with its memory and disk kept. A call to it resumes it.

func (*Functions) ProcessOutput

func (c *Functions) ProcessOutput(ctx context.Context, id string, process string, q FunctionProcessOutputQuery, opts *RequestOptions) (*ProcessOutput, error)

ProcessOutput Returns a process's output after a cursor, and the cursor to read on from. The latest 1 MiB is kept; truncated says when the cursor fell behind.

func (*Functions) Read

func (c *Functions) Read(ctx context.Context, id string, q FunctionReadQuery, opts *RequestOptions) ([]byte, error)

Read Returns a file's bytes.

func (*Functions) Remove

func (c *Functions) Remove(ctx context.Context, id string, in FileRemove, opts *RequestOptions) (*FileRemoved, error)

Remove Removes a file, a link or a directory (recursive for one with contents). One missing is success, removed false.

func (*Functions) Rename

func (c *Functions) Rename(ctx context.Context, id string, in FileRename, opts *RequestOptions) (*FileRenamed, error)

Rename Moves a file, a link or a directory; refused 409 when something is at its new path, unless overwrite. With sha256 or size, a file written in parts is put in place once whole: its writes ended, then only a file of that size with every byte written and whose bytes hash to it moves; refused 409 `upload_incomplete` or `checksum_mismatch`, nothing moved. With sha256, it is safe to send again: once moved, it returns the same answer while `from` is gone and `to` holds those bytes.

func (*Functions) ResizeProcess

func (c *Functions) ResizeProcess(ctx context.Context, id string, process string, in Terminal, opts *RequestOptions) (*Process, error)

ResizeProcess Resizes the terminal of a process started with a pty (its window's columns and rows, which the process is told by SIGWINCH), and returns the process; refused 409 for a process without one. A process that ended is left as it is, so a retry is safe.

func (*Functions) Resume

func (c *Functions) Resume(ctx context.Context, id string, opts *RequestOptions) (*SandboxInfo, error)

Resume Resumes a paused function where it was, its memory and processes as they were.

func (c *Functions) RevokeLinks(ctx context.Context, id string, opts *RequestOptions) (*FileLinksRevoked, error)

RevokeLinks Ends every file link made for a function so far; links made after work.

func (*Functions) RunCode

func (c *Functions) RunCode(ctx context.Context, id string, in RunCode, opts *RequestOptions) (*CodeRun, error)

RunCode Runs a cell of Python in a function as a notebook does, in a Jupyter kernel it keeps running for the cell's `context`: variables, imports and functions stay for the next cell. Returns what it printed, its values and displays (text, HTML, images such as charts), and its exception with its traceback. The context's kernel starts on its first cell. A cell past `timeoutSeconds` is interrupted and its context kept. Refused 409 `kernel_not_installed` when the image has no ipykernel. A paused function is resumed first.

func (*Functions) Screenshot

func (c *Functions) Screenshot(ctx context.Context, id string, q FunctionScreenshotQuery, opts *RequestOptions) ([]byte, error)

Screenshot Returns what a function's screen shows now, as `image/png` (or `image/jpeg`): its X display `:1`, whole. Refused 409 `display_not_running` when no display runs. A paused function is resumed first.

func (*Functions) SetNetwork

func (c *Functions) SetNetwork(ctx context.Context, id string, in NetworkRules, opts *RequestOptions) (*SandboxNetwork, error)

SetNetwork Replaces where a function may connect out, for its next connection and within a second for its open ones: those the new rules refuse are cut.

func (*Functions) SignalProcess

func (c *Functions) SignalProcess(ctx context.Context, id string, process string, in ProcessSignal, opts *RequestOptions) (*Process, error)

SignalProcess Sends a signal to a process and its group; a process that ended is not signalled, so a retry is safe.

func (*Functions) Snapshot

func (c *Functions) Snapshot(ctx context.Context, id string, in SnapshotRequest, opts *RequestOptions) (*Stored, error)

Snapshot Keeps a function's memory and disk as they are now, a snapshot to start functions from; with `image`, its disk alone as that image's next version. The function runs on. Asked again with the same Idempotency-Key, it returns the same snapshot.

func (*Functions) Stat

Stat Returns what is at a path: a file, a directory or a link, or nothing (exists false). With sha256=true, a file's SHA-256 too.

func (*Functions) Update

func (c *Functions) Update(ctx context.Context, id string, in MachineUpdate, opts *RequestOptions) (*SandboxInfo, error)

Update Changes its name, labels, idle pause, maxCost, autoWake, lifetime, delete protection, environment or sizes; each field left out stays as it is. A lifetime (`deleteAfterSeconds`) sent again before its end moves the end to that many seconds from now; 0 takes it off. A lifetime is refused (409 `delete_protected`) while `deleteProtection` is true. A running one holds a changed environment before this answers (a paused one's at its wake): each process it starts after the answer has it, and its running processes keep the one they started with. Its vCPUs, memory and disk grow while it runs, its commands running on. One paused or stopped is not woken for it: judged at once as a live resize is (past the vCPUs it was made with 409, over its organization's limits `quota_exceeded`), its new sizes are returned at once, and its next wake grows it to them before the call that woke it runs. A smaller size, or a machine starting or failed, is refused 409 naming why, and nothing is changed. With If-Match, made only while its revision is that one, else 412. Sent again with the same Idempotency-Key and body while it is the latest change, it returns the current state and changes nothing; the same key with a different body returns 409 idempotency_key_reused.

func (*Functions) UploadFolder

func (c *Functions) UploadFolder(ctx context.Context, id string, data []byte, q FunctionUploadFolderQuery, opts *RequestOptions) (*FolderUnpacked, error)

UploadFolder Unpacks the request's tar archive (gzip-compressed or not, told by its first bytes) into a folder, made with its parents, by tar in the function as the bytes arrive, of any size, nothing of it kept on disk but what tar writes; returns once tar has ended, or 400 `invalid_archive` with what tar said. A paused function is woken first.

func (*Functions) Write

func (c *Functions) Write(ctx context.Context, id string, data []byte, q FunctionWriteQuery, opts *RequestOptions) (*FileWritten, error)

Write Writes the request's bytes to a file as they come, of any size (Content-Length required), its folders made: the file whole when they all came, or as it was. With offset, they are written into it in place.

func (*Functions) WriteFolderUpload

func (c *Functions) WriteFolderUpload(ctx context.Context, id string, upload string, data []byte, q FunctionWriteFolderUploadQuery, opts *RequestOptions) (*FolderUploadReceived, error)

WriteFolderUpload Sends the request's bytes, a part of the archive at its offset, into tar's input as they arrive, of any size, and returns the bytes received in all once tar took them. A part past them is refused 409 `upload_incomplete`, naming them: send the parts in order.

func (*Functions) WriteProcess

func (c *Functions) WriteProcess(ctx context.Context, id string, process string, in ProcessInput, opts *RequestOptions) (*ProcessWritten, error)

WriteProcess Sends input to a process started with stdinOpen or a pty, and returns how much of its input it has taken.

type Identities

type Identities struct {
	// contains filtered or unexported fields
}

Identities An agent or CI pipeline: who a key acts as besides a person, holding grants of its own.

func (*Identities) Delete

func (c *Identities) Delete(ctx context.Context, id string, opts *RequestOptions) (*IdentityInfo, error)

Delete Deletes an agent or CI pipeline and frees its name, with its grants and keys: refused from their next call. The caller needs `grants:delete` as well, as the grants go with it. What it made stays. Deleted again, it returns 404.

func (*Identities) Get added in v2.1.0

Get Returns one by its ID. Another organization's, one deleted, or one past the key's reach returns 404.

func (*Identities) List

List Lists the organization's agents and CI pipelines, by name.

func (*Identities) ListAll

ListAll is every item of every page List reads from q.Cursor (none: the first page), each page read as the last is used up.

func (*Identities) Update

func (c *Identities) Update(ctx context.Context, id string, in Rename, opts *RequestOptions) (*IdentityInfo, error)

Update Renames an agent or CI pipeline; its keys and grants stay as they are. A name another of its kind has returns 409.

type Identity

type Identity struct {

	// Info is what it was when last read.
	Info *IdentityInfo
	// contains filtered or unexported fields
}

Identity is one of identities: An agent or CI pipeline: who a key acts as besides a person, holding grants of its own.

func (*Identity) Delete added in v2.1.0

func (s *Identity) Delete(ctx context.Context, opts *RequestOptions) (*IdentityInfo, error)

Delete Deletes an agent or CI pipeline and frees its name, with its grants and keys: refused from their next call. The caller needs `grants:delete` as well, as the grants go with it. What it made stays. Deleted again, it returns 404.

func (*Identity) ID

func (s *Identity) ID() string

ID is its id.

func (*Identity) Refresh added in v2.1.0

func (s *Identity) Refresh(ctx context.Context, q *IdentityGetQuery, opts *RequestOptions) error

Refresh Returns one by its ID. Another organization's, one deleted, or one past the key's reach returns 404.

func (*Identity) Update added in v2.1.0

func (s *Identity) Update(ctx context.Context, name string, in *Rename, opts *RequestOptions) error

Update Renames an agent or CI pipeline; its keys and grants stay as they are. A name another of its kind has returns 409.

type IdentityGetQuery added in v2.1.0

type IdentityGetQuery struct {
	// Wait Seconds to wait, at most 60, for its state to differ from `ifState`; it answers once it does, or as it is when the wait ends. At least 0. At most 60.
	Wait *float64
	// IfState The state the caller last read, which `wait` waits for it to leave.
	IfState *string
}

IdentityGetQuery is what Get takes in its query.

type IdentityInfo added in v2.1.0

type IdentityInfo struct {
	// ID Its ID, a key's `agentId`.
	ID string `json:"id"`
	// Object Always `identity`.
	Object string `json:"object"`
	// Kind `agent` or `ci`.
	Kind string `json:"kind"`
	// Name Its name, unique in the organization for its kind.
	Name string `json:"name"`
	// CreatedAt When it was made.
	CreatedAt string `json:"createdAt"`
	// State `active`; `deleted` once deleted: a delete's answer.
	State string `json:"state"`
	// DeletedAt When it was deleted: a delete's answer, its state `deleted`.
	DeletedAt *string `json:"deletedAt,omitempty"`
}

IdentityInfo An agent or CI pipeline: who a key acts as, besides a person.

type IdentityListQuery

type IdentityListQuery struct {
	// Cursor Where the page starts: a page's `next`.
	Cursor *string
	// Limit The most items the page holds. At least 1. At most 200. Default: 50.
	Limit *int64
}

IdentityListQuery is what List takes in its query.

type Image

type Image struct {

	// Info is what it was when last read.
	Info *Stored
	// contains filtered or unexported fields
}

Image is one of images: What a machine boots: a root filesystem, its environment and its start.

func (*Image) Delete

func (s *Image) Delete(ctx context.Context, opts *RequestOptions) (*Stored, error)

Delete Deletes an image version. Machines already started from it keep running. One an App boots from is refused with image_in_use (409) naming the App.

func (*Image) ID

func (s *Image) ID() string

ID is its id.

func (*Image) Logs

func (s *Image) Logs(ctx context.Context, q *ImageLogsQuery, opts *RequestOptions) (*ImageLogs, error)

Logs Returns an image's build log after a line, as the build writes it and once it has ended.

func (*Image) Refresh

func (s *Image) Refresh(ctx context.Context, q *ImageGetQuery, opts *RequestOptions) error

Refresh Returns an image, by its ID, its name (its newest version) or one of its tags (`name:tag`).

func (*Image) Update

func (s *Image) Update(ctx context.Context, in *StoredUpdate, opts *RequestOptions) error

Update Changes its lifetime (`deleteAfterSeconds`) or delete protection (`deleteProtection`). A lifetime sent again before its end moves the end to that many seconds from now; 0 takes it off. At its end Runtime deletes it as its delete does: final, and it can't be undone. A lifetime and protection are never set together (409 `delete_protected`). Each field left out stays as it is.

type ImageArchive

type ImageArchive struct {
	// Sha256 The whole archive's SHA-256, in hex.
	Sha256 string `json:"sha256"`
	// Size Its size in bytes. At least 1.
	Size int64 `json:"size"`
	// Chunks Its chunks' SHA-256s, in order. At most 200 items.
	Chunks []string `json:"chunks"`
}

ImageArchive A build context's archive: a tar (gzip allowed), cut into chunks of at most 1 MiB, each uploaded first (`images.context.put`).

type ImageBuild

type ImageBuild struct {
	// Vcpu Its vCPUs; a build machine's default when omitted. At least 1. At most 8.
	Vcpu *int64 `json:"vcpu,omitempty"`
	// MemoryGb Its memory in GB; a build machine's default when omitted. At least 1. At most 16.
	MemoryGb *float64 `json:"memoryGB,omitempty"`
	// DiskGb Its disk in GB: the base image, the earlier stages and the context. A build machine's default when omitted, at least its image's size. At least 4. At most 32.
	DiskGb *float64 `json:"diskGB,omitempty"`
	// TimeoutSeconds Seconds the build may run before it fails. At least 60. At most 3600. Default: 1800.
	TimeoutSeconds *int64 `json:"timeoutSeconds,omitempty"`
}

ImageBuild What an image's build runs on: a machine of its own, deleted once the build ends.

type ImageContext

type ImageContext struct {
	// Archive The archive.
	Archive ImageArchive `json:"archive"`
	// Files Every regular file in it.
	Files []ImageContextFile `json:"files"`
}

ImageContext A build context uploaded as chunks: the SDKs and CLI make it from a folder and its `.dockerignore`.

type ImageContextFile

type ImageContextFile struct {
	// Path Its path in the context.
	Path string `json:"path"`
	// Sha256 Its SHA-256, in hex.
	Sha256 string `json:"sha256"`
	// Size Its size in bytes.
	Size int64 `json:"size"`
	// Mode Its permission bits.
	Mode *int64 `json:"mode,omitempty"`
}

ImageContextFile A regular file of a build context's archive.

type ImageCreate

type ImageCreate struct {
	// Name Its name, 1 to 64 of `a-z`, `0-9`, `.`, `_` and `-`: each build of a name is its next version.
	Name *string `json:"name,omitempty"`
	// Labels Labels to find it by.
	Labels map[string]string `json:"labels,omitempty"`
	// Tags Tags its name takes for it once it is ready; `latest` when it has a name and none is given. At most 16 items.
	Tags []string `json:"tags,omitempty"`
	// Image An OCI image to use as it is: `python:3.12-slim`, `ghcr.io/org/app:1`. A private one is named by its digest, `repo@sha256:<64 hex digits>`, with `pullSecret`.
	Image *string `json:"image,omitempty"`
	// PullSecret The secret holding the registry login that pulls a private `image`: a hidden secret with header `Authorization`, format `Basic {value}`, its value the base64 of `username:token`, as its hosts the registry's token service (`auth.docker.io` for Docker Hub, the registry's own name for `ghcr.io`, `quay.io` and others), and as its scope `{"none": true}`, so no machine's requests carry it. Runtime's egress proxy signs in with it for this import's build machine alone, which never holds the login or a token. The caller needs the `secrets:use` permission.
	PullSecret *string `json:"pullSecret,omitempty"`
	// Dockerfile A Dockerfile: multi-stage builds, `ARG`, `COPY --from`, heredocs. `COPY` reads `files`.
	Dockerfile *string `json:"dockerfile,omitempty"`
	// Recipe Packages, files and commands, rendered into a Dockerfile. Not with `files` or `context`.
	Recipe *ImageRecipe `json:"recipe,omitempty"`
	// Files The Dockerfile's build context, inline: at most 1 MiB in all. Not with `context`. At most 256 items.
	Files []ImageFile `json:"files,omitempty"`
	// Context The Dockerfile's build context, uploaded first as chunks: up to 200 MiB. Not with `files`.
	Context *ImageContext `json:"context,omitempty"`
	// Dockerignore The context's `.dockerignore`: what it names is never copied.
	Dockerignore *string `json:"dockerignore,omitempty"`
	// Target The stage to build instead of the last.
	Target *string `json:"target,omitempty"`
	// BuildArgs The Dockerfile's `ARG` values.
	BuildArgs map[string]string `json:"buildArgs,omitempty"`
	// Env Environment every machine from it starts with, over the Dockerfile's `ENV`.
	Env map[string]string `json:"env,omitempty"`
	// Start What every machine from it starts at each fresh boot, in place of the Dockerfile's `ENTRYPOINT` and `CMD`.
	Start *MachineStart `json:"start,omitempty"`
	// Build What its build runs on.
	Build *ImageBuild `json:"build,omitempty"`
	// DeleteAfterSeconds Seconds until Runtime deletes this version, as its delete does: final, and it can't be undone; one an App boots is deleted once none does. 0 or omitted: kept until deleted. At least 0. At most 315360000.
	DeleteAfterSeconds *int64 `json:"deleteAfterSeconds,omitempty"`
	// DeleteProtection Whether this version's delete is refused (409 `delete_protected`) until an update turns this off; false when omitted. Not with `deleteAfterSeconds`.
	DeleteProtection *bool `json:"deleteProtection,omitempty"`
}

ImageCreate An image to build, from exactly one of `image` and `dockerfile`.

type ImageFile

type ImageFile struct {
	// Path Its path in the build context, which `COPY` and `ADD` read.
	Path string `json:"path"`
	// Content Its content: UTF-8 text, or base64 when `encoding` says so.
	Content string `json:"content"`
	// Encoding `utf8` (the default) or `base64`.
	Encoding *string `json:"encoding,omitempty"`
	// Mode Its permission bits, 0 to 511 (0777 in octal). At least 0. At most 511.
	Mode *int64 `json:"mode,omitempty"`
}

ImageFile A file of an image build's context, sent inline.

type ImageGetQuery

type ImageGetQuery struct {
	// Wait Seconds to wait, at most 60, for its state to differ from `ifState`; it answers once it does, or as it is when the wait ends. At least 0. At most 60.
	Wait *float64
	// IfState The state the caller last read, which `wait` waits for it to leave.
	IfState *string
}

ImageGetQuery is what Get takes in its query.

type ImageListQuery

type ImageListQuery struct {
	// Name Only those of this name.
	Name *string
	// State Only those in these states, comma-separated.
	State *string
	// Label Only those with every label given (repeat it for several): key:value, or a key for any value.
	Label []string
	// Cursor Where the page starts: a page's `next`.
	Cursor *string
	// Limit The most items the page holds. At least 1. At most 200. Default: 50.
	Limit *int64
}

ImageListQuery is what List takes in its query.

type ImageLogLine

type ImageLogLine struct {
	// Seq Its number, from 1.
	Seq int64 `json:"seq"`
	// At When it was written.
	At string `json:"at"`
	// Stream `build` (the build's output) or `system` (Runtime's).
	Stream string `json:"stream"`
	// Text The line, without its newline.
	Text string `json:"text"`
}

ImageLogLine One line of an image's build log.

type ImageLogs

type ImageLogs struct {
	// Lines The lines after `after`, in order.
	Lines []ImageLogLine `json:"lines"`
	// NextAfter The last line's number: send it as `after` to read on.
	NextAfter int64 `json:"nextAfter"`
	// State The image's state.
	State string `json:"state"`
	// Truncated Whether lines before these were dropped.
	Truncated bool `json:"truncated"`
	// Done Whether the build has ended: no line comes after these.
	Done bool `json:"done"`
}

ImageLogs An image's build log after a line.

type ImageLogsQuery

type ImageLogsQuery struct {
	// After Lines after this one. At least 0. Default: 0.
	After *int64
	// Limit At most this many lines. At least 1. At most 1000. Default: 1000.
	Limit *int64
	// Follow Answer as NDJSON events until the build ends: `line` for each, then `done` with the image, or `continue` with the `after` to follow on from; as `Accept: application/x-ndjson` does.
	Follow *bool
}

ImageLogsQuery is what Logs takes in its query.

type ImageRecipe

type ImageRecipe struct {
	// Base The image it starts from: `runtime` (the default, Runtime's own) or an OCI image, such as `python:3.12-slim`.
	Base *string `json:"base,omitempty"`
	// Apt Debian packages, each `name` or `name=version`. At most 500 items.
	Apt []string `json:"apt,omitempty"`
	// Pip Python packages, each as pip takes one: `pandas`, `numpy==2.1`, `uvicorn[standard]>=0.30`. At most 500 items.
	Pip []string `json:"pip,omitempty"`
	// Npm npm packages, installed globally: `typescript`, `@scope/tool@1`. At most 500 items.
	Npm []string `json:"npm,omitempty"`
	// Commands Shell commands, each run by `/bin/sh` in `workdir` after the packages and files. At most 500 items.
	Commands []string `json:"commands,omitempty"`
	// Env Environment set before the packages; `$NAME` names its base's.
	Env map[string]string `json:"env,omitempty"`
	// Files Files written into the image, each `path` absolute: at most 1 MiB in all. At most 256 items.
	Files []ImageFile `json:"files,omitempty"`
	// Workdir Where its commands run and its machines start: `/workspace` by default.
	Workdir *string `json:"workdir,omitempty"`
}

ImageRecipe An image described by its packages, files and commands, rendered into a Dockerfile: `FROM` its base, its `env`, one `RUN` each for its apt, pip and npm packages, its files, then its commands in `workdir`.

type Images

type Images struct {
	// contains filtered or unexported fields
}

Images What a machine boots: a root filesystem, its environment and its start.

func (*Images) Create

func (c *Images) Create(ctx context.Context, in ImageCreate, opts *RequestOptions) (*Image, error)

Create Builds an image from an OCI image or a Dockerfile on a machine of its own, and returns it at once, `making`: `ready` once built, else `failed` with `error`. Each build of a name is its next version. Asked again with the same Idempotency-Key, it returns the same one.

func (*Images) Delete

func (c *Images) Delete(ctx context.Context, id string, opts *RequestOptions) (*Stored, error)

Delete Deletes an image version. Machines already started from it keep running. One an App boots from is refused with image_in_use (409) naming the App.

func (*Images) Get

func (c *Images) Get(ctx context.Context, id string, q ImageGetQuery, opts *RequestOptions) (*Image, error)

Get Returns an image, by its ID, its name (its newest version) or one of its tags (`name:tag`).

func (*Images) List

func (c *Images) List(ctx context.Context, q ImageListQuery, opts *RequestOptions) (*Page[Stored], error)

List Lists the project's images, newest first.

func (*Images) ListAll

func (c *Images) ListAll(ctx context.Context, q ImageListQuery, opts *RequestOptions) iter.Seq2[Stored, error]

ListAll is every item of every page List reads from q.Cursor (none: the first page), each page read as the last is used up.

func (*Images) Logs

func (c *Images) Logs(ctx context.Context, id string, q ImageLogsQuery, opts *RequestOptions) (*ImageLogs, error)

Logs Returns an image's build log after a line, as the build writes it and once it has ended.

func (*Images) Missing

func (c *Images) Missing(ctx context.Context, in ContextAsked, opts *RequestOptions) (*ContextMissing, error)

Missing Returns which chunks of a build context still need uploading. The chunks it holds count as used, so they are kept for the build that names them: a chunk is kept 24 hours after its last use, and an organization's build context holds at most 200 MiB.

func (*Images) Put

func (c *Images) Put(ctx context.Context, digest string, data []byte, opts *RequestOptions) (*ChunkStored, error)

Put Uploads one chunk of a build context: the request's bytes, 1 byte to 1 MiB, named by their SHA-256. Asked again, it stores nothing more.

func (*Images) Update

func (c *Images) Update(ctx context.Context, id string, in StoredUpdate, opts *RequestOptions) (*Stored, error)

Update Changes its lifetime (`deleteAfterSeconds`) or delete protection (`deleteProtection`). A lifetime sent again before its end moves the end to that many seconds from now; 0 takes it off. At its end Runtime deletes it as its delete does: final, and it can't be undone. A lifetime and protection are never set together (409 `delete_protected`). Each field left out stays as it is.

type Job

type Job struct {

	// Info is what it was when last read.
	Info *JobInfo
	// contains filtered or unexported fields
}

Job is one of jobs: A command run in a fresh machine, once or on a cron schedule in a timezone. Each run is a machine made at its time, deleted when its command ends, and billed as any machine is; its exit code and its last 256 KiB of output are kept. Runs of one job never overlap: a time that comes while one runs is made once it ends, and times missed make one run.

func (*Job) Delete

func (s *Job) Delete(ctx context.Context, opts *RequestOptions) (*JobInfo, error)

Delete Deletes a job: no run is made from then on, and a run in flight is ended. Its runs' records stay readable for 7 days.

func (*Job) ID

func (s *Job) ID() string

ID is its id.

func (*Job) Pause

func (s *Job) Pause(ctx context.Context, opts *RequestOptions) error

Pause Pauses a job: no run is made at its times until it is resumed. A run in flight runs to its end.

func (*Job) Refresh

func (s *Job) Refresh(ctx context.Context, q *JobGetQuery, opts *RequestOptions) error

Refresh Returns a job.

func (*Job) Resume

func (s *Job) Resume(ctx context.Context, opts *RequestOptions) error

Resume Resumes a paused job: its next run is made at its schedule's next time from now.

func (*Job) Run

func (s *Job) Run(ctx context.Context, opts *RequestOptions) error

Run Makes a run now, beside its schedule; a paused job stays paused. Refused 409 while a run of it is in flight. Asked again with the same Idempotency-Key, it makes nothing more.

func (*Job) Update

func (s *Job) Update(ctx context.Context, in *JobSettings, opts *RequestOptions) error

Update Changes a job's settings: each one named replaces its own, the rest are kept. Runs made from then on use them; one in flight runs as it was made. A new schedule's next run is at its next time from now.

type JobCreate

type JobCreate struct {
	JobSettings
	// Name Its name, unique in its project.
	Name *string `json:"name,omitempty"`
	// Labels Labels to find it by; each run carries them.
	Labels map[string]string `json:"labels,omitempty"`
}

JobCreate A job to create: its schedule and run are required.

type JobError

type JobError struct {
	// At The time whose run was not made.
	At string `json:"at"`
	// Status The HTTP status its create was answered with.
	Status int64 `json:"status"`
	// Code The error's code, as any call's error names it.
	Code string `json:"code"`
	// Message What went wrong.
	Message string `json:"message"`
	// RequestID The create's request ID, for support.
	RequestID *string `json:"requestId,omitempty"`
}

JobError Why a time's run was not made and will not be tried again: the answer its create got. The job waits for its next time; a run made takes it off.

type JobGetQuery

type JobGetQuery struct {
	// Wait Seconds to wait, at most 60, for its state to differ from `ifState`; it answers once it does, or as it is when the wait ends. At least 0. At most 60.
	Wait *float64
	// IfState The state the caller last read, which `wait` waits for it to leave.
	IfState *string
}

JobGetQuery is what Get takes in its query.

type JobInfo

type JobInfo struct {
	JobSettings
	// ID Its ID.
	ID string `json:"id"`
	// Object Always `job`.
	Object string `json:"object"`
	// Name Its name, unique in its project.
	Name *string `json:"name,omitempty"`
	// State Where it is: `scheduled` (its runs are made at their times), `paused` (none is), `finished` (its one time ran).
	State string `json:"state"`
	// Labels Its labels.
	Labels map[string]string `json:"labels"`
	// NextRunAt When its next run is made, or its next retry; none when paused or finished.
	NextRunAt *string `json:"nextRunAt,omitempty"`
	// LastError Why its last time's run was not made, when it was refused: that time failed and it waits for its next; none once a run is made.
	LastError *JobError `json:"lastError,omitempty"`
	// CreatedAt When it was created.
	CreatedAt *string `json:"createdAt,omitempty"`
	// Revision Its revision, changed by every change to it.
	Revision *int64 `json:"revision,omitempty"`
	// DeletedAt When it was deleted: a delete's answer, its state `deleted`.
	DeletedAt *string `json:"deletedAt,omitempty"`
}

JobInfo A job.

type JobListQuery

type JobListQuery struct {
	// Label Only those with every label given (repeat it for several): key:value, or a key for any value.
	Label []string
	// Cursor Where the page starts: a page's `next`.
	Cursor *string
	// Limit The most items the page holds. At least 1. At most 200. Default: 50.
	Limit *int64
}

JobListQuery is what List takes in its query.

type JobRetry

type JobRetry struct {
	// MaxAttempts Attempts in all for one time, the first included; 1 (no retry) when omitted. At least 1. At most 10. Default: 1.
	MaxAttempts *int64 `json:"maxAttempts,omitempty"`
	// BackoffSeconds Seconds from a failed attempt's end to the next. At least 0. At most 86400. Default: 30.
	BackoffSeconds *int64 `json:"backoffSeconds,omitempty"`
}

JobRetry How a failed run is run again: a run that ends with an exit code other than 0, or at its timeout.

type JobRun

type JobRun struct {
	// ID Its ID.
	ID string `json:"id"`
	// Object Always `job.run`.
	Object string `json:"object"`
	// Job Its job's ID.
	Job string `json:"job"`
	// State Its machine's state: `starting` and `running` while it runs, `deleted` once it ended, `error` when it failed to start.
	State string `json:"state"`
	// At The time it is for: its schedule's, or when it was asked for.
	At string `json:"at"`
	// Attempt Its attempt at that time, from 1.
	Attempt int64 `json:"attempt"`
	// Manual Someone asked for it (`run`), rather than its schedule.
	Manual bool `json:"manual"`
	// CreatedAt When it was made.
	CreatedAt string `json:"createdAt"`
	// EndedAt When its command ended.
	EndedAt *string `json:"endedAt,omitempty"`
	// ExitCode Its command's exit code, once it ended; none for one a signal or its timeout ended, or one deleted before its end.
	ExitCode *int64 `json:"exitCode,omitempty"`
	// Succeeded It ended with exit code 0.
	Succeeded bool `json:"succeeded"`
	// OutputBytes How many bytes its command wrote, stdout and stderr together.
	OutputBytes *int64 `json:"outputBytes,omitempty"`
}

JobRun One run of a job: a machine made at one of its times, deleted when its command ended.

type JobRunGetQuery

type JobRunGetQuery struct {
	// Wait Seconds to wait, at most 60, for its state to differ from `ifState`; it answers once it does, or as it is when the wait ends. At least 0. At most 60.
	Wait *float64
	// IfState The state the caller last read, which `wait` waits for it to leave.
	IfState *string
}

JobRunGetQuery is what Get takes in its query.

type JobRunListQuery

type JobRunListQuery struct {
	// Job Its job, by ID.
	Job string
	// Order `newest` first, or `oldest` first. Default: "oldest".
	Order *string
	// Cursor Where the page starts: a page's `next`.
	Cursor *string
	// Limit The most items the page holds. At least 1. At most 200. Default: 50.
	Limit *int64
}

JobRunListQuery is what List takes in its query.

type JobRunOutput

type JobRunOutput struct {
	// Chunks The output, in the order it was written.
	Chunks []OutputChunk `json:"chunks"`
	// NextCursor The cursor to read on from.
	NextCursor int64 `json:"nextCursor"`
	// Truncated Output before what is kept was dropped, past the cursor.
	Truncated bool `json:"truncated"`
	// Complete The run ended and nothing is left past the next cursor.
	Complete bool `json:"complete"`
}

JobRunOutput A run's output, stdout and stderr together in the order written, after a cursor: its last 256 KiB are kept.

type JobRunOutputQuery

type JobRunOutputQuery struct {
	// Cursor Output after this byte. At least 0. Default: 0.
	Cursor *int64
	// MaxBytes At most this many bytes. At least 1. At most 262144. Default: 65536.
	MaxBytes *int64
}

JobRunOutputQuery is what Output takes in its query.

type JobRuns

type JobRuns struct {
	// contains filtered or unexported fields
}

JobRuns One run of a job: a machine made at one of its times, deleted when its command ends. Its record (exit code, times, the last 256 KiB of its output) stays readable for 7 days after.

func (*JobRuns) Get

func (c *JobRuns) Get(ctx context.Context, id string, q JobRunGetQuery, opts *RequestOptions) (*JobRun, error)

Get Returns a run.

func (*JobRuns) List

func (c *JobRuns) List(ctx context.Context, q JobRunListQuery, opts *RequestOptions) (*Page[JobRun], error)

List Lists a job's runs, oldest first unless `order` is `newest`, deleted ones included while their records are kept.

func (*JobRuns) ListAll

ListAll is every item of every page List reads from q.Cursor (none: the first page), each page read as the last is used up.

func (*JobRuns) Output

Output Returns a run's output after a cursor, stdout and stderr together in the order written, and the cursor to read on from. Its last 256 KiB are kept; truncated says when the cursor fell before them.

type JobSchedule

type JobSchedule struct {
	// At The one time it runs.
	At *string `json:"at,omitempty"`
	// Cron A cron expression of five fields (minute, hour, day of month, month, day of week), as cron reads them, or `@hourly`, `@daily`, `@weekly`, `@monthly` or `@yearly`.
	Cron *string `json:"cron,omitempty"`
	// Timezone The IANA timezone its cron's times are in (`America/Denver`), daylight saving included; UTC when omitted.
	Timezone *string `json:"timezone,omitempty"`
}

JobSchedule When a job runs: once, at `at`; or at each time of its `cron` in its `timezone`. One of the two.

type JobSecrets

type JobSecrets struct {
	// Only The secrets each run gets in their own variables, by name: only those of them whose scope admits it; [] none. At most 64 items.
	Only []string `json:"only,omitempty"`
	// Env Variables each holding the value of one of the org's visible secrets whose scope admits the run, by the secret's name, `only` or not: `{"WEBSITE_TOKEN": "CRON_SECRET"}`.
	Env map[string]string `json:"env,omitempty"`
}

JobSecrets Which of its org's secrets each run gets, and under which variables.

type JobSettings

type JobSettings struct {
	// Schedule When it runs.
	Schedule *JobSchedule `json:"schedule,omitempty"`
	// Run The command each run runs; the run ends when it ends.
	Run *SandboxRun `json:"run,omitempty"`
	// Retry How a failed run is run again; never when omitted.
	Retry *JobRetry `json:"retry,omitempty"`
	// Secrets Which of its org's secrets each run gets; every one whose scope admits it when omitted.
	Secrets *JobSecrets `json:"secrets,omitempty"`
	// Vcpu Each run's vCPUs, at least every plan's least (a smaller number is taken as it); a job's default (2) when omitted. At least 2.
	Vcpu *int64 `json:"vcpu,omitempty"`
	// MemoryGb Each run's memory in GB (1 GB is 1,024 MiB); a fraction is taken to the MiB (`0.5`). A job's default (1) when omitted. At least 1.
	MemoryGb *float64 `json:"memoryGB,omitempty"`
	// DiskGb Each run's disk in GB, to the MiB, over a fresh copy of its image. When omitted, a job's default (4) or its image's size, whichever is larger. At least 1.
	DiskGb *float64 `json:"diskGB,omitempty"`
	// Image The image each run boots, by name (its newest version), `name:version` or ID; Runtime's default image when omitted.
	Image *string `json:"image,omitempty"`
	// User Who its command runs as: `runtime` (uid 1000, with passwordless sudo) or `root`. Its image's when omitted, else `runtime`.
	User *string `json:"user,omitempty"`
	// Volumes Volumes each run attaches and mounts, at most one, in the job's project; a run waits while another machine holds it.
	Volumes []VolumeMount `json:"volumes,omitempty"`
	// MaxCost The most one run may cost, in US dollars (`"0.50"`): a run pauses once it has cost that, as a machine at its maxCost does.
	MaxCost *string `json:"maxCost,omitempty"`
}

JobSettings A job's settings: what each of its runs is made with.

type Jobs

type Jobs struct {
	// contains filtered or unexported fields
}

Jobs A command run in a fresh machine, once or on a cron schedule in a timezone. Each run is a machine made at its time, deleted when its command ends, and billed as any machine is; its exit code and its last 256 KiB of output are kept. Runs of one job never overlap: a time that comes while one runs is made once it ends, and times missed make one run.

func (*Jobs) Create

func (c *Jobs) Create(ctx context.Context, in JobCreate, opts *RequestOptions) (*Job, error)

Create Creates a job. Its first run is made at its schedule's first time. Asked again with the same Idempotency-Key, it returns the same job.

func (*Jobs) Delete

func (c *Jobs) Delete(ctx context.Context, id string, opts *RequestOptions) (*JobInfo, error)

Delete Deletes a job: no run is made from then on, and a run in flight is ended. Its runs' records stay readable for 7 days.

func (*Jobs) Get

func (c *Jobs) Get(ctx context.Context, id string, q JobGetQuery, opts *RequestOptions) (*Job, error)

Get Returns a job.

func (*Jobs) List

func (c *Jobs) List(ctx context.Context, q JobListQuery, opts *RequestOptions) (*Page[JobInfo], error)

List Lists the project's jobs, newest first.

func (*Jobs) ListAll

func (c *Jobs) ListAll(ctx context.Context, q JobListQuery, opts *RequestOptions) iter.Seq2[JobInfo, error]

ListAll is every item of every page List reads from q.Cursor (none: the first page), each page read as the last is used up.

func (*Jobs) Pause

func (c *Jobs) Pause(ctx context.Context, id string, opts *RequestOptions) (*JobInfo, error)

Pause Pauses a job: no run is made at its times until it is resumed. A run in flight runs to its end.

func (*Jobs) Resume

func (c *Jobs) Resume(ctx context.Context, id string, opts *RequestOptions) (*JobInfo, error)

Resume Resumes a paused job: its next run is made at its schedule's next time from now.

func (*Jobs) Run

func (c *Jobs) Run(ctx context.Context, id string, opts *RequestOptions) (*JobInfo, error)

Run Makes a run now, beside its schedule; a paused job stays paused. Refused 409 while a run of it is in flight. Asked again with the same Idempotency-Key, it makes nothing more.

func (*Jobs) Update

func (c *Jobs) Update(ctx context.Context, id string, in JobSettings, opts *RequestOptions) (*JobInfo, error)

Update Changes a job's settings: each one named replaces its own, the rest are kept. Runs made from then on use them; one in flight runs as it was made. A new schedule's next run is at its next time from now.

type Key

type Key struct {
	// ID Its ID.
	ID string `json:"id"`
	// Object Always `key`.
	Object string `json:"object"`
	// Name Its name, as its maker gave it.
	Name string `json:"name"`
	// State `active` while it works; `deleted` once revoked: a delete's answer.
	State string `json:"state"`
	// AccountID The person it acts as or for.
	AccountID *string `json:"accountId,omitempty"`
	// AgentID The agent or CI pipeline it acts as.
	AgentID *string `json:"agentId,omitempty"`
	// ProjectID The one project it acts in; every project its holder reaches when omitted.
	ProjectID *string `json:"projectId,omitempty"`
	// CreatedAt When it was made.
	CreatedAt string `json:"createdAt"`
	// ExpiresAt When it stops working; never when omitted.
	ExpiresAt *string `json:"expiresAt,omitempty"`
	// LastUsedAt When it was last used.
	LastUsedAt *string `json:"lastUsedAt,omitempty"`
	// MaxCost The most one request made with it commits, in US dollars.
	MaxCost *string `json:"maxCost,omitempty"`
	// SpendCap The most the machines made with it, with those of every key made with it, may spend over spendCapWindowSeconds, in US dollars.
	SpendCap *string `json:"spendCap,omitempty"`
	// SpendCapWindowSeconds The rolling window spendCap counts over, in seconds.
	SpendCapWindowSeconds *int64 `json:"spendCapWindowSeconds,omitempty"`
	// Spent What it spent over spendCapWindowSeconds (the last 24 hours when it has no spendCap), in US dollars, as spendCap counts it: its machines' and those of every key made with it. Listed and updated keys only.
	Spent *string `json:"spent,omitempty"`
	// DeletedAt When it was revoked: a delete's answer, its state `deleted`.
	DeletedAt *string `json:"deletedAt,omitempty"`
	// Github The GitHub Actions jobs that may assume it: such a key has no secret.
	Github *KeyGitHubTrust `json:"github,omitempty"`
}

Key An API key, without its secret.

type KeyAuthorization

type KeyAuthorization struct {
	// ClientID The client's `client_id`.
	ClientID string `json:"clientId"`
	// RedirectUri Where the client is sent back: one of its redirect URIs.
	RedirectUri string `json:"redirectUri"`
	// CodeChallenge Its S256 `code_challenge`.
	CodeChallenge string `json:"codeChallenge"`
	// State Its `state`, sent back unchanged.
	State *string `json:"state,omitempty"`
}

KeyAuthorization An OAuth client's request for a key, as `/v2/oauth/authorize` received it.

type KeyCreate

type KeyCreate struct {
	// Name Its name. At least 1 character. At most 64 characters.
	Name string `json:"name"`
	// ProjectID Held to this one project (Growth and up); every project its holder reaches when omitted.
	ProjectID *string `json:"projectId,omitempty"`
	// AgentID One of the organization's agents or CI pipelines it acts as, for the caller; the caller itself when omitted.
	AgentID *string `json:"agentId,omitempty"`
	// Actions The actions it holds, each `product:action` as each call's reference page names it (`sandboxes:create`, `sandboxes:exec`), on every plan: it acts as an agent of its own granted exactly these, never more than its caller may do or spend, in every project its caller reaches (one held to one project, with projectId or by a caller that reaches one alone, starts at Growth), and its agent and role are deleted with it. Omitted, it holds every action its holder's grant allows, or, made with a key that has actions, those actions. Not with agentId.
	Actions []string `json:"actions,omitempty"`
	// ExpiresInSeconds Seconds until it stops working; never when omitted. At least 60. At most 31536000.
	ExpiresInSeconds *int64 `json:"expiresInSeconds,omitempty"`
	// MaxCost The most one request made with it may commit, in US dollars (`"5.00"`): one asking more is refused 403, and a create that names no maxCost gets this one. Made with a key that has one, at most that key's.
	MaxCost *string `json:"maxCost,omitempty"`
	// SpendCap The most the machines made with it, with those of every key made with it, may spend over spendCapWindowSeconds, in US dollars, as billed: once reached, a create is refused 403 until the window passes it, and a create that names no maxCost gets what is left as its maxCost. Running machines may pass it. Made with a key that has one, at most that key's, and counted in it too.
	SpendCap *string `json:"spendCap,omitempty"`
	// SpendCapWindowSeconds The rolling window spendCap counts over, in seconds; a day when omitted. At least 60. At most 2592000.
	SpendCapWindowSeconds *int64 `json:"spendCapWindowSeconds,omitempty"`
	// UserCode The code a device shows (OAuth 2.0 device flow, RFC 8628): the key goes to that device, never in this answer.
	UserCode *string `json:"userCode,omitempty"`
	// Authorization An OAuth client's request (authorization code with PKCE): the key goes to that client, never in this answer.
	Authorization *KeyAuthorization `json:"authorization,omitempty"`
	// Github The GitHub Actions jobs that may assume it, by their workflow's OpenID Connect token: it then has no secret, and needs actions, none of them a key's.
	Github *KeyGitHub `json:"github,omitempty"`
}

KeyCreate A key to make.

type KeyCreated

type KeyCreated struct {
	Key
	// Secret The key itself, to send as `Authorization: Bearer <secret>`; omitted for a key a device or an OAuth client collects.
	Secret *string `json:"secret,omitempty"`
	// RedirectTo For an OAuth client's key: where to send the person, with the code the client exchanges for it.
	RedirectTo *string `json:"redirectTo,omitempty"`
}

KeyCreated A key just made, with its secret: shown this once, never again.

type KeyGitHub added in v2.1.0

type KeyGitHub struct {
	// Repository The repository, `owner/name`: one that a GitHub account connected to the organization through Runtime's GitHub App holds. The key holds it by GitHub's own numbers for it and its owner, so a renamed repository still passes and another repository made under its old name never does.
	Repository string `json:"repository"`
	// Workflow The workflow a job must run, as its path in the repository (`.github/workflows/deploy.yml`); any of the repository's when omitted.
	Workflow *string `json:"workflow,omitempty"`
	// Ref The ref a job must run on (`refs/heads/main`); any when omitted.
	Ref *string `json:"ref,omitempty"`
}

KeyGitHub The GitHub Actions jobs that may assume a key (`POST /v2/keys/{id}:assume`), with their workflow's OpenID Connect token.

type KeyGitHubTrust added in v2.1.0

type KeyGitHubTrust struct {
	// Repository The repository's name as GitHub gave it when the key was made: in the create's answer alone, as its name is GitHub's to change.
	Repository *string `json:"repository,omitempty"`
	// RepositoryID GitHub's number for the repository, which a rename keeps.
	RepositoryID int64 `json:"repositoryId"`
	// OwnerID GitHub's number for the account that owns it.
	OwnerID int64 `json:"ownerId"`
	// Workflow The workflow a job must run, as its path in the repository; any when omitted.
	Workflow *string `json:"workflow,omitempty"`
	// Ref The ref a job must run on; any when omitted.
	Ref *string `json:"ref,omitempty"`
}

KeyGitHubTrust The GitHub Actions jobs a key trusts, as it holds them: by GitHub's own numbers.

type KeyListQuery

type KeyListQuery struct {
	// Cursor Where the page starts: a page's `next`.
	Cursor *string
	// Limit The most items the page holds. At least 1. At most 200. Default: 50.
	Limit *int64
}

KeyListQuery is what List takes in its query.

type KeySpend

type KeySpend struct {
	// KeyID The key the machines and storage were made with. Omitted for what was made with no key (signed in to the console), and for `others`.
	KeyID *string `json:"keyId,omitempty"`
	// Name The key's name.
	Name *string `json:"name,omitempty"`
	// AccountID The person the key acts for, or who made it signed in to the console.
	AccountID *string `json:"accountId,omitempty"`
	// Email That person's email address.
	Email *string `json:"email,omitempty"`
	// AgentID The agent or CI pipeline the key acts as.
	AgentID *string `json:"agentId,omitempty"`
	// Source `key`: one key's. `console`: made signed in, with no key. `others`: keys the caller may not see, together. `unknown`: made by something deleted too long ago to name.
	Source string `json:"source"`
	// Charged Charged this month at the card's rates, in US dollars.
	Charged string `json:"charged"`
}

KeySpend What one key, or what was made with no key, used this month.

type KeySpendCap

type KeySpendCap struct {
	// Cap The most its holder's machines may spend over windowSeconds, in US dollars.
	Cap string `json:"cap"`
	// Spent What they spent over the window, in US dollars, as the cap counts it.
	Spent string `json:"spent"`
	// Remaining What is left: cap less spent, never below 0. Once 0, a create is refused 403 until the window passes it.
	Remaining string `json:"remaining"`
	// WindowSeconds The rolling window the cap counts over, in seconds.
	WindowSeconds int64 `json:"windowSeconds"`
}

KeySpendCap The spend cap a key's creates are held to, and what is left under it.

type KeyUpdate

type KeyUpdate struct {
	// Name Its name. At least 1 character. At most 64 characters.
	Name *string `json:"name,omitempty"`
	// MaxCost The most one request made with it may commit, in US dollars (`"5.00"`). Never more than a key it was made with, nor than the key that changes it: a key never raises its own caps.
	MaxCost *string `json:"maxCost,omitempty"`
	// SpendCap The most the machines made with it, with those of every key made with it, may spend over spendCapWindowSeconds, in US dollars, as billed. Never more than a key it was made with, nor than the key that changes it.
	SpendCap *string `json:"spendCap,omitempty"`
	// SpendCapWindowSeconds The rolling window spendCap counts over, in seconds; kept when omitted, a day for a key that had no spendCap. At least 60. At most 2592000.
	SpendCapWindowSeconds *int64 `json:"spendCapWindowSeconds,omitempty"`
	// Remove Caps to remove: `maxCost`, `spendCap`. The key is then held only by the caps of the keys it was made with and of its holder's grants.
	Remove []string `json:"remove,omitempty"`
}

KeyUpdate A change to a key: each field left out stays as it is.

type KeyUsage

type KeyUsage struct {
	// KeyID The key's ID.
	KeyID string `json:"keyId"`
	// Name Its name.
	Name string `json:"name"`
	// AgentID The agent or CI pipeline it acts as.
	AgentID *string `json:"agentId,omitempty"`
	// AccountID The person it acts as or for.
	AccountID *string `json:"accountId,omitempty"`
	// DaySpent What its calls committed in the last 24 hours, in US dollars, as its spend caps count it.
	DaySpent string `json:"daySpent"`
	// PeriodSpent What its calls committed this month (UTC), in US dollars.
	PeriodSpent string `json:"periodSpent"`
	// Running Its holder's machines running now.
	Running int64 `json:"running"`
	// Machines Its holder's machines, not deleted.
	Machines int64 `json:"machines"`
}

KeyUsage One key's spend and what its holder runs: a coordinator reads what each worker's key spent.

type Keys

type Keys struct {
	// contains filtered or unexported fields
}

Keys An API key: what a program, an agent or a CI pipeline calls the API with, acting as the person or agent who made it and never reaching more. Its secret is shown once, when it is made.

func (*Keys) Assume added in v2.1.0

func (c *Keys) Assume(ctx context.Context, id string, opts *RequestOptions) (*KeyCreated, error)

Assume Makes a key for one GitHub Actions job from a key whose `github` admits it, and returns its secret this once. The job's OpenID Connect token, asked for with audience `withruntime.com` (`permissions: id-token: write`), is the call's bearer token: no API key is sent. The new key acts as the trusted key does, with its project and actions, makes no keys, and works for an hour; what it spends counts toward the trusted key's spendCap.

func (*Keys) Create

func (c *Keys) Create(ctx context.Context, in KeyCreate, opts *RequestOptions) (*KeyCreated, error)

Create Makes a key that acts as the caller, or as one of the organization's agents for the caller, and returns its secret this once. With `userCode` or `authorization`, the key goes to the device or OAuth client that asked for it instead, which collects it once from `/v2/oauth/token`. A key made with a key works until its own end, never past that key's: it lives on when that key is revoked, so a key is rotated by making its next with it.

func (*Keys) Delete

func (c *Keys) Delete(ctx context.Context, id string, opts *RequestOptions) (*Key, error)

Delete Revokes a key: refused from its next call, with the hand-off tokens made from it; a key made with it works on. An owner or an admin revokes any key of the organization; everyone else, their own. Revoked again, it returns 404.

func (*Keys) List

func (c *Keys) List(ctx context.Context, q KeyListQuery, opts *RequestOptions) (*Page[Key], error)

List Lists the organization's live keys, newest first, without their secrets: every key for an owner or an admin, the caller's own otherwise.

func (*Keys) ListAll

func (c *Keys) ListAll(ctx context.Context, q KeyListQuery, opts *RequestOptions) iter.Seq2[Key, error]

ListAll is every item of every page List reads from q.Cursor (none: the first page), each page read as the last is used up.

func (*Keys) Update

func (c *Keys) Update(ctx context.Context, id string, in KeyUpdate, opts *RequestOptions) (*Key, error)

Update Renames a key, or sets or removes its caps (`maxCost`, `spendCap`); its secret stays as it is. A cap is never set above that of a key it was made with, nor above the caller's own key's, so a key never raises its own caps. An owner or an admin changes any key of the organization; everyone else, their own.

type Limit

type Limit struct {
	// Name `running.vcpus`, `running.memory`, `machine.vcpus`, `machine.memory` or `starts.per-second`.
	Name string `json:"name"`
	// Unit What `max` and `used` count.
	Unit string `json:"unit"`
	// Max The most it may hold; none for no limit.
	Max *int64 `json:"max,omitempty"`
	// Used What it holds now.
	Used int64 `json:"used"`
}

Limit One limit the org is held to, and what it uses of it now.

type MachineReady

type MachineReady struct {
	// State `ready` (the check passed), `timeout` (not within `readyTimeoutSeconds`), or `not_running` (it never ran).
	State string `json:"state"`
	// WaitedMs How long it waited, in milliseconds.
	WaitedMs int64 `json:"waitedMs"`
}

MachineReady How a create's wait for its start's ready check (`start.readyPort`, `start.readyCommand`) went.

type MachineStart

type MachineStart struct {
	// Cmd The command: text, run by `bash -lc` (`sh -lc` in an image without bash), or the program and its arguments as a list, run without a shell.
	Cmd any `json:"cmd"`
	// Cwd The directory it runs in; the user's home when omitted.
	Cwd *string `json:"cwd,omitempty"`
	// Env Environment variables to add.
	Env map[string]string `json:"env,omitempty"`
	// ReadyPort A port it listens on once ready: a create answers once something listens there. At least 1. At most 65535.
	ReadyPort *int64 `json:"readyPort,omitempty"`
	// ReadyCommand A shell command that exits 0 once it is ready, run by `/bin/sh -c` in `cwd` until it does: a create answers once it has.
	ReadyCommand *string `json:"readyCommand,omitempty"`
	// ReadyTimeoutSeconds How long a create waits for `readyPort` or `readyCommand`, 1 to 300 seconds: 60 when omitted. At least 1. At most 300.
	ReadyTimeoutSeconds *int64 `json:"readyTimeoutSeconds,omitempty"`
}

MachineStart A command a machine starts at every fresh boot.

type MachineUpdate

type MachineUpdate struct {
	// Name Its name, unique in its project.
	Name *string `json:"name,omitempty"`
	// Labels Its labels, in place of its own; those under `runtime.` are kept.
	Labels map[string]string `json:"labels,omitempty"`
	// IdlePauseSeconds Seconds with nothing happening before it pauses, 60 to 86400; 0 never. Nothing happening means no call or command running, no traffic, almost no CPU, and no outbound connection it opened still open.
	IdlePauseSeconds *int64 `json:"idlePauseSeconds,omitempty"`
	// Vcpu Its vCPUs, grown while it runs; a running machine's vCPUs only grow. A number under every plan's least is taken as it. At least 2.
	Vcpu *int64 `json:"vcpu,omitempty"`
	// MemoryGb Its memory in GB (1 GB is 1,024 MiB), grown while it runs; a running machine's memory only grows. At least 1.
	MemoryGb *float64 `json:"memoryGB,omitempty"`
	// DiskGb Its disk in GB (1 GB is 1,024 MiB), grown while it runs, its file system with it; a disk only grows. At least 1.
	DiskGb *float64 `json:"diskGB,omitempty"`
	// User Who its commands run as from now when a call names no `user`: `runtime` or `root`. Running ones keep theirs.
	User *string `json:"user,omitempty"`
	// Env Environment variables to set, each over its own value, the others kept: the update answers once a running one holds the change (a paused one is given it at its wake), so each process, command and terminal it starts after the answer has them; processes already running keep the environment they started with. At most 32 variables and 32768 bytes of names and values in all, as a create's; values are never answered.
	Env map[string]string `json:"env,omitempty"`
	// RemoveEnv Names of environment variables to take out, the same way: gone from the next process it starts; processes already running keep them.
	RemoveEnv []string `json:"removeEnv,omitempty"`
	// MaxCost The most it may cost in all, in US dollars (`"5.00"`), in place of its own: one paused at its old maxCost wakes at its next call under a higher one.
	MaxCost *string `json:"maxCost,omitempty"`
	// AutoWake Whether a call that reaches it paused (an exec, a file, a terminal, a preview's visitor) resumes it from now. false: such a call answers 409 sandbox_paused and it stays paused until its own `:resume`.
	AutoWake *bool `json:"autoWake,omitempty"`
	// DeleteAfterSeconds Seconds from now until Runtime deletes it, as its delete does: final, and it can't be undone. Sent again before then, it renews it; 0 takes its end off (kept until deleted). At least 0. At most 315360000.
	DeleteAfterSeconds *int64 `json:"deleteAfterSeconds,omitempty"`
	// Files Text files to write in it before it answers, over what is there, each path to its text: absolute, or under its code's folder (`/app` for an app or a function, `/site` for a site, `/workspace` for the rest); at most 256 files, and its request at most 4 MiB. An app's or a function's server is then started again, once, on them, and it answers once its port serves again, or 409 `start_failed` when it does not within 60 seconds. Binary files and big trees go by files.write and uploadFolder.
	Files map[string]string `json:"files,omitempty"`
	// DeleteProtection true refuses its delete (409 `delete_protected`) until an update sends false; while true, its time limit pauses it instead of deleting it. Not while it has a `deleteAt`, unless the same update sends `deleteAfterSeconds` 0.
	DeleteProtection *bool `json:"deleteProtection,omitempty"`
	// Secrets The secrets it may get, by name, at most 64, in place of its list: only those of them whose scope admits it; [] none. A running one holds the change within 5 seconds (about 3 today): a visible secret's file in `/run/secrets` appears or is removed, and the proxy puts in or leaves out a hidden one's value. At most 64 items.
	Secrets []string `json:"secrets,omitempty"`
}

MachineUpdate A change to a machine's settings: each field left out stays as it is.

type McpServer

type McpServer struct {
	// Name Its name, unique in the agent: its tools are `mcp:<name>`.
	Name string `json:"name"`
	// Url Its URL (Streamable HTTP).
	Url string `json:"url"`
}

McpServer An MCP server an agent's sessions connect to. Its credentials are a secret whose hosts name its URL's host.

type Me

type Me struct {
	// Object Always `me`.
	Object string `json:"object"`
	// OrgID The organization the key acts for.
	OrgID string `json:"orgId"`
	// OrgName The organization's name, as its members see it.
	OrgName string `json:"orgName"`
	// Plan Its plan on the price card.
	Plan string `json:"plan"`
	// KeyID The key's ID.
	KeyID string `json:"keyId"`
	// AgentID Who the key acts as: an agent, a CI pipeline, a team or a person, by its ID.
	AgentID *string `json:"agentId,omitempty"`
	// ProjectID The project the call acts in.
	ProjectID string `json:"projectId"`
	// ProjectName The project's name.
	ProjectName *string `json:"projectName,omitempty"`
	// Role The built-in role of the grant that admits it (owner, admin, developer, viewer, billing); none for an org's own role.
	Role *string `json:"role,omitempty"`
	// Scope What a call that names no resource reaches: `org` (the whole organization) or `project` (the key's project alone).
	Scope string `json:"scope"`
	// Billing How the organization pays: `test` (no card yet: every call that creates or changes a machine, volume or address answers 402 `card_required`), `trial`, `live`, `grace` (a payment is due; work runs until it pauses) or `paused` (work paused until paid; nothing deleted).
	Billing *string `json:"billing,omitempty"`
}

Me Who is calling: the key, the agent it is, the org it acts for, and what admits it.

type MeClient

type MeClient struct {
	// contains filtered or unexported fields
}

MeClient Who is calling: the key, the organization it acts for, its project, and the role that admits it.

func (*MeClient) Get

func (c *MeClient) Get(ctx context.Context, opts *RequestOptions) (*Me, error)

Get Returns who the key is: the agent it acts as, its organization, plan, project and the role that admits it.

type Message

type Message struct {
	// Seq Its place in the conversation, from 1: the cursor that reads on after it.
	Seq int64 `json:"seq"`
	// Type `message`, `reply`, `tool_call`, `tool_result`, `ask`, `answer`, `state` or `error`.
	Type string `json:"type"`
	// At When it was written.
	At string `json:"at"`
	// From Who it is from: `user`, the agent, a tool's name, or the session or key that sent it.
	From *string `json:"from,omitempty"`
	// Text Its text: what was said, a tool's input or result as JSON, or an error's message.
	Text *string `json:"text,omitempty"`
	// Ref A tool call's or an ask's ID, which its result or answer names.
	Ref *string `json:"ref,omitempty"`
	// Choices An ask's choices.
	Choices []string `json:"choices,omitempty"`
	// State A `state` message's new state.
	State *string `json:"state,omitempty"`
}

Message One entry of a session's conversation, in the order the harness wrote it.

type MessageReadQuery

type MessageReadQuery struct {
	// Cursor Messages after this `seq`. At least 0. Default: 0.
	Cursor *int64
	// WaitSeconds Seconds to wait, at most 60, for a message past the cursor; it answers at once when there is one. At least 0. At most 60.
	WaitSeconds *float64
	// Limit At most this many messages. At least 1. At most 1000. Default: 200.
	Limit *int64
}

MessageReadQuery is what Read takes in its query.

type MessageSend

type MessageSend struct {
	// Text A message: the next turn's input.
	Text *string `json:"text,omitempty"`
	// Answer An answer to an ask the session waits on.
	Answer *AskAnswer `json:"answer,omitempty"`
	// Interrupt Ends the turn that runs, as Escape does in the harness; the session waits for the next message.
	Interrupt *bool `json:"interrupt,omitempty"`
}

MessageSend What to send a session: a message, an answer to one of its asks, or an interrupt. One of the three.

type Messages

type Messages struct {
	// contains filtered or unexported fields
}

Messages A session's conversation with its harness: what was sent to it, what it said, the tools it called and their results, and the asks it waits on. Kept on the session's own disk, so a fork of the session keeps it.

func (*Messages) Read

Read Returns a session's messages after a cursor, oldest first, and its conversation's state. With `waitSeconds`, it waits for the next one. A paused session is woken to read them.

func (*Messages) Send

func (c *Messages) Send(ctx context.Context, id string, in MessageSend, opts *RequestOptions) (*Message, error)

Send Sends a session a message, an answer to one of its asks, or an interrupt, and returns it as written. A paused session wakes for it. Asked again with the same Idempotency-Key, it sends nothing more.

type MeterUse

type MeterUse struct {
	// Meter The card's meter (`cpu`, `memory`, `traffic-out`, ...).
	Meter string `json:"meter"`
	// Quantity Used this month, in the meter's base unit, as an integer in text.
	Quantity string `json:"quantity"`
	// Unit The base unit: `core-microseconds`, `vcpu-microseconds`, `byte-seconds`, `bytes`, `calls` or `seconds`.
	Unit string `json:"unit"`
	// Charged Charged this month at the card's rate, in US dollars.
	Charged string `json:"charged"`
}

MeterUse One meter's use and charges this month.

type MetricPoint

type MetricPoint struct {
	// At When it was read; for a step, where the step starts.
	At string `json:"at"`
	// CpuPercent Its CPU, as a percent of all its vCPUs (0 to 100).
	CpuPercent float64 `json:"cpuPercent"`
	// CpuCores The same as a number of cores.
	CpuCores *float64 `json:"cpuCores,omitempty"`
	// CpuPeakPercent Its busiest minute, as a percent of all its vCPUs.
	CpuPeakPercent *float64 `json:"cpuPeakPercent,omitempty"`
	// CpuWaitPercent Percent of the last 10 seconds some task of it waited for a CPU.
	CpuWaitPercent *float64 `json:"cpuWaitPercent,omitempty"`
	// MemoryStallPercent Percent of the last 10 seconds some task of it waited for memory.
	MemoryStallPercent *float64 `json:"memoryStallPercent,omitempty"`
	// MemoryBytes Memory it holds, in bytes: its resident memory on its host.
	MemoryBytes int64 `json:"memoryBytes"`
	// MemoryPeakBytes The most memory it has held, in bytes; for a step, its highest minute's average.
	MemoryPeakBytes *int64 `json:"memoryPeakBytes,omitempty"`
	// Samples How many measures it is made of: two reads for the reading now; for a step, the minutes the host measured it in.
	Samples int64 `json:"samples"`
	// DiskReadBytesPerSecond Bytes its disks read a second.
	DiskReadBytesPerSecond *float64 `json:"diskReadBytesPerSecond,omitempty"`
	// DiskWriteBytesPerSecond Bytes its disks wrote a second.
	DiskWriteBytesPerSecond *float64 `json:"diskWriteBytesPerSecond,omitempty"`
	// DiskReadOpsPerSecond Reads its disks completed a second.
	DiskReadOpsPerSecond *float64 `json:"diskReadOpsPerSecond,omitempty"`
	// DiskWriteOpsPerSecond Writes its disks completed a second.
	DiskWriteOpsPerSecond *float64 `json:"diskWriteOpsPerSecond,omitempty"`
}

MetricPoint A machine's CPU and memory as its host measures them from the machine's own cgroup, never by a call into the machine, so reading them does not wake it or keep it awake. Either the current reading (over the host's last 5 seconds, with disk and pressure) or one step of a window (averaged over the time the machine ran in it).

type MetricsBase

type MetricsBase struct {
	// State Its state.
	State string `json:"state"`
	// Range The window asked for.
	Range string `json:"range"`
	// StepSeconds The window's step, in seconds.
	StepSeconds int64 `json:"stepSeconds"`
	// Since Where the window starts: the start of the step that holds the range's start.
	Since string `json:"since"`
	// Until Where it ends: now.
	Until string `json:"until"`
	// Vcpu Its vCPUs.
	Vcpu int64 `json:"vcpu"`
	// MemoryLimitBytes Its memory, in bytes.
	MemoryLimitBytes int64 `json:"memoryLimitBytes"`
	// DiskLimitBytes Its disk, in bytes.
	DiskLimitBytes int64 `json:"diskLimitBytes"`
	// Latest The reading taken now, or where its host takes none on asking, its newest measured minute of the last 3 minutes; none when it is not running, or has no such minute (made or woken within about a minute).
	Latest *MetricPoint `json:"latest,omitempty"`
	// Points The window's steps, oldest first, each averaged over the time the machine ran in it. Steps in which it did not run are omitted. A minute appears about a minute after it ends; `latest` holds the current reading.
	Points []MetricPoint `json:"points"`
}

MetricsBase A machine's CPU and memory over a time window, in steps, and its current reading (with disk and pressure) while it runs. Steps are returned in every state, including paused and stopped. Ranges: `15m` and `1h` in 60-second steps, `6h` in 120-second steps, `24h` in 480-second steps, `7d` and `30d` in 1-hour steps. Defaults to `1h`.

type Network

type Network struct {
	NetworkSettings
	// ID Its ID.
	ID string `json:"id"`
	// Object Always `network`.
	Object string `json:"object"`
	// Name Its name.
	Name string `json:"name"`
	// State Its state: `ready` once every member's host serves it.
	State string `json:"state"`
	// CreatedAt When it was made.
	CreatedAt string `json:"createdAt"`
}

Network A private network: its members reach each other at `<id>.sandbox.internal`, over TCP.

type NetworkListQuery

type NetworkListQuery struct {
	// Cursor Where the page starts: a page's `next`.
	Cursor *string
	// Limit The most items the page holds. At least 1. At most 200. Default: 50.
	Limit *int64
}

NetworkListQuery is what List takes in its query.

type NetworkRules

type NetworkRules struct {
	// AllowOutbound The only places it may reach, each a host, `*.` and a name for every name under it, an address or a CIDR (`[` and `]` around an IPv6 address), every port when it names none; `:port` for that port alone, on a host name for a port beyond 80 and 443, which go together. `*` is every public host. Every public host when omitted; nothing when empty.
	AllowOutbound []string `json:"allowOutbound,omitempty"`
	// DenyOutbound Places it may never reach, written as in allowOutbound with no port: a deny wins over every allow.
	DenyOutbound []string `json:"denyOutbound,omitempty"`
}

NetworkRules Where a machine may connect out, past the walls every machine has.

type NetworkSettings

type NetworkSettings struct {
	// Members The machines in it, by ID; none for every machine of the org.
	Members []string `json:"members,omitempty"`
}

NetworkSettings A private network's settings, as it keeps them.

type Networks

type Networks struct {
	// contains filtered or unexported fields
}

Networks A private network: its machines reach each other by name, over TCP.

func (*Networks) List

List Lists the org's private networks, by name.

func (*Networks) ListAll

ListAll is every item of every page List reads from q.Cursor (none: the first page), each page read as the last is used up.

type Notebook

type Notebook struct {

	// Info is what it was when last read.
	Info      *SandboxInfo
	Files     *NotebookFiles
	Processes *NotebookProcesses
	Network   *NotebookNetwork
	// contains filtered or unexported fields
}

Notebook is one of notebooks: A machine running JupyterLab on port 8888 over /workspace, with NumPy, pandas and matplotlib, reached at its private preview. It pauses after 300 seconds with nothing happening, its kernels kept in memory, and a visit resumes it where it was.

func (*Notebook) Act

func (s *Notebook) Act(ctx context.Context, actions []Action, in *ActRequest, opts *RequestOptions) (*Acted, error)

Act Moves, clicks, drags and scrolls the mouse and types on the keyboard of a notebook's screen (its X display `:1`), each step in turn as one command, and returns where the mouse is then. It stops at the first step that fails, refused 409 `act_failed` naming it; refused 409 `display_not_running` when no display runs. A paused notebook is resumed first.

func (*Notebook) Delete

func (s *Notebook) Delete(ctx context.Context, opts *RequestOptions) (*SandboxInfo, error)

Delete Deletes a notebook, its memory and its disk.

func (*Notebook) Exec

func (s *Notebook) Exec(ctx context.Context, cmd string, in *ExecRequest, opts *RequestOptions) (*Process, error)

Exec Runs a command as a process and returns it once it ended, with its output; with wait false, at once, while it runs. A paused notebook is resumed first. Asked again with the same Idempotency-Key, it runs nothing more: it returns the first run's process, waiting for its end while it runs.

func (*Notebook) Fork

func (s *Notebook) Fork(ctx context.Context, in *ForkRequest, opts *RequestOptions) (*Forked, error)

Fork Copies a notebook as it is now, memory and disk, into `count` copies of its own, each running on its host. Asked again with the same Idempotency-Key, it returns the same copies.

func (*Notebook) ID

func (s *Notebook) ID() string

ID is its id.

func (*Notebook) Metrics

Metrics Returns a notebook's CPU, memory, disks and pressure, as its host reads them from the notebook's own cgroup over a fifth of a second: never a call into the notebook, so it does not wake a paused one nor keep one from its idle pause. One that is not running has no reading.

func (*Notebook) Pause

func (s *Notebook) Pause(ctx context.Context, opts *RequestOptions) error

Pause Pauses a notebook with its memory and disk kept. A call to it resumes it.

func (*Notebook) Refresh

func (s *Notebook) Refresh(ctx context.Context, q *NotebookGetQuery, opts *RequestOptions) error

Refresh Returns a notebook.

func (*Notebook) Resume

func (s *Notebook) Resume(ctx context.Context, opts *RequestOptions) error

Resume Resumes a paused notebook where it was, its memory and processes as they were.

func (*Notebook) RunCode

func (s *Notebook) RunCode(ctx context.Context, code string, in *RunCode, opts *RequestOptions) (*CodeRun, error)

RunCode Runs a cell of Python in a notebook as a notebook does, in a Jupyter kernel it keeps running for the cell's `context`: variables, imports and functions stay for the next cell. Returns what it printed, its values and displays (text, HTML, images such as charts), and its exception with its traceback. The context's kernel starts on its first cell. A cell past `timeoutSeconds` is interrupted and its context kept. Refused 409 `kernel_not_installed` when the image has no ipykernel. A paused notebook is resumed first.

func (*Notebook) Screenshot

func (s *Notebook) Screenshot(ctx context.Context, q *NotebookScreenshotQuery, opts *RequestOptions) ([]byte, error)

Screenshot Returns what a notebook's screen shows now, as `image/png` (or `image/jpeg`): its X display `:1`, whole. Refused 409 `display_not_running` when no display runs. A paused notebook is resumed first.

func (*Notebook) Snapshot

func (s *Notebook) Snapshot(ctx context.Context, in *SnapshotRequest, opts *RequestOptions) (*Stored, error)

Snapshot Keeps a notebook's memory and disk as they are now, a snapshot to start notebooks from; with `image`, its disk alone as that image's next version. The notebook runs on. Asked again with the same Idempotency-Key, it returns the same snapshot.

func (*Notebook) Update

func (s *Notebook) Update(ctx context.Context, in *MachineUpdate, opts *RequestOptions) error

Update Changes its name, labels, idle pause, maxCost, autoWake, lifetime, delete protection, environment or sizes; each field left out stays as it is. A lifetime (`deleteAfterSeconds`) sent again before its end moves the end to that many seconds from now; 0 takes it off. A lifetime is refused (409 `delete_protected`) while `deleteProtection` is true. A running one holds a changed environment before this answers (a paused one's at its wake): each process it starts after the answer has it, and its running processes keep the one they started with. Its vCPUs, memory and disk grow while it runs, its commands running on. One paused or stopped is not woken for it: judged at once as a live resize is (past the vCPUs it was made with 409, over its organization's limits `quota_exceeded`), its new sizes are returned at once, and its next wake grows it to them before the call that woke it runs. A smaller size, or a machine starting or failed, is refused 409 naming why, and nothing is changed. With If-Match, made only while its revision is that one, else 412. Sent again with the same Idempotency-Key and body while it is the latest change, it returns the current state and changes nothing; the same key with a different body returns 409 idempotency_key_reused.

type NotebookDownloadFolderQuery

type NotebookDownloadFolderQuery struct {
	// Path The folder, absolute, such as `/workspace/app`.
	Path string
	// Gzip Compress the archive with gzip. Default: false.
	Gzip *bool
	// User Who packs it: `runtime` or `root`; the notebook's `user` when omitted.
	User *string
	// Exclude Paths in the folder to leave out, relative to it and comma-separated (`node_modules,.cache`): plain names, no wildcards, at most 32.
	Exclude *string
}

NotebookDownloadFolderQuery is what DownloadFolder takes in its query.

type NotebookFiles

type NotebookFiles struct {
	// contains filtered or unexported fields
}

NotebookFiles is a notebook's files.

func (*NotebookFiles) AbortFolderUpload

func (g *NotebookFiles) AbortFolderUpload(ctx context.Context, upload string, opts *RequestOptions) (*FolderUploadAborted, error)

AbortFolderUpload Stops a folder upload's tar; what it unpacked so far stays.

func (*NotebookFiles) BeginFolderUpload

func (g *NotebookFiles) BeginFolderUpload(ctx context.Context, path string, in *FolderUploadBegin, opts *RequestOptions) (*FolderUpload, error)

BeginFolderUpload Begins a folder's upload in parts: tar starts in the notebook, unpacking into the folder each part as it arrives. Send the parts in order by offset (writeFolderUpload), then commitFolderUpload; an upload no call names for 10 minutes is ended. A paused notebook is woken first.

func (*NotebookFiles) CommitFolderUpload

func (g *NotebookFiles) CommitFolderUpload(ctx context.Context, upload string, opts *RequestOptions) (*FolderUnpacked, error)

CommitFolderUpload Ends a folder upload's input and returns once tar has ended, as an exec returns once its command has: the folder, or 400 `invalid_archive` with what tar said. Sent again, it returns how tar ended. An upload no call has named for 10 minutes since its last part or commit is ended.

func (*NotebookFiles) DownloadFolder

func (g *NotebookFiles) DownloadFolder(ctx context.Context, path string, q *NotebookDownloadFolderQuery, opts *RequestOptions) ([]byte, error)

DownloadFolder Returns a folder as a tar archive (`application/x-tar`, or `application/gzip` with gzip), packed by tar in the notebook as it streams, of any size; its entries are relative to the folder (`./a.txt`). A folder that fails part way (a file it may not read, or one that changes as it is read) ends as an archive every tar reader refuses, never as a short one that reads whole. At most 4 at once in a notebook. A paused notebook is woken first.

func (g *NotebookFiles) Link(ctx context.Context, path string, in *FileLinkCreate, opts *RequestOptions) (*FileLink, error)

Link Makes an expiring address for one file that anyone may open with no API key, from a browser, curl or another service: GET downloads it (Range works, so videos play and downloads resume; archive: true downloads a folder as .tar.gz), PUT with the raw body uploads it (up to maxBytes, written whole; Content-Length required). The link acts as the key that made it: an upload link needs write, and the link ends with its key, with revokeLinks or with its notebook. A paused notebook is woken for it unless wake is false. A port it serves is shared by a preview (previews.create), not a link.

func (*NotebookFiles) List

List Lists a directory's entries in path order, to a depth.

func (*NotebookFiles) Mkdir

func (g *NotebookFiles) Mkdir(ctx context.Context, path string, in *FileMkdir, opts *RequestOptions) (*FileMade, error)

Mkdir Makes a directory, and its parents unless parents is false. One there already is success, created false.

func (*NotebookFiles) Read

func (g *NotebookFiles) Read(ctx context.Context, path string, q *NotebookReadQuery, opts *RequestOptions) ([]byte, error)

Read Returns a file's bytes.

func (*NotebookFiles) Remove

func (g *NotebookFiles) Remove(ctx context.Context, path string, in *FileRemove, opts *RequestOptions) (*FileRemoved, error)

Remove Removes a file, a link or a directory (recursive for one with contents). One missing is success, removed false.

func (*NotebookFiles) Rename

func (g *NotebookFiles) Rename(ctx context.Context, in *FileRename, opts *RequestOptions) (*FileRenamed, error)

Rename Moves a file, a link or a directory; refused 409 when something is at its new path, unless overwrite. With sha256 or size, a file written in parts is put in place once whole: its writes ended, then only a file of that size with every byte written and whose bytes hash to it moves; refused 409 `upload_incomplete` or `checksum_mismatch`, nothing moved. With sha256, it is safe to send again: once moved, it returns the same answer while `from` is gone and `to` holds those bytes.

func (g *NotebookFiles) RevokeLinks(ctx context.Context, opts *RequestOptions) (*FileLinksRevoked, error)

RevokeLinks Ends every file link made for a notebook so far; links made after work.

func (*NotebookFiles) Stat

Stat Returns what is at a path: a file, a directory or a link, or nothing (exists false). With sha256=true, a file's SHA-256 too.

func (*NotebookFiles) UploadFolder

func (g *NotebookFiles) UploadFolder(ctx context.Context, path string, data []byte, q *NotebookUploadFolderQuery, opts *RequestOptions) (*FolderUnpacked, error)

UploadFolder Unpacks the request's tar archive (gzip-compressed or not, told by its first bytes) into a folder, made with its parents, by tar in the notebook as the bytes arrive, of any size, nothing of it kept on disk but what tar writes; returns once tar has ended, or 400 `invalid_archive` with what tar said. A paused notebook is woken first.

func (*NotebookFiles) Write

func (g *NotebookFiles) Write(ctx context.Context, path string, data []byte, q *NotebookWriteQuery, opts *RequestOptions) (*FileWritten, error)

Write Writes the request's bytes to a file as they come, of any size (Content-Length required), its folders made: the file whole when they all came, or as it was. With offset, they are written into it in place.

func (*NotebookFiles) WriteFolderUpload

func (g *NotebookFiles) WriteFolderUpload(ctx context.Context, upload string, data []byte, q *NotebookWriteFolderUploadQuery, opts *RequestOptions) (*FolderUploadReceived, error)

WriteFolderUpload Sends the request's bytes, a part of the archive at its offset, into tar's input as they arrive, of any size, and returns the bytes received in all once tar took them. A part past them is refused 409 `upload_incomplete`, naming them: send the parts in order.

type NotebookGetQuery

type NotebookGetQuery struct {
	// Wait Seconds to wait, at most 60, for its state to differ from `ifState`; it answers once it does, or as it is when the wait ends. At least 0. At most 60.
	Wait *float64
	// IfState The state the caller last read, which `wait` waits for it to leave.
	IfState *string
}

NotebookGetQuery is what Get takes in its query.

type NotebookListFilesQuery

type NotebookListFilesQuery struct {
	// Path The directory. Default: "/workspace".
	Path *string
	// Depth How deep to list. At least 1. At most 10. Default: 1.
	Depth *int64
	// Limit At most this many entries. At least 1. At most 2000. Default: 2000.
	Limit *int64
	// Hidden List entries whose names start with a dot. Default: true.
	Hidden *bool
	// Glob Only entries whose path relative to the directory matches: `*` within a name, `**` across folders, `?` one character, `{a,b}` either (`**/*.py`); at most 512 characters, 32 wildcards and 64 texts in braces. The listing then reaches as deep as the glob does (10 folders for `**`) unless depth says, and is searched past its first 2,000 entries, up to 50,000. At most 512 characters.
	Glob *string
}

NotebookListFilesQuery is what ListFiles takes in its query.

type NotebookListQuery

type NotebookListQuery struct {
	// State Only those in these states, comma-separated.
	State *string
	// Name Only the notebook of this name.
	Name *string
	// Label Only those with every label given (repeat it for several): key:value, or a key for any value.
	Label []string
	// Cursor Where the page starts: a page's `next`.
	Cursor *string
	// Limit The most items the page holds. At least 1. At most 200. Default: 50.
	Limit *int64
}

NotebookListQuery is what List takes in its query.

type NotebookMetricsQuery

type NotebookMetricsQuery struct {
	// Range The window: `15m`, `1h`, `6h`, `24h`, `7d` or `30d`. Default: "1h".
	Range *string
}

NotebookMetricsQuery is what Metrics takes in its query.

type NotebookNetwork

type NotebookNetwork struct {
	// contains filtered or unexported fields
}

NotebookNetwork is a notebook's network.

func (*NotebookNetwork) Get

Get Returns where a notebook may connect out.

func (*NotebookNetwork) Set

Set Replaces where a notebook may connect out, for its next connection and within a second for its open ones: those the new rules refuse are cut.

type NotebookProcessOutputQuery

type NotebookProcessOutputQuery struct {
	// Cursor Output after this byte. At least 0. Default: 0.
	Cursor *int64
	// WaitSeconds Seconds to wait for output past the cursor or its exit, at most 8. At least 0. At most 8.
	WaitSeconds *float64
	// MaxBytes At most this many bytes. At least 4096. At most 196608. Default: 65536.
	MaxBytes *int64
	// Follow Answer as NDJSON events from the cursor until it exits (stdout, stderr, truncated, exit; continue with the cursor to follow on from), as `Accept: application/x-ndjson` does.
	Follow *bool
}

NotebookProcessOutputQuery is what ProcessOutput takes in its query.

type NotebookProcesses

type NotebookProcesses struct {
	// contains filtered or unexported fields
}

NotebookProcesses is a notebook's processes.

func (*NotebookProcesses) List

List Lists a notebook's processes, newest first: those running and those that ended lately.

func (*NotebookProcesses) Output

Output Returns a process's output after a cursor, and the cursor to read on from. The latest 1 MiB is kept; truncated says when the cursor fell behind.

func (*NotebookProcesses) Resize

func (g *NotebookProcesses) Resize(ctx context.Context, process string, in *Terminal, opts *RequestOptions) (*Process, error)

Resize Resizes the terminal of a process started with a pty (its window's columns and rows, which the process is told by SIGWINCH), and returns the process; refused 409 for a process without one. A process that ended is left as it is, so a retry is safe.

func (*NotebookProcesses) Signal

func (g *NotebookProcesses) Signal(ctx context.Context, process string, in *ProcessSignal, opts *RequestOptions) (*Process, error)

Signal Sends a signal to a process and its group; a process that ended is not signalled, so a retry is safe.

func (*NotebookProcesses) Write

func (g *NotebookProcesses) Write(ctx context.Context, process string, in *ProcessInput, opts *RequestOptions) (*ProcessWritten, error)

Write Sends input to a process started with stdinOpen or a pty, and returns how much of its input it has taken.

type NotebookReadQuery

type NotebookReadQuery struct {
	// Path The file's path in the machine.
	Path string
}

NotebookReadQuery is what Read takes in its query.

type NotebookScreenshotQuery

type NotebookScreenshotQuery struct {
	// Format `png`, or `jpeg`: smaller and quicker to send, for a model that reads it. Default: "png".
	Format *string
	// Quality A jpeg's quality, 1 to 100. At least 1. At most 100. Default: 80.
	Quality *int64
}

NotebookScreenshotQuery is what Screenshot takes in its query.

type NotebookStatQuery

type NotebookStatQuery struct {
	// Path The file's path in the machine.
	Path string
	// Sha256 Also return a file's SHA-256, read from its bytes: to check a file you put in place (files:rename with sha256) is whole. Default: false.
	Sha256 *bool
}

NotebookStatQuery is what Stat takes in its query.

type NotebookUploadFolderQuery

type NotebookUploadFolderQuery struct {
	// Path The folder, absolute, such as `/workspace/app`: made with its parents.
	Path string
	// User Who unpacks it: `runtime` or `root`; the notebook's `user` when omitted.
	User *string
}

NotebookUploadFolderQuery is what UploadFolder takes in its query.

type NotebookWriteFolderUploadQuery

type NotebookWriteFolderUploadQuery struct {
	// Offset Where the part starts in the archive: at most the bytes received so far. Bytes before them were taken already and are skipped, so a part sent again is never unpacked twice. At least 0. Default: 0.
	Offset *int64
}

NotebookWriteFolderUploadQuery is what WriteFolderUpload takes in its query.

type NotebookWriteQuery

type NotebookWriteQuery struct {
	// Path The file's path in the machine.
	Path string
	// Mode Its mode, in octal (`644`).
	Mode *string
	// Offset Write the bytes into the file in place from this byte, keeping the bytes before and after them (the file is made when there is none); one that fails part way may leave its range written in part, so send it again. Parts of one file may be written so at once and in any order: write them to a new path, then rename it with its size and sha256 to put it in place whole. At least 0.
	Offset *int64
	// Sha256 The bytes' SHA-256 in hex: refused 409 `checksum_mismatch`, the file as it was, when they differ. Not with offset.
	Sha256 *string
}

NotebookWriteQuery is what Write takes in its query.

type Notebooks

type Notebooks struct {
	// contains filtered or unexported fields
}

Notebooks A machine running JupyterLab on port 8888 over /workspace, with NumPy, pandas and matplotlib, reached at its private preview. It pauses after 300 seconds with nothing happening, its kernels kept in memory, and a visit resumes it where it was.

func (*Notebooks) AbortFolderUpload

func (c *Notebooks) AbortFolderUpload(ctx context.Context, id string, upload string, opts *RequestOptions) (*FolderUploadAborted, error)

AbortFolderUpload Stops a folder upload's tar; what it unpacked so far stays.

func (*Notebooks) Act

func (c *Notebooks) Act(ctx context.Context, id string, in ActRequest, opts *RequestOptions) (*Acted, error)

Act Moves, clicks, drags and scrolls the mouse and types on the keyboard of a notebook's screen (its X display `:1`), each step in turn as one command, and returns where the mouse is then. It stops at the first step that fails, refused 409 `act_failed` naming it; refused 409 `display_not_running` when no display runs. A paused notebook is resumed first.

func (*Notebooks) BeginFolderUpload

func (c *Notebooks) BeginFolderUpload(ctx context.Context, id string, in FolderUploadBegin, opts *RequestOptions) (*FolderUpload, error)

BeginFolderUpload Begins a folder's upload in parts: tar starts in the notebook, unpacking into the folder each part as it arrives. Send the parts in order by offset (writeFolderUpload), then commitFolderUpload; an upload no call names for 10 minutes is ended. A paused notebook is woken first.

func (*Notebooks) CommitFolderUpload

func (c *Notebooks) CommitFolderUpload(ctx context.Context, id string, upload string, opts *RequestOptions) (*FolderUnpacked, error)

CommitFolderUpload Ends a folder upload's input and returns once tar has ended, as an exec returns once its command has: the folder, or 400 `invalid_archive` with what tar said. Sent again, it returns how tar ended. An upload no call has named for 10 minutes since its last part or commit is ended.

func (*Notebooks) Create

func (c *Notebooks) Create(ctx context.Context, in SandboxCreate, opts *RequestOptions) (*Notebook, error)

Create Creates a notebook. Asked again with the same Idempotency-Key, it returns the same notebook.

func (*Notebooks) Delete

func (c *Notebooks) Delete(ctx context.Context, id string, opts *RequestOptions) (*SandboxInfo, error)

Delete Deletes a notebook, its memory and its disk.

func (*Notebooks) DownloadFolder

func (c *Notebooks) DownloadFolder(ctx context.Context, id string, q NotebookDownloadFolderQuery, opts *RequestOptions) ([]byte, error)

DownloadFolder Returns a folder as a tar archive (`application/x-tar`, or `application/gzip` with gzip), packed by tar in the notebook as it streams, of any size; its entries are relative to the folder (`./a.txt`). A folder that fails part way (a file it may not read, or one that changes as it is read) ends as an archive every tar reader refuses, never as a short one that reads whole. At most 4 at once in a notebook. A paused notebook is woken first.

func (*Notebooks) Exec

func (c *Notebooks) Exec(ctx context.Context, id string, in ExecRequest, opts *RequestOptions) (*Process, error)

Exec Runs a command as a process and returns it once it ended, with its output; with wait false, at once, while it runs. A paused notebook is resumed first. Asked again with the same Idempotency-Key, it runs nothing more: it returns the first run's process, waiting for its end while it runs.

func (*Notebooks) Fork

func (c *Notebooks) Fork(ctx context.Context, id string, in ForkRequest, opts *RequestOptions) (*Forked, error)

Fork Copies a notebook as it is now, memory and disk, into `count` copies of its own, each running on its host. Asked again with the same Idempotency-Key, it returns the same copies.

func (*Notebooks) Get

Get Returns a notebook.

func (*Notebooks) GetNetwork

func (c *Notebooks) GetNetwork(ctx context.Context, id string, opts *RequestOptions) (*SandboxNetwork, error)

GetNetwork Returns where a notebook may connect out.

func (c *Notebooks) Link(ctx context.Context, id string, in FileLinkCreate, opts *RequestOptions) (*FileLink, error)

Link Makes an expiring address for one file that anyone may open with no API key, from a browser, curl or another service: GET downloads it (Range works, so videos play and downloads resume; archive: true downloads a folder as .tar.gz), PUT with the raw body uploads it (up to maxBytes, written whole; Content-Length required). The link acts as the key that made it: an upload link needs write, and the link ends with its key, with revokeLinks or with its notebook. A paused notebook is woken for it unless wake is false. A port it serves is shared by a preview (previews.create), not a link.

func (*Notebooks) List

List Lists the project's notebooks, newest first.

func (*Notebooks) ListAll

ListAll is every item of every page List reads from q.Cursor (none: the first page), each page read as the last is used up.

func (*Notebooks) ListFiles

func (c *Notebooks) ListFiles(ctx context.Context, id string, q NotebookListFilesQuery, opts *RequestOptions) (*FileList, error)

ListFiles Lists a directory's entries in path order, to a depth.

func (*Notebooks) ListProcesses

func (c *Notebooks) ListProcesses(ctx context.Context, id string, opts *RequestOptions) (*ProcessList, error)

ListProcesses Lists a notebook's processes, newest first: those running and those that ended lately.

func (*Notebooks) Metrics

Metrics Returns a notebook's CPU, memory, disks and pressure, as its host reads them from the notebook's own cgroup over a fifth of a second: never a call into the notebook, so it does not wake a paused one nor keep one from its idle pause. One that is not running has no reading.

func (*Notebooks) Mkdir

func (c *Notebooks) Mkdir(ctx context.Context, id string, in FileMkdir, opts *RequestOptions) (*FileMade, error)

Mkdir Makes a directory, and its parents unless parents is false. One there already is success, created false.

func (*Notebooks) Pause

func (c *Notebooks) Pause(ctx context.Context, id string, opts *RequestOptions) (*SandboxInfo, error)

Pause Pauses a notebook with its memory and disk kept. A call to it resumes it.

func (*Notebooks) ProcessOutput

func (c *Notebooks) ProcessOutput(ctx context.Context, id string, process string, q NotebookProcessOutputQuery, opts *RequestOptions) (*ProcessOutput, error)

ProcessOutput Returns a process's output after a cursor, and the cursor to read on from. The latest 1 MiB is kept; truncated says when the cursor fell behind.

func (*Notebooks) Read

func (c *Notebooks) Read(ctx context.Context, id string, q NotebookReadQuery, opts *RequestOptions) ([]byte, error)

Read Returns a file's bytes.

func (*Notebooks) Remove

func (c *Notebooks) Remove(ctx context.Context, id string, in FileRemove, opts *RequestOptions) (*FileRemoved, error)

Remove Removes a file, a link or a directory (recursive for one with contents). One missing is success, removed false.

func (*Notebooks) Rename

func (c *Notebooks) Rename(ctx context.Context, id string, in FileRename, opts *RequestOptions) (*FileRenamed, error)

Rename Moves a file, a link or a directory; refused 409 when something is at its new path, unless overwrite. With sha256 or size, a file written in parts is put in place once whole: its writes ended, then only a file of that size with every byte written and whose bytes hash to it moves; refused 409 `upload_incomplete` or `checksum_mismatch`, nothing moved. With sha256, it is safe to send again: once moved, it returns the same answer while `from` is gone and `to` holds those bytes.

func (*Notebooks) ResizeProcess

func (c *Notebooks) ResizeProcess(ctx context.Context, id string, process string, in Terminal, opts *RequestOptions) (*Process, error)

ResizeProcess Resizes the terminal of a process started with a pty (its window's columns and rows, which the process is told by SIGWINCH), and returns the process; refused 409 for a process without one. A process that ended is left as it is, so a retry is safe.

func (*Notebooks) Resume

func (c *Notebooks) Resume(ctx context.Context, id string, opts *RequestOptions) (*SandboxInfo, error)

Resume Resumes a paused notebook where it was, its memory and processes as they were.

func (c *Notebooks) RevokeLinks(ctx context.Context, id string, opts *RequestOptions) (*FileLinksRevoked, error)

RevokeLinks Ends every file link made for a notebook so far; links made after work.

func (*Notebooks) RunCode

func (c *Notebooks) RunCode(ctx context.Context, id string, in RunCode, opts *RequestOptions) (*CodeRun, error)

RunCode Runs a cell of Python in a notebook as a notebook does, in a Jupyter kernel it keeps running for the cell's `context`: variables, imports and functions stay for the next cell. Returns what it printed, its values and displays (text, HTML, images such as charts), and its exception with its traceback. The context's kernel starts on its first cell. A cell past `timeoutSeconds` is interrupted and its context kept. Refused 409 `kernel_not_installed` when the image has no ipykernel. A paused notebook is resumed first.

func (*Notebooks) Screenshot

func (c *Notebooks) Screenshot(ctx context.Context, id string, q NotebookScreenshotQuery, opts *RequestOptions) ([]byte, error)

Screenshot Returns what a notebook's screen shows now, as `image/png` (or `image/jpeg`): its X display `:1`, whole. Refused 409 `display_not_running` when no display runs. A paused notebook is resumed first.

func (*Notebooks) SetNetwork

func (c *Notebooks) SetNetwork(ctx context.Context, id string, in NetworkRules, opts *RequestOptions) (*SandboxNetwork, error)

SetNetwork Replaces where a notebook may connect out, for its next connection and within a second for its open ones: those the new rules refuse are cut.

func (*Notebooks) SignalProcess

func (c *Notebooks) SignalProcess(ctx context.Context, id string, process string, in ProcessSignal, opts *RequestOptions) (*Process, error)

SignalProcess Sends a signal to a process and its group; a process that ended is not signalled, so a retry is safe.

func (*Notebooks) Snapshot

func (c *Notebooks) Snapshot(ctx context.Context, id string, in SnapshotRequest, opts *RequestOptions) (*Stored, error)

Snapshot Keeps a notebook's memory and disk as they are now, a snapshot to start notebooks from; with `image`, its disk alone as that image's next version. The notebook runs on. Asked again with the same Idempotency-Key, it returns the same snapshot.

func (*Notebooks) Stat

Stat Returns what is at a path: a file, a directory or a link, or nothing (exists false). With sha256=true, a file's SHA-256 too.

func (*Notebooks) Update

func (c *Notebooks) Update(ctx context.Context, id string, in MachineUpdate, opts *RequestOptions) (*SandboxInfo, error)

Update Changes its name, labels, idle pause, maxCost, autoWake, lifetime, delete protection, environment or sizes; each field left out stays as it is. A lifetime (`deleteAfterSeconds`) sent again before its end moves the end to that many seconds from now; 0 takes it off. A lifetime is refused (409 `delete_protected`) while `deleteProtection` is true. A running one holds a changed environment before this answers (a paused one's at its wake): each process it starts after the answer has it, and its running processes keep the one they started with. Its vCPUs, memory and disk grow while it runs, its commands running on. One paused or stopped is not woken for it: judged at once as a live resize is (past the vCPUs it was made with 409, over its organization's limits `quota_exceeded`), its new sizes are returned at once, and its next wake grows it to them before the call that woke it runs. A smaller size, or a machine starting or failed, is refused 409 naming why, and nothing is changed. With If-Match, made only while its revision is that one, else 412. Sent again with the same Idempotency-Key and body while it is the latest change, it returns the current state and changes nothing; the same key with a different body returns 409 idempotency_key_reused.

func (*Notebooks) UploadFolder

func (c *Notebooks) UploadFolder(ctx context.Context, id string, data []byte, q NotebookUploadFolderQuery, opts *RequestOptions) (*FolderUnpacked, error)

UploadFolder Unpacks the request's tar archive (gzip-compressed or not, told by its first bytes) into a folder, made with its parents, by tar in the notebook as the bytes arrive, of any size, nothing of it kept on disk but what tar writes; returns once tar has ended, or 400 `invalid_archive` with what tar said. A paused notebook is woken first.

func (*Notebooks) Write

func (c *Notebooks) Write(ctx context.Context, id string, data []byte, q NotebookWriteQuery, opts *RequestOptions) (*FileWritten, error)

Write Writes the request's bytes to a file as they come, of any size (Content-Length required), its folders made: the file whole when they all came, or as it was. With offset, they are written into it in place.

func (*Notebooks) WriteFolderUpload

func (c *Notebooks) WriteFolderUpload(ctx context.Context, id string, upload string, data []byte, q NotebookWriteFolderUploadQuery, opts *RequestOptions) (*FolderUploadReceived, error)

WriteFolderUpload Sends the request's bytes, a part of the archive at its offset, into tar's input as they arrive, of any size, and returns the bytes received in all once tar took them. A part past them is refused 409 `upload_incomplete`, naming them: send the parts in order.

func (*Notebooks) WriteProcess

func (c *Notebooks) WriteProcess(ctx context.Context, id string, process string, in ProcessInput, opts *RequestOptions) (*ProcessWritten, error)

WriteProcess Sends input to a process started with stdinOpen or a pty, and returns how much of its input it has taken.

type Options

type Options struct {
	// APIKey defaults to the RUNTIME_API_KEY environment variable: a bearer
	// key, or a key pair's rtsk_ secret, which signs each request and is
	// never sent.
	APIKey string
	// Project is the one every call acts in (Runtime-Project), and a key pair signs for; it defaults
	// to the RUNTIME_PROJECT environment variable.
	Project string
	// BaseURL defaults to RUNTIME_API_URL, then https://api.withruntime.com.
	BaseURL string
	// MaxRetries of a retryable error, or of a lost connection on a call safe
	// to send again; 0 means 3, -1 none.
	MaxRetries int
	// HTTPClient sends every request; the default is http.DefaultClient's
	// transport, except that an address that refuses the TLS handshake is
	// passed over for the host's next.
	HTTPClient *http.Client
}

Options configure a Transport.

type Otel

type Otel struct {
	// contains filtered or unexported fields
}

Otel The org's events as OpenTelemetry logs, sent to your OTLP/HTTP endpoint.

func (*Otel) Create

func (c *Otel) Create(ctx context.Context, in ExportCreate, opts *RequestOptions) (*Export, error)

Create Makes an OpenTelemetry export.

func (*Otel) Delete

func (c *Otel) Delete(ctx context.Context, id string, opts *RequestOptions) (*Export, error)

Delete Deletes it: nothing more is sent to it.

func (*Otel) List

func (c *Otel) List(ctx context.Context, q ExportListQuery, opts *RequestOptions) (*Page[Export], error)

List Lists the org's, oldest first.

func (*Otel) ListAll

func (c *Otel) ListAll(ctx context.Context, q ExportListQuery, opts *RequestOptions) iter.Seq2[Export, error]

ListAll is every item of every page List reads from q.Cursor (none: the first page), each page read as the last is used up.

type OutputChunk

type OutputChunk struct {
	// Offset Where it starts in the process's output.
	Offset int64 `json:"offset"`
	// Stream The stream it was written to.
	Stream string `json:"stream"`
	// Text It, as text.
	Text string `json:"text"`
	// Base64 It, as bytes, when the process answers base64.
	Base64 *string `json:"base64,omitempty"`
}

OutputChunk Some of a process's output.

type Page

type Page[T any] struct {
	Items []T     `json:"items"`
	Next  *string `json:"next,omitempty"`
}

Page is what every list returns: a page of its items, and where the next page starts (the next call's cursor) when there is one.

type Point

type Point struct {
	// X
	X int64 `json:"x"`
	// Y
	Y int64 `json:"y"`
}

Point A point on the screen, in pixels from its top left corner.

type Port

type Port struct {
	PortSettings
	// ID Its ID.
	ID string `json:"id"`
	// Object Always `port`.
	Object string `json:"object"`
	// Connect `address:publicPort` (`[address]:publicPort` for IPv6), for a client's host and port.
	Connect string `json:"connect"`
	// Address The public address to connect to.
	Address string `json:"address"`
	// PublicPort The public port to connect to.
	PublicPort int64 `json:"publicPort"`
	// SandboxID The machine it carries to.
	SandboxID string `json:"sandboxId"`
	// State Its state: `ready` once every edge carries it.
	State string `json:"state"`
	// Disabled Turned off by Runtime: no connection passes.
	Disabled bool `json:"disabled"`
	// CreatedAt When it was opened.
	CreatedAt string `json:"createdAt"`
	// DeletedAt When it was deleted: a delete's answer, its state `deleted`.
	DeletedAt *string `json:"deletedAt,omitempty"`
}

Port A public TCP port: raw TCP from a public address and port to a port of a machine.

type PortCreate

type PortCreate struct {
	// SandboxID The machine to carry to.
	SandboxID string `json:"sandboxId"`
	// Port The port inside the machine, 1 to 65535.
	Port int64 `json:"port"`
	// Protocol `tcp`, the only one a public port carries: any other is refused, never made as TCP.
	Protocol *string `json:"protocol,omitempty"`
}

PortCreate A public TCP port to open.

type PortListQuery

type PortListQuery struct {
	// SandboxID Only this machine's ports.
	SandboxID *string
	// Cursor Where the page starts: a page's `next`.
	Cursor *string
	// Limit The most items the page holds. At least 1. At most 200. Default: 50.
	Limit *int64
}

PortListQuery is what List takes in its query.

type PortSettings

type PortSettings struct {
	// Port The port inside the machine. At least 1. At most 65535.
	Port int64 `json:"port"`
}

PortSettings A public TCP port's settings, as it keeps them.

type Ports

type Ports struct {
	// contains filtered or unexported fields
}

Ports A public TCP port carried to a port of a machine: a database, a game server, anything that is not HTTP.

func (*Ports) Create

func (c *Ports) Create(ctx context.Context, in PortCreate, opts *RequestOptions) (*Port, error)

Create Opens a public TCP port to a port of a machine: raw TCP, carried as it is. The public port is assigned from a pool of 10,000; returns 409 when every one is in use. Asked again for the same machine and port, it returns the same public port.

func (*Ports) Delete

func (c *Ports) Delete(ctx context.Context, id string, opts *RequestOptions) (*Port, error)

Delete Closes a public TCP port and the connections through it.

func (*Ports) List

func (c *Ports) List(ctx context.Context, q PortListQuery, opts *RequestOptions) (*Page[Port], error)

List Lists the org's public TCP ports, or one machine's, by `connect`.

func (*Ports) ListAll

func (c *Ports) ListAll(ctx context.Context, q PortListQuery, opts *RequestOptions) iter.Seq2[Port, error]

ListAll is every item of every page List reads from q.Cursor (none: the first page), each page read as the last is used up.

type Preview

type Preview struct {

	// Info is what it was when last read.
	Info *PreviewInfo
	// contains filtered or unexported fields
}

Preview is one of previews: A port of a machine at a public HTTPS address: private with a signed token, or public.

func (*Preview) Delete

func (s *Preview) Delete(ctx context.Context, opts *RequestOptions) (*PreviewInfo, error)

Delete Stops sharing a port.

func (*Preview) ID

func (s *Preview) ID() string

ID is its id.

func (*Preview) Name

func (s *Preview) Name() string

Name is its name.

func (*Preview) Refresh

func (s *Preview) Refresh(ctx context.Context, q *PreviewGetQuery, opts *RequestOptions) error

Refresh Returns a preview; `sign` returns one with a token.

func (*Preview) Rotate

func (s *Preview) Rotate(ctx context.Context, opts *RequestOptions) error

Rotate Refuses every token signed for a preview so far, and returns a new one.

func (*Preview) Sign

func (s *Preview) Sign(ctx context.Context, q *PreviewSignQuery, opts *RequestOptions) error

Sign Returns a private preview with a new token; tokens signed before keep their own expiry.

type PreviewCreate

type PreviewCreate struct {
	// Port The port inside the machine. At least 1. At most 65535.
	Port int64 `json:"port"`
	// Visibility `private` (default): a token is needed. `public`: anyone with the address.
	Visibility *string `json:"visibility,omitempty"`
	// EmbedOrigins The sites that may show it in an iframe; omitted on one that exists, kept as it is; empty for any site.
	EmbedOrigins []string `json:"embedOrigins,omitempty"`
	// TtlSeconds The token's lifetime in seconds, from 60 until the calling key's own end (a year at most); a day when omitted, or the key's end when that is sooner. At least 60. At most 31536000. Default: 86400.
	TtlSeconds *int64 `json:"ttlSeconds,omitempty"`
}

PreviewCreate A preview of the machine its path names to create, or its visibility and sites to change.

type PreviewGetQuery

type PreviewGetQuery struct {
	// Wait Seconds to wait, at most 60, for its state to differ from `ifState`; it answers once it does, or as it is when the wait ends. At least 0. At most 60.
	Wait *float64
	// IfState The state the caller last read, which `wait` waits for it to leave.
	IfState *string
}

PreviewGetQuery is what Get takes in its query.

type PreviewInfo

type PreviewInfo struct {
	// ID Its ID.
	ID string `json:"id"`
	// Name Its hostname, `<port>-<sandbox hex>.<domain>`: its own calls (`/v2/previews/{name}`) take it or its ID.
	Name string `json:"name"`
	// Object Always `preview`.
	Object string `json:"object"`
	// SandboxID The machine whose port it shares.
	SandboxID string `json:"sandboxId"`
	// Port The port inside the machine.
	Port int64 `json:"port"`
	// Visibility `private` or `public`.
	Visibility string `json:"visibility"`
	// Url Its address. A private one also needs the token.
	Url string `json:"url"`
	// State Where it is: `ready` once every serving host routes it.
	State string `json:"state"`
	// Token A token signed for this answer, for a private preview and a key that may create one: send it in the `x-runtime-preview-token` header, or open the url with `?runtime_preview_token=<token>` in a browser.
	Token *string `json:"token,omitempty"`
	// TokenExpiresAt When this answer's token stops working.
	TokenExpiresAt *string `json:"tokenExpiresAt,omitempty"`
	// EmbedOrigins The sites that may show it in an iframe; none for any site.
	EmbedOrigins []string `json:"embedOrigins,omitempty"`
	// CreatedAt When it was created.
	CreatedAt string `json:"createdAt"`
	// DeletedAt When it was deleted: a delete's answer, its state `deleted`.
	DeletedAt *string `json:"deletedAt,omitempty"`
}

PreviewInfo A preview.

type PreviewListQuery

type PreviewListQuery struct {
	// SandboxID The machine whose previews to list.
	SandboxID string
	// Cursor Where the page starts: a page's `next`.
	Cursor *string
	// Limit The most items the page holds. At least 1. At most 200. Default: 50.
	Limit *int64
}

PreviewListQuery is what List takes in its query.

type PreviewSignQuery

type PreviewSignQuery struct {
	// TtlSeconds The token's lifetime in seconds, from 60 until the calling key's own end (a year at most); a day when omitted, or the key's end when that is sooner. At least 60. At most 31536000. Default: 86400.
	TtlSeconds *int64
}

PreviewSignQuery is what Sign takes in its query.

type Previews

type Previews struct {
	// contains filtered or unexported fields
}

Previews A port of a machine at a public HTTPS address: private with a signed token, or public.

func (*Previews) Create

func (c *Previews) Create(ctx context.Context, id string, in PreviewCreate, opts *RequestOptions) (*Preview, error)

Create Shares a port of a machine at an HTTPS address and returns its url and, for a private one, a token; or changes its visibility and sites when it is shared. Asked again, the same preview.

func (*Previews) Delete

func (c *Previews) Delete(ctx context.Context, name string, opts *RequestOptions) (*PreviewInfo, error)

Delete Stops sharing a port.

func (*Previews) Get

func (c *Previews) Get(ctx context.Context, name string, q PreviewGetQuery, opts *RequestOptions) (*Preview, error)

Get Returns a preview; `sign` returns one with a token.

func (*Previews) List

List Lists a machine's previews, lowest port first.

func (*Previews) ListAll

ListAll is every item of every page List reads from q.Cursor (none: the first page), each page read as the last is used up.

func (*Previews) Rotate

func (c *Previews) Rotate(ctx context.Context, name string, opts *RequestOptions) (*PreviewInfo, error)

Rotate Refuses every token signed for a preview so far, and returns a new one.

func (*Previews) Sign

Sign Returns a private preview with a new token; tokens signed before keep their own expiry.

type Process

type Process struct {
	// ID Its ID.
	ID string `json:"id"`
	// Object Always `process`.
	Object string `json:"object"`
	// State Where it is.
	State string `json:"state"`
	// ExitCode Its exit code once it exited; negative when a signal ended it.
	ExitCode *int64 `json:"exitCode,omitempty"`
	// Command The command it runs.
	Command string `json:"command"`
	// Cwd The directory it runs in.
	Cwd *string `json:"cwd,omitempty"`
	// Pty It runs on a terminal.
	Pty bool `json:"pty"`
	// StdinOpen Its standard input is open for processes.write.
	StdinOpen bool `json:"stdinOpen"`
	// StdinOffset Bytes of input it has taken.
	StdinOffset int64 `json:"stdinOffset"`
	// OutputEncoding How its output is answered.
	OutputEncoding string `json:"outputEncoding"`
	// StartedAt When it started.
	StartedAt string `json:"startedAt"`
	// EndedAt When it ended.
	EndedAt *string `json:"endedAt,omitempty"`
	// TimeoutSeconds Seconds it may run before it is killed.
	TimeoutSeconds *float64 `json:"timeoutSeconds,omitempty"`
	// OutputBytes Bytes of output it has written: the cursor past its last.
	OutputBytes int64 `json:"outputBytes"`
	// FirstOffset The oldest byte of its output still kept.
	FirstOffset int64 `json:"firstOffset"`
	// Stdout What it wrote to standard output, as UTF-8: given once an exec waited for its end.
	Stdout *string `json:"stdout,omitempty"`
	// Stderr What it wrote to standard error, as UTF-8: given once an exec waited for its end.
	Stderr *string `json:"stderr,omitempty"`
	// StdoutTruncated stdout holds only part of what it wrote (its first 1 MiB).
	StdoutTruncated *bool `json:"stdoutTruncated,omitempty"`
	// StderrTruncated stderr holds only part of what it wrote (its first 1 MiB).
	StderrTruncated *bool `json:"stderrTruncated,omitempty"`
	// DurationSeconds How long it ran, in seconds, to the millisecond, once it ended.
	DurationSeconds *float64 `json:"durationSeconds,omitempty"`
}

Process A process.

type ProcessInput

type ProcessInput struct {
	// Data The bytes.
	Data *string `json:"data,omitempty"`
	// Offset Bytes of input sent before these (its stdinOffset): a resend is then never taken twice. They go after every other write when omitted.
	Offset *int64 `json:"offset,omitempty"`
	// Eof Close its input after these (^D on a terminal).
	Eof *bool `json:"eof,omitempty"`
}

ProcessInput Input to send a process.

type ProcessList

type ProcessList struct {
	// Items Each process.
	Items []Process `json:"items"`
}

ProcessList A machine's processes, newest first.

type ProcessOutput

type ProcessOutput struct {
	// Chunks The output, in the order it was written.
	Chunks []OutputChunk `json:"chunks"`
	// NextCursor The cursor to read on from.
	NextCursor int64 `json:"nextCursor"`
	// Truncated Output past the cursor was dropped before it was read.
	Truncated bool `json:"truncated"`
	// DroppedBytes How many bytes were dropped.
	DroppedBytes int64 `json:"droppedBytes"`
	// Process The process.
	Process *Process `json:"process,omitempty"`
}

ProcessOutput A process's output after a cursor.

type ProcessSignal

type ProcessSignal struct {
	// Signal The signal; SIGTERM when omitted.
	Signal *string `json:"signal,omitempty"`
}

ProcessSignal A signal to send a process and its group.

type ProcessWritten

type ProcessWritten struct {
	// Offset Bytes of input it has taken in all.
	Offset int64 `json:"offset"`
	// Process The process.
	Process *Process `json:"process,omitempty"`
}

ProcessWritten Input a process took.

type ProductLine

type ProductLine struct {
	// Product What it was used by, as `hours` names it (`sandbox`, `disk`, `traffic`, ...).
	Product string `json:"product"`
	// Meter The card's meter (`cpu`, `memory`, `traffic-out`, ...).
	Meter string `json:"meter"`
	// Name The meter's name on the card (`CPU`, `Memory`), from `names::METERS`.
	Name string `json:"name"`
	// Quantity Used this month, in `unit`, as a decimal in text.
	Quantity string `json:"quantity"`
	// Unit What `quantity` counts: `active vCPU-hours`, `GiB-hours`, `GiB-months`, `GB`, ...
	Unit string `json:"unit"`
	// Rate The card's price for one of `unit`, as the card writes it (`$0.03 per active vCPU-hour`).
	Rate string `json:"rate"`
	// Charged What it costs on the price card, before any credit, in US dollars.
	Charged string `json:"charged"`
}

ProductLine One meter's part of one product's month: a quantity at the card's rate.

type Project

type Project struct {

	// Info is what it was when last read.
	Info *ProjectInfo
	// contains filtered or unexported fields
}

Project is one of projects: A project: where machines, storage, addresses and keys sit, each in one. Every organization has a default project, where a call that names none acts.

func (*Project) Delete added in v2.1.0

func (s *Project) Delete(ctx context.Context, opts *RequestOptions) (*ProjectInfo, error)

Delete Deletes a project and frees its name, with the grants, keys and invitations held to it. The caller needs `grants:delete` as well, as the grants go with it. The default project, or one that still holds a machine, storage or an address, returns 409. Deleted again, it returns 404.

func (*Project) ID

func (s *Project) ID() string

ID is its id.

func (*Project) Limits

func (s *Project) Limits(ctx context.Context, limits ProjectLimits, in *ProjectLimitsSet, opts *RequestOptions) error

Limits Sets a project's own limits: each of its organization's plan limits set lower for it alone, by the price card's names. The whole set: a limit left out is its organization's again. One above its organization's returns 400 `limit_above_org`, naming the limit and both figures. Each start in the project is held to its limits and its organization's.

func (*Project) Refresh added in v2.1.0

func (s *Project) Refresh(ctx context.Context, q *ProjectGetQuery, opts *RequestOptions) error

Refresh Returns one by its ID. Another organization's, one deleted, or one past the key's reach returns 404.

func (*Project) Update added in v2.1.0

func (s *Project) Update(ctx context.Context, name string, in *Rename, opts *RequestOptions) error

Update Renames a project; what is in it stays as it is. A name another project has returns 409.

type ProjectCreate

type ProjectCreate struct {
	// Name Its name, unique in the organization. At least 1 character. At most 64 characters.
	Name string `json:"name"`
	// Limits Its own limits ([`ProjectLimits`]); none, its organization's.
	Limits *ProjectLimits `json:"limits,omitempty"`
}

ProjectCreate A new project.

type ProjectGetQuery added in v2.1.0

type ProjectGetQuery struct {
	// Wait Seconds to wait, at most 60, for its state to differ from `ifState`; it answers once it does, or as it is when the wait ends. At least 0. At most 60.
	Wait *float64
	// IfState The state the caller last read, which `wait` waits for it to leave.
	IfState *string
}

ProjectGetQuery is what Get takes in its query.

type ProjectInfo added in v2.1.0

type ProjectInfo struct {
	// ID Its ID.
	ID string `json:"id"`
	// Object Always `project`.
	Object string `json:"object"`
	// Name Its name, unique in the organization.
	Name string `json:"name"`
	// Default Whether it is the organization's default project, where a call that names none acts.
	Default bool `json:"default"`
	// CreatedAt When it was made.
	CreatedAt string `json:"createdAt"`
	// State `active`; `deleted` once deleted: a delete's answer.
	State string `json:"state"`
	// DeletedAt When it was deleted: a delete's answer, its state `deleted`.
	DeletedAt *string `json:"deletedAt,omitempty"`
	// Limits Its own limits: those of its organization's plan limits set lower for it. One not set is its organization's.
	Limits ProjectLimits `json:"limits"`
}

ProjectInfo A project: where machines, storage, addresses and keys sit.

type ProjectLimits

type ProjectLimits struct {
	// RunningVcpu The most vCPUs its machines run at once. At least 0.
	RunningVcpu *int64 `json:"runningVcpu,omitempty"`
	// RunningMemoryGib The most memory its machines hold at once, in GiB. At least 0.
	RunningMemoryGib *int64 `json:"runningMemoryGib,omitempty"`
	// MachineVcpu The most vCPUs one of its machines has. At least 0.
	MachineVcpu *int64 `json:"machineVcpu,omitempty"`
	// MachineMemoryGib The most memory one of its machines has, in GiB. At least 0.
	MachineMemoryGib *int64 `json:"machineMemoryGib,omitempty"`
	// NewMachinesPerSecond The most machines it starts a second. At least 0.
	NewMachinesPerSecond *int64 `json:"newMachinesPerSecond,omitempty"`
}

ProjectLimits A project's own limits: each of its organization's plan limits set lower for it alone, never higher, by the price card's names and in its units. A start in it is held to both. One not set is its organization's.

type ProjectLimitsSet

type ProjectLimitsSet struct {
	// Limits Its limits, the whole set: each one given is set, each one left out is its organization's again.
	Limits ProjectLimits `json:"limits"`
}

ProjectLimitsSet A project's own limits, set.

type ProjectListQuery

type ProjectListQuery struct {
	// Cursor Where the page starts: a page's `next`.
	Cursor *string
	// Limit The most items the page holds. At least 1. At most 200. Default: 50.
	Limit *int64
}

ProjectListQuery is what List takes in its query.

type Projects

type Projects struct {
	// contains filtered or unexported fields
}

Projects A project: where machines, storage, addresses and keys sit, each in one. Every organization has a default project, where a call that names none acts.

func (*Projects) Create

func (c *Projects) Create(ctx context.Context, in ProjectCreate, opts *RequestOptions) (*Project, error)

Create Creates a project, with its own limits when given. A name another project has returns 409; a limit above its organization's returns 400 `limit_above_org`. Asked again with the same Idempotency-Key, it returns the same one.

func (*Projects) Delete

func (c *Projects) Delete(ctx context.Context, id string, opts *RequestOptions) (*ProjectInfo, error)

Delete Deletes a project and frees its name, with the grants, keys and invitations held to it. The caller needs `grants:delete` as well, as the grants go with it. The default project, or one that still holds a machine, storage or an address, returns 409. Deleted again, it returns 404.

func (*Projects) Get added in v2.1.0

func (c *Projects) Get(ctx context.Context, id string, q ProjectGetQuery, opts *RequestOptions) (*Project, error)

Get Returns one by its ID. Another organization's, one deleted, or one past the key's reach returns 404.

func (*Projects) Limits

func (c *Projects) Limits(ctx context.Context, id string, in ProjectLimitsSet, opts *RequestOptions) (*ProjectInfo, error)

Limits Sets a project's own limits: each of its organization's plan limits set lower for it alone, by the price card's names. The whole set: a limit left out is its organization's again. One above its organization's returns 400 `limit_above_org`, naming the limit and both figures. Each start in the project is held to its limits and its organization's.

func (*Projects) List

List Lists the organization's projects, the default first, then by name.

func (*Projects) ListAll

ListAll is every item of every page List reads from q.Cursor (none: the first page), each page read as the last is used up.

func (*Projects) Update

func (c *Projects) Update(ctx context.Context, id string, in Rename, opts *RequestOptions) (*ProjectInfo, error)

Update Renames a project; what is in it stays as it is. A name another project has returns 409.

type Rename

type Rename struct {
	// Name Its name. At least 1 character. At most 64 characters.
	Name string `json:"name"`
}

Rename A new name; everything else stays as it is.

type RequestOptions

type RequestOptions struct {
	// IdempotencyKey makes a retry safe; one is made for every write when empty.
	IdempotencyKey string
}

RequestOptions apply to one call.

type Role

type Role struct {

	// Info is what it was when last read.
	Info *RoleInfo
	// contains filtered or unexported fields
}

Role is one of roles: One of the organization's own roles: the actions a grant of it allows. The built-in roles (owner, admin, developer, viewer, billing) are not listed here.

func (*Role) Actions

func (s *Role) Actions(ctx context.Context, in *RoleActionsChange, opts *RequestOptions) error

Actions Adds actions to a role and removes actions from it, in place, and returns the role. Every key and grant that gives the role has the new actions from its next call; no key's secret changes. Only an owner or an admin may change a role's actions, and only to add actions the caller may perform itself across the whole organization: any other caller or action returns 403. An action no call has returns 400. A role Runtime manages (its name starts with `runtime.`) returns 409, as does a removal from a role that a deny grant gives (a deny is lifted only by deleting that grant; an addition is allowed), a removal that would leave the role with no actions, or one that removes an action the role still holds through a wildcard such as `images:*`. Adding an action the role already holds, or removing one it does not hold, changes nothing, so the call is safe to retry. Each change is one audit log entry, `roles:actions`, whose reason lists the actions added and removed.

func (*Role) Delete added in v2.1.0

func (s *Role) Delete(ctx context.Context, opts *RequestOptions) (*RoleInfo, error)

Delete Deletes a role and frees its name, with the grants and invitations that give it. The caller needs `grants:delete` as well, as the grants go with it. A role that a deny grant gives returns 409: a deny is lifted only by deleting that grant. Deleted again, it returns 404.

func (*Role) ID

func (s *Role) ID() string

ID is its id.

func (*Role) Refresh added in v2.1.0

func (s *Role) Refresh(ctx context.Context, q *RoleGetQuery, opts *RequestOptions) error

Refresh Returns one by its ID. Another organization's, one deleted, or one past the key's reach returns 404.

func (*Role) Update added in v2.1.0

func (s *Role) Update(ctx context.Context, name string, in *Rename, opts *RequestOptions) error

Update Renames a role; its actions and its grants stay as they are. A built-in role's name, or another role's, returns 409.

type RoleActionsChange

type RoleActionsChange struct {
	// Add The actions to add. One the role already holds as written is left as it is. At most 100 items.
	Add []string `json:"add,omitempty"`
	// Remove The actions to remove, each as the role holds it. One the role does not hold is ignored. At most 100 items.
	Remove []string `json:"remove,omitempty"`
}

RoleActionsChange A change to a role's actions: the actions to add and the actions to remove, in one step. Each is `product:action`, `product:*` or `*`.

type RoleGetQuery added in v2.1.0

type RoleGetQuery struct {
	// Wait Seconds to wait, at most 60, for its state to differ from `ifState`; it answers once it does, or as it is when the wait ends. At least 0. At most 60.
	Wait *float64
	// IfState The state the caller last read, which `wait` waits for it to leave.
	IfState *string
}

RoleGetQuery is what Get takes in its query.

type RoleInfo added in v2.1.0

type RoleInfo struct {
	// ID Its ID.
	ID string `json:"id"`
	// Object Always `role`.
	Object string `json:"object"`
	// Name Its name, unique in the organization.
	Name string `json:"name"`
	// Actions The actions it holds, each `product:action`, `product:*` or `*`.
	Actions []string `json:"actions"`
	// CreatedAt When it was made.
	CreatedAt string `json:"createdAt"`
	// State `active`; `deleted` once deleted: a delete's answer.
	State string `json:"state"`
	// DeletedAt When it was deleted: a delete's answer, its state `deleted`.
	DeletedAt *string `json:"deletedAt,omitempty"`
}

RoleInfo One of the organization's own roles: the actions a grant of it allows.

type RoleListQuery

type RoleListQuery struct {
	// Cursor Where the page starts: a page's `next`.
	Cursor *string
	// Limit The most items the page holds. At least 1. At most 200. Default: 50.
	Limit *int64
}

RoleListQuery is what List takes in its query.

type Roles

type Roles struct {
	// contains filtered or unexported fields
}

Roles One of the organization's own roles: the actions a grant of it allows. The built-in roles (owner, admin, developer, viewer, billing) are not listed here.

func (*Roles) Actions

func (c *Roles) Actions(ctx context.Context, id string, in RoleActionsChange, opts *RequestOptions) (*RoleInfo, error)

Actions Adds actions to a role and removes actions from it, in place, and returns the role. Every key and grant that gives the role has the new actions from its next call; no key's secret changes. Only an owner or an admin may change a role's actions, and only to add actions the caller may perform itself across the whole organization: any other caller or action returns 403. An action no call has returns 400. A role Runtime manages (its name starts with `runtime.`) returns 409, as does a removal from a role that a deny grant gives (a deny is lifted only by deleting that grant; an addition is allowed), a removal that would leave the role with no actions, or one that removes an action the role still holds through a wildcard such as `images:*`. Adding an action the role already holds, or removing one it does not hold, changes nothing, so the call is safe to retry. Each change is one audit log entry, `roles:actions`, whose reason lists the actions added and removed.

func (*Roles) Delete

func (c *Roles) Delete(ctx context.Context, id string, opts *RequestOptions) (*RoleInfo, error)

Delete Deletes a role and frees its name, with the grants and invitations that give it. The caller needs `grants:delete` as well, as the grants go with it. A role that a deny grant gives returns 409: a deny is lifted only by deleting that grant. Deleted again, it returns 404.

func (*Roles) Get added in v2.1.0

func (c *Roles) Get(ctx context.Context, id string, q RoleGetQuery, opts *RequestOptions) (*Role, error)

Get Returns one by its ID. Another organization's, one deleted, or one past the key's reach returns 404.

func (*Roles) List

func (c *Roles) List(ctx context.Context, q RoleListQuery, opts *RequestOptions) (*Page[RoleInfo], error)

List Lists the organization's own roles, by name.

func (*Roles) ListAll

func (c *Roles) ListAll(ctx context.Context, q RoleListQuery, opts *RequestOptions) iter.Seq2[RoleInfo, error]

ListAll is every item of every page List reads from q.Cursor (none: the first page), each page read as the last is used up.

func (*Roles) Update

func (c *Roles) Update(ctx context.Context, id string, in Rename, opts *RequestOptions) (*RoleInfo, error)

Update Renames a role; its actions and its grants stay as they are. A built-in role's name, or another role's, returns 409.

type Route

type Route struct {
	Method     string   `json:"method"`
	Path       string   `json:"path"`
	Params     []string `json:"params"`
	Query      []string `json:"query"`
	Body       string   `json:"body"`
	Raw        bool     `json:"raw"`
	Idempotent bool     `json:"idempotent"`
	Runs       string   `json:"runs"`
}

Route is one verb's route: what Call sends for it.

type RunArgs

type RunArgs struct {
	// Cmd The command: text is run by `bash -lc` (`sh -lc` in an image without bash); a list is the program and its arguments, run without a shell.
	Cmd any `json:"cmd"`
	// Image The image it boots, by name or ID; Runtime's default image when omitted.
	Image *string `json:"image,omitempty"`
	// Vcpu Its vCPUs; 2 when omitted.
	Vcpu *int64 `json:"vcpu,omitempty"`
	// MemoryGb Its memory in GB (1 GB is 1,024 MiB); 4 when omitted.
	MemoryGb *float64 `json:"memoryGB,omitempty"`
	// Cwd The directory it runs in; the user's home when omitted.
	Cwd *string `json:"cwd,omitempty"`
	// Env Environment variables to add.
	Env map[string]string `json:"env,omitempty"`
	// Stdin Bytes sent to its standard input.
	Stdin *string `json:"stdin,omitempty"`
	// TimeoutSeconds Seconds it may run before it is stopped; it runs to its end when omitted.
	TimeoutSeconds *float64 `json:"timeoutSeconds,omitempty"`
}

RunArgs is what Run takes.

type RunCode

type RunCode struct {
	// Code The code. At most 1048576 characters.
	Code string `json:"code"`
	// Language Its language: `python`. Default: "python".
	Language *string `json:"language,omitempty"`
	// Context The context it runs in, each its own kernel and state, started on its first cell (`a-z`, `0-9`, `-`, at most 63); `default` when omitted. At least 1 character. At most 63 characters.
	Context *string `json:"context,omitempty"`
	// TimeoutSeconds Seconds it may run before it is interrupted, its context kept: 1 to 50, 45 when omitted. Run longer work as a process (exec with `wait: false`). At least 1. At most 50.
	TimeoutSeconds *int64 `json:"timeoutSeconds,omitempty"`
}

RunCode A cell to run.

type Runtime

type Runtime struct {
	Transport     *Transport
	Sandboxes     *Sandboxes
	Functions     *Functions
	Secrets       *Secrets
	Apps          *Apps
	Sites         *Sites
	Ci            *Ci
	Browsers      *Browsers
	Desktops      *Desktops
	Notebooks     *Notebooks
	Workspaces    *Workspaces
	Containers    *Containers
	Builds        *Builds
	Jobs          *Jobs
	JobRuns       *JobRuns
	Agents        *Agents
	AgentSessions *AgentSessions
	Messages      *Messages
	Snapshots     *Snapshots
	Images        *Images
	Volumes       *Volumes
	Sessions      *Sessions
	Keys          *Keys
	Projects      *Projects
	Identities    *Identities
	Roles         *Roles
	Audit         *Audit
	Me            *MeClient
	Usage         *UsageClient
	Previews      *Previews
	Domains       *Domains
	Ports         *Ports
	EgressIps     *EgressIps
	Tunnels       *Tunnels
	Networks      *Networks
	Webhooks      *Webhooks
	Events        *Events
	Otel          *Otel
	Feedback      *FeedbackClient
}

Runtime is every product's client over one transport: New(Options{}) reads RUNTIME_API_KEY, and Sandboxes.Create is a sandbox to work in.

func New

func New(o Options) *Runtime

New is a Runtime for o.

func (*Runtime) Call

func (k *Runtime) Call(ctx context.Context, name string, args map[string]any, opts *RequestOptions) (any, error)

Call calls any verb by its name, product.verb (sandboxes.create), with its arguments by name: its path's parts, its query's fields and its body's. A verb newer than this SDK is found in the API's own served description, so it is callable before the SDK is updated.

func (*Runtime) Run

func (k *Runtime) Run(ctx context.Context, a RunArgs, opts *RequestOptions) (answer any, err error)

Run Runs a command in a new sandbox and deletes the sandbox after, whether the command succeeded or not. Returns the command's result.

type Sandbox

type Sandbox struct {

	// Info is what it was when last read.
	Info      *SandboxInfo
	Files     *SandboxFiles
	Processes *SandboxProcesses
	Network   *SandboxNetworkCalls
	Previews  *SandboxPreviews
	// contains filtered or unexported fields
}

Sandbox is one of sandboxes: A Linux machine with its own kernel, made in milliseconds, paused with its memory kept when idle and resumed where it was. Its life: running, then idle, then paused, until you delete it. A paused sandbox is kept with its memory and disk until it is deleted: it has no time limit, no retention period and no expiry, and nothing deletes it for its age. Every 30 days a sandbox stays paused, counted from its `pausedAt`, a `sandbox.still_paused` event is written for its organization.

func (*Sandbox) Act

func (s *Sandbox) Act(ctx context.Context, actions []Action, in *ActRequest, opts *RequestOptions) (*Acted, error)

Act Moves, clicks, drags and scrolls the mouse and types on the keyboard of a sandbox's screen (its X display `:1`), each step in turn as one command, and returns where the mouse is then. It stops at the first step that fails, refused 409 `act_failed` naming it; refused 409 `display_not_running` when no display runs. A paused sandbox is resumed first.

func (*Sandbox) Delete

func (s *Sandbox) Delete(ctx context.Context, opts *RequestOptions) (*SandboxInfo, error)

Delete Deletes a sandbox, its memory and its disk.

func (*Sandbox) Exec

func (s *Sandbox) Exec(ctx context.Context, cmd string, in *ExecRequest, opts *RequestOptions) (*Process, error)

Exec Runs a command as a process and returns it once it ended, with its output; with wait false, at once, while it runs. A paused sandbox is resumed first. Asked again with the same Idempotency-Key, it runs nothing more: it returns the first run's process, waiting for its end while it runs.

func (*Sandbox) ExecStream

func (s *Sandbox) ExecStream(cmd string, in *ExecRequest, opts *RequestOptions) *Stream[OutputChunk, Process]

ExecStream Runs a command and yields its output as it is written, stdout and stderr in order; once it ends, wait() returns the process with its exit code.

func (*Sandbox) Fork

func (s *Sandbox) Fork(ctx context.Context, in *ForkRequest, opts *RequestOptions) (*Forked, error)

Fork Copies a sandbox as it is now, memory and disk, into `count` copies of its own, each running on its host. Asked again with the same Idempotency-Key, it returns the same copies.

func (*Sandbox) ID

func (s *Sandbox) ID() string

ID is its id.

func (*Sandbox) Metrics

Metrics Returns a sandbox's CPU, memory, disks and pressure, as its host reads them from the sandbox's own cgroup over a fifth of a second: never a call into the sandbox, so it does not wake a paused one nor keep one from its idle pause. One that is not running has no reading.

func (*Sandbox) Pause

func (s *Sandbox) Pause(ctx context.Context, opts *RequestOptions) error

Pause Pauses a sandbox with its memory and disk kept. A call to it resumes it.

func (*Sandbox) Refresh

func (s *Sandbox) Refresh(ctx context.Context, q *SandboxGetQuery, opts *RequestOptions) error

Refresh Returns a sandbox.

func (*Sandbox) Resume

func (s *Sandbox) Resume(ctx context.Context, opts *RequestOptions) error

Resume Resumes a paused sandbox where it was, its memory and processes as they were.

func (*Sandbox) RunCode

func (s *Sandbox) RunCode(ctx context.Context, code string, in *RunCode, opts *RequestOptions) (*CodeRun, error)

RunCode Runs a cell of Python in a sandbox as a notebook does, in a Jupyter kernel it keeps running for the cell's `context`: variables, imports and functions stay for the next cell. Returns what it printed, its values and displays (text, HTML, images such as charts), and its exception with its traceback. The context's kernel starts on its first cell. A cell past `timeoutSeconds` is interrupted and its context kept. Refused 409 `kernel_not_installed` when the image has no ipykernel. A paused sandbox is resumed first.

func (*Sandbox) Screenshot

func (s *Sandbox) Screenshot(ctx context.Context, q *SandboxScreenshotQuery, opts *RequestOptions) ([]byte, error)

Screenshot Returns what a sandbox's screen shows now, as `image/png` (or `image/jpeg`): its X display `:1`, whole. Refused 409 `display_not_running` when no display runs. A paused sandbox is resumed first.

func (*Sandbox) Snapshot

func (s *Sandbox) Snapshot(ctx context.Context, in *SnapshotRequest, opts *RequestOptions) (*Stored, error)

Snapshot Keeps a sandbox's memory and disk as they are now, a snapshot to start sandboxes from; with `image`, its disk alone as that image's next version. The sandbox runs on. Asked again with the same Idempotency-Key, it returns the same snapshot.

func (*Sandbox) Update

func (s *Sandbox) Update(ctx context.Context, in *MachineUpdate, opts *RequestOptions) error

Update Changes its name, labels, idle pause, maxCost, autoWake, lifetime, delete protection, environment or sizes; each field left out stays as it is. A lifetime (`deleteAfterSeconds`) sent again before its end moves the end to that many seconds from now; 0 takes it off. A lifetime is refused (409 `delete_protected`) while `deleteProtection` is true. A running one holds a changed environment before this answers (a paused one's at its wake): each process it starts after the answer has it, and its running processes keep the one they started with. Its vCPUs, memory and disk grow while it runs, its commands running on. One paused or stopped is not woken for it: judged at once as a live resize is (past the vCPUs it was made with 409, over its organization's limits `quota_exceeded`), its new sizes are returned at once, and its next wake grows it to them before the call that woke it runs. A smaller size, or a machine starting or failed, is refused 409 naming why, and nothing is changed. With If-Match, made only while its revision is that one, else 412. Sent again with the same Idempotency-Key and body while it is the latest change, it returns the current state and changes nothing; the same key with a different body returns 409 idempotency_key_reused.

type SandboxCreate

type SandboxCreate struct {
	SandboxSettings
	// Volumes Volumes it attaches and mounts at its create, at most one; detached when it is deleted, to attach to another.
	Volumes []VolumeMount `json:"volumes,omitempty"`
	// Run A command it runs once it starts. When the command ends, the machine is `paused` with its disk kept (exitCode says how it ended) and a call starts it again. Needs the `exec` permission too.
	Run *SandboxRun `json:"run,omitempty"`
	// Name Its name, unique in its project.
	Name *string `json:"name,omitempty"`
	// Labels Labels to find it by.
	Labels map[string]string `json:"labels,omitempty"`
	// GetOrCreate With a name: the machine of that name when there is one, else a new one.
	GetOrCreate *bool `json:"getOrCreate,omitempty"`
	// MaxCost The most it may cost in all, in US dollars (`"5.00"`): once it has cost that it pauses, and starts again only once its maxCost is raised (`update`); what a key's per-request and spend caps count. When omitted under a key with a per-request or spend cap, the most that key's caps leave.
	MaxCost *string `json:"maxCost,omitempty"`
	// IdlePauseSeconds Seconds with nothing happening before it pauses, 60 to 86400; 0 never; its product's default when omitted (300 for a sandbox). A fork keeps its source's, except 0: a copy never pauses only when its fork asks. At least 0. At most 86400.
	IdlePauseSeconds *int64 `json:"idlePauseSeconds,omitempty"`
	// From What it starts as, by ID or name: a snapshot (a copy of it running, at its sizes, in its project, with its secrets) or an image (as `image` takes it). A name is a snapshot's when the project has one of that name, else an image's. Not with `image`. Running copies of a sandbox are `fork`'s.
	From *string `json:"from,omitempty"`
	// Snapshot Deprecated: SDK 1.0.x's name for `from` with a snapshot, read as `from` ([`snapshot_is_from`]). Not with `from`.
	Snapshot *string `json:"snapshot,omitempty"`
	// Network Where it may connect out from its first start, as setNetwork takes it; the open internet behind every machine's walls when omitted.
	Network *NetworkRules `json:"network,omitempty"`
	// Env Environment variables for every command and process in it and its start, at most 32 and 32768 bytes of names and values; values are never answered. A copy keeps them.
	Env map[string]string `json:"env,omitempty"`
	// AutoWake Whether a call that reaches it paused (an exec, a file, a terminal, a preview's visitor) resumes it; true when omitted. false: such a call answers 409 sandbox_paused and it stays paused until its own `:resume`. A fork's copies keep it.
	AutoWake *bool `json:"autoWake,omitempty"`
	// DeleteAfterSeconds Seconds until Runtime deletes it, as its delete does: final at once, its memory and disk gone and no longer billed; it can't be undone. 0 or omitted: kept until deleted. Its owner renews it with update; a copy, snapshot or image made from it sets its own. At least 0. At most 315360000.
	DeleteAfterSeconds *int64 `json:"deleteAfterSeconds,omitempty"`
	// Files Text files to write in it before it answers, each path to its text: absolute, or under its code's folder (`/app` for an app or a function, `/site` for a site, `/workspace` for the rest); at most 256 files, and its request at most 4 MiB. An app's or a function's server is then started again, once, on them, and it answers once its port serves again, or 409 `start_failed` when it does not within 60 seconds. Binary files and big trees go by files.write and uploadFolder.
	Files map[string]string `json:"files,omitempty"`
	// DeleteProtection Whether its delete is refused (409 `delete_protected`) until an update turns this off; false when omitted. Not with `deleteAfterSeconds`. While true, its time limit pauses it instead of deleting it; only its organization's close deletes it. A copy, snapshot or image made from it sets its own.
	DeleteProtection *bool `json:"deleteProtection,omitempty"`
}

SandboxCreate A machine to create.

type SandboxDownloadFolderQuery

type SandboxDownloadFolderQuery struct {
	// Path The folder, absolute, such as `/workspace/app`.
	Path string
	// Gzip Compress the archive with gzip. Default: false.
	Gzip *bool
	// User Who packs it: `runtime` or `root`; the sandbox's `user` when omitted.
	User *string
	// Exclude Paths in the folder to leave out, relative to it and comma-separated (`node_modules,.cache`): plain names, no wildcards, at most 32.
	Exclude *string
}

SandboxDownloadFolderQuery is what DownloadFolder takes in its query.

type SandboxFiles

type SandboxFiles struct {
	// contains filtered or unexported fields
}

SandboxFiles is a sandbox's files.

func (*SandboxFiles) AbortFolderUpload

func (g *SandboxFiles) AbortFolderUpload(ctx context.Context, upload string, opts *RequestOptions) (*FolderUploadAborted, error)

AbortFolderUpload Stops a folder upload's tar; what it unpacked so far stays.

func (*SandboxFiles) BeginFolderUpload

func (g *SandboxFiles) BeginFolderUpload(ctx context.Context, path string, in *FolderUploadBegin, opts *RequestOptions) (*FolderUpload, error)

BeginFolderUpload Begins a folder's upload in parts: tar starts in the sandbox, unpacking into the folder each part as it arrives. Send the parts in order by offset (writeFolderUpload), then commitFolderUpload; an upload no call names for 10 minutes is ended. A paused sandbox is woken first.

func (*SandboxFiles) CommitFolderUpload

func (g *SandboxFiles) CommitFolderUpload(ctx context.Context, upload string, opts *RequestOptions) (*FolderUnpacked, error)

CommitFolderUpload Ends a folder upload's input and returns once tar has ended, as an exec returns once its command has: the folder, or 400 `invalid_archive` with what tar said. Sent again, it returns how tar ended. An upload no call has named for 10 minutes since its last part or commit is ended.

func (*SandboxFiles) DownloadFolder

func (g *SandboxFiles) DownloadFolder(ctx context.Context, path string, q *SandboxDownloadFolderQuery, opts *RequestOptions) ([]byte, error)

DownloadFolder Returns a folder as a tar archive (`application/x-tar`, or `application/gzip` with gzip), packed by tar in the sandbox as it streams, of any size; its entries are relative to the folder (`./a.txt`). A folder that fails part way (a file it may not read, or one that changes as it is read) ends as an archive every tar reader refuses, never as a short one that reads whole. At most 4 at once in a sandbox. A paused sandbox is woken first.

func (g *SandboxFiles) Link(ctx context.Context, path string, in *FileLinkCreate, opts *RequestOptions) (*FileLink, error)

Link Makes an expiring address for one file that anyone may open with no API key, from a browser, curl or another service: GET downloads it (Range works, so videos play and downloads resume; archive: true downloads a folder as .tar.gz), PUT with the raw body uploads it (up to maxBytes, written whole; Content-Length required). The link acts as the key that made it: an upload link needs write, and the link ends with its key, with revokeLinks or with its sandbox. A paused sandbox is woken for it unless wake is false. A port it serves is shared by a preview (previews.create), not a link.

func (*SandboxFiles) List

List Lists a directory's entries in path order, to a depth.

func (*SandboxFiles) Mkdir

func (g *SandboxFiles) Mkdir(ctx context.Context, path string, in *FileMkdir, opts *RequestOptions) (*FileMade, error)

Mkdir Makes a directory, and its parents unless parents is false. One there already is success, created false.

func (*SandboxFiles) Read

func (g *SandboxFiles) Read(ctx context.Context, path string, q *SandboxReadQuery, opts *RequestOptions) ([]byte, error)

Read Returns a file's bytes.

func (*SandboxFiles) Remove

func (g *SandboxFiles) Remove(ctx context.Context, path string, in *FileRemove, opts *RequestOptions) (*FileRemoved, error)

Remove Removes a file, a link or a directory (recursive for one with contents). One missing is success, removed false.

func (*SandboxFiles) Rename

func (g *SandboxFiles) Rename(ctx context.Context, in *FileRename, opts *RequestOptions) (*FileRenamed, error)

Rename Moves a file, a link or a directory; refused 409 when something is at its new path, unless overwrite. With sha256 or size, a file written in parts is put in place once whole: its writes ended, then only a file of that size with every byte written and whose bytes hash to it moves; refused 409 `upload_incomplete` or `checksum_mismatch`, nothing moved. With sha256, it is safe to send again: once moved, it returns the same answer while `from` is gone and `to` holds those bytes.

func (g *SandboxFiles) RevokeLinks(ctx context.Context, opts *RequestOptions) (*FileLinksRevoked, error)

RevokeLinks Ends every file link made for a sandbox so far; links made after work.

func (*SandboxFiles) Stat

func (g *SandboxFiles) Stat(ctx context.Context, path string, q *SandboxStatQuery, opts *RequestOptions) (*FileInfo, error)

Stat Returns what is at a path: a file, a directory or a link, or nothing (exists false). With sha256=true, a file's SHA-256 too.

func (*SandboxFiles) UploadFolder

func (g *SandboxFiles) UploadFolder(ctx context.Context, path string, data []byte, q *SandboxUploadFolderQuery, opts *RequestOptions) (*FolderUnpacked, error)

UploadFolder Unpacks the request's tar archive (gzip-compressed or not, told by its first bytes) into a folder, made with its parents, by tar in the sandbox as the bytes arrive, of any size, nothing of it kept on disk but what tar writes; returns once tar has ended, or 400 `invalid_archive` with what tar said. A paused sandbox is woken first.

func (*SandboxFiles) Write

func (g *SandboxFiles) Write(ctx context.Context, path string, data []byte, q *SandboxWriteQuery, opts *RequestOptions) (*FileWritten, error)

Write Writes the request's bytes to a file as they come, of any size (Content-Length required), its folders made: the file whole when they all came, or as it was. With offset, they are written into it in place.

func (*SandboxFiles) WriteFolderUpload

func (g *SandboxFiles) WriteFolderUpload(ctx context.Context, upload string, data []byte, q *SandboxWriteFolderUploadQuery, opts *RequestOptions) (*FolderUploadReceived, error)

WriteFolderUpload Sends the request's bytes, a part of the archive at its offset, into tar's input as they arrive, of any size, and returns the bytes received in all once tar took them. A part past them is refused 409 `upload_incomplete`, naming them: send the parts in order.

type SandboxGetQuery

type SandboxGetQuery struct {
	// Wait Seconds to wait, at most 60, for its state to differ from `ifState`; it answers once it does, or as it is when the wait ends. At least 0. At most 60.
	Wait *float64
	// IfState The state the caller last read, which `wait` waits for it to leave.
	IfState *string
}

SandboxGetQuery is what Get takes in its query.

type SandboxInfo

type SandboxInfo struct {
	SandboxSettings
	// ID Its ID.
	ID string `json:"id"`
	// Object Its product's kind: `sandbox` for a sandbox, `app` for an app, and so on.
	Object string `json:"object"`
	// Name Its name, unique in its project.
	Name *string `json:"name,omitempty"`
	// State Where it is.
	State string `json:"state"`
	// Labels Its labels.
	Labels map[string]string `json:"labels"`
	// CreatedAt When it was created.
	CreatedAt *string `json:"createdAt,omitempty"`
	// DeletedAt When it was deleted: a delete's answer alone.
	DeletedAt *string `json:"deletedAt,omitempty"`
	// Revision Its revision, changed by every change to it: what an update's If-Match names.
	Revision *int64 `json:"revision,omitempty"`
	// IdlePauseSeconds Seconds with nothing happening before it pauses; 0 never. Default: 300.
	IdlePauseSeconds *int64 `json:"idlePauseSeconds,omitempty"`
	// MaxCost The most it may cost in all, in US dollars; none when it has no such cap.
	MaxCost *string `json:"maxCost,omitempty"`
	// AutoWake Whether a call that reaches it paused resumes it; false: only its own resume does, and such a call answers 409 sandbox_paused. Default: true.
	AutoWake *bool `json:"autoWake,omitempty"`
	// ExitCode Its run's exit code, once its run ended; none for one a signal or its timeout ended.
	ExitCode *int64 `json:"exitCode,omitempty"`
	// EndedAt When its run ended.
	EndedAt *string `json:"endedAt,omitempty"`
	// PausedAt When its pause began (or its run ended), while it is paused.
	PausedAt *string `json:"pausedAt,omitempty"`
	// Ready A create's answer alone, for a start with a ready check: how its wait went.
	Ready *MachineReady `json:"ready,omitempty"`
	// Url For a machine that serves a port of its own (an app, a site or a function on 8080, a container on its image's, a notebook on 8888, a workspace on 8080, a desktop on 6080, a browser's DevTools on 9222): a link that opens it, answered by its create, get and update, none for a key that may not share its ports. It works for 10 minutes; a browser that opens it is given a cookie for that address for a day and sent on to the address without it, so no history keeps a link that still opens it. Another port is shared with previews.create.
	Url *string `json:"url,omitempty"`
	// DeleteAt When Runtime deletes it (`deleteAfterSeconds`), finally: it can't be undone, as its delete can't; none: kept until deleted.
	DeleteAt *string `json:"deleteAt,omitempty"`
	// DeleteProtection Whether its delete is refused (409 `delete_protected`) until an update turns this off.
	DeleteProtection *bool `json:"deleteProtection,omitempty"`
}

SandboxInfo A machine.

type SandboxListFilesQuery

type SandboxListFilesQuery struct {
	// Path The directory. Default: "/workspace".
	Path *string
	// Depth How deep to list. At least 1. At most 10. Default: 1.
	Depth *int64
	// Limit At most this many entries. At least 1. At most 2000. Default: 2000.
	Limit *int64
	// Hidden List entries whose names start with a dot. Default: true.
	Hidden *bool
	// Glob Only entries whose path relative to the directory matches: `*` within a name, `**` across folders, `?` one character, `{a,b}` either (`**/*.py`); at most 512 characters, 32 wildcards and 64 texts in braces. The listing then reaches as deep as the glob does (10 folders for `**`) unless depth says, and is searched past its first 2,000 entries, up to 50,000. At most 512 characters.
	Glob *string
}

SandboxListFilesQuery is what ListFiles takes in its query.

type SandboxListQuery

type SandboxListQuery struct {
	// State Only those in these states, comma-separated.
	State *string
	// Name Only the sandbox of this name.
	Name *string
	// Label Only those with every label given (repeat it for several): key:value, or a key for any value.
	Label []string
	// Cursor Where the page starts: a page's `next`.
	Cursor *string
	// Limit The most items the page holds. At least 1. At most 200. Default: 50.
	Limit *int64
}

SandboxListQuery is what List takes in its query.

type SandboxMetrics

type SandboxMetrics struct {
	MetricsBase
	// ID The machine's ID.
	ID string `json:"id"`
}

SandboxMetrics A machine's metrics.

type SandboxMetricsQuery

type SandboxMetricsQuery struct {
	// Range The window: `15m`, `1h`, `6h`, `24h`, `7d` or `30d`. Default: "1h".
	Range *string
}

SandboxMetricsQuery is what Metrics takes in its query.

type SandboxNetwork

type SandboxNetwork struct {
	NetworkRules
	// ID The machine's ID.
	ID string `json:"id"`
}

SandboxNetwork Where a machine may connect out.

type SandboxNetworkCalls

type SandboxNetworkCalls struct {
	// contains filtered or unexported fields
}

SandboxNetworkCalls is a sandbox's network.

func (*SandboxNetworkCalls) Get

Get Returns where a sandbox may connect out.

func (*SandboxNetworkCalls) Set

Set Replaces where a sandbox may connect out, for its next connection and within a second for its open ones: those the new rules refuse are cut.

type SandboxPreviews

type SandboxPreviews struct {
	// contains filtered or unexported fields
}

SandboxPreviews is a sandbox's previews.

func (*SandboxPreviews) Create

func (g *SandboxPreviews) Create(ctx context.Context, port int64, in *PreviewCreate, opts *RequestOptions) (*Preview, error)

Create Shares a port of a machine at an HTTPS address and returns its url and, for a private one, a token; or changes its visibility and sites when it is shared. Asked again, the same preview.

type SandboxProcessOutputQuery

type SandboxProcessOutputQuery struct {
	// Cursor Output after this byte. At least 0. Default: 0.
	Cursor *int64
	// WaitSeconds Seconds to wait for output past the cursor or its exit, at most 8. At least 0. At most 8.
	WaitSeconds *float64
	// MaxBytes At most this many bytes. At least 4096. At most 196608. Default: 65536.
	MaxBytes *int64
	// Follow Answer as NDJSON events from the cursor until it exits (stdout, stderr, truncated, exit; continue with the cursor to follow on from), as `Accept: application/x-ndjson` does.
	Follow *bool
}

SandboxProcessOutputQuery is what ProcessOutput takes in its query.

type SandboxProcesses

type SandboxProcesses struct {
	// contains filtered or unexported fields
}

SandboxProcesses is a sandbox's processes.

func (*SandboxProcesses) List

List Lists a sandbox's processes, newest first: those running and those that ended lately.

func (*SandboxProcesses) Output

Output Returns a process's output after a cursor, and the cursor to read on from. The latest 1 MiB is kept; truncated says when the cursor fell behind.

func (*SandboxProcesses) Resize

func (g *SandboxProcesses) Resize(ctx context.Context, process string, in *Terminal, opts *RequestOptions) (*Process, error)

Resize Resizes the terminal of a process started with a pty (its window's columns and rows, which the process is told by SIGWINCH), and returns the process; refused 409 for a process without one. A process that ended is left as it is, so a retry is safe.

func (*SandboxProcesses) Signal

func (g *SandboxProcesses) Signal(ctx context.Context, process string, in *ProcessSignal, opts *RequestOptions) (*Process, error)

Signal Sends a signal to a process and its group; a process that ended is not signalled, so a retry is safe.

func (*SandboxProcesses) Write

func (g *SandboxProcesses) Write(ctx context.Context, process string, in *ProcessInput, opts *RequestOptions) (*ProcessWritten, error)

Write Sends input to a process started with stdinOpen or a pty, and returns how much of its input it has taken.

type SandboxReadQuery

type SandboxReadQuery struct {
	// Path The file's path in the machine.
	Path string
}

SandboxReadQuery is what Read takes in its query.

type SandboxRun

type SandboxRun struct {
	// Cmd The command: text, run by `bash -lc` (`sh -lc` in an image without bash), or the program and its arguments as a list, run without a shell.
	Cmd any `json:"cmd"`
	// Cwd The directory it runs in; the user's home when omitted.
	Cwd *string `json:"cwd,omitempty"`
	// Env Environment variables to add.
	Env map[string]string `json:"env,omitempty"`
	// TimeoutSeconds Seconds it may run before it is stopped (`1.5` for 1,500 ms); no limit when omitted or 0. At least 0.
	TimeoutSeconds *float64 `json:"timeoutSeconds,omitempty"`
}

SandboxRun A command a machine runs once it starts: when it ends, the machine stops.

type SandboxScreenshotQuery

type SandboxScreenshotQuery struct {
	// Format `png`, or `jpeg`: smaller and quicker to send, for a model that reads it. Default: "png".
	Format *string
	// Quality A jpeg's quality, 1 to 100. At least 1. At most 100. Default: 80.
	Quality *int64
}

SandboxScreenshotQuery is what Screenshot takes in its query.

type SandboxSettings

type SandboxSettings struct {
	// Vcpu Its vCPUs, at least every plan's least (a smaller number is taken as it); its product's default when omitted. At least 2.
	Vcpu *int64 `json:"vcpu,omitempty"`
	// MemoryGb Its memory in GB (1 GB is 1,024 MiB); a fraction is taken to the MiB (`1.5`). Its product's default when omitted. At least 1.
	MemoryGb *float64 `json:"memoryGB,omitempty"`
	// DiskGb Its disk in GB (1 GB is 1,024 MiB), to the MiB. When omitted, its product's default or its image's size, whichever is larger. At least 1.
	DiskGb *float64 `json:"diskGB,omitempty"`
	// Image The image it boots, by name (its newest version), `name:version` or ID; Runtime's default image when omitted.
	Image *string `json:"image,omitempty"`
	// Secrets The secrets it may get, by name, at most 64: only those of them whose scope admits it; [] none; every one whose scope admits it when omitted. A name with no secret yet takes effect once that secret is created. An update changes it; a fork or a copy of a snapshot keeps it. At most 64 items.
	Secrets []string `json:"secrets,omitempty"`
	// Start The command it starts at every fresh boot and keeps running, as a service: a web server, a runner, a desktop. A wake with its memory kept does not start it again. Its image's when omitted.
	Start *MachineStart `json:"start,omitempty"`
	// User Who every command, process, terminal and code run in it runs as when the call names no `user`: `runtime` (uid 1000, with passwordless sudo) or `root`. Its image's when omitted, else `runtime`.
	User *string `json:"user,omitempty"`
}

SandboxSettings A machine's settings: what a create sets on it.

type SandboxStatQuery

type SandboxStatQuery struct {
	// Path The file's path in the machine.
	Path string
	// Sha256 Also return a file's SHA-256, read from its bytes: to check a file you put in place (files:rename with sha256) is whole. Default: false.
	Sha256 *bool
}

SandboxStatQuery is what Stat takes in its query.

type SandboxUploadFolderQuery

type SandboxUploadFolderQuery struct {
	// Path The folder, absolute, such as `/workspace/app`: made with its parents.
	Path string
	// User Who unpacks it: `runtime` or `root`; the sandbox's `user` when omitted.
	User *string
}

SandboxUploadFolderQuery is what UploadFolder takes in its query.

type SandboxWriteFolderUploadQuery

type SandboxWriteFolderUploadQuery struct {
	// Offset Where the part starts in the archive: at most the bytes received so far. Bytes before them were taken already and are skipped, so a part sent again is never unpacked twice. At least 0. Default: 0.
	Offset *int64
}

SandboxWriteFolderUploadQuery is what WriteFolderUpload takes in its query.

type SandboxWriteQuery

type SandboxWriteQuery struct {
	// Path The file's path in the machine.
	Path string
	// Mode Its mode, in octal (`644`).
	Mode *string
	// Offset Write the bytes into the file in place from this byte, keeping the bytes before and after them (the file is made when there is none); one that fails part way may leave its range written in part, so send it again. Parts of one file may be written so at once and in any order: write them to a new path, then rename it with its size and sha256 to put it in place whole. At least 0.
	Offset *int64
	// Sha256 The bytes' SHA-256 in hex: refused 409 `checksum_mismatch`, the file as it was, when they differ. Not with offset.
	Sha256 *string
}

SandboxWriteQuery is what Write takes in its query.

type Sandboxes

type Sandboxes struct {
	// contains filtered or unexported fields
}

Sandboxes A Linux machine with its own kernel, made in milliseconds, paused with its memory kept when idle and resumed where it was. Its life: running, then idle, then paused, until you delete it. A paused sandbox is kept with its memory and disk until it is deleted: it has no time limit, no retention period and no expiry, and nothing deletes it for its age. Every 30 days a sandbox stays paused, counted from its `pausedAt`, a `sandbox.still_paused` event is written for its organization.

func (*Sandboxes) AbortFolderUpload

func (c *Sandboxes) AbortFolderUpload(ctx context.Context, id string, upload string, opts *RequestOptions) (*FolderUploadAborted, error)

AbortFolderUpload Stops a folder upload's tar; what it unpacked so far stays.

func (*Sandboxes) Act

func (c *Sandboxes) Act(ctx context.Context, id string, in ActRequest, opts *RequestOptions) (*Acted, error)

Act Moves, clicks, drags and scrolls the mouse and types on the keyboard of a sandbox's screen (its X display `:1`), each step in turn as one command, and returns where the mouse is then. It stops at the first step that fails, refused 409 `act_failed` naming it; refused 409 `display_not_running` when no display runs. A paused sandbox is resumed first.

func (*Sandboxes) BeginFolderUpload

func (c *Sandboxes) BeginFolderUpload(ctx context.Context, id string, in FolderUploadBegin, opts *RequestOptions) (*FolderUpload, error)

BeginFolderUpload Begins a folder's upload in parts: tar starts in the sandbox, unpacking into the folder each part as it arrives. Send the parts in order by offset (writeFolderUpload), then commitFolderUpload; an upload no call names for 10 minutes is ended. A paused sandbox is woken first.

func (*Sandboxes) CommitFolderUpload

func (c *Sandboxes) CommitFolderUpload(ctx context.Context, id string, upload string, opts *RequestOptions) (*FolderUnpacked, error)

CommitFolderUpload Ends a folder upload's input and returns once tar has ended, as an exec returns once its command has: the folder, or 400 `invalid_archive` with what tar said. Sent again, it returns how tar ended. An upload no call has named for 10 minutes since its last part or commit is ended.

func (*Sandboxes) Create

func (c *Sandboxes) Create(ctx context.Context, in SandboxCreate, opts *RequestOptions) (*Sandbox, error)

Create Creates a sandbox. Asked again with the same Idempotency-Key, it returns the same sandbox.

func (*Sandboxes) Delete

func (c *Sandboxes) Delete(ctx context.Context, id string, opts *RequestOptions) (*SandboxInfo, error)

Delete Deletes a sandbox, its memory and its disk.

func (*Sandboxes) DownloadFolder

func (c *Sandboxes) DownloadFolder(ctx context.Context, id string, q SandboxDownloadFolderQuery, opts *RequestOptions) ([]byte, error)

DownloadFolder Returns a folder as a tar archive (`application/x-tar`, or `application/gzip` with gzip), packed by tar in the sandbox as it streams, of any size; its entries are relative to the folder (`./a.txt`). A folder that fails part way (a file it may not read, or one that changes as it is read) ends as an archive every tar reader refuses, never as a short one that reads whole. At most 4 at once in a sandbox. A paused sandbox is woken first.

func (*Sandboxes) Exec

func (c *Sandboxes) Exec(ctx context.Context, id string, in ExecRequest, opts *RequestOptions) (*Process, error)

Exec Runs a command as a process and returns it once it ended, with its output; with wait false, at once, while it runs. A paused sandbox is resumed first. Asked again with the same Idempotency-Key, it runs nothing more: it returns the first run's process, waiting for its end while it runs.

func (*Sandboxes) Fork

func (c *Sandboxes) Fork(ctx context.Context, id string, in ForkRequest, opts *RequestOptions) (*Forked, error)

Fork Copies a sandbox as it is now, memory and disk, into `count` copies of its own, each running on its host. Asked again with the same Idempotency-Key, it returns the same copies.

func (*Sandboxes) Get

Get Returns a sandbox.

func (*Sandboxes) GetNetwork

func (c *Sandboxes) GetNetwork(ctx context.Context, id string, opts *RequestOptions) (*SandboxNetwork, error)

GetNetwork Returns where a sandbox may connect out.

func (c *Sandboxes) Link(ctx context.Context, id string, in FileLinkCreate, opts *RequestOptions) (*FileLink, error)

Link Makes an expiring address for one file that anyone may open with no API key, from a browser, curl or another service: GET downloads it (Range works, so videos play and downloads resume; archive: true downloads a folder as .tar.gz), PUT with the raw body uploads it (up to maxBytes, written whole; Content-Length required). The link acts as the key that made it: an upload link needs write, and the link ends with its key, with revokeLinks or with its sandbox. A paused sandbox is woken for it unless wake is false. A port it serves is shared by a preview (previews.create), not a link.

func (*Sandboxes) List

List Lists the project's sandboxes, newest first.

func (*Sandboxes) ListAll

ListAll is every item of every page List reads from q.Cursor (none: the first page), each page read as the last is used up.

func (*Sandboxes) ListFiles

func (c *Sandboxes) ListFiles(ctx context.Context, id string, q SandboxListFilesQuery, opts *RequestOptions) (*FileList, error)

ListFiles Lists a directory's entries in path order, to a depth.

func (*Sandboxes) ListProcesses

func (c *Sandboxes) ListProcesses(ctx context.Context, id string, opts *RequestOptions) (*ProcessList, error)

ListProcesses Lists a sandbox's processes, newest first: those running and those that ended lately.

func (*Sandboxes) Metrics

Metrics Returns a sandbox's CPU, memory, disks and pressure, as its host reads them from the sandbox's own cgroup over a fifth of a second: never a call into the sandbox, so it does not wake a paused one nor keep one from its idle pause. One that is not running has no reading.

func (*Sandboxes) Mkdir

func (c *Sandboxes) Mkdir(ctx context.Context, id string, in FileMkdir, opts *RequestOptions) (*FileMade, error)

Mkdir Makes a directory, and its parents unless parents is false. One there already is success, created false.

func (*Sandboxes) Pause

func (c *Sandboxes) Pause(ctx context.Context, id string, opts *RequestOptions) (*SandboxInfo, error)

Pause Pauses a sandbox with its memory and disk kept. A call to it resumes it.

func (*Sandboxes) ProcessOutput

func (c *Sandboxes) ProcessOutput(ctx context.Context, id string, process string, q SandboxProcessOutputQuery, opts *RequestOptions) (*ProcessOutput, error)

ProcessOutput Returns a process's output after a cursor, and the cursor to read on from. The latest 1 MiB is kept; truncated says when the cursor fell behind.

func (*Sandboxes) Read

func (c *Sandboxes) Read(ctx context.Context, id string, q SandboxReadQuery, opts *RequestOptions) ([]byte, error)

Read Returns a file's bytes.

func (*Sandboxes) Remove

func (c *Sandboxes) Remove(ctx context.Context, id string, in FileRemove, opts *RequestOptions) (*FileRemoved, error)

Remove Removes a file, a link or a directory (recursive for one with contents). One missing is success, removed false.

func (*Sandboxes) Rename

func (c *Sandboxes) Rename(ctx context.Context, id string, in FileRename, opts *RequestOptions) (*FileRenamed, error)

Rename Moves a file, a link or a directory; refused 409 when something is at its new path, unless overwrite. With sha256 or size, a file written in parts is put in place once whole: its writes ended, then only a file of that size with every byte written and whose bytes hash to it moves; refused 409 `upload_incomplete` or `checksum_mismatch`, nothing moved. With sha256, it is safe to send again: once moved, it returns the same answer while `from` is gone and `to` holds those bytes.

func (*Sandboxes) ResizeProcess

func (c *Sandboxes) ResizeProcess(ctx context.Context, id string, process string, in Terminal, opts *RequestOptions) (*Process, error)

ResizeProcess Resizes the terminal of a process started with a pty (its window's columns and rows, which the process is told by SIGWINCH), and returns the process; refused 409 for a process without one. A process that ended is left as it is, so a retry is safe.

func (*Sandboxes) Resume

func (c *Sandboxes) Resume(ctx context.Context, id string, opts *RequestOptions) (*SandboxInfo, error)

Resume Resumes a paused sandbox where it was, its memory and processes as they were.

func (c *Sandboxes) RevokeLinks(ctx context.Context, id string, opts *RequestOptions) (*FileLinksRevoked, error)

RevokeLinks Ends every file link made for a sandbox so far; links made after work.

func (*Sandboxes) RunCode

func (c *Sandboxes) RunCode(ctx context.Context, id string, in RunCode, opts *RequestOptions) (*CodeRun, error)

RunCode Runs a cell of Python in a sandbox as a notebook does, in a Jupyter kernel it keeps running for the cell's `context`: variables, imports and functions stay for the next cell. Returns what it printed, its values and displays (text, HTML, images such as charts), and its exception with its traceback. The context's kernel starts on its first cell. A cell past `timeoutSeconds` is interrupted and its context kept. Refused 409 `kernel_not_installed` when the image has no ipykernel. A paused sandbox is resumed first.

func (*Sandboxes) Screenshot

func (c *Sandboxes) Screenshot(ctx context.Context, id string, q SandboxScreenshotQuery, opts *RequestOptions) ([]byte, error)

Screenshot Returns what a sandbox's screen shows now, as `image/png` (or `image/jpeg`): its X display `:1`, whole. Refused 409 `display_not_running` when no display runs. A paused sandbox is resumed first.

func (*Sandboxes) SetNetwork

func (c *Sandboxes) SetNetwork(ctx context.Context, id string, in NetworkRules, opts *RequestOptions) (*SandboxNetwork, error)

SetNetwork Replaces where a sandbox may connect out, for its next connection and within a second for its open ones: those the new rules refuse are cut.

func (*Sandboxes) SignalProcess

func (c *Sandboxes) SignalProcess(ctx context.Context, id string, process string, in ProcessSignal, opts *RequestOptions) (*Process, error)

SignalProcess Sends a signal to a process and its group; a process that ended is not signalled, so a retry is safe.

func (*Sandboxes) Snapshot

func (c *Sandboxes) Snapshot(ctx context.Context, id string, in SnapshotRequest, opts *RequestOptions) (*Stored, error)

Snapshot Keeps a sandbox's memory and disk as they are now, a snapshot to start sandboxes from; with `image`, its disk alone as that image's next version. The sandbox runs on. Asked again with the same Idempotency-Key, it returns the same snapshot.

func (*Sandboxes) Stat

Stat Returns what is at a path: a file, a directory or a link, or nothing (exists false). With sha256=true, a file's SHA-256 too.

func (*Sandboxes) Update

func (c *Sandboxes) Update(ctx context.Context, id string, in MachineUpdate, opts *RequestOptions) (*SandboxInfo, error)

Update Changes its name, labels, idle pause, maxCost, autoWake, lifetime, delete protection, environment or sizes; each field left out stays as it is. A lifetime (`deleteAfterSeconds`) sent again before its end moves the end to that many seconds from now; 0 takes it off. A lifetime is refused (409 `delete_protected`) while `deleteProtection` is true. A running one holds a changed environment before this answers (a paused one's at its wake): each process it starts after the answer has it, and its running processes keep the one they started with. Its vCPUs, memory and disk grow while it runs, its commands running on. One paused or stopped is not woken for it: judged at once as a live resize is (past the vCPUs it was made with 409, over its organization's limits `quota_exceeded`), its new sizes are returned at once, and its next wake grows it to them before the call that woke it runs. A smaller size, or a machine starting or failed, is refused 409 naming why, and nothing is changed. With If-Match, made only while its revision is that one, else 412. Sent again with the same Idempotency-Key and body while it is the latest change, it returns the current state and changes nothing; the same key with a different body returns 409 idempotency_key_reused.

func (*Sandboxes) UploadFolder

func (c *Sandboxes) UploadFolder(ctx context.Context, id string, data []byte, q SandboxUploadFolderQuery, opts *RequestOptions) (*FolderUnpacked, error)

UploadFolder Unpacks the request's tar archive (gzip-compressed or not, told by its first bytes) into a folder, made with its parents, by tar in the sandbox as the bytes arrive, of any size, nothing of it kept on disk but what tar writes; returns once tar has ended, or 400 `invalid_archive` with what tar said. A paused sandbox is woken first.

func (*Sandboxes) Write

func (c *Sandboxes) Write(ctx context.Context, id string, data []byte, q SandboxWriteQuery, opts *RequestOptions) (*FileWritten, error)

Write Writes the request's bytes to a file as they come, of any size (Content-Length required), its folders made: the file whole when they all came, or as it was. With offset, they are written into it in place.

func (*Sandboxes) WriteFolderUpload

func (c *Sandboxes) WriteFolderUpload(ctx context.Context, id string, upload string, data []byte, q SandboxWriteFolderUploadQuery, opts *RequestOptions) (*FolderUploadReceived, error)

WriteFolderUpload Sends the request's bytes, a part of the archive at its offset, into tar's input as they arrive, of any size, and returns the bytes received in all once tar took them. A part past them is refused 409 `upload_incomplete`, naming them: send the parts in order.

func (*Sandboxes) WriteProcess

func (c *Sandboxes) WriteProcess(ctx context.Context, id string, process string, in ProcessInput, opts *RequestOptions) (*ProcessWritten, error)

WriteProcess Sends input to a process started with stdinOpen or a pty, and returns how much of its input it has taken.

type ScreenSize

type ScreenSize struct {
	// Width
	Width int64 `json:"width"`
	// Height
	Height int64 `json:"height"`
}

ScreenSize The screen's size, in pixels.

type Secret

type Secret struct {

	// Info is what it was when last read.
	Info *SecretInfo
	// contains filtered or unexported fields
}

Secret is one of secrets: A value a machine uses, sealed at rest and never answered. Hidden (the default): the machine sees a placeholder, and the egress proxy puts the value in its place, only on HTTPS to the secret's hosts. Visible: the machine holds the value, in its environment variable and in /run/secrets/<envName>.

func (*Secret) Delete

func (s *Secret) Delete(ctx context.Context, opts *RequestOptions) (*SecretInfo, error)

Delete Deletes a secret and its value: no request carries it from then on, open connections' included, and a visible secret's file is removed from every machine within a second. Deleted again, it returns the same deleted secret.

func (*Secret) Name

func (s *Secret) Name() string

Name is its name.

func (*Secret) Refresh

func (s *Secret) Refresh(ctx context.Context, q *SecretGetQuery, opts *RequestOptions) error

Refresh Returns a secret, without its value.

func (*Secret) Set

func (s *Secret) Set(ctx context.Context, in *SecretSet, opts *RequestOptions) error

Set Stores or replaces a secret with its value, or changes one without it. Replacing it keeps its placeholder and raises its version; machines' new requests carry the new value within a second, and a visible secret's file holds it within a second. A running machine's processes keep the environment they started with; new commands get the new one. Asked again with the same Idempotency-Key and body, it returns the secret as that request left it. A deleted secret's name stored again is a new secret with a new placeholder, and so is a visible secret stored hidden. Without its value, it changes only the hosts, rules (`policies.rules`) and scope it names and keeps every other setting: hosts and rules only narrow, refused 400 when wider, since widening needs the value; a visible secret's scope only narrows, since its machines hold its value, and its file is removed within a second from each machine the scope leaves out. A secret not stored yet needs its value (404).

type SecretApi

type SecretApi struct {
	// Graphql Its GraphQL mutations.
	Graphql *SecretGraphql `json:"graphql,omitempty"`
}

SecretApi What API calls carrying a secret may do.

type SecretGetQuery

type SecretGetQuery struct {
	// Wait Seconds to wait, at most 60, for its state to differ from `ifState`; it answers once it does, or as it is when the wait ends. At least 0. At most 60.
	Wait *float64
	// IfState The state the caller last read, which `wait` waits for it to leave.
	IfState *string
}

SecretGetQuery is what Get takes in its query.

type SecretGit

type SecretGit struct {
	// Push The branches a push may update: 1 to 16 patterns of 12 to 256 characters, `refs/heads/` then a branch name, `*` only at the end, and `{label.<key>}` for the machine's own label right below a fixed first segment (`refs/heads/task/{label.task}`). A tag, a delete or any other ref is refused, and so is every API write that moves a ref. Opening or editing a pull request, reviewing it, and commenting on a pull request or an issue go under any rule that allows the path. Any other API write goes only when a rule names its exact path, with no `*`. A secret with no rules makes no API write.
	Push []string `json:"push"`
}

SecretGit What a git push carrying a secret may update.

type SecretGraphql

type SecretGraphql struct {
	// Path The GraphQL endpoint's path; `/graphql` when omitted.
	Path *string `json:"path,omitempty"`
	// Mutations Only these mutations, by name (at most 64); a request making any other is refused.
	Mutations []string `json:"mutations"`
}

SecretGraphql The GraphQL mutations a request carrying a secret may make.

type SecretInfo

type SecretInfo struct {
	SecretSettings
	// Name Its name.
	Name string `json:"name"`
	// Object Always `secret`.
	Object string `json:"object"`
	// State `active` while requests carry it; `deleted` once deleted: a delete's answer.
	State string `json:"state"`
	// Placeholder What a machine holds in the value's place; none when visible.
	Placeholder *string `json:"placeholder,omitempty"`
	// Version Raised by each change.
	Version int64 `json:"version"`
	// ValueBytes Its value's length in bytes.
	ValueBytes *int64 `json:"valueBytes,omitempty"`
	// UpdatedAt When it was last changed.
	UpdatedAt *string `json:"updatedAt,omitempty"`
	// DeletedAt When it was deleted: a delete's answer, its state `deleted`.
	DeletedAt *string `json:"deletedAt,omitempty"`
}

SecretInfo A secret, without its value.

type SecretListQuery

type SecretListQuery struct {
	// Cursor Where the page starts: a page's `next`.
	Cursor *string
	// Limit The most items the page holds. At least 1. At most 200. Default: 50.
	Limit *int64
}

SecretListQuery is what List takes in its query.

type SecretPolicies

type SecretPolicies struct {
	// Rules Only requests one of these rules allows carry it; every request to its hosts when omitted. A set with its value and without rules removes them; one without its value keeps them, or narrows them to these.
	Rules []SecretRule `json:"rules,omitempty"`
	// Git Its git pushes' branches. Kept when a set leaves it out; only a set with the value changes it.
	Git *SecretGit `json:"git,omitempty"`
	// Api Its API calls' limits. Kept when a set leaves it out; only a set with the value changes it.
	Api *SecretApi `json:"api,omitempty"`
}

SecretPolicies How a secret may be used, beyond its hosts: a request carries it only when every policy it holds allows it.

type SecretRule

type SecretRule struct {
	// Methods Only these methods (`POST`); every method when omitted.
	Methods []string `json:"methods,omitempty"`
	// Paths Only these paths: exact (`/v1/chat/completions`), or a prefix ending in `/*`.
	Paths []string `json:"paths"`
}

SecretRule Which requests to a secret's hosts may carry it.

type SecretScope

type SecretScope struct {
	// LabelsAny Machines with every label of any one of these sets. Give this or `none`.
	LabelsAny []map[string]string `json:"labelsAny,omitempty"`
	// None `true`: no machine. Runtime alone uses the secret: it is in no machine's requests or environment. A registry login an image import pulls with (`pullSecret`) has this scope. Give this or `labelsAny`.
	None *bool `json:"none,omitempty"`
}

SecretScope Which machines may use a secret.

type SecretSet

type SecretSet struct {
	SecretSettings
	// Value Its value, never answered. Hidden: 1 to 8192 visible ASCII characters and spaces, one line, since it goes into an HTTP header. Visible: 1 byte to 64 KiB of UTF-8 text with no NUL, newlines included (a PEM file, an SSH key, a service account's JSON). With it, the set stores the secret whole, as its fields say. Without it, the set changes only the hosts, `policies.rules` and scope it names, and keeps the rest: hosts and rules only narrow, since widening needs the value, and so does a visible secret's scope, whose machines hold its value; any other field is refused 400.
	Value *string `json:"value,omitempty"`
	// ExpectedVersion Replaced only from this version; 409 otherwise.
	ExpectedVersion *int64 `json:"expectedVersion,omitempty"`
}

SecretSet A secret to store or replace, or, without its value, to change.

type SecretSettings

type SecretSettings struct {
	// Visible The machine holds the value itself, in its environment variable from its start and in the file `/run/secrets/<envName>` (mode 0400, owned by root), which is rewritten within a second of each change and removed within a second of a delete or a scope that leaves the machine out. For values the proxy cannot put in, such as a database password or an SSH key. Changed only by a set with the value; false when omitted.
	Visible *bool `json:"visible,omitempty"`
	// Hosts The hosts its value goes to on HTTPS: a name, or `*.` and a name for every name under it. Required unless visible; refused when visible.
	Hosts []string `json:"hosts,omitempty"`
	// Header The header it is set in on every request to its hosts; when omitted, its placeholder is replaced in the credential headers (Authorization, x-api-key and the like). Hidden secrets only.
	Header *string `json:"header,omitempty"`
	// Format The header's value, `{value}` replaced by the secret; `{value}` when omitted. Hidden secrets only.
	Format *string `json:"format,omitempty"`
	// EnvName The environment variable that holds its placeholder (or, when visible, its value) in each machine it reaches; its name when omitted. When two secrets that reach one machine name the same variable, it holds the one first by name.
	EnvName *string `json:"envName,omitempty"`
	// Scope The machines that may use it; every machine of the organization when omitted.
	Scope *SecretScope `json:"scope,omitempty"`
	// Policies How it may be used. Hidden secrets only.
	Policies *SecretPolicies `json:"policies,omitempty"`
}

SecretSettings A secret's settings: what it keeps beside its sealed value.

type Secrets

type Secrets struct {
	// contains filtered or unexported fields
}

Secrets A value a machine uses, sealed at rest and never answered. Hidden (the default): the machine sees a placeholder, and the egress proxy puts the value in its place, only on HTTPS to the secret's hosts. Visible: the machine holds the value, in its environment variable and in /run/secrets/<envName>.

func (*Secrets) Delete

func (c *Secrets) Delete(ctx context.Context, name string, opts *RequestOptions) (*SecretInfo, error)

Delete Deletes a secret and its value: no request carries it from then on, open connections' included, and a visible secret's file is removed from every machine within a second. Deleted again, it returns the same deleted secret.

func (*Secrets) Get

func (c *Secrets) Get(ctx context.Context, name string, q SecretGetQuery, opts *RequestOptions) (*Secret, error)

Get Returns a secret, without its value.

func (*Secrets) List

List Lists the organization's secrets by name, without their values.

func (*Secrets) ListAll

ListAll is every item of every page List reads from q.Cursor (none: the first page), each page read as the last is used up.

func (*Secrets) Set

func (c *Secrets) Set(ctx context.Context, name string, in SecretSet, opts *RequestOptions) (*SecretInfo, error)

Set Stores or replaces a secret with its value, or changes one without it. Replacing it keeps its placeholder and raises its version; machines' new requests carry the new value within a second, and a visible secret's file holds it within a second. A running machine's processes keep the environment they started with; new commands get the new one. Asked again with the same Idempotency-Key and body, it returns the secret as that request left it. A deleted secret's name stored again is a new secret with a new placeholder, and so is a visible secret stored hidden. Without its value, it changes only the hosts, rules (`policies.rules`) and scope it names and keeps every other setting: hosts and rules only narrow, refused 400 when wider, since widening needs the value; a visible secret's scope only narrows, since its machines hold its value, and its file is removed within a second from each machine the scope leaves out. A secret not stored yet needs its value (404).

type Session

type Session struct {
	// ID Its ID.
	ID string `json:"id"`
	// Object Always `session`.
	Object string `json:"object"`
	// MachineID The machine it reaches, alone.
	MachineID string `json:"machineId"`
	// Name Its name, as its maker gave it.
	Name string `json:"name"`
	// AccountID The person it acts as or for.
	AccountID *string `json:"accountId,omitempty"`
	// AgentID The agent or CI pipeline it acts as.
	AgentID *string `json:"agentId,omitempty"`
	// State `active` while it works; `deleted` once ended: a delete's answer.
	State string `json:"state"`
	// CreatedAt When it was made.
	CreatedAt string `json:"createdAt"`
	// ExpiresAt When it stops working: its own end, or the end of the key that made it, the sooner.
	ExpiresAt string `json:"expiresAt"`
	// DeletedAt When a delete ended it, or a revoke of the key that made it: a delete's answer, and a create's sent again once it ended. Omitted for one that ended at `expiresAt`.
	DeletedAt *string `json:"deletedAt,omitempty"`
}

Session A session: a token for one machine, for a frontend.

type SessionCreate

type SessionCreate struct {
	// MachineID The machine it reaches (a sandbox, an app, a desktop, any machine), by its ID.
	MachineID string `json:"machineId"`
	// ExpiresInSeconds Seconds until it stops working, 60 to 86400; 3600 when omitted. Never past the key that makes it. At least 60. At most 86400.
	ExpiresInSeconds *int64 `json:"expiresInSeconds,omitempty"`
	// Name Its name: your own handle for it, such as the user it is for. At least 1 character. At most 64 characters.
	Name *string `json:"name,omitempty"`
}

SessionCreate A session to make.

type SessionCreated

type SessionCreated struct {
	Session
	// Token The token, to send as `Authorization: Bearer <token>` from the frontend.
	Token string `json:"token"`
}

SessionCreated A session just made, with its token: shown this once, never again.

type SessionMessages

type SessionMessages struct {
	// Messages The messages, oldest first.
	Messages []Message `json:"messages"`
	// NextCursor The cursor to read on from: the last message's `seq`, or the one sent.
	NextCursor int64 `json:"nextCursor"`
	// State The conversation's state: `working`, `waiting`, `idle` or `ended`.
	State string `json:"state"`
	// WaitingOn What it waits on, while `waiting`: an ask's ID, or a tool's name.
	WaitingOn *string `json:"waitingOn,omitempty"`
	// Account The model account its turns use now, by secret name.
	Account *string `json:"account,omitempty"`
}

SessionMessages A session's messages after a cursor, and where its conversation is.

type Sessions

type Sessions struct {
	// contains filtered or unexported fields
}

Sessions A short-lived token a frontend holds to reach one machine directly: it reads the machine, runs its commands and processes, reads and writes its files, and signs its previews' links, and does nothing else. It acts as the key that made it and ends with that key.

func (*Sessions) Create

Create Makes a session for one machine the caller reaches and returns its token this once. The token reads the machine, runs its commands and processes, reads and writes its files and signs its previews' links, and nothing else; it acts as the caller, lives `expiresInSeconds` (an hour unless asked, a day at most), never past the caller's key, and ends when that key is revoked. The API answers CORS for its calls, so a web page can make them. Sent again with the same Idempotency-Key and body, it makes none and returns 409 `conflict` with the session it made in `details.made`, without its token; with another body, 409 `idempotency_key_reused`.

func (*Sessions) Delete

func (c *Sessions) Delete(ctx context.Context, id string, opts *RequestOptions) (*Session, error)

Delete Ends a session now: its next call is refused. Its maker ends its own; an owner or an admin, any of the organization's. Ended already, it returns 404.

type Site

type Site struct {

	// Info is what it was when last read.
	Info      *SandboxInfo
	Files     *SiteFiles
	Processes *SiteProcesses
	Network   *SiteNetwork
	// contains filtered or unexported fields
}

Site is one of sites: A machine that serves the static files in /site on port 8080 (as Netlify and Vercel serve a build's output), reached at its preview. It pauses after 60 seconds with nothing happening, its memory kept, and a visit resumes it.

func (*Site) Act

func (s *Site) Act(ctx context.Context, actions []Action, in *ActRequest, opts *RequestOptions) (*Acted, error)

Act Moves, clicks, drags and scrolls the mouse and types on the keyboard of a site's screen (its X display `:1`), each step in turn as one command, and returns where the mouse is then. It stops at the first step that fails, refused 409 `act_failed` naming it; refused 409 `display_not_running` when no display runs. A paused site is resumed first.

func (*Site) Delete

func (s *Site) Delete(ctx context.Context, opts *RequestOptions) (*SandboxInfo, error)

Delete Deletes a site, its memory and its disk.

func (*Site) Exec

func (s *Site) Exec(ctx context.Context, cmd string, in *ExecRequest, opts *RequestOptions) (*Process, error)

Exec Runs a command as a process and returns it once it ended, with its output; with wait false, at once, while it runs. A paused site is resumed first. Asked again with the same Idempotency-Key, it runs nothing more: it returns the first run's process, waiting for its end while it runs.

func (*Site) Fork

func (s *Site) Fork(ctx context.Context, in *ForkRequest, opts *RequestOptions) (*Forked, error)

Fork Copies a site as it is now, memory and disk, into `count` copies of its own, each running on its host. Asked again with the same Idempotency-Key, it returns the same copies.

func (*Site) ID

func (s *Site) ID() string

ID is its id.

func (*Site) Metrics

func (s *Site) Metrics(ctx context.Context, q *SiteMetricsQuery, opts *RequestOptions) (*SandboxMetrics, error)

Metrics Returns a site's CPU, memory, disks and pressure, as its host reads them from the site's own cgroup over a fifth of a second: never a call into the site, so it does not wake a paused one nor keep one from its idle pause. One that is not running has no reading.

func (*Site) Pause

func (s *Site) Pause(ctx context.Context, opts *RequestOptions) error

Pause Pauses a site with its memory and disk kept. A call to it resumes it.

func (*Site) Refresh

func (s *Site) Refresh(ctx context.Context, q *SiteGetQuery, opts *RequestOptions) error

Refresh Returns a site.

func (*Site) Resume

func (s *Site) Resume(ctx context.Context, opts *RequestOptions) error

Resume Resumes a paused site where it was, its memory and processes as they were.

func (*Site) RunCode

func (s *Site) RunCode(ctx context.Context, code string, in *RunCode, opts *RequestOptions) (*CodeRun, error)

RunCode Runs a cell of Python in a site as a notebook does, in a Jupyter kernel it keeps running for the cell's `context`: variables, imports and functions stay for the next cell. Returns what it printed, its values and displays (text, HTML, images such as charts), and its exception with its traceback. The context's kernel starts on its first cell. A cell past `timeoutSeconds` is interrupted and its context kept. Refused 409 `kernel_not_installed` when the image has no ipykernel. A paused site is resumed first.

func (*Site) Screenshot

func (s *Site) Screenshot(ctx context.Context, q *SiteScreenshotQuery, opts *RequestOptions) ([]byte, error)

Screenshot Returns what a site's screen shows now, as `image/png` (or `image/jpeg`): its X display `:1`, whole. Refused 409 `display_not_running` when no display runs. A paused site is resumed first.

func (*Site) Snapshot

func (s *Site) Snapshot(ctx context.Context, in *SnapshotRequest, opts *RequestOptions) (*Stored, error)

Snapshot Keeps a site's memory and disk as they are now, a snapshot to start sites from; with `image`, its disk alone as that image's next version. The site runs on. Asked again with the same Idempotency-Key, it returns the same snapshot.

func (*Site) Update

func (s *Site) Update(ctx context.Context, in *MachineUpdate, opts *RequestOptions) error

Update Changes its name, labels, idle pause, maxCost, autoWake, lifetime, delete protection, environment or sizes; each field left out stays as it is. A lifetime (`deleteAfterSeconds`) sent again before its end moves the end to that many seconds from now; 0 takes it off. A lifetime is refused (409 `delete_protected`) while `deleteProtection` is true. A running one holds a changed environment before this answers (a paused one's at its wake): each process it starts after the answer has it, and its running processes keep the one they started with. Its vCPUs, memory and disk grow while it runs, its commands running on. One paused or stopped is not woken for it: judged at once as a live resize is (past the vCPUs it was made with 409, over its organization's limits `quota_exceeded`), its new sizes are returned at once, and its next wake grows it to them before the call that woke it runs. A smaller size, or a machine starting or failed, is refused 409 naming why, and nothing is changed. With If-Match, made only while its revision is that one, else 412. Sent again with the same Idempotency-Key and body while it is the latest change, it returns the current state and changes nothing; the same key with a different body returns 409 idempotency_key_reused.

type SiteDownloadFolderQuery

type SiteDownloadFolderQuery struct {
	// Path The folder, absolute, such as `/workspace/app`.
	Path string
	// Gzip Compress the archive with gzip. Default: false.
	Gzip *bool
	// User Who packs it: `runtime` or `root`; the site's `user` when omitted.
	User *string
	// Exclude Paths in the folder to leave out, relative to it and comma-separated (`node_modules,.cache`): plain names, no wildcards, at most 32.
	Exclude *string
}

SiteDownloadFolderQuery is what DownloadFolder takes in its query.

type SiteFiles

type SiteFiles struct {
	// contains filtered or unexported fields
}

SiteFiles is a site's files.

func (*SiteFiles) AbortFolderUpload

func (g *SiteFiles) AbortFolderUpload(ctx context.Context, upload string, opts *RequestOptions) (*FolderUploadAborted, error)

AbortFolderUpload Stops a folder upload's tar; what it unpacked so far stays.

func (*SiteFiles) BeginFolderUpload

func (g *SiteFiles) BeginFolderUpload(ctx context.Context, path string, in *FolderUploadBegin, opts *RequestOptions) (*FolderUpload, error)

BeginFolderUpload Begins a folder's upload in parts: tar starts in the site, unpacking into the folder each part as it arrives. Send the parts in order by offset (writeFolderUpload), then commitFolderUpload; an upload no call names for 10 minutes is ended. A paused site is woken first.

func (*SiteFiles) CommitFolderUpload

func (g *SiteFiles) CommitFolderUpload(ctx context.Context, upload string, opts *RequestOptions) (*FolderUnpacked, error)

CommitFolderUpload Ends a folder upload's input and returns once tar has ended, as an exec returns once its command has: the folder, or 400 `invalid_archive` with what tar said. Sent again, it returns how tar ended. An upload no call has named for 10 minutes since its last part or commit is ended.

func (*SiteFiles) DownloadFolder

func (g *SiteFiles) DownloadFolder(ctx context.Context, path string, q *SiteDownloadFolderQuery, opts *RequestOptions) ([]byte, error)

DownloadFolder Returns a folder as a tar archive (`application/x-tar`, or `application/gzip` with gzip), packed by tar in the site as it streams, of any size; its entries are relative to the folder (`./a.txt`). A folder that fails part way (a file it may not read, or one that changes as it is read) ends as an archive every tar reader refuses, never as a short one that reads whole. At most 4 at once in a site. A paused site is woken first.

func (g *SiteFiles) Link(ctx context.Context, path string, in *FileLinkCreate, opts *RequestOptions) (*FileLink, error)

Link Makes an expiring address for one file that anyone may open with no API key, from a browser, curl or another service: GET downloads it (Range works, so videos play and downloads resume; archive: true downloads a folder as .tar.gz), PUT with the raw body uploads it (up to maxBytes, written whole; Content-Length required). The link acts as the key that made it: an upload link needs write, and the link ends with its key, with revokeLinks or with its site. A paused site is woken for it unless wake is false. A port it serves is shared by a preview (previews.create), not a link.

func (*SiteFiles) List

List Lists a directory's entries in path order, to a depth.

func (*SiteFiles) Mkdir

func (g *SiteFiles) Mkdir(ctx context.Context, path string, in *FileMkdir, opts *RequestOptions) (*FileMade, error)

Mkdir Makes a directory, and its parents unless parents is false. One there already is success, created false.

func (*SiteFiles) Read

func (g *SiteFiles) Read(ctx context.Context, path string, q *SiteReadQuery, opts *RequestOptions) ([]byte, error)

Read Returns a file's bytes.

func (*SiteFiles) Remove

func (g *SiteFiles) Remove(ctx context.Context, path string, in *FileRemove, opts *RequestOptions) (*FileRemoved, error)

Remove Removes a file, a link or a directory (recursive for one with contents). One missing is success, removed false.

func (*SiteFiles) Rename

func (g *SiteFiles) Rename(ctx context.Context, in *FileRename, opts *RequestOptions) (*FileRenamed, error)

Rename Moves a file, a link or a directory; refused 409 when something is at its new path, unless overwrite. With sha256 or size, a file written in parts is put in place once whole: its writes ended, then only a file of that size with every byte written and whose bytes hash to it moves; refused 409 `upload_incomplete` or `checksum_mismatch`, nothing moved. With sha256, it is safe to send again: once moved, it returns the same answer while `from` is gone and `to` holds those bytes.

func (g *SiteFiles) RevokeLinks(ctx context.Context, opts *RequestOptions) (*FileLinksRevoked, error)

RevokeLinks Ends every file link made for a site so far; links made after work.

func (*SiteFiles) Stat

func (g *SiteFiles) Stat(ctx context.Context, path string, q *SiteStatQuery, opts *RequestOptions) (*FileInfo, error)

Stat Returns what is at a path: a file, a directory or a link, or nothing (exists false). With sha256=true, a file's SHA-256 too.

func (*SiteFiles) UploadFolder

func (g *SiteFiles) UploadFolder(ctx context.Context, path string, data []byte, q *SiteUploadFolderQuery, opts *RequestOptions) (*FolderUnpacked, error)

UploadFolder Unpacks the request's tar archive (gzip-compressed or not, told by its first bytes) into a folder, made with its parents, by tar in the site as the bytes arrive, of any size, nothing of it kept on disk but what tar writes; returns once tar has ended, or 400 `invalid_archive` with what tar said. A paused site is woken first.

func (*SiteFiles) Write

func (g *SiteFiles) Write(ctx context.Context, path string, data []byte, q *SiteWriteQuery, opts *RequestOptions) (*FileWritten, error)

Write Writes the request's bytes to a file as they come, of any size (Content-Length required), its folders made: the file whole when they all came, or as it was. With offset, they are written into it in place.

func (*SiteFiles) WriteFolderUpload

func (g *SiteFiles) WriteFolderUpload(ctx context.Context, upload string, data []byte, q *SiteWriteFolderUploadQuery, opts *RequestOptions) (*FolderUploadReceived, error)

WriteFolderUpload Sends the request's bytes, a part of the archive at its offset, into tar's input as they arrive, of any size, and returns the bytes received in all once tar took them. A part past them is refused 409 `upload_incomplete`, naming them: send the parts in order.

type SiteGetQuery

type SiteGetQuery struct {
	// Wait Seconds to wait, at most 60, for its state to differ from `ifState`; it answers once it does, or as it is when the wait ends. At least 0. At most 60.
	Wait *float64
	// IfState The state the caller last read, which `wait` waits for it to leave.
	IfState *string
}

SiteGetQuery is what Get takes in its query.

type SiteListFilesQuery

type SiteListFilesQuery struct {
	// Path The directory. Default: "/workspace".
	Path *string
	// Depth How deep to list. At least 1. At most 10. Default: 1.
	Depth *int64
	// Limit At most this many entries. At least 1. At most 2000. Default: 2000.
	Limit *int64
	// Hidden List entries whose names start with a dot. Default: true.
	Hidden *bool
	// Glob Only entries whose path relative to the directory matches: `*` within a name, `**` across folders, `?` one character, `{a,b}` either (`**/*.py`); at most 512 characters, 32 wildcards and 64 texts in braces. The listing then reaches as deep as the glob does (10 folders for `**`) unless depth says, and is searched past its first 2,000 entries, up to 50,000. At most 512 characters.
	Glob *string
}

SiteListFilesQuery is what ListFiles takes in its query.

type SiteListQuery

type SiteListQuery struct {
	// State Only those in these states, comma-separated.
	State *string
	// Name Only the site of this name.
	Name *string
	// Label Only those with every label given (repeat it for several): key:value, or a key for any value.
	Label []string
	// Cursor Where the page starts: a page's `next`.
	Cursor *string
	// Limit The most items the page holds. At least 1. At most 200. Default: 50.
	Limit *int64
}

SiteListQuery is what List takes in its query.

type SiteMetricsQuery

type SiteMetricsQuery struct {
	// Range The window: `15m`, `1h`, `6h`, `24h`, `7d` or `30d`. Default: "1h".
	Range *string
}

SiteMetricsQuery is what Metrics takes in its query.

type SiteNetwork

type SiteNetwork struct {
	// contains filtered or unexported fields
}

SiteNetwork is a site's network.

func (*SiteNetwork) Get

Get Returns where a site may connect out.

func (*SiteNetwork) Set

Set Replaces where a site may connect out, for its next connection and within a second for its open ones: those the new rules refuse are cut.

type SiteProcessOutputQuery

type SiteProcessOutputQuery struct {
	// Cursor Output after this byte. At least 0. Default: 0.
	Cursor *int64
	// WaitSeconds Seconds to wait for output past the cursor or its exit, at most 8. At least 0. At most 8.
	WaitSeconds *float64
	// MaxBytes At most this many bytes. At least 4096. At most 196608. Default: 65536.
	MaxBytes *int64
	// Follow Answer as NDJSON events from the cursor until it exits (stdout, stderr, truncated, exit; continue with the cursor to follow on from), as `Accept: application/x-ndjson` does.
	Follow *bool
}

SiteProcessOutputQuery is what ProcessOutput takes in its query.

type SiteProcesses

type SiteProcesses struct {
	// contains filtered or unexported fields
}

SiteProcesses is a site's processes.

func (*SiteProcesses) List

func (g *SiteProcesses) List(ctx context.Context, opts *RequestOptions) (*ProcessList, error)

List Lists a site's processes, newest first: those running and those that ended lately.

func (*SiteProcesses) Output

Output Returns a process's output after a cursor, and the cursor to read on from. The latest 1 MiB is kept; truncated says when the cursor fell behind.

func (*SiteProcesses) Resize

func (g *SiteProcesses) Resize(ctx context.Context, process string, in *Terminal, opts *RequestOptions) (*Process, error)

Resize Resizes the terminal of a process started with a pty (its window's columns and rows, which the process is told by SIGWINCH), and returns the process; refused 409 for a process without one. A process that ended is left as it is, so a retry is safe.

func (*SiteProcesses) Signal

func (g *SiteProcesses) Signal(ctx context.Context, process string, in *ProcessSignal, opts *RequestOptions) (*Process, error)

Signal Sends a signal to a process and its group; a process that ended is not signalled, so a retry is safe.

func (*SiteProcesses) Write

func (g *SiteProcesses) Write(ctx context.Context, process string, in *ProcessInput, opts *RequestOptions) (*ProcessWritten, error)

Write Sends input to a process started with stdinOpen or a pty, and returns how much of its input it has taken.

type SiteReadQuery

type SiteReadQuery struct {
	// Path The file's path in the machine.
	Path string
}

SiteReadQuery is what Read takes in its query.

type SiteScreenshotQuery

type SiteScreenshotQuery struct {
	// Format `png`, or `jpeg`: smaller and quicker to send, for a model that reads it. Default: "png".
	Format *string
	// Quality A jpeg's quality, 1 to 100. At least 1. At most 100. Default: 80.
	Quality *int64
}

SiteScreenshotQuery is what Screenshot takes in its query.

type SiteStatQuery

type SiteStatQuery struct {
	// Path The file's path in the machine.
	Path string
	// Sha256 Also return a file's SHA-256, read from its bytes: to check a file you put in place (files:rename with sha256) is whole. Default: false.
	Sha256 *bool
}

SiteStatQuery is what Stat takes in its query.

type SiteUploadFolderQuery

type SiteUploadFolderQuery struct {
	// Path The folder, absolute, such as `/workspace/app`: made with its parents.
	Path string
	// User Who unpacks it: `runtime` or `root`; the site's `user` when omitted.
	User *string
}

SiteUploadFolderQuery is what UploadFolder takes in its query.

type SiteWriteFolderUploadQuery

type SiteWriteFolderUploadQuery struct {
	// Offset Where the part starts in the archive: at most the bytes received so far. Bytes before them were taken already and are skipped, so a part sent again is never unpacked twice. At least 0. Default: 0.
	Offset *int64
}

SiteWriteFolderUploadQuery is what WriteFolderUpload takes in its query.

type SiteWriteQuery

type SiteWriteQuery struct {
	// Path The file's path in the machine.
	Path string
	// Mode Its mode, in octal (`644`).
	Mode *string
	// Offset Write the bytes into the file in place from this byte, keeping the bytes before and after them (the file is made when there is none); one that fails part way may leave its range written in part, so send it again. Parts of one file may be written so at once and in any order: write them to a new path, then rename it with its size and sha256 to put it in place whole. At least 0.
	Offset *int64
	// Sha256 The bytes' SHA-256 in hex: refused 409 `checksum_mismatch`, the file as it was, when they differ. Not with offset.
	Sha256 *string
}

SiteWriteQuery is what Write takes in its query.

type Sites

type Sites struct {
	// contains filtered or unexported fields
}

Sites A machine that serves the static files in /site on port 8080 (as Netlify and Vercel serve a build's output), reached at its preview. It pauses after 60 seconds with nothing happening, its memory kept, and a visit resumes it.

func (*Sites) AbortFolderUpload

func (c *Sites) AbortFolderUpload(ctx context.Context, id string, upload string, opts *RequestOptions) (*FolderUploadAborted, error)

AbortFolderUpload Stops a folder upload's tar; what it unpacked so far stays.

func (*Sites) Act

func (c *Sites) Act(ctx context.Context, id string, in ActRequest, opts *RequestOptions) (*Acted, error)

Act Moves, clicks, drags and scrolls the mouse and types on the keyboard of a site's screen (its X display `:1`), each step in turn as one command, and returns where the mouse is then. It stops at the first step that fails, refused 409 `act_failed` naming it; refused 409 `display_not_running` when no display runs. A paused site is resumed first.

func (*Sites) BeginFolderUpload

func (c *Sites) BeginFolderUpload(ctx context.Context, id string, in FolderUploadBegin, opts *RequestOptions) (*FolderUpload, error)

BeginFolderUpload Begins a folder's upload in parts: tar starts in the site, unpacking into the folder each part as it arrives. Send the parts in order by offset (writeFolderUpload), then commitFolderUpload; an upload no call names for 10 minutes is ended. A paused site is woken first.

func (*Sites) CommitFolderUpload

func (c *Sites) CommitFolderUpload(ctx context.Context, id string, upload string, opts *RequestOptions) (*FolderUnpacked, error)

CommitFolderUpload Ends a folder upload's input and returns once tar has ended, as an exec returns once its command has: the folder, or 400 `invalid_archive` with what tar said. Sent again, it returns how tar ended. An upload no call has named for 10 minutes since its last part or commit is ended.

func (*Sites) Create

func (c *Sites) Create(ctx context.Context, in SandboxCreate, opts *RequestOptions) (*Site, error)

Create Creates a site. Asked again with the same Idempotency-Key, it returns the same site.

func (*Sites) Delete

func (c *Sites) Delete(ctx context.Context, id string, opts *RequestOptions) (*SandboxInfo, error)

Delete Deletes a site, its memory and its disk.

func (*Sites) DownloadFolder

func (c *Sites) DownloadFolder(ctx context.Context, id string, q SiteDownloadFolderQuery, opts *RequestOptions) ([]byte, error)

DownloadFolder Returns a folder as a tar archive (`application/x-tar`, or `application/gzip` with gzip), packed by tar in the site as it streams, of any size; its entries are relative to the folder (`./a.txt`). A folder that fails part way (a file it may not read, or one that changes as it is read) ends as an archive every tar reader refuses, never as a short one that reads whole. At most 4 at once in a site. A paused site is woken first.

func (*Sites) Exec

func (c *Sites) Exec(ctx context.Context, id string, in ExecRequest, opts *RequestOptions) (*Process, error)

Exec Runs a command as a process and returns it once it ended, with its output; with wait false, at once, while it runs. A paused site is resumed first. Asked again with the same Idempotency-Key, it runs nothing more: it returns the first run's process, waiting for its end while it runs.

func (*Sites) Fork

func (c *Sites) Fork(ctx context.Context, id string, in ForkRequest, opts *RequestOptions) (*Forked, error)

Fork Copies a site as it is now, memory and disk, into `count` copies of its own, each running on its host. Asked again with the same Idempotency-Key, it returns the same copies.

func (*Sites) Get

func (c *Sites) Get(ctx context.Context, id string, q SiteGetQuery, opts *RequestOptions) (*Site, error)

Get Returns a site.

func (*Sites) GetNetwork

func (c *Sites) GetNetwork(ctx context.Context, id string, opts *RequestOptions) (*SandboxNetwork, error)

GetNetwork Returns where a site may connect out.

func (c *Sites) Link(ctx context.Context, id string, in FileLinkCreate, opts *RequestOptions) (*FileLink, error)

Link Makes an expiring address for one file that anyone may open with no API key, from a browser, curl or another service: GET downloads it (Range works, so videos play and downloads resume; archive: true downloads a folder as .tar.gz), PUT with the raw body uploads it (up to maxBytes, written whole; Content-Length required). The link acts as the key that made it: an upload link needs write, and the link ends with its key, with revokeLinks or with its site. A paused site is woken for it unless wake is false. A port it serves is shared by a preview (previews.create), not a link.

func (*Sites) List

func (c *Sites) List(ctx context.Context, q SiteListQuery, opts *RequestOptions) (*Page[SandboxInfo], error)

List Lists the project's sites, newest first.

func (*Sites) ListAll

ListAll is every item of every page List reads from q.Cursor (none: the first page), each page read as the last is used up.

func (*Sites) ListFiles

func (c *Sites) ListFiles(ctx context.Context, id string, q SiteListFilesQuery, opts *RequestOptions) (*FileList, error)

ListFiles Lists a directory's entries in path order, to a depth.

func (*Sites) ListProcesses

func (c *Sites) ListProcesses(ctx context.Context, id string, opts *RequestOptions) (*ProcessList, error)

ListProcesses Lists a site's processes, newest first: those running and those that ended lately.

func (*Sites) Metrics

func (c *Sites) Metrics(ctx context.Context, id string, q SiteMetricsQuery, opts *RequestOptions) (*SandboxMetrics, error)

Metrics Returns a site's CPU, memory, disks and pressure, as its host reads them from the site's own cgroup over a fifth of a second: never a call into the site, so it does not wake a paused one nor keep one from its idle pause. One that is not running has no reading.

func (*Sites) Mkdir

func (c *Sites) Mkdir(ctx context.Context, id string, in FileMkdir, opts *RequestOptions) (*FileMade, error)

Mkdir Makes a directory, and its parents unless parents is false. One there already is success, created false.

func (*Sites) Pause

func (c *Sites) Pause(ctx context.Context, id string, opts *RequestOptions) (*SandboxInfo, error)

Pause Pauses a site with its memory and disk kept. A call to it resumes it.

func (*Sites) ProcessOutput

func (c *Sites) ProcessOutput(ctx context.Context, id string, process string, q SiteProcessOutputQuery, opts *RequestOptions) (*ProcessOutput, error)

ProcessOutput Returns a process's output after a cursor, and the cursor to read on from. The latest 1 MiB is kept; truncated says when the cursor fell behind.

func (*Sites) Read

func (c *Sites) Read(ctx context.Context, id string, q SiteReadQuery, opts *RequestOptions) ([]byte, error)

Read Returns a file's bytes.

func (*Sites) Remove

func (c *Sites) Remove(ctx context.Context, id string, in FileRemove, opts *RequestOptions) (*FileRemoved, error)

Remove Removes a file, a link or a directory (recursive for one with contents). One missing is success, removed false.

func (*Sites) Rename

func (c *Sites) Rename(ctx context.Context, id string, in FileRename, opts *RequestOptions) (*FileRenamed, error)

Rename Moves a file, a link or a directory; refused 409 when something is at its new path, unless overwrite. With sha256 or size, a file written in parts is put in place once whole: its writes ended, then only a file of that size with every byte written and whose bytes hash to it moves; refused 409 `upload_incomplete` or `checksum_mismatch`, nothing moved. With sha256, it is safe to send again: once moved, it returns the same answer while `from` is gone and `to` holds those bytes.

func (*Sites) ResizeProcess

func (c *Sites) ResizeProcess(ctx context.Context, id string, process string, in Terminal, opts *RequestOptions) (*Process, error)

ResizeProcess Resizes the terminal of a process started with a pty (its window's columns and rows, which the process is told by SIGWINCH), and returns the process; refused 409 for a process without one. A process that ended is left as it is, so a retry is safe.

func (*Sites) Resume

func (c *Sites) Resume(ctx context.Context, id string, opts *RequestOptions) (*SandboxInfo, error)

Resume Resumes a paused site where it was, its memory and processes as they were.

func (c *Sites) RevokeLinks(ctx context.Context, id string, opts *RequestOptions) (*FileLinksRevoked, error)

RevokeLinks Ends every file link made for a site so far; links made after work.

func (*Sites) RunCode

func (c *Sites) RunCode(ctx context.Context, id string, in RunCode, opts *RequestOptions) (*CodeRun, error)

RunCode Runs a cell of Python in a site as a notebook does, in a Jupyter kernel it keeps running for the cell's `context`: variables, imports and functions stay for the next cell. Returns what it printed, its values and displays (text, HTML, images such as charts), and its exception with its traceback. The context's kernel starts on its first cell. A cell past `timeoutSeconds` is interrupted and its context kept. Refused 409 `kernel_not_installed` when the image has no ipykernel. A paused site is resumed first.

func (*Sites) Screenshot

func (c *Sites) Screenshot(ctx context.Context, id string, q SiteScreenshotQuery, opts *RequestOptions) ([]byte, error)

Screenshot Returns what a site's screen shows now, as `image/png` (or `image/jpeg`): its X display `:1`, whole. Refused 409 `display_not_running` when no display runs. A paused site is resumed first.

func (*Sites) SetNetwork

func (c *Sites) SetNetwork(ctx context.Context, id string, in NetworkRules, opts *RequestOptions) (*SandboxNetwork, error)

SetNetwork Replaces where a site may connect out, for its next connection and within a second for its open ones: those the new rules refuse are cut.

func (*Sites) SignalProcess

func (c *Sites) SignalProcess(ctx context.Context, id string, process string, in ProcessSignal, opts *RequestOptions) (*Process, error)

SignalProcess Sends a signal to a process and its group; a process that ended is not signalled, so a retry is safe.

func (*Sites) Snapshot

func (c *Sites) Snapshot(ctx context.Context, id string, in SnapshotRequest, opts *RequestOptions) (*Stored, error)

Snapshot Keeps a site's memory and disk as they are now, a snapshot to start sites from; with `image`, its disk alone as that image's next version. The site runs on. Asked again with the same Idempotency-Key, it returns the same snapshot.

func (*Sites) Stat

func (c *Sites) Stat(ctx context.Context, id string, q SiteStatQuery, opts *RequestOptions) (*FileInfo, error)

Stat Returns what is at a path: a file, a directory or a link, or nothing (exists false). With sha256=true, a file's SHA-256 too.

func (*Sites) Update

func (c *Sites) Update(ctx context.Context, id string, in MachineUpdate, opts *RequestOptions) (*SandboxInfo, error)

Update Changes its name, labels, idle pause, maxCost, autoWake, lifetime, delete protection, environment or sizes; each field left out stays as it is. A lifetime (`deleteAfterSeconds`) sent again before its end moves the end to that many seconds from now; 0 takes it off. A lifetime is refused (409 `delete_protected`) while `deleteProtection` is true. A running one holds a changed environment before this answers (a paused one's at its wake): each process it starts after the answer has it, and its running processes keep the one they started with. Its vCPUs, memory and disk grow while it runs, its commands running on. One paused or stopped is not woken for it: judged at once as a live resize is (past the vCPUs it was made with 409, over its organization's limits `quota_exceeded`), its new sizes are returned at once, and its next wake grows it to them before the call that woke it runs. A smaller size, or a machine starting or failed, is refused 409 naming why, and nothing is changed. With If-Match, made only while its revision is that one, else 412. Sent again with the same Idempotency-Key and body while it is the latest change, it returns the current state and changes nothing; the same key with a different body returns 409 idempotency_key_reused.

func (*Sites) UploadFolder

func (c *Sites) UploadFolder(ctx context.Context, id string, data []byte, q SiteUploadFolderQuery, opts *RequestOptions) (*FolderUnpacked, error)

UploadFolder Unpacks the request's tar archive (gzip-compressed or not, told by its first bytes) into a folder, made with its parents, by tar in the site as the bytes arrive, of any size, nothing of it kept on disk but what tar writes; returns once tar has ended, or 400 `invalid_archive` with what tar said. A paused site is woken first.

func (*Sites) Write

func (c *Sites) Write(ctx context.Context, id string, data []byte, q SiteWriteQuery, opts *RequestOptions) (*FileWritten, error)

Write Writes the request's bytes to a file as they come, of any size (Content-Length required), its folders made: the file whole when they all came, or as it was. With offset, they are written into it in place.

func (*Sites) WriteFolderUpload

func (c *Sites) WriteFolderUpload(ctx context.Context, id string, upload string, data []byte, q SiteWriteFolderUploadQuery, opts *RequestOptions) (*FolderUploadReceived, error)

WriteFolderUpload Sends the request's bytes, a part of the archive at its offset, into tar's input as they arrive, of any size, and returns the bytes received in all once tar took them. A part past them is refused 409 `upload_incomplete`, naming them: send the parts in order.

func (*Sites) WriteProcess

func (c *Sites) WriteProcess(ctx context.Context, id string, process string, in ProcessInput, opts *RequestOptions) (*ProcessWritten, error)

WriteProcess Sends input to a process started with stdinOpen or a pty, and returns how much of its input it has taken.

type Snapshot

type Snapshot struct {

	// Info is what it was when last read.
	Info *Stored
	// contains filtered or unexported fields
}

Snapshot is one of snapshots: A machine's memory and disk as they were, kept to start new machines from; or a volume's disk as it was, kept to restore as a new volume.

func (*Snapshot) Delete

func (s *Snapshot) Delete(ctx context.Context, opts *RequestOptions) (*Stored, error)

Delete Deletes a snapshot, its memory and its disk.

func (*Snapshot) ID

func (s *Snapshot) ID() string

ID is its id.

func (*Snapshot) Refresh

func (s *Snapshot) Refresh(ctx context.Context, q *SnapshotGetQuery, opts *RequestOptions) error

Refresh Returns a snapshot.

func (*Snapshot) Update

func (s *Snapshot) Update(ctx context.Context, in *StoredUpdate, opts *RequestOptions) error

Update Changes its lifetime (`deleteAfterSeconds`) or delete protection (`deleteProtection`). A lifetime sent again before its end moves the end to that many seconds from now; 0 takes it off. At its end Runtime deletes it as its delete does: final, and it can't be undone. A lifetime and protection are never set together (409 `delete_protected`). Each field left out stays as it is.

type SnapshotGetQuery

type SnapshotGetQuery struct {
	// Wait Seconds to wait, at most 60, for its state to differ from `ifState`; it answers once it does, or as it is when the wait ends. At least 0. At most 60.
	Wait *float64
	// IfState The state the caller last read, which `wait` waits for it to leave.
	IfState *string
}

SnapshotGetQuery is what Get takes in its query.

type SnapshotListQuery

type SnapshotListQuery struct {
	// Name Only those of this name.
	Name *string
	// State Only those in these states, comma-separated.
	State *string
	// Label Only those with every label given (repeat it for several): key:value, or a key for any value.
	Label []string
	// Sandbox Only those taken of this machine, by its ID; a deleted one's snapshots too.
	Sandbox *string
	// Volume Only those taken of this volume, by its ID; a deleted one's snapshots too.
	Volume *string
	// Cursor Where the page starts: a page's `next`.
	Cursor *string
	// Limit The most items the page holds. At least 1. At most 200. Default: 50.
	Limit *int64
}

SnapshotListQuery is what List takes in its query.

type SnapshotRequest

type SnapshotRequest struct {
	// Name Its name, unique among the project's snapshots.
	Name *string `json:"name,omitempty"`
	// Labels Labels to find it by.
	Labels map[string]string `json:"labels,omitempty"`
	// Image Keeps its disk alone, synced, as the next version of the image of this name (`name:1`, `name:2`, ...) in place of a snapshot: an image machines are created from, each booting fresh over a disk of its own. Its memory is not kept; name is ignored.
	Image *string `json:"image,omitempty"`
	// Start With image: the command each machine created from the image starts at every fresh boot; the machine's own when omitted.
	Start *MachineStart `json:"start,omitempty"`
	// DeleteAfterSeconds Seconds until Runtime deletes the snapshot (or, with image, that image version), as its delete does: final, and it can't be undone. 0 or omitted: kept until deleted. At least 0. At most 315360000.
	DeleteAfterSeconds *int64 `json:"deleteAfterSeconds,omitempty"`
	// DeleteProtection Whether the snapshot's (or, with image, that image version's) delete is refused (409 `delete_protected`) until an update turns this off; false when omitted. Not with `deleteAfterSeconds`.
	DeleteProtection *bool `json:"deleteProtection,omitempty"`
}

SnapshotRequest A snapshot of a machine to take.

type SnapshotSchedule added in v2.2.0

type SnapshotSchedule struct {
	// EverySeconds Seconds between its snapshots, 3600 (an hour) to 31536000 (a year); 0 in an update turns the schedule off. The first is this long after it is set. At least 0. At most 31536000.
	EverySeconds int64 `json:"everySeconds"`
	// Keep How many of its newest scheduled snapshots are kept, 1 to 365. At least 1. At most 365.
	Keep int64 `json:"keep"`
}

SnapshotSchedule A volume's snapshots on a timer: one every `everySeconds`, each as `:snapshot` makes one, the newest `keep` of them kept and the oldest past that deleted as its delete does. Snapshots made otherwise are never counted or deleted.

type Snapshots

type Snapshots struct {
	// contains filtered or unexported fields
}

Snapshots A machine's memory and disk as they were, kept to start new machines from; or a volume's disk as it was, kept to restore as a new volume.

func (*Snapshots) Delete

func (c *Snapshots) Delete(ctx context.Context, id string, opts *RequestOptions) (*Stored, error)

Delete Deletes a snapshot, its memory and its disk.

func (*Snapshots) Get

Get Returns a snapshot.

func (*Snapshots) List

List Lists the project's snapshots, newest first.

func (*Snapshots) ListAll

ListAll is every item of every page List reads from q.Cursor (none: the first page), each page read as the last is used up.

func (*Snapshots) Update

func (c *Snapshots) Update(ctx context.Context, id string, in StoredUpdate, opts *RequestOptions) (*Stored, error)

Update Changes its lifetime (`deleteAfterSeconds`) or delete protection (`deleteProtection`). A lifetime sent again before its end moves the end to that many seconds from now; 0 takes it off. At its end Runtime deletes it as its delete does: final, and it can't be undone. A lifetime and protection are never set together (409 `delete_protected`). Each field left out stays as it is.

type Stored

type Stored struct {
	// ID Its ID.
	ID string `json:"id"`
	// Object Its kind: `snapshot`, `image` or `volume`.
	Object string `json:"object"`
	// Name Its name, unique in its project among its kind.
	Name *string `json:"name,omitempty"`
	// State Where it is.
	State string `json:"state"`
	// Labels Its labels.
	Labels map[string]string `json:"labels"`
	// SizeBytes What it was made to hold, in bytes.
	SizeBytes int64 `json:"sizeBytes"`
	// StoredBytes What it holds now, in bytes.
	StoredBytes int64 `json:"storedBytes"`
	// ParentID What it was made from (a snapshot's machine, an image's base), if anything.
	ParentID *string `json:"parentId,omitempty"`
	// AttachedTo The machine it is attached to now, if any.
	AttachedTo *string `json:"attachedTo,omitempty"`
	// CreatedAt When it was made.
	CreatedAt *string `json:"createdAt,omitempty"`
	// Version An image's version of its name: each build or keep of a name is its next.
	Version *int64 `json:"version,omitempty"`
	// Tags An image's tags, each `name:tag`.
	Tags []string `json:"tags,omitempty"`
	// Error Why an image's build failed.
	Error *string `json:"error,omitempty"`
	// DeletedAt When it was deleted: a delete's answer, its state `deleted`.
	DeletedAt *string `json:"deletedAt,omitempty"`
	// DeleteAt When Runtime deletes it (`deleteAfterSeconds`), finally: it can't be undone, as its delete can't; none: kept until deleted.
	DeleteAt *string `json:"deleteAt,omitempty"`
	// DeleteWaitsFor Once `deleteAt` has passed, what its delete waits for: the App that boots this image, or the machine this volume is attached to, by its ID. It is deleted as soon as that one no longer does.
	DeleteWaitsFor *string `json:"deleteWaitsFor,omitempty"`
	// DeleteProtection Whether its delete is refused (409 `delete_protected`) until an update turns this off.
	DeleteProtection *bool `json:"deleteProtection,omitempty"`
	// SnapshotSchedule A volume's snapshot schedule; none: off.
	SnapshotSchedule *SnapshotSchedule `json:"snapshotSchedule,omitempty"`
}

Stored Stored data: a snapshot, an image or a volume.

type StoredUpdate

type StoredUpdate struct {
	// DeleteAfterSeconds Seconds from now until Runtime deletes it, as its delete does: final, and it can't be undone. Sent again before then, it renews it; 0 takes its end off (kept until deleted). At least 0. At most 315360000.
	DeleteAfterSeconds *int64 `json:"deleteAfterSeconds,omitempty"`
	// DeleteProtection true refuses its delete (409 `delete_protected`) until an update sends false. Not while it has a `deleteAt`, unless the same update sends `deleteAfterSeconds` 0.
	DeleteProtection *bool `json:"deleteProtection,omitempty"`
}

StoredUpdate A change to a snapshot, an image version or a volume: each field left out stays as it is.

type Stream

type Stream[C any, P any] struct {
	// contains filtered or unexported fields
}

Stream is a stream (the spec's streams): what a started thing writes, read on from a cursor as it is written. Next returns each chunk, io.EOF at its end; Wait reads it to its end and returns the thing as it ended.

func (*Stream[C, P]) Next

func (s *Stream[C, P]) Next(ctx context.Context) (*C, error)

Next is the next chunk, or io.EOF once the thing has ended and all it wrote is read.

func (*Stream[C, P]) Started

func (s *Stream[C, P]) Started(ctx context.Context) (*P, error)

Started is the thing as it started (a process: its ID).

func (*Stream[C, P]) Wait

func (s *Stream[C, P]) Wait(ctx context.Context) (*P, error)

Wait reads it to its end and returns the thing as it ended (a process: its exit code).

type Terminal

type Terminal struct {
	// Cols Its columns. At least 1. At most 65535.
	Cols int64 `json:"cols"`
	// Rows Its rows. At least 1. At most 65535.
	Rows int64 `json:"rows"`
}

Terminal A terminal's size.

type Transport

type Transport struct {
	// contains filtered or unexported fields
}

Transport is HTTP, retries and errors, shared by every product's client.

func NewTransport

func NewTransport(o Options) *Transport

NewTransport makes a Transport.

func (*Transport) Do

func (t *Transport) Do(ctx context.Context, method, path string, query url.Values, body any, call Call, opts *RequestOptions, out any) error

Do sends one request and decodes its answer into out.

type Tunnel

type Tunnel struct {
	TunnelSettings
	// ID Its ID.
	ID string `json:"id"`
	// Object Always `tunnel`.
	Object string `json:"object"`
	// State Its state: `ready` once its gateway answers.
	State string `json:"state"`
	// Disabled Turned off: no traffic passes.
	Disabled bool `json:"disabled"`
	// CreatedAt When it was made.
	CreatedAt string `json:"createdAt"`
}

Tunnel A WireGuard tunnel from the org's own network into its machines.

type TunnelListQuery

type TunnelListQuery struct {
	// Cursor Where the page starts: a page's `next`.
	Cursor *string
	// Limit The most items the page holds. At least 1. At most 200. Default: 50.
	Limit *int64
}

TunnelListQuery is what List takes in its query.

type TunnelMember

type TunnelMember struct {
	// SandboxID The machine.
	SandboxID string `json:"sandboxId"`
	// Address Its address in the subnet.
	Address string `json:"address"`
}

TunnelMember A machine's address in a tunnel's subnet.

type TunnelPeer

type TunnelPeer struct {
	// ID Its ID.
	ID string `json:"id"`
	// Name Its name, unique in the tunnel.
	Name string `json:"name"`
	// PublicKey Its WireGuard public key.
	PublicKey string `json:"publicKey"`
	// Address Its address in the tunnel's subnet.
	Address string `json:"address"`
	// Routes The org's own ranges behind it that machines may reach.
	Routes []string `json:"routes"`
	// CreatedAt When it was added.
	CreatedAt string `json:"createdAt"`
	// RotatedAt When its key was last replaced.
	RotatedAt *string `json:"rotatedAt,omitempty"`
}

TunnelPeer One of the org's own machines or routers on a tunnel.

type TunnelSettings

type TunnelSettings struct {
	// Subnet Its private IPv4 range, /16 to /24.
	Subnet string `json:"subnet"`
	// GatewayAddress The gateway's address in the subnet.
	GatewayAddress string `json:"gatewayAddress"`
	// Endpoint Where peers send WireGuard: address:port.
	Endpoint string `json:"endpoint"`
	// GatewayPublicKey The gateway's WireGuard public key; none until the gateway has made its pair.
	GatewayPublicKey *string `json:"gatewayPublicKey,omitempty"`
	// Rate Its monthly price when it was made, in US dollars (`"5.00"`); it does not change.
	Rate string `json:"rate"`
	// Peers The org's machines and routers on it.
	Peers []TunnelPeer `json:"peers"`
	// Members Each machine's address in the subnet.
	Members []TunnelMember `json:"members"`
}

TunnelSettings A WireGuard tunnel's settings, as it keeps them; its gateway's private key is kept sealed and never answered.

type Tunnels

type Tunnels struct {
	// contains filtered or unexported fields
}

Tunnels A WireGuard tunnel from your own network into your machines.

func (*Tunnels) List

func (c *Tunnels) List(ctx context.Context, q TunnelListQuery, opts *RequestOptions) (*Page[Tunnel], error)

List Lists the org's WireGuard tunnels.

func (*Tunnels) ListAll

ListAll is every item of every page List reads from q.Cursor (none: the first page), each page read as the last is used up.

type Usage

type Usage struct {
	// OrgID The organization.
	OrgID string `json:"orgId"`
	// PeriodStart The month's first moment (UTC).
	PeriodStart string `json:"periodStart"`
	// Credited Every credit ever added, in US dollars.
	Credited string `json:"credited"`
	// Spent Every charge ever settled, in US dollars.
	Spent string `json:"spent"`
	// Available What can still be spent: credited less spent, in US dollars.
	Available string `json:"available"`
	// PeriodSpent Charged this month, in US dollars.
	PeriodSpent string `json:"periodSpent"`
	// Meters This month's use and charges by meter.
	Meters []MeterUse `json:"meters"`
	// Plan Its plan on the price card.
	Plan string `json:"plan"`
	// Limits Every limit it is held to, with what it uses of each now: the figures a create past one is refused by.
	Limits []Limit `json:"limits"`
	// SpendCap The org's own cap on a month's charges, in US dollars.
	SpendCap *string `json:"spendCap,omitempty"`
	// Key One key's spend, when the call names it (`key`).
	Key *KeyUsage `json:"key,omitempty"`
	// KeySpendCap The spend cap this key's creates are held to: the tightest of its own, those of the keys it was made with, and its holder's grants'. Omitted when none holds it.
	KeySpendCap *KeySpendCap `json:"keySpendCap,omitempty"`
	// Hours With `by=hour`: what each product used each hour, since the month began or 7 days ago, whichever is earlier (or since `since`, if later), oldest first. Only hours that cost something; with `meter`, only hours that used it.
	Hours []UsageHour `json:"hours,omitempty"`
	// Lines With `by=hour`: what each product's month is made of, a line for each meter it used, its quantity at the card's rate. A product's lines sum to its hours since the month began (or since `since`, if later).
	Lines []ProductLine `json:"lines,omitempty"`
	// Keys With `by=key`: what each key's machines and storage used this month, most first. A key the caller may not see is counted under `others`.
	Keys []KeySpend `json:"keys,omitempty"`
}

Usage What the org has used and has left, at the card's prices.

type UsageClient

type UsageClient struct {
	// contains filtered or unexported fields
}

UsageClient What the organization has used and has left at the price card's rates, and every limit it is held to.

func (*UsageClient) Export

Export Returns the organization's measured usage in a time range, of every resource or only those named: each meter of each machine's, disk's or address's hour, what it used and its price at the card, oldest first, paginated. Each line settles at its hour's end and is final once finalThrough reaches it, so closed hours can be read while resources run.

func (*UsageClient) Get

Get Returns the organization's credit and charges (everything credited and spent, what is left, and this month's use and charges by meter), its plan, and every limit it is held to with what it uses of each now; with key, that key's spend.

type UsageExport

type UsageExport struct {
	// Since The range's first moment, inclusive (UTC).
	Since string `json:"since"`
	// Until The range's end, exclusive (UTC).
	Until string `json:"until"`
	// FinalThrough Every line whose `settledAt` is at or before this moment is final: all usage before it has been measured. It never moves back; a later hour stays open until its usage is measured. None: no line is final yet.
	FinalThrough *string `json:"finalThrough,omitempty"`
	// Items Each meter of each resource's hour.
	Items []UsageLine `json:"items"`
	// Next Pass as cursor, with the same range, for the next page; none on the last.
	Next *string `json:"next,omitempty"`
	// Cursor The cursor this page was asked from; none on the first page.
	Cursor *string `json:"cursor,omitempty"`
}

UsageExport The organization's measured usage in a time range, oldest hour first.

type UsageExportQuery

type UsageExportQuery struct {
	// Since The range's first moment, inclusive (UTC, RFC 3339).
	Since string
	// Until The range's end, exclusive (UTC, RFC 3339).
	Until string
	// By What the range selects lines by: `hour`, each line's hour's start, or `settled`, its settledAt (its hour's end), of hours that have ended. Ranges by `settled`, each from the last one's end to no later than `finalThrough`, read every line once, final. Default: "hour".
	By *string
	// ResourceID Only the usage of these resources (repeat it for several, up to 100): each line's `resourceId`, such as a machine's ID.
	ResourceID []string
	// Cursor Where the page starts: a page's `next`.
	Cursor *string
	// Limit At most this many machine-hours. At least 1. At most 500. Default: 100.
	Limit *int64
}

UsageExportQuery is what Export takes in its query.

type UsageGetQuery

type UsageGetQuery struct {
	// Key One key's spend too, by its ID: a key the caller may see (its own holder's, or any for an owner or admin); any other is 404.
	Key *string
	// By Splits too (repeat it for both): `hour`, what each product used each hour (`hours`); `key`, what each key used this month (`keys`).
	By []string
	// Meter With `by=hour`, only this meter's use (`traffic-out`, `cpu`, ...): each hour by what used it, with its `quantity`.
	Meter *string
	// Since With `by=hour`, only the hours from this one on (UTC, RFC 3339), never before the month began or 7 days ago, whichever is earlier.
	Since *string
}

UsageGetQuery is what Get takes in its query.

type UsageHour

type UsageHour struct {
	// At The hour's first moment (UTC).
	At string `json:"at"`
	// Product What it was used by: the machine's kind (`sandbox`, `app`, `function`, `ci`, ...), what is kept on disk (`disk`, `volume`, `snapshot`, `image`), or `traffic`, what was sent out; `machine` or `storage` when what used it was deleted too long ago to name. With `meter`, never `traffic`: what sent it out.
	Product string `json:"product"`
	// Charged What it costs on the price card, before any credit, in US dollars.
	Charged string `json:"charged"`
	// Quantity With `meter`: what it used of that meter in the hour, in the meter's base unit, as an integer in text.
	Quantity *string `json:"quantity,omitempty"`
}

UsageHour One product's use in one hour, at the card's prices.

type UsageLine

type UsageLine struct {
	// ID The line's ID: the same line has the same ID on every read.
	ID string `json:"id"`
	// SubjectID The resource it was used by: a machine, a disk or an address.
	SubjectID string `json:"subjectId"`
	// ResourceID The ID its product names it by (a machine's own ID).
	ResourceID string `json:"resourceId"`
	// ProjectID Its project.
	ProjectID string `json:"projectId"`
	// Meter The card's meter (`cpu`, `memory`, `standard`, `traffic-out`, ...).
	Meter string `json:"meter"`
	// StartsAt The hour's first moment (UTC).
	StartsAt string `json:"startsAt"`
	// EndsAt The hour's end.
	EndsAt string `json:"endsAt"`
	// Quantity What was used, in the meter's base unit, as an integer in text.
	Quantity string `json:"quantity"`
	// Unit The base unit: `core-microseconds`, `vcpu-microseconds`, `byte-seconds`, `bytes`, `calls` or `seconds`.
	Unit string `json:"unit"`
	// ChargedMicros The hour alone at the card's rate, rounded down, in integer microdollars as text.
	ChargedMicros string `json:"chargedMicros"`
	// RateMicros The card's rate, in microdollars per priced unit, as an integer in text.
	RateMicros string `json:"rateMicros"`
	// SettledAt When the line settles: its hour's end (UTC). A line can change only until the page's `finalThrough` reaches it.
	SettledAt string `json:"settledAt"`
	// Final Whether the line is final: its `settledAt` is at or before the page's `finalThrough`, and it never changes again.
	Final bool `json:"final"`
	// ResourceFinal Whether its resource is deleted and every line it will ever have is final.
	ResourceFinal bool `json:"resourceFinal"`
}

UsageLine One meter of one machine's, disk's or address's hour, as measured, at the card's price.

type Volume

type Volume struct {

	// Info is what it was when last read.
	Info *Stored
	// contains filtered or unexported fields
}

Volume is one of volumes: A disk that outlives the machines it is attached to.

func (*Volume) Delete

func (s *Volume) Delete(ctx context.Context, opts *RequestOptions) (*Stored, error)

Delete Deletes a volume and what it holds. One attached to a machine is refused: delete the machine first. Its snapshots are kept until each is deleted.

func (*Volume) ID

func (s *Volume) ID() string

ID is its id.

func (*Volume) Refresh

func (s *Volume) Refresh(ctx context.Context, q *VolumeGetQuery, opts *RequestOptions) error

Refresh Returns a volume.

func (*Volume) Snapshot added in v2.2.0

func (s *Volume) Snapshot(ctx context.Context, opts *RequestOptions) error

Snapshot Keeps the volume's disk as it is now, a snapshot to restore as a new volume (`from`); one attached to a running machine is taken as it runs, consistent as after a power cut. It returns the snapshot at once, `making` until its copy is off-site, then `ready`. One never attached holds nothing to keep (409). Asked again with the same Idempotency-Key, it returns the same snapshot.

func (*Volume) Update

func (s *Volume) Update(ctx context.Context, in *VolumeUpdate, opts *RequestOptions) error

Update Changes its lifetime (`deleteAfterSeconds`), delete protection (`deleteProtection`) or snapshot schedule (`snapshotSchedule`). A lifetime sent again before its end moves the end to that many seconds from now; 0 takes it off. At its end Runtime deletes it as its delete does: final, and it can't be undone. A lifetime and protection are never set together (409 `delete_protected`). A schedule sent replaces the one it has, its first snapshot `everySeconds` from now; `everySeconds` 0 turns it off, and the snapshots it made are kept. Each field left out stays as it is.

type VolumeCreate

type VolumeCreate struct {
	VolumeSettings
	// Name Its name, unique in its project among volumes.
	Name *string `json:"name,omitempty"`
	// Labels Labels to find it by.
	Labels map[string]string `json:"labels,omitempty"`
	// SizeMib Its size in MiB, 64 to 409600 (400 GiB). Not with `from`, whose snapshot's size it takes.
	SizeMib *int64 `json:"sizeMiB,omitempty"`
	// From A snapshot of a volume, by its ID (`ready`), to restore: the new volume holds what that volume held when the snapshot was taken, at its size. A restore is always a new volume, never an overwrite.
	From *string `json:"from,omitempty"`
	// DeleteAfterSeconds Seconds until Runtime deletes it and what it holds, as its delete does: final, and it can't be undone; one attached to a machine is deleted once that machine ends. 0 or omitted: kept until deleted. At least 0. At most 315360000.
	DeleteAfterSeconds *int64 `json:"deleteAfterSeconds,omitempty"`
	// DeleteProtection Whether its delete is refused (409 `delete_protected`) until an update turns this off; false when omitted. Not with `deleteAfterSeconds`.
	DeleteProtection *bool `json:"deleteProtection,omitempty"`
}

VolumeCreate A volume to create: an empty disk, formatted ext4 at its first mount.

type VolumeGetQuery

type VolumeGetQuery struct {
	// Wait Seconds to wait, at most 60, for its state to differ from `ifState`; it answers once it does, or as it is when the wait ends. At least 0. At most 60.
	Wait *float64
	// IfState The state the caller last read, which `wait` waits for it to leave.
	IfState *string
}

VolumeGetQuery is what Get takes in its query.

type VolumeListQuery

type VolumeListQuery struct {
	// Name Only those of this name.
	Name *string
	// State Only those in these states, comma-separated.
	State *string
	// Label Only those with every label given (repeat it for several): key:value, or a key for any value.
	Label []string
	// Cursor Where the page starts: a page's `next`.
	Cursor *string
	// Limit The most items the page holds. At least 1. At most 200. Default: 50.
	Limit *int64
}

VolumeListQuery is what List takes in its query.

type VolumeMount

type VolumeMount struct {
	// Volume The volume, by name or ID, in the machine's project.
	Volume string `json:"volume"`
	// Path Where it is mounted, such as `/data`: an absolute path, not under `/proc`, `/sys`, `/dev`, `/etc`, `/usr`, `/bin`, `/sbin`, `/lib` or `/boot`.
	Path string `json:"path"`
}

VolumeMount A volume a machine attaches at its create, mounted read-write in it, one machine at a time; detached when the machine is deleted.

type VolumeSettings added in v2.2.0

type VolumeSettings struct {
	// SnapshotSchedule Its snapshots on a timer; off when omitted.
	SnapshotSchedule *SnapshotSchedule `json:"snapshotSchedule,omitempty"`
}

VolumeSettings A volume's settings.

type VolumeUpdate added in v2.2.0

type VolumeUpdate struct {
	StoredUpdate
	// SnapshotSchedule Its snapshot schedule, in place of the one it has; `everySeconds` 0 turns it off.
	SnapshotSchedule *SnapshotSchedule `json:"snapshotSchedule,omitempty"`
}

VolumeUpdate A change to a volume: each field left out stays as it is.

type Volumes

type Volumes struct {
	// contains filtered or unexported fields
}

Volumes A disk that outlives the machines it is attached to.

func (*Volumes) Create

func (c *Volumes) Create(ctx context.Context, in VolumeCreate, opts *RequestOptions) (*Volume, error)

Create Creates an empty volume. Asked again with the same Idempotency-Key, it returns the same one.

func (*Volumes) Delete

func (c *Volumes) Delete(ctx context.Context, id string, opts *RequestOptions) (*Stored, error)

Delete Deletes a volume and what it holds. One attached to a machine is refused: delete the machine first. Its snapshots are kept until each is deleted.

func (*Volumes) Get

func (c *Volumes) Get(ctx context.Context, id string, q VolumeGetQuery, opts *RequestOptions) (*Volume, error)

Get Returns a volume.

func (*Volumes) List

func (c *Volumes) List(ctx context.Context, q VolumeListQuery, opts *RequestOptions) (*Page[Stored], error)

List Lists the project's volumes, newest first.

func (*Volumes) ListAll

ListAll is every item of every page List reads from q.Cursor (none: the first page), each page read as the last is used up.

func (*Volumes) Snapshot added in v2.2.0

func (c *Volumes) Snapshot(ctx context.Context, id string, opts *RequestOptions) (*Stored, error)

Snapshot Keeps the volume's disk as it is now, a snapshot to restore as a new volume (`from`); one attached to a running machine is taken as it runs, consistent as after a power cut. It returns the snapshot at once, `making` until its copy is off-site, then `ready`. One never attached holds nothing to keep (409). Asked again with the same Idempotency-Key, it returns the same snapshot.

func (*Volumes) Update

func (c *Volumes) Update(ctx context.Context, id string, in VolumeUpdate, opts *RequestOptions) (*Stored, error)

Update Changes its lifetime (`deleteAfterSeconds`), delete protection (`deleteProtection`) or snapshot schedule (`snapshotSchedule`). A lifetime sent again before its end moves the end to that many seconds from now; 0 takes it off. At its end Runtime deletes it as its delete does: final, and it can't be undone. A lifetime and protection are never set together (409 `delete_protected`). A schedule sent replaces the one it has, its first snapshot `everySeconds` from now; `everySeconds` 0 turns it off, and the snapshots it made are kept. Each field left out stays as it is.

type Webhook

type Webhook struct {
	// ID Its ID.
	ID string `json:"id"`
	// Object Always `webhook`.
	Object string `json:"object"`
	// Url The https URL each event is sent to; in a list, its origin alone (`https://host/…`).
	Url string `json:"url"`
	// Events The events it is sent (`sandbox.created`); `*` for every one.
	Events []string `json:"events"`
	// State `active` while it is sent to; `deleted` once deleted: a delete's answer.
	State string `json:"state"`
	// CreatedAt When it was made.
	CreatedAt string `json:"createdAt"`
	// Secret Its signing secret (`whsec_...`): returned when it is made, and never again.
	Secret *string `json:"secret,omitempty"`
	// DeletedAt When it was deleted: a delete's answer, its state `deleted`.
	DeletedAt *string `json:"deletedAt,omitempty"`
}

Webhook A webhook: a signed POST to your URL for each event it names.

type WebhookCreate

type WebhookCreate struct {
	// Url The https URL to send each event to.
	Url string `json:"url"`
	// Events The events to send it, at most 32; `["*"]` (every one) when omitted.
	Events []string `json:"events,omitempty"`
}

WebhookCreate A webhook to make.

type WebhookListQuery

type WebhookListQuery struct {
	// Cursor Where the page starts: a page's `next`.
	Cursor *string
	// Limit The most items the page holds. At least 1. At most 200. Default: 50.
	Limit *int64
}

WebhookListQuery is what List takes in its query.

type Webhooks

type Webhooks struct {
	// contains filtered or unexported fields
}

Webhooks A signed POST to your URL for each event it names.

func (*Webhooks) Create

func (c *Webhooks) Create(ctx context.Context, in WebhookCreate, opts *RequestOptions) (*Webhook, error)

Create Makes a webhook, returning its signing secret this once.

func (*Webhooks) Delete

func (c *Webhooks) Delete(ctx context.Context, id string, opts *RequestOptions) (*Webhook, error)

Delete Deletes it: nothing more is sent to it.

func (*Webhooks) List

List Lists the org's, oldest first.

func (*Webhooks) ListAll

ListAll is every item of every page List reads from q.Cursor (none: the first page), each page read as the last is used up.

type Workspace

type Workspace struct {

	// Info is what it was when last read.
	Info      *SandboxInfo
	Files     *WorkspaceFiles
	Processes *WorkspaceProcesses
	Network   *WorkspaceNetwork
	// contains filtered or unexported fields
}

Workspace is one of workspaces: A development environment: a machine running VS Code in the browser (code-server) on port 8080 over /workspace, reached at its private preview, as Codespaces and Gitpod give one. It pauses after 30 minutes with nothing happening, its memory kept.

func (*Workspace) Act

func (s *Workspace) Act(ctx context.Context, actions []Action, in *ActRequest, opts *RequestOptions) (*Acted, error)

Act Moves, clicks, drags and scrolls the mouse and types on the keyboard of a workspace's screen (its X display `:1`), each step in turn as one command, and returns where the mouse is then. It stops at the first step that fails, refused 409 `act_failed` naming it; refused 409 `display_not_running` when no display runs. A paused workspace is resumed first.

func (*Workspace) Delete

func (s *Workspace) Delete(ctx context.Context, opts *RequestOptions) (*SandboxInfo, error)

Delete Deletes a workspace, its memory and its disk.

func (*Workspace) Exec

func (s *Workspace) Exec(ctx context.Context, cmd string, in *ExecRequest, opts *RequestOptions) (*Process, error)

Exec Runs a command as a process and returns it once it ended, with its output; with wait false, at once, while it runs. A paused workspace is resumed first. Asked again with the same Idempotency-Key, it runs nothing more: it returns the first run's process, waiting for its end while it runs.

func (*Workspace) Fork

func (s *Workspace) Fork(ctx context.Context, in *ForkRequest, opts *RequestOptions) (*Forked, error)

Fork Copies a workspace as it is now, memory and disk, into `count` copies of its own, each running on its host. Asked again with the same Idempotency-Key, it returns the same copies.

func (*Workspace) ID

func (s *Workspace) ID() string

ID is its id.

func (*Workspace) Metrics

Metrics Returns a workspace's CPU, memory, disks and pressure, as its host reads them from the workspace's own cgroup over a fifth of a second: never a call into the workspace, so it does not wake a paused one nor keep one from its idle pause. One that is not running has no reading.

func (*Workspace) Pause

func (s *Workspace) Pause(ctx context.Context, opts *RequestOptions) error

Pause Pauses a workspace with its memory and disk kept. A call to it resumes it.

func (*Workspace) Refresh

func (s *Workspace) Refresh(ctx context.Context, q *WorkspaceGetQuery, opts *RequestOptions) error

Refresh Returns a workspace.

func (*Workspace) Resume

func (s *Workspace) Resume(ctx context.Context, opts *RequestOptions) error

Resume Resumes a paused workspace where it was, its memory and processes as they were.

func (*Workspace) RunCode

func (s *Workspace) RunCode(ctx context.Context, code string, in *RunCode, opts *RequestOptions) (*CodeRun, error)

RunCode Runs a cell of Python in a workspace as a notebook does, in a Jupyter kernel it keeps running for the cell's `context`: variables, imports and functions stay for the next cell. Returns what it printed, its values and displays (text, HTML, images such as charts), and its exception with its traceback. The context's kernel starts on its first cell. A cell past `timeoutSeconds` is interrupted and its context kept. Refused 409 `kernel_not_installed` when the image has no ipykernel. A paused workspace is resumed first.

func (*Workspace) Screenshot

func (s *Workspace) Screenshot(ctx context.Context, q *WorkspaceScreenshotQuery, opts *RequestOptions) ([]byte, error)

Screenshot Returns what a workspace's screen shows now, as `image/png` (or `image/jpeg`): its X display `:1`, whole. Refused 409 `display_not_running` when no display runs. A paused workspace is resumed first.

func (*Workspace) Snapshot

func (s *Workspace) Snapshot(ctx context.Context, in *SnapshotRequest, opts *RequestOptions) (*Stored, error)

Snapshot Keeps a workspace's memory and disk as they are now, a snapshot to start workspaces from; with `image`, its disk alone as that image's next version. The workspace runs on. Asked again with the same Idempotency-Key, it returns the same snapshot.

func (*Workspace) Update

func (s *Workspace) Update(ctx context.Context, in *MachineUpdate, opts *RequestOptions) error

Update Changes its name, labels, idle pause, maxCost, autoWake, lifetime, delete protection, environment or sizes; each field left out stays as it is. A lifetime (`deleteAfterSeconds`) sent again before its end moves the end to that many seconds from now; 0 takes it off. A lifetime is refused (409 `delete_protected`) while `deleteProtection` is true. A running one holds a changed environment before this answers (a paused one's at its wake): each process it starts after the answer has it, and its running processes keep the one they started with. Its vCPUs, memory and disk grow while it runs, its commands running on. One paused or stopped is not woken for it: judged at once as a live resize is (past the vCPUs it was made with 409, over its organization's limits `quota_exceeded`), its new sizes are returned at once, and its next wake grows it to them before the call that woke it runs. A smaller size, or a machine starting or failed, is refused 409 naming why, and nothing is changed. With If-Match, made only while its revision is that one, else 412. Sent again with the same Idempotency-Key and body while it is the latest change, it returns the current state and changes nothing; the same key with a different body returns 409 idempotency_key_reused.

type WorkspaceDownloadFolderQuery

type WorkspaceDownloadFolderQuery struct {
	// Path The folder, absolute, such as `/workspace/app`.
	Path string
	// Gzip Compress the archive with gzip. Default: false.
	Gzip *bool
	// User Who packs it: `runtime` or `root`; the workspace's `user` when omitted.
	User *string
	// Exclude Paths in the folder to leave out, relative to it and comma-separated (`node_modules,.cache`): plain names, no wildcards, at most 32.
	Exclude *string
}

WorkspaceDownloadFolderQuery is what DownloadFolder takes in its query.

type WorkspaceFiles

type WorkspaceFiles struct {
	// contains filtered or unexported fields
}

WorkspaceFiles is a workspace's files.

func (*WorkspaceFiles) AbortFolderUpload

func (g *WorkspaceFiles) AbortFolderUpload(ctx context.Context, upload string, opts *RequestOptions) (*FolderUploadAborted, error)

AbortFolderUpload Stops a folder upload's tar; what it unpacked so far stays.

func (*WorkspaceFiles) BeginFolderUpload

func (g *WorkspaceFiles) BeginFolderUpload(ctx context.Context, path string, in *FolderUploadBegin, opts *RequestOptions) (*FolderUpload, error)

BeginFolderUpload Begins a folder's upload in parts: tar starts in the workspace, unpacking into the folder each part as it arrives. Send the parts in order by offset (writeFolderUpload), then commitFolderUpload; an upload no call names for 10 minutes is ended. A paused workspace is woken first.

func (*WorkspaceFiles) CommitFolderUpload

func (g *WorkspaceFiles) CommitFolderUpload(ctx context.Context, upload string, opts *RequestOptions) (*FolderUnpacked, error)

CommitFolderUpload Ends a folder upload's input and returns once tar has ended, as an exec returns once its command has: the folder, or 400 `invalid_archive` with what tar said. Sent again, it returns how tar ended. An upload no call has named for 10 minutes since its last part or commit is ended.

func (*WorkspaceFiles) DownloadFolder

func (g *WorkspaceFiles) DownloadFolder(ctx context.Context, path string, q *WorkspaceDownloadFolderQuery, opts *RequestOptions) ([]byte, error)

DownloadFolder Returns a folder as a tar archive (`application/x-tar`, or `application/gzip` with gzip), packed by tar in the workspace as it streams, of any size; its entries are relative to the folder (`./a.txt`). A folder that fails part way (a file it may not read, or one that changes as it is read) ends as an archive every tar reader refuses, never as a short one that reads whole. At most 4 at once in a workspace. A paused workspace is woken first.

func (g *WorkspaceFiles) Link(ctx context.Context, path string, in *FileLinkCreate, opts *RequestOptions) (*FileLink, error)

Link Makes an expiring address for one file that anyone may open with no API key, from a browser, curl or another service: GET downloads it (Range works, so videos play and downloads resume; archive: true downloads a folder as .tar.gz), PUT with the raw body uploads it (up to maxBytes, written whole; Content-Length required). The link acts as the key that made it: an upload link needs write, and the link ends with its key, with revokeLinks or with its workspace. A paused workspace is woken for it unless wake is false. A port it serves is shared by a preview (previews.create), not a link.

func (*WorkspaceFiles) List

List Lists a directory's entries in path order, to a depth.

func (*WorkspaceFiles) Mkdir

func (g *WorkspaceFiles) Mkdir(ctx context.Context, path string, in *FileMkdir, opts *RequestOptions) (*FileMade, error)

Mkdir Makes a directory, and its parents unless parents is false. One there already is success, created false.

func (*WorkspaceFiles) Read

func (g *WorkspaceFiles) Read(ctx context.Context, path string, q *WorkspaceReadQuery, opts *RequestOptions) ([]byte, error)

Read Returns a file's bytes.

func (*WorkspaceFiles) Remove

func (g *WorkspaceFiles) Remove(ctx context.Context, path string, in *FileRemove, opts *RequestOptions) (*FileRemoved, error)

Remove Removes a file, a link or a directory (recursive for one with contents). One missing is success, removed false.

func (*WorkspaceFiles) Rename

func (g *WorkspaceFiles) Rename(ctx context.Context, in *FileRename, opts *RequestOptions) (*FileRenamed, error)

Rename Moves a file, a link or a directory; refused 409 when something is at its new path, unless overwrite. With sha256 or size, a file written in parts is put in place once whole: its writes ended, then only a file of that size with every byte written and whose bytes hash to it moves; refused 409 `upload_incomplete` or `checksum_mismatch`, nothing moved. With sha256, it is safe to send again: once moved, it returns the same answer while `from` is gone and `to` holds those bytes.

func (g *WorkspaceFiles) RevokeLinks(ctx context.Context, opts *RequestOptions) (*FileLinksRevoked, error)

RevokeLinks Ends every file link made for a workspace so far; links made after work.

func (*WorkspaceFiles) Stat

Stat Returns what is at a path: a file, a directory or a link, or nothing (exists false). With sha256=true, a file's SHA-256 too.

func (*WorkspaceFiles) UploadFolder

func (g *WorkspaceFiles) UploadFolder(ctx context.Context, path string, data []byte, q *WorkspaceUploadFolderQuery, opts *RequestOptions) (*FolderUnpacked, error)

UploadFolder Unpacks the request's tar archive (gzip-compressed or not, told by its first bytes) into a folder, made with its parents, by tar in the workspace as the bytes arrive, of any size, nothing of it kept on disk but what tar writes; returns once tar has ended, or 400 `invalid_archive` with what tar said. A paused workspace is woken first.

func (*WorkspaceFiles) Write

func (g *WorkspaceFiles) Write(ctx context.Context, path string, data []byte, q *WorkspaceWriteQuery, opts *RequestOptions) (*FileWritten, error)

Write Writes the request's bytes to a file as they come, of any size (Content-Length required), its folders made: the file whole when they all came, or as it was. With offset, they are written into it in place.

func (*WorkspaceFiles) WriteFolderUpload

func (g *WorkspaceFiles) WriteFolderUpload(ctx context.Context, upload string, data []byte, q *WorkspaceWriteFolderUploadQuery, opts *RequestOptions) (*FolderUploadReceived, error)

WriteFolderUpload Sends the request's bytes, a part of the archive at its offset, into tar's input as they arrive, of any size, and returns the bytes received in all once tar took them. A part past them is refused 409 `upload_incomplete`, naming them: send the parts in order.

type WorkspaceGetQuery

type WorkspaceGetQuery struct {
	// Wait Seconds to wait, at most 60, for its state to differ from `ifState`; it answers once it does, or as it is when the wait ends. At least 0. At most 60.
	Wait *float64
	// IfState The state the caller last read, which `wait` waits for it to leave.
	IfState *string
}

WorkspaceGetQuery is what Get takes in its query.

type WorkspaceListFilesQuery

type WorkspaceListFilesQuery struct {
	// Path The directory. Default: "/workspace".
	Path *string
	// Depth How deep to list. At least 1. At most 10. Default: 1.
	Depth *int64
	// Limit At most this many entries. At least 1. At most 2000. Default: 2000.
	Limit *int64
	// Hidden List entries whose names start with a dot. Default: true.
	Hidden *bool
	// Glob Only entries whose path relative to the directory matches: `*` within a name, `**` across folders, `?` one character, `{a,b}` either (`**/*.py`); at most 512 characters, 32 wildcards and 64 texts in braces. The listing then reaches as deep as the glob does (10 folders for `**`) unless depth says, and is searched past its first 2,000 entries, up to 50,000. At most 512 characters.
	Glob *string
}

WorkspaceListFilesQuery is what ListFiles takes in its query.

type WorkspaceListQuery

type WorkspaceListQuery struct {
	// State Only those in these states, comma-separated.
	State *string
	// Name Only the workspace of this name.
	Name *string
	// Label Only those with every label given (repeat it for several): key:value, or a key for any value.
	Label []string
	// Cursor Where the page starts: a page's `next`.
	Cursor *string
	// Limit The most items the page holds. At least 1. At most 200. Default: 50.
	Limit *int64
}

WorkspaceListQuery is what List takes in its query.

type WorkspaceMetricsQuery

type WorkspaceMetricsQuery struct {
	// Range The window: `15m`, `1h`, `6h`, `24h`, `7d` or `30d`. Default: "1h".
	Range *string
}

WorkspaceMetricsQuery is what Metrics takes in its query.

type WorkspaceNetwork

type WorkspaceNetwork struct {
	// contains filtered or unexported fields
}

WorkspaceNetwork is a workspace's network.

func (*WorkspaceNetwork) Get

Get Returns where a workspace may connect out.

func (*WorkspaceNetwork) Set

Set Replaces where a workspace may connect out, for its next connection and within a second for its open ones: those the new rules refuse are cut.

type WorkspaceProcessOutputQuery

type WorkspaceProcessOutputQuery struct {
	// Cursor Output after this byte. At least 0. Default: 0.
	Cursor *int64
	// WaitSeconds Seconds to wait for output past the cursor or its exit, at most 8. At least 0. At most 8.
	WaitSeconds *float64
	// MaxBytes At most this many bytes. At least 4096. At most 196608. Default: 65536.
	MaxBytes *int64
	// Follow Answer as NDJSON events from the cursor until it exits (stdout, stderr, truncated, exit; continue with the cursor to follow on from), as `Accept: application/x-ndjson` does.
	Follow *bool
}

WorkspaceProcessOutputQuery is what ProcessOutput takes in its query.

type WorkspaceProcesses

type WorkspaceProcesses struct {
	// contains filtered or unexported fields
}

WorkspaceProcesses is a workspace's processes.

func (*WorkspaceProcesses) List

List Lists a workspace's processes, newest first: those running and those that ended lately.

func (*WorkspaceProcesses) Output

Output Returns a process's output after a cursor, and the cursor to read on from. The latest 1 MiB is kept; truncated says when the cursor fell behind.

func (*WorkspaceProcesses) Resize

func (g *WorkspaceProcesses) Resize(ctx context.Context, process string, in *Terminal, opts *RequestOptions) (*Process, error)

Resize Resizes the terminal of a process started with a pty (its window's columns and rows, which the process is told by SIGWINCH), and returns the process; refused 409 for a process without one. A process that ended is left as it is, so a retry is safe.

func (*WorkspaceProcesses) Signal

func (g *WorkspaceProcesses) Signal(ctx context.Context, process string, in *ProcessSignal, opts *RequestOptions) (*Process, error)

Signal Sends a signal to a process and its group; a process that ended is not signalled, so a retry is safe.

func (*WorkspaceProcesses) Write

Write Sends input to a process started with stdinOpen or a pty, and returns how much of its input it has taken.

type WorkspaceReadQuery

type WorkspaceReadQuery struct {
	// Path The file's path in the machine.
	Path string
}

WorkspaceReadQuery is what Read takes in its query.

type WorkspaceScreenshotQuery

type WorkspaceScreenshotQuery struct {
	// Format `png`, or `jpeg`: smaller and quicker to send, for a model that reads it. Default: "png".
	Format *string
	// Quality A jpeg's quality, 1 to 100. At least 1. At most 100. Default: 80.
	Quality *int64
}

WorkspaceScreenshotQuery is what Screenshot takes in its query.

type WorkspaceStatQuery

type WorkspaceStatQuery struct {
	// Path The file's path in the machine.
	Path string
	// Sha256 Also return a file's SHA-256, read from its bytes: to check a file you put in place (files:rename with sha256) is whole. Default: false.
	Sha256 *bool
}

WorkspaceStatQuery is what Stat takes in its query.

type WorkspaceUploadFolderQuery

type WorkspaceUploadFolderQuery struct {
	// Path The folder, absolute, such as `/workspace/app`: made with its parents.
	Path string
	// User Who unpacks it: `runtime` or `root`; the workspace's `user` when omitted.
	User *string
}

WorkspaceUploadFolderQuery is what UploadFolder takes in its query.

type WorkspaceWriteFolderUploadQuery

type WorkspaceWriteFolderUploadQuery struct {
	// Offset Where the part starts in the archive: at most the bytes received so far. Bytes before them were taken already and are skipped, so a part sent again is never unpacked twice. At least 0. Default: 0.
	Offset *int64
}

WorkspaceWriteFolderUploadQuery is what WriteFolderUpload takes in its query.

type WorkspaceWriteQuery

type WorkspaceWriteQuery struct {
	// Path The file's path in the machine.
	Path string
	// Mode Its mode, in octal (`644`).
	Mode *string
	// Offset Write the bytes into the file in place from this byte, keeping the bytes before and after them (the file is made when there is none); one that fails part way may leave its range written in part, so send it again. Parts of one file may be written so at once and in any order: write them to a new path, then rename it with its size and sha256 to put it in place whole. At least 0.
	Offset *int64
	// Sha256 The bytes' SHA-256 in hex: refused 409 `checksum_mismatch`, the file as it was, when they differ. Not with offset.
	Sha256 *string
}

WorkspaceWriteQuery is what Write takes in its query.

type Workspaces

type Workspaces struct {
	// contains filtered or unexported fields
}

Workspaces A development environment: a machine running VS Code in the browser (code-server) on port 8080 over /workspace, reached at its private preview, as Codespaces and Gitpod give one. It pauses after 30 minutes with nothing happening, its memory kept.

func (*Workspaces) AbortFolderUpload

func (c *Workspaces) AbortFolderUpload(ctx context.Context, id string, upload string, opts *RequestOptions) (*FolderUploadAborted, error)

AbortFolderUpload Stops a folder upload's tar; what it unpacked so far stays.

func (*Workspaces) Act

func (c *Workspaces) Act(ctx context.Context, id string, in ActRequest, opts *RequestOptions) (*Acted, error)

Act Moves, clicks, drags and scrolls the mouse and types on the keyboard of a workspace's screen (its X display `:1`), each step in turn as one command, and returns where the mouse is then. It stops at the first step that fails, refused 409 `act_failed` naming it; refused 409 `display_not_running` when no display runs. A paused workspace is resumed first.

func (*Workspaces) BeginFolderUpload

func (c *Workspaces) BeginFolderUpload(ctx context.Context, id string, in FolderUploadBegin, opts *RequestOptions) (*FolderUpload, error)

BeginFolderUpload Begins a folder's upload in parts: tar starts in the workspace, unpacking into the folder each part as it arrives. Send the parts in order by offset (writeFolderUpload), then commitFolderUpload; an upload no call names for 10 minutes is ended. A paused workspace is woken first.

func (*Workspaces) CommitFolderUpload

func (c *Workspaces) CommitFolderUpload(ctx context.Context, id string, upload string, opts *RequestOptions) (*FolderUnpacked, error)

CommitFolderUpload Ends a folder upload's input and returns once tar has ended, as an exec returns once its command has: the folder, or 400 `invalid_archive` with what tar said. Sent again, it returns how tar ended. An upload no call has named for 10 minutes since its last part or commit is ended.

func (*Workspaces) Create

func (c *Workspaces) Create(ctx context.Context, in SandboxCreate, opts *RequestOptions) (*Workspace, error)

Create Creates a workspace. Asked again with the same Idempotency-Key, it returns the same workspace.

func (*Workspaces) Delete

func (c *Workspaces) Delete(ctx context.Context, id string, opts *RequestOptions) (*SandboxInfo, error)

Delete Deletes a workspace, its memory and its disk.

func (*Workspaces) DownloadFolder

func (c *Workspaces) DownloadFolder(ctx context.Context, id string, q WorkspaceDownloadFolderQuery, opts *RequestOptions) ([]byte, error)

DownloadFolder Returns a folder as a tar archive (`application/x-tar`, or `application/gzip` with gzip), packed by tar in the workspace as it streams, of any size; its entries are relative to the folder (`./a.txt`). A folder that fails part way (a file it may not read, or one that changes as it is read) ends as an archive every tar reader refuses, never as a short one that reads whole. At most 4 at once in a workspace. A paused workspace is woken first.

func (*Workspaces) Exec

func (c *Workspaces) Exec(ctx context.Context, id string, in ExecRequest, opts *RequestOptions) (*Process, error)

Exec Runs a command as a process and returns it once it ended, with its output; with wait false, at once, while it runs. A paused workspace is resumed first. Asked again with the same Idempotency-Key, it runs nothing more: it returns the first run's process, waiting for its end while it runs.

func (*Workspaces) Fork

func (c *Workspaces) Fork(ctx context.Context, id string, in ForkRequest, opts *RequestOptions) (*Forked, error)

Fork Copies a workspace as it is now, memory and disk, into `count` copies of its own, each running on its host. Asked again with the same Idempotency-Key, it returns the same copies.

func (*Workspaces) Get

Get Returns a workspace.

func (*Workspaces) GetNetwork

func (c *Workspaces) GetNetwork(ctx context.Context, id string, opts *RequestOptions) (*SandboxNetwork, error)

GetNetwork Returns where a workspace may connect out.

func (c *Workspaces) Link(ctx context.Context, id string, in FileLinkCreate, opts *RequestOptions) (*FileLink, error)

Link Makes an expiring address for one file that anyone may open with no API key, from a browser, curl or another service: GET downloads it (Range works, so videos play and downloads resume; archive: true downloads a folder as .tar.gz), PUT with the raw body uploads it (up to maxBytes, written whole; Content-Length required). The link acts as the key that made it: an upload link needs write, and the link ends with its key, with revokeLinks or with its workspace. A paused workspace is woken for it unless wake is false. A port it serves is shared by a preview (previews.create), not a link.

func (*Workspaces) List

List Lists the project's workspaces, newest first.

func (*Workspaces) ListAll

ListAll is every item of every page List reads from q.Cursor (none: the first page), each page read as the last is used up.

func (*Workspaces) ListFiles

ListFiles Lists a directory's entries in path order, to a depth.

func (*Workspaces) ListProcesses

func (c *Workspaces) ListProcesses(ctx context.Context, id string, opts *RequestOptions) (*ProcessList, error)

ListProcesses Lists a workspace's processes, newest first: those running and those that ended lately.

func (*Workspaces) Metrics

Metrics Returns a workspace's CPU, memory, disks and pressure, as its host reads them from the workspace's own cgroup over a fifth of a second: never a call into the workspace, so it does not wake a paused one nor keep one from its idle pause. One that is not running has no reading.

func (*Workspaces) Mkdir

func (c *Workspaces) Mkdir(ctx context.Context, id string, in FileMkdir, opts *RequestOptions) (*FileMade, error)

Mkdir Makes a directory, and its parents unless parents is false. One there already is success, created false.

func (*Workspaces) Pause

func (c *Workspaces) Pause(ctx context.Context, id string, opts *RequestOptions) (*SandboxInfo, error)

Pause Pauses a workspace with its memory and disk kept. A call to it resumes it.

func (*Workspaces) ProcessOutput

func (c *Workspaces) ProcessOutput(ctx context.Context, id string, process string, q WorkspaceProcessOutputQuery, opts *RequestOptions) (*ProcessOutput, error)

ProcessOutput Returns a process's output after a cursor, and the cursor to read on from. The latest 1 MiB is kept; truncated says when the cursor fell behind.

func (*Workspaces) Read

func (c *Workspaces) Read(ctx context.Context, id string, q WorkspaceReadQuery, opts *RequestOptions) ([]byte, error)

Read Returns a file's bytes.

func (*Workspaces) Remove

func (c *Workspaces) Remove(ctx context.Context, id string, in FileRemove, opts *RequestOptions) (*FileRemoved, error)

Remove Removes a file, a link or a directory (recursive for one with contents). One missing is success, removed false.

func (*Workspaces) Rename

func (c *Workspaces) Rename(ctx context.Context, id string, in FileRename, opts *RequestOptions) (*FileRenamed, error)

Rename Moves a file, a link or a directory; refused 409 when something is at its new path, unless overwrite. With sha256 or size, a file written in parts is put in place once whole: its writes ended, then only a file of that size with every byte written and whose bytes hash to it moves; refused 409 `upload_incomplete` or `checksum_mismatch`, nothing moved. With sha256, it is safe to send again: once moved, it returns the same answer while `from` is gone and `to` holds those bytes.

func (*Workspaces) ResizeProcess

func (c *Workspaces) ResizeProcess(ctx context.Context, id string, process string, in Terminal, opts *RequestOptions) (*Process, error)

ResizeProcess Resizes the terminal of a process started with a pty (its window's columns and rows, which the process is told by SIGWINCH), and returns the process; refused 409 for a process without one. A process that ended is left as it is, so a retry is safe.

func (*Workspaces) Resume

func (c *Workspaces) Resume(ctx context.Context, id string, opts *RequestOptions) (*SandboxInfo, error)

Resume Resumes a paused workspace where it was, its memory and processes as they were.

func (c *Workspaces) RevokeLinks(ctx context.Context, id string, opts *RequestOptions) (*FileLinksRevoked, error)

RevokeLinks Ends every file link made for a workspace so far; links made after work.

func (*Workspaces) RunCode

func (c *Workspaces) RunCode(ctx context.Context, id string, in RunCode, opts *RequestOptions) (*CodeRun, error)

RunCode Runs a cell of Python in a workspace as a notebook does, in a Jupyter kernel it keeps running for the cell's `context`: variables, imports and functions stay for the next cell. Returns what it printed, its values and displays (text, HTML, images such as charts), and its exception with its traceback. The context's kernel starts on its first cell. A cell past `timeoutSeconds` is interrupted and its context kept. Refused 409 `kernel_not_installed` when the image has no ipykernel. A paused workspace is resumed first.

func (*Workspaces) Screenshot

func (c *Workspaces) Screenshot(ctx context.Context, id string, q WorkspaceScreenshotQuery, opts *RequestOptions) ([]byte, error)

Screenshot Returns what a workspace's screen shows now, as `image/png` (or `image/jpeg`): its X display `:1`, whole. Refused 409 `display_not_running` when no display runs. A paused workspace is resumed first.

func (*Workspaces) SetNetwork

func (c *Workspaces) SetNetwork(ctx context.Context, id string, in NetworkRules, opts *RequestOptions) (*SandboxNetwork, error)

SetNetwork Replaces where a workspace may connect out, for its next connection and within a second for its open ones: those the new rules refuse are cut.

func (*Workspaces) SignalProcess

func (c *Workspaces) SignalProcess(ctx context.Context, id string, process string, in ProcessSignal, opts *RequestOptions) (*Process, error)

SignalProcess Sends a signal to a process and its group; a process that ended is not signalled, so a retry is safe.

func (*Workspaces) Snapshot

func (c *Workspaces) Snapshot(ctx context.Context, id string, in SnapshotRequest, opts *RequestOptions) (*Stored, error)

Snapshot Keeps a workspace's memory and disk as they are now, a snapshot to start workspaces from; with `image`, its disk alone as that image's next version. The workspace runs on. Asked again with the same Idempotency-Key, it returns the same snapshot.

func (*Workspaces) Stat

Stat Returns what is at a path: a file, a directory or a link, or nothing (exists false). With sha256=true, a file's SHA-256 too.

func (*Workspaces) Update

func (c *Workspaces) Update(ctx context.Context, id string, in MachineUpdate, opts *RequestOptions) (*SandboxInfo, error)

Update Changes its name, labels, idle pause, maxCost, autoWake, lifetime, delete protection, environment or sizes; each field left out stays as it is. A lifetime (`deleteAfterSeconds`) sent again before its end moves the end to that many seconds from now; 0 takes it off. A lifetime is refused (409 `delete_protected`) while `deleteProtection` is true. A running one holds a changed environment before this answers (a paused one's at its wake): each process it starts after the answer has it, and its running processes keep the one they started with. Its vCPUs, memory and disk grow while it runs, its commands running on. One paused or stopped is not woken for it: judged at once as a live resize is (past the vCPUs it was made with 409, over its organization's limits `quota_exceeded`), its new sizes are returned at once, and its next wake grows it to them before the call that woke it runs. A smaller size, or a machine starting or failed, is refused 409 naming why, and nothing is changed. With If-Match, made only while its revision is that one, else 412. Sent again with the same Idempotency-Key and body while it is the latest change, it returns the current state and changes nothing; the same key with a different body returns 409 idempotency_key_reused.

func (*Workspaces) UploadFolder

func (c *Workspaces) UploadFolder(ctx context.Context, id string, data []byte, q WorkspaceUploadFolderQuery, opts *RequestOptions) (*FolderUnpacked, error)

UploadFolder Unpacks the request's tar archive (gzip-compressed or not, told by its first bytes) into a folder, made with its parents, by tar in the workspace as the bytes arrive, of any size, nothing of it kept on disk but what tar writes; returns once tar has ended, or 400 `invalid_archive` with what tar said. A paused workspace is woken first.

func (*Workspaces) Write

func (c *Workspaces) Write(ctx context.Context, id string, data []byte, q WorkspaceWriteQuery, opts *RequestOptions) (*FileWritten, error)

Write Writes the request's bytes to a file as they come, of any size (Content-Length required), its folders made: the file whole when they all came, or as it was. With offset, they are written into it in place.

func (*Workspaces) WriteFolderUpload

func (c *Workspaces) WriteFolderUpload(ctx context.Context, id string, upload string, data []byte, q WorkspaceWriteFolderUploadQuery, opts *RequestOptions) (*FolderUploadReceived, error)

WriteFolderUpload Sends the request's bytes, a part of the archive at its offset, into tar's input as they arrive, of any size, and returns the bytes received in all once tar took them. A part past them is refused 409 `upload_incomplete`, naming them: send the parts in order.

func (*Workspaces) WriteProcess

func (c *Workspaces) WriteProcess(ctx context.Context, id string, process string, in ProcessInput, opts *RequestOptions) (*ProcessWritten, error)

WriteProcess Sends input to a process started with stdinOpen or a pty, and returns how much of its input it has taken.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL