withruntime 0.28.0 → 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 -775
- 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 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.
|
|
11
|
+
class Notebooks
|
|
12
|
+
def initialize(transport)
|
|
13
|
+
@transport = transport
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
# Creates a notebook. Asked again with the same Idempotency-Key, it returns the same notebook.
|
|
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/notebooks", 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 notebook.
|
|
22
|
+
def get(id, wait: nil, if_state: nil)
|
|
23
|
+
Sandbox.from(@transport.request("GET", "/v2/notebooks/#{URI.encode_www_form_component(id)}", query: { "wait" => wait, "ifState" => if_state }, idempotent: true))
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
# Lists the project's notebooks, newest first.
|
|
27
|
+
def list(state: nil, name: nil, label: nil, cursor: nil, limit: nil)
|
|
28
|
+
Generated.page(@transport.request("GET", "/v2/notebooks", query: { "state" => state, "name" => name, "label" => label, "cursor" => cursor, "limit" => limit }, idempotent: true)) { |i| Sandbox.from(i) }
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
# Deletes a notebook, its memory and its disk.
|
|
32
|
+
def delete(id, idempotency_key: nil)
|
|
33
|
+
Sandbox.from(@transport.request("DELETE", "/v2/notebooks/#{URI.encode_www_form_component(id)}", idempotency_key: idempotency_key))
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
# Pauses a notebook 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/notebooks/#{URI.encode_www_form_component(id)}:pause", idempotency_key: idempotency_key))
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
# Resumes a paused notebook where it was, its memory and processes as they were.
|
|
42
|
+
def resume(id, idempotency_key: nil)
|
|
43
|
+
Sandbox.from(@transport.request("POST", "/v2/notebooks/#{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 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.
|
|
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/notebooks/#{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/notebooks/#{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/notebooks/#{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/notebooks/#{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/notebooks/#{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/notebooks/#{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 notebook's processes, newest first: those running and those that ended lately.
|
|
77
|
+
def list_processes(id)
|
|
78
|
+
ProcessList.from(@transport.request("GET", "/v2/notebooks/#{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/notebooks/#{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/notebooks/#{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/notebooks/#{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 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.
|
|
97
|
+
def download_folder(id, path:, gzip: nil, user: nil, exclude: nil)
|
|
98
|
+
@transport.request("GET", "/v2/notebooks/#{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 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.
|
|
102
|
+
def upload_folder(id, data, path:, user: nil, idempotency_key: nil)
|
|
103
|
+
FolderUnpacked.from(@transport.request("PUT", "/v2/notebooks/#{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 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.
|
|
107
|
+
def begin_folder_upload(id, path:, gzip: nil, user: nil, idempotency_key: nil)
|
|
108
|
+
FolderUpload.from(@transport.request("POST", "/v2/notebooks/#{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/notebooks/#{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/notebooks/#{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/notebooks/#{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/notebooks/#{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/notebooks/#{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 notebook. A paused notebook 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/notebooks/#{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 notebook so far; links made after work.
|
|
142
|
+
def revoke_links(id, idempotency_key: nil)
|
|
143
|
+
FileLinksRevoked.from(@transport.request("POST", "/v2/notebooks/#{URI.encode_www_form_component(id)}/files:revokeLinks", idempotency_key: idempotency_key))
|
|
144
|
+
end
|
|
145
|
+
|
|
146
|
+
# Returns where a notebook may connect out.
|
|
147
|
+
def get_network(id)
|
|
148
|
+
SandboxNetwork.from(@transport.request("GET", "/v2/notebooks/#{URI.encode_www_form_component(id)}/network", idempotent: true))
|
|
149
|
+
end
|
|
150
|
+
|
|
151
|
+
# 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.
|
|
152
|
+
def metrics(id, range: nil)
|
|
153
|
+
SandboxMetrics.from(@transport.request("GET", "/v2/notebooks/#{URI.encode_www_form_component(id)}/metrics", query: { "range" => range }, idempotent: true))
|
|
154
|
+
end
|
|
155
|
+
|
|
156
|
+
# 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.
|
|
157
|
+
def set_network(id, allow_outbound: nil, deny_outbound: nil, idempotency_key: nil)
|
|
158
|
+
SandboxNetwork.from(@transport.request("PUT", "/v2/notebooks/#{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 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.
|
|
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/notebooks/#{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 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.
|
|
167
|
+
def snapshot(id, name: nil, labels: nil, image: nil, start: nil, idempotency_key: nil)
|
|
168
|
+
Stored.from(@transport.request("POST", "/v2/notebooks/#{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/notebooks/#{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 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.
|
|
177
|
+
def screenshot(id, format: nil, quality: nil)
|
|
178
|
+
@transport.request("GET", "/v2/notebooks/#{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 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.
|
|
182
|
+
def act(id, actions:, idempotency_key: nil)
|
|
183
|
+
Acted.from(@transport.request("POST", "/v2/notebooks/#{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 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.
|
|
187
|
+
def run_code(id, code:, language: nil, context: nil, timeout_seconds: nil, idempotency_key: nil)
|
|
188
|
+
CodeRun.from(@transport.request("POST", "/v2/notebooks/#{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,94 @@
|
|
|
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
|
+
# An OpenTelemetry export to make.
|
|
10
|
+
# - +endpoint+: The OTLP/HTTP endpoint's base URL (https).
|
|
11
|
+
# - +headers+: Headers sent with each request (an API key), at most 16.
|
|
12
|
+
# - +events+: The events to send it; `["*"]` (every one) when omitted.
|
|
13
|
+
ExportCreate = Struct.new(:endpoint, :headers, :events, keyword_init: true) do
|
|
14
|
+
def self.from(h)
|
|
15
|
+
return nil if h.nil?
|
|
16
|
+
|
|
17
|
+
new(
|
|
18
|
+
endpoint: h["endpoint"],
|
|
19
|
+
headers: h["headers"],
|
|
20
|
+
events: h["events"],
|
|
21
|
+
)
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
def to_wire
|
|
25
|
+
{
|
|
26
|
+
"endpoint" => self.endpoint,
|
|
27
|
+
"headers" => self.headers,
|
|
28
|
+
"events" => self.events,
|
|
29
|
+
}.compact
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
# An OpenTelemetry export: the events as OTLP logs, POSTed to `<endpoint>/v1/logs`.
|
|
34
|
+
# - +id+: Its ID.
|
|
35
|
+
# - +object+: Always `otel`.
|
|
36
|
+
# - +endpoint+: The OTLP/HTTP endpoint's base URL (https); in a list, its origin alone.
|
|
37
|
+
# - +header_names+: The names of the headers sent with each request; their values are never shown.
|
|
38
|
+
# - +events+: The events it is sent; `*` for every one.
|
|
39
|
+
# - +state+: `active` while it is sent to; `deleted` once deleted: a delete's answer.
|
|
40
|
+
# - +created_at+: When it was made.
|
|
41
|
+
# - +deleted_at+: When it was deleted: a delete's answer, its state `deleted`.
|
|
42
|
+
Export = Struct.new(:id, :object, :endpoint, :header_names, :events, :state, :created_at, :deleted_at, keyword_init: true) do
|
|
43
|
+
def self.from(h)
|
|
44
|
+
return nil if h.nil?
|
|
45
|
+
|
|
46
|
+
new(
|
|
47
|
+
id: h["id"],
|
|
48
|
+
object: h["object"],
|
|
49
|
+
endpoint: h["endpoint"],
|
|
50
|
+
header_names: h["headerNames"],
|
|
51
|
+
events: h["events"],
|
|
52
|
+
state: h["state"],
|
|
53
|
+
created_at: h["createdAt"],
|
|
54
|
+
deleted_at: h["deletedAt"],
|
|
55
|
+
)
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
def to_wire
|
|
59
|
+
{
|
|
60
|
+
"id" => self.id,
|
|
61
|
+
"object" => self.object,
|
|
62
|
+
"endpoint" => self.endpoint,
|
|
63
|
+
"headerNames" => self.header_names,
|
|
64
|
+
"events" => self.events,
|
|
65
|
+
"state" => self.state,
|
|
66
|
+
"createdAt" => self.created_at,
|
|
67
|
+
"deletedAt" => self.deleted_at,
|
|
68
|
+
}.compact
|
|
69
|
+
end
|
|
70
|
+
end
|
|
71
|
+
|
|
72
|
+
# The org's events as OpenTelemetry logs, sent to your OTLP/HTTP endpoint.
|
|
73
|
+
class Otel
|
|
74
|
+
def initialize(transport)
|
|
75
|
+
@transport = transport
|
|
76
|
+
end
|
|
77
|
+
|
|
78
|
+
# Makes an OpenTelemetry export.
|
|
79
|
+
def create(endpoint:, headers: nil, events: nil, idempotency_key: nil)
|
|
80
|
+
Export.from(@transport.request("POST", "/v2/otel", body: { "endpoint" => endpoint, "headers" => headers, "events" => events }.compact, idempotency_key: idempotency_key))
|
|
81
|
+
end
|
|
82
|
+
|
|
83
|
+
# Lists the org's, oldest first.
|
|
84
|
+
def list(cursor: nil, limit: nil)
|
|
85
|
+
Generated.page(@transport.request("GET", "/v2/otel", query: { "cursor" => cursor, "limit" => limit }, idempotent: true)) { |i| Export.from(i) }
|
|
86
|
+
end
|
|
87
|
+
|
|
88
|
+
# Deletes it: nothing more is sent to it.
|
|
89
|
+
def delete(id, idempotency_key: nil)
|
|
90
|
+
Export.from(@transport.request("DELETE", "/v2/otel/#{URI.encode_www_form_component(id)}", idempotency_key: idempotency_key, idempotent: true))
|
|
91
|
+
end
|
|
92
|
+
end
|
|
93
|
+
end
|
|
94
|
+
end
|
|
@@ -0,0 +1,118 @@
|
|
|
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 public TCP port to open.
|
|
10
|
+
# - +sandbox_id+: The sandbox to carry to.
|
|
11
|
+
# - +port+: The port inside the sandbox, 1 to 65535.
|
|
12
|
+
PortCreate = Struct.new(:sandbox_id, :port, keyword_init: true) do
|
|
13
|
+
def self.from(h)
|
|
14
|
+
return nil if h.nil?
|
|
15
|
+
|
|
16
|
+
new(
|
|
17
|
+
sandbox_id: h["sandboxId"],
|
|
18
|
+
port: h["port"],
|
|
19
|
+
)
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
def to_wire
|
|
23
|
+
{
|
|
24
|
+
"sandboxId" => self.sandbox_id,
|
|
25
|
+
"port" => self.port,
|
|
26
|
+
}.compact
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
# A public TCP port's settings, as it keeps them.
|
|
31
|
+
# - +port+: The port inside the sandbox. At least 1. At most 65535.
|
|
32
|
+
PortSettings = Struct.new(:port, keyword_init: true) do
|
|
33
|
+
def self.from(h)
|
|
34
|
+
return nil if h.nil?
|
|
35
|
+
|
|
36
|
+
new(
|
|
37
|
+
port: h["port"],
|
|
38
|
+
)
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
def to_wire
|
|
42
|
+
{
|
|
43
|
+
"port" => self.port,
|
|
44
|
+
}.compact
|
|
45
|
+
end
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
# A public TCP port: raw TCP from a public address and port to a port of a sandbox.
|
|
49
|
+
# - +port+: The port inside the sandbox. At least 1. At most 65535.
|
|
50
|
+
# - +id+: Its ID.
|
|
51
|
+
# - +object+: Always `port`.
|
|
52
|
+
# - +connect+: `address:publicPort` (`[address]:publicPort` for IPv6), for a client's host and port.
|
|
53
|
+
# - +address+: The public address to connect to.
|
|
54
|
+
# - +public_port+: The public port to connect to.
|
|
55
|
+
# - +sandbox_id+: The sandbox it carries to.
|
|
56
|
+
# - +state+: Its state: `ready` once every edge carries it.
|
|
57
|
+
# - +disabled+: Turned off by Runtime: no connection passes.
|
|
58
|
+
# - +created_at+: When it was opened.
|
|
59
|
+
# - +deleted_at+: When it was deleted: a delete's answer, its state `deleted`.
|
|
60
|
+
Port = Struct.new(:port, :id, :object, :connect, :address, :public_port, :sandbox_id, :state, :disabled, :created_at, :deleted_at, keyword_init: true) do
|
|
61
|
+
def self.from(h)
|
|
62
|
+
return nil if h.nil?
|
|
63
|
+
|
|
64
|
+
new(
|
|
65
|
+
port: h["port"],
|
|
66
|
+
id: h["id"],
|
|
67
|
+
object: h["object"],
|
|
68
|
+
connect: h["connect"],
|
|
69
|
+
address: h["address"],
|
|
70
|
+
public_port: h["publicPort"],
|
|
71
|
+
sandbox_id: h["sandboxId"],
|
|
72
|
+
state: h["state"],
|
|
73
|
+
disabled: h["disabled"],
|
|
74
|
+
created_at: h["createdAt"],
|
|
75
|
+
deleted_at: h["deletedAt"],
|
|
76
|
+
)
|
|
77
|
+
end
|
|
78
|
+
|
|
79
|
+
def to_wire
|
|
80
|
+
{
|
|
81
|
+
"port" => self.port,
|
|
82
|
+
"id" => self.id,
|
|
83
|
+
"object" => self.object,
|
|
84
|
+
"connect" => self.connect,
|
|
85
|
+
"address" => self.address,
|
|
86
|
+
"publicPort" => self.public_port,
|
|
87
|
+
"sandboxId" => self.sandbox_id,
|
|
88
|
+
"state" => self.state,
|
|
89
|
+
"disabled" => self.disabled,
|
|
90
|
+
"createdAt" => self.created_at,
|
|
91
|
+
"deletedAt" => self.deleted_at,
|
|
92
|
+
}.compact
|
|
93
|
+
end
|
|
94
|
+
end
|
|
95
|
+
|
|
96
|
+
# A public TCP port carried to a port of a sandbox: a database, a game server, anything that is not HTTP.
|
|
97
|
+
class Ports
|
|
98
|
+
def initialize(transport)
|
|
99
|
+
@transport = transport
|
|
100
|
+
end
|
|
101
|
+
|
|
102
|
+
# Opens a public TCP port to a port of a sandbox: 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 sandbox and port, it returns the same public port.
|
|
103
|
+
def create(sandbox_id:, port:, idempotency_key: nil)
|
|
104
|
+
Port.from(@transport.request("POST", "/v2/ports", body: { "sandboxId" => sandbox_id, "port" => port }.compact, idempotency_key: idempotency_key, idempotent: true))
|
|
105
|
+
end
|
|
106
|
+
|
|
107
|
+
# Lists the org's public TCP ports, or one sandbox's, by `connect`.
|
|
108
|
+
def list(sandbox_id: nil, cursor: nil, limit: nil)
|
|
109
|
+
Generated.page(@transport.request("GET", "/v2/ports", query: { "sandboxId" => sandbox_id, "cursor" => cursor, "limit" => limit }, idempotent: true)) { |i| Port.from(i) }
|
|
110
|
+
end
|
|
111
|
+
|
|
112
|
+
# Closes a public TCP port and the connections through it.
|
|
113
|
+
def delete(id, idempotency_key: nil)
|
|
114
|
+
Port.from(@transport.request("DELETE", "/v2/ports/#{URI.encode_www_form_component(id)}", idempotency_key: idempotency_key, idempotent: true))
|
|
115
|
+
end
|
|
116
|
+
end
|
|
117
|
+
end
|
|
118
|
+
end
|
|
@@ -0,0 +1,124 @@
|
|
|
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 preview of the sandbox its path names to create, or its visibility and sites to change.
|
|
10
|
+
# - +port+: The port inside the sandbox. At least 1. At most 65535.
|
|
11
|
+
# - +visibility+: `private` (default): a token is needed. `public`: anyone with the address.
|
|
12
|
+
# - +embed_origins+: The sites that may show it in an iframe; omitted on one that exists, kept as it is; empty for any site.
|
|
13
|
+
# - +ttl_seconds+: 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.
|
|
14
|
+
PreviewCreate = Struct.new(:port, :visibility, :embed_origins, :ttl_seconds, keyword_init: true) do
|
|
15
|
+
def self.from(h)
|
|
16
|
+
return nil if h.nil?
|
|
17
|
+
|
|
18
|
+
new(
|
|
19
|
+
port: h["port"],
|
|
20
|
+
visibility: h["visibility"],
|
|
21
|
+
embed_origins: h["embedOrigins"],
|
|
22
|
+
ttl_seconds: h["ttlSeconds"],
|
|
23
|
+
)
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
def to_wire
|
|
27
|
+
{
|
|
28
|
+
"port" => self.port,
|
|
29
|
+
"visibility" => self.visibility,
|
|
30
|
+
"embedOrigins" => self.embed_origins,
|
|
31
|
+
"ttlSeconds" => self.ttl_seconds,
|
|
32
|
+
}.compact
|
|
33
|
+
end
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
# A preview.
|
|
37
|
+
# - +id+: Its ID.
|
|
38
|
+
# - +object+: Always `preview`.
|
|
39
|
+
# - +sandbox_id+: The sandbox whose port it shares.
|
|
40
|
+
# - +port+: The port inside the sandbox.
|
|
41
|
+
# - +visibility+: `private` or `public`.
|
|
42
|
+
# - +url+: Its address. A private one also needs the token.
|
|
43
|
+
# - +state+: Where it is: `ready` once every serving host routes it.
|
|
44
|
+
# - +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.
|
|
45
|
+
# - +token_expires_at+: When this answer's token stops working.
|
|
46
|
+
# - +embed_origins+: The sites that may show it in an iframe; none for any site.
|
|
47
|
+
# - +created_at+: When it was created.
|
|
48
|
+
# - +deleted_at+: When it was deleted: a delete's answer, its state `deleted`.
|
|
49
|
+
Preview = Struct.new(:id, :object, :sandbox_id, :port, :visibility, :url, :state, :token, :token_expires_at, :embed_origins, :created_at, :deleted_at, keyword_init: true) do
|
|
50
|
+
def self.from(h)
|
|
51
|
+
return nil if h.nil?
|
|
52
|
+
|
|
53
|
+
new(
|
|
54
|
+
id: h["id"],
|
|
55
|
+
object: h["object"],
|
|
56
|
+
sandbox_id: h["sandboxId"],
|
|
57
|
+
port: h["port"],
|
|
58
|
+
visibility: h["visibility"],
|
|
59
|
+
url: h["url"],
|
|
60
|
+
state: h["state"],
|
|
61
|
+
token: h["token"],
|
|
62
|
+
token_expires_at: h["tokenExpiresAt"],
|
|
63
|
+
embed_origins: h["embedOrigins"],
|
|
64
|
+
created_at: h["createdAt"],
|
|
65
|
+
deleted_at: h["deletedAt"],
|
|
66
|
+
)
|
|
67
|
+
end
|
|
68
|
+
|
|
69
|
+
def to_wire
|
|
70
|
+
{
|
|
71
|
+
"id" => self.id,
|
|
72
|
+
"object" => self.object,
|
|
73
|
+
"sandboxId" => self.sandbox_id,
|
|
74
|
+
"port" => self.port,
|
|
75
|
+
"visibility" => self.visibility,
|
|
76
|
+
"url" => self.url,
|
|
77
|
+
"state" => self.state,
|
|
78
|
+
"token" => self.token,
|
|
79
|
+
"tokenExpiresAt" => self.token_expires_at,
|
|
80
|
+
"embedOrigins" => self.embed_origins,
|
|
81
|
+
"createdAt" => self.created_at,
|
|
82
|
+
"deletedAt" => self.deleted_at,
|
|
83
|
+
}.compact
|
|
84
|
+
end
|
|
85
|
+
end
|
|
86
|
+
|
|
87
|
+
# A port of a sandbox at a public HTTPS address: private with a signed token, or public.
|
|
88
|
+
class Previews
|
|
89
|
+
def initialize(transport)
|
|
90
|
+
@transport = transport
|
|
91
|
+
end
|
|
92
|
+
|
|
93
|
+
# Shares a port of a sandbox 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.
|
|
94
|
+
def create(id, port:, visibility: nil, embed_origins: nil, ttl_seconds: nil, idempotency_key: nil)
|
|
95
|
+
Preview.from(@transport.request("POST", "/v2/sandboxes/#{URI.encode_www_form_component(id)}/previews", body: { "port" => port, "visibility" => visibility, "embedOrigins" => embed_origins, "ttlSeconds" => ttl_seconds }.compact, idempotency_key: idempotency_key))
|
|
96
|
+
end
|
|
97
|
+
|
|
98
|
+
# Lists a sandbox's previews, lowest port first.
|
|
99
|
+
def list(sandbox_id:, cursor: nil, limit: nil)
|
|
100
|
+
Generated.page(@transport.request("GET", "/v2/previews", query: { "sandboxId" => sandbox_id, "cursor" => cursor, "limit" => limit }, idempotent: true)) { |i| Preview.from(i) }
|
|
101
|
+
end
|
|
102
|
+
|
|
103
|
+
# Returns a preview; `sign` returns one with a token.
|
|
104
|
+
def get(name)
|
|
105
|
+
Preview.from(@transport.request("GET", "/v2/previews/#{URI.encode_www_form_component(name)}", idempotent: true))
|
|
106
|
+
end
|
|
107
|
+
|
|
108
|
+
# Returns a private preview with a new token; tokens signed before keep their own expiry.
|
|
109
|
+
def sign(name, ttl_seconds: nil, idempotency_key: nil)
|
|
110
|
+
Preview.from(@transport.request("POST", "/v2/previews/#{URI.encode_www_form_component(name)}:sign", query: { "ttlSeconds" => ttl_seconds }, idempotency_key: idempotency_key))
|
|
111
|
+
end
|
|
112
|
+
|
|
113
|
+
# Refuses every token signed for a preview so far, and returns a new one.
|
|
114
|
+
def rotate(name, idempotency_key: nil)
|
|
115
|
+
Preview.from(@transport.request("POST", "/v2/previews/#{URI.encode_www_form_component(name)}:rotate", idempotency_key: idempotency_key))
|
|
116
|
+
end
|
|
117
|
+
|
|
118
|
+
# Stops sharing a port.
|
|
119
|
+
def delete(name, idempotency_key: nil)
|
|
120
|
+
Preview.from(@transport.request("DELETE", "/v2/previews/#{URI.encode_www_form_component(name)}", idempotency_key: idempotency_key))
|
|
121
|
+
end
|
|
122
|
+
end
|
|
123
|
+
end
|
|
124
|
+
end
|
|
@@ -0,0 +1,108 @@
|
|
|
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 project: where sandboxes, storage, addresses and keys sit.
|
|
10
|
+
# - +id+: Its ID.
|
|
11
|
+
# - +object+: Always `project`.
|
|
12
|
+
# - +name+: Its name, unique in the organization.
|
|
13
|
+
# - +default+: Whether it is the organization's default project, where a call that names none acts.
|
|
14
|
+
# - +created_at+: When it was made.
|
|
15
|
+
# - +state+: `active`; `deleted` once deleted: a delete's answer.
|
|
16
|
+
# - +deleted_at+: When it was deleted: a delete's answer, its state `deleted`.
|
|
17
|
+
Project = Struct.new(:id, :object, :name, :default, :created_at, :state, :deleted_at, keyword_init: true) do
|
|
18
|
+
def self.from(h)
|
|
19
|
+
return nil if h.nil?
|
|
20
|
+
|
|
21
|
+
new(
|
|
22
|
+
id: h["id"],
|
|
23
|
+
object: h["object"],
|
|
24
|
+
name: h["name"],
|
|
25
|
+
default: h["default"],
|
|
26
|
+
created_at: h["createdAt"],
|
|
27
|
+
state: h["state"],
|
|
28
|
+
deleted_at: h["deletedAt"],
|
|
29
|
+
)
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
def to_wire
|
|
33
|
+
{
|
|
34
|
+
"id" => self.id,
|
|
35
|
+
"object" => self.object,
|
|
36
|
+
"name" => self.name,
|
|
37
|
+
"default" => self.default,
|
|
38
|
+
"createdAt" => self.created_at,
|
|
39
|
+
"state" => self.state,
|
|
40
|
+
"deletedAt" => self.deleted_at,
|
|
41
|
+
}.compact
|
|
42
|
+
end
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
# A new project.
|
|
46
|
+
# - +name+: Its name, unique in the organization. At least 1 character. At most 64 characters.
|
|
47
|
+
ProjectCreate = Struct.new(:name, keyword_init: true) do
|
|
48
|
+
def self.from(h)
|
|
49
|
+
return nil if h.nil?
|
|
50
|
+
|
|
51
|
+
new(
|
|
52
|
+
name: h["name"],
|
|
53
|
+
)
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
def to_wire
|
|
57
|
+
{
|
|
58
|
+
"name" => self.name,
|
|
59
|
+
}.compact
|
|
60
|
+
end
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
# A new name; everything else stays as it is.
|
|
64
|
+
# - +name+: Its name. At least 1 character. At most 64 characters.
|
|
65
|
+
Rename = Struct.new(:name, keyword_init: true) do
|
|
66
|
+
def self.from(h)
|
|
67
|
+
return nil if h.nil?
|
|
68
|
+
|
|
69
|
+
new(
|
|
70
|
+
name: h["name"],
|
|
71
|
+
)
|
|
72
|
+
end
|
|
73
|
+
|
|
74
|
+
def to_wire
|
|
75
|
+
{
|
|
76
|
+
"name" => self.name,
|
|
77
|
+
}.compact
|
|
78
|
+
end
|
|
79
|
+
end
|
|
80
|
+
|
|
81
|
+
# A project: where sandboxes, storage, addresses and keys sit, each in one. Every organization has a default project, where a call that names none acts.
|
|
82
|
+
class Projects
|
|
83
|
+
def initialize(transport)
|
|
84
|
+
@transport = transport
|
|
85
|
+
end
|
|
86
|
+
|
|
87
|
+
# Lists the organization's projects, the default first, then by name.
|
|
88
|
+
def list(cursor: nil, limit: nil)
|
|
89
|
+
Generated.page(@transport.request("GET", "/v2/projects", query: { "cursor" => cursor, "limit" => limit }, idempotent: true)) { |i| Project.from(i) }
|
|
90
|
+
end
|
|
91
|
+
|
|
92
|
+
# Creates a project. A name another project has returns 409. Asked again with the same Idempotency-Key, it returns the same one.
|
|
93
|
+
def create(name:, idempotency_key: nil)
|
|
94
|
+
Project.from(@transport.request("POST", "/v2/projects", body: { "name" => name }.compact, idempotency_key: idempotency_key, idempotent: true))
|
|
95
|
+
end
|
|
96
|
+
|
|
97
|
+
# Renames a project; what is in it stays as it is. A name another project has returns 409.
|
|
98
|
+
def update(id, name:, idempotency_key: nil)
|
|
99
|
+
Project.from(@transport.request("POST", "/v2/projects/#{URI.encode_www_form_component(id)}:update", body: { "name" => name }.compact, idempotency_key: idempotency_key, idempotent: true))
|
|
100
|
+
end
|
|
101
|
+
|
|
102
|
+
# 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 sandbox, storage or an address, returns 409. Deleted again, it returns 404.
|
|
103
|
+
def delete(id, idempotency_key: nil)
|
|
104
|
+
Project.from(@transport.request("DELETE", "/v2/projects/#{URI.encode_www_form_component(id)}", idempotency_key: idempotency_key, idempotent: true))
|
|
105
|
+
end
|
|
106
|
+
end
|
|
107
|
+
end
|
|
108
|
+
end
|