pinesandbox 0.3.21 → 0.3.22
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/README.md +2 -2
- data/lib/pinesandbox/attach_credentials_source.rb +6 -4
- data/lib/pinesandbox/control_plane.rb +4 -0
- data/lib/pinesandbox/errors.rb +22 -0
- data/lib/pinesandbox/terminal_reason.rb +2 -1
- data/lib/pinesandbox/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 55f1a5304b3816e9e36f1d087f979d082050f2ee19639d489272e35ca55d2a9a
|
|
4
|
+
data.tar.gz: d7e5f8f0f84a2cc876a4a54e2f47ff468c33483760a203cea636c75050891556
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 94cd92b7ff365c67c795346987cd503475bfac9bbf696d26919df8c6d671babe6c891d42e26b7678ca18f81a5a8393e4a078f9bf11e6e3bdbdd75c328670f6f4
|
|
7
|
+
data.tar.gz: 6528144c681b71f9434dfa8dee8d7a1356e0d69cc7730ff763ee79580e4470a86c4fcc814c951984aab9770db09104db17aaa57fca46a79584433c0b831ef14b
|
data/README.md
CHANGED
|
@@ -16,12 +16,12 @@ bundle add pinesandbox
|
|
|
16
16
|
|
|
17
17
|
Bundler pins it to the latest release's compatibility line (`"~> 0.3.<patch>"`), so
|
|
18
18
|
`bundle update` takes later patches but not a new minor version. Using it needs a project key (`pk_…`) from the
|
|
19
|
-
[Console](https://console.pinecomputer.io).
|
|
19
|
+
[Console](https://console.pinecomputer.io). Access is by approval:
|
|
20
20
|
[request access](https://pinecomputer.io/#access) if you don't have one yet. Each
|
|
21
21
|
release is also an archive on the [Ruby SDK page](https://console.pinecomputer.io/sdks/ruby),
|
|
22
22
|
for vendoring.
|
|
23
23
|
|
|
24
|
-
The current
|
|
24
|
+
The current SDK is on the `0.3` compatibility line.
|
|
25
25
|
|
|
26
26
|
## Create a Computer
|
|
27
27
|
|
|
@@ -321,10 +321,12 @@ module PineSandbox
|
|
|
321
321
|
def raise_generic(resp, label,
|
|
322
322
|
forbidden: "project or key may not mint attach credentials (scope, project status, or computer status)")
|
|
323
323
|
if resp.status == 403
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
324
|
+
attributes = error_attributes(resp)
|
|
325
|
+
if attributes[:problem_type] == SpendLimitReachedError::PROBLEM_TYPE
|
|
326
|
+
raise SpendLimitReachedError.new(error_message(resp, forbidden), **attributes.slice(:request_id, :op))
|
|
327
|
+
end
|
|
328
|
+
|
|
329
|
+
raise ProjectAccessDenied.new(error_message(resp, forbidden), **attributes)
|
|
328
330
|
end
|
|
329
331
|
default =
|
|
330
332
|
case resp.status
|
|
@@ -284,6 +284,10 @@ module PineSandbox
|
|
|
284
284
|
# the op path already carries the id for get/destroy/pause/resume.
|
|
285
285
|
rid = resp.headers["x-request-id"] || resp.headers["X-Request-Id"]
|
|
286
286
|
op = op_for(resp)
|
|
287
|
+
if resp.status == 403 && body.is_a?(Hash) && body["type"] == PineSandbox::SpendLimitReachedError::PROBLEM_TYPE
|
|
288
|
+
raise PineSandbox::SpendLimitReachedError.new(status_message(resp), request_id: rid, op: op)
|
|
289
|
+
end
|
|
290
|
+
|
|
287
291
|
ext = {}
|
|
288
292
|
ext["op"] = op if op && !op.to_s.empty?
|
|
289
293
|
ext["request_id"] = rid unless rid.to_s.empty?
|
data/lib/pinesandbox/errors.rb
CHANGED
|
@@ -642,6 +642,28 @@ module PineSandbox
|
|
|
642
642
|
end
|
|
643
643
|
end
|
|
644
644
|
|
|
645
|
+
# 403 SPEND_LIMIT_REACHED: the project has reached its monthly spend limit, or
|
|
646
|
+
# its organization is out of credits, so a Computer wasn't started or resumed
|
|
647
|
+
# or its idle timeout wasn't changed. The same error whichever call was
|
|
648
|
+
# refused. Reads, stop, pause and delete still work. Not retried by the SDK:
|
|
649
|
+
# credits are added or the limit raised first; #message says which.
|
|
650
|
+
class SpendLimitReachedError < Error
|
|
651
|
+
CODE = "SPEND_LIMIT_REACHED".freeze
|
|
652
|
+
# The refusal's problem type, the same from every call.
|
|
653
|
+
PROBLEM_TYPE = "urn:pinesandbox:problem:spend-limit-reached".freeze
|
|
654
|
+
|
|
655
|
+
attr_reader :status, :request_id, :op
|
|
656
|
+
|
|
657
|
+
def initialize(message, status: 403, request_id: nil, op: nil)
|
|
658
|
+
@status = status
|
|
659
|
+
@request_id = request_id
|
|
660
|
+
@op = op
|
|
661
|
+
super(PineSandbox.with_context(message, op: op, request_id: request_id))
|
|
662
|
+
end
|
|
663
|
+
|
|
664
|
+
def code = CODE
|
|
665
|
+
end
|
|
666
|
+
|
|
645
667
|
# 429 COMPUTER_CAPACITY_EXCEEDED on create/attach: the project is at its
|
|
646
668
|
# concurrent Computer limit, so nothing was provisioned. Not retried by the
|
|
647
669
|
# SDK — capacity frees only when another of the project's Computers stops.
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
# Generated by specs/gen-signal-actions.py from sdks/pine-computer/contract/signal-actions.json. Do not edit; run `python3 specs/gen-signal-actions.py`.
|
|
2
|
-
# signal-actions source-sha256=
|
|
2
|
+
# signal-actions source-sha256=6b1fd0c880882510913e27b38e9169567f64c4d7193e7acc158a4da906ff8c20 body-sha256=8b26db77552ce1578c3677792aab7c0519ef534aee4668e65e183e5951857fa2
|
|
3
3
|
|
|
4
4
|
module PineSandbox
|
|
5
5
|
# @api private — the terminal_reason values of a turn's result: how a turn or a
|
|
@@ -15,6 +15,7 @@ module PineSandbox
|
|
|
15
15
|
EXECUTOR_PANIC = "executor_panic".freeze
|
|
16
16
|
COORDINATOR_RESTARTED = "coordinator_restarted".freeze
|
|
17
17
|
STORAGE_EXHAUSTED = "storage_exhausted".freeze
|
|
18
|
+
SPEND_LIMIT_REACHED = "spend_limit_reached".freeze
|
|
18
19
|
OUTPUT_INVALID = "output_invalid".freeze
|
|
19
20
|
DRAFT_REGISTERED = "draft_registered".freeze
|
|
20
21
|
CLARIFICATION_REQUESTED = "clarification_requested".freeze
|
data/lib/pinesandbox/version.rb
CHANGED