withruntime 1.0.0 → 1.1.1
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.
- package/CHANGELOG.md +76 -0
- package/README.md +145 -0
- package/dist/generated/agentSessions.d.ts +218 -0
- package/dist/generated/agentSessions.js +154 -0
- package/dist/generated/agents.d.ts +193 -0
- package/dist/generated/agents.js +166 -0
- package/dist/generated/apps.d.ts +87 -28
- package/dist/generated/apps.js +153 -41
- package/dist/generated/audit.d.ts +2 -2
- package/dist/generated/audit.js +3 -3
- package/dist/generated/browsers.d.ts +87 -28
- package/dist/generated/browsers.js +153 -41
- package/dist/generated/builds.d.ts +87 -28
- package/dist/generated/builds.js +153 -41
- package/dist/generated/ci.d.ts +87 -28
- package/dist/generated/ci.js +153 -41
- package/dist/generated/containers.d.ts +87 -28
- package/dist/generated/containers.js +153 -41
- package/dist/generated/desktops.d.ts +89 -30
- package/dist/generated/desktops.js +155 -43
- package/dist/generated/domains.d.ts +52 -15
- package/dist/generated/domains.js +74 -14
- package/dist/generated/egressIps.d.ts +6 -6
- package/dist/generated/egressIps.js +4 -4
- package/dist/generated/events.d.ts +4 -2
- package/dist/generated/events.js +3 -3
- package/dist/generated/feedback.d.ts +1 -1
- package/dist/generated/feedback.js +3 -3
- package/dist/generated/functions.d.ts +87 -28
- package/dist/generated/functions.js +153 -41
- package/dist/generated/identities.d.ts +2 -2
- package/dist/generated/identities.js +5 -5
- package/dist/generated/images.d.ts +68 -14
- package/dist/generated/images.js +96 -15
- package/dist/generated/index.d.ts +9 -0
- package/dist/generated/index.js +12 -0
- package/dist/generated/jobRuns.d.ts +11 -4
- package/dist/generated/jobRuns.js +6 -6
- package/dist/generated/jobs.d.ts +58 -9
- package/dist/generated/jobs.js +98 -14
- package/dist/generated/keys.d.ts +8 -6
- package/dist/generated/keys.js +6 -6
- package/dist/generated/me.d.ts +2 -2
- package/dist/generated/me.js +3 -3
- package/dist/generated/messages.d.ts +67 -0
- package/dist/generated/messages.js +17 -0
- package/dist/generated/networks.d.ts +4 -4
- package/dist/generated/networks.js +4 -4
- package/dist/generated/notebooks.d.ts +87 -28
- package/dist/generated/notebooks.js +153 -41
- package/dist/generated/otel.d.ts +2 -2
- package/dist/generated/otel.js +5 -5
- package/dist/generated/ports.d.ts +11 -11
- package/dist/generated/ports.js +8 -8
- package/dist/generated/previews.d.ts +50 -15
- package/dist/generated/previews.js +70 -18
- package/dist/generated/projects.d.ts +30 -6
- package/dist/generated/projects.js +13 -9
- package/dist/generated/roles.d.ts +11 -2
- package/dist/generated/roles.js +9 -5
- package/dist/generated/routes.js +1 -1
- package/dist/generated/runtime.d.ts +15 -3
- package/dist/generated/runtime.js +31 -18
- package/dist/generated/sandboxes.d.ts +213 -66
- package/dist/generated/sandboxes.js +171 -43
- package/dist/generated/secrets.d.ts +45 -6
- package/dist/generated/secrets.js +69 -9
- package/dist/generated/sessions.d.ts +1 -1
- package/dist/generated/sessions.js +4 -4
- package/dist/generated/signing.js +3 -1
- package/dist/generated/sites.d.ts +87 -28
- package/dist/generated/sites.js +153 -41
- package/dist/generated/snapshots.d.ts +70 -5
- package/dist/generated/snapshots.js +107 -7
- package/dist/generated/tunnels.d.ts +8 -8
- package/dist/generated/tunnels.js +4 -4
- package/dist/generated/usage.d.ts +57 -6
- package/dist/generated/usage.js +4 -4
- package/dist/generated/volumes.d.ts +72 -7
- package/dist/generated/volumes.js +114 -10
- package/dist/generated/webhooks.d.ts +2 -2
- package/dist/generated/webhooks.js +5 -5
- package/dist/generated/workspaces.d.ts +87 -28
- package/dist/generated/workspaces.js +153 -41
- package/dist/v2/bin.d.ts +2 -0
- package/dist/v2/bin.js +15 -0
- package/dist/v2/cli.d.ts +15 -2
- package/dist/v2/cli.js +158 -53
- package/dist/v2/json.d.ts +9 -0
- package/dist/v2/json.js +5 -0
- package/dist/v2/mcp.js +14 -1
- package/dist/v2/openapi.json +7695 -4382
- package/dist/v2/shims/fly.js +49 -13
- package/dist/v2/shims/morph.js +1 -1
- package/dist/v2/table.d.ts +7 -4
- package/dist/v2/table.js +97 -34
- package/package.json +7 -5
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
// Generated by spec-gen from engines/front/crates/spec. Do not edit:
|
|
2
2
|
// change the spec and run `cargo run -p runtime-front-spec-gen -- write`.
|
|
3
|
-
import { Paginated, toBytes, Stream } from "./runtime.js";
|
|
3
|
+
import { Paginated, Transport, toBytes, Stream } from "./runtime.js";
|
|
4
|
+
import { Previews } from "./previews.js";
|
|
4
5
|
/** A sandbox's files. */
|
|
5
6
|
export class SandboxFiles {
|
|
6
7
|
#c;
|
|
@@ -90,6 +91,10 @@ export class SandboxProcesses {
|
|
|
90
91
|
signal(process, input = {}, options) {
|
|
91
92
|
return this.#c.signalProcess(this.#id, process, input, options);
|
|
92
93
|
}
|
|
94
|
+
/** 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. */
|
|
95
|
+
resize(process, input, options) {
|
|
96
|
+
return this.#c.resizeProcess(this.#id, process, input, options);
|
|
97
|
+
}
|
|
93
98
|
/** Lists a sandbox's processes, newest first: those running and those that ended lately. */
|
|
94
99
|
list(options) {
|
|
95
100
|
return this.#c.listProcesses(this.#id, options);
|
|
@@ -112,7 +117,20 @@ export class SandboxNetworkCalls {
|
|
|
112
117
|
return this.#c.setNetwork(this.#id, input, options);
|
|
113
118
|
}
|
|
114
119
|
}
|
|
115
|
-
/**
|
|
120
|
+
/** A sandbox's previews. */
|
|
121
|
+
export class SandboxPreviews {
|
|
122
|
+
#c;
|
|
123
|
+
#id;
|
|
124
|
+
constructor(client, id) {
|
|
125
|
+
this.#c = client;
|
|
126
|
+
this.#id = id;
|
|
127
|
+
}
|
|
128
|
+
/** 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. */
|
|
129
|
+
create(port, input = {}, options) {
|
|
130
|
+
return this.#c.create(this.#id, { ...input, port: port }, options);
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
/** 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. */
|
|
116
134
|
export class Sandbox {
|
|
117
135
|
#c;
|
|
118
136
|
/** What it was when last read. */
|
|
@@ -120,20 +138,118 @@ export class Sandbox {
|
|
|
120
138
|
files;
|
|
121
139
|
processes;
|
|
122
140
|
network;
|
|
141
|
+
previews;
|
|
123
142
|
constructor(client, info) {
|
|
124
143
|
this.#c = client;
|
|
125
144
|
this.info = info;
|
|
126
145
|
this.files = new SandboxFiles(client, info.id);
|
|
127
146
|
this.processes = new SandboxProcesses(client, info.id);
|
|
128
147
|
this.network = new SandboxNetworkCalls(client, info.id);
|
|
148
|
+
this.previews = new SandboxPreviews(new Previews(client.transport), info.id);
|
|
129
149
|
}
|
|
130
150
|
/** Its id. */
|
|
131
151
|
get id() {
|
|
132
152
|
return this.info.id;
|
|
133
153
|
}
|
|
154
|
+
/** Its vCPUs; its product's default when omitted. At least 1. */
|
|
155
|
+
get vcpu() {
|
|
156
|
+
return this.info.vcpu;
|
|
157
|
+
}
|
|
158
|
+
/** 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. */
|
|
159
|
+
get memoryGB() {
|
|
160
|
+
return this.info.memoryGB;
|
|
161
|
+
}
|
|
162
|
+
/** 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. */
|
|
163
|
+
get diskGB() {
|
|
164
|
+
return this.info.diskGB;
|
|
165
|
+
}
|
|
166
|
+
/** The image it boots, by name (its newest version), `name:version` or ID; Runtime's default image when omitted. */
|
|
167
|
+
get image() {
|
|
168
|
+
return this.info.image;
|
|
169
|
+
}
|
|
170
|
+
/** 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. Fixed for its life: a fork or a copy of a snapshot keeps it. At most 64 items. */
|
|
171
|
+
get secrets() {
|
|
172
|
+
return this.info.secrets;
|
|
173
|
+
}
|
|
174
|
+
/** 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. */
|
|
175
|
+
get start() {
|
|
176
|
+
return this.info.start;
|
|
177
|
+
}
|
|
178
|
+
/** 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`. */
|
|
179
|
+
get user() {
|
|
180
|
+
return this.info.user;
|
|
181
|
+
}
|
|
182
|
+
/** Its product's kind: `sandbox` for a sandbox, `app` for an app, and so on. */
|
|
183
|
+
get object() {
|
|
184
|
+
return this.info.object;
|
|
185
|
+
}
|
|
186
|
+
/** Its name, unique in its project. */
|
|
187
|
+
get name() {
|
|
188
|
+
return this.info.name;
|
|
189
|
+
}
|
|
190
|
+
/** Where it is. */
|
|
191
|
+
get state() {
|
|
192
|
+
return this.info.state;
|
|
193
|
+
}
|
|
194
|
+
/** Its labels. */
|
|
195
|
+
get labels() {
|
|
196
|
+
return this.info.labels;
|
|
197
|
+
}
|
|
198
|
+
/** When it was created. */
|
|
199
|
+
get createdAt() {
|
|
200
|
+
return this.info.createdAt;
|
|
201
|
+
}
|
|
202
|
+
/** When it was deleted: a delete's answer alone. */
|
|
203
|
+
get deletedAt() {
|
|
204
|
+
return this.info.deletedAt;
|
|
205
|
+
}
|
|
206
|
+
/** Its revision, changed by every change to it: what an update's If-Match names. */
|
|
207
|
+
get revision() {
|
|
208
|
+
return this.info.revision;
|
|
209
|
+
}
|
|
210
|
+
/** Seconds with nothing happening before it pauses; 0 never. Default: 300. */
|
|
211
|
+
get idlePauseSeconds() {
|
|
212
|
+
return this.info.idlePauseSeconds;
|
|
213
|
+
}
|
|
214
|
+
/** The most it may cost in all, in US dollars; none when it has no such cap. */
|
|
215
|
+
get maxCost() {
|
|
216
|
+
return this.info.maxCost;
|
|
217
|
+
}
|
|
218
|
+
/** 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. */
|
|
219
|
+
get autoWake() {
|
|
220
|
+
return this.info.autoWake;
|
|
221
|
+
}
|
|
222
|
+
/** Its run's exit code, once its run ended; none for one a signal or its timeout ended. */
|
|
223
|
+
get exitCode() {
|
|
224
|
+
return this.info.exitCode;
|
|
225
|
+
}
|
|
226
|
+
/** When its run ended. */
|
|
227
|
+
get endedAt() {
|
|
228
|
+
return this.info.endedAt;
|
|
229
|
+
}
|
|
230
|
+
/** When its pause began (or its run ended), while it is paused. */
|
|
231
|
+
get pausedAt() {
|
|
232
|
+
return this.info.pausedAt;
|
|
233
|
+
}
|
|
234
|
+
/** A create's answer alone, for a start with a ready check: how its wait went. */
|
|
235
|
+
get ready() {
|
|
236
|
+
return this.info.ready;
|
|
237
|
+
}
|
|
238
|
+
/** When Runtime deletes it (`deleteAfterSeconds`), finally: it can't be undone, as its delete can't; none: kept until deleted. */
|
|
239
|
+
get deleteAt() {
|
|
240
|
+
return this.info.deleteAt;
|
|
241
|
+
}
|
|
242
|
+
/** Whether its delete is refused (409 `delete_protected`) until an update turns this off. */
|
|
243
|
+
get deleteProtection() {
|
|
244
|
+
return this.info.deleteProtection;
|
|
245
|
+
}
|
|
246
|
+
/** Makes one and returns it, as `new Runtime().sandboxes.create()` does, with a client of its own: `RUNTIME_API_KEY`, or the key `options` names. */
|
|
247
|
+
static async create(input = {}, options = {}) {
|
|
248
|
+
return new Sandboxes(new Transport(options)).create(input, options);
|
|
249
|
+
}
|
|
134
250
|
/** Returns a sandbox. */
|
|
135
251
|
async refresh(query = {}, options) {
|
|
136
|
-
this.info =
|
|
252
|
+
this.info = (await this.#c.get(this.id, query, options)).info;
|
|
137
253
|
return this;
|
|
138
254
|
}
|
|
139
255
|
/** Deletes a sandbox, its memory and its disk. */
|
|
@@ -166,7 +282,7 @@ export class Sandbox {
|
|
|
166
282
|
snapshot(input = {}, options) {
|
|
167
283
|
return this.#c.snapshot(this.id, input, options);
|
|
168
284
|
}
|
|
169
|
-
/** 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
|
|
285
|
+
/** 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. */
|
|
170
286
|
async update(input = {}, options) {
|
|
171
287
|
this.info = await this.#c.update(this.id, input, options);
|
|
172
288
|
return this;
|
|
@@ -183,6 +299,10 @@ export class Sandbox {
|
|
|
183
299
|
runCode(code, input = {}, options) {
|
|
184
300
|
return this.#c.runCode(this.id, { ...input, code: code }, options);
|
|
185
301
|
}
|
|
302
|
+
/** Starts a command and returns its process at once, while the command runs on. Its output is read with `processes.output` and it is stopped with `processes.signal`. */
|
|
303
|
+
spawn(cmd, input = {}, options) {
|
|
304
|
+
return this.exec(cmd, { ...input, wait: false }, options);
|
|
305
|
+
}
|
|
186
306
|
/** 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. */
|
|
187
307
|
execStream(cmd, input = {}, options) {
|
|
188
308
|
const c = this.#c;
|
|
@@ -192,151 +312,159 @@ export class Sandbox {
|
|
|
192
312
|
return { items: a.chunks, next: a.nextCursor, thing: a.process };
|
|
193
313
|
}, (t, cursor) => t.state !== "running" && cursor >= t.outputBytes);
|
|
194
314
|
}
|
|
315
|
+
/** Deletes it when the `await using` block that holds it ends. */
|
|
316
|
+
async [Symbol.asyncDispose]() {
|
|
317
|
+
await this.delete();
|
|
318
|
+
}
|
|
195
319
|
}
|
|
196
|
-
/** 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
|
|
320
|
+
/** 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. */
|
|
197
321
|
export class Sandboxes {
|
|
198
|
-
|
|
322
|
+
transport;
|
|
199
323
|
constructor(transport) {
|
|
200
|
-
this
|
|
324
|
+
this.transport = transport;
|
|
201
325
|
}
|
|
202
326
|
/** Creates a sandbox. Asked again with the same Idempotency-Key, it returns the same sandbox. */
|
|
203
327
|
async create(input = {}, options) {
|
|
204
|
-
return new Sandbox(this, await this
|
|
328
|
+
return new Sandbox(this, await this.transport.request("POST", `/v2/sandboxes`, { body: input, options, idempotent: true }));
|
|
205
329
|
}
|
|
206
330
|
/** Returns a sandbox. */
|
|
207
331
|
async get(id, query = {}, options) {
|
|
208
|
-
return new Sandbox(this, await this
|
|
332
|
+
return new Sandbox(this, await this.transport.request("GET", `/v2/sandboxes/${encodeURIComponent(id)}`, { query: { ...query }, options, idempotent: true }));
|
|
209
333
|
}
|
|
210
334
|
/** Lists the project's sandboxes, newest first. */
|
|
211
335
|
list(query = {}, options) {
|
|
212
|
-
return new Paginated((cursor) => this
|
|
336
|
+
return new Paginated((cursor) => this.transport.request("GET", `/v2/sandboxes`, { query: { ...query, cursor }, options, idempotent: true }));
|
|
213
337
|
}
|
|
214
338
|
/** Deletes a sandbox, its memory and its disk. */
|
|
215
339
|
delete(id, options) {
|
|
216
|
-
return this
|
|
340
|
+
return this.transport.request("DELETE", `/v2/sandboxes/${encodeURIComponent(id)}`, { options });
|
|
217
341
|
}
|
|
218
342
|
/** Pauses a sandbox with its memory and disk kept. A call to it resumes it. */
|
|
219
343
|
pause(id, options) {
|
|
220
|
-
return this
|
|
344
|
+
return this.transport.request("POST", `/v2/sandboxes/${encodeURIComponent(id)}:pause`, { options });
|
|
221
345
|
}
|
|
222
346
|
/** Resumes a paused sandbox where it was, its memory and processes as they were. */
|
|
223
347
|
resume(id, options) {
|
|
224
|
-
return this
|
|
348
|
+
return this.transport.request("POST", `/v2/sandboxes/${encodeURIComponent(id)}:resume`, { options });
|
|
225
349
|
}
|
|
226
350
|
/** 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. */
|
|
227
351
|
exec(id, input, options) {
|
|
228
|
-
return this
|
|
352
|
+
return this.transport.request("POST", `/v2/sandboxes/${encodeURIComponent(id)}:exec`, { body: input, options, idempotent: true, runs: true, runsSeconds: input.timeoutSeconds });
|
|
229
353
|
}
|
|
230
354
|
/** Returns a file's bytes. */
|
|
231
355
|
read(id, query, options) {
|
|
232
|
-
return this
|
|
356
|
+
return this.transport.request("GET", `/v2/sandboxes/${encodeURIComponent(id)}/files`, { query: { ...query }, raw: true, options, idempotent: true });
|
|
233
357
|
}
|
|
234
358
|
/** 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. */
|
|
235
359
|
write(id, data, query, options) {
|
|
236
|
-
return this
|
|
360
|
+
return this.transport.request("PUT", `/v2/sandboxes/${encodeURIComponent(id)}/files`, { data: toBytes(data), query: { ...query }, options });
|
|
237
361
|
}
|
|
238
362
|
/** 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. */
|
|
239
363
|
processOutput(id, process, query = {}, options) {
|
|
240
|
-
return this
|
|
364
|
+
return this.transport.request("GET", `/v2/sandboxes/${encodeURIComponent(id)}/processes/${encodeURIComponent(process)}/output`, { query: { ...query }, options, idempotent: true });
|
|
241
365
|
}
|
|
242
366
|
/** Sends input to a process started with stdinOpen or a pty, and returns how much of its input it has taken. */
|
|
243
367
|
writeProcess(id, process, input = {}, options) {
|
|
244
|
-
return this
|
|
368
|
+
return this.transport.request("POST", `/v2/sandboxes/${encodeURIComponent(id)}/processes/${encodeURIComponent(process)}:write`, { body: input, options });
|
|
245
369
|
}
|
|
246
370
|
/** Sends a signal to a process and its group; a process that ended is not signalled, so a retry is safe. */
|
|
247
371
|
signalProcess(id, process, input = {}, options) {
|
|
248
|
-
return this
|
|
372
|
+
return this.transport.request("POST", `/v2/sandboxes/${encodeURIComponent(id)}/processes/${encodeURIComponent(process)}:signal`, { body: input, options, idempotent: true });
|
|
373
|
+
}
|
|
374
|
+
/** 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. */
|
|
375
|
+
resizeProcess(id, process, input, options) {
|
|
376
|
+
return this.transport.request("POST", `/v2/sandboxes/${encodeURIComponent(id)}/processes/${encodeURIComponent(process)}:resize`, { body: input, options, idempotent: true });
|
|
249
377
|
}
|
|
250
378
|
/** Lists a sandbox's processes, newest first: those running and those that ended lately. */
|
|
251
379
|
listProcesses(id, options) {
|
|
252
|
-
return this
|
|
380
|
+
return this.transport.request("GET", `/v2/sandboxes/${encodeURIComponent(id)}/processes`, { options, idempotent: true });
|
|
253
381
|
}
|
|
254
382
|
/** Removes a file, a link or a directory (recursive for one with contents). One missing is success, removed false. */
|
|
255
383
|
remove(id, input, options) {
|
|
256
|
-
return this
|
|
384
|
+
return this.transport.request("POST", `/v2/sandboxes/${encodeURIComponent(id)}/files:remove`, { body: input, options });
|
|
257
385
|
}
|
|
258
386
|
/** 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. */
|
|
259
387
|
stat(id, query, options) {
|
|
260
|
-
return this
|
|
388
|
+
return this.transport.request("GET", `/v2/sandboxes/${encodeURIComponent(id)}/files/stat`, { query: { ...query }, options, idempotent: true });
|
|
261
389
|
}
|
|
262
390
|
/** Lists a directory's entries in path order, to a depth. */
|
|
263
391
|
listFiles(id, query = {}, options) {
|
|
264
|
-
return this
|
|
392
|
+
return this.transport.request("GET", `/v2/sandboxes/${encodeURIComponent(id)}/files/list`, { query: { ...query }, options, idempotent: true });
|
|
265
393
|
}
|
|
266
394
|
/** 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. */
|
|
267
395
|
downloadFolder(id, query, options) {
|
|
268
|
-
return this
|
|
396
|
+
return this.transport.request("GET", `/v2/sandboxes/${encodeURIComponent(id)}/files/archive`, { query: { ...query }, raw: true, options, idempotent: true });
|
|
269
397
|
}
|
|
270
398
|
/** 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. */
|
|
271
399
|
uploadFolder(id, data, query, options) {
|
|
272
|
-
return this
|
|
400
|
+
return this.transport.request("PUT", `/v2/sandboxes/${encodeURIComponent(id)}/files/archive`, { data: toBytes(data), query: { ...query }, options, idempotent: true });
|
|
273
401
|
}
|
|
274
402
|
/** 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. */
|
|
275
403
|
beginFolderUpload(id, input, options) {
|
|
276
|
-
return this
|
|
404
|
+
return this.transport.request("POST", `/v2/sandboxes/${encodeURIComponent(id)}/files/archive/uploads`, { body: input, options });
|
|
277
405
|
}
|
|
278
406
|
/** 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. */
|
|
279
407
|
writeFolderUpload(id, upload, data, query = {}, options) {
|
|
280
|
-
return this
|
|
408
|
+
return this.transport.request("PUT", `/v2/sandboxes/${encodeURIComponent(id)}/files/archive/uploads/${encodeURIComponent(upload)}`, { data: toBytes(data), query: { ...query }, options, idempotent: true });
|
|
281
409
|
}
|
|
282
410
|
/** 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. */
|
|
283
411
|
commitFolderUpload(id, upload, options) {
|
|
284
|
-
return this
|
|
412
|
+
return this.transport.request("POST", `/v2/sandboxes/${encodeURIComponent(id)}/files/archive/uploads/${encodeURIComponent(upload)}:commit`, { options, idempotent: true });
|
|
285
413
|
}
|
|
286
414
|
/** Stops a folder upload's tar; what it unpacked so far stays. */
|
|
287
415
|
abortFolderUpload(id, upload, options) {
|
|
288
|
-
return this
|
|
416
|
+
return this.transport.request("POST", `/v2/sandboxes/${encodeURIComponent(id)}/files/archive/uploads/${encodeURIComponent(upload)}:abort`, { options, idempotent: true });
|
|
289
417
|
}
|
|
290
418
|
/** Makes a directory, and its parents unless parents is false. One there already is success, created false. */
|
|
291
419
|
mkdir(id, input, options) {
|
|
292
|
-
return this
|
|
420
|
+
return this.transport.request("POST", `/v2/sandboxes/${encodeURIComponent(id)}/files:mkdir`, { body: input, options, idempotent: true });
|
|
293
421
|
}
|
|
294
422
|
/** 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. */
|
|
295
423
|
rename(id, input, options) {
|
|
296
|
-
return this
|
|
424
|
+
return this.transport.request("POST", `/v2/sandboxes/${encodeURIComponent(id)}/files:rename`, { body: input, options });
|
|
297
425
|
}
|
|
298
426
|
/** 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. */
|
|
299
427
|
link(id, input, options) {
|
|
300
|
-
return this
|
|
428
|
+
return this.transport.request("POST", `/v2/sandboxes/${encodeURIComponent(id)}/files:link`, { body: input, options });
|
|
301
429
|
}
|
|
302
430
|
/** Ends every file link made for a sandbox so far; links made after work. */
|
|
303
431
|
revokeLinks(id, options) {
|
|
304
|
-
return this
|
|
432
|
+
return this.transport.request("POST", `/v2/sandboxes/${encodeURIComponent(id)}/files:revokeLinks`, { options });
|
|
305
433
|
}
|
|
306
434
|
/** Returns where a sandbox may connect out. */
|
|
307
435
|
getNetwork(id, options) {
|
|
308
|
-
return this
|
|
436
|
+
return this.transport.request("GET", `/v2/sandboxes/${encodeURIComponent(id)}/network`, { options, idempotent: true });
|
|
309
437
|
}
|
|
310
438
|
/** 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. */
|
|
311
439
|
metrics(id, query = {}, options) {
|
|
312
|
-
return this
|
|
440
|
+
return this.transport.request("GET", `/v2/sandboxes/${encodeURIComponent(id)}/metrics`, { query: { ...query }, options, idempotent: true });
|
|
313
441
|
}
|
|
314
442
|
/** 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. */
|
|
315
443
|
setNetwork(id, input = {}, options) {
|
|
316
|
-
return this
|
|
444
|
+
return this.transport.request("PUT", `/v2/sandboxes/${encodeURIComponent(id)}/network`, { body: input, options });
|
|
317
445
|
}
|
|
318
446
|
/** 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. */
|
|
319
447
|
fork(id, input = {}, options) {
|
|
320
|
-
return this
|
|
448
|
+
return this.transport.request("POST", `/v2/sandboxes/${encodeURIComponent(id)}:fork`, { body: input, options, idempotent: true });
|
|
321
449
|
}
|
|
322
450
|
/** 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. */
|
|
323
451
|
snapshot(id, input = {}, options) {
|
|
324
|
-
return this
|
|
452
|
+
return this.transport.request("POST", `/v2/sandboxes/${encodeURIComponent(id)}:snapshot`, { body: input, options, idempotent: true });
|
|
325
453
|
}
|
|
326
|
-
/** 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
|
|
454
|
+
/** 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. */
|
|
327
455
|
update(id, input = {}, options) {
|
|
328
|
-
return this
|
|
456
|
+
return this.transport.request("POST", `/v2/sandboxes/${encodeURIComponent(id)}:update`, { body: input, options });
|
|
329
457
|
}
|
|
330
458
|
/** 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. */
|
|
331
459
|
screenshot(id, query = {}, options) {
|
|
332
|
-
return this
|
|
460
|
+
return this.transport.request("GET", `/v2/sandboxes/${encodeURIComponent(id)}/screenshot`, { query: { ...query }, raw: true, options, idempotent: true });
|
|
333
461
|
}
|
|
334
462
|
/** 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. */
|
|
335
463
|
act(id, input, options) {
|
|
336
|
-
return this
|
|
464
|
+
return this.transport.request("POST", `/v2/sandboxes/${encodeURIComponent(id)}:act`, { body: input, options });
|
|
337
465
|
}
|
|
338
466
|
/** 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. */
|
|
339
467
|
runCode(id, input, options) {
|
|
340
|
-
return this
|
|
468
|
+
return this.transport.request("POST", `/v2/sandboxes/${encodeURIComponent(id)}:runCode`, { body: input, options });
|
|
341
469
|
}
|
|
342
470
|
}
|
|
@@ -2,8 +2,10 @@ import type { RequestOptions, Transport } from "./runtime.js";
|
|
|
2
2
|
import { Paginated } from "./runtime.js";
|
|
3
3
|
/** Which machines may use a secret. */
|
|
4
4
|
export interface SecretScope {
|
|
5
|
-
/** Machines with every label of any one of these sets. */
|
|
6
|
-
labelsAny
|
|
5
|
+
/** Machines with every label of any one of these sets. Give this or `none`. */
|
|
6
|
+
labelsAny?: Record<string, string>[];
|
|
7
|
+
/** `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`. */
|
|
8
|
+
none?: boolean;
|
|
7
9
|
}
|
|
8
10
|
/** Which requests to a secret's hosts may carry it. */
|
|
9
11
|
export interface SecretRule {
|
|
@@ -86,6 +88,13 @@ export type SecretListQuery = {
|
|
|
86
88
|
/** The most items the page holds. At least 1. At most 200. Default: 50. */
|
|
87
89
|
limit?: number;
|
|
88
90
|
};
|
|
91
|
+
/** What get takes in its query. */
|
|
92
|
+
export type SecretGetQuery = {
|
|
93
|
+
/** 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. */
|
|
94
|
+
wait?: number;
|
|
95
|
+
/** The state the caller last read, which `wait` waits for it to leave. */
|
|
96
|
+
ifState?: string;
|
|
97
|
+
};
|
|
89
98
|
/** 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>. */
|
|
90
99
|
export declare class Secret {
|
|
91
100
|
#private;
|
|
@@ -94,21 +103,51 @@ export declare class Secret {
|
|
|
94
103
|
constructor(client: Secrets, info: SecretInfo);
|
|
95
104
|
/** Its name. */
|
|
96
105
|
get name(): string;
|
|
106
|
+
/** 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. */
|
|
107
|
+
get visible(): boolean | undefined;
|
|
108
|
+
/** 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. */
|
|
109
|
+
get hosts(): string[] | undefined;
|
|
110
|
+
/** 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. */
|
|
111
|
+
get header(): string | undefined;
|
|
112
|
+
/** The header's value, `{value}` replaced by the secret; `{value}` when omitted. Hidden secrets only. */
|
|
113
|
+
get format(): string | undefined;
|
|
114
|
+
/** 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. */
|
|
115
|
+
get envName(): string | undefined;
|
|
116
|
+
/** The machines that may use it; every machine of the organization when omitted. */
|
|
117
|
+
get scope(): SecretScope | undefined;
|
|
118
|
+
/** How it may be used. Hidden secrets only. */
|
|
119
|
+
get policies(): SecretPolicies | undefined;
|
|
120
|
+
/** Always `secret`. */
|
|
121
|
+
get object(): "secret" | (string & {});
|
|
122
|
+
/** `active` while requests carry it; `deleted` once deleted: a delete's answer. */
|
|
123
|
+
get state(): "active" | "deleted" | (string & {});
|
|
124
|
+
/** What a machine holds in the value's place; none when visible. */
|
|
125
|
+
get placeholder(): string | undefined;
|
|
126
|
+
/** Raised by each change. */
|
|
127
|
+
get version(): number;
|
|
128
|
+
/** Its value's length in bytes. */
|
|
129
|
+
get valueBytes(): number | undefined;
|
|
130
|
+
/** When it was last changed. */
|
|
131
|
+
get updatedAt(): string | undefined;
|
|
132
|
+
/** When it was deleted: a delete's answer, its state `deleted`. */
|
|
133
|
+
get deletedAt(): string | undefined;
|
|
97
134
|
/** Returns a secret, without its value. */
|
|
98
|
-
refresh(options?: RequestOptions): Promise<this>;
|
|
135
|
+
refresh(query?: SecretGetQuery & RequestOptions, options?: RequestOptions): Promise<this>;
|
|
99
136
|
/** 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). */
|
|
100
137
|
set(input?: SecretSet, options?: RequestOptions): Promise<this>;
|
|
101
138
|
/** 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. */
|
|
102
139
|
delete(options?: RequestOptions): Promise<SecretInfo>;
|
|
140
|
+
/** Deletes it when the `await using` block that holds it ends. */
|
|
141
|
+
[Symbol.asyncDispose](): Promise<void>;
|
|
103
142
|
}
|
|
104
143
|
/** 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>. */
|
|
105
144
|
export declare class Secrets {
|
|
106
|
-
|
|
145
|
+
readonly transport: Transport;
|
|
107
146
|
constructor(transport: Transport);
|
|
108
147
|
/** Lists the organization's secrets by name, without their values. */
|
|
109
|
-
list(query?: SecretListQuery, options?: RequestOptions): Paginated<SecretInfo>;
|
|
148
|
+
list(query?: SecretListQuery & RequestOptions, options?: RequestOptions): Paginated<SecretInfo>;
|
|
110
149
|
/** Returns a secret, without its value. */
|
|
111
|
-
get(name: string, options?: RequestOptions): Promise<Secret>;
|
|
150
|
+
get(name: string, query?: SecretGetQuery & RequestOptions, options?: RequestOptions): Promise<Secret>;
|
|
112
151
|
/** 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). */
|
|
113
152
|
set(name: string, input?: SecretSet, options?: RequestOptions): Promise<SecretInfo>;
|
|
114
153
|
/** 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. */
|
|
@@ -14,9 +14,65 @@ export class Secret {
|
|
|
14
14
|
get name() {
|
|
15
15
|
return this.info.name;
|
|
16
16
|
}
|
|
17
|
+
/** 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. */
|
|
18
|
+
get visible() {
|
|
19
|
+
return this.info.visible;
|
|
20
|
+
}
|
|
21
|
+
/** 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. */
|
|
22
|
+
get hosts() {
|
|
23
|
+
return this.info.hosts;
|
|
24
|
+
}
|
|
25
|
+
/** 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. */
|
|
26
|
+
get header() {
|
|
27
|
+
return this.info.header;
|
|
28
|
+
}
|
|
29
|
+
/** The header's value, `{value}` replaced by the secret; `{value}` when omitted. Hidden secrets only. */
|
|
30
|
+
get format() {
|
|
31
|
+
return this.info.format;
|
|
32
|
+
}
|
|
33
|
+
/** 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. */
|
|
34
|
+
get envName() {
|
|
35
|
+
return this.info.envName;
|
|
36
|
+
}
|
|
37
|
+
/** The machines that may use it; every machine of the organization when omitted. */
|
|
38
|
+
get scope() {
|
|
39
|
+
return this.info.scope;
|
|
40
|
+
}
|
|
41
|
+
/** How it may be used. Hidden secrets only. */
|
|
42
|
+
get policies() {
|
|
43
|
+
return this.info.policies;
|
|
44
|
+
}
|
|
45
|
+
/** Always `secret`. */
|
|
46
|
+
get object() {
|
|
47
|
+
return this.info.object;
|
|
48
|
+
}
|
|
49
|
+
/** `active` while requests carry it; `deleted` once deleted: a delete's answer. */
|
|
50
|
+
get state() {
|
|
51
|
+
return this.info.state;
|
|
52
|
+
}
|
|
53
|
+
/** What a machine holds in the value's place; none when visible. */
|
|
54
|
+
get placeholder() {
|
|
55
|
+
return this.info.placeholder;
|
|
56
|
+
}
|
|
57
|
+
/** Raised by each change. */
|
|
58
|
+
get version() {
|
|
59
|
+
return this.info.version;
|
|
60
|
+
}
|
|
61
|
+
/** Its value's length in bytes. */
|
|
62
|
+
get valueBytes() {
|
|
63
|
+
return this.info.valueBytes;
|
|
64
|
+
}
|
|
65
|
+
/** When it was last changed. */
|
|
66
|
+
get updatedAt() {
|
|
67
|
+
return this.info.updatedAt;
|
|
68
|
+
}
|
|
69
|
+
/** When it was deleted: a delete's answer, its state `deleted`. */
|
|
70
|
+
get deletedAt() {
|
|
71
|
+
return this.info.deletedAt;
|
|
72
|
+
}
|
|
17
73
|
/** Returns a secret, without its value. */
|
|
18
|
-
async refresh(options) {
|
|
19
|
-
this.info =
|
|
74
|
+
async refresh(query = {}, options) {
|
|
75
|
+
this.info = (await this.#c.get(this.name, query, options)).info;
|
|
20
76
|
return this;
|
|
21
77
|
}
|
|
22
78
|
/** 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). */
|
|
@@ -28,27 +84,31 @@ export class Secret {
|
|
|
28
84
|
delete(options) {
|
|
29
85
|
return this.#c.delete(this.name, options);
|
|
30
86
|
}
|
|
87
|
+
/** Deletes it when the `await using` block that holds it ends. */
|
|
88
|
+
async [Symbol.asyncDispose]() {
|
|
89
|
+
await this.delete();
|
|
90
|
+
}
|
|
31
91
|
}
|
|
32
92
|
/** 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>. */
|
|
33
93
|
export class Secrets {
|
|
34
|
-
|
|
94
|
+
transport;
|
|
35
95
|
constructor(transport) {
|
|
36
|
-
this
|
|
96
|
+
this.transport = transport;
|
|
37
97
|
}
|
|
38
98
|
/** Lists the organization's secrets by name, without their values. */
|
|
39
99
|
list(query = {}, options) {
|
|
40
|
-
return new Paginated((cursor) => this
|
|
100
|
+
return new Paginated((cursor) => this.transport.request("GET", `/v2/secrets`, { query: { ...query, cursor }, options, idempotent: true }));
|
|
41
101
|
}
|
|
42
102
|
/** Returns a secret, without its value. */
|
|
43
|
-
async get(name, options) {
|
|
44
|
-
return new Secret(this, await this
|
|
103
|
+
async get(name, query = {}, options) {
|
|
104
|
+
return new Secret(this, await this.transport.request("GET", `/v2/secrets/${encodeURIComponent(name)}`, { query: { ...query }, options, idempotent: true }));
|
|
45
105
|
}
|
|
46
106
|
/** 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). */
|
|
47
107
|
set(name, input = {}, options) {
|
|
48
|
-
return this
|
|
108
|
+
return this.transport.request("PUT", `/v2/secrets/${encodeURIComponent(name)}`, { body: input, options, idempotent: true });
|
|
49
109
|
}
|
|
50
110
|
/** 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. */
|
|
51
111
|
delete(name, options) {
|
|
52
|
-
return this
|
|
112
|
+
return this.transport.request("DELETE", `/v2/secrets/${encodeURIComponent(name)}`, { options, idempotent: true });
|
|
53
113
|
}
|
|
54
114
|
}
|
|
@@ -38,7 +38,7 @@ export interface SessionCreated extends Session {
|
|
|
38
38
|
}
|
|
39
39
|
/** 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. */
|
|
40
40
|
export declare class Sessions {
|
|
41
|
-
|
|
41
|
+
readonly transport: Transport;
|
|
42
42
|
constructor(transport: Transport);
|
|
43
43
|
/** 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`. */
|
|
44
44
|
create(input: SessionCreate, options?: RequestOptions): Promise<SessionCreated>;
|
|
@@ -2,16 +2,16 @@
|
|
|
2
2
|
// change the spec and run `cargo run -p runtime-front-spec-gen -- write`.
|
|
3
3
|
/** 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. */
|
|
4
4
|
export class Sessions {
|
|
5
|
-
|
|
5
|
+
transport;
|
|
6
6
|
constructor(transport) {
|
|
7
|
-
this
|
|
7
|
+
this.transport = transport;
|
|
8
8
|
}
|
|
9
9
|
/** 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`. */
|
|
10
10
|
create(input, options) {
|
|
11
|
-
return this
|
|
11
|
+
return this.transport.request("POST", `/v2/sessions`, { body: input, options, idempotent: true });
|
|
12
12
|
}
|
|
13
13
|
/** 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. */
|
|
14
14
|
delete(id, options) {
|
|
15
|
-
return this
|
|
15
|
+
return this.transport.request("DELETE", `/v2/sessions/${encodeURIComponent(id)}`, { options, idempotent: true });
|
|
16
16
|
}
|
|
17
17
|
}
|