withruntime 0.27.1 → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/withruntime/generated/apps.rb +192 -0
- data/lib/withruntime/generated/audit.rb +78 -0
- data/lib/withruntime/generated/browsers.rb +192 -0
- data/lib/withruntime/generated/builds.rb +192 -0
- data/lib/withruntime/generated/ci.rb +192 -0
- data/lib/withruntime/generated/containers.rb +192 -0
- data/lib/withruntime/generated/desktops.rb +192 -0
- data/lib/withruntime/generated/domains.rb +152 -0
- data/lib/withruntime/generated/egress_ips.rb +81 -0
- data/lib/withruntime/generated/events.rb +60 -0
- data/lib/withruntime/generated/feedback.rb +96 -0
- data/lib/withruntime/generated/functions.rb +192 -0
- data/lib/withruntime/generated/identities.rb +68 -0
- data/lib/withruntime/generated/images.rb +391 -0
- data/lib/withruntime/generated/job_runs.rb +110 -0
- data/lib/withruntime/generated/jobs.rb +333 -0
- data/lib/withruntime/generated/keys.rb +261 -0
- data/lib/withruntime/generated/kit.rb +111 -0
- data/lib/withruntime/generated/me.rb +69 -0
- data/lib/withruntime/generated/networks.rb +72 -0
- data/lib/withruntime/generated/notebooks.rb +192 -0
- data/lib/withruntime/generated/otel.rb +94 -0
- data/lib/withruntime/generated/ports.rb +118 -0
- data/lib/withruntime/generated/previews.rb +124 -0
- data/lib/withruntime/generated/projects.rb +108 -0
- data/lib/withruntime/generated/roles.rb +68 -0
- data/lib/withruntime/generated/routes.rb +11 -0
- data/lib/withruntime/generated/runtime.rb +188 -0
- data/lib/withruntime/generated/sandboxes.rb +1835 -0
- data/lib/withruntime/generated/secrets.rb +294 -0
- data/lib/withruntime/generated/sessions.rb +143 -0
- data/lib/withruntime/generated/sites.rb +192 -0
- data/lib/withruntime/generated/snapshots.rb +32 -0
- data/lib/withruntime/generated/tunnels.rb +165 -0
- data/lib/withruntime/generated/usage.rb +287 -0
- data/lib/withruntime/generated/volumes.rb +61 -0
- data/lib/withruntime/generated/webhooks.rb +91 -0
- data/lib/withruntime/generated/workspaces.rb +192 -0
- data/lib/withruntime/signing.rb +162 -0
- data/lib/withruntime/version.rb +2 -2
- data/lib/withruntime.rb +5 -43
- metadata +45 -35
- data/lib/withruntime/agents.rb +0 -877
- data/lib/withruntime/api_defaults.rb +0 -17
- data/lib/withruntime/apps.rb +0 -377
- data/lib/withruntime/browsers.rb +0 -104
- data/lib/withruntime/builds.rb +0 -218
- data/lib/withruntime/ci.rb +0 -164
- data/lib/withruntime/client.rb +0 -140
- data/lib/withruntime/containers.rb +0 -39
- data/lib/withruntime/credentials.rb +0 -111
- data/lib/withruntime/fields.rb +0 -40
- data/lib/withruntime/file_watch.rb +0 -73
- data/lib/withruntime/images.rb +0 -258
- data/lib/withruntime/network_products.rb +0 -49
- data/lib/withruntime/parity_products.rb +0 -51
- data/lib/withruntime/products.rb +0 -560
- data/lib/withruntime/record.rb +0 -99
- data/lib/withruntime/reservations.rb +0 -76
- data/lib/withruntime/sandbox.rb +0 -770
- data/lib/withruntime/tar.rb +0 -292
- data/lib/withruntime/transport.rb +0 -575
- data/lib/withruntime/tunnel.rb +0 -275
- data/lib/withruntime/wallet.rb +0 -68
- data/lib/withruntime/websocket.rb +0 -384
|
@@ -0,0 +1,261 @@
|
|
|
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 API key, without its secret.
|
|
10
|
+
# - +id+: Its ID.
|
|
11
|
+
# - +object+: Always `key`.
|
|
12
|
+
# - +name+: Its name, as its maker gave it.
|
|
13
|
+
# - +state+: `active` while it works; `deleted` once revoked: a delete's answer.
|
|
14
|
+
# - +account_id+: The person it acts as or for.
|
|
15
|
+
# - +agent_id+: The agent or CI pipeline it acts as.
|
|
16
|
+
# - +project_id+: The one project it acts in; every project its holder reaches when omitted.
|
|
17
|
+
# - +created_at+: When it was made.
|
|
18
|
+
# - +expires_at+: When it stops working; never when omitted.
|
|
19
|
+
# - +last_used_at+: When it was last used.
|
|
20
|
+
# - +max_cost+: The most one request made with it commits, in US dollars.
|
|
21
|
+
# - +spend_cap+: The most the sandboxes made with it, with those of every key made with it, may spend over spendCapWindowSeconds, in US dollars.
|
|
22
|
+
# - +spend_cap_window_seconds+: The rolling window spendCap counts over, in seconds.
|
|
23
|
+
# - +spent+: What it spent over spendCapWindowSeconds (the last 24 hours when it has no spendCap), in US dollars, as spendCap counts it: its sandboxes' and those of every key made with it. Listed and updated keys only.
|
|
24
|
+
# - +deleted_at+: When it was revoked: a delete's answer, its state `deleted`.
|
|
25
|
+
Key = Struct.new(:id, :object, :name, :state, :account_id, :agent_id, :project_id, :created_at, :expires_at, :last_used_at, :max_cost, :spend_cap, :spend_cap_window_seconds, :spent, :deleted_at, keyword_init: true) do
|
|
26
|
+
def self.from(h)
|
|
27
|
+
return nil if h.nil?
|
|
28
|
+
|
|
29
|
+
new(
|
|
30
|
+
id: h["id"],
|
|
31
|
+
object: h["object"],
|
|
32
|
+
name: h["name"],
|
|
33
|
+
state: h["state"],
|
|
34
|
+
account_id: h["accountId"],
|
|
35
|
+
agent_id: h["agentId"],
|
|
36
|
+
project_id: h["projectId"],
|
|
37
|
+
created_at: h["createdAt"],
|
|
38
|
+
expires_at: h["expiresAt"],
|
|
39
|
+
last_used_at: h["lastUsedAt"],
|
|
40
|
+
max_cost: h["maxCost"],
|
|
41
|
+
spend_cap: h["spendCap"],
|
|
42
|
+
spend_cap_window_seconds: h["spendCapWindowSeconds"],
|
|
43
|
+
spent: h["spent"],
|
|
44
|
+
deleted_at: h["deletedAt"],
|
|
45
|
+
)
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
def to_wire
|
|
49
|
+
{
|
|
50
|
+
"id" => self.id,
|
|
51
|
+
"object" => self.object,
|
|
52
|
+
"name" => self.name,
|
|
53
|
+
"state" => self.state,
|
|
54
|
+
"accountId" => self.account_id,
|
|
55
|
+
"agentId" => self.agent_id,
|
|
56
|
+
"projectId" => self.project_id,
|
|
57
|
+
"createdAt" => self.created_at,
|
|
58
|
+
"expiresAt" => self.expires_at,
|
|
59
|
+
"lastUsedAt" => self.last_used_at,
|
|
60
|
+
"maxCost" => self.max_cost,
|
|
61
|
+
"spendCap" => self.spend_cap,
|
|
62
|
+
"spendCapWindowSeconds" => self.spend_cap_window_seconds,
|
|
63
|
+
"spent" => self.spent,
|
|
64
|
+
"deletedAt" => self.deleted_at,
|
|
65
|
+
}.compact
|
|
66
|
+
end
|
|
67
|
+
end
|
|
68
|
+
|
|
69
|
+
# An OAuth client's request for a key, as `/v2/oauth/authorize` received it.
|
|
70
|
+
# - +client_id+: The client's `client_id`.
|
|
71
|
+
# - +redirect_uri+: Where the client is sent back: one of its redirect URIs.
|
|
72
|
+
# - +code_challenge+: Its S256 `code_challenge`.
|
|
73
|
+
# - +state+: Its `state`, sent back unchanged.
|
|
74
|
+
KeyAuthorization = Struct.new(:client_id, :redirect_uri, :code_challenge, :state, keyword_init: true) do
|
|
75
|
+
def self.from(h)
|
|
76
|
+
return nil if h.nil?
|
|
77
|
+
|
|
78
|
+
new(
|
|
79
|
+
client_id: h["clientId"],
|
|
80
|
+
redirect_uri: h["redirectUri"],
|
|
81
|
+
code_challenge: h["codeChallenge"],
|
|
82
|
+
state: h["state"],
|
|
83
|
+
)
|
|
84
|
+
end
|
|
85
|
+
|
|
86
|
+
def to_wire
|
|
87
|
+
{
|
|
88
|
+
"clientId" => self.client_id,
|
|
89
|
+
"redirectUri" => self.redirect_uri,
|
|
90
|
+
"codeChallenge" => self.code_challenge,
|
|
91
|
+
"state" => self.state,
|
|
92
|
+
}.compact
|
|
93
|
+
end
|
|
94
|
+
end
|
|
95
|
+
|
|
96
|
+
# A key to make.
|
|
97
|
+
# - +name+: Its name. At least 1 character. At most 64 characters.
|
|
98
|
+
# - +project_id+: Held to this one project (Growth and up); every project its holder reaches when omitted.
|
|
99
|
+
# - +agent_id+: One of the organization's agents or CI pipelines it acts as, for the caller; the caller itself when omitted.
|
|
100
|
+
# - +expires_in_seconds+: Seconds until it stops working; never when omitted. At least 60. At most 31536000.
|
|
101
|
+
# - +max_cost+: The most one request made with it may commit, in US dollars (`"5.00"`): one asking more is refused 403, and a create that names no maxCost gets this one. Made with a key that has one, at most that key's.
|
|
102
|
+
# - +spend_cap+: The most the sandboxes made with it, with those of every key made with it, may spend over spendCapWindowSeconds, in US dollars, as billed: once reached, a create is refused 403 until the window passes it, and a create that names no maxCost gets what is left as its maxCost. Running sandboxes may pass it. Made with a key that has one, at most that key's, and counted in it too.
|
|
103
|
+
# - +spend_cap_window_seconds+: The rolling window spendCap counts over, in seconds; a day when omitted. At least 60. At most 2592000.
|
|
104
|
+
# - +user_code+: The code a device shows (OAuth 2.0 device flow, RFC 8628): the key goes to that device, never in this answer.
|
|
105
|
+
# - +authorization+: An OAuth client's request (authorization code with PKCE): the key goes to that client, never in this answer.
|
|
106
|
+
KeyCreate = Struct.new(:name, :project_id, :agent_id, :expires_in_seconds, :max_cost, :spend_cap, :spend_cap_window_seconds, :user_code, :authorization, keyword_init: true) do
|
|
107
|
+
def self.from(h)
|
|
108
|
+
return nil if h.nil?
|
|
109
|
+
|
|
110
|
+
new(
|
|
111
|
+
name: h["name"],
|
|
112
|
+
project_id: h["projectId"],
|
|
113
|
+
agent_id: h["agentId"],
|
|
114
|
+
expires_in_seconds: h["expiresInSeconds"],
|
|
115
|
+
max_cost: h["maxCost"],
|
|
116
|
+
spend_cap: h["spendCap"],
|
|
117
|
+
spend_cap_window_seconds: h["spendCapWindowSeconds"],
|
|
118
|
+
user_code: h["userCode"],
|
|
119
|
+
authorization: KeyAuthorization.from(h["authorization"]),
|
|
120
|
+
)
|
|
121
|
+
end
|
|
122
|
+
|
|
123
|
+
def to_wire
|
|
124
|
+
{
|
|
125
|
+
"name" => self.name,
|
|
126
|
+
"projectId" => self.project_id,
|
|
127
|
+
"agentId" => self.agent_id,
|
|
128
|
+
"expiresInSeconds" => self.expires_in_seconds,
|
|
129
|
+
"maxCost" => self.max_cost,
|
|
130
|
+
"spendCap" => self.spend_cap,
|
|
131
|
+
"spendCapWindowSeconds" => self.spend_cap_window_seconds,
|
|
132
|
+
"userCode" => self.user_code,
|
|
133
|
+
"authorization" => self.authorization&.to_wire,
|
|
134
|
+
}.compact
|
|
135
|
+
end
|
|
136
|
+
end
|
|
137
|
+
|
|
138
|
+
# A key just made, with its secret: shown this once, never again.
|
|
139
|
+
# - +id+: Its ID.
|
|
140
|
+
# - +object+: Always `key`.
|
|
141
|
+
# - +name+: Its name, as its maker gave it.
|
|
142
|
+
# - +state+: `active` while it works; `deleted` once revoked: a delete's answer.
|
|
143
|
+
# - +account_id+: The person it acts as or for.
|
|
144
|
+
# - +agent_id+: The agent or CI pipeline it acts as.
|
|
145
|
+
# - +project_id+: The one project it acts in; every project its holder reaches when omitted.
|
|
146
|
+
# - +created_at+: When it was made.
|
|
147
|
+
# - +expires_at+: When it stops working; never when omitted.
|
|
148
|
+
# - +last_used_at+: When it was last used.
|
|
149
|
+
# - +max_cost+: The most one request made with it commits, in US dollars.
|
|
150
|
+
# - +spend_cap+: The most the sandboxes made with it, with those of every key made with it, may spend over spendCapWindowSeconds, in US dollars.
|
|
151
|
+
# - +spend_cap_window_seconds+: The rolling window spendCap counts over, in seconds.
|
|
152
|
+
# - +spent+: What it spent over spendCapWindowSeconds (the last 24 hours when it has no spendCap), in US dollars, as spendCap counts it: its sandboxes' and those of every key made with it. Listed and updated keys only.
|
|
153
|
+
# - +deleted_at+: When it was revoked: a delete's answer, its state `deleted`.
|
|
154
|
+
# - +secret+: The key itself, to send as `Authorization: Bearer <secret>`; omitted for a key a device or an OAuth client collects.
|
|
155
|
+
# - +redirect_to+: For an OAuth client's key: where to send the person, with the code the client exchanges for it.
|
|
156
|
+
KeyCreated = Struct.new(:id, :object, :name, :state, :account_id, :agent_id, :project_id, :created_at, :expires_at, :last_used_at, :max_cost, :spend_cap, :spend_cap_window_seconds, :spent, :deleted_at, :secret, :redirect_to, keyword_init: true) do
|
|
157
|
+
def self.from(h)
|
|
158
|
+
return nil if h.nil?
|
|
159
|
+
|
|
160
|
+
new(
|
|
161
|
+
id: h["id"],
|
|
162
|
+
object: h["object"],
|
|
163
|
+
name: h["name"],
|
|
164
|
+
state: h["state"],
|
|
165
|
+
account_id: h["accountId"],
|
|
166
|
+
agent_id: h["agentId"],
|
|
167
|
+
project_id: h["projectId"],
|
|
168
|
+
created_at: h["createdAt"],
|
|
169
|
+
expires_at: h["expiresAt"],
|
|
170
|
+
last_used_at: h["lastUsedAt"],
|
|
171
|
+
max_cost: h["maxCost"],
|
|
172
|
+
spend_cap: h["spendCap"],
|
|
173
|
+
spend_cap_window_seconds: h["spendCapWindowSeconds"],
|
|
174
|
+
spent: h["spent"],
|
|
175
|
+
deleted_at: h["deletedAt"],
|
|
176
|
+
secret: h["secret"],
|
|
177
|
+
redirect_to: h["redirectTo"],
|
|
178
|
+
)
|
|
179
|
+
end
|
|
180
|
+
|
|
181
|
+
def to_wire
|
|
182
|
+
{
|
|
183
|
+
"id" => self.id,
|
|
184
|
+
"object" => self.object,
|
|
185
|
+
"name" => self.name,
|
|
186
|
+
"state" => self.state,
|
|
187
|
+
"accountId" => self.account_id,
|
|
188
|
+
"agentId" => self.agent_id,
|
|
189
|
+
"projectId" => self.project_id,
|
|
190
|
+
"createdAt" => self.created_at,
|
|
191
|
+
"expiresAt" => self.expires_at,
|
|
192
|
+
"lastUsedAt" => self.last_used_at,
|
|
193
|
+
"maxCost" => self.max_cost,
|
|
194
|
+
"spendCap" => self.spend_cap,
|
|
195
|
+
"spendCapWindowSeconds" => self.spend_cap_window_seconds,
|
|
196
|
+
"spent" => self.spent,
|
|
197
|
+
"deletedAt" => self.deleted_at,
|
|
198
|
+
"secret" => self.secret,
|
|
199
|
+
"redirectTo" => self.redirect_to,
|
|
200
|
+
}.compact
|
|
201
|
+
end
|
|
202
|
+
end
|
|
203
|
+
|
|
204
|
+
# A change to a key: each field left out stays as it is.
|
|
205
|
+
# - +name+: Its name. At least 1 character. At most 64 characters.
|
|
206
|
+
# - +max_cost+: The most one request made with it may commit, in US dollars (`"5.00"`). Never more than a key it was made with, nor than the key that changes it: a key never raises its own caps.
|
|
207
|
+
# - +spend_cap+: The most the sandboxes made with it, with those of every key made with it, may spend over spendCapWindowSeconds, in US dollars, as billed. Never more than a key it was made with, nor than the key that changes it.
|
|
208
|
+
# - +spend_cap_window_seconds+: The rolling window spendCap counts over, in seconds; kept when omitted, a day for a key that had no spendCap. At least 60. At most 2592000.
|
|
209
|
+
# - +remove+: Caps to remove: `maxCost`, `spendCap`. The key is then held only by the caps of the keys it was made with and of its holder's grants.
|
|
210
|
+
KeyUpdate = Struct.new(:name, :max_cost, :spend_cap, :spend_cap_window_seconds, :remove, keyword_init: true) do
|
|
211
|
+
def self.from(h)
|
|
212
|
+
return nil if h.nil?
|
|
213
|
+
|
|
214
|
+
new(
|
|
215
|
+
name: h["name"],
|
|
216
|
+
max_cost: h["maxCost"],
|
|
217
|
+
spend_cap: h["spendCap"],
|
|
218
|
+
spend_cap_window_seconds: h["spendCapWindowSeconds"],
|
|
219
|
+
remove: h["remove"],
|
|
220
|
+
)
|
|
221
|
+
end
|
|
222
|
+
|
|
223
|
+
def to_wire
|
|
224
|
+
{
|
|
225
|
+
"name" => self.name,
|
|
226
|
+
"maxCost" => self.max_cost,
|
|
227
|
+
"spendCap" => self.spend_cap,
|
|
228
|
+
"spendCapWindowSeconds" => self.spend_cap_window_seconds,
|
|
229
|
+
"remove" => self.remove,
|
|
230
|
+
}.compact
|
|
231
|
+
end
|
|
232
|
+
end
|
|
233
|
+
|
|
234
|
+
# An API key: what a program, an agent or a CI pipeline calls the API with, acting as the person or agent who made it and never reaching more. Its secret is shown once, when it is made.
|
|
235
|
+
class Keys
|
|
236
|
+
def initialize(transport)
|
|
237
|
+
@transport = transport
|
|
238
|
+
end
|
|
239
|
+
|
|
240
|
+
# Lists the organization's live keys, newest first, without their secrets: every key for an owner or an admin, the caller's own otherwise.
|
|
241
|
+
def list(cursor: nil, limit: nil)
|
|
242
|
+
Generated.page(@transport.request("GET", "/v2/keys", query: { "cursor" => cursor, "limit" => limit }, idempotent: true)) { |i| Key.from(i) }
|
|
243
|
+
end
|
|
244
|
+
|
|
245
|
+
# Makes a key that acts as the caller, or as one of the organization's agents for the caller, and returns its secret this once. With `userCode` or `authorization`, the key goes to the device or OAuth client that asked for it instead, which collects it once from `/v2/oauth/token`. A key made with a key works until its own end, never past that key's: it lives on when that key is revoked, so a key is rotated by making its next with it.
|
|
246
|
+
def create(name:, project_id: nil, agent_id: nil, expires_in_seconds: nil, max_cost: nil, spend_cap: nil, spend_cap_window_seconds: nil, user_code: nil, authorization: nil, idempotency_key: nil)
|
|
247
|
+
KeyCreated.from(@transport.request("POST", "/v2/keys", body: { "name" => name, "projectId" => project_id, "agentId" => agent_id, "expiresInSeconds" => expires_in_seconds, "maxCost" => max_cost, "spendCap" => spend_cap, "spendCapWindowSeconds" => spend_cap_window_seconds, "userCode" => user_code, "authorization" => authorization }.compact, idempotency_key: idempotency_key))
|
|
248
|
+
end
|
|
249
|
+
|
|
250
|
+
# Renames a key, or sets or removes its caps (`maxCost`, `spendCap`); its secret stays as it is. A cap is never set above that of a key it was made with, nor above the caller's own key's, so a key never raises its own caps. An owner or an admin changes any key of the organization; everyone else, their own.
|
|
251
|
+
def update(id, name: nil, max_cost: nil, spend_cap: nil, spend_cap_window_seconds: nil, remove: nil, idempotency_key: nil)
|
|
252
|
+
Key.from(@transport.request("POST", "/v2/keys/#{URI.encode_www_form_component(id)}:update", body: { "name" => name, "maxCost" => max_cost, "spendCap" => spend_cap, "spendCapWindowSeconds" => spend_cap_window_seconds, "remove" => remove }.compact, idempotency_key: idempotency_key, idempotent: true))
|
|
253
|
+
end
|
|
254
|
+
|
|
255
|
+
# Revokes a key: refused from its next call, with the hand-off tokens made from it; a key made with it works on. An owner or an admin revokes any key of the organization; everyone else, their own. Revoked again, it returns 404.
|
|
256
|
+
def delete(id, idempotency_key: nil)
|
|
257
|
+
Key.from(@transport.request("DELETE", "/v2/keys/#{URI.encode_www_form_component(id)}", idempotency_key: idempotency_key, idempotent: true))
|
|
258
|
+
end
|
|
259
|
+
end
|
|
260
|
+
end
|
|
261
|
+
end
|
|
@@ -0,0 +1,111 @@
|
|
|
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_relative "runtime"
|
|
5
|
+
require_relative "routes"
|
|
6
|
+
require_relative "sandboxes"
|
|
7
|
+
require_relative "functions"
|
|
8
|
+
require_relative "secrets"
|
|
9
|
+
require_relative "apps"
|
|
10
|
+
require_relative "sites"
|
|
11
|
+
require_relative "ci"
|
|
12
|
+
require_relative "browsers"
|
|
13
|
+
require_relative "desktops"
|
|
14
|
+
require_relative "notebooks"
|
|
15
|
+
require_relative "workspaces"
|
|
16
|
+
require_relative "containers"
|
|
17
|
+
require_relative "builds"
|
|
18
|
+
require_relative "jobs"
|
|
19
|
+
require_relative "job_runs"
|
|
20
|
+
require_relative "snapshots"
|
|
21
|
+
require_relative "images"
|
|
22
|
+
require_relative "volumes"
|
|
23
|
+
require_relative "sessions"
|
|
24
|
+
require_relative "keys"
|
|
25
|
+
require_relative "projects"
|
|
26
|
+
require_relative "identities"
|
|
27
|
+
require_relative "roles"
|
|
28
|
+
require_relative "audit"
|
|
29
|
+
require_relative "me"
|
|
30
|
+
require_relative "usage"
|
|
31
|
+
require_relative "previews"
|
|
32
|
+
require_relative "domains"
|
|
33
|
+
require_relative "ports"
|
|
34
|
+
require_relative "egress_ips"
|
|
35
|
+
require_relative "tunnels"
|
|
36
|
+
require_relative "networks"
|
|
37
|
+
require_relative "webhooks"
|
|
38
|
+
require_relative "events"
|
|
39
|
+
require_relative "otel"
|
|
40
|
+
require_relative "feedback"
|
|
41
|
+
|
|
42
|
+
module Withruntime
|
|
43
|
+
module Generated
|
|
44
|
+
# Every product's client over one transport.
|
|
45
|
+
class Runtime
|
|
46
|
+
attr_reader :transport, :sandboxes, :functions, :secrets, :apps, :sites, :ci, :browsers, :desktops, :notebooks, :workspaces, :containers, :builds, :jobs, :job_runs, :snapshots, :images, :volumes, :sessions, :keys, :projects, :identities, :roles, :audit, :me, :usage, :previews, :domains, :ports, :egress_ips, :tunnels, :networks, :webhooks, :events, :otel, :feedback
|
|
47
|
+
|
|
48
|
+
def initialize(**options)
|
|
49
|
+
@transport = Transport.new(**options)
|
|
50
|
+
@sandboxes = Sandboxes.new(@transport)
|
|
51
|
+
@functions = Functions.new(@transport)
|
|
52
|
+
@secrets = Secrets.new(@transport)
|
|
53
|
+
@apps = Apps.new(@transport)
|
|
54
|
+
@sites = Sites.new(@transport)
|
|
55
|
+
@ci = Ci.new(@transport)
|
|
56
|
+
@browsers = Browsers.new(@transport)
|
|
57
|
+
@desktops = Desktops.new(@transport)
|
|
58
|
+
@notebooks = Notebooks.new(@transport)
|
|
59
|
+
@workspaces = Workspaces.new(@transport)
|
|
60
|
+
@containers = Containers.new(@transport)
|
|
61
|
+
@builds = Builds.new(@transport)
|
|
62
|
+
@jobs = Jobs.new(@transport)
|
|
63
|
+
@job_runs = JobRuns.new(@transport)
|
|
64
|
+
@snapshots = Snapshots.new(@transport)
|
|
65
|
+
@images = Images.new(@transport)
|
|
66
|
+
@volumes = Volumes.new(@transport)
|
|
67
|
+
@sessions = Sessions.new(@transport)
|
|
68
|
+
@keys = Keys.new(@transport)
|
|
69
|
+
@projects = Projects.new(@transport)
|
|
70
|
+
@identities = Identities.new(@transport)
|
|
71
|
+
@roles = Roles.new(@transport)
|
|
72
|
+
@audit = Audit.new(@transport)
|
|
73
|
+
@me = MeClient.new(@transport)
|
|
74
|
+
@usage = UsageClient.new(@transport)
|
|
75
|
+
@previews = Previews.new(@transport)
|
|
76
|
+
@domains = Domains.new(@transport)
|
|
77
|
+
@ports = Ports.new(@transport)
|
|
78
|
+
@egress_ips = EgressIps.new(@transport)
|
|
79
|
+
@tunnels = Tunnels.new(@transport)
|
|
80
|
+
@networks = Networks.new(@transport)
|
|
81
|
+
@webhooks = Webhooks.new(@transport)
|
|
82
|
+
@events = Events.new(@transport)
|
|
83
|
+
@otel = Otel.new(@transport)
|
|
84
|
+
@feedback = FeedbackClient.new(@transport)
|
|
85
|
+
@served = nil
|
|
86
|
+
end
|
|
87
|
+
|
|
88
|
+
# Calls any verb by its name, "product.verb" ("sandboxes.create"), with
|
|
89
|
+
# its arguments by name: its path's parts, its query's fields and its
|
|
90
|
+
# body's. A verb newer than this SDK is found in the API's own served
|
|
91
|
+
# description, so it is callable before the SDK is updated.
|
|
92
|
+
def call(name, args = {}, idempotency_key: nil)
|
|
93
|
+
route = ROUTES[name] || (@served ||= Generated.routes_of(@transport.request("GET", "/v2/openapi.json", idempotent: true)))[name]
|
|
94
|
+
raise ArgumentError, "No verb #{name}: GET /v2/openapi.json names each." unless route
|
|
95
|
+
|
|
96
|
+
Generated.call_route(@transport, route, args, idempotency_key: idempotency_key)
|
|
97
|
+
end
|
|
98
|
+
|
|
99
|
+
# Runs a command in a new sandbox and deletes the sandbox after, whether the command succeeded or not. Returns the command's result.
|
|
100
|
+
def run(cmd:, image: nil, vcpu: nil, memory_gb: nil, cwd: nil, env: nil, stdin: nil, timeout_seconds: nil)
|
|
101
|
+
a0 = call("sandboxes.create", { "image" => image, "vcpu" => vcpu, "memoryGB" => memory_gb })
|
|
102
|
+
begin
|
|
103
|
+
a1 = call("sandboxes.exec", { "id" => a0["id"], "cmd" => cmd, "cwd" => cwd, "env" => env, "stdin" => stdin, "timeoutSeconds" => timeout_seconds })
|
|
104
|
+
a1
|
|
105
|
+
ensure
|
|
106
|
+
call("sandboxes.delete", { "id" => a0["id"] })
|
|
107
|
+
end
|
|
108
|
+
end
|
|
109
|
+
end
|
|
110
|
+
end
|
|
111
|
+
end
|
|
@@ -0,0 +1,69 @@
|
|
|
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
|
+
# Who is calling: the key, the agent it is, the org it acts for, and what admits it.
|
|
10
|
+
# - +object+: Always `me`.
|
|
11
|
+
# - +org_id+: The organization the key acts for.
|
|
12
|
+
# - +org_name+: The organization's name, as its members see it.
|
|
13
|
+
# - +plan+: Its plan on the price card.
|
|
14
|
+
# - +key_id+: The key's ID.
|
|
15
|
+
# - +agent_id+: Who the key acts as: an agent, a CI pipeline, a team or a person, by its ID.
|
|
16
|
+
# - +project_id+: The project the call acts in.
|
|
17
|
+
# - +project_name+: The project's name.
|
|
18
|
+
# - +role+: The built-in role of the grant that admits it (owner, admin, developer, viewer, billing); none for an org's own role.
|
|
19
|
+
# - +scope+: What a call that names no resource reaches: `org` (the whole organization) or `project` (the key's project alone).
|
|
20
|
+
# - +billing+: How the organization pays: `test` (no card yet: every call is answered, and nothing runs or is billed), `trial`, `live`, `grace` (a payment is due; work runs until it pauses) or `paused` (work paused until paid; nothing deleted).
|
|
21
|
+
Me = Struct.new(:object, :org_id, :org_name, :plan, :key_id, :agent_id, :project_id, :project_name, :role, :scope, :billing, keyword_init: true) do
|
|
22
|
+
def self.from(h)
|
|
23
|
+
return nil if h.nil?
|
|
24
|
+
|
|
25
|
+
new(
|
|
26
|
+
object: h["object"],
|
|
27
|
+
org_id: h["orgId"],
|
|
28
|
+
org_name: h["orgName"],
|
|
29
|
+
plan: h["plan"],
|
|
30
|
+
key_id: h["keyId"],
|
|
31
|
+
agent_id: h["agentId"],
|
|
32
|
+
project_id: h["projectId"],
|
|
33
|
+
project_name: h["projectName"],
|
|
34
|
+
role: h["role"],
|
|
35
|
+
scope: h["scope"],
|
|
36
|
+
billing: h["billing"],
|
|
37
|
+
)
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
def to_wire
|
|
41
|
+
{
|
|
42
|
+
"object" => self.object,
|
|
43
|
+
"orgId" => self.org_id,
|
|
44
|
+
"orgName" => self.org_name,
|
|
45
|
+
"plan" => self.plan,
|
|
46
|
+
"keyId" => self.key_id,
|
|
47
|
+
"agentId" => self.agent_id,
|
|
48
|
+
"projectId" => self.project_id,
|
|
49
|
+
"projectName" => self.project_name,
|
|
50
|
+
"role" => self.role,
|
|
51
|
+
"scope" => self.scope,
|
|
52
|
+
"billing" => self.billing,
|
|
53
|
+
}.compact
|
|
54
|
+
end
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
# Who is calling: the key, the organization it acts for, its project, and the role that admits it.
|
|
58
|
+
class MeClient
|
|
59
|
+
def initialize(transport)
|
|
60
|
+
@transport = transport
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
# Returns who the key is: the agent it acts as, its organization, plan, project and the role that admits it.
|
|
64
|
+
def get()
|
|
65
|
+
Me.from(@transport.request("GET", "/v2/me", idempotent: true))
|
|
66
|
+
end
|
|
67
|
+
end
|
|
68
|
+
end
|
|
69
|
+
end
|
|
@@ -0,0 +1,72 @@
|
|
|
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 private network's settings, as it keeps them.
|
|
10
|
+
# - +members+: The machines in it, by ID; none for every sandbox of the org.
|
|
11
|
+
NetworkSettings = Struct.new(:members, keyword_init: true) do
|
|
12
|
+
def self.from(h)
|
|
13
|
+
return nil if h.nil?
|
|
14
|
+
|
|
15
|
+
new(
|
|
16
|
+
members: h["members"],
|
|
17
|
+
)
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
def to_wire
|
|
21
|
+
{
|
|
22
|
+
"members" => self.members,
|
|
23
|
+
}.compact
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
# A private network: its members reach each other at `<id>.sandbox.internal`, over TCP.
|
|
28
|
+
# - +members+: The machines in it, by ID; none for every sandbox of the org.
|
|
29
|
+
# - +id+: Its ID.
|
|
30
|
+
# - +object+: Always `network`.
|
|
31
|
+
# - +name+: Its name.
|
|
32
|
+
# - +state+: Its state: `ready` once every member's host serves it.
|
|
33
|
+
# - +created_at+: When it was made.
|
|
34
|
+
Network = Struct.new(:members, :id, :object, :name, :state, :created_at, keyword_init: true) do
|
|
35
|
+
def self.from(h)
|
|
36
|
+
return nil if h.nil?
|
|
37
|
+
|
|
38
|
+
new(
|
|
39
|
+
members: h["members"],
|
|
40
|
+
id: h["id"],
|
|
41
|
+
object: h["object"],
|
|
42
|
+
name: h["name"],
|
|
43
|
+
state: h["state"],
|
|
44
|
+
created_at: h["createdAt"],
|
|
45
|
+
)
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
def to_wire
|
|
49
|
+
{
|
|
50
|
+
"members" => self.members,
|
|
51
|
+
"id" => self.id,
|
|
52
|
+
"object" => self.object,
|
|
53
|
+
"name" => self.name,
|
|
54
|
+
"state" => self.state,
|
|
55
|
+
"createdAt" => self.created_at,
|
|
56
|
+
}.compact
|
|
57
|
+
end
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
# A private network: its sandboxes reach each other by name, over TCP.
|
|
61
|
+
class Networks
|
|
62
|
+
def initialize(transport)
|
|
63
|
+
@transport = transport
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
# Lists the org's private networks, by name.
|
|
67
|
+
def list(cursor: nil, limit: nil)
|
|
68
|
+
Generated.page(@transport.request("GET", "/v2/networks", query: { "cursor" => cursor, "limit" => limit }, idempotent: true)) { |i| Network.from(i) }
|
|
69
|
+
end
|
|
70
|
+
end
|
|
71
|
+
end
|
|
72
|
+
end
|