Skip to main content

Async Python client for Drukbox.

Project description

drukbox-python-sdk

Async Python client for the Drukbox host API.

The SDK provisions sandbox VMs, reads host state, deletes hosts, and returns the SSH connection details a caller needs. It speaks HTTP only: SSH sessions, file transfer, command execution, and retry orchestration belong in the caller.

Install

pip install drukbox-python-sdk
uv add drukbox-python-sdk

Usage

from drukbox_sdk import SandboxAPI

sandbox = SandboxAPI(
    base_url="https://sandbox.internal.ts.net",
    token="...",
)

try:
    host = await sandbox.create_host(
        image="ghcr.io/drukbox/sandbox:abc123",
        env={"FOO": "bar"},
        idempotency_key="agent-run-42",
    )
    # Use host.external_ssh_host (or host.internal_ssh_host when the
    # service runs with Tailscale enabled), host.external_ssh_port,
    # and host.known_hosts with asyncssh or another SSH client.
finally:
    await sandbox.delete_host(host.id)
    await sandbox.aclose()

create_host blocks until the host is active — typically ~10–30s, up to a few minutes worst case. The SDK's default timeout (300s) covers this. Pass an idempotency_key for retry safety: a retry with the same key after a successful provision returns the original host instead of creating a duplicate.

SandboxAPI.from_env(prefix="SANDBOX_") reads SANDBOX_SERVICE_URL, SANDBOX_SERVICE_TOKEN, and optional SANDBOX_SERVICE_TIMEOUT.

Contract

Public exports live in drukbox_sdk:

  • SandboxAPI
  • SandboxHost
  • SandboxAPIError and typed subclasses for auth, not found, conflict, unavailable, and unclassified response errors

Supported host operations:

  • create_host
  • get_host
  • attach
  • list_hosts
  • delete_host
  • aclose

create_host supports the service's optional image, env, expires_at, and Idempotency-Key inputs.

The SDK does not mint Tailscale auth keys, manage ACLs, establish SSH, provision Linux users, transfer files, or run remote commands.

Development

uv sync
uv run ruff check
uv run ruff format --check
uv run pyright
uv run pytest

Tests use respx to fake the Drukbox HTTP API. They do not need a real network, VM provider, or Drukbox service.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

drukbox_python_sdk-0.0.1.tar.gz (11.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

drukbox_python_sdk-0.0.1-py3-none-any.whl (7.8 kB view details)

Uploaded Python 3

File details

Details for the file drukbox_python_sdk-0.0.1.tar.gz.

File metadata

  • Download URL: drukbox_python_sdk-0.0.1.tar.gz
  • Upload date:
  • Size: 11.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for drukbox_python_sdk-0.0.1.tar.gz
Algorithm Hash digest
SHA256 d8c10a6f51c0dd8a92c5ff012cd1ea625584b678aa03c9a0779e6a427f85eeb7
MD5 f483931e9920fdcaa6850c4ee97c1d3a
BLAKE2b-256 f35dc7dea248b49deda46da7e449c3f1ee23edcfc6307b73117f4431fed1d1f0

See more details on using hashes here.

Provenance

The following attestation bundles were made for drukbox_python_sdk-0.0.1.tar.gz:

Publisher: release.yml on clawhaven/drukbox-python-sdk

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file drukbox_python_sdk-0.0.1-py3-none-any.whl.

File metadata

File hashes

Hashes for drukbox_python_sdk-0.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 b1385fa7157304d96c877c99499e9cc78007de2a12212a8669c4d2cff899a6bd
MD5 a14a39fae87e4d83509da65b471bf89a
BLAKE2b-256 95c8402843cabaa4fa92920b6016c2f5a1a9f330fcf77ce8d32fc03789b96cb7

See more details on using hashes here.

Provenance

The following attestation bundles were made for drukbox_python_sdk-0.0.1-py3-none-any.whl:

Publisher: release.yml on clawhaven/drukbox-python-sdk

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page