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.
Files changed (66) hide show
  1. checksums.yaml +4 -4
  2. data/lib/withruntime/generated/apps.rb +192 -0
  3. data/lib/withruntime/generated/audit.rb +78 -0
  4. data/lib/withruntime/generated/browsers.rb +192 -0
  5. data/lib/withruntime/generated/builds.rb +192 -0
  6. data/lib/withruntime/generated/ci.rb +192 -0
  7. data/lib/withruntime/generated/containers.rb +192 -0
  8. data/lib/withruntime/generated/desktops.rb +192 -0
  9. data/lib/withruntime/generated/domains.rb +152 -0
  10. data/lib/withruntime/generated/egress_ips.rb +81 -0
  11. data/lib/withruntime/generated/events.rb +60 -0
  12. data/lib/withruntime/generated/feedback.rb +96 -0
  13. data/lib/withruntime/generated/functions.rb +192 -0
  14. data/lib/withruntime/generated/identities.rb +68 -0
  15. data/lib/withruntime/generated/images.rb +391 -0
  16. data/lib/withruntime/generated/job_runs.rb +110 -0
  17. data/lib/withruntime/generated/jobs.rb +333 -0
  18. data/lib/withruntime/generated/keys.rb +261 -0
  19. data/lib/withruntime/generated/kit.rb +111 -0
  20. data/lib/withruntime/generated/me.rb +69 -0
  21. data/lib/withruntime/generated/networks.rb +72 -0
  22. data/lib/withruntime/generated/notebooks.rb +192 -0
  23. data/lib/withruntime/generated/otel.rb +94 -0
  24. data/lib/withruntime/generated/ports.rb +118 -0
  25. data/lib/withruntime/generated/previews.rb +124 -0
  26. data/lib/withruntime/generated/projects.rb +108 -0
  27. data/lib/withruntime/generated/roles.rb +68 -0
  28. data/lib/withruntime/generated/routes.rb +11 -0
  29. data/lib/withruntime/generated/runtime.rb +188 -0
  30. data/lib/withruntime/generated/sandboxes.rb +1835 -0
  31. data/lib/withruntime/generated/secrets.rb +294 -0
  32. data/lib/withruntime/generated/sessions.rb +143 -0
  33. data/lib/withruntime/generated/sites.rb +192 -0
  34. data/lib/withruntime/generated/snapshots.rb +32 -0
  35. data/lib/withruntime/generated/tunnels.rb +165 -0
  36. data/lib/withruntime/generated/usage.rb +287 -0
  37. data/lib/withruntime/generated/volumes.rb +61 -0
  38. data/lib/withruntime/generated/webhooks.rb +91 -0
  39. data/lib/withruntime/generated/workspaces.rb +192 -0
  40. data/lib/withruntime/signing.rb +162 -0
  41. data/lib/withruntime/version.rb +2 -2
  42. data/lib/withruntime.rb +5 -43
  43. metadata +45 -35
  44. data/lib/withruntime/agents.rb +0 -877
  45. data/lib/withruntime/api_defaults.rb +0 -17
  46. data/lib/withruntime/apps.rb +0 -377
  47. data/lib/withruntime/browsers.rb +0 -104
  48. data/lib/withruntime/builds.rb +0 -218
  49. data/lib/withruntime/ci.rb +0 -164
  50. data/lib/withruntime/client.rb +0 -140
  51. data/lib/withruntime/containers.rb +0 -39
  52. data/lib/withruntime/credentials.rb +0 -111
  53. data/lib/withruntime/fields.rb +0 -40
  54. data/lib/withruntime/file_watch.rb +0 -73
  55. data/lib/withruntime/images.rb +0 -258
  56. data/lib/withruntime/network_products.rb +0 -49
  57. data/lib/withruntime/parity_products.rb +0 -51
  58. data/lib/withruntime/products.rb +0 -560
  59. data/lib/withruntime/record.rb +0 -99
  60. data/lib/withruntime/reservations.rb +0 -76
  61. data/lib/withruntime/sandbox.rb +0 -770
  62. data/lib/withruntime/tar.rb +0 -292
  63. data/lib/withruntime/transport.rb +0 -575
  64. data/lib/withruntime/tunnel.rb +0 -275
  65. data/lib/withruntime/wallet.rb +0 -68
  66. data/lib/withruntime/websocket.rb +0 -384
@@ -0,0 +1,32 @@
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 sandbox's memory and disk as they were, kept to start new sandboxes from.
11
+ class Snapshots
12
+ def initialize(transport)
13
+ @transport = transport
14
+ end
15
+
16
+ # Lists the project's snapshots, newest first.
17
+ def list(name: nil, state: nil, label: nil, sandbox: nil, cursor: nil, limit: nil)
18
+ Generated.page(@transport.request("GET", "/v2/snapshots", query: { "name" => name, "state" => state, "label" => label, "sandbox" => sandbox, "cursor" => cursor, "limit" => limit }, idempotent: true)) { |i| Stored.from(i) }
19
+ end
20
+
21
+ # Returns a snapshot.
22
+ def get(id)
23
+ Stored.from(@transport.request("GET", "/v2/snapshots/#{URI.encode_www_form_component(id)}", idempotent: true))
24
+ end
25
+
26
+ # Deletes a snapshot, its memory and its disk.
27
+ def delete(id, idempotency_key: nil)
28
+ Stored.from(@transport.request("DELETE", "/v2/snapshots/#{URI.encode_www_form_component(id)}", idempotency_key: idempotency_key))
29
+ end
30
+ end
31
+ end
32
+ end
@@ -0,0 +1,165 @@
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
+ # One of the org's own machines or routers on a tunnel.
10
+ # - +id+: Its ID.
11
+ # - +name+: Its name, unique in the tunnel.
12
+ # - +public_key+: Its WireGuard public key.
13
+ # - +address+: Its address in the tunnel's subnet.
14
+ # - +routes+: The org's own ranges behind it that sandboxes may reach.
15
+ # - +created_at+: When it was added.
16
+ # - +rotated_at+: When its key was last replaced.
17
+ TunnelPeer = Struct.new(:id, :name, :public_key, :address, :routes, :created_at, :rotated_at, keyword_init: true) do
18
+ def self.from(h)
19
+ return nil if h.nil?
20
+
21
+ new(
22
+ id: h["id"],
23
+ name: h["name"],
24
+ public_key: h["publicKey"],
25
+ address: h["address"],
26
+ routes: h["routes"],
27
+ created_at: h["createdAt"],
28
+ rotated_at: h["rotatedAt"],
29
+ )
30
+ end
31
+
32
+ def to_wire
33
+ {
34
+ "id" => self.id,
35
+ "name" => self.name,
36
+ "publicKey" => self.public_key,
37
+ "address" => self.address,
38
+ "routes" => self.routes,
39
+ "createdAt" => self.created_at,
40
+ "rotatedAt" => self.rotated_at,
41
+ }.compact
42
+ end
43
+ end
44
+
45
+ # A sandbox's address in a tunnel's subnet.
46
+ # - +sandbox_id+: The sandbox.
47
+ # - +address+: Its address in the subnet.
48
+ TunnelMember = Struct.new(:sandbox_id, :address, keyword_init: true) do
49
+ def self.from(h)
50
+ return nil if h.nil?
51
+
52
+ new(
53
+ sandbox_id: h["sandboxId"],
54
+ address: h["address"],
55
+ )
56
+ end
57
+
58
+ def to_wire
59
+ {
60
+ "sandboxId" => self.sandbox_id,
61
+ "address" => self.address,
62
+ }.compact
63
+ end
64
+ end
65
+
66
+ # A WireGuard tunnel's settings, as it keeps them; its gateway's private key is kept sealed and never answered.
67
+ # - +subnet+: Its private IPv4 range, /16 to /24.
68
+ # - +gateway_address+: The gateway's address in the subnet.
69
+ # - +endpoint+: Where peers send WireGuard: address:port.
70
+ # - +gateway_public_key+: The gateway's WireGuard public key; none until the gateway has made its pair.
71
+ # - +rate+: Its monthly price when it was made, in US dollars (`"5.00"`); it does not change.
72
+ # - +peers+: The org's machines and routers on it.
73
+ # - +members+: Each sandbox's address in the subnet.
74
+ TunnelSettings = Struct.new(:subnet, :gateway_address, :endpoint, :gateway_public_key, :rate, :peers, :members, keyword_init: true) do
75
+ def self.from(h)
76
+ return nil if h.nil?
77
+
78
+ new(
79
+ subnet: h["subnet"],
80
+ gateway_address: h["gatewayAddress"],
81
+ endpoint: h["endpoint"],
82
+ gateway_public_key: h["gatewayPublicKey"],
83
+ rate: h["rate"],
84
+ peers: h["peers"]&.map { |i| TunnelPeer.from(i) },
85
+ members: h["members"]&.map { |i| TunnelMember.from(i) },
86
+ )
87
+ end
88
+
89
+ def to_wire
90
+ {
91
+ "subnet" => self.subnet,
92
+ "gatewayAddress" => self.gateway_address,
93
+ "endpoint" => self.endpoint,
94
+ "gatewayPublicKey" => self.gateway_public_key,
95
+ "rate" => self.rate,
96
+ "peers" => self.peers&.map { |i| i&.to_wire },
97
+ "members" => self.members&.map { |i| i&.to_wire },
98
+ }.compact
99
+ end
100
+ end
101
+
102
+ # A WireGuard tunnel from the org's own network into its sandboxes.
103
+ # - +subnet+: Its private IPv4 range, /16 to /24.
104
+ # - +gateway_address+: The gateway's address in the subnet.
105
+ # - +endpoint+: Where peers send WireGuard: address:port.
106
+ # - +gateway_public_key+: The gateway's WireGuard public key; none until the gateway has made its pair.
107
+ # - +rate+: Its monthly price when it was made, in US dollars (`"5.00"`); it does not change.
108
+ # - +peers+: The org's machines and routers on it.
109
+ # - +members+: Each sandbox's address in the subnet.
110
+ # - +id+: Its ID.
111
+ # - +object+: Always `tunnel`.
112
+ # - +state+: Its state: `ready` once its gateway answers.
113
+ # - +disabled+: Turned off: no traffic passes.
114
+ # - +created_at+: When it was made.
115
+ Tunnel = Struct.new(:subnet, :gateway_address, :endpoint, :gateway_public_key, :rate, :peers, :members, :id, :object, :state, :disabled, :created_at, keyword_init: true) do
116
+ def self.from(h)
117
+ return nil if h.nil?
118
+
119
+ new(
120
+ subnet: h["subnet"],
121
+ gateway_address: h["gatewayAddress"],
122
+ endpoint: h["endpoint"],
123
+ gateway_public_key: h["gatewayPublicKey"],
124
+ rate: h["rate"],
125
+ peers: h["peers"]&.map { |i| TunnelPeer.from(i) },
126
+ members: h["members"]&.map { |i| TunnelMember.from(i) },
127
+ id: h["id"],
128
+ object: h["object"],
129
+ state: h["state"],
130
+ disabled: h["disabled"],
131
+ created_at: h["createdAt"],
132
+ )
133
+ end
134
+
135
+ def to_wire
136
+ {
137
+ "subnet" => self.subnet,
138
+ "gatewayAddress" => self.gateway_address,
139
+ "endpoint" => self.endpoint,
140
+ "gatewayPublicKey" => self.gateway_public_key,
141
+ "rate" => self.rate,
142
+ "peers" => self.peers&.map { |i| i&.to_wire },
143
+ "members" => self.members&.map { |i| i&.to_wire },
144
+ "id" => self.id,
145
+ "object" => self.object,
146
+ "state" => self.state,
147
+ "disabled" => self.disabled,
148
+ "createdAt" => self.created_at,
149
+ }.compact
150
+ end
151
+ end
152
+
153
+ # A WireGuard tunnel from your own network into your sandboxes.
154
+ class Tunnels
155
+ def initialize(transport)
156
+ @transport = transport
157
+ end
158
+
159
+ # Lists the org's WireGuard tunnels.
160
+ def list(cursor: nil, limit: nil)
161
+ Generated.page(@transport.request("GET", "/v2/tunnels", query: { "cursor" => cursor, "limit" => limit }, idempotent: true)) { |i| Tunnel.from(i) }
162
+ end
163
+ end
164
+ end
165
+ end
@@ -0,0 +1,287 @@
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
+ # One meter's use and charges this month.
10
+ # - +meter+: The card's meter (`cpu`, `memory`, `traffic-out`, ...).
11
+ # - +quantity+: Used this month, in the meter's base unit, as an integer in text.
12
+ # - +unit+: The base unit: `core-microseconds`, `vcpu-microseconds`, `byte-seconds`, `bytes`, `calls` or `seconds`.
13
+ # - +charged+: Charged this month at the card's rate, in US dollars.
14
+ MeterUse = Struct.new(:meter, :quantity, :unit, :charged, keyword_init: true) do
15
+ def self.from(h)
16
+ return nil if h.nil?
17
+
18
+ new(
19
+ meter: h["meter"],
20
+ quantity: h["quantity"],
21
+ unit: h["unit"],
22
+ charged: h["charged"],
23
+ )
24
+ end
25
+
26
+ def to_wire
27
+ {
28
+ "meter" => self.meter,
29
+ "quantity" => self.quantity,
30
+ "unit" => self.unit,
31
+ "charged" => self.charged,
32
+ }.compact
33
+ end
34
+ end
35
+
36
+ # One limit the org is held to, and what it uses of it now.
37
+ # - +name+: `running.vcpus`, `running.memory`, `machine.vcpus`, `machine.memory` or `starts.per-second`.
38
+ # - +unit+: What `max` and `used` count.
39
+ # - +max+: The most it may hold; none for no limit.
40
+ # - +used+: What it holds now.
41
+ Limit = Struct.new(:name, :unit, :max, :used, keyword_init: true) do
42
+ def self.from(h)
43
+ return nil if h.nil?
44
+
45
+ new(
46
+ name: h["name"],
47
+ unit: h["unit"],
48
+ max: h["max"],
49
+ used: h["used"],
50
+ )
51
+ end
52
+
53
+ def to_wire
54
+ {
55
+ "name" => self.name,
56
+ "unit" => self.unit,
57
+ "max" => self.max,
58
+ "used" => self.used,
59
+ }.compact
60
+ end
61
+ end
62
+
63
+ # One key's spend and what its holder runs: a coordinator reads what each worker's key spent.
64
+ # - +key_id+: The key's ID.
65
+ # - +name+: Its name.
66
+ # - +agent_id+: The agent or CI pipeline it acts as.
67
+ # - +account_id+: The person it acts as or for.
68
+ # - +day_spent+: What its calls committed in the last 24 hours, in US dollars, as its spend caps count it.
69
+ # - +period_spent+: What its calls committed this month (UTC), in US dollars.
70
+ # - +running+: Its holder's machines running now.
71
+ # - +machines+: Its holder's machines, not deleted.
72
+ KeyUsage = Struct.new(:key_id, :name, :agent_id, :account_id, :day_spent, :period_spent, :running, :machines, keyword_init: true) do
73
+ def self.from(h)
74
+ return nil if h.nil?
75
+
76
+ new(
77
+ key_id: h["keyId"],
78
+ name: h["name"],
79
+ agent_id: h["agentId"],
80
+ account_id: h["accountId"],
81
+ day_spent: h["daySpent"],
82
+ period_spent: h["periodSpent"],
83
+ running: h["running"],
84
+ machines: h["machines"],
85
+ )
86
+ end
87
+
88
+ def to_wire
89
+ {
90
+ "keyId" => self.key_id,
91
+ "name" => self.name,
92
+ "agentId" => self.agent_id,
93
+ "accountId" => self.account_id,
94
+ "daySpent" => self.day_spent,
95
+ "periodSpent" => self.period_spent,
96
+ "running" => self.running,
97
+ "machines" => self.machines,
98
+ }.compact
99
+ end
100
+ end
101
+
102
+ # The spend cap a key's creates are held to, and what is left under it.
103
+ # - +cap+: The most its holder's sandboxes may spend over windowSeconds, in US dollars.
104
+ # - +spent+: What they spent over the window, in US dollars, as the cap counts it.
105
+ # - +remaining+: What is left: cap less spent, never below 0. Once 0, a create is refused 403 until the window passes it.
106
+ # - +window_seconds+: The rolling window the cap counts over, in seconds.
107
+ KeySpendCap = Struct.new(:cap, :spent, :remaining, :window_seconds, keyword_init: true) do
108
+ def self.from(h)
109
+ return nil if h.nil?
110
+
111
+ new(
112
+ cap: h["cap"],
113
+ spent: h["spent"],
114
+ remaining: h["remaining"],
115
+ window_seconds: h["windowSeconds"],
116
+ )
117
+ end
118
+
119
+ def to_wire
120
+ {
121
+ "cap" => self.cap,
122
+ "spent" => self.spent,
123
+ "remaining" => self.remaining,
124
+ "windowSeconds" => self.window_seconds,
125
+ }.compact
126
+ end
127
+ end
128
+
129
+ # What the org has used and has left, at the card's prices.
130
+ # - +org_id+: The organization.
131
+ # - +period_start+: The month's first moment (UTC).
132
+ # - +credited+: Every credit ever added, in US dollars.
133
+ # - +spent+: Every charge ever settled, in US dollars.
134
+ # - +available+: What can still be spent: credited less spent, in US dollars.
135
+ # - +period_spent+: Charged this month, in US dollars.
136
+ # - +meters+: This month's use and charges by meter.
137
+ # - +plan+: Its plan on the price card.
138
+ # - +limits+: Every limit it is held to, with what it uses of each now: the figures a create past one is refused by.
139
+ # - +spend_cap+: The org's own cap on a month's charges, in US dollars.
140
+ # - +key+: One key's spend, when the call names it (`key`).
141
+ # - +key_spend_cap+: The spend cap this key's creates are held to: the tightest of its own, those of the keys it was made with, and its holder's grants'. Omitted when none holds it.
142
+ Usage = Struct.new(:org_id, :period_start, :credited, :spent, :available, :period_spent, :meters, :plan, :limits, :spend_cap, :key, :key_spend_cap, keyword_init: true) do
143
+ def self.from(h)
144
+ return nil if h.nil?
145
+
146
+ new(
147
+ org_id: h["orgId"],
148
+ period_start: h["periodStart"],
149
+ credited: h["credited"],
150
+ spent: h["spent"],
151
+ available: h["available"],
152
+ period_spent: h["periodSpent"],
153
+ meters: h["meters"]&.map { |i| MeterUse.from(i) },
154
+ plan: h["plan"],
155
+ limits: h["limits"]&.map { |i| Limit.from(i) },
156
+ spend_cap: h["spendCap"],
157
+ key: KeyUsage.from(h["key"]),
158
+ key_spend_cap: KeySpendCap.from(h["keySpendCap"]),
159
+ )
160
+ end
161
+
162
+ def to_wire
163
+ {
164
+ "orgId" => self.org_id,
165
+ "periodStart" => self.period_start,
166
+ "credited" => self.credited,
167
+ "spent" => self.spent,
168
+ "available" => self.available,
169
+ "periodSpent" => self.period_spent,
170
+ "meters" => self.meters&.map { |i| i&.to_wire },
171
+ "plan" => self.plan,
172
+ "limits" => self.limits&.map { |i| i&.to_wire },
173
+ "spendCap" => self.spend_cap,
174
+ "key" => self.key&.to_wire,
175
+ "keySpendCap" => self.key_spend_cap&.to_wire,
176
+ }.compact
177
+ end
178
+ end
179
+
180
+ # One meter of one machine's, disk's or address's hour, as measured, at the card's price.
181
+ # - +id+: The line's ID: the same line has the same ID on every read.
182
+ # - +subject_id+: The resource it was used by: a machine, a disk or an address.
183
+ # - +resource_id+: The ID its product names it by (a sandbox's own ID).
184
+ # - +project_id+: Its project.
185
+ # - +meter+: The card's meter (`cpu`, `memory`, `standard`, `traffic-out`, ...).
186
+ # - +starts_at+: The hour's first moment (UTC).
187
+ # - +ends_at+: The hour's end.
188
+ # - +quantity+: What was used, in the meter's base unit, as an integer in text.
189
+ # - +unit+: The base unit: `core-microseconds`, `vcpu-microseconds`, `byte-seconds`, `bytes`, `calls` or `seconds`.
190
+ # - +charged_micros+: The hour alone at the card's rate, rounded down, in integer microdollars as text.
191
+ # - +rate_micros+: The card's rate, in microdollars per priced unit, as an integer in text.
192
+ # - +settled_at+: When the line settles: its hour's end (UTC). A line can change only until the page's `finalThrough` reaches it.
193
+ # - +final+: Whether the line is final: its `settledAt` is at or before the page's `finalThrough`, and it never changes again.
194
+ # - +resource_final+: Whether its resource is deleted and every line it will ever have is final.
195
+ UsageLine = Struct.new(:id, :subject_id, :resource_id, :project_id, :meter, :starts_at, :ends_at, :quantity, :unit, :charged_micros, :rate_micros, :settled_at, :final, :resource_final, keyword_init: true) do
196
+ def self.from(h)
197
+ return nil if h.nil?
198
+
199
+ new(
200
+ id: h["id"],
201
+ subject_id: h["subjectId"],
202
+ resource_id: h["resourceId"],
203
+ project_id: h["projectId"],
204
+ meter: h["meter"],
205
+ starts_at: h["startsAt"],
206
+ ends_at: h["endsAt"],
207
+ quantity: h["quantity"],
208
+ unit: h["unit"],
209
+ charged_micros: h["chargedMicros"],
210
+ rate_micros: h["rateMicros"],
211
+ settled_at: h["settledAt"],
212
+ final: h["final"],
213
+ resource_final: h["resourceFinal"],
214
+ )
215
+ end
216
+
217
+ def to_wire
218
+ {
219
+ "id" => self.id,
220
+ "subjectId" => self.subject_id,
221
+ "resourceId" => self.resource_id,
222
+ "projectId" => self.project_id,
223
+ "meter" => self.meter,
224
+ "startsAt" => self.starts_at,
225
+ "endsAt" => self.ends_at,
226
+ "quantity" => self.quantity,
227
+ "unit" => self.unit,
228
+ "chargedMicros" => self.charged_micros,
229
+ "rateMicros" => self.rate_micros,
230
+ "settledAt" => self.settled_at,
231
+ "final" => self.final,
232
+ "resourceFinal" => self.resource_final,
233
+ }.compact
234
+ end
235
+ end
236
+
237
+ # The organization's measured usage in a time range, oldest hour first.
238
+ # - +since+: The range's first moment, inclusive (UTC).
239
+ # - +until+: The range's end, exclusive (UTC).
240
+ # - +final_through+: Every line whose `settledAt` is at or before this moment is final: all usage before it has been measured. It never moves back; a later hour stays open until its usage is measured. None: no line is final yet.
241
+ # - +items+: Each meter of each resource's hour.
242
+ # - +next+: Pass as cursor, with the same range, for the next page; none on the last.
243
+ # - +cursor+: The cursor this page was asked from; none on the first page.
244
+ UsageExport = Struct.new(:since, :until, :final_through, :items, :next, :cursor, keyword_init: true) do
245
+ def self.from(h)
246
+ return nil if h.nil?
247
+
248
+ new(
249
+ since: h["since"],
250
+ until: h["until"],
251
+ final_through: h["finalThrough"],
252
+ items: h["items"]&.map { |i| UsageLine.from(i) },
253
+ next: h["next"],
254
+ cursor: h["cursor"],
255
+ )
256
+ end
257
+
258
+ def to_wire
259
+ {
260
+ "since" => self.since,
261
+ "until" => self.until,
262
+ "finalThrough" => self.final_through,
263
+ "items" => self.items&.map { |i| i&.to_wire },
264
+ "next" => self.next,
265
+ "cursor" => self.cursor,
266
+ }.compact
267
+ end
268
+ end
269
+
270
+ # What the organization has used and has left at the price card's rates, and every limit it is held to.
271
+ class UsageClient
272
+ def initialize(transport)
273
+ @transport = transport
274
+ end
275
+
276
+ # Returns the organization's credit and charges (everything credited and spent, what is left, and this month's use and charges by meter), its plan, and every limit it is held to with what it uses of each now; with key, that key's spend.
277
+ def get(key: nil)
278
+ Usage.from(@transport.request("GET", "/v2/usage", query: { "key" => key }, idempotent: true))
279
+ end
280
+
281
+ # Returns the organization's measured usage in a time range, of every resource or only those named: each meter of each machine's, disk's or address's hour, what it used and its price at the card, oldest first, paginated. Each line settles at its hour's end and is final once finalThrough reaches it, so closed hours can be read while resources run.
282
+ def export(since:, until:, by: nil, resource_id: nil, cursor: nil, limit: nil)
283
+ UsageExport.from(@transport.request("GET", "/v2/usage/export", query: { "since" => since, "until" => binding.local_variable_get(:until), "by" => by, "resourceId" => resource_id, "cursor" => cursor, "limit" => limit }, idempotent: true))
284
+ end
285
+ end
286
+ end
287
+ end
@@ -0,0 +1,61 @@
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 volume to create: an empty disk, formatted ext4 at its first mount.
11
+ # - +name+: Its name, unique in its project among volumes.
12
+ # - +labels+: Labels to find it by.
13
+ # - +size_mib+: Its size in MiB, 64 to 409600 (400 GiB).
14
+ VolumeCreate = Struct.new(:name, :labels, :size_mib, keyword_init: true) do
15
+ def self.from(h)
16
+ return nil if h.nil?
17
+
18
+ new(
19
+ name: h["name"],
20
+ labels: h["labels"],
21
+ size_mib: h["sizeMiB"],
22
+ )
23
+ end
24
+
25
+ def to_wire
26
+ {
27
+ "name" => self.name,
28
+ "labels" => self.labels,
29
+ "sizeMiB" => self.size_mib,
30
+ }.compact
31
+ end
32
+ end
33
+
34
+ # A disk that outlives the machines it is attached to.
35
+ class Volumes
36
+ def initialize(transport)
37
+ @transport = transport
38
+ end
39
+
40
+ # Creates an empty volume. Asked again with the same Idempotency-Key, it returns the same one.
41
+ def create(name: nil, labels: nil, size_mib:, idempotency_key: nil)
42
+ Stored.from(@transport.request("POST", "/v2/volumes", body: { "name" => name, "labels" => labels, "sizeMiB" => size_mib }.compact, idempotency_key: idempotency_key, idempotent: true))
43
+ end
44
+
45
+ # Lists the project's volumes, newest first.
46
+ def list(name: nil, state: nil, label: nil, cursor: nil, limit: nil)
47
+ Generated.page(@transport.request("GET", "/v2/volumes", query: { "name" => name, "state" => state, "label" => label, "cursor" => cursor, "limit" => limit }, idempotent: true)) { |i| Stored.from(i) }
48
+ end
49
+
50
+ # Returns a volume.
51
+ def get(id)
52
+ Stored.from(@transport.request("GET", "/v2/volumes/#{URI.encode_www_form_component(id)}", idempotent: true))
53
+ end
54
+
55
+ # Deletes a volume and what it holds. One attached to a sandbox is refused: delete the sandbox first.
56
+ def delete(id, idempotency_key: nil)
57
+ Stored.from(@transport.request("DELETE", "/v2/volumes/#{URI.encode_www_form_component(id)}", idempotency_key: idempotency_key))
58
+ end
59
+ end
60
+ end
61
+ end
@@ -0,0 +1,91 @@
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 webhook to make.
10
+ # - +url+: The https URL to send each event to.
11
+ # - +events+: The events to send it, at most 32; `["*"]` (every one) when omitted.
12
+ WebhookCreate = Struct.new(:url, :events, keyword_init: true) do
13
+ def self.from(h)
14
+ return nil if h.nil?
15
+
16
+ new(
17
+ url: h["url"],
18
+ events: h["events"],
19
+ )
20
+ end
21
+
22
+ def to_wire
23
+ {
24
+ "url" => self.url,
25
+ "events" => self.events,
26
+ }.compact
27
+ end
28
+ end
29
+
30
+ # A webhook: a signed POST to your URL for each event it names.
31
+ # - +id+: Its ID.
32
+ # - +object+: Always `webhook`.
33
+ # - +url+: The https URL each event is sent to; in a list, its origin alone (`https://host/…`).
34
+ # - +events+: The events it is sent (`sandbox.created`); `*` for every one.
35
+ # - +state+: `active` while it is sent to; `deleted` once deleted: a delete's answer.
36
+ # - +created_at+: When it was made.
37
+ # - +secret+: Its signing secret (`whsec_...`): returned when it is made, and never again.
38
+ # - +deleted_at+: When it was deleted: a delete's answer, its state `deleted`.
39
+ Webhook = Struct.new(:id, :object, :url, :events, :state, :created_at, :secret, :deleted_at, keyword_init: true) do
40
+ def self.from(h)
41
+ return nil if h.nil?
42
+
43
+ new(
44
+ id: h["id"],
45
+ object: h["object"],
46
+ url: h["url"],
47
+ events: h["events"],
48
+ state: h["state"],
49
+ created_at: h["createdAt"],
50
+ secret: h["secret"],
51
+ deleted_at: h["deletedAt"],
52
+ )
53
+ end
54
+
55
+ def to_wire
56
+ {
57
+ "id" => self.id,
58
+ "object" => self.object,
59
+ "url" => self.url,
60
+ "events" => self.events,
61
+ "state" => self.state,
62
+ "createdAt" => self.created_at,
63
+ "secret" => self.secret,
64
+ "deletedAt" => self.deleted_at,
65
+ }.compact
66
+ end
67
+ end
68
+
69
+ # A signed POST to your URL for each event it names.
70
+ class Webhooks
71
+ def initialize(transport)
72
+ @transport = transport
73
+ end
74
+
75
+ # Makes a webhook, returning its signing secret this once.
76
+ def create(url:, events: nil, idempotency_key: nil)
77
+ Webhook.from(@transport.request("POST", "/v2/webhooks", body: { "url" => url, "events" => events }.compact, idempotency_key: idempotency_key))
78
+ end
79
+
80
+ # Lists the org's, oldest first.
81
+ def list(cursor: nil, limit: nil)
82
+ Generated.page(@transport.request("GET", "/v2/webhooks", query: { "cursor" => cursor, "limit" => limit }, idempotent: true)) { |i| Webhook.from(i) }
83
+ end
84
+
85
+ # Deletes it: nothing more is sent to it.
86
+ def delete(id, idempotency_key: nil)
87
+ Webhook.from(@transport.request("DELETE", "/v2/webhooks/#{URI.encode_www_form_component(id)}", idempotency_key: idempotency_key, idempotent: true))
88
+ end
89
+ end
90
+ end
91
+ end