runcloud-sdk 0.9.0__tar.gz → 0.10.0__tar.gz
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.
- {runcloud_sdk-0.9.0/runcloud_sdk.egg-info → runcloud_sdk-0.10.0}/PKG-INFO +1 -1
- {runcloud_sdk-0.9.0 → runcloud_sdk-0.10.0}/pyproject.toml +1 -1
- {runcloud_sdk-0.9.0 → runcloud_sdk-0.10.0}/runcloud/client.py +28 -2
- {runcloud_sdk-0.9.0 → runcloud_sdk-0.10.0/runcloud_sdk.egg-info}/PKG-INFO +1 -1
- {runcloud_sdk-0.9.0 → runcloud_sdk-0.10.0}/tests/test_sdk.py +29 -0
- {runcloud_sdk-0.9.0 → runcloud_sdk-0.10.0}/LICENSE +0 -0
- {runcloud_sdk-0.9.0 → runcloud_sdk-0.10.0}/README.md +0 -0
- {runcloud_sdk-0.9.0 → runcloud_sdk-0.10.0}/runcloud/__init__.py +0 -0
- {runcloud_sdk-0.9.0 → runcloud_sdk-0.10.0}/runcloud/compat/__init__.py +0 -0
- {runcloud_sdk-0.9.0 → runcloud_sdk-0.10.0}/runcloud/compat/blaxel.py +0 -0
- {runcloud_sdk-0.9.0 → runcloud_sdk-0.10.0}/runcloud/compat/daytona.py +0 -0
- {runcloud_sdk-0.9.0 → runcloud_sdk-0.10.0}/runcloud/compat/e2b.py +0 -0
- {runcloud_sdk-0.9.0 → runcloud_sdk-0.10.0}/runcloud/compat/modal.py +0 -0
- {runcloud_sdk-0.9.0 → runcloud_sdk-0.10.0}/runcloud/compat/sprites.py +0 -0
- {runcloud_sdk-0.9.0 → runcloud_sdk-0.10.0}/runcloud/compat/vercel.py +0 -0
- {runcloud_sdk-0.9.0 → runcloud_sdk-0.10.0}/runcloud_sdk.egg-info/SOURCES.txt +0 -0
- {runcloud_sdk-0.9.0 → runcloud_sdk-0.10.0}/runcloud_sdk.egg-info/dependency_links.txt +0 -0
- {runcloud_sdk-0.9.0 → runcloud_sdk-0.10.0}/runcloud_sdk.egg-info/requires.txt +0 -0
- {runcloud_sdk-0.9.0 → runcloud_sdk-0.10.0}/runcloud_sdk.egg-info/top_level.txt +0 -0
- {runcloud_sdk-0.9.0 → runcloud_sdk-0.10.0}/setup.cfg +0 -0
|
@@ -354,6 +354,7 @@ class Client:
|
|
|
354
354
|
timeout_seconds: Optional[int] = None,
|
|
355
355
|
region: Optional[str] = None,
|
|
356
356
|
name: Optional[str] = None,
|
|
357
|
+
tags: Optional[dict[str, str]] = None,
|
|
357
358
|
) -> "Sandbox":
|
|
358
359
|
values = {
|
|
359
360
|
"image": image,
|
|
@@ -364,6 +365,7 @@ class Client:
|
|
|
364
365
|
"timeoutSeconds": timeout_seconds,
|
|
365
366
|
"region": region,
|
|
366
367
|
"name": name,
|
|
368
|
+
"tags": tags,
|
|
367
369
|
}
|
|
368
370
|
body = {key: value for key, value in values.items() if value is not None}
|
|
369
371
|
return Sandbox(self, self.request("POST", "/run-cloud/sandboxes", body))
|
|
@@ -373,15 +375,20 @@ class Client:
|
|
|
373
375
|
return Sandbox(self, self.request("GET", f"/run-cloud/sandboxes/{sid}"))
|
|
374
376
|
|
|
375
377
|
def list(
|
|
376
|
-
self,
|
|
378
|
+
self,
|
|
379
|
+
state: Optional[str] = None,
|
|
380
|
+
name: Optional[str] = None,
|
|
381
|
+
tags: Optional[dict[str, str]] = None,
|
|
377
382
|
) -> list["Sandbox"]:
|
|
378
|
-
#
|
|
383
|
+
# Every filter is applied server-side, so finding a sandbox by the name
|
|
379
384
|
# you gave it does not mean paging the whole fleet and matching locally.
|
|
385
|
+
# Repeated `tag` params are ANDed together.
|
|
380
386
|
filters = [
|
|
381
387
|
(key, value)
|
|
382
388
|
for key, value in (("state", state), ("name", name))
|
|
383
389
|
if value
|
|
384
390
|
]
|
|
391
|
+
filters.extend(("tag", f"{key}:{value}") for key, value in (tags or {}).items())
|
|
385
392
|
query = "?" + urllib.parse.urlencode(filters) if filters else ""
|
|
386
393
|
payload = self.request("GET", "/run-cloud/sandboxes" + query) or {}
|
|
387
394
|
return [Sandbox(self, item) for item in payload.get("items", [])]
|
|
@@ -401,6 +408,25 @@ class Sandbox:
|
|
|
401
408
|
def name(self) -> str:
|
|
402
409
|
return str(self._data.get("name") or "")
|
|
403
410
|
|
|
411
|
+
@property
|
|
412
|
+
def tags(self) -> dict[str, str]:
|
|
413
|
+
value = self._data.get("tags")
|
|
414
|
+
return dict(value) if isinstance(value, dict) else {}
|
|
415
|
+
|
|
416
|
+
def set_tags(self, tags: dict[str, Optional[str]]) -> "Sandbox":
|
|
417
|
+
"""Merge tags into this sandbox. A None value deletes that key.
|
|
418
|
+
|
|
419
|
+
Tags survive the sandbox's destruction, so they stay usable for
|
|
420
|
+
attribution and support long after the sandbox is gone.
|
|
421
|
+
"""
|
|
422
|
+
sid = urllib.parse.quote(self.id, safe="")
|
|
423
|
+
updated = self._client.request(
|
|
424
|
+
"PATCH", f"/run-cloud/sandboxes/{sid}/tags", {"tags": tags}
|
|
425
|
+
)
|
|
426
|
+
if isinstance(updated, dict) and isinstance(updated.get("tags"), dict):
|
|
427
|
+
self._data["tags"] = updated["tags"]
|
|
428
|
+
return self
|
|
429
|
+
|
|
404
430
|
def refresh(self) -> "Sandbox":
|
|
405
431
|
self._data = self._client.request(
|
|
406
432
|
"GET", f"/run-cloud/sandboxes/{urllib.parse.quote(self.id, safe='')}"
|
|
@@ -416,6 +416,35 @@ class SDKTests(unittest.TestCase):
|
|
|
416
416
|
self.assertIsNone(delete_request.get_header("Content-type"))
|
|
417
417
|
self.assertEqual(post_request.get_header("Content-type"), "application/json")
|
|
418
418
|
|
|
419
|
+
def test_tags_are_sent_on_create_and_exposed_on_the_record(self):
|
|
420
|
+
box = self.client.create(tags={"newly.session": "sess-1"})
|
|
421
|
+
method, path, body = self.recorder.calls[0]
|
|
422
|
+
self.assertEqual((method, path), ("POST", "/run-cloud/sandboxes"))
|
|
423
|
+
self.assertEqual(body["tags"], {"newly.session": "sess-1"})
|
|
424
|
+
# The fixture carries no tags, so an untagged payload must read as {}.
|
|
425
|
+
self.assertEqual(box.tags, {})
|
|
426
|
+
|
|
427
|
+
def test_create_omits_tags_when_none_are_given(self):
|
|
428
|
+
self.client.create()
|
|
429
|
+
_, _, body = self.recorder.calls[0]
|
|
430
|
+
self.assertNotIn("tags", body)
|
|
431
|
+
|
|
432
|
+
def test_list_ands_repeated_tag_filters(self):
|
|
433
|
+
self.client.list(state="running", tags={"newly.role": "agent", "env": "dev"})
|
|
434
|
+
_, path, _ = self.recorder.calls[0]
|
|
435
|
+
self.assertEqual(
|
|
436
|
+
path,
|
|
437
|
+
"/run-cloud/sandboxes?state=running&tag=newly.role%3Aagent&tag=env%3Adev",
|
|
438
|
+
)
|
|
439
|
+
|
|
440
|
+
def test_set_tags_patches_and_keeps_null_delete_markers(self):
|
|
441
|
+
box = self.client.create()
|
|
442
|
+
box.set_tags({"newly.role": "agent", "gone": None})
|
|
443
|
+
method, path, body = self.recorder.calls[-1]
|
|
444
|
+
self.assertEqual(method, "PATCH")
|
|
445
|
+
self.assertEqual(path, "/run-cloud/sandboxes/sb_python/tags")
|
|
446
|
+
self.assertEqual(body, {"tags": {"newly.role": "agent", "gone": None}})
|
|
447
|
+
|
|
419
448
|
|
|
420
449
|
class CredentialTests(unittest.TestCase):
|
|
421
450
|
def setUp(self):
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|