universal-sandbox 0.0.6__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 (59) hide show
  1. universal_sandbox-0.0.6/PKG-INFO +138 -0
  2. universal_sandbox-0.0.6/README.md +103 -0
  3. universal_sandbox-0.0.6/setup.cfg +4 -0
  4. universal_sandbox-0.0.6/setup.py +40 -0
  5. universal_sandbox-0.0.6/universal_sandbox/__init__.py +50 -0
  6. universal_sandbox-0.0.6/universal_sandbox/aio/__init__.py +4 -0
  7. universal_sandbox-0.0.6/universal_sandbox/aio/client.py +156 -0
  8. universal_sandbox-0.0.6/universal_sandbox/aio/raw_client.py +177 -0
  9. universal_sandbox-0.0.6/universal_sandbox/browser/__init__.py +4 -0
  10. universal_sandbox-0.0.6/universal_sandbox/browser/client.py +156 -0
  11. universal_sandbox-0.0.6/universal_sandbox/browser/raw_client.py +177 -0
  12. universal_sandbox-0.0.6/universal_sandbox/client.py +375 -0
  13. universal_sandbox-0.0.6/universal_sandbox/code_interpreter/__init__.py +4 -0
  14. universal_sandbox-0.0.6/universal_sandbox/code_interpreter/client.py +257 -0
  15. universal_sandbox-0.0.6/universal_sandbox/code_interpreter/raw_client.py +315 -0
  16. universal_sandbox-0.0.6/universal_sandbox/core/__init__.py +52 -0
  17. universal_sandbox-0.0.6/universal_sandbox/core/api_error.py +23 -0
  18. universal_sandbox-0.0.6/universal_sandbox/core/client_wrapper.py +84 -0
  19. universal_sandbox-0.0.6/universal_sandbox/core/datetime_utils.py +28 -0
  20. universal_sandbox-0.0.6/universal_sandbox/core/file.py +67 -0
  21. universal_sandbox-0.0.6/universal_sandbox/core/force_multipart.py +16 -0
  22. universal_sandbox-0.0.6/universal_sandbox/core/http_client.py +543 -0
  23. universal_sandbox-0.0.6/universal_sandbox/core/http_response.py +55 -0
  24. universal_sandbox-0.0.6/universal_sandbox/core/jsonable_encoder.py +100 -0
  25. universal_sandbox-0.0.6/universal_sandbox/core/pydantic_utilities.py +255 -0
  26. universal_sandbox-0.0.6/universal_sandbox/core/query_encoder.py +58 -0
  27. universal_sandbox-0.0.6/universal_sandbox/core/remove_none_from_dict.py +11 -0
  28. universal_sandbox-0.0.6/universal_sandbox/core/request_options.py +35 -0
  29. universal_sandbox-0.0.6/universal_sandbox/core/serialization.py +276 -0
  30. universal_sandbox-0.0.6/universal_sandbox/environment.py +7 -0
  31. universal_sandbox-0.0.6/universal_sandbox/errors/__init__.py +7 -0
  32. universal_sandbox-0.0.6/universal_sandbox/errors/unprocessable_entity_error.py +11 -0
  33. universal_sandbox-0.0.6/universal_sandbox/raw_client.py +238 -0
  34. universal_sandbox-0.0.6/universal_sandbox/sandboxes/__init__.py +4 -0
  35. universal_sandbox-0.0.6/universal_sandbox/sandboxes/client.py +344 -0
  36. universal_sandbox-0.0.6/universal_sandbox/sandboxes/raw_client.py +432 -0
  37. universal_sandbox-0.0.6/universal_sandbox/tokens/__init__.py +4 -0
  38. universal_sandbox-0.0.6/universal_sandbox/tokens/client.py +357 -0
  39. universal_sandbox-0.0.6/universal_sandbox/tokens/raw_client.py +447 -0
  40. universal_sandbox-0.0.6/universal_sandbox/types/__init__.py +35 -0
  41. universal_sandbox-0.0.6/universal_sandbox/types/create_sandbox_request.py +42 -0
  42. universal_sandbox-0.0.6/universal_sandbox/types/delete_response.py +25 -0
  43. universal_sandbox-0.0.6/universal_sandbox/types/execute_request.py +31 -0
  44. universal_sandbox-0.0.6/universal_sandbox/types/execute_response.py +26 -0
  45. universal_sandbox-0.0.6/universal_sandbox/types/health_status.py +34 -0
  46. universal_sandbox-0.0.6/universal_sandbox/types/http_validation_error.py +20 -0
  47. universal_sandbox-0.0.6/universal_sandbox/types/limits_response.py +25 -0
  48. universal_sandbox-0.0.6/universal_sandbox/types/sandbox_list_response.py +25 -0
  49. universal_sandbox-0.0.6/universal_sandbox/types/sandbox_provider.py +5 -0
  50. universal_sandbox-0.0.6/universal_sandbox/types/sandbox_response.py +32 -0
  51. universal_sandbox-0.0.6/universal_sandbox/types/sandbox_urls.py +26 -0
  52. universal_sandbox-0.0.6/universal_sandbox/types/token_response.py +33 -0
  53. universal_sandbox-0.0.6/universal_sandbox/types/validation_error.py +22 -0
  54. universal_sandbox-0.0.6/universal_sandbox/types/validation_error_loc_item.py +5 -0
  55. universal_sandbox-0.0.6/universal_sandbox.egg-info/PKG-INFO +138 -0
  56. universal_sandbox-0.0.6/universal_sandbox.egg-info/SOURCES.txt +57 -0
  57. universal_sandbox-0.0.6/universal_sandbox.egg-info/dependency_links.txt +1 -0
  58. universal_sandbox-0.0.6/universal_sandbox.egg-info/requires.txt +1 -0
  59. universal_sandbox-0.0.6/universal_sandbox.egg-info/top_level.txt +1 -0
@@ -0,0 +1,138 @@
1
+ Metadata-Version: 2.4
2
+ Name: universal-sandbox
3
+ Version: 0.0.6
4
+ Summary: Python SDK for Universal Sandbox API
5
+ Home-page: https://github.com/universal-sandbox/sdk-python
6
+ Author: Universal Sandbox
7
+ Author-email: support@ai-infra.org
8
+ License: MIT
9
+ Project-URL: Documentation, https://api.sandbox.ai-infra.org/docs
10
+ Project-URL: Source, https://github.com/universal-sandbox/sdk-python
11
+ Project-URL: Bug Reports, https://github.com/universal-sandbox/sdk-python/issues
12
+ Classifier: Development Status :: 4 - Beta
13
+ Classifier: Intended Audience :: Developers
14
+ Classifier: License :: OSI Approved :: MIT License
15
+ Classifier: Programming Language :: Python :: 3
16
+ Classifier: Programming Language :: Python :: 3.8
17
+ Classifier: Programming Language :: Python :: 3.9
18
+ Classifier: Programming Language :: Python :: 3.10
19
+ Classifier: Programming Language :: Python :: 3.11
20
+ Classifier: Programming Language :: Python :: 3.12
21
+ Requires-Python: >=3.8
22
+ Description-Content-Type: text/markdown
23
+ Requires-Dist: requests>=2.25.0
24
+ Dynamic: author
25
+ Dynamic: author-email
26
+ Dynamic: classifier
27
+ Dynamic: description
28
+ Dynamic: description-content-type
29
+ Dynamic: home-page
30
+ Dynamic: license
31
+ Dynamic: project-url
32
+ Dynamic: requires-dist
33
+ Dynamic: requires-python
34
+ Dynamic: summary
35
+
36
+ # Universal Sandbox Python SDK
37
+
38
+ Python SDK for Universal Sandbox API.
39
+
40
+ 📖 **[API Documentation](https://api.sandbox.ai-infra.org/docs)**
41
+
42
+ ## Installation
43
+
44
+ ```bash
45
+ pip install universal-sandbox
46
+ ```
47
+
48
+ ## Usage
49
+
50
+ For more detailed usage, please refer to [example.py](./example.py)
51
+
52
+ ```python
53
+ from universal_sandbox import Sandbox
54
+
55
+ # Initialize client
56
+ # Get Sandbox API Token from https://ai-infra.org/
57
+ sandbox = Sandbox(token="sandbox-api-token")
58
+
59
+ # Check API health
60
+ health = sandbox.check_health()
61
+ print(health.status)
62
+
63
+ # Create a code interpreter sandbox
64
+ sb = sandbox.code_interpreter.create()
65
+ print(f"Sandbox ID: {sb.id}")
66
+ print(f"Provider: {sb.provider}")
67
+
68
+ # Execute code
69
+ result = sandbox.sandboxes.execute(sb.id, command="print('Hello, World!')")
70
+ print(result.stdout)
71
+
72
+ # Get sandbox info
73
+ info = sandbox.sandboxes.get(sb.id)
74
+ print(f"Status: {info.status}")
75
+
76
+ # List all sandboxes
77
+ sandbox_list = sandbox.sandboxes.list()
78
+ print(f"Total: {sandbox_list.total}")
79
+
80
+ # Delete sandbox
81
+ sandbox.sandboxes.delete(sb.id)
82
+ ```
83
+
84
+ ## API to SDK Mapping
85
+
86
+ | API Endpoint | SDK Interface |
87
+ |------------------------------------|--------------------------------------|
88
+ | `GET /health` | `sandbox.check_health()` |
89
+ | `GET /regions` | `sandbox.list_regions()` |
90
+ | `GET /limits` | `sandbox.get_limits()` |
91
+ | `POST /sandboxes/code-interpreter` | `sandbox.code_interpreter.create()` |
92
+ | `POST /sandboxes/browser` | `sandbox.browser.create()` |
93
+ | `POST /sandboxes/aio` | `sandbox.aio.create()` |
94
+ | `GET /sandboxes` | `sandbox.sandboxes.list()` |
95
+ | `GET /sandboxes/{id}` | `sandbox.sandboxes.get()` |
96
+ | `DELETE /sandboxes/{id}` | `sandbox.sandboxes.delete()` |
97
+ | `POST /sandboxes/{id}/execute` | `sandbox.sandboxes.execute()` |
98
+ | `POST /admin/tokens` | `sandbox.tokens.issue()` |
99
+ | `POST /admin/tokens/{prefix}/revoke` | `sandbox.tokens.revoke()` |
100
+ | `GET /admin/users/{user_id}/token` | `sandbox.tokens.get()` |
101
+
102
+ ## API Reference
103
+
104
+ ### Sandbox Client
105
+
106
+ ```python
107
+ from universal_sandbox import Sandbox
108
+
109
+ sandbox = Sandbox(
110
+ token="your-token", # API token (optional if auth disabled)
111
+ base_url="https://...", # Optional, defaults to production
112
+ )
113
+ ```
114
+
115
+ ### Root Methods
116
+
117
+ - `sandbox.check_health()` - Check API health status
118
+ - `sandbox.list_regions()` - List available regions for all providers
119
+ - `sandbox.get_limits()` - Get resource limits and current usage
120
+
121
+ ### Sandbox Creation
122
+
123
+ - `sandbox.code_interpreter.create(provider, timeout_minutes, region, metadata)` - Create code interpreter
124
+ - `sandbox.browser.create(provider, timeout_minutes, region, metadata)` - Create browser sandbox
125
+ - `sandbox.aio.create(provider, timeout_minutes, region, metadata)` - Create all-in-one sandbox (only supports `provider="volcengine"`)
126
+
127
+ ### Sandbox Management
128
+
129
+ - `sandbox.sandboxes.list()` - List all sandboxes
130
+ - `sandbox.sandboxes.get(sandbox_id)` - Get sandbox by ID
131
+ - `sandbox.sandboxes.delete(sandbox_id)` - Delete a sandbox
132
+ - `sandbox.sandboxes.execute(sandbox_id, command, timeout)` - Execute command
133
+
134
+ ### Token Management (Admin)
135
+
136
+ - `sandbox.tokens.issue(...)` - Create a personal access token
137
+ - `sandbox.tokens.revoke(prefix)` - Revoke a token
138
+ - `sandbox.tokens.get(user_id)` - Get user's token
@@ -0,0 +1,103 @@
1
+ # Universal Sandbox Python SDK
2
+
3
+ Python SDK for Universal Sandbox API.
4
+
5
+ 📖 **[API Documentation](https://api.sandbox.ai-infra.org/docs)**
6
+
7
+ ## Installation
8
+
9
+ ```bash
10
+ pip install universal-sandbox
11
+ ```
12
+
13
+ ## Usage
14
+
15
+ For more detailed usage, please refer to [example.py](./example.py)
16
+
17
+ ```python
18
+ from universal_sandbox import Sandbox
19
+
20
+ # Initialize client
21
+ # Get Sandbox API Token from https://ai-infra.org/
22
+ sandbox = Sandbox(token="sandbox-api-token")
23
+
24
+ # Check API health
25
+ health = sandbox.check_health()
26
+ print(health.status)
27
+
28
+ # Create a code interpreter sandbox
29
+ sb = sandbox.code_interpreter.create()
30
+ print(f"Sandbox ID: {sb.id}")
31
+ print(f"Provider: {sb.provider}")
32
+
33
+ # Execute code
34
+ result = sandbox.sandboxes.execute(sb.id, command="print('Hello, World!')")
35
+ print(result.stdout)
36
+
37
+ # Get sandbox info
38
+ info = sandbox.sandboxes.get(sb.id)
39
+ print(f"Status: {info.status}")
40
+
41
+ # List all sandboxes
42
+ sandbox_list = sandbox.sandboxes.list()
43
+ print(f"Total: {sandbox_list.total}")
44
+
45
+ # Delete sandbox
46
+ sandbox.sandboxes.delete(sb.id)
47
+ ```
48
+
49
+ ## API to SDK Mapping
50
+
51
+ | API Endpoint | SDK Interface |
52
+ |------------------------------------|--------------------------------------|
53
+ | `GET /health` | `sandbox.check_health()` |
54
+ | `GET /regions` | `sandbox.list_regions()` |
55
+ | `GET /limits` | `sandbox.get_limits()` |
56
+ | `POST /sandboxes/code-interpreter` | `sandbox.code_interpreter.create()` |
57
+ | `POST /sandboxes/browser` | `sandbox.browser.create()` |
58
+ | `POST /sandboxes/aio` | `sandbox.aio.create()` |
59
+ | `GET /sandboxes` | `sandbox.sandboxes.list()` |
60
+ | `GET /sandboxes/{id}` | `sandbox.sandboxes.get()` |
61
+ | `DELETE /sandboxes/{id}` | `sandbox.sandboxes.delete()` |
62
+ | `POST /sandboxes/{id}/execute` | `sandbox.sandboxes.execute()` |
63
+ | `POST /admin/tokens` | `sandbox.tokens.issue()` |
64
+ | `POST /admin/tokens/{prefix}/revoke` | `sandbox.tokens.revoke()` |
65
+ | `GET /admin/users/{user_id}/token` | `sandbox.tokens.get()` |
66
+
67
+ ## API Reference
68
+
69
+ ### Sandbox Client
70
+
71
+ ```python
72
+ from universal_sandbox import Sandbox
73
+
74
+ sandbox = Sandbox(
75
+ token="your-token", # API token (optional if auth disabled)
76
+ base_url="https://...", # Optional, defaults to production
77
+ )
78
+ ```
79
+
80
+ ### Root Methods
81
+
82
+ - `sandbox.check_health()` - Check API health status
83
+ - `sandbox.list_regions()` - List available regions for all providers
84
+ - `sandbox.get_limits()` - Get resource limits and current usage
85
+
86
+ ### Sandbox Creation
87
+
88
+ - `sandbox.code_interpreter.create(provider, timeout_minutes, region, metadata)` - Create code interpreter
89
+ - `sandbox.browser.create(provider, timeout_minutes, region, metadata)` - Create browser sandbox
90
+ - `sandbox.aio.create(provider, timeout_minutes, region, metadata)` - Create all-in-one sandbox (only supports `provider="volcengine"`)
91
+
92
+ ### Sandbox Management
93
+
94
+ - `sandbox.sandboxes.list()` - List all sandboxes
95
+ - `sandbox.sandboxes.get(sandbox_id)` - Get sandbox by ID
96
+ - `sandbox.sandboxes.delete(sandbox_id)` - Delete a sandbox
97
+ - `sandbox.sandboxes.execute(sandbox_id, command, timeout)` - Execute command
98
+
99
+ ### Token Management (Admin)
100
+
101
+ - `sandbox.tokens.issue(...)` - Create a personal access token
102
+ - `sandbox.tokens.revoke(prefix)` - Revoke a token
103
+ - `sandbox.tokens.get(user_id)` - Get user's token
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1,40 @@
1
+ """Setup script for Universal Sandbox Python SDK."""
2
+ from setuptools import setup, find_packages
3
+ from pathlib import Path
4
+
5
+ # Read the README file
6
+ readme_file = Path(__file__).parent / "README.md"
7
+ long_description = readme_file.read_text(encoding="utf-8") if readme_file.exists() else ""
8
+
9
+ setup(
10
+ name="universal-sandbox",
11
+ version="0.0.6",
12
+ description="Python SDK for Universal Sandbox API",
13
+ long_description=long_description,
14
+ long_description_content_type="text/markdown",
15
+ author="Universal Sandbox",
16
+ author_email="support@ai-infra.org",
17
+ url="https://github.com/universal-sandbox/sdk-python",
18
+ project_urls={
19
+ "Documentation": "https://api.sandbox.ai-infra.org/docs",
20
+ "Source": "https://github.com/universal-sandbox/sdk-python",
21
+ "Bug Reports": "https://github.com/universal-sandbox/sdk-python/issues",
22
+ },
23
+ packages=find_packages(),
24
+ python_requires=">=3.8",
25
+ install_requires=[
26
+ "requests>=2.25.0",
27
+ ],
28
+ license="MIT",
29
+ classifiers=[
30
+ "Development Status :: 4 - Beta",
31
+ "Intended Audience :: Developers",
32
+ "License :: OSI Approved :: MIT License",
33
+ "Programming Language :: Python :: 3",
34
+ "Programming Language :: Python :: 3.8",
35
+ "Programming Language :: Python :: 3.9",
36
+ "Programming Language :: Python :: 3.10",
37
+ "Programming Language :: Python :: 3.11",
38
+ "Programming Language :: Python :: 3.12",
39
+ ],
40
+ )
@@ -0,0 +1,50 @@
1
+ # This file was auto-generated by Fern from our API Definition.
2
+
3
+ # isort: skip_file
4
+
5
+ from .types import (
6
+ CreateSandboxRequest,
7
+ DeleteResponse,
8
+ ExecuteRequest,
9
+ ExecuteResponse,
10
+ HealthStatus,
11
+ HttpValidationError,
12
+ LimitsResponse,
13
+ SandboxListResponse,
14
+ SandboxProvider,
15
+ SandboxResponse,
16
+ SandboxUrls,
17
+ TokenResponse,
18
+ ValidationError,
19
+ ValidationErrorLocItem,
20
+ )
21
+ from .errors import UnprocessableEntityError
22
+ from . import aio, browser, code_interpreter, sandboxes, tokens
23
+ from .client import AsyncSandbox, Sandbox
24
+ from .environment import SandboxEnvironment
25
+
26
+ __all__ = [
27
+ "AsyncSandbox",
28
+ "CreateSandboxRequest",
29
+ "DeleteResponse",
30
+ "ExecuteRequest",
31
+ "ExecuteResponse",
32
+ "HealthStatus",
33
+ "HttpValidationError",
34
+ "LimitsResponse",
35
+ "Sandbox",
36
+ "SandboxEnvironment",
37
+ "SandboxListResponse",
38
+ "SandboxProvider",
39
+ "SandboxResponse",
40
+ "SandboxUrls",
41
+ "TokenResponse",
42
+ "UnprocessableEntityError",
43
+ "ValidationError",
44
+ "ValidationErrorLocItem",
45
+ "aio",
46
+ "browser",
47
+ "code_interpreter",
48
+ "sandboxes",
49
+ "tokens",
50
+ ]
@@ -0,0 +1,4 @@
1
+ # This file was auto-generated by Fern from our API Definition.
2
+
3
+ # isort: skip_file
4
+
@@ -0,0 +1,156 @@
1
+ # This file was auto-generated by Fern from our API Definition.
2
+
3
+ import typing
4
+
5
+ from ..core.client_wrapper import AsyncClientWrapper, SyncClientWrapper
6
+ from ..core.request_options import RequestOptions
7
+ from ..types.sandbox_provider import SandboxProvider
8
+ from ..types.sandbox_response import SandboxResponse
9
+ from .raw_client import AsyncRawAioClient, RawAioClient
10
+
11
+ # this is used as the default value for optional parameters
12
+ OMIT = typing.cast(typing.Any, ...)
13
+
14
+
15
+ class AioClient:
16
+ def __init__(self, *, client_wrapper: SyncClientWrapper):
17
+ self._raw_client = RawAioClient(client_wrapper=client_wrapper)
18
+
19
+ @property
20
+ def with_raw_response(self) -> RawAioClient:
21
+ """
22
+ Retrieves a raw implementation of this client that returns raw responses.
23
+
24
+ Returns
25
+ -------
26
+ RawAioClient
27
+ """
28
+ return self._raw_client
29
+
30
+ def create(
31
+ self,
32
+ *,
33
+ provider: typing.Optional[SandboxProvider] = OMIT,
34
+ region: typing.Optional[str] = OMIT,
35
+ timeout_minutes: typing.Optional[int] = OMIT,
36
+ metadata: typing.Optional[typing.Dict[str, typing.Optional[typing.Any]]] = OMIT,
37
+ request_options: typing.Optional[RequestOptions] = None,
38
+ ) -> SandboxResponse:
39
+ """
40
+ Create a new all-in-one sandbox with shell, MCP, and VNC capabilities.
41
+
42
+ Parameters
43
+ ----------
44
+ provider : typing.Optional[SandboxProvider]
45
+ Provider to use (auto-detected if not specified)
46
+
47
+ region : typing.Optional[str]
48
+ Preferred region for the sandbox
49
+
50
+ timeout_minutes : typing.Optional[int]
51
+ Custom timeout in minutes
52
+
53
+ metadata : typing.Optional[typing.Dict[str, typing.Optional[typing.Any]]]
54
+ Additional metadata
55
+
56
+ request_options : typing.Optional[RequestOptions]
57
+ Request-specific configuration.
58
+
59
+ Returns
60
+ -------
61
+ SandboxResponse
62
+ Successful Response
63
+
64
+ Examples
65
+ --------
66
+ from ai_infra import Sandbox
67
+
68
+ client = Sandbox(
69
+ token="YOUR_TOKEN",
70
+ )
71
+ client.aio.create()
72
+ """
73
+ _response = self._raw_client.create(
74
+ provider=provider,
75
+ region=region,
76
+ timeout_minutes=timeout_minutes,
77
+ metadata=metadata,
78
+ request_options=request_options,
79
+ )
80
+ return _response.data
81
+
82
+
83
+ class AsyncAioClient:
84
+ def __init__(self, *, client_wrapper: AsyncClientWrapper):
85
+ self._raw_client = AsyncRawAioClient(client_wrapper=client_wrapper)
86
+
87
+ @property
88
+ def with_raw_response(self) -> AsyncRawAioClient:
89
+ """
90
+ Retrieves a raw implementation of this client that returns raw responses.
91
+
92
+ Returns
93
+ -------
94
+ AsyncRawAioClient
95
+ """
96
+ return self._raw_client
97
+
98
+ async def create(
99
+ self,
100
+ *,
101
+ provider: typing.Optional[SandboxProvider] = OMIT,
102
+ region: typing.Optional[str] = OMIT,
103
+ timeout_minutes: typing.Optional[int] = OMIT,
104
+ metadata: typing.Optional[typing.Dict[str, typing.Optional[typing.Any]]] = OMIT,
105
+ request_options: typing.Optional[RequestOptions] = None,
106
+ ) -> SandboxResponse:
107
+ """
108
+ Create a new all-in-one sandbox with shell, MCP, and VNC capabilities.
109
+
110
+ Parameters
111
+ ----------
112
+ provider : typing.Optional[SandboxProvider]
113
+ Provider to use (auto-detected if not specified)
114
+
115
+ region : typing.Optional[str]
116
+ Preferred region for the sandbox
117
+
118
+ timeout_minutes : typing.Optional[int]
119
+ Custom timeout in minutes
120
+
121
+ metadata : typing.Optional[typing.Dict[str, typing.Optional[typing.Any]]]
122
+ Additional metadata
123
+
124
+ request_options : typing.Optional[RequestOptions]
125
+ Request-specific configuration.
126
+
127
+ Returns
128
+ -------
129
+ SandboxResponse
130
+ Successful Response
131
+
132
+ Examples
133
+ --------
134
+ import asyncio
135
+
136
+ from ai_infra import AsyncSandbox
137
+
138
+ client = AsyncSandbox(
139
+ token="YOUR_TOKEN",
140
+ )
141
+
142
+
143
+ async def main() -> None:
144
+ await client.aio.create()
145
+
146
+
147
+ asyncio.run(main())
148
+ """
149
+ _response = await self._raw_client.create(
150
+ provider=provider,
151
+ region=region,
152
+ timeout_minutes=timeout_minutes,
153
+ metadata=metadata,
154
+ request_options=request_options,
155
+ )
156
+ return _response.data
@@ -0,0 +1,177 @@
1
+ # This file was auto-generated by Fern from our API Definition.
2
+
3
+ import typing
4
+ from json.decoder import JSONDecodeError
5
+
6
+ from ..core.api_error import ApiError
7
+ from ..core.client_wrapper import AsyncClientWrapper, SyncClientWrapper
8
+ from ..core.http_response import AsyncHttpResponse, HttpResponse
9
+ from ..core.pydantic_utilities import parse_obj_as
10
+ from ..core.request_options import RequestOptions
11
+ from ..errors.unprocessable_entity_error import UnprocessableEntityError
12
+ from ..types.http_validation_error import HttpValidationError
13
+ from ..types.sandbox_provider import SandboxProvider
14
+ from ..types.sandbox_response import SandboxResponse
15
+
16
+ # this is used as the default value for optional parameters
17
+ OMIT = typing.cast(typing.Any, ...)
18
+
19
+
20
+ class RawAioClient:
21
+ def __init__(self, *, client_wrapper: SyncClientWrapper):
22
+ self._client_wrapper = client_wrapper
23
+
24
+ def create(
25
+ self,
26
+ *,
27
+ provider: typing.Optional[SandboxProvider] = OMIT,
28
+ region: typing.Optional[str] = OMIT,
29
+ timeout_minutes: typing.Optional[int] = OMIT,
30
+ metadata: typing.Optional[typing.Dict[str, typing.Optional[typing.Any]]] = OMIT,
31
+ request_options: typing.Optional[RequestOptions] = None,
32
+ ) -> HttpResponse[SandboxResponse]:
33
+ """
34
+ Create a new all-in-one sandbox with shell, MCP, and VNC capabilities.
35
+
36
+ Parameters
37
+ ----------
38
+ provider : typing.Optional[SandboxProvider]
39
+ Provider to use (auto-detected if not specified)
40
+
41
+ region : typing.Optional[str]
42
+ Preferred region for the sandbox
43
+
44
+ timeout_minutes : typing.Optional[int]
45
+ Custom timeout in minutes
46
+
47
+ metadata : typing.Optional[typing.Dict[str, typing.Optional[typing.Any]]]
48
+ Additional metadata
49
+
50
+ request_options : typing.Optional[RequestOptions]
51
+ Request-specific configuration.
52
+
53
+ Returns
54
+ -------
55
+ HttpResponse[SandboxResponse]
56
+ Successful Response
57
+ """
58
+ _response = self._client_wrapper.httpx_client.request(
59
+ "sandboxes/aio",
60
+ method="POST",
61
+ json={
62
+ "provider": provider,
63
+ "region": region,
64
+ "timeout_minutes": timeout_minutes,
65
+ "metadata": metadata,
66
+ },
67
+ headers={
68
+ "content-type": "application/json",
69
+ },
70
+ request_options=request_options,
71
+ omit=OMIT,
72
+ )
73
+ try:
74
+ if 200 <= _response.status_code < 300:
75
+ _data = typing.cast(
76
+ SandboxResponse,
77
+ parse_obj_as(
78
+ type_=SandboxResponse, # type: ignore
79
+ object_=_response.json(),
80
+ ),
81
+ )
82
+ return HttpResponse(response=_response, data=_data)
83
+ if _response.status_code == 422:
84
+ raise UnprocessableEntityError(
85
+ headers=dict(_response.headers),
86
+ body=typing.cast(
87
+ HttpValidationError,
88
+ parse_obj_as(
89
+ type_=HttpValidationError, # type: ignore
90
+ object_=_response.json(),
91
+ ),
92
+ ),
93
+ )
94
+ _response_json = _response.json()
95
+ except JSONDecodeError:
96
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
97
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
98
+
99
+
100
+ class AsyncRawAioClient:
101
+ def __init__(self, *, client_wrapper: AsyncClientWrapper):
102
+ self._client_wrapper = client_wrapper
103
+
104
+ async def create(
105
+ self,
106
+ *,
107
+ provider: typing.Optional[SandboxProvider] = OMIT,
108
+ region: typing.Optional[str] = OMIT,
109
+ timeout_minutes: typing.Optional[int] = OMIT,
110
+ metadata: typing.Optional[typing.Dict[str, typing.Optional[typing.Any]]] = OMIT,
111
+ request_options: typing.Optional[RequestOptions] = None,
112
+ ) -> AsyncHttpResponse[SandboxResponse]:
113
+ """
114
+ Create a new all-in-one sandbox with shell, MCP, and VNC capabilities.
115
+
116
+ Parameters
117
+ ----------
118
+ provider : typing.Optional[SandboxProvider]
119
+ Provider to use (auto-detected if not specified)
120
+
121
+ region : typing.Optional[str]
122
+ Preferred region for the sandbox
123
+
124
+ timeout_minutes : typing.Optional[int]
125
+ Custom timeout in minutes
126
+
127
+ metadata : typing.Optional[typing.Dict[str, typing.Optional[typing.Any]]]
128
+ Additional metadata
129
+
130
+ request_options : typing.Optional[RequestOptions]
131
+ Request-specific configuration.
132
+
133
+ Returns
134
+ -------
135
+ AsyncHttpResponse[SandboxResponse]
136
+ Successful Response
137
+ """
138
+ _response = await self._client_wrapper.httpx_client.request(
139
+ "sandboxes/aio",
140
+ method="POST",
141
+ json={
142
+ "provider": provider,
143
+ "region": region,
144
+ "timeout_minutes": timeout_minutes,
145
+ "metadata": metadata,
146
+ },
147
+ headers={
148
+ "content-type": "application/json",
149
+ },
150
+ request_options=request_options,
151
+ omit=OMIT,
152
+ )
153
+ try:
154
+ if 200 <= _response.status_code < 300:
155
+ _data = typing.cast(
156
+ SandboxResponse,
157
+ parse_obj_as(
158
+ type_=SandboxResponse, # type: ignore
159
+ object_=_response.json(),
160
+ ),
161
+ )
162
+ return AsyncHttpResponse(response=_response, data=_data)
163
+ if _response.status_code == 422:
164
+ raise UnprocessableEntityError(
165
+ headers=dict(_response.headers),
166
+ body=typing.cast(
167
+ HttpValidationError,
168
+ parse_obj_as(
169
+ type_=HttpValidationError, # type: ignore
170
+ object_=_response.json(),
171
+ ),
172
+ ),
173
+ )
174
+ _response_json = _response.json()
175
+ except JSONDecodeError:
176
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
177
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
@@ -0,0 +1,4 @@
1
+ # This file was auto-generated by Fern from our API Definition.
2
+
3
+ # isort: skip_file
4
+