Skip to content

armgit / E2B

Public Imported from GitHub
0

Open-source, secure environment with real-world tools for enterprise-grade agents.

Support sandbox domain in sdk and cli (#821)

Jiri Sveceny10e9a28a821f
diff --git a/.changeset/purple-kangaroos-tease.md b/.changeset/purple-kangaroos-tease.md
new file mode 100644
index 000000000..18a9fe2d3
--- /dev/null
+++ b/.changeset/purple-kangaroos-tease.md
@@ -0,0 +1,7 @@
+---
+'@e2b/python-sdk': minor
+'e2b': minor
+'@e2b/cli': minor
+---
+
+Support for dynamic sandbox traffic domain
diff --git a/packages/js-sdk/src/api/schema.gen.ts b/packages/js-sdk/src/api/schema.gen.ts
index 82954ee37..25747aedb 100644
--- a/packages/js-sdk/src/api/schema.gen.ts
+++ b/packages/js-sdk/src/api/schema.gen.ts
@@ -193,7 +193,11 @@ export interface paths {
/** @description Get sandbox metrics */
get: {
parameters: {
- query?: never;
+ query?: {
+ end?: number;
+ /** @description Starting timestamp of the metrics that should be returned in milliseconds */
+ start?: number;
+ };
header?: never;
path: {
sandboxID: components["parameters"]["sandboxID"];
@@ -211,6 +215,7 @@ export interface paths {
"application/json": components["schemas"]["SandboxMetric"][];
};
};
+ 400: components["responses"]["400"];
401: components["responses"]["401"];
404: components["responses"]["404"];
500: components["responses"]["500"];
@@ -411,12 +416,12 @@ export interface paths {
path?: never;
cookie?: never;
};
- /** @description List all running sandboxes with metrics */
+ /** @description List metrics for given sandboxes */
get: {
parameters: {
- query?: {
- /** @description Metadata query used to filter the sandboxes (e.g. "user=abc&app=prod"). Each key and values must be URL encoded. */
- metadata?: string;
+ query: {
+ /** @description Comma-separated list of sandbox IDs to get metrics for */
+ sandbox_ids: string[];
};
header?: never;
path?: never;
@@ -430,7 +435,7 @@ export interface paths {
[name: string]: unknown;
};
content: {
- "application/json": components["schemas"]["RunningSandboxWithMetrics"][];
+ "application/json": components["schemas"]["SandboxesWithMetrics"];
};
};
400: components["responses"]["400"];
@@ -796,12 +801,11 @@ export interface components {
* @description Identifier of the access token
*/
id: string;
+ mask: components["schemas"]["IdentifierMaskingDetails"];
/** @description Name of the access token */
name: string;
- /** @description Raw value of the access token */
+ /** @description The fully created access token */
token: string;
- /** @description Mask of the access token */
- tokenMask: string;
};
CreatedTeamAPIKey: {
/**
@@ -809,7 +813,7 @@ export interface components {
* @description Timestamp of API key creation
*/
createdAt: string;
- createdBy: components["schemas"]["TeamUser"] | null;
+ createdBy?: components["schemas"]["TeamUser"] | null;
/**
* Format: uuid
* @description Identifier of the API key
@@ -817,13 +821,12 @@ export interface components {
id: string;
/** @description Raw value of the API key */
key: string;
- /** @description Mask of the API key */
- keyMask: string;
/**
* Format: date-time
* @description Last time this API key was used
*/
- lastUsed: string | null;
+ lastUsed?: string | null;
+ mask: components["schemas"]["IdentifierMaskingDetails"];
/** @description Name of the API key */
name: string;
};
@@ -839,10 +842,23 @@ export interface components {
/** @description Error */
message: string;
};
+ IdentifierMaskingDetails: {
+ /** @description Prefix used in masked version of the token or key */
+ maskedValuePrefix: string;
+ /** @description Suffix used in masked version of the token or key */
+ maskedValueSuffix: string;
+ /** @description Prefix that identifies the token or key type */
+ prefix: string;
+ /** @description Length of the token or key */
+ valueLength: number;
+ };
ListedSandbox: {
/** @description Alias of the template */
alias?: string;
- /** @description Identifier of the client */
+ /**
+ * @deprecated
+ * @description Identifier of the client
+ */
clientID: string;
cpuCount: components["schemas"]["CPUCount"];
/**
@@ -906,11 +922,20 @@ export interface components {
* @description Amount of allocated memory in MiB
*/
allocatedMemoryMiB: number;
+ /** @description Identifier of the cluster */
+ clusterID?: string | null;
+ /** @description Commit of the orchestrator */
+ commit: string;
/**
* Format: uint64
* @description Number of sandbox create fails
*/
createFails: number;
+ /**
+ * Format: uint64
+ * @description Number of sandbox create successes
+ */
+ createSuccesses: number;
/** @description Identifier of the node */
nodeID: string;
/**
@@ -930,11 +955,20 @@ export interface components {
NodeDetail: {
/** @description List of cached builds id on the node */
cachedBuilds: string[];
+ /** @description Identifier of the cluster */
+ clusterID?: string | null;
+ /** @description Commit of the orchestrator */
+ commit: string;
/**
* Format: uint64
* @description Number of sandbox create fails
*/
createFails: number;
+ /**
+ * Format: uint64
+ * @description Number of sandbox create successes
+ */
+ createSuccesses: number;
/** @description Identifier of the node */
nodeID: string;
/** @description List of sandboxes running on the node */
@@ -964,35 +998,16 @@ export interface components {
*/
timeout: number;
};
- RunningSandboxWithMetrics: {
+ Sandbox: {
/** @description Alias of the template */
alias?: string;
- /** @description Identifier of the client */
- clientID: string;
- cpuCount: components["schemas"]["CPUCount"];
- /**
- * Format: date-time
- * @description Time when the sandbox will expire
- */
- endAt: string;
- memoryMB: components["schemas"]["MemoryMB"];
- metadata?: components["schemas"]["SandboxMetadata"];
- metrics?: components["schemas"]["SandboxMetric"][];
- /** @description Identifier of the sandbox */
- sandboxID: string;
/**
- * Format: date-time
- * @description Time when the sandbox was started
+ * @deprecated
+ * @description Identifier of the client
*/
- startedAt: string;
- /** @description Identifier of the template from which is the sandbox created */
- templateID: string;
- };
- Sandbox: {
- /** @description Alias of the template */
- alias?: string;
- /** @description Identifier of the client */
clientID: string;
+ /** @description Base domain where the sandbox traffic is accessible */
+ domain?: string | null;
/** @description Access token used for envd communication */
envdAccessToken?: string;
/** @description Version of the envd running in the sandbox */
@@ -1005,9 +1020,14 @@ export interface components {
SandboxDetail: {
/** @description Alias of the template */
alias?: string;
- /** @description Identifier of the client */
+ /**
+ * @deprecated
+ * @description Identifier of the client
+ */
clientID: string;
cpuCount: components["schemas"]["CPUCount"];
+ /** @description Base domain where the sandbox traffic is accessible */
+ domain?: string | null;
/**
* Format: date-time
* @description Time when the sandbox will expire
@@ -1030,6 +1050,11 @@ export interface components {
/** @description Identifier of the template from which is the sandbox created */
templateID: string;
};
+ SandboxesWithMetrics: {
+ sandboxes: {
+ [key: string]: components["schemas"]["SandboxMetric"];
+ };
+ };
/** @description Log entry with timestamp and line */
SandboxLog: {
/** @description Log line content */
@@ -1061,14 +1086,14 @@ export interface components {
cpuUsedPct: number;
/**
* Format: int64
- * @description Total memory in MiB
+ * @description Total memory in bytes
*/
- memTotalMiB: number;
+ memTotal: number;
/**
* Format: int64
- * @description Memory used in MiB
+ * @description Memory used in bytes
*/
- memUsedMiB: number;
+ memUsed: number;
/**
* Format: date-time
* @description Timestamp of the metric entry
@@ -1096,19 +1121,18 @@ export interface components {
* @description Timestamp of API key creation
*/
createdAt: string;
- createdBy: components["schemas"]["TeamUser"] | null;
+ createdBy?: components["schemas"]["TeamUser"] | null;
/**
* Format: uuid
* @description Identifier of the API key
*/
id: string;
- /** @description Mask of the API key */
- keyMask: string;
/**
* Format: date-time
* @description Last time this API key was used
*/
- lastUsed: string | null;
+ lastUsed?: string | null;
+ mask: components["schemas"]["IdentifierMaskingDetails"];
/** @description Name of the API key */
name: string;
};
@@ -1167,6 +1191,8 @@ export interface components {
* @default []
*/
logs: string[];
+ /** @description Message with the status reason, currently reporting only for error status */
+ reason?: string;
/**
* @description Status of the template
* @enum {string}
@@ -1182,6 +1208,8 @@ export interface components {
/** @description Dockerfile for the template */
dockerfile: string;
memoryMB?: components["schemas"]["MemoryMB"];
+ /** @description Ready check command to execute in the template after the build */
+ readyCmd?: string;
/** @description Start command to execute in the template after the build */
startCmd?: string;
/** @description Identifier of the team */
diff --git a/packages/js-sdk/src/sandbox/index.ts b/packages/js-sdk/src/sandbox/index.ts
index 3bad2634d..8dca72484 100644
--- a/packages/js-sdk/src/sandbox/index.ts
+++ b/packages/js-sdk/src/sandbox/index.ts
@@ -117,6 +117,11 @@ export class Sandbox extends SandboxApi {
*/
readonly sandboxId: string
+ /**
+ * Domain where the sandbox is hosted.
+ */
+ readonly sandboxDomain: string
+
protected readonly envdPort = 49983
protected readonly connectionConfig: ConnectionConfig
@@ -135,15 +140,18 @@ export class Sandbox extends SandboxApi {
constructor(
opts: Omit<SandboxOpts, 'timeoutMs' | 'envs' | 'metadata'> & {
sandboxId: string
+ sandboxDomain?: string
envdVersion?: string
envdAccessToken?: string
}
) {
super()
- this.sandboxId = opts.sandboxId
this.connectionConfig = new ConnectionConfig(opts)
+ this.sandboxId = opts.sandboxId
+ this.sandboxDomain = opts.sandboxDomain ?? this.connectionConfig.domain
+
this.envdAccessToken = opts.envdAccessToken
this.envdApiUrl = `${
this.connectionConfig.debug ? 'http' : 'https'
@@ -287,6 +295,7 @@ export class Sandbox extends SandboxApi {
return new this({
sandboxId,
+ sandboxDomain: info.sandboxDomain,
envdAccessToken: info.envdAccessToken,
envdVersion: info.envdVersion,
...config,
@@ -315,7 +324,7 @@ export class Sandbox extends SandboxApi {
return `localhost:${port}`
}
- return `${port}-${this.sandboxId}.${this.connectionConfig.domain}`
+ return `${port}-${this.sandboxId}.${this.sandboxDomain}`
}
/**
diff --git a/packages/js-sdk/src/sandbox/sandboxApi.ts b/packages/js-sdk/src/sandbox/sandboxApi.ts
index 0194167e1..2e75cdbec 100644
--- a/packages/js-sdk/src/sandbox/sandboxApi.ts
+++ b/packages/js-sdk/src/sandbox/sandboxApi.ts
@@ -30,6 +30,11 @@ export interface SandboxInfo {
*/
sandboxId: string
+ /**
+ * Domain where the sandbox is hosted.
+ */
+ sandboxDomain?: string
+
/**
* Template ID.
*/
@@ -246,6 +251,7 @@ export class SandboxApi {
return {
sandboxId: res.data.sandboxID,
+ sandboxDomain: res.data!.domain || undefined,
templateId: res.data.templateID,
...(res.data.alias && { name: res.data.alias }),
metadata: res.data.metadata ?? {},
@@ -304,6 +310,7 @@ export class SandboxApi {
}
): Promise<{
sandboxId: string
+ sandboxDomain?: string
envdVersion: string
envdAccessToken?: string
}> {
@@ -337,6 +344,7 @@ export class SandboxApi {
return {
sandboxId: res.data!.sandboxID,
+ sandboxDomain: res.data!.domain || undefined,
envdVersion: res.data!.envdVersion,
envdAccessToken: res.data!.envdAccessToken
}
diff --git a/packages/python-sdk/e2b/api/__init__.py b/packages/python-sdk/e2b/api/__init__.py
index 614ff25e1..93953fa6a 100644
--- a/packages/python-sdk/e2b/api/__init__.py
+++ b/packages/python-sdk/e2b/api/__init__.py
@@ -21,6 +21,7 @@ logger = logging.getLogger(__name__)
@dataclass
class SandboxCreateResponse:
sandbox_id: str
+ sandbox_domain: Optional[str]
envd_version: str
envd_access_token: str
diff --git a/packages/python-sdk/e2b/api/client/api/sandboxes/get_sandboxes_metrics.py b/packages/python-sdk/e2b/api/client/api/sandboxes/get_sandboxes_metrics.py
index b26bbcfb3..e7a2d4145 100644
--- a/packages/python-sdk/e2b/api/client/api/sandboxes/get_sandboxes_metrics.py
+++ b/packages/python-sdk/e2b/api/client/api/sandboxes/get_sandboxes_metrics.py
@@ -6,17 +6,19 @@ import httpx
from ... import errors
from ...client import AuthenticatedClient, Client
from ...models.error import Error
-from ...models.running_sandbox_with_metrics import RunningSandboxWithMetrics
-from ...types import UNSET, Response, Unset
+from ...models.sandboxes_with_metrics import SandboxesWithMetrics
+from ...types import UNSET, Response
def _get_kwargs(
*,
- metadata: Union[Unset, str] = UNSET,
+ sandbox_ids: list[str],
) -> dict[str, Any]:
params: dict[str, Any] = {}
- params["metadata"] = metadata
+ json_sandbox_ids = sandbox_ids
+
+ params["sandbox_ids"] = json_sandbox_ids
params = {k: v for k, v in params.items() if v is not UNSET and v is not None}
@@ -31,16 +33,9 @@ def _get_kwargs(
def _parse_response(
*, client: Union[AuthenticatedClient, Client], response: httpx.Response
-) -> Optional[Union[Error, list["RunningSandboxWithMetrics"]]]:
+) -> Optional[Union[Error, SandboxesWithMetrics]]:
if response.status_code == 200:
- response_200 = []
- _response_200 = response.json()
- for response_200_item_data in _response_200:
- response_200_item = RunningSandboxWithMetrics.from_dict(
- response_200_item_data
- )
-
- response_200.append(response_200_item)
+ response_200 = SandboxesWithMetrics.from_dict(response.json())
return response_200
if response.status_code == 400:
@@ -63,7 +58,7 @@ def _parse_response(
def _build_response(
*, client: Union[AuthenticatedClient, Client], response: httpx.Response
-) -> Response[Union[Error, list["RunningSandboxWithMetrics"]]]:
+) -> Response[Union[Error, SandboxesWithMetrics]]:
return Response(
status_code=HTTPStatus(response.status_code),
content=response.content,
@@ -75,23 +70,23 @@ def _build_response(
def sync_detailed(
*,
client: AuthenticatedClient,
- metadata: Union[Unset, str] = UNSET,
-) -> Response[Union[Error, list["RunningSandboxWithMetrics"]]]:
- """List all running sandboxes with metrics
+ sandbox_ids: list[str],
+) -> Response[Union[Error, SandboxesWithMetrics]]:
+ """List metrics for given sandboxes
Args:
- metadata (Union[Unset, str]):
+ sandbox_ids (list[str]):
Raises:
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
httpx.TimeoutException: If the request takes longer than Client.timeout.
Returns:
- Response[Union[Error, list['RunningSandboxWithMetrics']]]
+ Response[Union[Error, SandboxesWithMetrics]]
"""
kwargs = _get_kwargs(
- metadata=metadata,
+ sandbox_ids=sandbox_ids,
)
response = client.get_httpx_client().request(
@@ -104,47 +99,47 @@ def sync_detailed(
def sync(
*,
client: AuthenticatedClient,
- metadata: Union[Unset, str] = UNSET,
-) -> Optional[Union[Error, list["RunningSandboxWithMetrics"]]]:
- """List all running sandboxes with metrics
+ sandbox_ids: list[str],
+) -> Optional[Union[Error, SandboxesWithMetrics]]:
+ """List metrics for given sandboxes
Args:
- metadata (Union[Unset, str]):
+ sandbox_ids (list[str]):
Raises:
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
httpx.TimeoutException: If the request takes longer than Client.timeout.
Returns:
- Union[Error, list['RunningSandboxWithMetrics']]
+ Union[Error, SandboxesWithMetrics]
"""
return sync_detailed(
client=client,
- metadata=metadata,
+ sandbox_ids=sandbox_ids,
).parsed
async def asyncio_detailed(
*,
client: AuthenticatedClient,
- metadata: Union[Unset, str] = UNSET,
-) -> Response[Union[Error, list["RunningSandboxWithMetrics"]]]:
- """List all running sandboxes with metrics
+ sandbox_ids: list[str],
+) -> Response[Union[Error, SandboxesWithMetrics]]:
+ """List metrics for given sandboxes
Args:
- metadata (Union[Unset, str]):
+ sandbox_ids (list[str]):
Raises:
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
httpx.TimeoutException: If the request takes longer than Client.timeout.
Returns:
- Response[Union[Error, list['RunningSandboxWithMetrics']]]
+ Response[Union[Error, SandboxesWithMetrics]]
"""
kwargs = _get_kwargs(
- metadata=metadata,
+ sandbox_ids=sandbox_ids,
)
response = await client.get_async_httpx_client().request(**kwargs)
@@ -155,24 +150,24 @@ async def asyncio_detailed(
async def asyncio(
*,
client: AuthenticatedClient,
- metadata: Union[Unset, str] = UNSET,
-) -> Optional[Union[Error, list["RunningSandboxWithMetrics"]]]:
- """List all running sandboxes with metrics
+ sandbox_ids: list[str],
+) -> Optional[Union[Error, SandboxesWithMetrics]]:
+ """List metrics for given sandboxes
Args:
- metadata (Union[Unset, str]):
+ sandbox_ids (list[str]):
Raises:
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
httpx.TimeoutException: If the request takes longer than Client.timeout.
Returns:
- Union[Error, list['RunningSandboxWithMetrics']]
+ Union[Error, SandboxesWithMetrics]
"""
return (
await asyncio_detailed(
client=client,
- metadata=metadata,
+ sandbox_ids=sandbox_ids,
)
).parsed
diff --git a/packages/python-sdk/e2b/api/client/api/sandboxes/get_sandboxes_sandbox_id_metrics.py b/packages/python-sdk/e2b/api/client/api/sandboxes/get_sandboxes_sandbox_id_metrics.py
index 0ce53aa30..c3f4c0037 100644
--- a/packages/python-sdk/e2b/api/client/api/sandboxes/get_sandboxes_sandbox_id_metrics.py
+++ b/packages/python-sdk/e2b/api/client/api/sandboxes/get_sandboxes_sandbox_id_metrics.py
@@ -7,15 +7,27 @@ from ... import errors
from ...client import AuthenticatedClient, Client
from ...models.error import Error
from ...models.sandbox_metric import SandboxMetric
-from ...types import Response
+from ...types import UNSET, Response, Unset
def _get_kwargs(
sandbox_id: str,
+ *,
+ start: Union[Unset, int] = UNSET,
+ end: Union[Unset, int] = UNSET,
) -> dict[str, Any]:
+ params: dict[str, Any] = {}
+
+ params["start"] = start
+
+ params["end"] = end
+
+ params = {k: v for k, v in params.items() if v is not UNSET and v is not None}
+
_kwargs: dict[str, Any] = {
"method": "get",
"url": f"/sandboxes/{sandbox_id}/metrics",
+ "params": params,
}
return _kwargs
@@ -33,6 +45,10 @@ def _parse_response(
response_200.append(response_200_item)
return response_200
+ if response.status_code == 400:
+ response_400 = Error.from_dict(response.json())
+
+ return response_400
if response.status_code == 401:
response_401 = Error.from_dict(response.json())
@@ -66,11 +82,16 @@ def sync_detailed(
sandbox_id: str,
*,
client: AuthenticatedClient,
+ start: Union[Unset, int] = UNSET,
+ end: Union[Unset, int] = UNSET,
) -> Response[Union[Error, list["SandboxMetric"]]]:
"""Get sandbox metrics
Args:
sandbox_id (str):
+ start (Union[Unset, int]):
+ end (Union[Unset, int]): Ending timestamp of the metrics that should be returned in
+ milliseconds
Raises:
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
@@ -82,6 +103,8 @@ def sync_detailed(
kwargs = _get_kwargs(
sandbox_id=sandbox_id,
+ start=start,
+ end=end,
)
response = client.get_httpx_client().request(
@@ -95,11 +118,16 @@ def sync(
sandbox_id: str,
*,
client: AuthenticatedClient,
+ start: Union[Unset, int] = UNSET,
+ end: Union[Unset, int] = UNSET,
) -> Optional[Union[Error, list["SandboxMetric"]]]:
"""Get sandbox metrics
Args:
sandbox_id (str):
+ start (Union[Unset, int]):
+ end (Union[Unset, int]): Ending timestamp of the metrics that should be returned in
+ milliseconds
Raises:
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
@@ -112,6 +140,8 @@ def sync(
return sync_detailed(
sandbox_id=sandbox_id,
client=client,
+ start=start,
+ end=end,
).parsed
@@ -119,11 +149,16 @@ async def asyncio_detailed(
sandbox_id: str,
*,
client: AuthenticatedClient,
+ start: Union[Unset, int] = UNSET,
+ end: Union[Unset, int] = UNSET,
) -> Response[Union[Error, list["SandboxMetric"]]]:
"""Get sandbox metrics
Args:
sandbox_id (str):
+ start (Union[Unset, int]):
+ end (Union[Unset, int]): Ending timestamp of the metrics that should be returned in
+ milliseconds
Raises:
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
@@ -135,6 +170,8 @@ async def asyncio_detailed(
kwargs = _get_kwargs(
sandbox_id=sandbox_id,
+ start=start,
+ end=end,
)
response = await client.get_async_httpx_client().request(**kwargs)
@@ -146,11 +183,16 @@ async def asyncio(
sandbox_id: str,
*,
client: AuthenticatedClient,
+ start: Union[Unset, int] = UNSET,
+ end: Union[Unset, int] = UNSET,
) -> Optional[Union[Error, list["SandboxMetric"]]]:
"""Get sandbox metrics
Args:
sandbox_id (str):
+ start (Union[Unset, int]):
+ end (Union[Unset, int]): Ending timestamp of the metrics that should be returned in
+ milliseconds
Raises:
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
@@ -164,5 +206,7 @@ async def asyncio(
await asyncio_detailed(
sandbox_id=sandbox_id,
client=client,
+ start=start,
+ end=end,
)
).parsed
diff --git a/packages/python-sdk/e2b/api/client/models/__init__.py b/packages/python-sdk/e2b/api/client/models/__init__.py
index 1cec9c41a..5dc96d9c3 100644
--- a/packages/python-sdk/e2b/api/client/models/__init__.py
+++ b/packages/python-sdk/e2b/api/client/models/__init__.py
@@ -3,6 +3,7 @@
from .created_access_token import CreatedAccessToken
from .created_team_api_key import CreatedTeamAPIKey
from .error import Error
+from .identifier_masking_details import IdentifierMaskingDetails
from .listed_sandbox import ListedSandbox
from .new_access_token import NewAccessToken
from .new_sandbox import NewSandbox
@@ -16,13 +17,13 @@ from .post_sandboxes_sandbox_id_refreshes_body import (
)
from .post_sandboxes_sandbox_id_timeout_body import PostSandboxesSandboxIDTimeoutBody
from .resumed_sandbox import ResumedSandbox
-from .running_sandbox_with_metrics import RunningSandboxWithMetrics
from .sandbox import Sandbox
from .sandbox_detail import SandboxDetail
from .sandbox_log import SandboxLog
from .sandbox_logs import SandboxLogs
from .sandbox_metric import SandboxMetric
from .sandbox_state import SandboxState
+from .sandboxes_with_metrics import SandboxesWithMetrics
from .team import Team
from .team_api_key import TeamAPIKey
from .team_user import TeamUser
@@ -37,6 +38,7 @@ __all__ = (
"CreatedAccessToken",
"CreatedTeamAPIKey",
"Error",
+ "IdentifierMaskingDetails",
"ListedSandbox",
"NewAccessToken",
"NewSandbox",
@@ -48,9 +50,9 @@ __all__ = (
"PostSandboxesSandboxIDRefreshesBody",
"PostSandboxesSandboxIDTimeoutBody",
"ResumedSandbox",
- "RunningSandboxWithMetrics",
"Sandbox",
"SandboxDetail",
+ "SandboxesWithMetrics",
"SandboxLog",
"SandboxLogs",
"SandboxMetric",
diff --git a/packages/python-sdk/e2b/api/client/models/created_access_token.py b/packages/python-sdk/e2b/api/client/models/created_access_token.py
index beb225edb..04224adbc 100644
--- a/packages/python-sdk/e2b/api/client/models/created_access_token.py
+++ b/packages/python-sdk/e2b/api/client/models/created_access_token.py
@@ -1,12 +1,16 @@
import datetime
from collections.abc import Mapping
-from typing import Any, TypeVar
+from typing import TYPE_CHECKING, Any, TypeVar
from uuid import UUID
from attrs import define as _attrs_define
from attrs import field as _attrs_field
from dateutil.parser import isoparse
+if TYPE_CHECKING:
+ from ..models.identifier_masking_details import IdentifierMaskingDetails
+
+
T = TypeVar("T", bound="CreatedAccessToken")
@@ -16,16 +20,16 @@ class CreatedAccessToken:
Attributes:
created_at (datetime.datetime): Timestamp of access token creation
id (UUID): Identifier of the access token
+ mask (IdentifierMaskingDetails):
name (str): Name of the access token
- token (str): Raw value of the access token
- token_mask (str): Mask of the access token
+ token (str): The fully created access token
"""
created_at: datetime.datetime
id: UUID
+ mask: "IdentifierMaskingDetails"
name: str
token: str
- token_mask: str
additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict)
def to_dict(self) -> dict[str, Any]:
@@ -33,21 +37,21 @@ class CreatedAccessToken:
id = str(self.id)
+ mask = self.mask.to_dict()
+
name = self.name
token = self.token
- token_mask = self.token_mask
-
field_dict: dict[str, Any] = {}
field_dict.update(self.additional_properties)
field_dict.update(
{
"createdAt": created_at,
"id": id,
+ "mask": mask,
"name": name,
"token": token,
- "tokenMask": token_mask,
}
)
@@ -55,23 +59,25 @@ class CreatedAccessToken:
@classmethod
def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T:
+ from ..models.identifier_masking_details import IdentifierMaskingDetails
+
d = dict(src_dict)
created_at = isoparse(d.pop("createdAt"))
id = UUID(d.pop("id"))
+ mask = IdentifierMaskingDetails.from_dict(d.pop("mask"))
+
name = d.pop("name")
token = d.pop("token")
- token_mask = d.pop("tokenMask")
-
created_access_token = cls(
created_at=created_at,
id=id,
+ mask=mask,
name=name,
token=token,
- token_mask=token_mask,
)
created_access_token.additional_properties = d
diff --git a/packages/python-sdk/e2b/api/client/models/created_team_api_key.py b/packages/python-sdk/e2b/api/client/models/created_team_api_key.py
index 55a2a88cc..f1d4150b7 100644
--- a/packages/python-sdk/e2b/api/client/models/created_team_api_key.py
+++ b/packages/python-sdk/e2b/api/client/models/created_team_api_key.py
@@ -7,7 +7,10 @@ from attrs import define as _attrs_define
from attrs import field as _attrs_field
from dateutil.parser import isoparse
+from ..types import UNSET, Unset
+
if TYPE_CHECKING:
+ from ..models.identifier_masking_details import IdentifierMaskingDetails
from ..models.team_user import TeamUser
@@ -19,21 +22,21 @@ class CreatedTeamAPIKey:
"""
Attributes:
created_at (datetime.datetime): Timestamp of API key creation
- created_by (Union['TeamUser', None]):
id (UUID): Identifier of the API key
key (str): Raw value of the API key
- key_mask (str): Mask of the API key
- last_used (Union[None, datetime.datetime]): Last time this API key was used
+ mask (IdentifierMaskingDetails):
name (str): Name of the API key
+ created_by (Union['TeamUser', None, Unset]):
+ last_used (Union[None, Unset, datetime.datetime]): Last time this API key was used
"""
created_at: datetime.datetime
- created_by: Union["TeamUser", None]
id: UUID
key: str
- key_mask: str
- last_used: Union[None, datetime.datetime]
+ mask: "IdentifierMaskingDetails"
name: str
+ created_by: Union["TeamUser", None, Unset] = UNSET
+ last_used: Union[None, Unset, datetime.datetime] = UNSET
additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict)
def to_dict(self) -> dict[str, Any]:
@@ -41,52 +44,69 @@ class CreatedTeamAPIKey:
created_at = self.created_at.isoformat()
- created_by: Union[None, dict[str, Any]]
- if isinstance(self.created_by, TeamUser):
- created_by = self.created_by.to_dict()
- else:
- created_by = self.created_by
-
id = str(self.id)
key = self.key
- key_mask = self.key_mask
+ mask = self.mask.to_dict()
- last_used: Union[None, str]
- if isinstance(self.last_used, datetime.datetime):
+ name = self.name
+
+ created_by: Union[None, Unset, dict[str, Any]]
+ if isinstance(self.created_by, Unset):
+ created_by = UNSET
+ elif isinstance(self.created_by, TeamUser):
+ created_by = self.created_by.to_dict()
+ else:
+ created_by = self.created_by
+
+ last_used: Union[None, Unset, str]
+ if isinstance(self.last_used, Unset):
+ last_used = UNSET
+ elif isinstance(self.last_used, datetime.datetime):
last_used = self.last_used.isoformat()
else:
last_used = self.last_used
- name = self.name
-
field_dict: dict[str, Any] = {}
field_dict.update(self.additional_properties)
field_dict.update(
{
"createdAt": created_at,
- "createdBy": created_by,
"id": id,
"key": key,
- "keyMask": key_mask,
- "lastUsed": last_used,
+ "mask": mask,
"name": name,
}
)
+ if created_by is not UNSET:
+ field_dict["createdBy"] = created_by
+ if last_used is not UNSET:
+ field_dict["lastUsed"] = last_used
return field_dict
@classmethod
def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T:
+ from ..models.identifier_masking_details import IdentifierMaskingDetails
from ..models.team_user import TeamUser
d = dict(src_dict)
created_at = isoparse(d.pop("createdAt"))
- def _parse_created_by(data: object) -> Union["TeamUser", None]:
+ id = UUID(d.pop("id"))
+
+ key = d.pop("key")
+
+ mask = IdentifierMaskingDetails.from_dict(d.pop("mask"))
+
+ name = d.pop("name")
+
+ def _parse_created_by(data: object) -> Union["TeamUser", None, Unset]:
if data is None:
return data
+ if isinstance(data, Unset):
+ return data
try:
if not isinstance(data, dict):
raise TypeError()
@@ -95,19 +115,15 @@ class CreatedTeamAPIKey:
return created_by_type_1
except: # noqa: E722
pass
- return cast(Union["TeamUser", None], data)
-
- created_by = _parse_created_by(d.pop("createdBy"))
-
- id = UUID(d.pop("id"))
-
- key = d.pop("key")
+ return cast(Union["TeamUser", None, Unset], data)
- key_mask = d.pop("keyMask")
+ created_by = _parse_created_by(d.pop("createdBy", UNSET))
- def _parse_last_used(data: object) -> Union[None, datetime.datetime]:
+ def _parse_last_used(data: object) -> Union[None, Unset, datetime.datetime]:
if data is None:
return data
+ if isinstance(data, Unset):
+ return data
try:
if not isinstance(data, str):
raise TypeError()
@@ -116,20 +132,18 @@ class CreatedTeamAPIKey:
return last_used_type_0
except: # noqa: E722
pass
- return cast(Union[None, datetime.datetime], data)
+ return cast(Union[None, Unset, datetime.datetime], data)
- last_used = _parse_last_used(d.pop("lastUsed"))
-
- name = d.pop("name")
+ last_used = _parse_last_used(d.pop("lastUsed", UNSET))
created_team_api_key = cls(
created_at=created_at,
- created_by=created_by,
id=id,
key=key,
- key_mask=key_mask,
- last_used=last_used,
+ mask=mask,
name=name,
+ created_by=created_by,
+ last_used=last_used,
)
created_team_api_key.additional_properties = d
diff --git a/packages/python-sdk/e2b/api/client/models/identifier_masking_details.py b/packages/python-sdk/e2b/api/client/models/identifier_masking_details.py
new file mode 100644
index 000000000..60c0bdedb
--- /dev/null
+++ b/packages/python-sdk/e2b/api/client/models/identifier_masking_details.py
@@ -0,0 +1,83 @@
+from collections.abc import Mapping
+from typing import Any, TypeVar
+
+from attrs import define as _attrs_define
+from attrs import field as _attrs_field
+
+T = TypeVar("T", bound="IdentifierMaskingDetails")
+
+
+@_attrs_define
+class IdentifierMaskingDetails:
+ """
+ Attributes:
+ masked_value_prefix (str): Prefix used in masked version of the token or key
+ masked_value_suffix (str): Suffix used in masked version of the token or key
+ prefix (str): Prefix that identifies the token or key type
+ value_length (int): Length of the token or key
+ """
+
+ masked_value_prefix: str
+ masked_value_suffix: str
+ prefix: str
+ value_length: int
+ additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict)
+
+ def to_dict(self) -> dict[str, Any]:
+ masked_value_prefix = self.masked_value_prefix
+
+ masked_value_suffix = self.masked_value_suffix
+
+ prefix = self.prefix
+
+ value_length = self.value_length
+
+ field_dict: dict[str, Any] = {}
+ field_dict.update(self.additional_properties)
+ field_dict.update(
+ {
+ "maskedValuePrefix": masked_value_prefix,
+ "maskedValueSuffix": masked_value_suffix,
+ "prefix": prefix,
+ "valueLength": value_length,
+ }
+ )
+
+ return field_dict
+
+ @classmethod
+ def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T:
+ d = dict(src_dict)
+ masked_value_prefix = d.pop("maskedValuePrefix")
+
+ masked_value_suffix = d.pop("maskedValueSuffix")
+
+ prefix = d.pop("prefix")
+
+ value_length = d.pop("valueLength")
+
+ identifier_masking_details = cls(
+ masked_value_prefix=masked_value_prefix,
+ masked_value_suffix=masked_value_suffix,
+ prefix=prefix,
+ value_length=value_length,
+ )
+
+ identifier_masking_details.additional_properties = d
+ return identifier_masking_details
+
+ @property
+ def additional_keys(self) -> list[str]:
+ return list(self.additional_properties.keys())
+
+ def __getitem__(self, key: str) -> Any:
+ return self.additional_properties[key]
+
+ def __setitem__(self, key: str, value: Any) -> None:
+ self.additional_properties[key] = value
+
+ def __delitem__(self, key: str) -> None:
+ del self.additional_properties[key]
+
+ def __contains__(self, key: str) -> bool:
+ return key in self.additional_properties
diff --git a/packages/python-sdk/e2b/api/client/models/node.py b/packages/python-sdk/e2b/api/client/models/node.py
index 3e18f67d3..592348ec4 100644
--- a/packages/python-sdk/e2b/api/client/models/node.py
+++ b/packages/python-sdk/e2b/api/client/models/node.py
@@ -1,10 +1,11 @@
from collections.abc import Mapping
-from typing import Any, TypeVar
+from typing import Any, TypeVar, Union, cast
from attrs import define as _attrs_define
from attrs import field as _attrs_field
from ..models.node_status import NodeStatus
+from ..types import UNSET, Unset
T = TypeVar("T", bound="Node")
@@ -15,22 +16,28 @@ class Node:
Attributes:
allocated_cpu (int): Number of allocated CPU cores
allocated_memory_mi_b (int): Amount of allocated memory in MiB
+ commit (str): Commit of the orchestrator
create_fails (int): Number of sandbox create fails
+ create_successes (int): Number of sandbox create successes
node_id (str): Identifier of the node
sandbox_count (int): Number of sandboxes running on the node
sandbox_starting_count (int): Number of starting Sandboxes
status (NodeStatus): Status of the node
version (str): Version of the orchestrator
+ cluster_id (Union[None, Unset, str]): Identifier of the cluster
"""
allocated_cpu: int
allocated_memory_mi_b: int
+ commit: str
create_fails: int
+ create_successes: int
node_id: str
sandbox_count: int
sandbox_starting_count: int
status: NodeStatus
version: str
+ cluster_id: Union[None, Unset, str] = UNSET
additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict)
def to_dict(self) -> dict[str, Any]:
@@ -38,8 +45,12 @@ class Node:
allocated_memory_mi_b = self.allocated_memory_mi_b
+ commit = self.commit
+
create_fails = self.create_fails
+ create_successes = self.create_successes
+
node_id = self.node_id
sandbox_count = self.sandbox_count
@@ -50,13 +61,21 @@ class Node:
version = self.version
+ cluster_id: Union[None, Unset, str]
+ if isinstance(self.cluster_id, Unset):
+ cluster_id = UNSET
+ else:
+ cluster_id = self.cluster_id
+
field_dict: dict[str, Any] = {}
field_dict.update(self.additional_properties)
field_dict.update(
{
"allocatedCPU": allocated_cpu,
"allocatedMemoryMiB": allocated_memory_mi_b,
+ "commit": commit,
"createFails": create_fails,
+ "createSuccesses": create_successes,
"nodeID": node_id,
"sandboxCount": sandbox_count,
"sandboxStartingCount": sandbox_starting_count,
@@ -64,6 +83,8 @@ class Node:
"version": version,
}
)
+ if cluster_id is not UNSET:
+ field_dict["clusterID"] = cluster_id
return field_dict
@@ -74,8 +95,12 @@ class Node:
allocated_memory_mi_b = d.pop("allocatedMemoryMiB")
+ commit = d.pop("commit")
+
create_fails = d.pop("createFails")
+ create_successes = d.pop("createSuccesses")
+
node_id = d.pop("nodeID")
sandbox_count = d.pop("sandboxCount")
@@ -86,15 +111,27 @@ class Node:
version = d.pop("version")
+ def _parse_cluster_id(data: object) -> Union[None, Unset, str]:
+ if data is None:
+ return data
+ if isinstance(data, Unset):
+ return data
+ return cast(Union[None, Unset, str], data)
+
+ cluster_id = _parse_cluster_id(d.pop("clusterID", UNSET))
+
node = cls(
allocated_cpu=allocated_cpu,
allocated_memory_mi_b=allocated_memory_mi_b,
+ commit=commit,
create_fails=create_fails,
+ create_successes=create_successes,
node_id=node_id,
sandbox_count=sandbox_count,
sandbox_starting_count=sandbox_starting_count,
status=status,
version=version,
+ cluster_id=cluster_id,
)
node.additional_properties = d
diff --git a/packages/python-sdk/e2b/api/client/models/node_detail.py b/packages/python-sdk/e2b/api/client/models/node_detail.py
index 6f523d37f..ea60fd31b 100644
--- a/packages/python-sdk/e2b/api/client/models/node_detail.py
+++ b/packages/python-sdk/e2b/api/client/models/node_detail.py
@@ -1,10 +1,11 @@
from collections.abc import Mapping
-from typing import TYPE_CHECKING, Any, TypeVar, cast
+from typing import TYPE_CHECKING, Any, TypeVar, Union, cast
from attrs import define as _attrs_define
from attrs import field as _attrs_field
from ..models.node_status import NodeStatus
+from ..types import UNSET, Unset
if TYPE_CHECKING:
from ..models.listed_sandbox import ListedSandbox
@@ -18,26 +19,36 @@ class NodeDetail:
"""
Attributes:
cached_builds (list[str]): List of cached builds id on the node
+ commit (str): Commit of the orchestrator
create_fails (int): Number of sandbox create fails
+ create_successes (int): Number of sandbox create successes
node_id (str): Identifier of the node
sandboxes (list['ListedSandbox']): List of sandboxes running on the node
status (NodeStatus): Status of the node
version (str): Version of the orchestrator
+ cluster_id (Union[None, Unset, str]): Identifier of the cluster
"""
cached_builds: list[str]
+ commit: str
create_fails: int
+ create_successes: int
node_id: str
sandboxes: list["ListedSandbox"]
status: NodeStatus
version: str
+ cluster_id: Union[None, Unset, str] = UNSET
additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict)
def to_dict(self) -> dict[str, Any]:
cached_builds = self.cached_builds
+ commit = self.commit
+
create_fails = self.create_fails
+ create_successes = self.create_successes
+
node_id = self.node_id
sandboxes = []
@@ -49,18 +60,28 @@ class NodeDetail:
version = self.version
+ cluster_id: Union[None, Unset, str]
+ if isinstance(self.cluster_id, Unset):
+ cluster_id = UNSET
+ else:
+ cluster_id = self.cluster_id
+
field_dict: dict[str, Any] = {}
field_dict.update(self.additional_properties)
field_dict.update(
{
"cachedBuilds": cached_builds,
+ "commit": commit,
"createFails": create_fails,
+ "createSuccesses": create_successes,
"nodeID": node_id,
"sandboxes": sandboxes,
"status": status,
"version": version,
}
)
+ if cluster_id is not UNSET:
+ field_dict["clusterID"] = cluster_id
return field_dict
@@ -71,8 +92,12 @@ class NodeDetail:
d = dict(src_dict)
cached_builds = cast(list[str], d.pop("cachedBuilds"))
+ commit = d.pop("commit")
+
create_fails = d.pop("createFails")
+ create_successes = d.pop("createSuccesses")
+
node_id = d.pop("nodeID")
sandboxes = []
@@ -86,13 +111,25 @@ class NodeDetail:
version = d.pop("version")
+ def _parse_cluster_id(data: object) -> Union[None, Unset, str]:
+ if data is None:
+ return data
+ if isinstance(data, Unset):
+ return data
+ return cast(Union[None, Unset, str], data)
+
+ cluster_id = _parse_cluster_id(d.pop("clusterID", UNSET))
+
node_detail = cls(
cached_builds=cached_builds,
+ commit=commit,
create_fails=create_fails,
+ create_successes=create_successes,
node_id=node_id,
sandboxes=sandboxes,
status=status,
version=version,
+ cluster_id=cluster_id,
)
node_detail.additional_properties = d
diff --git a/packages/python-sdk/e2b/api/client/models/running_sandbox_with_metrics.py b/packages/python-sdk/e2b/api/client/models/running_sandbox_with_metrics.py
deleted file mode 100644
index e4b360f90..000000000
--- a/packages/python-sdk/e2b/api/client/models/running_sandbox_with_metrics.py
+++ /dev/null
@@ -1,154 +0,0 @@
-import datetime
-from collections.abc import Mapping
-from typing import TYPE_CHECKING, Any, TypeVar, Union
-
-from attrs import define as _attrs_define
-from attrs import field as _attrs_field
-from dateutil.parser import isoparse
-
-from ..types import UNSET, Unset
-
-if TYPE_CHECKING:
- from ..models.sandbox_metric import SandboxMetric
-
-
-T = TypeVar("T", bound="RunningSandboxWithMetrics")
-
-
-@_attrs_define
-class RunningSandboxWithMetrics:
- """
- Attributes:
- client_id (str): Identifier of the client
- cpu_count (int): CPU cores for the sandbox
- end_at (datetime.datetime): Time when the sandbox will expire
- memory_mb (int): Memory for the sandbox in MB
- sandbox_id (str): Identifier of the sandbox
- started_at (datetime.datetime): Time when the sandbox was started
- template_id (str): Identifier of the template from which is the sandbox created
- alias (Union[Unset, str]): Alias of the template
- metadata (Union[Unset, Any]):
- metrics (Union[Unset, list['SandboxMetric']]):
- """
-
- client_id: str
- cpu_count: int
- end_at: datetime.datetime
- memory_mb: int
- sandbox_id: str
- started_at: datetime.datetime
- template_id: str
- alias: Union[Unset, str] = UNSET
- metadata: Union[Unset, Any] = UNSET
- metrics: Union[Unset, list["SandboxMetric"]] = UNSET
- additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict)
-
- def to_dict(self) -> dict[str, Any]:
- client_id = self.client_id
-
- cpu_count = self.cpu_count
-
- end_at = self.end_at.isoformat()
-
- memory_mb = self.memory_mb
-
- sandbox_id = self.sandbox_id
-
- started_at = self.started_at.isoformat()
-
- template_id = self.template_id
-
- alias = self.alias
-
- metadata = self.metadata
-
- metrics: Union[Unset, list[dict[str, Any]]] = UNSET
- if not isinstance(self.metrics, Unset):
- metrics = []
- for metrics_item_data in self.metrics:
- metrics_item = metrics_item_data.to_dict()
- metrics.append(metrics_item)
-
- field_dict: dict[str, Any] = {}
- field_dict.update(self.additional_properties)
- field_dict.update(
- {
- "clientID": client_id,
- "cpuCount": cpu_count,
- "endAt": end_at,
- "memoryMB": memory_mb,
- "sandboxID": sandbox_id,
- "startedAt": started_at,
- "templateID": template_id,
- }
- )
- if alias is not UNSET:
- field_dict["alias"] = alias
- if metadata is not UNSET:
- field_dict["metadata"] = metadata
- if metrics is not UNSET:
- field_dict["metrics"] = metrics
-
- return field_dict
-
- @classmethod
- def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T:
- from ..models.sandbox_metric import SandboxMetric
-
- d = dict(src_dict)
- client_id = d.pop("clientID")
-
- cpu_count = d.pop("cpuCount")
-
- end_at = isoparse(d.pop("endAt"))
-
- memory_mb = d.pop("memoryMB")
-
- sandbox_id = d.pop("sandboxID")
-
- started_at = isoparse(d.pop("startedAt"))
-
- template_id = d.pop("templateID")
-
- alias = d.pop("alias", UNSET)
-
- metadata = d.pop("metadata", UNSET)
-
- metrics = []
- _metrics = d.pop("metrics", UNSET)
- for metrics_item_data in _metrics or []:
- metrics_item = SandboxMetric.from_dict(metrics_item_data)
-
- metrics.append(metrics_item)
-
- running_sandbox_with_metrics = cls(
- client_id=client_id,
- cpu_count=cpu_count,
- end_at=end_at,
- memory_mb=memory_mb,
- sandbox_id=sandbox_id,
- started_at=started_at,
- template_id=template_id,
- alias=alias,
- metadata=metadata,
- metrics=metrics,
- )
-
- running_sandbox_with_metrics.additional_properties = d
- return running_sandbox_with_metrics
-
- @property
- def additional_keys(self) -> list[str]:
- return list(self.additional_properties.keys())
-
- def __getitem__(self, key: str) -> Any:
- return self.additional_properties[key]
-
- def __setitem__(self, key: str, value: Any) -> None:
- self.additional_properties[key] = value
-
- def __delitem__(self, key: str) -> None:
- del self.additional_properties[key]
-
- def __contains__(self, key: str) -> bool:
- return key in self.additional_properties
diff --git a/packages/python-sdk/e2b/api/client/models/sandbox.py b/packages/python-sdk/e2b/api/client/models/sandbox.py
index b3b7caa87..7f3f9f54f 100644
--- a/packages/python-sdk/e2b/api/client/models/sandbox.py
+++ b/packages/python-sdk/e2b/api/client/models/sandbox.py
@@ -1,5 +1,5 @@
from collections.abc import Mapping
-from typing import Any, TypeVar, Union
+from typing import Any, TypeVar, Union, cast
from attrs import define as _attrs_define
from attrs import field as _attrs_field
@@ -18,6 +18,7 @@ class Sandbox:
sandbox_id (str): Identifier of the sandbox
template_id (str): Identifier of the template from which is the sandbox created
alias (Union[Unset, str]): Alias of the template
+ domain (Union[None, Unset, str]): Base domain where the sandbox traffic is accessible
envd_access_token (Union[Unset, str]): Access token used for envd communication
"""
@@ -26,6 +27,7 @@ class Sandbox:
sandbox_id: str
template_id: str
alias: Union[Unset, str] = UNSET
+ domain: Union[None, Unset, str] = UNSET
envd_access_token: Union[Unset, str] = UNSET
additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict)
@@ -40,6 +42,12 @@ class Sandbox:
alias = self.alias
+ domain: Union[None, Unset, str]
+ if isinstance(self.domain, Unset):
+ domain = UNSET
+ else:
+ domain = self.domain
+
envd_access_token = self.envd_access_token
field_dict: dict[str, Any] = {}
@@ -54,6 +62,8 @@ class Sandbox:
)
if alias is not UNSET:
field_dict["alias"] = alias
+ if domain is not UNSET:
+ field_dict["domain"] = domain
if envd_access_token is not UNSET:
field_dict["envdAccessToken"] = envd_access_token
@@ -72,6 +82,15 @@ class Sandbox:
alias = d.pop("alias", UNSET)
+ def _parse_domain(data: object) -> Union[None, Unset, str]:
+ if data is None:
+ return data
+ if isinstance(data, Unset):
+ return data
+ return cast(Union[None, Unset, str], data)
+
+ domain = _parse_domain(d.pop("domain", UNSET))
+
envd_access_token = d.pop("envdAccessToken", UNSET)
sandbox = cls(
@@ -80,6 +99,7 @@ class Sandbox:
sandbox_id=sandbox_id,
template_id=template_id,
alias=alias,
+ domain=domain,
envd_access_token=envd_access_token,
)
diff --git a/packages/python-sdk/e2b/api/client/models/sandbox_detail.py b/packages/python-sdk/e2b/api/client/models/sandbox_detail.py
index dacfda150..02e6ec2a4 100644
--- a/packages/python-sdk/e2b/api/client/models/sandbox_detail.py
+++ b/packages/python-sdk/e2b/api/client/models/sandbox_detail.py
@@ -1,6 +1,6 @@
import datetime
from collections.abc import Mapping
-from typing import Any, TypeVar, Union
+from typing import Any, TypeVar, Union, cast
from attrs import define as _attrs_define
from attrs import field as _attrs_field
@@ -25,6 +25,7 @@ class SandboxDetail:
state (SandboxState): State of the sandbox
template_id (str): Identifier of the template from which is the sandbox created
alias (Union[Unset, str]): Alias of the template
+ domain (Union[None, Unset, str]): Base domain where the sandbox traffic is accessible
envd_access_token (Union[Unset, str]): Access token used for envd communication
envd_version (Union[Unset, str]): Version of the envd running in the sandbox
metadata (Union[Unset, Any]):
@@ -39,6 +40,7 @@ class SandboxDetail:
state: SandboxState
template_id: str
alias: Union[Unset, str] = UNSET
+ domain: Union[None, Unset, str] = UNSET
envd_access_token: Union[Unset, str] = UNSET
envd_version: Union[Unset, str] = UNSET
metadata: Union[Unset, Any] = UNSET
@@ -63,6 +65,12 @@ class SandboxDetail:
alias = self.alias
+ domain: Union[None, Unset, str]
+ if isinstance(self.domain, Unset):
+ domain = UNSET
+ else:
+ domain = self.domain
+
envd_access_token = self.envd_access_token
envd_version = self.envd_version
@@ -85,6 +93,8 @@ class SandboxDetail:
)
if alias is not UNSET:
field_dict["alias"] = alias
+ if domain is not UNSET:
+ field_dict["domain"] = domain
if envd_access_token is not UNSET:
field_dict["envdAccessToken"] = envd_access_token
if envd_version is not UNSET:
@@ -115,6 +125,15 @@ class SandboxDetail:
alias = d.pop("alias", UNSET)
+ def _parse_domain(data: object) -> Union[None, Unset, str]:
+ if data is None:
+ return data
+ if isinstance(data, Unset):
+ return data
+ return cast(Union[None, Unset, str], data)
+
+ domain = _parse_domain(d.pop("domain", UNSET))
+
envd_access_token = d.pop("envdAccessToken", UNSET)
envd_version = d.pop("envdVersion", UNSET)
@@ -131,6 +150,7 @@ class SandboxDetail:
state=state,
template_id=template_id,
alias=alias,
+ domain=domain,
envd_access_token=envd_access_token,
envd_version=envd_version,
metadata=metadata,
diff --git a/packages/python-sdk/e2b/api/client/models/sandbox_metric.py b/packages/python-sdk/e2b/api/client/models/sandbox_metric.py
index 7526ba933..3ac132ae2 100644
--- a/packages/python-sdk/e2b/api/client/models/sandbox_metric.py
+++ b/packages/python-sdk/e2b/api/client/models/sandbox_metric.py
@@ -16,15 +16,15 @@ class SandboxMetric:
Attributes:
cpu_count (int): Number of CPU cores
cpu_used_pct (float): CPU usage percentage
- mem_total_mi_b (int): Total memory in MiB
- mem_used_mi_b (int): Memory used in MiB
+ mem_total (int): Total memory in bytes
+ mem_used (int): Memory used in bytes
timestamp (datetime.datetime): Timestamp of the metric entry
"""
cpu_count: int
cpu_used_pct: float
- mem_total_mi_b: int
- mem_used_mi_b: int
+ mem_total: int
+ mem_used: int
timestamp: datetime.datetime
additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict)
@@ -33,9 +33,9 @@ class SandboxMetric:
cpu_used_pct = self.cpu_used_pct
- mem_total_mi_b = self.mem_total_mi_b
+ mem_total = self.mem_total
- mem_used_mi_b = self.mem_used_mi_b
+ mem_used = self.mem_used
timestamp = self.timestamp.isoformat()
@@ -45,8 +45,8 @@ class SandboxMetric:
{
"cpuCount": cpu_count,
"cpuUsedPct": cpu_used_pct,
- "memTotalMiB": mem_total_mi_b,
- "memUsedMiB": mem_used_mi_b,
+ "memTotal": mem_total,
+ "memUsed": mem_used,
"timestamp": timestamp,
}
)
@@ -60,17 +60,17 @@ class SandboxMetric:
cpu_used_pct = d.pop("cpuUsedPct")
- mem_total_mi_b = d.pop("memTotalMiB")
+ mem_total = d.pop("memTotal")
- mem_used_mi_b = d.pop("memUsedMiB")
+ mem_used = d.pop("memUsed")
timestamp = isoparse(d.pop("timestamp"))
sandbox_metric = cls(
cpu_count=cpu_count,
cpu_used_pct=cpu_used_pct,
- mem_total_mi_b=mem_total_mi_b,
- mem_used_mi_b=mem_used_mi_b,
+ mem_total=mem_total,
+ mem_used=mem_used,
timestamp=timestamp,
)
diff --git a/packages/python-sdk/e2b/api/client/models/sandboxes_with_metrics.py b/packages/python-sdk/e2b/api/client/models/sandboxes_with_metrics.py
new file mode 100644
index 000000000..64981d955
--- /dev/null
+++ b/packages/python-sdk/e2b/api/client/models/sandboxes_with_metrics.py
@@ -0,0 +1,59 @@
+from collections.abc import Mapping
+from typing import Any, TypeVar
+
+from attrs import define as _attrs_define
+from attrs import field as _attrs_field
+
+T = TypeVar("T", bound="SandboxesWithMetrics")
+
+
+@_attrs_define
+class SandboxesWithMetrics:
+ """
+ Attributes:
+ sandboxes (Any):
+ """
+
+ sandboxes: Any
+ additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict)
+
+ def to_dict(self) -> dict[str, Any]:
+ sandboxes = self.sandboxes
+
+ field_dict: dict[str, Any] = {}
+ field_dict.update(self.additional_properties)
+ field_dict.update(
+ {
+ "sandboxes": sandboxes,
+ }
+ )
+
+ return field_dict
+
+ @classmethod
+ def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T:
+ d = dict(src_dict)
+ sandboxes = d.pop("sandboxes")
+
+ sandboxes_with_metrics = cls(
+ sandboxes=sandboxes,
+ )
+
+ sandboxes_with_metrics.additional_properties = d
+ return sandboxes_with_metrics
+
+ @property
+ def additional_keys(self) -> list[str]:
+ return list(self.additional_properties.keys())
+
+ def __getitem__(self, key: str) -> Any:
+ return self.additional_properties[key]
+
+ def __setitem__(self, key: str, value: Any) -> None:
+ self.additional_properties[key] = value
+
+ def __delitem__(self, key: str) -> None:
+ del self.additional_properties[key]
+
+ def __contains__(self, key: str) -> bool:
+ return key in self.additional_properties
diff --git a/packages/python-sdk/e2b/api/client/models/team_api_key.py b/packages/python-sdk/e2b/api/client/models/team_api_key.py
index d047ad375..7edbbc1e4 100644
--- a/packages/python-sdk/e2b/api/client/models/team_api_key.py
+++ b/packages/python-sdk/e2b/api/client/models/team_api_key.py
@@ -7,7 +7,10 @@ from attrs import define as _attrs_define
from attrs import field as _attrs_field
from dateutil.parser import isoparse
+from ..types import UNSET, Unset
+
if TYPE_CHECKING:
+ from ..models.identifier_masking_details import IdentifierMaskingDetails
from ..models.team_user import TeamUser
@@ -19,19 +22,19 @@ class TeamAPIKey:
"""
Attributes:
created_at (datetime.datetime): Timestamp of API key creation
- created_by (Union['TeamUser', None]):
id (UUID): Identifier of the API key
- key_mask (str): Mask of the API key
- last_used (Union[None, datetime.datetime]): Last time this API key was used
+ mask (IdentifierMaskingDetails):
name (str): Name of the API key
+ created_by (Union['TeamUser', None, Unset]):
+ last_used (Union[None, Unset, datetime.datetime]): Last time this API key was used
"""
created_at: datetime.datetime
- created_by: Union["TeamUser", None]
id: UUID
- key_mask: str
- last_used: Union[None, datetime.datetime]
+ mask: "IdentifierMaskingDetails"
name: str
+ created_by: Union["TeamUser", None, Unset] = UNSET
+ last_used: Union[None, Unset, datetime.datetime] = UNSET
additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict)
def to_dict(self) -> dict[str, Any]:
@@ -39,49 +42,64 @@ class TeamAPIKey:
created_at = self.created_at.isoformat()
- created_by: Union[None, dict[str, Any]]
- if isinstance(self.created_by, TeamUser):
+ id = str(self.id)
+
+ mask = self.mask.to_dict()
+
+ name = self.name
+
+ created_by: Union[None, Unset, dict[str, Any]]
+ if isinstance(self.created_by, Unset):
+ created_by = UNSET
+ elif isinstance(self.created_by, TeamUser):
created_by = self.created_by.to_dict()
else:
created_by = self.created_by
- id = str(self.id)
-
- key_mask = self.key_mask
-
- last_used: Union[None, str]
- if isinstance(self.last_used, datetime.datetime):
+ last_used: Union[None, Unset, str]
+ if isinstance(self.last_used, Unset):
+ last_used = UNSET
+ elif isinstance(self.last_used, datetime.datetime):
last_used = self.last_used.isoformat()
else:
last_used = self.last_used
- name = self.name
-
field_dict: dict[str, Any] = {}
field_dict.update(self.additional_properties)
field_dict.update(
{
"createdAt": created_at,
- "createdBy": created_by,
"id": id,
- "keyMask": key_mask,
- "lastUsed": last_used,
+ "mask": mask,
"name": name,
}
)
+ if created_by is not UNSET:
+ field_dict["createdBy"] = created_by
+ if last_used is not UNSET:
+ field_dict["lastUsed"] = last_used
return field_dict
@classmethod
def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T:
+ from ..models.identifier_masking_details import IdentifierMaskingDetails
from ..models.team_user import TeamUser
d = dict(src_dict)
created_at = isoparse(d.pop("createdAt"))
- def _parse_created_by(data: object) -> Union["TeamUser", None]:
+ id = UUID(d.pop("id"))
+
+ mask = IdentifierMaskingDetails.from_dict(d.pop("mask"))
+
+ name = d.pop("name")
+
+ def _parse_created_by(data: object) -> Union["TeamUser", None, Unset]:
if data is None:
return data
+ if isinstance(data, Unset):
+ return data
try:
if not isinstance(data, dict):
raise TypeError()
@@ -90,17 +108,15 @@ class TeamAPIKey:
return created_by_type_1
except: # noqa: E722
pass
- return cast(Union["TeamUser", None], data)
+ return cast(Union["TeamUser", None, Unset], data)
- created_by = _parse_created_by(d.pop("createdBy"))
+ created_by = _parse_created_by(d.pop("createdBy", UNSET))
- id = UUID(d.pop("id"))
-
- key_mask = d.pop("keyMask")
-
- def _parse_last_used(data: object) -> Union[None, datetime.datetime]:
+ def _parse_last_used(data: object) -> Union[None, Unset, datetime.datetime]:
if data is None:
return data
+ if isinstance(data, Unset):
+ return data
try:
if not isinstance(data, str):
raise TypeError()
@@ -109,19 +125,17 @@ class TeamAPIKey:
return last_used_type_0
except: # noqa: E722
pass
- return cast(Union[None, datetime.datetime], data)
+ return cast(Union[None, Unset, datetime.datetime], data)
- last_used = _parse_last_used(d.pop("lastUsed"))
-
- name = d.pop("name")
+ last_used = _parse_last_used(d.pop("lastUsed", UNSET))
team_api_key = cls(
created_at=created_at,
- created_by=created_by,
id=id,
- key_mask=key_mask,
- last_used=last_used,
+ mask=mask,
name=name,
+ created_by=created_by,
+ last_used=last_used,
)
team_api_key.additional_properties = d
diff --git a/packages/python-sdk/e2b/api/client/models/template_build.py b/packages/python-sdk/e2b/api/client/models/template_build.py
index aecc8cb40..1d5691957 100644
--- a/packages/python-sdk/e2b/api/client/models/template_build.py
+++ b/packages/python-sdk/e2b/api/client/models/template_build.py
@@ -1,10 +1,11 @@
from collections.abc import Mapping
-from typing import Any, TypeVar, cast
+from typing import Any, TypeVar, Union, cast
from attrs import define as _attrs_define
from attrs import field as _attrs_field
from ..models.template_build_status import TemplateBuildStatus
+from ..types import UNSET, Unset
T = TypeVar("T", bound="TemplateBuild")
@@ -17,12 +18,14 @@ class TemplateBuild:
logs (list[str]): Build logs
status (TemplateBuildStatus): Status of the template
template_id (str): Identifier of the template
+ reason (Union[Unset, str]): Message with the status reason, currently reporting only for error status
"""
build_id: str
logs: list[str]
status: TemplateBuildStatus
template_id: str
+ reason: Union[Unset, str] = UNSET
additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict)
def to_dict(self) -> dict[str, Any]:
@@ -34,6 +37,8 @@ class TemplateBuild:
template_id = self.template_id
+ reason = self.reason
+
field_dict: dict[str, Any] = {}
field_dict.update(self.additional_properties)
field_dict.update(
@@ -44,6 +49,8 @@ class TemplateBuild:
"templateID": template_id,
}
)
+ if reason is not UNSET:
+ field_dict["reason"] = reason
return field_dict
@@ -58,11 +65,14 @@ class TemplateBuild:
template_id = d.pop("templateID")
+ reason = d.pop("reason", UNSET)
+
template_build = cls(
build_id=build_id,
logs=logs,
status=status,
template_id=template_id,
+ reason=reason,
)
template_build.additional_properties = d
diff --git a/packages/python-sdk/e2b/api/client/models/template_build_request.py b/packages/python-sdk/e2b/api/client/models/template_build_request.py
index 71ad19052..31c9689b2 100644
--- a/packages/python-sdk/e2b/api/client/models/template_build_request.py
+++ b/packages/python-sdk/e2b/api/client/models/template_build_request.py
@@ -17,6 +17,7 @@ class TemplateBuildRequest:
alias (Union[Unset, str]): Alias of the template
cpu_count (Union[Unset, int]): CPU cores for the sandbox
memory_mb (Union[Unset, int]): Memory for the sandbox in MB
+ ready_cmd (Union[Unset, str]): Ready check command to execute in the template after the build
start_cmd (Union[Unset, str]): Start command to execute in the template after the build
team_id (Union[Unset, str]): Identifier of the team
"""
@@ -25,6 +26,7 @@ class TemplateBuildRequest:
alias: Union[Unset, str] = UNSET
cpu_count: Union[Unset, int] = UNSET
memory_mb: Union[Unset, int] = UNSET
+ ready_cmd: Union[Unset, str] = UNSET
start_cmd: Union[Unset, str] = UNSET
team_id: Union[Unset, str] = UNSET
additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict)
@@ -38,6 +40,8 @@ class TemplateBuildRequest:
memory_mb = self.memory_mb
+ ready_cmd = self.ready_cmd
+
start_cmd = self.start_cmd
team_id = self.team_id
@@ -55,6 +59,8 @@ class TemplateBuildRequest:
field_dict["cpuCount"] = cpu_count
if memory_mb is not UNSET:
field_dict["memoryMB"] = memory_mb
+ if ready_cmd is not UNSET:
+ field_dict["readyCmd"] = ready_cmd
if start_cmd is not UNSET:
field_dict["startCmd"] = start_cmd
if team_id is not UNSET:
@@ -73,6 +79,8 @@ class TemplateBuildRequest:
memory_mb = d.pop("memoryMB", UNSET)
+ ready_cmd = d.pop("readyCmd", UNSET)
+
start_cmd = d.pop("startCmd", UNSET)
team_id = d.pop("teamID", UNSET)
@@ -82,6 +90,7 @@ class TemplateBuildRequest:
alias=alias,
cpu_count=cpu_count,
memory_mb=memory_mb,
+ ready_cmd=ready_cmd,
start_cmd=start_cmd,
team_id=team_id,
)
diff --git a/packages/python-sdk/e2b/sandbox/main.py b/packages/python-sdk/e2b/sandbox/main.py
index 8fda0f95f..c8dea728e 100644
--- a/packages/python-sdk/e2b/sandbox/main.py
+++ b/packages/python-sdk/e2b/sandbox/main.py
@@ -41,7 +41,18 @@ class SandboxSetup(ABC):
def sandbox_id(self) -> str:
...
- def _file_url(self, path: Optional[str] = None, user: str = "user", signature: Optional[str] = None, signature_expiration: Optional[int] = None) -> str:
+ @property
+ @abstractmethod
+ def sandbox_domain(self) -> str:
+ ...
+
+ def _file_url(
+ self,
+ path: Optional[str] = None,
+ user: str = "user",
+ signature: Optional[str] = None,
+ signature_expiration: Optional[int] = None,
+ ) -> str:
url = urllib.parse.urljoin(self.envd_api_url, ENVD_API_FILES_ROUTE)
query = {"path": path} if path else {}
query = {**query, "username": user}
@@ -62,7 +73,13 @@ class SandboxSetup(ABC):
return url
- def download_url(self, path: str, user: str = "user", use_signature: bool = False, use_signature_expiration: Optional[int] = None) -> str:
+ def download_url(
+ self,
+ path: str,
+ user: str = "user",
+ use_signature: bool = False,
+ use_signature_expiration: Optional[int] = None,
+ ) -> str:
"""
Get the URL to download a file from the sandbox.
@@ -75,12 +92,22 @@ class SandboxSetup(ABC):
"""
if use_signature:
- signature = get_signature(path, "read", user, self._envd_access_token, use_signature_expiration)
- return self._file_url(path, user, signature["signature"], signature["expiration"])
+ signature = get_signature(
+ path, "read", user, self._envd_access_token, use_signature_expiration
+ )
+ return self._file_url(
+ path, user, signature["signature"], signature["expiration"]
+ )
else:
return self._file_url(path)
- def upload_url(self, path: Optional[str] = None, user: str = "user", use_signature: bool = False, use_signature_expiration: Optional[int] = None) -> str:
+ def upload_url(
+ self,
+ path: Optional[str] = None,
+ user: str = "user",
+ use_signature: bool = False,
+ use_signature_expiration: Optional[int] = None,
+ ) -> str:
"""
Get the URL to upload a file to the sandbox.
@@ -95,8 +122,12 @@ class SandboxSetup(ABC):
"""
if use_signature:
- signature = get_signature(path, "write", user, self._envd_access_token, use_signature_expiration)
- return self._file_url(path, user, signature["signature"], signature["expiration"])
+ signature = get_signature(
+ path, "write", user, self._envd_access_token, use_signature_expiration
+ )
+ return self._file_url(
+ path, user, signature["signature"], signature["expiration"]
+ )
else:
return self._file_url(path)
@@ -112,4 +143,4 @@ class SandboxSetup(ABC):
if self.connection_config.debug:
return f"localhost:{port}"
- return f"{port}-{self.sandbox_id}.{self.connection_config.domain}"
+ return f"{port}-{self.sandbox_id}.{self.sandbox_domain}"
diff --git a/packages/python-sdk/e2b/sandbox/sandbox_api.py b/packages/python-sdk/e2b/sandbox/sandbox_api.py
index ba1836316..f928a4039 100644
--- a/packages/python-sdk/e2b/sandbox/sandbox_api.py
+++ b/packages/python-sdk/e2b/sandbox/sandbox_api.py
@@ -14,6 +14,8 @@ class SandboxInfo:
sandbox_id: str
"""Sandbox ID."""
+ sandbox_domain: Optional[str]
+ """Domain where the sandbox is hosted."""
template_id: str
"""Template ID."""
name: Optional[str]
@@ -29,6 +31,7 @@ class SandboxInfo:
_envd_access_token: Optional[str]
"""Envd access token."""
+
@dataclass
class ListedSandbox:
"""Information about a sandbox."""
@@ -51,6 +54,7 @@ class ListedSandbox:
"""Sandbox start time."""
end_at: datetime
+
@dataclass
class SandboxQuery:
"""Query parameters for listing sandboxes."""
diff --git a/packages/python-sdk/e2b/sandbox/signature.py b/packages/python-sdk/e2b/sandbox/signature.py
index d094ee908..b08a40b96 100644
--- a/packages/python-sdk/e2b/sandbox/signature.py
+++ b/packages/python-sdk/e2b/sandbox/signature.py
@@ -6,6 +6,7 @@ from typing import Optional, TypedDict, Literal
Operation = Literal["read", "write"]
+
class Signature(TypedDict):
signature: str
expiration: Optional[int] # Unix timestamp or None
diff --git a/packages/python-sdk/e2b/sandbox_async/main.py b/packages/python-sdk/e2b/sandbox_async/main.py
index 1bd0dd9fe..27f60b915 100644
--- a/packages/python-sdk/e2b/sandbox_async/main.py
+++ b/packages/python-sdk/e2b/sandbox_async/main.py
@@ -32,6 +32,7 @@ class AsyncTransportWithLogger(httpx.AsyncHTTPTransport):
class AsyncSandboxOpts(TypedDict):
sandbox_id: str
+ sandbox_domain: Optional[str]
envd_version: Optional[str]
envd_access_token: Optional[str]
connection_config: ConnectionConfig
@@ -88,6 +89,13 @@ class AsyncSandbox(SandboxSetup, SandboxApi):
"""
return self._sandbox_id
+ @property
+ def sandbox_domain(self) -> str:
+ """
+ Unique identifier of the sandbox.
+ """
+ return self._sandbox_domain
+
@property
def envd_api_url(self) -> str:
return self._envd_api_url
@@ -112,9 +120,11 @@ class AsyncSandbox(SandboxSetup, SandboxApi):
"""
super().__init__()
- self._sandbox_id = opts["sandbox_id"]
self._connection_config = opts["connection_config"]
+ self._sandbox_id = opts["sandbox_id"]
+ self._sandbox_domain = opts["sandbox_domain"] or self.connection_config.domain
+
self._envd_api_url = f"{'http' if self.connection_config.debug else 'https'}://{self.get_host(self.envd_port)}"
self._envd_version = opts["envd_version"]
self._envd_access_token = opts["envd_access_token"]
@@ -219,6 +229,7 @@ class AsyncSandbox(SandboxSetup, SandboxApi):
if debug:
sandbox_id = "debug_sandbox_id"
+ sandbox_domain = None
envd_version = None
envd_access_token = None
else:
@@ -236,6 +247,7 @@ class AsyncSandbox(SandboxSetup, SandboxApi):
)
sandbox_id = response.sandbox_id
+ sandbox_domain = response.sandbox_domain
envd_version = response.envd_version
envd_access_token = response.envd_access_token
@@ -255,6 +267,7 @@ class AsyncSandbox(SandboxSetup, SandboxApi):
return cls(
sandbox_id=sandbox_id,
+ sandbox_domain=sandbox_domain,
envd_version=envd_version,
envd_access_token=envd_access_token,
connection_config=connection_config,
@@ -313,6 +326,7 @@ class AsyncSandbox(SandboxSetup, SandboxApi):
return cls(
sandbox_id=sandbox_id,
+ sandbox_domain=response.sandbox_domain,
connection_config=connection_config,
envd_version=response.envd_version,
envd_access_token=response._envd_access_token,
diff --git a/packages/python-sdk/e2b/sandbox_async/sandbox_api.py b/packages/python-sdk/e2b/sandbox_async/sandbox_api.py
index 59a38e9bd..6ef22bb76 100644
--- a/packages/python-sdk/e2b/sandbox_async/sandbox_api.py
+++ b/packages/python-sdk/e2b/sandbox_async/sandbox_api.py
@@ -4,7 +4,12 @@ from typing import Optional, Dict, List
from packaging.version import Version
-from e2b.sandbox.sandbox_api import SandboxInfo, SandboxApiBase, SandboxQuery, ListedSandbox
+from e2b.sandbox.sandbox_api import (
+ SandboxInfo,
+ SandboxApiBase,
+ SandboxQuery,
+ ListedSandbox,
+)
from e2b.exceptions import TemplateException
from e2b.api import AsyncApiClient, SandboxCreateResponse
from e2b.api.client.models import NewSandbox, PostSandboxesSandboxIDTimeoutBody
@@ -144,6 +149,7 @@ class SandboxApi(SandboxApiBase):
return SandboxInfo(
sandbox_id=res.parsed.sandbox_id,
+ sandbox_domain=res.parsed.domain,
template_id=res.parsed.template_id,
name=res.parsed.alias if isinstance(res.parsed.alias, str) else None,
metadata=(
@@ -288,6 +294,7 @@ class SandboxApi(SandboxApiBase):
return SandboxCreateResponse(
sandbox_id=res.parsed.sandbox_id,
+ sandbox_domain=res.parsed.domain,
envd_version=res.parsed.envd_version,
envd_access_token=res.parsed.envd_access_token,
)
diff --git a/packages/python-sdk/e2b/sandbox_sync/filesystem/filesystem.py b/packages/python-sdk/e2b/sandbox_sync/filesystem/filesystem.py
index 65a84b264..a7ae9320c 100644
--- a/packages/python-sdk/e2b/sandbox_sync/filesystem/filesystem.py
+++ b/packages/python-sdk/e2b/sandbox_sync/filesystem/filesystem.py
@@ -449,7 +449,7 @@ class Filesystem:
headers={
**authentication_header(user),
KEEPALIVE_PING_HEADER: str(KEEPALIVE_PING_INTERVAL_SEC),
- }
+ },
)
except Exception as e:
raise handle_rpc_exception(e)
diff --git a/packages/python-sdk/e2b/sandbox_sync/main.py b/packages/python-sdk/e2b/sandbox_sync/main.py
index 6dba662a9..b09cc8190 100644
--- a/packages/python-sdk/e2b/sandbox_sync/main.py
+++ b/packages/python-sdk/e2b/sandbox_sync/main.py
@@ -76,10 +76,17 @@ class Sandbox(SandboxSetup, SandboxApi):
@property
def sandbox_id(self) -> str:
"""
- Unique identifier of the sandbox
+ Unique identifier of the sandbox.
"""
return self._sandbox_id
+ @property
+ def sandbox_domain(self) -> str:
+ """
+ Domain where the sandbox is hosted.
+ """
+ return self._sandbox_domain
+
@property
def envd_api_url(self) -> str:
return self._envd_api_url
@@ -139,6 +146,7 @@ class Sandbox(SandboxSetup, SandboxApi):
if debug:
self._sandbox_id = "debug_sandbox_id"
+ self._sandbox_domain = None
self._envd_version = None
self._envd_access_token = None
elif sandbox_id is not None:
@@ -152,11 +160,12 @@ class Sandbox(SandboxSetup, SandboxApi):
)
self._sandbox_id = sandbox_id
+ self._sandbox_domain = response.sandbox_domain
self._envd_version = response.envd_version
self._envd_access_token = response._envd_access_token
if response._envd_access_token is not None and not isinstance(
- response._envd_access_token, Unset
+ response._envd_access_token, Unset
):
connection_headers["X-Access-Token"] = response._envd_access_token
else:
@@ -174,7 +183,9 @@ class Sandbox(SandboxSetup, SandboxApi):
secure=secure or False,
proxy=proxy,
)
+
self._sandbox_id = response.sandbox_id
+ self._sandbox_domain = response.sandbox_domain
self._envd_version = response.envd_version
if response.envd_access_token is not None and not isinstance(
@@ -195,6 +206,7 @@ class Sandbox(SandboxSetup, SandboxApi):
proxy=proxy,
)
+ self._sandbox_domain = self._sandbox_domain or self._connection_config.domain
self._envd_api_url = f"{'http' if self.connection_config.debug else 'https'}://{self.get_host(self.envd_port)}"
self._envd_api = httpx.Client(
base_url=self.envd_api_url,
diff --git a/packages/python-sdk/e2b/sandbox_sync/sandbox_api.py b/packages/python-sdk/e2b/sandbox_sync/sandbox_api.py
index a47241a1e..e817276dc 100644
--- a/packages/python-sdk/e2b/sandbox_sync/sandbox_api.py
+++ b/packages/python-sdk/e2b/sandbox_sync/sandbox_api.py
@@ -3,7 +3,12 @@ import urllib.parse
from typing import Optional, Dict, List
from packaging.version import Version
-from e2b.sandbox.sandbox_api import SandboxInfo, SandboxApiBase, SandboxQuery, ListedSandbox
+from e2b.sandbox.sandbox_api import (
+ SandboxInfo,
+ SandboxApiBase,
+ SandboxQuery,
+ ListedSandbox,
+)
from e2b.exceptions import TemplateException
from e2b.api import ApiClient, SandboxCreateResponse
from e2b.api.client.models import NewSandbox, PostSandboxesSandboxIDTimeoutBody
@@ -139,6 +144,7 @@ class SandboxApi(SandboxApiBase):
return SandboxInfo(
sandbox_id=res.parsed.sandbox_id,
+ sandbox_domain=res.parsed.domain,
template_id=res.parsed.template_id,
name=res.parsed.alias if isinstance(res.parsed.alias, str) else None,
metadata=(
@@ -280,6 +286,7 @@ class SandboxApi(SandboxApiBase):
return SandboxCreateResponse(
sandbox_id=res.parsed.sandbox_id,
+ sandbox_domain=res.parsed.domain,
envd_version=res.parsed.envd_version,
envd_access_token=res.parsed.envd_access_token,
)
diff --git a/packages/python-sdk/e2b_connect/client.py b/packages/python-sdk/e2b_connect/client.py
index ab52a3baa..0029a973b 100644
--- a/packages/python-sdk/e2b_connect/client.py
+++ b/packages/python-sdk/e2b_connect/client.py
@@ -37,6 +37,7 @@ class Code(Enum):
data_loss = "data_loss"
unauthenticated = "unauthenticated"
+
def make_error_from_http_code(http_code: int):
error_code_map = {
400: Code.invalid_argument,
@@ -54,9 +55,10 @@ def make_error_from_http_code(http_code: int):
504: Code.deadline_exceeded,
505: Code.unimplemented,
}
-
+
return error_code_map.get(http_code, Code.unknown)
+
class ConnectException(Exception):
def __init__(self, status: Code, message: str):
self.status = status
@@ -85,12 +87,10 @@ def error_for_response(http_resp: Response):
error = json.loads(http_resp.content)
return make_error(error)
except (json.decoder.JSONDecodeError, KeyError):
- error = {
- "code": http_resp.status,
- "message": http_resp.content.decode('utf-8')
- }
+ error = {"code": http_resp.status, "message": http_resp.content.decode("utf-8")}
return make_error(error)
+
def make_error(error):
status = None
try:
diff --git a/packages/python-sdk/tests/async/sandbox_async/commands/test_cmd_list.py b/packages/python-sdk/tests/async/sandbox_async/commands/test_cmd_list.py
index 8020ec2f6..b7906a665 100644
--- a/packages/python-sdk/tests/async/sandbox_async/commands/test_cmd_list.py
+++ b/packages/python-sdk/tests/async/sandbox_async/commands/test_cmd_list.py
@@ -1,4 +1,3 @@
-
from e2b import AsyncSandbox
diff --git a/packages/python-sdk/tests/async/sandbox_async/files/test_exists.py b/packages/python-sdk/tests/async/sandbox_async/files/test_exists.py
index 3b81a23f2..203dd19a3 100644
--- a/packages/python-sdk/tests/async/sandbox_async/files/test_exists.py
+++ b/packages/python-sdk/tests/async/sandbox_async/files/test_exists.py
@@ -1,4 +1,3 @@
-
from e2b import AsyncSandbox
diff --git a/packages/python-sdk/tests/async/sandbox_async/files/test_remove.py b/packages/python-sdk/tests/async/sandbox_async/files/test_remove.py
index 752929b97..07cf2cfa3 100644
--- a/packages/python-sdk/tests/async/sandbox_async/files/test_remove.py
+++ b/packages/python-sdk/tests/async/sandbox_async/files/test_remove.py
@@ -1,4 +1,3 @@
-
from e2b import AsyncSandbox
diff --git a/packages/python-sdk/tests/async/sandbox_async/files/test_secured.py b/packages/python-sdk/tests/async/sandbox_async/files/test_secured.py
index 6e7dd2d23..8a67bc234 100644
--- a/packages/python-sdk/tests/async/sandbox_async/files/test_secured.py
+++ b/packages/python-sdk/tests/async/sandbox_async/files/test_secured.py
@@ -7,6 +7,7 @@ from e2b import (
AsyncSandbox,
)
+
@pytest.mark.skip_debug()
async def test_download_url_with_signing(template):
sbx = await AsyncSandbox.create(template, timeout=100, secure=True)
@@ -20,11 +21,12 @@ async def test_download_url_with_signing(template):
with urllib.request.urlopen(signed_url) as resp:
assert resp.status == 200
body_bytes = resp.read()
- body_text = body_bytes.decode()
+ body_text = body_bytes.decode()
assert body_text == file_content
finally:
await sbx.kill()
+
@pytest.mark.skip_debug()
async def test_download_url_with_signing_and_expiration(template):
sbx = await AsyncSandbox.create(template, timeout=100, secure=True)
@@ -38,11 +40,12 @@ async def test_download_url_with_signing_and_expiration(template):
with urllib.request.urlopen(signed_url) as resp:
assert resp.status == 200
body_bytes = resp.read()
- body_text = body_bytes.decode()
+ body_text = body_bytes.decode()
assert body_text == file_content
finally:
await sbx.kill()
+
@pytest.mark.skip_debug()
async def test_download_url_with_expired_signing(template):
sbx = await AsyncSandbox.create(template, timeout=100, secure=True)
@@ -62,11 +65,11 @@ async def test_download_url_with_expired_signing(template):
err = exc_info.value
assert err.code == 401, f"Unexpected status {err.code}"
- error_json_str = err.read().decode() # bytes ➜ str
- error_payload = json.loads(error_json_str) # str ➜ dict
+ error_json_str = err.read().decode() # bytes ➜ str
+ error_payload = json.loads(error_json_str) # str ➜ dict
expected_payload = {"code": 401, "message": "signature is already expired"}
assert error_payload == expected_payload
finally:
- await sbx.kill()
\ No newline at end of file
+ await sbx.kill()
diff --git a/packages/python-sdk/tests/async/sandbox_async/test_connect.py b/packages/python-sdk/tests/async/sandbox_async/test_connect.py
index 89a6d065d..6a6fc65a2 100644
--- a/packages/python-sdk/tests/async/sandbox_async/test_connect.py
+++ b/packages/python-sdk/tests/async/sandbox_async/test_connect.py
@@ -3,6 +3,7 @@ import pytest
from e2b import AsyncSandbox
+
@pytest.mark.skip_debug()
async def test_connect(template):
sbx = await AsyncSandbox.create(template, timeout=10)
@@ -14,6 +15,7 @@ async def test_connect(template):
finally:
await sbx.kill()
+
@pytest.mark.skip_debug()
async def test_connect_with_secure(template):
dir_name = f"test_directory_{uuid.uuid4()}"
diff --git a/packages/python-sdk/tests/async/sandbox_async/test_secure.py b/packages/python-sdk/tests/async/sandbox_async/test_secure.py
index 8759a8b33..8557e4597 100644
--- a/packages/python-sdk/tests/async/sandbox_async/test_secure.py
+++ b/packages/python-sdk/tests/async/sandbox_async/test_secure.py
@@ -2,6 +2,7 @@ import pytest
from e2b import AsyncSandbox
+
@pytest.mark.skip_debug()
async def test_start_secured(template):
sbx = await AsyncSandbox.create(template, timeout=5, secure=True)
@@ -12,6 +13,7 @@ async def test_start_secured(template):
finally:
await sbx.kill()
+
@pytest.mark.skip_debug()
async def test_connect_to_secured(template):
sbx = await AsyncSandbox.create(template, timeout=100, secure=True)
diff --git a/packages/python-sdk/tests/sync/sandbox_sync/files/test_secured.py b/packages/python-sdk/tests/sync/sandbox_sync/files/test_secured.py
index 84b396ce8..2dc55a103 100644
--- a/packages/python-sdk/tests/sync/sandbox_sync/files/test_secured.py
+++ b/packages/python-sdk/tests/sync/sandbox_sync/files/test_secured.py
@@ -5,6 +5,7 @@ import pytest
from e2b import Sandbox
+
@pytest.mark.skip_debug()
async def test_download_url_with_signing(template):
sbx = Sandbox(template, timeout=100, secure=True)
@@ -18,11 +19,12 @@ async def test_download_url_with_signing(template):
with urllib.request.urlopen(signed_url) as resp:
assert resp.status == 200
body_bytes = resp.read()
- body_text = body_bytes.decode()
+ body_text = body_bytes.decode()
assert body_text == file_content
finally:
sbx.kill()
+
@pytest.mark.skip_debug()
async def test_download_url_with_signing_and_expiration(template):
sbx = Sandbox(template, timeout=100, secure=True)
@@ -36,11 +38,12 @@ async def test_download_url_with_signing_and_expiration(template):
with urllib.request.urlopen(signed_url) as resp:
assert resp.status == 200
body_bytes = resp.read()
- body_text = body_bytes.decode()
+ body_text = body_bytes.decode()
assert body_text == file_content
finally:
sbx.kill()
+
@pytest.mark.skip_debug()
async def test_download_url_with_expired_signing(template):
sbx = Sandbox(template, timeout=100, secure=True)
@@ -60,11 +63,11 @@ async def test_download_url_with_expired_signing(template):
err = exc_info.value
assert err.code == 401, f"Unexpected status {err.code}"
- error_json_str = err.read().decode() # bytes ➜ str
- error_payload = json.loads(error_json_str) # str ➜ dict
+ error_json_str = err.read().decode() # bytes ➜ str
+ error_payload = json.loads(error_json_str) # str ➜ dict
expected_payload = {"code": 401, "message": "signature is already expired"}
assert error_payload == expected_payload
finally:
- sbx.kill()
\ No newline at end of file
+ sbx.kill()
diff --git a/packages/python-sdk/tests/sync/sandbox_sync/test_secure.py b/packages/python-sdk/tests/sync/sandbox_sync/test_secure.py
index aad330d78..fe597fef5 100644
--- a/packages/python-sdk/tests/sync/sandbox_sync/test_secure.py
+++ b/packages/python-sdk/tests/sync/sandbox_sync/test_secure.py
@@ -2,6 +2,7 @@ import pytest
from e2b import Sandbox
+
@pytest.mark.skip_debug()
def test_start_secured(template):
sbx = Sandbox(template, timeout=5, secure=True)
@@ -12,6 +13,7 @@ def test_start_secured(template):
finally:
sbx.kill()
+
@pytest.mark.skip_debug()
def test_connect_to_secured(template):
sbx = Sandbox(template, timeout=5, secure=True)
diff --git a/spec/openapi.yml b/spec/openapi.yml
index b47e63996..5a783614a 100644
--- a/spec/openapi.yml
+++ b/spec/openapi.yml
@@ -201,8 +201,8 @@ components:
- timestamp
- cpuCount
- cpuUsedPct
- - memUsedMiB
- - memTotalMiB
+ - memUsed
+ - memTotal
properties:
timestamp:
type: string
@@ -216,14 +216,14 @@ components:
type: number
format: float
description: CPU usage percentage
- memUsedMiB:
+ memUsed:
type: integer
format: int64
- description: Memory used in MiB
- memTotalMiB:
+ description: Memory used in bytes
+ memTotal:
type: integer
format: int64
- description: Total memory in MiB
+ description: Total memory in bytes
Sandbox:
required:
@@ -243,6 +243,7 @@ components:
description: Alias of the template
clientID:
type: string
+ deprecated: true
description: Identifier of the client
envdVersion:
type: string
@@ -250,6 +251,10 @@ components:
envdAccessToken:
type: string
description: Access token used for envd communication
+ domain:
+ type: string
+ nullable: true
+ description: Base domain where the sandbox traffic is accessible
SandboxDetail:
required:
@@ -273,6 +278,7 @@ components:
description: Identifier of the sandbox
clientID:
type: string
+ deprecated: true
description: Identifier of the client
startedAt:
type: string
@@ -288,6 +294,10 @@ components:
envdAccessToken:
type: string
description: Access token used for envd communication
+ domain:
+ type: string
+ nullable: true
+ description: Base domain where the sandbox traffic is accessible
cpuCount:
$ref: "#/components/schemas/CPUCount"
memoryMB:
@@ -319,6 +329,7 @@ components:
description: Identifier of the sandbox
clientID:
type: string
+ deprecated: true
description: Identifier of the client
startedAt:
type: string
@@ -337,45 +348,12 @@ components:
state:
$ref: "#/components/schemas/SandboxState"
- RunningSandboxWithMetrics:
+ SandboxesWithMetrics:
required:
- - templateID
- - sandboxID
- - clientID
- - startedAt
- - cpuCount
- - memoryMB
- - endAt
+ - sandboxes
properties:
- templateID:
- type: string
- description: Identifier of the template from which is the sandbox created
- alias:
- type: string
- description: Alias of the template
- sandboxID:
- type: string
- description: Identifier of the sandbox
- clientID:
- type: string
- description: Identifier of the client
- startedAt:
- type: string
- format: date-time
- description: Time when the sandbox was started
- endAt:
- type: string
- format: date-time
- description: Time when the sandbox will expire
- cpuCount:
- $ref: "#/components/schemas/CPUCount"
- memoryMB:
- $ref: "#/components/schemas/MemoryMB"
- metadata:
- $ref: "#/components/schemas/SandboxMetadata"
- metrics:
- type: array
- items:
+ sandboxes:
+ additionalProperties:
$ref: "#/components/schemas/SandboxMetric"
NewSandbox:
@@ -489,6 +467,9 @@ components:
startCmd:
description: Start command to execute in the template after the build
type: string
+ readyCmd:
+ description: Ready check command to execute in the template after the build
+ type: string
cpuCount:
$ref: "#/components/schemas/CPUCount"
memoryMB:
@@ -521,6 +502,9 @@ components:
- waiting
- ready
- error
+ reason:
+ type: string
+ description: Message with the status reason, currently reporting only for error status
NodeStatus:
type: string
@@ -545,16 +529,25 @@ components:
- sandboxCount
- allocatedCPU
- allocatedMemoryMiB
+ - createSuccesses
- createFails
- sandboxStartingCount
- version
+ - commit
properties:
version:
type: string
description: Version of the orchestrator
+ commit:
+ type: string
+ description: Commit of the orchestrator
nodeID:
type: string
description: Identifier of the node
+ clusterID:
+ type: string
+ nullable: true
+ description: Identifier of the cluster
status:
$ref: "#/components/schemas/NodeStatus"
sandboxCount:
@@ -569,6 +562,10 @@ components:
type: integer
format: int32
description: Amount of allocated memory in MiB
+ createSuccesses:
+ type: integer
+ format: uint64
+ description: Number of sandbox create successes
createFails:
type: integer
format: uint64
@@ -584,12 +581,21 @@ components:
- status
- sandboxes
- cachedBuilds
+ - createSuccesses
- createFails
- version
+ - commit
properties:
+ clusterID:
+ type: string
+ nullable: true
+ description: Identifier of the cluster
version:
type: string
description: Version of the orchestrator
+ commit:
+ type: string
+ description: Commit of the orchestrator
nodeID:
type: string
description: Identifier of the node
@@ -605,6 +611,10 @@ components:
description: List of cached builds id on the node
items:
type: string
+ createSuccesses:
+ type: integer
+ format: uint64
+ description: Number of sandbox create successes
createFails:
type: integer
format: uint64
@@ -615,7 +625,7 @@ components:
- id
- name
- token
- - tokenMask
+ - mask
- createdAt
properties:
id:
@@ -627,10 +637,9 @@ components:
description: Name of the access token
token:
type: string
- description: Raw value of the access token
- tokenMask:
- type: string
- description: Mask of the access token
+ description: The fully created access token
+ mask:
+ $ref: "#/components/schemas/IdentifierMaskingDetails"
createdAt:
type: string
format: date-time
@@ -648,10 +657,8 @@ components:
required:
- id
- name
- - keyMask
+ - mask
- createdAt
- - createdBy
- - lastUsed
properties:
id:
type: string
@@ -660,9 +667,8 @@ components:
name:
type: string
description: Name of the API key
- keyMask:
- type: string
- description: Mask of the API key
+ mask:
+ $ref: "#/components/schemas/IdentifierMaskingDetails"
createdAt:
type: string
format: date-time
@@ -680,26 +686,23 @@ components:
CreatedTeamAPIKey:
required:
- id
- - name
- key
- - keyMask
+ - mask
+ - name
- createdAt
- - createdBy
- - lastUsed
properties:
id:
type: string
format: uuid
description: Identifier of the API key
- name:
- type: string
- description: Name of the API key
key:
type: string
description: Raw value of the API key
- keyMask:
+ mask:
+ $ref: "#/components/schemas/IdentifierMaskingDetails"
+ name:
type: string
- description: Mask of the API key
+ description: Name of the API key
createdAt:
type: string
format: date-time
@@ -743,6 +746,26 @@ components:
type: string
description: Error
+ IdentifierMaskingDetails:
+ required:
+ - prefix
+ - valueLength
+ - maskedValuePrefix
+ - maskedValueSuffix
+ properties:
+ prefix:
+ type: string
+ description: Prefix that identifies the token or key type
+ valueLength:
+ type: integer
+ description: Length of the token or key
+ maskedValuePrefix:
+ type: string
+ description: Prefix used in masked version of the token or key
+ maskedValueSuffix:
+ type: string
+ description: Suffix used in masked version of the token or key
+
tags:
- name: templates
- name: sandboxes
@@ -900,27 +923,31 @@ paths:
/sandboxes/metrics:
get:
- description: List all running sandboxes with metrics
+ description: List metrics for given sandboxes
tags: [sandboxes]
security:
- ApiKeyAuth: []
+ - Supabase1TokenAuth: []
+ Supabase2TeamAuth: []
parameters:
- - name: metadata
+ - name: sandbox_ids
in: query
- description: Metadata query used to filter the sandboxes (e.g. "user=abc&app=prod"). Each key and values must be URL encoded.
- required: false
+ required: true
+ description: Comma-separated list of sandbox IDs to get metrics for
+ explode: false
schema:
- type: string
+ type: array
+ items:
+ type: string
+ maxItems: 100
+ uniqueItems: true
responses:
"200":
description: Successfully returned all running sandboxes with metrics
content:
application/json:
schema:
- type: array
- items:
- allOf:
- - $ref: "#/components/schemas/RunningSandboxWithMetrics"
+ $ref: "#/components/schemas/SandboxesWithMetrics"
"401":
$ref: "#/components/responses/401"
"400":
@@ -967,9 +994,9 @@ paths:
"500":
$ref: "#/components/responses/500"
- /sandboxes/{sandboxID}/metrics:
+ /sandboxes/{sandboxID}:
get:
- description: Get sandbox metrics
+ description: Get a sandbox by id
tags: [sandboxes]
security:
- ApiKeyAuth: []
@@ -979,13 +1006,11 @@ paths:
- $ref: "#/components/parameters/sandboxID"
responses:
"200":
- description: Successfully returned the sandbox metrics
+ description: Successfully returned the sandbox
content:
application/json:
schema:
- type: array
- items:
- $ref: "#/components/schemas/SandboxMetric"
+ $ref: "#/components/schemas/SandboxDetail"
"404":
$ref: "#/components/responses/404"
"401":
@@ -993,9 +1018,8 @@ paths:
"500":
$ref: "#/components/responses/500"
- /sandboxes/{sandboxID}:
- get:
- description: Get a sandbox by id
+ delete:
+ description: Kill a sandbox
tags: [sandboxes]
security:
- ApiKeyAuth: []
@@ -1004,12 +1028,8 @@ paths:
parameters:
- $ref: "#/components/parameters/sandboxID"
responses:
- "200":
- description: Successfully returned the sandbox
- content:
- application/json:
- schema:
- $ref: "#/components/schemas/SandboxDetail"
+ "204":
+ description: The sandbox was killed successfully
"404":
$ref: "#/components/responses/404"
"401":
@@ -1017,8 +1037,9 @@ paths:
"500":
$ref: "#/components/responses/500"
- delete:
- description: Kill a sandbox
+ /sandboxes/{sandboxID}/metrics:
+ get:
+ description: Get sandbox metrics
tags: [sandboxes]
security:
- ApiKeyAuth: []
@@ -1026,16 +1047,40 @@ paths:
Supabase2TeamAuth: []
parameters:
- $ref: "#/components/parameters/sandboxID"
+ - in: query
+ name: start
+ schema:
+ type: integer
+ format: int64
+ minimum: 0
+ description: Starting timestamp of the metrics that should be returned in milliseconds
+ - in: query
+ name: end
+ schema:
+ type: integer
+ format: int64
+ minimum: 0
+ description: Ending timestamp of the metrics that should be returned in milliseconds
+
responses:
- "204":
- description: The sandbox was killed successfully
- "404":
- $ref: "#/components/responses/404"
+ "200":
+ description: Successfully returned the sandbox metrics
+ content:
+ application/json:
+ schema:
+ type: array
+ items:
+ $ref: "#/components/schemas/SandboxMetric"
+ "400":
+ $ref: "#/components/responses/400"
"401":
$ref: "#/components/responses/401"
+ "404":
+ $ref: "#/components/responses/404"
"500":
$ref: "#/components/responses/500"
+
# TODO: Pause and resume might be exposed as POST /sandboxes/{sandboxID}/snapshot and then POST /sandboxes with specified snapshotting setup
/sandboxes/{sandboxID}/pause:
post: