Skip to content

armgit / E2B

Public Imported from GitHub
0

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

Update spec and templates to use /v3/ endpoint (#1002)

Jakub Novák423d87cf912c
diff --git a/.changeset/dry-countries-clap.md b/.changeset/dry-countries-clap.md
new file mode 100644
index 000000000..8ca31f0ea
--- /dev/null
+++ b/.changeset/dry-countries-clap.md
@@ -0,0 +1,7 @@
+---
+'@e2b/python-sdk': patch
+'e2b': patch
+'@e2b/cli': patch
+---
+
+Update template build to /v3/ endpoint
diff --git a/packages/js-sdk/src/api/schema.gen.ts b/packages/js-sdk/src/api/schema.gen.ts
index 869928258..eda37ca6d 100644
--- a/packages/js-sdk/src/api/schema.gen.ts
+++ b/packages/js-sdk/src/api/schema.gen.ts
@@ -137,6 +137,61 @@ export interface paths {
patch?: never;
trace?: never;
};
+ "/sandboxes/{sandboxID}/connect": {
+ parameters: {
+ query?: never;
+ header?: never;
+ path?: never;
+ cookie?: never;
+ };
+ get?: never;
+ put?: never;
+ /** @description Returns sandbox details. If the sandbox is paused, it will be resumed. TTL is only extended. */
+ post: {
+ parameters: {
+ query?: never;
+ header?: never;
+ path: {
+ sandboxID: components["parameters"]["sandboxID"];
+ };
+ cookie?: never;
+ };
+ requestBody: {
+ content: {
+ "application/json": components["schemas"]["ConnectSandbox"];
+ };
+ };
+ responses: {
+ /** @description The sandbox was already running */
+ 200: {
+ headers: {
+ [name: string]: unknown;
+ };
+ content: {
+ "application/json": components["schemas"]["Sandbox"];
+ };
+ };
+ /** @description The sandbox was resumed successfully */
+ 201: {
+ headers: {
+ [name: string]: unknown;
+ };
+ content: {
+ "application/json": components["schemas"]["Sandbox"];
+ };
+ };
+ 400: components["responses"]["400"];
+ 401: components["responses"]["401"];
+ 404: components["responses"]["404"];
+ 500: components["responses"]["500"];
+ };
+ };
+ delete?: never;
+ options?: never;
+ head?: never;
+ patch?: never;
+ trace?: never;
+ };
"/sandboxes/{sandboxID}/logs": {
parameters: {
query?: never;
@@ -323,7 +378,10 @@ export interface paths {
};
get?: never;
put?: never;
- /** @description Resume the sandbox */
+ /**
+ * @deprecated
+ * @description Resume the sandbox
+ */
post: {
parameters: {
query?: never;
@@ -535,6 +593,54 @@ export interface paths {
patch?: never;
trace?: never;
};
+ "/teams/{teamID}/metrics/max": {
+ parameters: {
+ query?: never;
+ header?: never;
+ path?: never;
+ cookie?: never;
+ };
+ /** @description Get the maximum metrics for the team in the given interval */
+ get: {
+ parameters: {
+ query: {
+ end?: number;
+ /** @description Metric to retrieve the maximum value for */
+ metric: "concurrent_sandboxes" | "sandbox_start_rate";
+ /** @description Unix timestamp for the start of the interval, in seconds, for which the metrics */
+ start?: number;
+ };
+ header?: never;
+ path: {
+ teamID: components["parameters"]["teamID"];
+ };
+ cookie?: never;
+ };
+ requestBody?: never;
+ responses: {
+ /** @description Successfully returned the team metrics */
+ 200: {
+ headers: {
+ [name: string]: unknown;
+ };
+ content: {
+ "application/json": components["schemas"]["MaxTeamMetric"];
+ };
+ };
+ 400: components["responses"]["400"];
+ 401: components["responses"]["401"];
+ 403: components["responses"]["403"];
+ 500: components["responses"]["500"];
+ };
+ };
+ put?: never;
+ post?: never;
+ delete?: never;
+ options?: never;
+ head?: never;
+ patch?: never;
+ trace?: never;
+ };
"/templates": {
parameters: {
query?: never;
@@ -568,7 +674,10 @@ export interface paths {
};
};
put?: never;
- /** @description Create a new template */
+ /**
+ * @deprecated
+ * @description Create a new template
+ */
post: {
parameters: {
query?: never;
@@ -588,7 +697,7 @@ export interface paths {
[name: string]: unknown;
};
content: {
- "application/json": components["schemas"]["Template"];
+ "application/json": components["schemas"]["TemplateLegacy"];
};
};
400: components["responses"]["400"];
@@ -611,7 +720,10 @@ export interface paths {
};
get?: never;
put?: never;
- /** @description Rebuild an template */
+ /**
+ * @deprecated
+ * @description Rebuild an template
+ */
post: {
parameters: {
query?: never;
@@ -633,7 +745,7 @@ export interface paths {
[name: string]: unknown;
};
content: {
- "application/json": components["schemas"]["Template"];
+ "application/json": components["schemas"]["TemplateLegacy"];
};
};
401: components["responses"]["401"];
@@ -704,7 +816,10 @@ export interface paths {
};
get?: never;
put?: never;
- /** @description Start the build */
+ /**
+ * @deprecated
+ * @description Start the build
+ */
post: {
parameters: {
query?: never;
@@ -880,7 +995,10 @@ export interface paths {
};
get?: never;
put?: never;
- /** @description Create a new template */
+ /**
+ * @deprecated
+ * @description Create a new template
+ */
post: {
parameters: {
query?: never;
@@ -900,7 +1018,7 @@ export interface paths {
[name: string]: unknown;
};
content: {
- "application/json": components["schemas"]["Template"];
+ "application/json": components["schemas"]["TemplateLegacy"];
};
};
400: components["responses"]["400"];
@@ -957,6 +1075,49 @@ export interface paths {
patch?: never;
trace?: never;
};
+ "/v3/templates": {
+ parameters: {
+ query?: never;
+ header?: never;
+ path?: never;
+ cookie?: never;
+ };
+ get?: never;
+ put?: never;
+ /** @description Create a new template */
+ post: {
+ parameters: {
+ query?: never;
+ header?: never;
+ path?: never;
+ cookie?: never;
+ };
+ requestBody: {
+ content: {
+ "application/json": components["schemas"]["TemplateBuildRequestV3"];
+ };
+ };
+ responses: {
+ /** @description The build was requested successfully */
+ 202: {
+ headers: {
+ [name: string]: unknown;
+ };
+ content: {
+ "application/json": components["schemas"]["TemplateRequestResponseV3"];
+ };
+ };
+ 400: components["responses"]["400"];
+ 401: components["responses"]["401"];
+ 500: components["responses"]["500"];
+ };
+ };
+ delete?: never;
+ options?: never;
+ head?: never;
+ patch?: never;
+ trace?: never;
+ };
}
export type webhooks = Record<string, never>;
export interface components {
@@ -978,6 +1139,8 @@ export interface components {
level: components["schemas"]["LogLevel"];
/** @description Log message content */
message: string;
+ /** @description Step in the build process related to the log entry */
+ step?: string;
/**
* Format: date-time
* @description Timestamp of the log entry
@@ -985,11 +1148,23 @@ export interface components {
timestamp: string;
};
BuildStatusReason: {
+ /**
+ * @description Log entries related to the status reason
+ * @default []
+ */
+ logEntries: components["schemas"]["BuildLogEntry"][];
/** @description Message with the status reason, currently reporting only for error status */
message: string;
/** @description Step that failed */
step?: string;
};
+ ConnectSandbox: {
+ /**
+ * Format: int32
+ * @description Timeout in seconds from the current time after which the sandbox should expire
+ */
+ timeout: number;
+ };
/**
* Format: int32
* @description CPU cores for the sandbox
@@ -1137,10 +1312,26 @@ export interface components {
* @enum {string}
*/
LogLevel: "debug" | "info" | "warn" | "error";
- /** @description MCP server configuration */
- McpConfig: {
- [key: string]: unknown;
+ /** @description Team metric with timestamp */
+ MaxTeamMetric: {
+ /**
+ * Format: date-time
+ * @deprecated
+ * @description Timestamp of the metric entry
+ */
+ timestamp: string;
+ /**
+ * Format: int64
+ * @description Timestamp of the metric entry in Unix time (seconds since epoch)
+ */
+ timestampUnix: number;
+ /** @description The maximum value of the requested metric in the given interval */
+ value: number;
};
+ /** @description MCP configuration for the sandbox */
+ Mcp: {
+ [key: string]: unknown;
+ } | null;
/**
* Format: int32
* @description Memory for the sandbox in MiB
@@ -1159,7 +1350,7 @@ export interface components {
*/
autoPause: boolean;
envVars?: components["schemas"]["EnvVars"];
- mcp?: components["schemas"]["McpConfig"];
+ mcp?: components["schemas"]["Mcp"];
metadata?: components["schemas"]["SandboxMetadata"];
/** @description Secure all system communication with sandbox */
secure?: boolean;
@@ -1289,6 +1480,11 @@ export interface components {
*/
NodeStatus: "ready" | "draining" | "connecting" | "unhealthy";
NodeStatusChange: {
+ /**
+ * Format: uuid
+ * @description Identifier of the cluster
+ */
+ clusterID?: string;
status: components["schemas"]["NodeStatus"];
};
ResumedSandbox: {
@@ -1426,9 +1622,15 @@ export interface components {
memUsed: number;
/**
* Format: date-time
+ * @deprecated
* @description Timestamp of the metric entry
*/
timestamp: string;
+ /**
+ * Format: int64
+ * @description Timestamp of the metric entry in Unix time (seconds since epoch)
+ */
+ timestampUnix: number;
};
/**
* @description State of the sandbox
@@ -1480,9 +1682,15 @@ export interface components {
sandboxStartRate: number;
/**
* Format: date-time
+ * @deprecated
* @description Timestamp of the metric entry
*/
timestamp: string;
+ /**
+ * Format: int64
+ * @description Timestamp of the metric entry in Unix time (seconds since epoch)
+ */
+ timestampUnix: number;
};
TeamUser: {
/** @description Email of the user */
@@ -1503,6 +1711,7 @@ export interface components {
buildCount: number;
/** @description Identifier of the last successful build for given template */
buildID: string;
+ buildStatus: components["schemas"]["TemplateBuildStatus"];
cpuCount: components["schemas"]["CPUCount"];
/**
* Format: date-time
@@ -1547,11 +1756,7 @@ export interface components {
*/
logs: string[];
reason?: components["schemas"]["BuildStatusReason"];
- /**
- * @description Status of the template
- * @enum {string}
- */
- status: "building" | "waiting" | "ready" | "error";
+ status: components["schemas"]["TemplateBuildStatus"];
/** @description Identifier of the template */
templateID: string;
};
@@ -1583,6 +1788,14 @@ export interface components {
/** @description Identifier of the team */
teamID?: string;
};
+ TemplateBuildRequestV3: {
+ /** @description Alias of the template */
+ alias: string;
+ cpuCount?: components["schemas"]["CPUCount"];
+ memoryMB?: components["schemas"]["MemoryMB"];
+ /** @description Identifier of the team */
+ teamID?: string;
+ };
TemplateBuildStartV2: {
/**
* @description Whether the whole build should be forced to run regardless of the cache
@@ -1604,6 +1817,61 @@ export interface components {
*/
steps: components["schemas"]["TemplateStep"][];
};
+ /**
+ * @description Status of the template build
+ * @enum {string}
+ */
+ TemplateBuildStatus: "building" | "waiting" | "ready" | "error";
+ TemplateLegacy: {
+ /** @description Aliases of the template */
+ aliases: string[];
+ /**
+ * Format: int32
+ * @description Number of times the template was built
+ */
+ buildCount: number;
+ /** @description Identifier of the last successful build for given template */
+ buildID: string;
+ cpuCount: components["schemas"]["CPUCount"];
+ /**
+ * Format: date-time
+ * @description Time when the template was created
+ */
+ createdAt: string;
+ createdBy: components["schemas"]["TeamUser"] | null;
+ diskSizeMB: components["schemas"]["DiskSizeMB"];
+ envdVersion: components["schemas"]["EnvdVersion"];
+ /**
+ * Format: date-time
+ * @description Time when the template was last used
+ */
+ lastSpawnedAt: string | null;
+ memoryMB: components["schemas"]["MemoryMB"];
+ /** @description Whether the template is public or only accessible by the team */
+ public: boolean;
+ /**
+ * Format: int64
+ * @description Number of times the template was used
+ */
+ spawnCount: number;
+ /** @description Identifier of the template */
+ templateID: string;
+ /**
+ * Format: date-time
+ * @description Time when the template was last updated
+ */
+ updatedAt: string;
+ };
+ TemplateRequestResponseV3: {
+ /** @description Aliases of the template */
+ aliases: string[];
+ /** @description Identifier of the last successful build for given template */
+ buildID: string;
+ /** @description Whether the template is public or only accessible by the team */
+ public: boolean;
+ /** @description Identifier of the template */
+ templateID: string;
+ };
/** @description Step in the template build process */
TemplateStep: {
/**
diff --git a/packages/js-sdk/src/template/buildApi.ts b/packages/js-sdk/src/template/buildApi.ts
index 4607a9a76..e3320782f 100644
--- a/packages/js-sdk/src/template/buildApi.ts
+++ b/packages/js-sdk/src/template/buildApi.ts
@@ -37,7 +37,7 @@ export async function requestBuild(
client: ApiClient,
{ alias, cpuCount, memoryMB }: RequestBuildInput
) {
- const requestBuildRes = await client.api.POST('/v2/templates', {
+ const requestBuildRes = await client.api.POST('/v3/templates', {
body: {
alias,
cpuCount,
diff --git a/packages/python-sdk/e2b/api/client/api/sandboxes/post_sandboxes_sandbox_id_connect.py b/packages/python-sdk/e2b/api/client/api/sandboxes/post_sandboxes_sandbox_id_connect.py
new file mode 100644
index 000000000..c3b71fcd4
--- /dev/null
+++ b/packages/python-sdk/e2b/api/client/api/sandboxes/post_sandboxes_sandbox_id_connect.py
@@ -0,0 +1,193 @@
+from http import HTTPStatus
+from typing import Any, Optional, Union
+
+import httpx
+
+from ... import errors
+from ...client import AuthenticatedClient, Client
+from ...models.connect_sandbox import ConnectSandbox
+from ...models.error import Error
+from ...models.sandbox import Sandbox
+from ...types import Response
+
+
+def _get_kwargs(
+ sandbox_id: str,
+ *,
+ body: ConnectSandbox,
+) -> dict[str, Any]:
+ headers: dict[str, Any] = {}
+
+ _kwargs: dict[str, Any] = {
+ "method": "post",
+ "url": f"/sandboxes/{sandbox_id}/connect",
+ }
+
+ _kwargs["json"] = body.to_dict()
+
+ headers["Content-Type"] = "application/json"
+
+ _kwargs["headers"] = headers
+ return _kwargs
+
+
+def _parse_response(
+ *, client: Union[AuthenticatedClient, Client], response: httpx.Response
+) -> Optional[Union[Error, Sandbox]]:
+ if response.status_code == 200:
+ response_200 = Sandbox.from_dict(response.json())
+
+ return response_200
+ if response.status_code == 201:
+ response_201 = Sandbox.from_dict(response.json())
+
+ return response_201
+ 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())
+
+ return response_401
+ if response.status_code == 404:
+ response_404 = Error.from_dict(response.json())
+
+ return response_404
+ if response.status_code == 500:
+ response_500 = Error.from_dict(response.json())
+
+ return response_500
+ if client.raise_on_unexpected_status:
+ raise errors.UnexpectedStatus(response.status_code, response.content)
+ else:
+ return None
+
+
+def _build_response(
+ *, client: Union[AuthenticatedClient, Client], response: httpx.Response
+) -> Response[Union[Error, Sandbox]]:
+ return Response(
+ status_code=HTTPStatus(response.status_code),
+ content=response.content,
+ headers=response.headers,
+ parsed=_parse_response(client=client, response=response),
+ )
+
+
+def sync_detailed(
+ sandbox_id: str,
+ *,
+ client: AuthenticatedClient,
+ body: ConnectSandbox,
+) -> Response[Union[Error, Sandbox]]:
+ """Returns sandbox details. If the sandbox is paused, it will be resumed. TTL is only extended.
+
+ Args:
+ sandbox_id (str):
+ body (ConnectSandbox):
+
+ 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, Sandbox]]
+ """
+
+ kwargs = _get_kwargs(
+ sandbox_id=sandbox_id,
+ body=body,
+ )
+
+ response = client.get_httpx_client().request(
+ **kwargs,
+ )
+
+ return _build_response(client=client, response=response)
+
+
+def sync(
+ sandbox_id: str,
+ *,
+ client: AuthenticatedClient,
+ body: ConnectSandbox,
+) -> Optional[Union[Error, Sandbox]]:
+ """Returns sandbox details. If the sandbox is paused, it will be resumed. TTL is only extended.
+
+ Args:
+ sandbox_id (str):
+ body (ConnectSandbox):
+
+ 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, Sandbox]
+ """
+
+ return sync_detailed(
+ sandbox_id=sandbox_id,
+ client=client,
+ body=body,
+ ).parsed
+
+
+async def asyncio_detailed(
+ sandbox_id: str,
+ *,
+ client: AuthenticatedClient,
+ body: ConnectSandbox,
+) -> Response[Union[Error, Sandbox]]:
+ """Returns sandbox details. If the sandbox is paused, it will be resumed. TTL is only extended.
+
+ Args:
+ sandbox_id (str):
+ body (ConnectSandbox):
+
+ 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, Sandbox]]
+ """
+
+ kwargs = _get_kwargs(
+ sandbox_id=sandbox_id,
+ body=body,
+ )
+
+ response = await client.get_async_httpx_client().request(**kwargs)
+
+ return _build_response(client=client, response=response)
+
+
+async def asyncio(
+ sandbox_id: str,
+ *,
+ client: AuthenticatedClient,
+ body: ConnectSandbox,
+) -> Optional[Union[Error, Sandbox]]:
+ """Returns sandbox details. If the sandbox is paused, it will be resumed. TTL is only extended.
+
+ Args:
+ sandbox_id (str):
+ body (ConnectSandbox):
+
+ 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, Sandbox]
+ """
+
+ return (
+ await asyncio_detailed(
+ sandbox_id=sandbox_id,
+ client=client,
+ body=body,
+ )
+ ).parsed
diff --git a/packages/python-sdk/e2b/api/client/api/templates/post_templates.py b/packages/python-sdk/e2b/api/client/api/templates/post_templates.py
index dfd9d064a..015b0d911 100644
--- a/packages/python-sdk/e2b/api/client/api/templates/post_templates.py
+++ b/packages/python-sdk/e2b/api/client/api/templates/post_templates.py
@@ -6,8 +6,8 @@ import httpx
from ... import errors
from ...client import AuthenticatedClient, Client
from ...models.error import Error
-from ...models.template import Template
from ...models.template_build_request import TemplateBuildRequest
+from ...models.template_legacy import TemplateLegacy
from ...types import Response
@@ -32,9 +32,9 @@ def _get_kwargs(
def _parse_response(
*, client: Union[AuthenticatedClient, Client], response: httpx.Response
-) -> Optional[Union[Error, Template]]:
+) -> Optional[Union[Error, TemplateLegacy]]:
if response.status_code == 202:
- response_202 = Template.from_dict(response.json())
+ response_202 = TemplateLegacy.from_dict(response.json())
return response_202
if response.status_code == 400:
@@ -57,7 +57,7 @@ def _parse_response(
def _build_response(
*, client: Union[AuthenticatedClient, Client], response: httpx.Response
-) -> Response[Union[Error, Template]]:
+) -> Response[Union[Error, TemplateLegacy]]:
return Response(
status_code=HTTPStatus(response.status_code),
content=response.content,
@@ -70,7 +70,7 @@ def sync_detailed(
*,
client: AuthenticatedClient,
body: TemplateBuildRequest,
-) -> Response[Union[Error, Template]]:
+) -> Response[Union[Error, TemplateLegacy]]:
"""Create a new template
Args:
@@ -81,7 +81,7 @@ def sync_detailed(
httpx.TimeoutException: If the request takes longer than Client.timeout.
Returns:
- Response[Union[Error, Template]]
+ Response[Union[Error, TemplateLegacy]]
"""
kwargs = _get_kwargs(
@@ -99,7 +99,7 @@ def sync(
*,
client: AuthenticatedClient,
body: TemplateBuildRequest,
-) -> Optional[Union[Error, Template]]:
+) -> Optional[Union[Error, TemplateLegacy]]:
"""Create a new template
Args:
@@ -110,7 +110,7 @@ def sync(
httpx.TimeoutException: If the request takes longer than Client.timeout.
Returns:
- Union[Error, Template]
+ Union[Error, TemplateLegacy]
"""
return sync_detailed(
@@ -123,7 +123,7 @@ async def asyncio_detailed(
*,
client: AuthenticatedClient,
body: TemplateBuildRequest,
-) -> Response[Union[Error, Template]]:
+) -> Response[Union[Error, TemplateLegacy]]:
"""Create a new template
Args:
@@ -134,7 +134,7 @@ async def asyncio_detailed(
httpx.TimeoutException: If the request takes longer than Client.timeout.
Returns:
- Response[Union[Error, Template]]
+ Response[Union[Error, TemplateLegacy]]
"""
kwargs = _get_kwargs(
@@ -150,7 +150,7 @@ async def asyncio(
*,
client: AuthenticatedClient,
body: TemplateBuildRequest,
-) -> Optional[Union[Error, Template]]:
+) -> Optional[Union[Error, TemplateLegacy]]:
"""Create a new template
Args:
@@ -161,7 +161,7 @@ async def asyncio(
httpx.TimeoutException: If the request takes longer than Client.timeout.
Returns:
- Union[Error, Template]
+ Union[Error, TemplateLegacy]
"""
return (
diff --git a/packages/python-sdk/e2b/api/client/api/templates/post_templates_template_id.py b/packages/python-sdk/e2b/api/client/api/templates/post_templates_template_id.py
index a478bb836..986a3b51f 100644
--- a/packages/python-sdk/e2b/api/client/api/templates/post_templates_template_id.py
+++ b/packages/python-sdk/e2b/api/client/api/templates/post_templates_template_id.py
@@ -6,8 +6,8 @@ import httpx
from ... import errors
from ...client import AuthenticatedClient, Client
from ...models.error import Error
-from ...models.template import Template
from ...models.template_build_request import TemplateBuildRequest
+from ...models.template_legacy import TemplateLegacy
from ...types import Response
@@ -33,9 +33,9 @@ def _get_kwargs(
def _parse_response(
*, client: Union[AuthenticatedClient, Client], response: httpx.Response
-) -> Optional[Union[Error, Template]]:
+) -> Optional[Union[Error, TemplateLegacy]]:
if response.status_code == 202:
- response_202 = Template.from_dict(response.json())
+ response_202 = TemplateLegacy.from_dict(response.json())
return response_202
if response.status_code == 401:
@@ -54,7 +54,7 @@ def _parse_response(
def _build_response(
*, client: Union[AuthenticatedClient, Client], response: httpx.Response
-) -> Response[Union[Error, Template]]:
+) -> Response[Union[Error, TemplateLegacy]]:
return Response(
status_code=HTTPStatus(response.status_code),
content=response.content,
@@ -68,7 +68,7 @@ def sync_detailed(
*,
client: AuthenticatedClient,
body: TemplateBuildRequest,
-) -> Response[Union[Error, Template]]:
+) -> Response[Union[Error, TemplateLegacy]]:
"""Rebuild an template
Args:
@@ -80,7 +80,7 @@ def sync_detailed(
httpx.TimeoutException: If the request takes longer than Client.timeout.
Returns:
- Response[Union[Error, Template]]
+ Response[Union[Error, TemplateLegacy]]
"""
kwargs = _get_kwargs(
@@ -100,7 +100,7 @@ def sync(
*,
client: AuthenticatedClient,
body: TemplateBuildRequest,
-) -> Optional[Union[Error, Template]]:
+) -> Optional[Union[Error, TemplateLegacy]]:
"""Rebuild an template
Args:
@@ -112,7 +112,7 @@ def sync(
httpx.TimeoutException: If the request takes longer than Client.timeout.
Returns:
- Union[Error, Template]
+ Union[Error, TemplateLegacy]
"""
return sync_detailed(
@@ -127,7 +127,7 @@ async def asyncio_detailed(
*,
client: AuthenticatedClient,
body: TemplateBuildRequest,
-) -> Response[Union[Error, Template]]:
+) -> Response[Union[Error, TemplateLegacy]]:
"""Rebuild an template
Args:
@@ -139,7 +139,7 @@ async def asyncio_detailed(
httpx.TimeoutException: If the request takes longer than Client.timeout.
Returns:
- Response[Union[Error, Template]]
+ Response[Union[Error, TemplateLegacy]]
"""
kwargs = _get_kwargs(
@@ -157,7 +157,7 @@ async def asyncio(
*,
client: AuthenticatedClient,
body: TemplateBuildRequest,
-) -> Optional[Union[Error, Template]]:
+) -> Optional[Union[Error, TemplateLegacy]]:
"""Rebuild an template
Args:
@@ -169,7 +169,7 @@ async def asyncio(
httpx.TimeoutException: If the request takes longer than Client.timeout.
Returns:
- Union[Error, Template]
+ Union[Error, TemplateLegacy]
"""
return (
diff --git a/packages/python-sdk/e2b/api/client/api/templates/post_v2_templates.py b/packages/python-sdk/e2b/api/client/api/templates/post_v2_templates.py
index 1a261efd0..86b5ebeb0 100644
--- a/packages/python-sdk/e2b/api/client/api/templates/post_v2_templates.py
+++ b/packages/python-sdk/e2b/api/client/api/templates/post_v2_templates.py
@@ -6,8 +6,8 @@ import httpx
from ... import errors
from ...client import AuthenticatedClient, Client
from ...models.error import Error
-from ...models.template import Template
from ...models.template_build_request_v2 import TemplateBuildRequestV2
+from ...models.template_legacy import TemplateLegacy
from ...types import Response
@@ -32,9 +32,9 @@ def _get_kwargs(
def _parse_response(
*, client: Union[AuthenticatedClient, Client], response: httpx.Response
-) -> Optional[Union[Error, Template]]:
+) -> Optional[Union[Error, TemplateLegacy]]:
if response.status_code == 202:
- response_202 = Template.from_dict(response.json())
+ response_202 = TemplateLegacy.from_dict(response.json())
return response_202
if response.status_code == 400:
@@ -57,7 +57,7 @@ def _parse_response(
def _build_response(
*, client: Union[AuthenticatedClient, Client], response: httpx.Response
-) -> Response[Union[Error, Template]]:
+) -> Response[Union[Error, TemplateLegacy]]:
return Response(
status_code=HTTPStatus(response.status_code),
content=response.content,
@@ -70,7 +70,7 @@ def sync_detailed(
*,
client: AuthenticatedClient,
body: TemplateBuildRequestV2,
-) -> Response[Union[Error, Template]]:
+) -> Response[Union[Error, TemplateLegacy]]:
"""Create a new template
Args:
@@ -81,7 +81,7 @@ def sync_detailed(
httpx.TimeoutException: If the request takes longer than Client.timeout.
Returns:
- Response[Union[Error, Template]]
+ Response[Union[Error, TemplateLegacy]]
"""
kwargs = _get_kwargs(
@@ -99,7 +99,7 @@ def sync(
*,
client: AuthenticatedClient,
body: TemplateBuildRequestV2,
-) -> Optional[Union[Error, Template]]:
+) -> Optional[Union[Error, TemplateLegacy]]:
"""Create a new template
Args:
@@ -110,7 +110,7 @@ def sync(
httpx.TimeoutException: If the request takes longer than Client.timeout.
Returns:
- Union[Error, Template]
+ Union[Error, TemplateLegacy]
"""
return sync_detailed(
@@ -123,7 +123,7 @@ async def asyncio_detailed(
*,
client: AuthenticatedClient,
body: TemplateBuildRequestV2,
-) -> Response[Union[Error, Template]]:
+) -> Response[Union[Error, TemplateLegacy]]:
"""Create a new template
Args:
@@ -134,7 +134,7 @@ async def asyncio_detailed(
httpx.TimeoutException: If the request takes longer than Client.timeout.
Returns:
- Response[Union[Error, Template]]
+ Response[Union[Error, TemplateLegacy]]
"""
kwargs = _get_kwargs(
@@ -150,7 +150,7 @@ async def asyncio(
*,
client: AuthenticatedClient,
body: TemplateBuildRequestV2,
-) -> Optional[Union[Error, Template]]:
+) -> Optional[Union[Error, TemplateLegacy]]:
"""Create a new template
Args:
@@ -161,7 +161,7 @@ async def asyncio(
httpx.TimeoutException: If the request takes longer than Client.timeout.
Returns:
- Union[Error, Template]
+ Union[Error, TemplateLegacy]
"""
return (
diff --git a/packages/python-sdk/e2b/api/client/api/templates/post_v3_templates.py b/packages/python-sdk/e2b/api/client/api/templates/post_v3_templates.py
new file mode 100644
index 000000000..4a39ba3f2
--- /dev/null
+++ b/packages/python-sdk/e2b/api/client/api/templates/post_v3_templates.py
@@ -0,0 +1,172 @@
+from http import HTTPStatus
+from typing import Any, Optional, Union
+
+import httpx
+
+from ... import errors
+from ...client import AuthenticatedClient, Client
+from ...models.error import Error
+from ...models.template_build_request_v3 import TemplateBuildRequestV3
+from ...models.template_request_response_v3 import TemplateRequestResponseV3
+from ...types import Response
+
+
+def _get_kwargs(
+ *,
+ body: TemplateBuildRequestV3,
+) -> dict[str, Any]:
+ headers: dict[str, Any] = {}
+
+ _kwargs: dict[str, Any] = {
+ "method": "post",
+ "url": "/v3/templates",
+ }
+
+ _kwargs["json"] = body.to_dict()
+
+ headers["Content-Type"] = "application/json"
+
+ _kwargs["headers"] = headers
+ return _kwargs
+
+
+def _parse_response(
+ *, client: Union[AuthenticatedClient, Client], response: httpx.Response
+) -> Optional[Union[Error, TemplateRequestResponseV3]]:
+ if response.status_code == 202:
+ response_202 = TemplateRequestResponseV3.from_dict(response.json())
+
+ return response_202
+ 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())
+
+ return response_401
+ if response.status_code == 500:
+ response_500 = Error.from_dict(response.json())
+
+ return response_500
+ if client.raise_on_unexpected_status:
+ raise errors.UnexpectedStatus(response.status_code, response.content)
+ else:
+ return None
+
+
+def _build_response(
+ *, client: Union[AuthenticatedClient, Client], response: httpx.Response
+) -> Response[Union[Error, TemplateRequestResponseV3]]:
+ return Response(
+ status_code=HTTPStatus(response.status_code),
+ content=response.content,
+ headers=response.headers,
+ parsed=_parse_response(client=client, response=response),
+ )
+
+
+def sync_detailed(
+ *,
+ client: AuthenticatedClient,
+ body: TemplateBuildRequestV3,
+) -> Response[Union[Error, TemplateRequestResponseV3]]:
+ """Create a new template
+
+ Args:
+ body (TemplateBuildRequestV3):
+
+ 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, TemplateRequestResponseV3]]
+ """
+
+ kwargs = _get_kwargs(
+ body=body,
+ )
+
+ response = client.get_httpx_client().request(
+ **kwargs,
+ )
+
+ return _build_response(client=client, response=response)
+
+
+def sync(
+ *,
+ client: AuthenticatedClient,
+ body: TemplateBuildRequestV3,
+) -> Optional[Union[Error, TemplateRequestResponseV3]]:
+ """Create a new template
+
+ Args:
+ body (TemplateBuildRequestV3):
+
+ 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, TemplateRequestResponseV3]
+ """
+
+ return sync_detailed(
+ client=client,
+ body=body,
+ ).parsed
+
+
+async def asyncio_detailed(
+ *,
+ client: AuthenticatedClient,
+ body: TemplateBuildRequestV3,
+) -> Response[Union[Error, TemplateRequestResponseV3]]:
+ """Create a new template
+
+ Args:
+ body (TemplateBuildRequestV3):
+
+ 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, TemplateRequestResponseV3]]
+ """
+
+ kwargs = _get_kwargs(
+ body=body,
+ )
+
+ response = await client.get_async_httpx_client().request(**kwargs)
+
+ return _build_response(client=client, response=response)
+
+
+async def asyncio(
+ *,
+ client: AuthenticatedClient,
+ body: TemplateBuildRequestV3,
+) -> Optional[Union[Error, TemplateRequestResponseV3]]:
+ """Create a new template
+
+ Args:
+ body (TemplateBuildRequestV3):
+
+ 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, TemplateRequestResponseV3]
+ """
+
+ return (
+ await asyncio_detailed(
+ client=client,
+ body=body,
+ )
+ ).parsed
diff --git a/packages/python-sdk/e2b/api/client/models/__init__.py b/packages/python-sdk/e2b/api/client/models/__init__.py
index b7299ce2f..9fb84bf08 100644
--- a/packages/python-sdk/e2b/api/client/models/__init__.py
+++ b/packages/python-sdk/e2b/api/client/models/__init__.py
@@ -4,6 +4,7 @@ from .aws_registry import AWSRegistry
from .aws_registry_type import AWSRegistryType
from .build_log_entry import BuildLogEntry
from .build_status_reason import BuildStatusReason
+from .connect_sandbox import ConnectSandbox
from .created_access_token import CreatedAccessToken
from .created_team_api_key import CreatedTeamAPIKey
from .disk_metrics import DiskMetrics
@@ -15,6 +16,8 @@ from .general_registry_type import GeneralRegistryType
from .identifier_masking_details import IdentifierMaskingDetails
from .listed_sandbox import ListedSandbox
from .log_level import LogLevel
+from .max_team_metric import MaxTeamMetric
+from .mcp_type_0 import McpType0
from .new_access_token import NewAccessToken
from .new_sandbox import NewSandbox
from .new_team_api_key import NewTeamAPIKey
@@ -46,8 +49,11 @@ from .template_build import TemplateBuild
from .template_build_file_upload import TemplateBuildFileUpload
from .template_build_request import TemplateBuildRequest
from .template_build_request_v2 import TemplateBuildRequestV2
+from .template_build_request_v3 import TemplateBuildRequestV3
from .template_build_start_v2 import TemplateBuildStartV2
from .template_build_status import TemplateBuildStatus
+from .template_legacy import TemplateLegacy
+from .template_request_response_v3 import TemplateRequestResponseV3
from .template_step import TemplateStep
from .template_update_request import TemplateUpdateRequest
from .update_team_api_key import UpdateTeamAPIKey
@@ -57,6 +63,7 @@ __all__ = (
"AWSRegistryType",
"BuildLogEntry",
"BuildStatusReason",
+ "ConnectSandbox",
"CreatedAccessToken",
"CreatedTeamAPIKey",
"DiskMetrics",
@@ -68,6 +75,8 @@ __all__ = (
"IdentifierMaskingDetails",
"ListedSandbox",
"LogLevel",
+ "MaxTeamMetric",
+ "McpType0",
"NewAccessToken",
"NewSandbox",
"NewTeamAPIKey",
@@ -97,8 +106,11 @@ __all__ = (
"TemplateBuildFileUpload",
"TemplateBuildRequest",
"TemplateBuildRequestV2",
+ "TemplateBuildRequestV3",
"TemplateBuildStartV2",
"TemplateBuildStatus",
+ "TemplateLegacy",
+ "TemplateRequestResponseV3",
"TemplateStep",
"TemplateUpdateRequest",
"UpdateTeamAPIKey",
diff --git a/packages/python-sdk/e2b/api/client/models/build_log_entry.py b/packages/python-sdk/e2b/api/client/models/build_log_entry.py
index 7d352ea12..35cae954f 100644
--- a/packages/python-sdk/e2b/api/client/models/build_log_entry.py
+++ b/packages/python-sdk/e2b/api/client/models/build_log_entry.py
@@ -1,12 +1,13 @@
import datetime
from collections.abc import Mapping
-from typing import Any, TypeVar
+from typing import Any, TypeVar, Union
from attrs import define as _attrs_define
from attrs import field as _attrs_field
from dateutil.parser import isoparse
from ..models.log_level import LogLevel
+from ..types import UNSET, Unset
T = TypeVar("T", bound="BuildLogEntry")
@@ -18,11 +19,13 @@ class BuildLogEntry:
level (LogLevel): State of the sandbox
message (str): Log message content
timestamp (datetime.datetime): Timestamp of the log entry
+ step (Union[Unset, str]): Step in the build process related to the log entry
"""
level: LogLevel
message: str
timestamp: datetime.datetime
+ step: Union[Unset, str] = UNSET
additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict)
def to_dict(self) -> dict[str, Any]:
@@ -32,6 +35,8 @@ class BuildLogEntry:
timestamp = self.timestamp.isoformat()
+ step = self.step
+
field_dict: dict[str, Any] = {}
field_dict.update(self.additional_properties)
field_dict.update(
@@ -41,6 +46,8 @@ class BuildLogEntry:
"timestamp": timestamp,
}
)
+ if step is not UNSET:
+ field_dict["step"] = step
return field_dict
@@ -53,10 +60,13 @@ class BuildLogEntry:
timestamp = isoparse(d.pop("timestamp"))
+ step = d.pop("step", UNSET)
+
build_log_entry = cls(
level=level,
message=message,
timestamp=timestamp,
+ step=step,
)
build_log_entry.additional_properties = d
diff --git a/packages/python-sdk/e2b/api/client/models/build_status_reason.py b/packages/python-sdk/e2b/api/client/models/build_status_reason.py
index 387d95976..e2af40317 100644
--- a/packages/python-sdk/e2b/api/client/models/build_status_reason.py
+++ b/packages/python-sdk/e2b/api/client/models/build_status_reason.py
@@ -1,11 +1,15 @@
from collections.abc import Mapping
-from typing import Any, TypeVar, Union
+from typing import TYPE_CHECKING, Any, TypeVar, Union
from attrs import define as _attrs_define
from attrs import field as _attrs_field
from ..types import UNSET, Unset
+if TYPE_CHECKING:
+ from ..models.build_log_entry import BuildLogEntry
+
+
T = TypeVar("T", bound="BuildStatusReason")
@@ -14,16 +18,25 @@ class BuildStatusReason:
"""
Attributes:
message (str): Message with the status reason, currently reporting only for error status
+ log_entries (Union[Unset, list['BuildLogEntry']]): Log entries related to the status reason
step (Union[Unset, str]): Step that failed
"""
message: str
+ log_entries: Union[Unset, list["BuildLogEntry"]] = UNSET
step: Union[Unset, str] = UNSET
additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict)
def to_dict(self) -> dict[str, Any]:
message = self.message
+ log_entries: Union[Unset, list[dict[str, Any]]] = UNSET
+ if not isinstance(self.log_entries, Unset):
+ log_entries = []
+ for log_entries_item_data in self.log_entries:
+ log_entries_item = log_entries_item_data.to_dict()
+ log_entries.append(log_entries_item)
+
step = self.step
field_dict: dict[str, Any] = {}
@@ -33,6 +46,8 @@ class BuildStatusReason:
"message": message,
}
)
+ if log_entries is not UNSET:
+ field_dict["logEntries"] = log_entries
if step is not UNSET:
field_dict["step"] = step
@@ -40,13 +55,23 @@ class BuildStatusReason:
@classmethod
def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T:
+ from ..models.build_log_entry import BuildLogEntry
+
d = dict(src_dict)
message = d.pop("message")
+ log_entries = []
+ _log_entries = d.pop("logEntries", UNSET)
+ for log_entries_item_data in _log_entries or []:
+ log_entries_item = BuildLogEntry.from_dict(log_entries_item_data)
+
+ log_entries.append(log_entries_item)
+
step = d.pop("step", UNSET)
build_status_reason = cls(
message=message,
+ log_entries=log_entries,
step=step,
)
diff --git a/packages/python-sdk/e2b/api/client/models/connect_sandbox.py b/packages/python-sdk/e2b/api/client/models/connect_sandbox.py
new file mode 100644
index 000000000..de7a8f8c1
--- /dev/null
+++ b/packages/python-sdk/e2b/api/client/models/connect_sandbox.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="ConnectSandbox")
+
+
+@_attrs_define
+class ConnectSandbox:
+ """
+ Attributes:
+ timeout (int): Timeout in seconds from the current time after which the sandbox should expire
+ """
+
+ timeout: int
+ additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict)
+
+ def to_dict(self) -> dict[str, Any]:
+ timeout = self.timeout
+
+ field_dict: dict[str, Any] = {}
+ field_dict.update(self.additional_properties)
+ field_dict.update(
+ {
+ "timeout": timeout,
+ }
+ )
+
+ return field_dict
+
+ @classmethod
+ def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T:
+ d = dict(src_dict)
+ timeout = d.pop("timeout")
+
+ connect_sandbox = cls(
+ timeout=timeout,
+ )
+
+ connect_sandbox.additional_properties = d
+ return connect_sandbox
+
+ @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/max_team_metric.py b/packages/python-sdk/e2b/api/client/models/max_team_metric.py
new file mode 100644
index 000000000..4a9c3e526
--- /dev/null
+++ b/packages/python-sdk/e2b/api/client/models/max_team_metric.py
@@ -0,0 +1,78 @@
+import datetime
+from collections.abc import Mapping
+from typing import Any, TypeVar
+
+from attrs import define as _attrs_define
+from attrs import field as _attrs_field
+from dateutil.parser import isoparse
+
+T = TypeVar("T", bound="MaxTeamMetric")
+
+
+@_attrs_define
+class MaxTeamMetric:
+ """Team metric with timestamp
+
+ Attributes:
+ timestamp (datetime.datetime): Timestamp of the metric entry
+ timestamp_unix (int): Timestamp of the metric entry in Unix time (seconds since epoch)
+ value (float): The maximum value of the requested metric in the given interval
+ """
+
+ timestamp: datetime.datetime
+ timestamp_unix: int
+ value: float
+ additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict)
+
+ def to_dict(self) -> dict[str, Any]:
+ timestamp = self.timestamp.isoformat()
+
+ timestamp_unix = self.timestamp_unix
+
+ value = self.value
+
+ field_dict: dict[str, Any] = {}
+ field_dict.update(self.additional_properties)
+ field_dict.update(
+ {
+ "timestamp": timestamp,
+ "timestampUnix": timestamp_unix,
+ "value": value,
+ }
+ )
+
+ return field_dict
+
+ @classmethod
+ def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T:
+ d = dict(src_dict)
+ timestamp = isoparse(d.pop("timestamp"))
+
+ timestamp_unix = d.pop("timestampUnix")
+
+ value = d.pop("value")
+
+ max_team_metric = cls(
+ timestamp=timestamp,
+ timestamp_unix=timestamp_unix,
+ value=value,
+ )
+
+ max_team_metric.additional_properties = d
+ return max_team_metric
+
+ @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/mcp_type_0.py b/packages/python-sdk/e2b/api/client/models/mcp_type_0.py
new file mode 100644
index 000000000..a58d6ea24
--- /dev/null
+++ b/packages/python-sdk/e2b/api/client/models/mcp_type_0.py
@@ -0,0 +1,44 @@
+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="McpType0")
+
+
+@_attrs_define
+class McpType0:
+ """MCP configuration for the sandbox"""
+
+ additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict)
+
+ def to_dict(self) -> dict[str, Any]:
+ field_dict: dict[str, Any] = {}
+ field_dict.update(self.additional_properties)
+
+ return field_dict
+
+ @classmethod
+ def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T:
+ d = dict(src_dict)
+ mcp_type_0 = cls()
+
+ mcp_type_0.additional_properties = d
+ return mcp_type_0
+
+ @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/new_sandbox.py b/packages/python-sdk/e2b/api/client/models/new_sandbox.py
index 0665c9818..6044fe881 100644
--- a/packages/python-sdk/e2b/api/client/models/new_sandbox.py
+++ b/packages/python-sdk/e2b/api/client/models/new_sandbox.py
@@ -1,11 +1,15 @@
from collections.abc import Mapping
-from typing import Any, TypeVar, Union
+from typing import TYPE_CHECKING, Any, TypeVar, Union, cast
from attrs import define as _attrs_define
from attrs import field as _attrs_field
from ..types import UNSET, Unset
+if TYPE_CHECKING:
+ from ..models.mcp_type_0 import McpType0
+
+
T = TypeVar("T", bound="NewSandbox")
@@ -17,7 +21,7 @@ class NewSandbox:
allow_internet_access (Union[Unset, bool]): Allow sandbox to access the internet
auto_pause (Union[Unset, bool]): Automatically pauses the sandbox after the timeout Default: False.
env_vars (Union[Unset, Any]):
- mcp (Union[Unset, Any]): MCP server configuration
+ mcp (Union['McpType0', None, Unset]): MCP configuration for the sandbox
metadata (Union[Unset, Any]):
secure (Union[Unset, bool]): Secure all system communication with sandbox
timeout (Union[Unset, int]): Time to live for the sandbox in seconds. Default: 15.
@@ -27,13 +31,15 @@ class NewSandbox:
allow_internet_access: Union[Unset, bool] = UNSET
auto_pause: Union[Unset, bool] = False
env_vars: Union[Unset, Any] = UNSET
- mcp: Union[Unset, Any] = UNSET
+ mcp: Union["McpType0", None, Unset] = UNSET
metadata: Union[Unset, Any] = UNSET
secure: Union[Unset, bool] = UNSET
timeout: Union[Unset, int] = 15
additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict)
def to_dict(self) -> dict[str, Any]:
+ from ..models.mcp_type_0 import McpType0
+
template_id = self.template_id
allow_internet_access = self.allow_internet_access
@@ -42,7 +48,13 @@ class NewSandbox:
env_vars = self.env_vars
- mcp = self.mcp
+ mcp: Union[None, Unset, dict[str, Any]]
+ if isinstance(self.mcp, Unset):
+ mcp = UNSET
+ elif isinstance(self.mcp, McpType0):
+ mcp = self.mcp.to_dict()
+ else:
+ mcp = self.mcp
metadata = self.metadata
@@ -76,6 +88,8 @@ class NewSandbox:
@classmethod
def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T:
+ from ..models.mcp_type_0 import McpType0
+
d = dict(src_dict)
template_id = d.pop("templateID")
@@ -85,7 +99,22 @@ class NewSandbox:
env_vars = d.pop("envVars", UNSET)
- mcp = d.pop("mcp", UNSET)
+ def _parse_mcp(data: object) -> Union["McpType0", None, Unset]:
+ if data is None:
+ return data
+ if isinstance(data, Unset):
+ return data
+ try:
+ if not isinstance(data, dict):
+ raise TypeError()
+ componentsschemas_mcp_type_0 = McpType0.from_dict(data)
+
+ return componentsschemas_mcp_type_0
+ except: # noqa: E722
+ pass
+ return cast(Union["McpType0", None, Unset], data)
+
+ mcp = _parse_mcp(d.pop("mcp", UNSET))
metadata = d.pop("metadata", UNSET)
diff --git a/packages/python-sdk/e2b/api/client/models/node_status_change.py b/packages/python-sdk/e2b/api/client/models/node_status_change.py
index 35ec53584..b628e429c 100644
--- a/packages/python-sdk/e2b/api/client/models/node_status_change.py
+++ b/packages/python-sdk/e2b/api/client/models/node_status_change.py
@@ -1,10 +1,12 @@
from collections.abc import Mapping
-from typing import Any, TypeVar
+from typing import Any, TypeVar, Union
+from uuid import UUID
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="NodeStatusChange")
@@ -14,14 +16,20 @@ class NodeStatusChange:
"""
Attributes:
status (NodeStatus): Status of the node
+ cluster_id (Union[Unset, UUID]): Identifier of the cluster
"""
status: NodeStatus
+ cluster_id: Union[Unset, UUID] = UNSET
additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict)
def to_dict(self) -> dict[str, Any]:
status = self.status.value
+ cluster_id: Union[Unset, str] = UNSET
+ if not isinstance(self.cluster_id, Unset):
+ cluster_id = str(self.cluster_id)
+
field_dict: dict[str, Any] = {}
field_dict.update(self.additional_properties)
field_dict.update(
@@ -29,6 +37,8 @@ class NodeStatusChange:
"status": status,
}
)
+ if cluster_id is not UNSET:
+ field_dict["clusterID"] = cluster_id
return field_dict
@@ -37,8 +47,16 @@ class NodeStatusChange:
d = dict(src_dict)
status = NodeStatus(d.pop("status"))
+ _cluster_id = d.pop("clusterID", UNSET)
+ cluster_id: Union[Unset, UUID]
+ if isinstance(_cluster_id, Unset):
+ cluster_id = UNSET
+ else:
+ cluster_id = UUID(_cluster_id)
+
node_status_change = cls(
status=status,
+ cluster_id=cluster_id,
)
node_status_change.additional_properties = d
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 ed0f637f8..eb7442fd9 100644
--- a/packages/python-sdk/e2b/api/client/models/sandbox_metric.py
+++ b/packages/python-sdk/e2b/api/client/models/sandbox_metric.py
@@ -21,6 +21,7 @@ class SandboxMetric:
mem_total (int): Total memory in bytes
mem_used (int): Memory used in bytes
timestamp (datetime.datetime): Timestamp of the metric entry
+ timestamp_unix (int): Timestamp of the metric entry in Unix time (seconds since epoch)
"""
cpu_count: int
@@ -30,6 +31,7 @@ class SandboxMetric:
mem_total: int
mem_used: int
timestamp: datetime.datetime
+ timestamp_unix: int
additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict)
def to_dict(self) -> dict[str, Any]:
@@ -47,6 +49,8 @@ class SandboxMetric:
timestamp = self.timestamp.isoformat()
+ timestamp_unix = self.timestamp_unix
+
field_dict: dict[str, Any] = {}
field_dict.update(self.additional_properties)
field_dict.update(
@@ -58,6 +62,7 @@ class SandboxMetric:
"memTotal": mem_total,
"memUsed": mem_used,
"timestamp": timestamp,
+ "timestampUnix": timestamp_unix,
}
)
@@ -80,6 +85,8 @@ class SandboxMetric:
timestamp = isoparse(d.pop("timestamp"))
+ timestamp_unix = d.pop("timestampUnix")
+
sandbox_metric = cls(
cpu_count=cpu_count,
cpu_used_pct=cpu_used_pct,
@@ -88,6 +95,7 @@ class SandboxMetric:
mem_total=mem_total,
mem_used=mem_used,
timestamp=timestamp,
+ timestamp_unix=timestamp_unix,
)
sandbox_metric.additional_properties = d
diff --git a/packages/python-sdk/e2b/api/client/models/team_metric.py b/packages/python-sdk/e2b/api/client/models/team_metric.py
index bba00ff72..97d30d751 100644
--- a/packages/python-sdk/e2b/api/client/models/team_metric.py
+++ b/packages/python-sdk/e2b/api/client/models/team_metric.py
@@ -17,11 +17,13 @@ class TeamMetric:
concurrent_sandboxes (int): The number of concurrent sandboxes for the team
sandbox_start_rate (float): Number of sandboxes started per second
timestamp (datetime.datetime): Timestamp of the metric entry
+ timestamp_unix (int): Timestamp of the metric entry in Unix time (seconds since epoch)
"""
concurrent_sandboxes: int
sandbox_start_rate: float
timestamp: datetime.datetime
+ timestamp_unix: int
additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict)
def to_dict(self) -> dict[str, Any]:
@@ -31,6 +33,8 @@ class TeamMetric:
timestamp = self.timestamp.isoformat()
+ timestamp_unix = self.timestamp_unix
+
field_dict: dict[str, Any] = {}
field_dict.update(self.additional_properties)
field_dict.update(
@@ -38,6 +42,7 @@ class TeamMetric:
"concurrentSandboxes": concurrent_sandboxes,
"sandboxStartRate": sandbox_start_rate,
"timestamp": timestamp,
+ "timestampUnix": timestamp_unix,
}
)
@@ -52,10 +57,13 @@ class TeamMetric:
timestamp = isoparse(d.pop("timestamp"))
+ timestamp_unix = d.pop("timestampUnix")
+
team_metric = cls(
concurrent_sandboxes=concurrent_sandboxes,
sandbox_start_rate=sandbox_start_rate,
timestamp=timestamp,
+ timestamp_unix=timestamp_unix,
)
team_metric.additional_properties = d
diff --git a/packages/python-sdk/e2b/api/client/models/template.py b/packages/python-sdk/e2b/api/client/models/template.py
index a3a4bfdc4..f29b16f97 100644
--- a/packages/python-sdk/e2b/api/client/models/template.py
+++ b/packages/python-sdk/e2b/api/client/models/template.py
@@ -6,6 +6,8 @@ from attrs import define as _attrs_define
from attrs import field as _attrs_field
from dateutil.parser import isoparse
+from ..models.template_build_status import TemplateBuildStatus
+
if TYPE_CHECKING:
from ..models.team_user import TeamUser
@@ -20,6 +22,7 @@ class Template:
aliases (list[str]): Aliases of the template
build_count (int): Number of times the template was built
build_id (str): Identifier of the last successful build for given template
+ build_status (TemplateBuildStatus): Status of the template build
cpu_count (int): CPU cores for the sandbox
created_at (datetime.datetime): Time when the template was created
created_by (Union['TeamUser', None]):
@@ -36,6 +39,7 @@ class Template:
aliases: list[str]
build_count: int
build_id: str
+ build_status: TemplateBuildStatus
cpu_count: int
created_at: datetime.datetime
created_by: Union["TeamUser", None]
@@ -58,6 +62,8 @@ class Template:
build_id = self.build_id
+ build_status = self.build_status.value
+
cpu_count = self.cpu_count
created_at = self.created_at.isoformat()
@@ -95,6 +101,7 @@ class Template:
"aliases": aliases,
"buildCount": build_count,
"buildID": build_id,
+ "buildStatus": build_status,
"cpuCount": cpu_count,
"createdAt": created_at,
"createdBy": created_by,
@@ -122,6 +129,8 @@ class Template:
build_id = d.pop("buildID")
+ build_status = TemplateBuildStatus(d.pop("buildStatus"))
+
cpu_count = d.pop("cpuCount")
created_at = isoparse(d.pop("createdAt"))
@@ -174,6 +183,7 @@ class Template:
aliases=aliases,
build_count=build_count,
build_id=build_id,
+ build_status=build_status,
cpu_count=cpu_count,
created_at=created_at,
created_by=created_by,
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 7c49554e1..157dea55d 100644
--- a/packages/python-sdk/e2b/api/client/models/template_build.py
+++ b/packages/python-sdk/e2b/api/client/models/template_build.py
@@ -22,7 +22,7 @@ class TemplateBuild:
build_id (str): Identifier of the build
log_entries (list['BuildLogEntry']): Build logs structured
logs (list[str]): Build logs
- status (TemplateBuildStatus): Status of the template
+ status (TemplateBuildStatus): Status of the template build
template_id (str): Identifier of the template
reason (Union[Unset, BuildStatusReason]):
"""
diff --git a/packages/python-sdk/e2b/api/client/models/template_build_request_v3.py b/packages/python-sdk/e2b/api/client/models/template_build_request_v3.py
new file mode 100644
index 000000000..0c14ad5d8
--- /dev/null
+++ b/packages/python-sdk/e2b/api/client/models/template_build_request_v3.py
@@ -0,0 +1,88 @@
+from collections.abc import Mapping
+from typing import Any, TypeVar, Union
+
+from attrs import define as _attrs_define
+from attrs import field as _attrs_field
+
+from ..types import UNSET, Unset
+
+T = TypeVar("T", bound="TemplateBuildRequestV3")
+
+
+@_attrs_define
+class TemplateBuildRequestV3:
+ """
+ Attributes:
+ alias (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 MiB
+ team_id (Union[Unset, str]): Identifier of the team
+ """
+
+ alias: str
+ cpu_count: Union[Unset, int] = UNSET
+ memory_mb: Union[Unset, int] = UNSET
+ team_id: Union[Unset, str] = UNSET
+ additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict)
+
+ def to_dict(self) -> dict[str, Any]:
+ alias = self.alias
+
+ cpu_count = self.cpu_count
+
+ memory_mb = self.memory_mb
+
+ team_id = self.team_id
+
+ field_dict: dict[str, Any] = {}
+ field_dict.update(self.additional_properties)
+ field_dict.update(
+ {
+ "alias": alias,
+ }
+ )
+ if cpu_count is not UNSET:
+ field_dict["cpuCount"] = cpu_count
+ if memory_mb is not UNSET:
+ field_dict["memoryMB"] = memory_mb
+ if team_id is not UNSET:
+ field_dict["teamID"] = team_id
+
+ return field_dict
+
+ @classmethod
+ def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T:
+ d = dict(src_dict)
+ alias = d.pop("alias")
+
+ cpu_count = d.pop("cpuCount", UNSET)
+
+ memory_mb = d.pop("memoryMB", UNSET)
+
+ team_id = d.pop("teamID", UNSET)
+
+ template_build_request_v3 = cls(
+ alias=alias,
+ cpu_count=cpu_count,
+ memory_mb=memory_mb,
+ team_id=team_id,
+ )
+
+ template_build_request_v3.additional_properties = d
+ return template_build_request_v3
+
+ @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/template_legacy.py b/packages/python-sdk/e2b/api/client/models/template_legacy.py
new file mode 100644
index 000000000..69501e565
--- /dev/null
+++ b/packages/python-sdk/e2b/api/client/models/template_legacy.py
@@ -0,0 +1,207 @@
+import datetime
+from collections.abc import Mapping
+from typing import TYPE_CHECKING, Any, TypeVar, Union, cast
+
+from attrs import define as _attrs_define
+from attrs import field as _attrs_field
+from dateutil.parser import isoparse
+
+if TYPE_CHECKING:
+ from ..models.team_user import TeamUser
+
+
+T = TypeVar("T", bound="TemplateLegacy")
+
+
+@_attrs_define
+class TemplateLegacy:
+ """
+ Attributes:
+ aliases (list[str]): Aliases of the template
+ build_count (int): Number of times the template was built
+ build_id (str): Identifier of the last successful build for given template
+ cpu_count (int): CPU cores for the sandbox
+ created_at (datetime.datetime): Time when the template was created
+ created_by (Union['TeamUser', None]):
+ disk_size_mb (int): Disk size for the sandbox in MiB
+ envd_version (str): Version of the envd running in the sandbox
+ last_spawned_at (Union[None, datetime.datetime]): Time when the template was last used
+ memory_mb (int): Memory for the sandbox in MiB
+ public (bool): Whether the template is public or only accessible by the team
+ spawn_count (int): Number of times the template was used
+ template_id (str): Identifier of the template
+ updated_at (datetime.datetime): Time when the template was last updated
+ """
+
+ aliases: list[str]
+ build_count: int
+ build_id: str
+ cpu_count: int
+ created_at: datetime.datetime
+ created_by: Union["TeamUser", None]
+ disk_size_mb: int
+ envd_version: str
+ last_spawned_at: Union[None, datetime.datetime]
+ memory_mb: int
+ public: bool
+ spawn_count: int
+ template_id: str
+ updated_at: datetime.datetime
+ additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict)
+
+ def to_dict(self) -> dict[str, Any]:
+ from ..models.team_user import TeamUser
+
+ aliases = self.aliases
+
+ build_count = self.build_count
+
+ build_id = self.build_id
+
+ cpu_count = self.cpu_count
+
+ 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
+
+ disk_size_mb = self.disk_size_mb
+
+ envd_version = self.envd_version
+
+ last_spawned_at: Union[None, str]
+ if isinstance(self.last_spawned_at, datetime.datetime):
+ last_spawned_at = self.last_spawned_at.isoformat()
+ else:
+ last_spawned_at = self.last_spawned_at
+
+ memory_mb = self.memory_mb
+
+ public = self.public
+
+ spawn_count = self.spawn_count
+
+ template_id = self.template_id
+
+ updated_at = self.updated_at.isoformat()
+
+ field_dict: dict[str, Any] = {}
+ field_dict.update(self.additional_properties)
+ field_dict.update(
+ {
+ "aliases": aliases,
+ "buildCount": build_count,
+ "buildID": build_id,
+ "cpuCount": cpu_count,
+ "createdAt": created_at,
+ "createdBy": created_by,
+ "diskSizeMB": disk_size_mb,
+ "envdVersion": envd_version,
+ "lastSpawnedAt": last_spawned_at,
+ "memoryMB": memory_mb,
+ "public": public,
+ "spawnCount": spawn_count,
+ "templateID": template_id,
+ "updatedAt": updated_at,
+ }
+ )
+
+ return field_dict
+
+ @classmethod
+ def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T:
+ from ..models.team_user import TeamUser
+
+ d = dict(src_dict)
+ aliases = cast(list[str], d.pop("aliases"))
+
+ build_count = d.pop("buildCount")
+
+ build_id = d.pop("buildID")
+
+ cpu_count = d.pop("cpuCount")
+
+ created_at = isoparse(d.pop("createdAt"))
+
+ def _parse_created_by(data: object) -> Union["TeamUser", None]:
+ if data is None:
+ return data
+ try:
+ if not isinstance(data, dict):
+ raise TypeError()
+ created_by_type_1 = TeamUser.from_dict(data)
+
+ return created_by_type_1
+ except: # noqa: E722
+ pass
+ return cast(Union["TeamUser", None], data)
+
+ created_by = _parse_created_by(d.pop("createdBy"))
+
+ disk_size_mb = d.pop("diskSizeMB")
+
+ envd_version = d.pop("envdVersion")
+
+ def _parse_last_spawned_at(data: object) -> Union[None, datetime.datetime]:
+ if data is None:
+ return data
+ try:
+ if not isinstance(data, str):
+ raise TypeError()
+ last_spawned_at_type_0 = isoparse(data)
+
+ return last_spawned_at_type_0
+ except: # noqa: E722
+ pass
+ return cast(Union[None, datetime.datetime], data)
+
+ last_spawned_at = _parse_last_spawned_at(d.pop("lastSpawnedAt"))
+
+ memory_mb = d.pop("memoryMB")
+
+ public = d.pop("public")
+
+ spawn_count = d.pop("spawnCount")
+
+ template_id = d.pop("templateID")
+
+ updated_at = isoparse(d.pop("updatedAt"))
+
+ template_legacy = cls(
+ aliases=aliases,
+ build_count=build_count,
+ build_id=build_id,
+ cpu_count=cpu_count,
+ created_at=created_at,
+ created_by=created_by,
+ disk_size_mb=disk_size_mb,
+ envd_version=envd_version,
+ last_spawned_at=last_spawned_at,
+ memory_mb=memory_mb,
+ public=public,
+ spawn_count=spawn_count,
+ template_id=template_id,
+ updated_at=updated_at,
+ )
+
+ template_legacy.additional_properties = d
+ return template_legacy
+
+ @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/template_request_response_v3.py b/packages/python-sdk/e2b/api/client/models/template_request_response_v3.py
new file mode 100644
index 000000000..efe0e8c4f
--- /dev/null
+++ b/packages/python-sdk/e2b/api/client/models/template_request_response_v3.py
@@ -0,0 +1,83 @@
+from collections.abc import Mapping
+from typing import Any, TypeVar, cast
+
+from attrs import define as _attrs_define
+from attrs import field as _attrs_field
+
+T = TypeVar("T", bound="TemplateRequestResponseV3")
+
+
+@_attrs_define
+class TemplateRequestResponseV3:
+ """
+ Attributes:
+ aliases (list[str]): Aliases of the template
+ build_id (str): Identifier of the last successful build for given template
+ public (bool): Whether the template is public or only accessible by the team
+ template_id (str): Identifier of the template
+ """
+
+ aliases: list[str]
+ build_id: str
+ public: bool
+ template_id: str
+ additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict)
+
+ def to_dict(self) -> dict[str, Any]:
+ aliases = self.aliases
+
+ build_id = self.build_id
+
+ public = self.public
+
+ template_id = self.template_id
+
+ field_dict: dict[str, Any] = {}
+ field_dict.update(self.additional_properties)
+ field_dict.update(
+ {
+ "aliases": aliases,
+ "buildID": build_id,
+ "public": public,
+ "templateID": template_id,
+ }
+ )
+
+ return field_dict
+
+ @classmethod
+ def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T:
+ d = dict(src_dict)
+ aliases = cast(list[str], d.pop("aliases"))
+
+ build_id = d.pop("buildID")
+
+ public = d.pop("public")
+
+ template_id = d.pop("templateID")
+
+ template_request_response_v3 = cls(
+ aliases=aliases,
+ build_id=build_id,
+ public=public,
+ template_id=template_id,
+ )
+
+ template_request_response_v3.additional_properties = d
+ return template_request_response_v3
+
+ @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/template_async/build_api.py b/packages/python-sdk/e2b/template_async/build_api.py
index 103e8f895..539420e87 100644
--- a/packages/python-sdk/e2b/template_async/build_api.py
+++ b/packages/python-sdk/e2b/template_async/build_api.py
@@ -10,14 +10,14 @@ import httpx
from e2b.api import handle_api_exception
from e2b.api.client.api.templates import (
- post_v2_templates,
+ post_v3_templates,
get_templates_template_id_files_hash,
post_v_2_templates_template_id_builds_build_id,
get_templates_template_id_builds_build_id_status,
)
from e2b.api.client.client import AuthenticatedClient
from e2b.api.client.models import (
- TemplateBuildRequestV2,
+ TemplateBuildRequestV3,
TemplateBuildStartV2,
TemplateBuildFileUpload,
TemplateBuild,
@@ -32,9 +32,9 @@ from e2b.template.utils import get_build_step_index
async def request_build(
client: AuthenticatedClient, name: str, cpu_count: int, memory_mb: int
):
- res = await post_v2_templates.asyncio_detailed(
+ res = await post_v3_templates.asyncio_detailed(
client=client,
- body=TemplateBuildRequestV2(
+ body=TemplateBuildRequestV3(
alias=name,
cpu_count=cpu_count,
memory_mb=memory_mb,
diff --git a/packages/python-sdk/e2b/template_sync/build_api.py b/packages/python-sdk/e2b/template_sync/build_api.py
index 30959c06a..f54efa516 100644
--- a/packages/python-sdk/e2b/template_sync/build_api.py
+++ b/packages/python-sdk/e2b/template_sync/build_api.py
@@ -10,14 +10,14 @@ import httpx
from e2b.api import handle_api_exception
from e2b.api.client.api.templates import (
- post_v2_templates,
+ post_v3_templates,
get_templates_template_id_files_hash,
post_v_2_templates_template_id_builds_build_id,
get_templates_template_id_builds_build_id_status,
)
from e2b.api.client.client import AuthenticatedClient
from e2b.api.client.models import (
- TemplateBuildRequestV2,
+ TemplateBuildRequestV3,
TemplateBuildStartV2,
TemplateBuildFileUpload,
TemplateBuild,
@@ -32,9 +32,9 @@ from e2b.template.utils import get_build_step_index
def request_build(
client: AuthenticatedClient, name: str, cpu_count: int, memory_mb: int
):
- res = post_v2_templates.sync_detailed(
+ res = post_v3_templates.sync_detailed(
client=client,
- body=TemplateBuildRequestV2(
+ body=TemplateBuildRequestV3(
alias=name,
cpu_count=cpu_count,
memory_mb=memory_mb,
diff --git a/spec/openapi.yml b/spec/openapi.yml
index 1bc938b5b..10a6870a3 100644
--- a/spec/openapi.yml
+++ b/spec/openapi.yml
@@ -193,9 +193,11 @@ components:
type: string
description: Environment variables for the sandbox
- McpConfig:
- additionalProperties: true
- description: MCP server configuration
+ Mcp:
+ type: object
+ description: MCP configuration for the sandbox
+ additionalProperties: {}
+ nullable: true
SandboxLog:
description: Log entry with timestamp and line
@@ -252,6 +254,7 @@ components:
description: Metric entry with timestamp and line
required:
- timestamp
+ - timestampUnix
- cpuCount
- cpuUsedPct
- memUsed
@@ -262,7 +265,12 @@ components:
timestamp:
type: string
format: date-time
+ deprecated: true
description: Timestamp of the metric entry
+ timestampUnix:
+ type: integer
+ format: int64
+ description: Timestamp of the metric entry in Unix time (seconds since epoch)
cpuCount:
type: integer
format: int32
@@ -455,7 +463,7 @@ components:
envVars:
$ref: "#/components/schemas/EnvVars"
mcp:
- $ref: "#/components/schemas/McpConfig"
+ $ref: "#/components/schemas/Mcp"
ResumedSandbox:
properties:
@@ -470,17 +478,34 @@ components:
deprecated: true
description: Automatically pauses the sandbox after the timeout
+ ConnectSandbox:
+ type: object
+ required:
+ - timeout
+ properties:
+ timeout:
+ description: Timeout in seconds from the current time after which the sandbox should expire
+ type: integer
+ format: int32
+ minimum: 0
+
TeamMetric:
description: Team metric with timestamp
required:
- timestamp
+ - timestampUnix
- concurrentSandboxes
- sandboxStartRate
properties:
timestamp:
type: string
format: date-time
+ deprecated: true
description: Timestamp of the metric entry
+ timestampUnix:
+ type: integer
+ format: int64
+ description: Timestamp of the metric entry in Unix time (seconds since epoch)
concurrentSandboxes:
type: integer
format: int32
@@ -490,7 +515,117 @@ components:
format: float
description: Number of sandboxes started per second
+ MaxTeamMetric:
+ description: Team metric with timestamp
+ required:
+ - timestamp
+ - timestampUnix
+ - value
+ properties:
+ timestamp:
+ type: string
+ format: date-time
+ deprecated: true
+ description: Timestamp of the metric entry
+ timestampUnix:
+ type: integer
+ format: int64
+ description: Timestamp of the metric entry in Unix time (seconds since epoch)
+ value:
+ type: number
+ description: The maximum value of the requested metric in the given interval
+
Template:
+ required:
+ - templateID
+ - buildID
+ - cpuCount
+ - memoryMB
+ - diskSizeMB
+ - public
+ - createdAt
+ - updatedAt
+ - createdBy
+ - lastSpawnedAt
+ - spawnCount
+ - buildCount
+ - envdVersion
+ - aliases
+ - buildStatus
+ properties:
+ templateID:
+ type: string
+ description: Identifier of the template
+ buildID:
+ type: string
+ description: Identifier of the last successful build for given template
+ cpuCount:
+ $ref: "#/components/schemas/CPUCount"
+ memoryMB:
+ $ref: "#/components/schemas/MemoryMB"
+ diskSizeMB:
+ $ref: "#/components/schemas/DiskSizeMB"
+ public:
+ type: boolean
+ description: Whether the template is public or only accessible by the team
+ aliases:
+ type: array
+ description: Aliases of the template
+ items:
+ type: string
+ createdAt:
+ type: string
+ format: date-time
+ description: Time when the template was created
+ updatedAt:
+ type: string
+ format: date-time
+ description: Time when the template was last updated
+ createdBy:
+ allOf:
+ - $ref: "#/components/schemas/TeamUser"
+ nullable: true
+ lastSpawnedAt:
+ type: string
+ nullable: true
+ format: date-time
+ description: Time when the template was last used
+ spawnCount:
+ type: integer
+ format: int64
+ description: Number of times the template was used
+ buildCount:
+ type: integer
+ format: int32
+ description: Number of times the template was built
+ envdVersion:
+ $ref: "#/components/schemas/EnvdVersion"
+ buildStatus:
+ $ref: "#/components/schemas/TemplateBuildStatus"
+
+ TemplateRequestResponseV3:
+ required:
+ - templateID
+ - buildID
+ - public
+ - aliases
+ properties:
+ templateID:
+ type: string
+ description: Identifier of the template
+ buildID:
+ type: string
+ description: Identifier of the last successful build for given template
+ public:
+ type: boolean
+ description: Whether the template is public or only accessible by the team
+ aliases:
+ type: array
+ description: Aliases of the template
+ items:
+ type: string
+
+ TemplateLegacy:
required:
- templateID
- buildID
@@ -601,6 +736,21 @@ components:
type: boolean
description: Whether the step should be forced to run regardless of the cache
+ TemplateBuildRequestV3:
+ required:
+ - alias
+ properties:
+ alias:
+ description: Alias of the template
+ type: string
+ teamID:
+ type: string
+ description: Identifier of the team
+ cpuCount:
+ $ref: "#/components/schemas/CPUCount"
+ memoryMB:
+ $ref: "#/components/schemas/MemoryMB"
+
TemplateBuildRequestV2:
required:
- alias
@@ -618,15 +768,15 @@ components:
FromImageRegistry:
oneOf:
- - $ref: '#/components/schemas/AWSRegistry'
- - $ref: '#/components/schemas/GCPRegistry'
- - $ref: '#/components/schemas/GeneralRegistry'
+ - $ref: "#/components/schemas/AWSRegistry"
+ - $ref: "#/components/schemas/GCPRegistry"
+ - $ref: "#/components/schemas/GeneralRegistry"
discriminator:
propertyName: type
mapping:
- aws: '#/components/schemas/AWSRegistry'
- gcp: '#/components/schemas/GCPRegistry'
- registry: '#/components/schemas/GeneralRegistry'
+ aws: "#/components/schemas/AWSRegistry"
+ gcp: "#/components/schemas/GCPRegistry"
+ registry: "#/components/schemas/GeneralRegistry"
AWSRegistry:
type: object
@@ -745,6 +895,9 @@ components:
description: Log message content
level:
$ref: "#/components/schemas/LogLevel"
+ step:
+ type: string
+ description: Step in the build process related to the log entry
BuildStatusReason:
required:
@@ -756,6 +909,21 @@ components:
step:
type: string
description: Step that failed
+ logEntries:
+ default: []
+ description: Log entries related to the status reason
+ type: array
+ items:
+ $ref: "#/components/schemas/BuildLogEntry"
+
+ TemplateBuildStatus:
+ type: string
+ description: Status of the template build
+ enum:
+ - building
+ - waiting
+ - ready
+ - error
TemplateBuild:
required:
@@ -784,13 +952,7 @@ components:
type: string
description: Identifier of the build
status:
- type: string
- description: Status of the template
- enum:
- - building
- - waiting
- - ready
- - error
+ $ref: "#/components/schemas/TemplateBuildStatus"
reason:
$ref: "#/components/schemas/BuildStatusReason"
@@ -812,6 +974,10 @@ components:
required:
- status
properties:
+ clusterID:
+ type: string
+ format: uuid
+ description: Identifier of the cluster
status:
$ref: "#/components/schemas/NodeStatus"
@@ -911,8 +1077,8 @@ components:
type: string
description: Identifier of the node
serviceInstanceID:
- type: string
- description: Service instance identifier of the node
+ type: string
+ description: Service instance identifier of the node
clusterID:
type: string
description: Identifier of the cluster
@@ -965,8 +1131,8 @@ components:
type: string
description: Identifier of the node
serviceInstanceID:
- type: string
- description: Service instance identifier of the node
+ type: string
+ description: Service instance identifier of the node
nodeID:
type: string
deprecated: true
@@ -1221,6 +1387,53 @@ paths:
"500":
$ref: "#/components/responses/500"
+ /teams/{teamID}/metrics/max:
+ get:
+ description: Get the maximum metrics for the team in the given interval
+ tags: [auth]
+ security:
+ - ApiKeyAuth: []
+ - Supabase1TokenAuth: []
+ Supabase2TeamAuth: []
+ parameters:
+ - $ref: "#/components/parameters/teamID"
+ - in: query
+ name: start
+ schema:
+ type: integer
+ format: int64
+ minimum: 0
+ description: Unix timestamp for the start of the interval, in seconds, for which the metrics
+ - in: query
+ name: end
+ schema:
+ type: integer
+ format: int64
+ minimum: 0
+ description: Unix timestamp for the end of the interval, in seconds, for which the metrics
+ - in: query
+ name: metric
+ required: true
+ schema:
+ type: string
+ enum: [concurrent_sandboxes, sandbox_start_rate]
+ description: Metric to retrieve the maximum value for
+ responses:
+ "200":
+ description: Successfully returned the team metrics
+ content:
+ application/json:
+ schema:
+ $ref: "#/components/schemas/MaxTeamMetric"
+ "400":
+ $ref: "#/components/responses/400"
+ "401":
+ $ref: "#/components/responses/401"
+ "403":
+ $ref: "#/components/responses/403"
+ "500":
+ $ref: "#/components/responses/500"
+
/sandboxes:
get:
description: List all running sandboxes
@@ -1520,6 +1733,7 @@ paths:
/sandboxes/{sandboxID}/resume:
post:
+ deprecated: true
description: Resume the sandbox
tags: [sandboxes]
security:
@@ -1550,6 +1764,44 @@ paths:
"500":
$ref: "#/components/responses/500"
+ /sandboxes/{sandboxID}/connect:
+ post:
+ description: Returns sandbox details. If the sandbox is paused, it will be resumed. TTL is only extended.
+ tags: [sandboxes]
+ security:
+ - ApiKeyAuth: []
+ - Supabase1TokenAuth: []
+ Supabase2TeamAuth: []
+ parameters:
+ - $ref: "#/components/parameters/sandboxID"
+ requestBody:
+ required: true
+ content:
+ application/json:
+ schema:
+ $ref: "#/components/schemas/ConnectSandbox"
+ responses:
+ "200":
+ description: The sandbox was already running
+ content:
+ application/json:
+ schema:
+ $ref: "#/components/schemas/Sandbox"
+ "201":
+ description: The sandbox was resumed successfully
+ content:
+ application/json:
+ schema:
+ $ref: "#/components/schemas/Sandbox"
+ "400":
+ $ref: "#/components/responses/400"
+ "401":
+ $ref: "#/components/responses/401"
+ "404":
+ $ref: "#/components/responses/404"
+ "500":
+ $ref: "#/components/responses/500"
+
/sandboxes/{sandboxID}/timeout:
post:
description: Set the timeout for the sandbox. The sandbox will expire x seconds from the time of the request. Calling this method multiple times overwrites the TTL, each time using the current timestamp as the starting point to measure the timeout duration.
@@ -1612,9 +1864,38 @@ paths:
"404":
$ref: "#/components/responses/404"
+ /v3/templates:
+ post:
+ description: Create a new template
+ tags: [templates]
+ security:
+ - ApiKeyAuth: []
+ - Supabase1TokenAuth: []
+ requestBody:
+ required: true
+ content:
+ application/json:
+ schema:
+ $ref: "#/components/schemas/TemplateBuildRequestV3"
+
+ responses:
+ "202":
+ description: The build was requested successfully
+ content:
+ application/json:
+ schema:
+ $ref: "#/components/schemas/TemplateRequestResponseV3"
+ "400":
+ $ref: "#/components/responses/400"
+ "401":
+ $ref: "#/components/responses/401"
+ "500":
+ $ref: "#/components/responses/500"
+
/v2/templates:
post:
description: Create a new template
+ deprecated: true
tags: [templates]
security:
- ApiKeyAuth: []
@@ -1632,7 +1913,7 @@ paths:
content:
application/json:
schema:
- $ref: "#/components/schemas/Template"
+ $ref: "#/components/schemas/TemplateLegacy"
"400":
$ref: "#/components/responses/400"
"401":
@@ -1678,6 +1959,7 @@ paths:
description: List all templates
tags: [templates]
security:
+ - ApiKeyAuth: []
- AccessTokenAuth: []
- Supabase1TokenAuth: []
parameters:
@@ -1703,6 +1985,7 @@ paths:
$ref: "#/components/responses/500"
post:
description: Create a new template
+ deprecated: true
tags: [templates]
security:
- AccessTokenAuth: []
@@ -1720,7 +2003,7 @@ paths:
content:
application/json:
schema:
- $ref: "#/components/schemas/Template"
+ $ref: "#/components/schemas/TemplateLegacy"
"400":
$ref: "#/components/responses/400"
"401":
@@ -1731,6 +2014,7 @@ paths:
/templates/{templateID}:
post:
description: Rebuild an template
+ deprecated: true
tags: [templates]
security:
- AccessTokenAuth: []
@@ -1750,7 +2034,7 @@ paths:
content:
application/json:
schema:
- $ref: "#/components/schemas/Template"
+ $ref: "#/components/schemas/TemplateLegacy"
"401":
$ref: "#/components/responses/401"
"500":
@@ -1775,6 +2059,7 @@ paths:
description: Update template
tags: [templates]
security:
+ - ApiKeyAuth: []
- AccessTokenAuth: []
- Supabase1TokenAuth: []
parameters:
@@ -1798,6 +2083,7 @@ paths:
/templates/{templateID}/builds/{buildID}:
post:
description: Start the build
+ deprecated: true
tags: [templates]
security:
- AccessTokenAuth: []
@@ -1909,6 +2195,7 @@ paths:
required: false
schema:
type: string
+ format: uuid
responses:
"200":
description: Successfully returned the node