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.
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 -775
  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
@@ -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