boxd 0.1.0.dev2__tar.gz → 0.1.1.dev4__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.
Files changed (39) hide show
  1. {boxd-0.1.0.dev2/src/boxd.egg-info → boxd-0.1.1.dev4}/PKG-INFO +15 -4
  2. {boxd-0.1.0.dev2 → boxd-0.1.1.dev4}/README.md +14 -3
  3. {boxd-0.1.0.dev2 → boxd-0.1.1.dev4}/pyproject.toml +1 -1
  4. {boxd-0.1.0.dev2 → boxd-0.1.1.dev4}/src/boxd/__init__.py +7 -1
  5. {boxd-0.1.0.dev2 → boxd-0.1.1.dev4}/src/boxd/_sync.py +2 -0
  6. {boxd-0.1.0.dev2 → boxd-0.1.1.dev4}/src/boxd/client.py +30 -2
  7. {boxd-0.1.0.dev2 → boxd-0.1.1.dev4/src/boxd.egg-info}/PKG-INFO +15 -4
  8. {boxd-0.1.0.dev2 → boxd-0.1.1.dev4}/LICENSE +0 -0
  9. {boxd-0.1.0.dev2 → boxd-0.1.1.dev4}/setup.cfg +0 -0
  10. {boxd-0.1.0.dev2 → boxd-0.1.1.dev4}/src/boxd/_generated/__init__.py +0 -0
  11. {boxd-0.1.0.dev2 → boxd-0.1.1.dev4}/src/boxd/_generated/api_pb2.py +0 -0
  12. {boxd-0.1.0.dev2 → boxd-0.1.1.dev4}/src/boxd/_generated/api_pb2_grpc.py +0 -0
  13. {boxd-0.1.0.dev2 → boxd-0.1.1.dev4}/src/boxd/_utils.py +0 -0
  14. {boxd-0.1.0.dev2 → boxd-0.1.1.dev4}/src/boxd/aio.py +0 -0
  15. {boxd-0.1.0.dev2 → boxd-0.1.1.dev4}/src/boxd/auth.py +0 -0
  16. {boxd-0.1.0.dev2 → boxd-0.1.1.dev4}/src/boxd/box.py +0 -0
  17. {boxd-0.1.0.dev2 → boxd-0.1.1.dev4}/src/boxd/boxes.py +0 -0
  18. {boxd-0.1.0.dev2 → boxd-0.1.1.dev4}/src/boxd/disks.py +0 -0
  19. {boxd-0.1.0.dev2 → boxd-0.1.1.dev4}/src/boxd/domains.py +0 -0
  20. {boxd-0.1.0.dev2 → boxd-0.1.1.dev4}/src/boxd/errors.py +0 -0
  21. {boxd-0.1.0.dev2 → boxd-0.1.1.dev4}/src/boxd/exec.py +0 -0
  22. {boxd-0.1.0.dev2 → boxd-0.1.1.dev4}/src/boxd/networks.py +0 -0
  23. {boxd-0.1.0.dev2 → boxd-0.1.1.dev4}/src/boxd/templates.py +0 -0
  24. {boxd-0.1.0.dev2 → boxd-0.1.1.dev4}/src/boxd/tokens.py +0 -0
  25. {boxd-0.1.0.dev2 → boxd-0.1.1.dev4}/src/boxd/types.py +0 -0
  26. {boxd-0.1.0.dev2 → boxd-0.1.1.dev4}/src/boxd.egg-info/SOURCES.txt +0 -0
  27. {boxd-0.1.0.dev2 → boxd-0.1.1.dev4}/src/boxd.egg-info/dependency_links.txt +0 -0
  28. {boxd-0.1.0.dev2 → boxd-0.1.1.dev4}/src/boxd.egg-info/requires.txt +0 -0
  29. {boxd-0.1.0.dev2 → boxd-0.1.1.dev4}/src/boxd.egg-info/top_level.txt +0 -0
  30. {boxd-0.1.0.dev2 → boxd-0.1.1.dev4}/tests/test_auth.py +0 -0
  31. {boxd-0.1.0.dev2 → boxd-0.1.1.dev4}/tests/test_boxes.py +0 -0
  32. {boxd-0.1.0.dev2 → boxd-0.1.1.dev4}/tests/test_e2e.py +0 -0
  33. {boxd-0.1.0.dev2 → boxd-0.1.1.dev4}/tests/test_e2e_v2.py +0 -0
  34. {boxd-0.1.0.dev2 → boxd-0.1.1.dev4}/tests/test_exec.py +0 -0
  35. {boxd-0.1.0.dev2 → boxd-0.1.1.dev4}/tests/test_files.py +0 -0
  36. {boxd-0.1.0.dev2 → boxd-0.1.1.dev4}/tests/test_lifecycle.py +0 -0
  37. {boxd-0.1.0.dev2 → boxd-0.1.1.dev4}/tests/test_proxies.py +0 -0
  38. {boxd-0.1.0.dev2 → boxd-0.1.1.dev4}/tests/test_utils.py +0 -0
  39. {boxd-0.1.0.dev2 → boxd-0.1.1.dev4}/tests/test_v2.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: boxd
3
- Version: 0.1.0.dev2
3
+ Version: 0.1.1.dev4
4
4
  Summary: Python SDK for the boxd cloud VM platform
5
5
  Author: Azin
6
6
  License-Expression: MIT
@@ -65,16 +65,27 @@ Compute() # reads BOXD_API_KEY or BOXD_TOKEN
65
65
 
66
66
  ## Configuration
67
67
 
68
- The SDK reads its endpoint configuration from constructor arguments or env vars:
68
+ Pick a named cluster preset:
69
+
70
+ ```python
71
+ Compute(api_key="bxk_...") # production (default)
72
+ Compute(api_key="bxd_...", environment="staging") # boxd-stg.sh
73
+ ```
74
+
75
+ `environment` also reads from the `BOXD_ENVIRONMENT` env var (`"production"` or `"staging"`).
76
+
77
+ For custom or self-hosted endpoints, override URLs explicitly — these take precedence over `environment`:
69
78
 
70
79
  ```python
71
80
  Compute(
72
81
  api_key="bxk_...",
73
- api_url="http://boxd.sh:9443", # default
74
- exchange_url="https://boxd.sh/api/v1/auth/token", # default
82
+ api_url="http://my-boxd.example.com:9443",
83
+ exchange_url="https://my-boxd.example.com/api/v1/auth/token",
75
84
  )
76
85
  ```
77
86
 
87
+ Env vars `BOXD_API_URL` / `BOXD_EXCHANGE_URL` override the preset too.
88
+
78
89
  Equivalent env vars: `BOXD_API_KEY`, `BOXD_TOKEN`, `BOXD_API_URL`, `BOXD_EXCHANGE_URL`.
79
90
 
80
91
  `api_url` accepts an optional URL scheme that controls TLS:
@@ -32,16 +32,27 @@ Compute() # reads BOXD_API_KEY or BOXD_TOKEN
32
32
 
33
33
  ## Configuration
34
34
 
35
- The SDK reads its endpoint configuration from constructor arguments or env vars:
35
+ Pick a named cluster preset:
36
+
37
+ ```python
38
+ Compute(api_key="bxk_...") # production (default)
39
+ Compute(api_key="bxd_...", environment="staging") # boxd-stg.sh
40
+ ```
41
+
42
+ `environment` also reads from the `BOXD_ENVIRONMENT` env var (`"production"` or `"staging"`).
43
+
44
+ For custom or self-hosted endpoints, override URLs explicitly — these take precedence over `environment`:
36
45
 
37
46
  ```python
38
47
  Compute(
39
48
  api_key="bxk_...",
40
- api_url="http://boxd.sh:9443", # default
41
- exchange_url="https://boxd.sh/api/v1/auth/token", # default
49
+ api_url="http://my-boxd.example.com:9443",
50
+ exchange_url="https://my-boxd.example.com/api/v1/auth/token",
42
51
  )
43
52
  ```
44
53
 
54
+ Env vars `BOXD_API_URL` / `BOXD_EXCHANGE_URL` override the preset too.
55
+
45
56
  Equivalent env vars: `BOXD_API_KEY`, `BOXD_TOKEN`, `BOXD_API_URL`, `BOXD_EXCHANGE_URL`.
46
57
 
47
58
  `api_url` accepts an optional URL scheme that controls TLS:
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "boxd"
3
- version = "0.1.0.dev2"
3
+ version = "0.1.1.dev4"
4
4
  description = "Python SDK for the boxd cloud VM platform"
5
5
  readme = "README.md"
6
6
  license = "MIT"
@@ -63,7 +63,13 @@ from .errors import (
63
63
  ConnectionError,
64
64
  )
65
65
 
66
- __version__ = "0.1.0"
66
+ try:
67
+ from importlib.metadata import version as _pkg_version
68
+
69
+ __version__ = _pkg_version("boxd")
70
+ except Exception:
71
+ # Fallback for source checkouts where the package isn't installed.
72
+ __version__ = "0.0.0+source"
67
73
 
68
74
  __all__ = [
69
75
  # Main client (sync)
@@ -411,6 +411,7 @@ class Compute(_SyncBase):
411
411
  token: str | None = None,
412
412
  api_url: str | None = None,
413
413
  exchange_url: str | None = None,
414
+ environment: str | None = None,
414
415
  ) -> None:
415
416
  from .client import Compute as AsyncCompute
416
417
 
@@ -420,6 +421,7 @@ class Compute(_SyncBase):
420
421
  token=token,
421
422
  api_url=api_url,
422
423
  exchange_url=exchange_url,
424
+ environment=environment,
423
425
  )
424
426
  self.box = BoxService(self._async.box, self._loop)
425
427
  self.template = TemplateService(self._async.template, self._loop)
@@ -22,6 +22,31 @@ from .types import ConfigResult, WhoamiResult
22
22
  _DEFAULT_API_URL = "http://boxd.sh:9443"
23
23
  _DEFAULT_EXCHANGE_URL = "https://boxd.sh/api/v1/auth/token"
24
24
 
25
+ # Named environments. Each is a (api_url, exchange_url) preset; explicit
26
+ # api_url / exchange_url args still override.
27
+ _ENVIRONMENT_URLS: dict[str, tuple[str, str]] = {
28
+ "production": (_DEFAULT_API_URL, _DEFAULT_EXCHANGE_URL),
29
+ "staging": (
30
+ "http://boxd-stg.sh:9443",
31
+ "https://boxd-stg.sh/api/v1/auth/token",
32
+ ),
33
+ }
34
+
35
+
36
+ def _resolve_environment(explicit: str | None) -> str:
37
+ """Pick environment preset: explicit arg > BOXD_ENVIRONMENT env > production."""
38
+ if explicit:
39
+ if explicit not in _ENVIRONMENT_URLS:
40
+ raise ValueError(
41
+ f"unknown environment {explicit!r}; expected one of "
42
+ f"{sorted(_ENVIRONMENT_URLS)}"
43
+ )
44
+ return explicit
45
+ from_env = os.environ.get("BOXD_ENVIRONMENT")
46
+ if from_env in _ENVIRONMENT_URLS:
47
+ return from_env
48
+ return "production"
49
+
25
50
 
26
51
  class Compute:
27
52
  """Main client for the boxd API.
@@ -39,16 +64,19 @@ class Compute:
39
64
  token: str | None = None,
40
65
  api_url: str | None = None,
41
66
  exchange_url: str | None = None,
67
+ environment: str | None = None,
42
68
  ) -> None:
69
+ env = _resolve_environment(environment)
70
+ preset_api_url, preset_exchange_url = _ENVIRONMENT_URLS[env]
43
71
  self._api_url = (
44
72
  api_url
45
73
  or os.environ.get("BOXD_API_URL")
46
- or _DEFAULT_API_URL
74
+ or preset_api_url
47
75
  )
48
76
  self._exchange_url = (
49
77
  exchange_url
50
78
  or os.environ.get("BOXD_EXCHANGE_URL")
51
- or _DEFAULT_EXCHANGE_URL
79
+ or preset_exchange_url
52
80
  )
53
81
 
54
82
  resolved_key = api_key or os.environ.get("BOXD_API_KEY")
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: boxd
3
- Version: 0.1.0.dev2
3
+ Version: 0.1.1.dev4
4
4
  Summary: Python SDK for the boxd cloud VM platform
5
5
  Author: Azin
6
6
  License-Expression: MIT
@@ -65,16 +65,27 @@ Compute() # reads BOXD_API_KEY or BOXD_TOKEN
65
65
 
66
66
  ## Configuration
67
67
 
68
- The SDK reads its endpoint configuration from constructor arguments or env vars:
68
+ Pick a named cluster preset:
69
+
70
+ ```python
71
+ Compute(api_key="bxk_...") # production (default)
72
+ Compute(api_key="bxd_...", environment="staging") # boxd-stg.sh
73
+ ```
74
+
75
+ `environment` also reads from the `BOXD_ENVIRONMENT` env var (`"production"` or `"staging"`).
76
+
77
+ For custom or self-hosted endpoints, override URLs explicitly — these take precedence over `environment`:
69
78
 
70
79
  ```python
71
80
  Compute(
72
81
  api_key="bxk_...",
73
- api_url="http://boxd.sh:9443", # default
74
- exchange_url="https://boxd.sh/api/v1/auth/token", # default
82
+ api_url="http://my-boxd.example.com:9443",
83
+ exchange_url="https://my-boxd.example.com/api/v1/auth/token",
75
84
  )
76
85
  ```
77
86
 
87
+ Env vars `BOXD_API_URL` / `BOXD_EXCHANGE_URL` override the preset too.
88
+
78
89
  Equivalent env vars: `BOXD_API_KEY`, `BOXD_TOKEN`, `BOXD_API_URL`, `BOXD_EXCHANGE_URL`.
79
90
 
80
91
  `api_url` accepts an optional URL scheme that controls TLS:
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
File without changes
File without changes
File without changes
File without changes
File without changes