withruntime 0.28.0 → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/withruntime/generated/apps.rb +192 -0
- data/lib/withruntime/generated/audit.rb +78 -0
- data/lib/withruntime/generated/browsers.rb +192 -0
- data/lib/withruntime/generated/builds.rb +192 -0
- data/lib/withruntime/generated/ci.rb +192 -0
- data/lib/withruntime/generated/containers.rb +192 -0
- data/lib/withruntime/generated/desktops.rb +192 -0
- data/lib/withruntime/generated/domains.rb +152 -0
- data/lib/withruntime/generated/egress_ips.rb +81 -0
- data/lib/withruntime/generated/events.rb +60 -0
- data/lib/withruntime/generated/feedback.rb +96 -0
- data/lib/withruntime/generated/functions.rb +192 -0
- data/lib/withruntime/generated/identities.rb +68 -0
- data/lib/withruntime/generated/images.rb +391 -0
- data/lib/withruntime/generated/job_runs.rb +110 -0
- data/lib/withruntime/generated/jobs.rb +333 -0
- data/lib/withruntime/generated/keys.rb +261 -0
- data/lib/withruntime/generated/kit.rb +111 -0
- data/lib/withruntime/generated/me.rb +69 -0
- data/lib/withruntime/generated/networks.rb +72 -0
- data/lib/withruntime/generated/notebooks.rb +192 -0
- data/lib/withruntime/generated/otel.rb +94 -0
- data/lib/withruntime/generated/ports.rb +118 -0
- data/lib/withruntime/generated/previews.rb +124 -0
- data/lib/withruntime/generated/projects.rb +108 -0
- data/lib/withruntime/generated/roles.rb +68 -0
- data/lib/withruntime/generated/routes.rb +11 -0
- data/lib/withruntime/generated/runtime.rb +188 -0
- data/lib/withruntime/generated/sandboxes.rb +1835 -0
- data/lib/withruntime/generated/secrets.rb +294 -0
- data/lib/withruntime/generated/sessions.rb +143 -0
- data/lib/withruntime/generated/sites.rb +192 -0
- data/lib/withruntime/generated/snapshots.rb +32 -0
- data/lib/withruntime/generated/tunnels.rb +165 -0
- data/lib/withruntime/generated/usage.rb +287 -0
- data/lib/withruntime/generated/volumes.rb +61 -0
- data/lib/withruntime/generated/webhooks.rb +91 -0
- data/lib/withruntime/generated/workspaces.rb +192 -0
- data/lib/withruntime/signing.rb +162 -0
- data/lib/withruntime/version.rb +2 -2
- data/lib/withruntime.rb +5 -43
- metadata +45 -35
- data/lib/withruntime/agents.rb +0 -877
- data/lib/withruntime/api_defaults.rb +0 -17
- data/lib/withruntime/apps.rb +0 -377
- data/lib/withruntime/browsers.rb +0 -104
- data/lib/withruntime/builds.rb +0 -218
- data/lib/withruntime/ci.rb +0 -164
- data/lib/withruntime/client.rb +0 -140
- data/lib/withruntime/containers.rb +0 -39
- data/lib/withruntime/credentials.rb +0 -111
- data/lib/withruntime/fields.rb +0 -40
- data/lib/withruntime/file_watch.rb +0 -73
- data/lib/withruntime/images.rb +0 -258
- data/lib/withruntime/network_products.rb +0 -49
- data/lib/withruntime/parity_products.rb +0 -51
- data/lib/withruntime/products.rb +0 -560
- data/lib/withruntime/record.rb +0 -99
- data/lib/withruntime/reservations.rb +0 -76
- data/lib/withruntime/sandbox.rb +0 -775
- data/lib/withruntime/tar.rb +0 -292
- data/lib/withruntime/transport.rb +0 -575
- data/lib/withruntime/tunnel.rb +0 -275
- data/lib/withruntime/wallet.rb +0 -68
- data/lib/withruntime/websocket.rb +0 -384
|
@@ -1,76 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
require "time"
|
|
4
|
-
|
|
5
|
-
module WithRuntime
|
|
6
|
-
# +runtime.reservations+: book room for a burst. Holds room for +sandboxes+
|
|
7
|
-
# sandboxes of one size for a window (up to 24 hours, starting within 14 days)
|
|
8
|
-
# and answers at once, confirmed or declined. A decline is a normal answer
|
|
9
|
-
# (+status+ is "declined"; +reason+, +message+, +largest_sandboxes+ and
|
|
10
|
-
# +nearest_window+ say why and what would fit), not an error. In the window,
|
|
11
|
-
# creates are never refused no_capacity or quota_exceeded up to what you
|
|
12
|
-
# booked; running sandboxes are billed as usual and booked room none of your
|
|
13
|
-
# sandboxes use costs a quarter of the memory rate. +estimate_micros+ (the most
|
|
14
|
-
# it can cost: every sandbox running the whole window), +unused_rate_micros+
|
|
15
|
-
# (unused room per GiB-hour of memory, as quoted when booked),
|
|
16
|
-
# +unused_max_micros+ (the most it costs if none run) and
|
|
17
|
-
# +unused_charged_micros+ (charged so far) are microdollars as a string.
|
|
18
|
-
#
|
|
19
|
-
# booking = runtime.reservations.create(sandboxes: 500, starts_at: Time.now + 3600, ends_at: Time.now + 3 * 3600)
|
|
20
|
-
# booking.status # => "confirmed"
|
|
21
|
-
#
|
|
22
|
-
# Standing room (+keep+) is held from now until you cancel it, for a pool that
|
|
23
|
-
# deletes a sandbox after each use and makes another: a replacement is never
|
|
24
|
-
# refused up to it. With +snapshots+ it is held on the servers holding them,
|
|
25
|
-
# at their size; +for_key+ keeps it for this key's sandboxes alone. Its
|
|
26
|
-
# +ends_at+, +held_until+ and +unused_max_micros+ are nil;
|
|
27
|
-
# +unused_per_hour_micros+ is the most its unused room costs an hour.
|
|
28
|
-
#
|
|
29
|
-
# pool = runtime.reservations.keep(sandboxes: 40, snapshots: [snapshot_id], for_key: true)
|
|
30
|
-
class Reservations < Product
|
|
31
|
-
# +starts_at+ and +ends_at+ are a Time or an ISO 8601 string. +vcpu+,
|
|
32
|
-
# +memory_mib+, +disk_mib+ and +region+ default to a create's defaults
|
|
33
|
-
# (2 vCPU, 4096 MiB each, the default region).
|
|
34
|
-
def create(sandboxes:, starts_at:, ends_at:, vcpu: nil, memory_mib: nil, disk_mib: nil, region: nil, idempotency_key: nil)
|
|
35
|
-
body = Fields.body(sandboxes: sandboxes, starts_at: iso(starts_at), ends_at: iso(ends_at),
|
|
36
|
-
vcpu: vcpu, memory_mib: memory_mib, disk_mib: disk_mib, region: region)
|
|
37
|
-
Record.new(@t.json("POST", "/v1/reservations", body: body, key: idempotency_key))
|
|
38
|
-
end
|
|
39
|
-
|
|
40
|
-
# Keeps standing room for +sandboxes+ sandboxes until it is cancelled. Keep
|
|
41
|
-
# a few more than the pool runs, for deletes still finishing.
|
|
42
|
-
def keep(sandboxes:, snapshots: nil, for_key: nil, vcpu: nil, memory_mib: nil, disk_mib: nil, region: nil,
|
|
43
|
-
idempotency_key: nil)
|
|
44
|
-
body = Fields.body(standing: true, sandboxes: sandboxes, snapshots: snapshots, for_key: for_key || nil,
|
|
45
|
-
vcpu: vcpu, memory_mib: memory_mib, disk_mib: disk_mib, region: region)
|
|
46
|
-
Record.new(@t.json("POST", "/v1/reservations", body: body, key: idempotency_key))
|
|
47
|
-
end
|
|
48
|
-
|
|
49
|
-
# Changes standing room in place: how many it holds, its snapshots, or
|
|
50
|
-
# both. It moves or grows only when all of it fits now; otherwise it raises
|
|
51
|
-
# no_capacity and nothing changes.
|
|
52
|
-
def update(id, sandboxes: nil, snapshots: nil, idempotency_key: nil)
|
|
53
|
-
body = Fields.body(sandboxes: sandboxes, snapshots: snapshots)
|
|
54
|
-
Record.new(@t.json("POST", "/v1/reservations/#{seg(id)}:update", body: body, key: idempotency_key))
|
|
55
|
-
end
|
|
56
|
-
|
|
57
|
-
# Bookings, newest first, as a Page (+data+, +next_cursor+, +more?+,
|
|
58
|
-
# +next_page+); iterating it walks every page.
|
|
59
|
-
def list(limit: nil, cursor: nil)
|
|
60
|
-
query = { "limit" => limit, "cursor" => cursor }
|
|
61
|
-
body = @t.json("GET", "/v1/reservations", query: query)
|
|
62
|
-
Page.new(body["items"].map { |item| Record.new(item) }, body["nextCursor"]) do |next_cursor|
|
|
63
|
-
list(limit: limit, cursor: next_cursor)
|
|
64
|
-
end
|
|
65
|
-
end
|
|
66
|
-
|
|
67
|
-
def get(id) = Record.new(@t.json("GET", "/v1/reservations/#{seg(id)}"))
|
|
68
|
-
|
|
69
|
-
# Gives the room back. The booking comes back with status "cancelled".
|
|
70
|
-
def cancel(id) = Record.new(@t.json("DELETE", "/v1/reservations/#{seg(id)}"))
|
|
71
|
-
|
|
72
|
-
private
|
|
73
|
-
|
|
74
|
-
def iso(at) = at.respond_to?(:iso8601) ? at.iso8601(3) : at
|
|
75
|
-
end
|
|
76
|
-
end
|