4040
4141@_attrs_define
4242class CreateSandboxRequest :
43- """Request to create a new sandbox from either a container image or a snapshot.
44- Exactly one of `image` or `snapshotId` must be provided.
43+ """Request to create a new sandbox from either a container image, a snapshot,
44+ or a pre-configured pool (via `extensions.poolRef`).
45+
46+ **Standard mode**: Exactly one of `image` or `snapshotId` must be provided,
47+ and `resourceLimits` is required.
4548
4649 When `image` is provided, `entrypoint` is required. When `snapshotId` is
4750 provided, `entrypoint` is optional. If omitted, the server defaults the
4851 sandbox entrypoint to `["tail", "-f", "/dev/null"]`.
4952
53+ **Pool mode**: When `extensions.poolRef` is set, the sandbox is created from
54+ a pre-configured pool. In this case `image`, `entrypoint`, and
55+ `resourceLimits` are all optional (defined by the Pool CRD template).
56+ `snapshotId` must not be provided together with `poolRef`.
57+
5058 **Note**: API Key authentication is required via the `OPEN-SANDBOX-API-KEY` header.
5159
5260 Attributes:
53- resource_limits (ResourceLimits): Runtime resource constraints as key-value pairs. Similar to Kubernetes
54- resource specifications,
55- allows flexible definition of resource limits. Common resource types include:
56- - `cpu`: CPU allocation in millicores (e.g., "250m" for 0.25 CPU cores)
57- - `memory`: Memory allocation in bytes or human-readable format (e.g., "512Mi", "1Gi")
58- - `gpu`: Number of GPU devices (e.g., "1")
59-
60- New resource types can be added without API changes.
61- Example: {'cpu': '500m', 'memory': '512Mi', 'gpu': '1'}.
6261 image (ImageSpec | Unset): Container image specification for sandbox provisioning.
6362
6463 Supports public registry images and private registry images with authentication.
@@ -82,6 +81,15 @@ class CreateSandboxRequest:
8281 Omit this field or set it to null to disable automatic expiration and require explicit cleanup.
8382 Note: manual cleanup support is runtime-dependent; Kubernetes providers may reject
8483 omitted or null timeout when the underlying workload provider does not support non-expiring sandboxes.
84+ resource_limits (ResourceLimits | Unset): Runtime resource constraints as key-value pairs. Similar to Kubernetes
85+ resource specifications,
86+ allows flexible definition of resource limits. Common resource types include:
87+ - `cpu`: CPU allocation in millicores (e.g., "250m" for 0.25 CPU cores)
88+ - `memory`: Memory allocation in bytes or human-readable format (e.g., "512Mi", "1Gi")
89+ - `gpu`: Number of GPU devices (e.g., "1")
90+
91+ New resource types can be added without API changes.
92+ Example: {'cpu': '500m', 'memory': '512Mi', 'gpu': '1'}.
8593 env (CreateSandboxRequestEnv | Unset): Environment variables to inject into the sandbox runtime. Example:
8694 {'API_KEY': 'secret-key', 'DEBUG': 'true', 'LOG_LEVEL': 'info'}.
8795 metadata (CreateSandboxRequestMetadata | Unset): Custom key-value metadata for management, filtering, and
@@ -140,11 +148,11 @@ class CreateSandboxRequest:
140148 via `validate_extensions` in server `src/extensions/validation.py`).
141149 """
142150
143- resource_limits : ResourceLimits
144151 image : ImageSpec | Unset = UNSET
145152 snapshot_id : str | Unset = UNSET
146153 platform : PlatformSpec | Unset = UNSET
147154 timeout : int | None | Unset = UNSET
155+ resource_limits : ResourceLimits | Unset = UNSET
148156 env : CreateSandboxRequestEnv | Unset = UNSET
149157 metadata : CreateSandboxRequestMetadata | Unset = UNSET
150158 entrypoint : list [str ] | Unset = UNSET
@@ -155,8 +163,6 @@ class CreateSandboxRequest:
155163 additional_properties : dict [str , Any ] = _attrs_field (init = False , factory = dict )
156164
157165 def to_dict (self ) -> dict [str , Any ]:
158- resource_limits = self .resource_limits .to_dict ()
159-
160166 image : dict [str , Any ] | Unset = UNSET
161167 if not isinstance (self .image , Unset ):
162168 image = self .image .to_dict ()
@@ -173,6 +179,10 @@ def to_dict(self) -> dict[str, Any]:
173179 else :
174180 timeout = self .timeout
175181
182+ resource_limits : dict [str , Any ] | Unset = UNSET
183+ if not isinstance (self .resource_limits , Unset ):
184+ resource_limits = self .resource_limits .to_dict ()
185+
176186 env : dict [str , Any ] | Unset = UNSET
177187 if not isinstance (self .env , Unset ):
178188 env = self .env .to_dict ()
@@ -204,11 +214,7 @@ def to_dict(self) -> dict[str, Any]:
204214
205215 field_dict : dict [str , Any ] = {}
206216 field_dict .update (self .additional_properties )
207- field_dict .update (
208- {
209- "resourceLimits" : resource_limits ,
210- }
211- )
217+ field_dict .update ({})
212218 if image is not UNSET :
213219 field_dict ["image" ] = image
214220 if snapshot_id is not UNSET :
@@ -217,6 +223,8 @@ def to_dict(self) -> dict[str, Any]:
217223 field_dict ["platform" ] = platform
218224 if timeout is not UNSET :
219225 field_dict ["timeout" ] = timeout
226+ if resource_limits is not UNSET :
227+ field_dict ["resourceLimits" ] = resource_limits
220228 if env is not UNSET :
221229 field_dict ["env" ] = env
222230 if metadata is not UNSET :
@@ -246,8 +254,6 @@ def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T:
246254 from ..models .volume import Volume
247255
248256 d = dict (src_dict )
249- resource_limits = ResourceLimits .from_dict (d .pop ("resourceLimits" ))
250-
251257 _image = d .pop ("image" , UNSET )
252258 image : ImageSpec | Unset
253259 if isinstance (_image , Unset ):
@@ -273,6 +279,13 @@ def _parse_timeout(data: object) -> int | None | Unset:
273279
274280 timeout = _parse_timeout (d .pop ("timeout" , UNSET ))
275281
282+ _resource_limits = d .pop ("resourceLimits" , UNSET )
283+ resource_limits : ResourceLimits | Unset
284+ if isinstance (_resource_limits , Unset ):
285+ resource_limits = UNSET
286+ else :
287+ resource_limits = ResourceLimits .from_dict (_resource_limits )
288+
276289 _env = d .pop ("env" , UNSET )
277290 env : CreateSandboxRequestEnv | Unset
278291 if isinstance (_env , Unset ):
@@ -315,11 +328,11 @@ def _parse_timeout(data: object) -> int | None | Unset:
315328 extensions = CreateSandboxRequestExtensions .from_dict (_extensions )
316329
317330 create_sandbox_request = cls (
318- resource_limits = resource_limits ,
319331 image = image ,
320332 snapshot_id = snapshot_id ,
321333 platform = platform ,
322334 timeout = timeout ,
335+ resource_limits = resource_limits ,
323336 env = env ,
324337 metadata = metadata ,
325338 entrypoint = entrypoint ,
0 commit comments