withruntime 0.27.1 → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/withruntime/generated/apps.rb +192 -0
- data/lib/withruntime/generated/audit.rb +78 -0
- data/lib/withruntime/generated/browsers.rb +192 -0
- data/lib/withruntime/generated/builds.rb +192 -0
- data/lib/withruntime/generated/ci.rb +192 -0
- data/lib/withruntime/generated/containers.rb +192 -0
- data/lib/withruntime/generated/desktops.rb +192 -0
- data/lib/withruntime/generated/domains.rb +152 -0
- data/lib/withruntime/generated/egress_ips.rb +81 -0
- data/lib/withruntime/generated/events.rb +60 -0
- data/lib/withruntime/generated/feedback.rb +96 -0
- data/lib/withruntime/generated/functions.rb +192 -0
- data/lib/withruntime/generated/identities.rb +68 -0
- data/lib/withruntime/generated/images.rb +391 -0
- data/lib/withruntime/generated/job_runs.rb +110 -0
- data/lib/withruntime/generated/jobs.rb +333 -0
- data/lib/withruntime/generated/keys.rb +261 -0
- data/lib/withruntime/generated/kit.rb +111 -0
- data/lib/withruntime/generated/me.rb +69 -0
- data/lib/withruntime/generated/networks.rb +72 -0
- data/lib/withruntime/generated/notebooks.rb +192 -0
- data/lib/withruntime/generated/otel.rb +94 -0
- data/lib/withruntime/generated/ports.rb +118 -0
- data/lib/withruntime/generated/previews.rb +124 -0
- data/lib/withruntime/generated/projects.rb +108 -0
- data/lib/withruntime/generated/roles.rb +68 -0
- data/lib/withruntime/generated/routes.rb +11 -0
- data/lib/withruntime/generated/runtime.rb +188 -0
- data/lib/withruntime/generated/sandboxes.rb +1835 -0
- data/lib/withruntime/generated/secrets.rb +294 -0
- data/lib/withruntime/generated/sessions.rb +143 -0
- data/lib/withruntime/generated/sites.rb +192 -0
- data/lib/withruntime/generated/snapshots.rb +32 -0
- data/lib/withruntime/generated/tunnels.rb +165 -0
- data/lib/withruntime/generated/usage.rb +287 -0
- data/lib/withruntime/generated/volumes.rb +61 -0
- data/lib/withruntime/generated/webhooks.rb +91 -0
- data/lib/withruntime/generated/workspaces.rb +192 -0
- data/lib/withruntime/signing.rb +162 -0
- data/lib/withruntime/version.rb +2 -2
- data/lib/withruntime.rb +5 -43
- metadata +45 -35
- data/lib/withruntime/agents.rb +0 -877
- data/lib/withruntime/api_defaults.rb +0 -17
- data/lib/withruntime/apps.rb +0 -377
- data/lib/withruntime/browsers.rb +0 -104
- data/lib/withruntime/builds.rb +0 -218
- data/lib/withruntime/ci.rb +0 -164
- data/lib/withruntime/client.rb +0 -140
- data/lib/withruntime/containers.rb +0 -39
- data/lib/withruntime/credentials.rb +0 -111
- data/lib/withruntime/fields.rb +0 -40
- data/lib/withruntime/file_watch.rb +0 -73
- data/lib/withruntime/images.rb +0 -258
- data/lib/withruntime/network_products.rb +0 -49
- data/lib/withruntime/parity_products.rb +0 -51
- data/lib/withruntime/products.rb +0 -560
- data/lib/withruntime/record.rb +0 -99
- data/lib/withruntime/reservations.rb +0 -76
- data/lib/withruntime/sandbox.rb +0 -770
- data/lib/withruntime/tar.rb +0 -292
- data/lib/withruntime/transport.rb +0 -575
- data/lib/withruntime/tunnel.rb +0 -275
- data/lib/withruntime/wallet.rb +0 -68
- data/lib/withruntime/websocket.rb +0 -384
|
@@ -0,0 +1,192 @@
|
|
|
1
|
+
# Generated by spec-gen from engines/front/crates/spec. Do not edit:
|
|
2
|
+
# change the spec and run `cargo run -p runtime-front-spec-gen -- write`.
|
|
3
|
+
|
|
4
|
+
require "uri"
|
|
5
|
+
require_relative "runtime"
|
|
6
|
+
require_relative "sandboxes"
|
|
7
|
+
|
|
8
|
+
module Withruntime
|
|
9
|
+
module Generated
|
|
10
|
+
# 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 and to VNC clients on 5900. It pauses after 300 seconds with nothing happening, its memory kept.
|
|
11
|
+
class Desktops
|
|
12
|
+
def initialize(transport)
|
|
13
|
+
@transport = transport
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
# Creates a desktop. Asked again with the same Idempotency-Key, it returns the same desktop.
|
|
17
|
+
def create(vcpu: nil, memory_gb: nil, disk_gb: nil, image: nil, secrets: nil, start: nil, user: nil, volumes: nil, run: nil, name: nil, labels: nil, get_or_create: nil, max_cost: nil, idle_pause_seconds: nil, snapshot: nil, network: nil, env: nil, idempotency_key: nil)
|
|
18
|
+
Sandbox.from(@transport.request("POST", "/v2/desktops", body: { "vcpu" => vcpu, "memoryGB" => memory_gb, "diskGB" => disk_gb, "image" => image, "secrets" => secrets, "start" => start, "user" => user, "volumes" => volumes, "run" => run, "name" => name, "labels" => labels, "getOrCreate" => get_or_create, "maxCost" => max_cost, "idlePauseSeconds" => idle_pause_seconds, "snapshot" => snapshot, "network" => network, "env" => env }.compact, idempotency_key: idempotency_key, idempotent: true))
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
# Returns a desktop.
|
|
22
|
+
def get(id, wait: nil, if_state: nil)
|
|
23
|
+
Sandbox.from(@transport.request("GET", "/v2/desktops/#{URI.encode_www_form_component(id)}", query: { "wait" => wait, "ifState" => if_state }, idempotent: true))
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
# Lists the project's desktops, newest first.
|
|
27
|
+
def list(state: nil, name: nil, label: nil, cursor: nil, limit: nil)
|
|
28
|
+
Generated.page(@transport.request("GET", "/v2/desktops", query: { "state" => state, "name" => name, "label" => label, "cursor" => cursor, "limit" => limit }, idempotent: true)) { |i| Sandbox.from(i) }
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
# Deletes a desktop, its memory and its disk.
|
|
32
|
+
def delete(id, idempotency_key: nil)
|
|
33
|
+
Sandbox.from(@transport.request("DELETE", "/v2/desktops/#{URI.encode_www_form_component(id)}", idempotency_key: idempotency_key))
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
# Pauses a desktop with its memory and disk kept. A call to it resumes it.
|
|
37
|
+
def pause(id, idempotency_key: nil)
|
|
38
|
+
Sandbox.from(@transport.request("POST", "/v2/desktops/#{URI.encode_www_form_component(id)}:pause", idempotency_key: idempotency_key))
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
# Resumes a paused desktop where it was, its memory and processes as they were.
|
|
42
|
+
def resume(id, idempotency_key: nil)
|
|
43
|
+
Sandbox.from(@transport.request("POST", "/v2/desktops/#{URI.encode_www_form_component(id)}:resume", idempotency_key: idempotency_key))
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
# 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.
|
|
47
|
+
def exec(id, cmd:, cwd: nil, env: nil, stdin: nil, timeout_seconds: nil, stream: nil, wait: nil, stdin_open: nil, output_encoding: nil, pty: nil, user: nil, idempotency_key: nil)
|
|
48
|
+
Process.from(@transport.request("POST", "/v2/desktops/#{URI.encode_www_form_component(id)}:exec", body: { "cmd" => cmd, "cwd" => cwd, "env" => env, "stdin" => stdin, "timeoutSeconds" => timeout_seconds, "stream" => stream, "wait" => wait, "stdinOpen" => stdin_open, "outputEncoding" => output_encoding, "pty" => pty, "user" => user }.compact, idempotency_key: idempotency_key, idempotent: true, runs: true, runs_seconds: timeout_seconds))
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
# Returns a file's bytes.
|
|
52
|
+
def read(id, path:)
|
|
53
|
+
@transport.request("GET", "/v2/desktops/#{URI.encode_www_form_component(id)}/files", query: { "path" => path }, raw: true, idempotent: true)
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
# 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.
|
|
57
|
+
def write(id, data, path:, mode: nil, offset: nil, sha256: nil, idempotency_key: nil)
|
|
58
|
+
FileWritten.from(@transport.request("PUT", "/v2/desktops/#{URI.encode_www_form_component(id)}/files", query: { "path" => path, "mode" => mode, "offset" => offset, "sha256" => sha256 }, data: data, idempotency_key: idempotency_key))
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
# 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.
|
|
62
|
+
def process_output(id, process, cursor: nil, wait_seconds: nil, max_bytes: nil, follow: nil)
|
|
63
|
+
ProcessOutput.from(@transport.request("GET", "/v2/desktops/#{URI.encode_www_form_component(id)}/processes/#{URI.encode_www_form_component(process)}/output", query: { "cursor" => cursor, "waitSeconds" => wait_seconds, "maxBytes" => max_bytes, "follow" => follow }, idempotent: true))
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
# Sends input to a process started with stdinOpen or a pty, and returns how much of its input it has taken.
|
|
67
|
+
def write_process(id, process, data: nil, offset: nil, eof: nil, idempotency_key: nil)
|
|
68
|
+
ProcessWritten.from(@transport.request("POST", "/v2/desktops/#{URI.encode_www_form_component(id)}/processes/#{URI.encode_www_form_component(process)}:write", body: { "data" => data, "offset" => offset, "eof" => eof }.compact, idempotency_key: idempotency_key))
|
|
69
|
+
end
|
|
70
|
+
|
|
71
|
+
# Sends a signal to a process and its group; a process that ended is not signalled, so a retry is safe.
|
|
72
|
+
def signal_process(id, process, signal: nil, idempotency_key: nil)
|
|
73
|
+
Process.from(@transport.request("POST", "/v2/desktops/#{URI.encode_www_form_component(id)}/processes/#{URI.encode_www_form_component(process)}:signal", body: { "signal" => signal }.compact, idempotency_key: idempotency_key, idempotent: true))
|
|
74
|
+
end
|
|
75
|
+
|
|
76
|
+
# Lists a desktop's processes, newest first: those running and those that ended lately.
|
|
77
|
+
def list_processes(id)
|
|
78
|
+
ProcessList.from(@transport.request("GET", "/v2/desktops/#{URI.encode_www_form_component(id)}/processes", idempotent: true))
|
|
79
|
+
end
|
|
80
|
+
|
|
81
|
+
# Removes a file, a link or a directory (recursive for one with contents). One missing is success, removed false.
|
|
82
|
+
def remove(id, path:, recursive: nil, idempotency_key: nil)
|
|
83
|
+
FileRemoved.from(@transport.request("POST", "/v2/desktops/#{URI.encode_www_form_component(id)}/files:remove", body: { "path" => path, "recursive" => recursive }.compact, idempotency_key: idempotency_key))
|
|
84
|
+
end
|
|
85
|
+
|
|
86
|
+
# 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.
|
|
87
|
+
def stat(id, path:, sha256: nil)
|
|
88
|
+
FileInfo.from(@transport.request("GET", "/v2/desktops/#{URI.encode_www_form_component(id)}/files/stat", query: { "path" => path, "sha256" => sha256 }, idempotent: true))
|
|
89
|
+
end
|
|
90
|
+
|
|
91
|
+
# Lists a directory's entries in path order, to a depth.
|
|
92
|
+
def list_files(id, path: nil, depth: nil, limit: nil, hidden: nil, glob: nil)
|
|
93
|
+
FileList.from(@transport.request("GET", "/v2/desktops/#{URI.encode_www_form_component(id)}/files/list", query: { "path" => path, "depth" => depth, "limit" => limit, "hidden" => hidden, "glob" => glob }, idempotent: true))
|
|
94
|
+
end
|
|
95
|
+
|
|
96
|
+
# 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.
|
|
97
|
+
def download_folder(id, path:, gzip: nil, user: nil, exclude: nil)
|
|
98
|
+
@transport.request("GET", "/v2/desktops/#{URI.encode_www_form_component(id)}/files/archive", query: { "path" => path, "gzip" => gzip, "user" => user, "exclude" => exclude }, raw: true, idempotent: true)
|
|
99
|
+
end
|
|
100
|
+
|
|
101
|
+
# 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.
|
|
102
|
+
def upload_folder(id, data, path:, user: nil, idempotency_key: nil)
|
|
103
|
+
FolderUnpacked.from(@transport.request("PUT", "/v2/desktops/#{URI.encode_www_form_component(id)}/files/archive", query: { "path" => path, "user" => user }, data: data, idempotency_key: idempotency_key, idempotent: true))
|
|
104
|
+
end
|
|
105
|
+
|
|
106
|
+
# 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.
|
|
107
|
+
def begin_folder_upload(id, path:, gzip: nil, user: nil, idempotency_key: nil)
|
|
108
|
+
FolderUpload.from(@transport.request("POST", "/v2/desktops/#{URI.encode_www_form_component(id)}/files/archive/uploads", body: { "path" => path, "gzip" => gzip, "user" => user }.compact, idempotency_key: idempotency_key))
|
|
109
|
+
end
|
|
110
|
+
|
|
111
|
+
# 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.
|
|
112
|
+
def write_folder_upload(id, upload, data, offset: nil, idempotency_key: nil)
|
|
113
|
+
FolderUploadReceived.from(@transport.request("PUT", "/v2/desktops/#{URI.encode_www_form_component(id)}/files/archive/uploads/#{URI.encode_www_form_component(upload)}", query: { "offset" => offset }, data: data, idempotency_key: idempotency_key, idempotent: true))
|
|
114
|
+
end
|
|
115
|
+
|
|
116
|
+
# 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. A front that restarts meanwhile returns 503 `run_goes_on`; sent again, it returns how tar ended. An upload no call has named for 10 minutes since its last part or commit is ended.
|
|
117
|
+
def commit_folder_upload(id, upload, idempotency_key: nil)
|
|
118
|
+
FolderUnpacked.from(@transport.request("POST", "/v2/desktops/#{URI.encode_www_form_component(id)}/files/archive/uploads/#{URI.encode_www_form_component(upload)}:commit", idempotency_key: idempotency_key, idempotent: true))
|
|
119
|
+
end
|
|
120
|
+
|
|
121
|
+
# Stops a folder upload's tar; what it unpacked so far stays.
|
|
122
|
+
def abort_folder_upload(id, upload, idempotency_key: nil)
|
|
123
|
+
FolderUploadAborted.from(@transport.request("POST", "/v2/desktops/#{URI.encode_www_form_component(id)}/files/archive/uploads/#{URI.encode_www_form_component(upload)}:abort", idempotency_key: idempotency_key, idempotent: true))
|
|
124
|
+
end
|
|
125
|
+
|
|
126
|
+
# Makes a directory, and its parents unless parents is false. One there already is success, created false.
|
|
127
|
+
def mkdir(id, path:, parents: nil, idempotency_key: nil)
|
|
128
|
+
FileMade.from(@transport.request("POST", "/v2/desktops/#{URI.encode_www_form_component(id)}/files:mkdir", body: { "path" => path, "parents" => parents }.compact, idempotency_key: idempotency_key, idempotent: true))
|
|
129
|
+
end
|
|
130
|
+
|
|
131
|
+
# 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.
|
|
132
|
+
def rename(id, from:, to:, overwrite: nil, sha256: nil, size: nil, idempotency_key: nil)
|
|
133
|
+
FileRenamed.from(@transport.request("POST", "/v2/desktops/#{URI.encode_www_form_component(id)}/files:rename", body: { "from" => from, "to" => to, "overwrite" => overwrite, "sha256" => sha256, "size" => size }.compact, idempotency_key: idempotency_key))
|
|
134
|
+
end
|
|
135
|
+
|
|
136
|
+
# 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.
|
|
137
|
+
def link(id, path:, method: nil, expires_in_seconds: nil, filename: nil, max_bytes: nil, wake: nil, archive: nil, idempotency_key: nil)
|
|
138
|
+
FileLink.from(@transport.request("POST", "/v2/desktops/#{URI.encode_www_form_component(id)}/files:link", body: { "path" => path, "method" => method, "expiresInSeconds" => expires_in_seconds, "filename" => filename, "maxBytes" => max_bytes, "wake" => wake, "archive" => archive }.compact, idempotency_key: idempotency_key))
|
|
139
|
+
end
|
|
140
|
+
|
|
141
|
+
# Ends every file link made for a desktop so far; links made after work.
|
|
142
|
+
def revoke_links(id, idempotency_key: nil)
|
|
143
|
+
FileLinksRevoked.from(@transport.request("POST", "/v2/desktops/#{URI.encode_www_form_component(id)}/files:revokeLinks", idempotency_key: idempotency_key))
|
|
144
|
+
end
|
|
145
|
+
|
|
146
|
+
# Returns where a desktop may connect out.
|
|
147
|
+
def get_network(id)
|
|
148
|
+
SandboxNetwork.from(@transport.request("GET", "/v2/desktops/#{URI.encode_www_form_component(id)}/network", idempotent: true))
|
|
149
|
+
end
|
|
150
|
+
|
|
151
|
+
# 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.
|
|
152
|
+
def metrics(id, range: nil)
|
|
153
|
+
SandboxMetrics.from(@transport.request("GET", "/v2/desktops/#{URI.encode_www_form_component(id)}/metrics", query: { "range" => range }, idempotent: true))
|
|
154
|
+
end
|
|
155
|
+
|
|
156
|
+
# 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.
|
|
157
|
+
def set_network(id, allow_outbound: nil, deny_outbound: nil, idempotency_key: nil)
|
|
158
|
+
SandboxNetwork.from(@transport.request("PUT", "/v2/desktops/#{URI.encode_www_form_component(id)}/network", body: { "allowOutbound" => allow_outbound, "denyOutbound" => deny_outbound }.compact, idempotency_key: idempotency_key))
|
|
159
|
+
end
|
|
160
|
+
|
|
161
|
+
# 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.
|
|
162
|
+
def fork(id, count: nil, name: nil, labels: nil, secrets: nil, max_cost: nil, idle_pause_seconds: nil, idempotency_key: nil)
|
|
163
|
+
Forked.from(@transport.request("POST", "/v2/desktops/#{URI.encode_www_form_component(id)}:fork", body: { "count" => count, "name" => name, "labels" => labels, "secrets" => secrets, "maxCost" => max_cost, "idlePauseSeconds" => idle_pause_seconds }.compact, idempotency_key: idempotency_key, idempotent: true))
|
|
164
|
+
end
|
|
165
|
+
|
|
166
|
+
# 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.
|
|
167
|
+
def snapshot(id, name: nil, labels: nil, image: nil, start: nil, idempotency_key: nil)
|
|
168
|
+
Stored.from(@transport.request("POST", "/v2/desktops/#{URI.encode_www_form_component(id)}:snapshot", body: { "name" => name, "labels" => labels, "image" => image, "start" => start }.compact, idempotency_key: idempotency_key, idempotent: true))
|
|
169
|
+
end
|
|
170
|
+
|
|
171
|
+
# Changes its name, labels, idle pause, maxCost, environment or sizes; each field left out stays as it is. 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; a smaller size, or a sandbox that is not running, is refused 409 naming why, and nothing is changed. With If-Match, made only while its revision is that one, else 412.
|
|
172
|
+
def update(id, name: nil, labels: nil, idle_pause_seconds: nil, vcpu: nil, memory_gb: nil, disk_gb: nil, user: nil, env: nil, remove_env: nil, max_cost: nil, idempotency_key: nil)
|
|
173
|
+
Sandbox.from(@transport.request("POST", "/v2/desktops/#{URI.encode_www_form_component(id)}:update", body: { "name" => name, "labels" => labels, "idlePauseSeconds" => idle_pause_seconds, "vcpu" => vcpu, "memoryGB" => memory_gb, "diskGB" => disk_gb, "user" => user, "env" => env, "removeEnv" => remove_env, "maxCost" => max_cost }.compact, idempotency_key: idempotency_key))
|
|
174
|
+
end
|
|
175
|
+
|
|
176
|
+
# 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.
|
|
177
|
+
def screenshot(id, format: nil, quality: nil)
|
|
178
|
+
@transport.request("GET", "/v2/desktops/#{URI.encode_www_form_component(id)}/screenshot", query: { "format" => format, "quality" => quality }, raw: true, idempotent: true)
|
|
179
|
+
end
|
|
180
|
+
|
|
181
|
+
# 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.
|
|
182
|
+
def act(id, actions:, idempotency_key: nil)
|
|
183
|
+
Acted.from(@transport.request("POST", "/v2/desktops/#{URI.encode_www_form_component(id)}:act", body: { "actions" => actions }.compact, idempotency_key: idempotency_key))
|
|
184
|
+
end
|
|
185
|
+
|
|
186
|
+
# 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.
|
|
187
|
+
def run_code(id, code:, language: nil, context: nil, timeout_seconds: nil, idempotency_key: nil)
|
|
188
|
+
CodeRun.from(@transport.request("POST", "/v2/desktops/#{URI.encode_www_form_component(id)}:runCode", body: { "code" => code, "language" => language, "context" => context, "timeoutSeconds" => timeout_seconds }.compact, idempotency_key: idempotency_key))
|
|
189
|
+
end
|
|
190
|
+
end
|
|
191
|
+
end
|
|
192
|
+
end
|
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
# Generated by spec-gen from engines/front/crates/spec. Do not edit:
|
|
2
|
+
# change the spec and run `cargo run -p runtime-front-spec-gen -- write`.
|
|
3
|
+
|
|
4
|
+
require "uri"
|
|
5
|
+
require_relative "runtime"
|
|
6
|
+
|
|
7
|
+
module Withruntime
|
|
8
|
+
module Generated
|
|
9
|
+
# A custom domain to add, or to point at another sandbox or port.
|
|
10
|
+
# - +hostname+: The hostname, at most 253 characters.
|
|
11
|
+
# - +sandbox_id+: The sandbox to serve.
|
|
12
|
+
# - +port+: The port inside the sandbox, 1 to 65535.
|
|
13
|
+
DomainCreate = Struct.new(:hostname, :sandbox_id, :port, keyword_init: true) do
|
|
14
|
+
def self.from(h)
|
|
15
|
+
return nil if h.nil?
|
|
16
|
+
|
|
17
|
+
new(
|
|
18
|
+
hostname: h["hostname"],
|
|
19
|
+
sandbox_id: h["sandboxId"],
|
|
20
|
+
port: h["port"],
|
|
21
|
+
)
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
def to_wire
|
|
25
|
+
{
|
|
26
|
+
"hostname" => self.hostname,
|
|
27
|
+
"sandboxId" => self.sandbox_id,
|
|
28
|
+
"port" => self.port,
|
|
29
|
+
}.compact
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
# A custom domain's settings, as it keeps them: the port it serves, and its proof of ownership as facts.
|
|
34
|
+
# - +port+: The port inside the sandbox. At least 1. At most 65535.
|
|
35
|
+
# - +token+: The token the TXT record at `_runtime-challenge.<hostname>` holds as `runtime-verify=<token>`.
|
|
36
|
+
# - +verified_at+: When the TXT record was last found to hold the token; none until it is.
|
|
37
|
+
# - +checked_at+: When the TXT record was last looked up.
|
|
38
|
+
# - +check_error+: What the last lookup found wrong; none when it proved the name.
|
|
39
|
+
DomainSettings = Struct.new(:port, :token, :verified_at, :checked_at, :check_error, keyword_init: true) do
|
|
40
|
+
def self.from(h)
|
|
41
|
+
return nil if h.nil?
|
|
42
|
+
|
|
43
|
+
new(
|
|
44
|
+
port: h["port"],
|
|
45
|
+
token: h["token"],
|
|
46
|
+
verified_at: h["verifiedAt"],
|
|
47
|
+
checked_at: h["checkedAt"],
|
|
48
|
+
check_error: h["checkError"],
|
|
49
|
+
)
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
def to_wire
|
|
53
|
+
{
|
|
54
|
+
"port" => self.port,
|
|
55
|
+
"token" => self.token,
|
|
56
|
+
"verifiedAt" => self.verified_at,
|
|
57
|
+
"checkedAt" => self.checked_at,
|
|
58
|
+
"checkError" => self.check_error,
|
|
59
|
+
}.compact
|
|
60
|
+
end
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
# A custom domain: your own hostname serving a sandbox's port.
|
|
64
|
+
# - +port+: The port inside the sandbox. At least 1. At most 65535.
|
|
65
|
+
# - +token+: The token the TXT record at `_runtime-challenge.<hostname>` holds as `runtime-verify=<token>`.
|
|
66
|
+
# - +verified_at+: When the TXT record was last found to hold the token; none until it is.
|
|
67
|
+
# - +checked_at+: When the TXT record was last looked up.
|
|
68
|
+
# - +check_error+: What the last lookup found wrong; none when it proved the name.
|
|
69
|
+
# - +id+: Its ID.
|
|
70
|
+
# - +object+: Always `domain`.
|
|
71
|
+
# - +hostname+: The hostname, lower case.
|
|
72
|
+
# - +sandbox_id+: The sandbox it serves.
|
|
73
|
+
# - +state+: Its state: `ready` once every serving host routes it.
|
|
74
|
+
# - +disabled+: Turned off by Runtime.
|
|
75
|
+
# - +created_at+: When it was added.
|
|
76
|
+
# - +records+: The DNS records to set: the TXT record that proves the name, and the CNAME that sends visitors here.
|
|
77
|
+
# - +deleted_at+: When it was deleted: a delete's answer, its state `deleted`.
|
|
78
|
+
Domain = Struct.new(:port, :token, :verified_at, :checked_at, :check_error, :id, :object, :hostname, :sandbox_id, :state, :disabled, :created_at, :records, :deleted_at, keyword_init: true) do
|
|
79
|
+
def self.from(h)
|
|
80
|
+
return nil if h.nil?
|
|
81
|
+
|
|
82
|
+
new(
|
|
83
|
+
port: h["port"],
|
|
84
|
+
token: h["token"],
|
|
85
|
+
verified_at: h["verifiedAt"],
|
|
86
|
+
checked_at: h["checkedAt"],
|
|
87
|
+
check_error: h["checkError"],
|
|
88
|
+
id: h["id"],
|
|
89
|
+
object: h["object"],
|
|
90
|
+
hostname: h["hostname"],
|
|
91
|
+
sandbox_id: h["sandboxId"],
|
|
92
|
+
state: h["state"],
|
|
93
|
+
disabled: h["disabled"],
|
|
94
|
+
created_at: h["createdAt"],
|
|
95
|
+
records: h["records"],
|
|
96
|
+
deleted_at: h["deletedAt"],
|
|
97
|
+
)
|
|
98
|
+
end
|
|
99
|
+
|
|
100
|
+
def to_wire
|
|
101
|
+
{
|
|
102
|
+
"port" => self.port,
|
|
103
|
+
"token" => self.token,
|
|
104
|
+
"verifiedAt" => self.verified_at,
|
|
105
|
+
"checkedAt" => self.checked_at,
|
|
106
|
+
"checkError" => self.check_error,
|
|
107
|
+
"id" => self.id,
|
|
108
|
+
"object" => self.object,
|
|
109
|
+
"hostname" => self.hostname,
|
|
110
|
+
"sandboxId" => self.sandbox_id,
|
|
111
|
+
"state" => self.state,
|
|
112
|
+
"disabled" => self.disabled,
|
|
113
|
+
"createdAt" => self.created_at,
|
|
114
|
+
"records" => self.records,
|
|
115
|
+
"deletedAt" => self.deleted_at,
|
|
116
|
+
}.compact
|
|
117
|
+
end
|
|
118
|
+
end
|
|
119
|
+
|
|
120
|
+
# Your own hostname serving a sandbox's port, with HTTPS.
|
|
121
|
+
class Domains
|
|
122
|
+
def initialize(transport)
|
|
123
|
+
@transport = transport
|
|
124
|
+
end
|
|
125
|
+
|
|
126
|
+
# Adds a hostname to serve a sandbox's port, checks its TXT record, and returns the DNS records to set. Asked again with another sandbox or port, it points the name there.
|
|
127
|
+
def create(hostname:, sandbox_id:, port:, idempotency_key: nil)
|
|
128
|
+
Domain.from(@transport.request("POST", "/v2/domains", body: { "hostname" => hostname, "sandboxId" => sandbox_id, "port" => port }.compact, idempotency_key: idempotency_key, idempotent: true))
|
|
129
|
+
end
|
|
130
|
+
|
|
131
|
+
# Lists the org's custom domains, by hostname.
|
|
132
|
+
def list(cursor: nil, limit: nil)
|
|
133
|
+
Generated.page(@transport.request("GET", "/v2/domains", query: { "cursor" => cursor, "limit" => limit }, idempotent: true)) { |i| Domain.from(i) }
|
|
134
|
+
end
|
|
135
|
+
|
|
136
|
+
# Returns a custom domain and the DNS records it needs.
|
|
137
|
+
def get(hostname)
|
|
138
|
+
Domain.from(@transport.request("GET", "/v2/domains/#{URI.encode_www_form_component(hostname)}", idempotent: true))
|
|
139
|
+
end
|
|
140
|
+
|
|
141
|
+
# Checks the TXT record now; the name is served once it matches.
|
|
142
|
+
def verify(hostname, idempotency_key: nil)
|
|
143
|
+
Domain.from(@transport.request("POST", "/v2/domains/#{URI.encode_www_form_component(hostname)}:verify", idempotency_key: idempotency_key, idempotent: true))
|
|
144
|
+
end
|
|
145
|
+
|
|
146
|
+
# Stops serving the hostname. Remove its DNS records too.
|
|
147
|
+
def delete(hostname, idempotency_key: nil)
|
|
148
|
+
Domain.from(@transport.request("DELETE", "/v2/domains/#{URI.encode_www_form_component(hostname)}", idempotency_key: idempotency_key, idempotent: true))
|
|
149
|
+
end
|
|
150
|
+
end
|
|
151
|
+
end
|
|
152
|
+
end
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
# Generated by spec-gen from engines/front/crates/spec. Do not edit:
|
|
2
|
+
# change the spec and run `cargo run -p runtime-front-spec-gen -- write`.
|
|
3
|
+
|
|
4
|
+
require "uri"
|
|
5
|
+
require_relative "runtime"
|
|
6
|
+
|
|
7
|
+
module Withruntime
|
|
8
|
+
module Generated
|
|
9
|
+
# A static egress IP's settings, as it keeps them.
|
|
10
|
+
# - +family+: 4 or 6.
|
|
11
|
+
# - +rate+: Its monthly price when it was reserved, in US dollars (`"5.00"`); it does not change.
|
|
12
|
+
EgressIpSettings = Struct.new(:family, :rate, keyword_init: true) do
|
|
13
|
+
def self.from(h)
|
|
14
|
+
return nil if h.nil?
|
|
15
|
+
|
|
16
|
+
new(
|
|
17
|
+
family: h["family"],
|
|
18
|
+
rate: h["rate"],
|
|
19
|
+
)
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
def to_wire
|
|
23
|
+
{
|
|
24
|
+
"family" => self.family,
|
|
25
|
+
"rate" => self.rate,
|
|
26
|
+
}.compact
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
# A static egress IP: every sandbox of the org sends from it.
|
|
31
|
+
# - +family+: 4 or 6.
|
|
32
|
+
# - +rate+: Its monthly price when it was reserved, in US dollars (`"5.00"`); it does not change.
|
|
33
|
+
# - +id+: Its ID.
|
|
34
|
+
# - +object+: Always `ip`.
|
|
35
|
+
# - +address+: The address.
|
|
36
|
+
# - +state+: Its state: `ready` once sandboxes send from it.
|
|
37
|
+
# - +disabled+: Turned off: its sandboxes send from the shared addresses.
|
|
38
|
+
# - +created_at+: When it was reserved.
|
|
39
|
+
EgressIp = Struct.new(:family, :rate, :id, :object, :address, :state, :disabled, :created_at, keyword_init: true) do
|
|
40
|
+
def self.from(h)
|
|
41
|
+
return nil if h.nil?
|
|
42
|
+
|
|
43
|
+
new(
|
|
44
|
+
family: h["family"],
|
|
45
|
+
rate: h["rate"],
|
|
46
|
+
id: h["id"],
|
|
47
|
+
object: h["object"],
|
|
48
|
+
address: h["address"],
|
|
49
|
+
state: h["state"],
|
|
50
|
+
disabled: h["disabled"],
|
|
51
|
+
created_at: h["createdAt"],
|
|
52
|
+
)
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
def to_wire
|
|
56
|
+
{
|
|
57
|
+
"family" => self.family,
|
|
58
|
+
"rate" => self.rate,
|
|
59
|
+
"id" => self.id,
|
|
60
|
+
"object" => self.object,
|
|
61
|
+
"address" => self.address,
|
|
62
|
+
"state" => self.state,
|
|
63
|
+
"disabled" => self.disabled,
|
|
64
|
+
"createdAt" => self.created_at,
|
|
65
|
+
}.compact
|
|
66
|
+
end
|
|
67
|
+
end
|
|
68
|
+
|
|
69
|
+
# A static egress IP: a public address every sandbox of the org sends from, the same every time, for others' allow-lists.
|
|
70
|
+
class EgressIps
|
|
71
|
+
def initialize(transport)
|
|
72
|
+
@transport = transport
|
|
73
|
+
end
|
|
74
|
+
|
|
75
|
+
# Lists the org's static egress IPs.
|
|
76
|
+
def list(cursor: nil, limit: nil)
|
|
77
|
+
Generated.page(@transport.request("GET", "/v2/egress-ips", query: { "cursor" => cursor, "limit" => limit }, idempotent: true)) { |i| EgressIp.from(i) }
|
|
78
|
+
end
|
|
79
|
+
end
|
|
80
|
+
end
|
|
81
|
+
end
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
# Generated by spec-gen from engines/front/crates/spec. Do not edit:
|
|
2
|
+
# change the spec and run `cargo run -p runtime-front-spec-gen -- write`.
|
|
3
|
+
|
|
4
|
+
require "uri"
|
|
5
|
+
require_relative "runtime"
|
|
6
|
+
|
|
7
|
+
module Withruntime
|
|
8
|
+
module Generated
|
|
9
|
+
# A lifecycle event: what changed, as a webhook is sent it.
|
|
10
|
+
# - +id+: Its ID (`evt_...`), the `runtime-webhook-id` of its webhook delivery.
|
|
11
|
+
# - +object+: Always `event`.
|
|
12
|
+
# - +type+: What happened (`sandbox.created`, `sandbox.paused`), a webhook's `runtime-event-type`.
|
|
13
|
+
# - +resource_id+: The ID of the resource it happened to.
|
|
14
|
+
# - +state+: The resource's state after it, when it says one.
|
|
15
|
+
# - +reason+: Why, when it says why (a stop's or a failure's).
|
|
16
|
+
# - +exit_code+: The exit code of a run that ended.
|
|
17
|
+
# - +created_at+: When it happened.
|
|
18
|
+
Event = Struct.new(:id, :object, :type, :resource_id, :state, :reason, :exit_code, :created_at, keyword_init: true) do
|
|
19
|
+
def self.from(h)
|
|
20
|
+
return nil if h.nil?
|
|
21
|
+
|
|
22
|
+
new(
|
|
23
|
+
id: h["id"],
|
|
24
|
+
object: h["object"],
|
|
25
|
+
type: h["type"],
|
|
26
|
+
resource_id: h["resourceId"],
|
|
27
|
+
state: h["state"],
|
|
28
|
+
reason: h["reason"],
|
|
29
|
+
exit_code: h["exitCode"],
|
|
30
|
+
created_at: h["createdAt"],
|
|
31
|
+
)
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
def to_wire
|
|
35
|
+
{
|
|
36
|
+
"id" => self.id,
|
|
37
|
+
"object" => self.object,
|
|
38
|
+
"type" => self.type,
|
|
39
|
+
"resourceId" => self.resource_id,
|
|
40
|
+
"state" => self.state,
|
|
41
|
+
"reason" => self.reason,
|
|
42
|
+
"exitCode" => self.exit_code,
|
|
43
|
+
"createdAt" => self.created_at,
|
|
44
|
+
}.compact
|
|
45
|
+
end
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
# What changed in the organization, as it changed: each event a webhook or an OpenTelemetry export is sent, kept 14 days.
|
|
49
|
+
class Events
|
|
50
|
+
def initialize(transport)
|
|
51
|
+
@transport = transport
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
# 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`.
|
|
55
|
+
def list(cursor: nil, limit: nil, type: nil, resource_id: nil)
|
|
56
|
+
Generated.page(@transport.request("GET", "/v2/events", query: { "cursor" => cursor, "limit" => limit, "type" => type, "resourceId" => resource_id }, idempotent: true)) { |i| Event.from(i) }
|
|
57
|
+
end
|
|
58
|
+
end
|
|
59
|
+
end
|
|
60
|
+
end
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
# Generated by spec-gen from engines/front/crates/spec. Do not edit:
|
|
2
|
+
# change the spec and run `cargo run -p runtime-front-spec-gen -- write`.
|
|
3
|
+
|
|
4
|
+
require "uri"
|
|
5
|
+
require_relative "runtime"
|
|
6
|
+
|
|
7
|
+
module Withruntime
|
|
8
|
+
module Generated
|
|
9
|
+
# A report to send.
|
|
10
|
+
# - +kind+: `bug`, `missing_feature`, `competitor_gap` (something another provider does better), `migration_blocker` (what stops a move to Runtime), `docs`, `pricing`, `praise` or `other`.
|
|
11
|
+
# - +summary+: One line. At least 1 character. At most 200 characters.
|
|
12
|
+
# - +detail+: What happened, what you expected, how to reproduce. At most 8000 characters.
|
|
13
|
+
# - +competitor+: The other provider, for a gap or a migration (E2B, Daytona, Modal). At most 80 characters.
|
|
14
|
+
# - +resource_id+: The resource it is about. At most 64 characters.
|
|
15
|
+
# - +request_id+: The requestId of the error you are reporting. At most 64 characters.
|
|
16
|
+
# - +page+: The page it is about, for a report from the site. At most 300 characters.
|
|
17
|
+
# - +rating+: A page's rating: 1 helpful, -1 not. At least -1. At most 1.
|
|
18
|
+
# - +contact_email+: An address to reply to, for a report from someone not signed in. At most 254 characters.
|
|
19
|
+
# - +context+: Anything else useful, at most 16 entries of text.
|
|
20
|
+
FeedbackCreate = Struct.new(:kind, :summary, :detail, :competitor, :resource_id, :request_id, :page, :rating, :contact_email, :context, keyword_init: true) do
|
|
21
|
+
def self.from(h)
|
|
22
|
+
return nil if h.nil?
|
|
23
|
+
|
|
24
|
+
new(
|
|
25
|
+
kind: h["kind"],
|
|
26
|
+
summary: h["summary"],
|
|
27
|
+
detail: h["detail"],
|
|
28
|
+
competitor: h["competitor"],
|
|
29
|
+
resource_id: h["resourceId"],
|
|
30
|
+
request_id: h["requestId"],
|
|
31
|
+
page: h["page"],
|
|
32
|
+
rating: h["rating"],
|
|
33
|
+
contact_email: h["contactEmail"],
|
|
34
|
+
context: h["context"],
|
|
35
|
+
)
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
def to_wire
|
|
39
|
+
{
|
|
40
|
+
"kind" => self.kind,
|
|
41
|
+
"summary" => self.summary,
|
|
42
|
+
"detail" => self.detail,
|
|
43
|
+
"competitor" => self.competitor,
|
|
44
|
+
"resourceId" => self.resource_id,
|
|
45
|
+
"requestId" => self.request_id,
|
|
46
|
+
"page" => self.page,
|
|
47
|
+
"rating" => self.rating,
|
|
48
|
+
"contactEmail" => self.contact_email,
|
|
49
|
+
"context" => self.context,
|
|
50
|
+
}.compact
|
|
51
|
+
end
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
# A report as it was received.
|
|
55
|
+
# - +id+: Its ID.
|
|
56
|
+
# - +object+: Always `feedback`.
|
|
57
|
+
# - +kind+: What it is about.
|
|
58
|
+
# - +summary+: Its one line.
|
|
59
|
+
# - +created_at+: When it was received.
|
|
60
|
+
Feedback = Struct.new(:id, :object, :kind, :summary, :created_at, keyword_init: true) do
|
|
61
|
+
def self.from(h)
|
|
62
|
+
return nil if h.nil?
|
|
63
|
+
|
|
64
|
+
new(
|
|
65
|
+
id: h["id"],
|
|
66
|
+
object: h["object"],
|
|
67
|
+
kind: h["kind"],
|
|
68
|
+
summary: h["summary"],
|
|
69
|
+
created_at: h["createdAt"],
|
|
70
|
+
)
|
|
71
|
+
end
|
|
72
|
+
|
|
73
|
+
def to_wire
|
|
74
|
+
{
|
|
75
|
+
"id" => self.id,
|
|
76
|
+
"object" => self.object,
|
|
77
|
+
"kind" => self.kind,
|
|
78
|
+
"summary" => self.summary,
|
|
79
|
+
"createdAt" => self.created_at,
|
|
80
|
+
}.compact
|
|
81
|
+
end
|
|
82
|
+
end
|
|
83
|
+
|
|
84
|
+
# 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.
|
|
85
|
+
class FeedbackClient
|
|
86
|
+
def initialize(transport)
|
|
87
|
+
@transport = transport
|
|
88
|
+
end
|
|
89
|
+
|
|
90
|
+
# Sends a report to Runtime's team. Quote the requestId of an error you hit; never send credentials, private files or user data.
|
|
91
|
+
def create(kind:, summary:, detail: nil, competitor: nil, resource_id: nil, request_id: nil, page: nil, rating: nil, contact_email: nil, context: nil, idempotency_key: nil)
|
|
92
|
+
Feedback.from(@transport.request("POST", "/v2/feedback", body: { "kind" => kind, "summary" => summary, "detail" => detail, "competitor" => competitor, "resourceId" => resource_id, "requestId" => request_id, "page" => page, "rating" => rating, "contactEmail" => contact_email, "context" => context }.compact, idempotency_key: idempotency_key))
|
|
93
|
+
end
|
|
94
|
+
end
|
|
95
|
+
end
|
|
96
|
+
end
|