chore: import upstream snapshot with attribution

This commit is contained in:
wehub-resource-sync
2026-07-13 12:47:58 +08:00
commit b16403ea71
789 changed files with 115226 additions and 0 deletions
+8
View File
@@ -0,0 +1,8 @@
"""A client library for accessing E2B API"""
from .client import AuthenticatedClient, Client
__all__ = (
"AuthenticatedClient",
"Client",
)
+1
View File
@@ -0,0 +1 @@
"""Contains methods for accessing the API"""
@@ -0,0 +1 @@
"""Contains endpoint functions for accessing the API"""
@@ -0,0 +1,161 @@
from http import HTTPStatus
from typing import Any, Optional, Union, cast
import httpx
from ... import errors
from ...client import AuthenticatedClient, Client
from ...models.error import Error
from ...types import Response
def _get_kwargs(
sandbox_id: str,
) -> dict[str, Any]:
_kwargs: dict[str, Any] = {
"method": "delete",
"url": f"/sandboxes/{sandbox_id}",
}
return _kwargs
def _parse_response(
*, client: Union[AuthenticatedClient, Client], response: httpx.Response
) -> Optional[Union[Any, Error]]:
if response.status_code == 204:
response_204 = cast(Any, None)
return response_204
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[Any, Error]]:
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,
) -> Response[Union[Any, Error]]:
"""Kill a sandbox
Args:
sandbox_id (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[Any, Error]]
"""
kwargs = _get_kwargs(
sandbox_id=sandbox_id,
)
response = client.get_httpx_client().request(
**kwargs,
)
return _build_response(client=client, response=response)
def sync(
sandbox_id: str,
*,
client: AuthenticatedClient,
) -> Optional[Union[Any, Error]]:
"""Kill a sandbox
Args:
sandbox_id (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[Any, Error]
"""
return sync_detailed(
sandbox_id=sandbox_id,
client=client,
).parsed
async def asyncio_detailed(
sandbox_id: str,
*,
client: AuthenticatedClient,
) -> Response[Union[Any, Error]]:
"""Kill a sandbox
Args:
sandbox_id (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[Any, Error]]
"""
kwargs = _get_kwargs(
sandbox_id=sandbox_id,
)
response = await client.get_async_httpx_client().request(**kwargs)
return _build_response(client=client, response=response)
async def asyncio(
sandbox_id: str,
*,
client: AuthenticatedClient,
) -> Optional[Union[Any, Error]]:
"""Kill a sandbox
Args:
sandbox_id (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[Any, Error]
"""
return (
await asyncio_detailed(
sandbox_id=sandbox_id,
client=client,
)
).parsed
@@ -0,0 +1,176 @@
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.listed_sandbox import ListedSandbox
from ...types import UNSET, Response, Unset
def _get_kwargs(
*,
metadata: Union[Unset, str] = UNSET,
) -> dict[str, Any]:
params: dict[str, Any] = {}
params["metadata"] = metadata
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": "/sandboxes",
"params": params,
}
return _kwargs
def _parse_response(
*, client: Union[AuthenticatedClient, Client], response: httpx.Response
) -> Optional[Union[Error, list["ListedSandbox"]]]:
if response.status_code == 200:
response_200 = []
_response_200 = response.json()
for response_200_item_data in _response_200:
response_200_item = ListedSandbox.from_dict(response_200_item_data)
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())
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, list["ListedSandbox"]]]:
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,
metadata: Union[Unset, str] = UNSET,
) -> Response[Union[Error, list["ListedSandbox"]]]:
"""List all running sandboxes
Args:
metadata (Union[Unset, 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['ListedSandbox']]]
"""
kwargs = _get_kwargs(
metadata=metadata,
)
response = client.get_httpx_client().request(
**kwargs,
)
return _build_response(client=client, response=response)
def sync(
*,
client: AuthenticatedClient,
metadata: Union[Unset, str] = UNSET,
) -> Optional[Union[Error, list["ListedSandbox"]]]:
"""List all running sandboxes
Args:
metadata (Union[Unset, 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['ListedSandbox']]
"""
return sync_detailed(
client=client,
metadata=metadata,
).parsed
async def asyncio_detailed(
*,
client: AuthenticatedClient,
metadata: Union[Unset, str] = UNSET,
) -> Response[Union[Error, list["ListedSandbox"]]]:
"""List all running sandboxes
Args:
metadata (Union[Unset, 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['ListedSandbox']]]
"""
kwargs = _get_kwargs(
metadata=metadata,
)
response = await client.get_async_httpx_client().request(**kwargs)
return _build_response(client=client, response=response)
async def asyncio(
*,
client: AuthenticatedClient,
metadata: Union[Unset, str] = UNSET,
) -> Optional[Union[Error, list["ListedSandbox"]]]:
"""List all running sandboxes
Args:
metadata (Union[Unset, 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['ListedSandbox']]
"""
return (
await asyncio_detailed(
client=client,
metadata=metadata,
)
).parsed
@@ -0,0 +1,173 @@
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.sandboxes_with_metrics import SandboxesWithMetrics
from ...types import UNSET, Response
def _get_kwargs(
*,
sandbox_ids: list[str],
) -> dict[str, Any]:
params: dict[str, Any] = {}
json_sandbox_ids = sandbox_ids
params["sandbox_ids"] = ",".join(str(item) for item in json_sandbox_ids)
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": "/sandboxes/metrics",
"params": params,
}
return _kwargs
def _parse_response(
*, client: Union[AuthenticatedClient, Client], response: httpx.Response
) -> Optional[Union[Error, SandboxesWithMetrics]]:
if response.status_code == 200:
response_200 = SandboxesWithMetrics.from_dict(response.json())
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())
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, SandboxesWithMetrics]]:
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,
sandbox_ids: list[str],
) -> Response[Union[Error, SandboxesWithMetrics]]:
"""List metrics for given sandboxes
Args:
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, SandboxesWithMetrics]]
"""
kwargs = _get_kwargs(
sandbox_ids=sandbox_ids,
)
response = client.get_httpx_client().request(
**kwargs,
)
return _build_response(client=client, response=response)
def sync(
*,
client: AuthenticatedClient,
sandbox_ids: list[str],
) -> Optional[Union[Error, SandboxesWithMetrics]]:
"""List metrics for given sandboxes
Args:
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, SandboxesWithMetrics]
"""
return sync_detailed(
client=client,
sandbox_ids=sandbox_ids,
).parsed
async def asyncio_detailed(
*,
client: AuthenticatedClient,
sandbox_ids: list[str],
) -> Response[Union[Error, SandboxesWithMetrics]]:
"""List metrics for given sandboxes
Args:
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, SandboxesWithMetrics]]
"""
kwargs = _get_kwargs(
sandbox_ids=sandbox_ids,
)
response = await client.get_async_httpx_client().request(**kwargs)
return _build_response(client=client, response=response)
async def asyncio(
*,
client: AuthenticatedClient,
sandbox_ids: list[str],
) -> Optional[Union[Error, SandboxesWithMetrics]]:
"""List metrics for given sandboxes
Args:
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, SandboxesWithMetrics]
"""
return (
await asyncio_detailed(
client=client,
sandbox_ids=sandbox_ids,
)
).parsed
@@ -0,0 +1,163 @@
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.sandbox_detail import SandboxDetail
from ...types import Response
def _get_kwargs(
sandbox_id: str,
) -> dict[str, Any]:
_kwargs: dict[str, Any] = {
"method": "get",
"url": f"/sandboxes/{sandbox_id}",
}
return _kwargs
def _parse_response(
*, client: Union[AuthenticatedClient, Client], response: httpx.Response
) -> Optional[Union[Error, SandboxDetail]]:
if response.status_code == 200:
response_200 = SandboxDetail.from_dict(response.json())
return response_200
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, SandboxDetail]]:
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,
) -> Response[Union[Error, SandboxDetail]]:
"""Get a sandbox by id
Args:
sandbox_id (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, SandboxDetail]]
"""
kwargs = _get_kwargs(
sandbox_id=sandbox_id,
)
response = client.get_httpx_client().request(
**kwargs,
)
return _build_response(client=client, response=response)
def sync(
sandbox_id: str,
*,
client: AuthenticatedClient,
) -> Optional[Union[Error, SandboxDetail]]:
"""Get a sandbox by id
Args:
sandbox_id (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, SandboxDetail]
"""
return sync_detailed(
sandbox_id=sandbox_id,
client=client,
).parsed
async def asyncio_detailed(
sandbox_id: str,
*,
client: AuthenticatedClient,
) -> Response[Union[Error, SandboxDetail]]:
"""Get a sandbox by id
Args:
sandbox_id (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, SandboxDetail]]
"""
kwargs = _get_kwargs(
sandbox_id=sandbox_id,
)
response = await client.get_async_httpx_client().request(**kwargs)
return _build_response(client=client, response=response)
async def asyncio(
sandbox_id: str,
*,
client: AuthenticatedClient,
) -> Optional[Union[Error, SandboxDetail]]:
"""Get a sandbox by id
Args:
sandbox_id (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, SandboxDetail]
"""
return (
await asyncio_detailed(
sandbox_id=sandbox_id,
client=client,
)
).parsed
@@ -0,0 +1,199 @@
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.sandbox_logs import SandboxLogs
from ...types import UNSET, Response, Unset
def _get_kwargs(
sandbox_id: str,
*,
start: Union[Unset, int] = UNSET,
limit: Union[Unset, int] = 1000,
) -> dict[str, Any]:
params: dict[str, Any] = {}
params["start"] = start
params["limit"] = limit
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}/logs",
"params": params,
}
return _kwargs
def _parse_response(
*, client: Union[AuthenticatedClient, Client], response: httpx.Response
) -> Optional[Union[Error, SandboxLogs]]:
if response.status_code == 200:
response_200 = SandboxLogs.from_dict(response.json())
return response_200
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, SandboxLogs]]:
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,
start: Union[Unset, int] = UNSET,
limit: Union[Unset, int] = 1000,
) -> Response[Union[Error, SandboxLogs]]:
"""Get sandbox logs. Use /v2/sandboxes/{sandboxID}/logs instead.
Args:
sandbox_id (str):
start (Union[Unset, int]):
limit (Union[Unset, int]): Default: 1000.
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, SandboxLogs]]
"""
kwargs = _get_kwargs(
sandbox_id=sandbox_id,
start=start,
limit=limit,
)
response = client.get_httpx_client().request(
**kwargs,
)
return _build_response(client=client, response=response)
def sync(
sandbox_id: str,
*,
client: AuthenticatedClient,
start: Union[Unset, int] = UNSET,
limit: Union[Unset, int] = 1000,
) -> Optional[Union[Error, SandboxLogs]]:
"""Get sandbox logs. Use /v2/sandboxes/{sandboxID}/logs instead.
Args:
sandbox_id (str):
start (Union[Unset, int]):
limit (Union[Unset, int]): Default: 1000.
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, SandboxLogs]
"""
return sync_detailed(
sandbox_id=sandbox_id,
client=client,
start=start,
limit=limit,
).parsed
async def asyncio_detailed(
sandbox_id: str,
*,
client: AuthenticatedClient,
start: Union[Unset, int] = UNSET,
limit: Union[Unset, int] = 1000,
) -> Response[Union[Error, SandboxLogs]]:
"""Get sandbox logs. Use /v2/sandboxes/{sandboxID}/logs instead.
Args:
sandbox_id (str):
start (Union[Unset, int]):
limit (Union[Unset, int]): Default: 1000.
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, SandboxLogs]]
"""
kwargs = _get_kwargs(
sandbox_id=sandbox_id,
start=start,
limit=limit,
)
response = await client.get_async_httpx_client().request(**kwargs)
return _build_response(client=client, response=response)
async def asyncio(
sandbox_id: str,
*,
client: AuthenticatedClient,
start: Union[Unset, int] = UNSET,
limit: Union[Unset, int] = 1000,
) -> Optional[Union[Error, SandboxLogs]]:
"""Get sandbox logs. Use /v2/sandboxes/{sandboxID}/logs instead.
Args:
sandbox_id (str):
start (Union[Unset, int]):
limit (Union[Unset, int]): Default: 1000.
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, SandboxLogs]
"""
return (
await asyncio_detailed(
sandbox_id=sandbox_id,
client=client,
start=start,
limit=limit,
)
).parsed
@@ -0,0 +1,212 @@
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.sandbox_metric import SandboxMetric
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
def _parse_response(
*, client: Union[AuthenticatedClient, Client], response: httpx.Response
) -> Optional[Union[Error, list["SandboxMetric"]]]:
if response.status_code == 200:
response_200 = []
_response_200 = response.json()
for response_200_item_data in _response_200:
response_200_item = SandboxMetric.from_dict(response_200_item_data)
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())
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, list["SandboxMetric"]]]:
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,
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]): Unix timestamp for the end of the interval, in seconds, for which
the metrics
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['SandboxMetric']]]
"""
kwargs = _get_kwargs(
sandbox_id=sandbox_id,
start=start,
end=end,
)
response = client.get_httpx_client().request(
**kwargs,
)
return _build_response(client=client, response=response)
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]): Unix timestamp for the end of the interval, in seconds, for which
the metrics
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['SandboxMetric']]
"""
return sync_detailed(
sandbox_id=sandbox_id,
client=client,
start=start,
end=end,
).parsed
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]): Unix timestamp for the end of the interval, in seconds, for which
the metrics
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['SandboxMetric']]]
"""
kwargs = _get_kwargs(
sandbox_id=sandbox_id,
start=start,
end=end,
)
response = await client.get_async_httpx_client().request(**kwargs)
return _build_response(client=client, response=response)
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]): Unix timestamp for the end of the interval, in seconds, for which
the metrics
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['SandboxMetric']]
"""
return (
await asyncio_detailed(
sandbox_id=sandbox_id,
client=client,
start=start,
end=end,
)
).parsed
@@ -0,0 +1,230 @@
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.listed_sandbox import ListedSandbox
from ...models.sandbox_state import SandboxState
from ...types import UNSET, Response, Unset
def _get_kwargs(
*,
metadata: Union[Unset, str] = UNSET,
state: Union[Unset, list[SandboxState]] = UNSET,
next_token: Union[Unset, str] = UNSET,
limit: Union[Unset, int] = 100,
) -> dict[str, Any]:
params: dict[str, Any] = {}
params["metadata"] = metadata
json_state: Union[Unset, list[str]] = UNSET
if not isinstance(state, Unset):
json_state = []
for state_item_data in state:
state_item = state_item_data.value
json_state.append(state_item)
if not isinstance(json_state, Unset):
params["state"] = ",".join(str(item) for item in json_state)
params["nextToken"] = next_token
params["limit"] = limit
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": "/v2/sandboxes",
"params": params,
}
return _kwargs
def _parse_response(
*, client: Union[AuthenticatedClient, Client], response: httpx.Response
) -> Optional[Union[Error, list["ListedSandbox"]]]:
if response.status_code == 200:
response_200 = []
_response_200 = response.json()
for response_200_item_data in _response_200:
response_200_item = ListedSandbox.from_dict(response_200_item_data)
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())
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, list["ListedSandbox"]]]:
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,
metadata: Union[Unset, str] = UNSET,
state: Union[Unset, list[SandboxState]] = UNSET,
next_token: Union[Unset, str] = UNSET,
limit: Union[Unset, int] = 100,
) -> Response[Union[Error, list["ListedSandbox"]]]:
"""List all sandboxes
Args:
metadata (Union[Unset, str]):
state (Union[Unset, list[SandboxState]]):
next_token (Union[Unset, str]):
limit (Union[Unset, int]): Default: 100.
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['ListedSandbox']]]
"""
kwargs = _get_kwargs(
metadata=metadata,
state=state,
next_token=next_token,
limit=limit,
)
response = client.get_httpx_client().request(
**kwargs,
)
return _build_response(client=client, response=response)
def sync(
*,
client: AuthenticatedClient,
metadata: Union[Unset, str] = UNSET,
state: Union[Unset, list[SandboxState]] = UNSET,
next_token: Union[Unset, str] = UNSET,
limit: Union[Unset, int] = 100,
) -> Optional[Union[Error, list["ListedSandbox"]]]:
"""List all sandboxes
Args:
metadata (Union[Unset, str]):
state (Union[Unset, list[SandboxState]]):
next_token (Union[Unset, str]):
limit (Union[Unset, int]): Default: 100.
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['ListedSandbox']]
"""
return sync_detailed(
client=client,
metadata=metadata,
state=state,
next_token=next_token,
limit=limit,
).parsed
async def asyncio_detailed(
*,
client: AuthenticatedClient,
metadata: Union[Unset, str] = UNSET,
state: Union[Unset, list[SandboxState]] = UNSET,
next_token: Union[Unset, str] = UNSET,
limit: Union[Unset, int] = 100,
) -> Response[Union[Error, list["ListedSandbox"]]]:
"""List all sandboxes
Args:
metadata (Union[Unset, str]):
state (Union[Unset, list[SandboxState]]):
next_token (Union[Unset, str]):
limit (Union[Unset, int]): Default: 100.
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['ListedSandbox']]]
"""
kwargs = _get_kwargs(
metadata=metadata,
state=state,
next_token=next_token,
limit=limit,
)
response = await client.get_async_httpx_client().request(**kwargs)
return _build_response(client=client, response=response)
async def asyncio(
*,
client: AuthenticatedClient,
metadata: Union[Unset, str] = UNSET,
state: Union[Unset, list[SandboxState]] = UNSET,
next_token: Union[Unset, str] = UNSET,
limit: Union[Unset, int] = 100,
) -> Optional[Union[Error, list["ListedSandbox"]]]:
"""List all sandboxes
Args:
metadata (Union[Unset, str]):
state (Union[Unset, list[SandboxState]]):
next_token (Union[Unset, str]):
limit (Union[Unset, int]): Default: 100.
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['ListedSandbox']]
"""
return (
await asyncio_detailed(
client=client,
metadata=metadata,
state=state,
next_token=next_token,
limit=limit,
)
).parsed
@@ -0,0 +1,254 @@
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.log_level import LogLevel
from ...models.logs_direction import LogsDirection
from ...models.sandbox_logs_v2_response import SandboxLogsV2Response
from ...types import UNSET, Response, Unset
def _get_kwargs(
sandbox_id: str,
*,
cursor: Union[Unset, int] = UNSET,
limit: Union[Unset, int] = 1000,
direction: Union[Unset, LogsDirection] = UNSET,
level: Union[Unset, LogLevel] = UNSET,
search: Union[Unset, str] = UNSET,
) -> dict[str, Any]:
params: dict[str, Any] = {}
params["cursor"] = cursor
params["limit"] = limit
json_direction: Union[Unset, str] = UNSET
if not isinstance(direction, Unset):
json_direction = direction.value
params["direction"] = json_direction
json_level: Union[Unset, str] = UNSET
if not isinstance(level, Unset):
json_level = level.value
params["level"] = json_level
params["search"] = search
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"/v2/sandboxes/{sandbox_id}/logs",
"params": params,
}
return _kwargs
def _parse_response(
*, client: Union[AuthenticatedClient, Client], response: httpx.Response
) -> Optional[Union[Error, SandboxLogsV2Response]]:
if response.status_code == 200:
response_200 = SandboxLogsV2Response.from_dict(response.json())
return response_200
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, SandboxLogsV2Response]]:
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,
cursor: Union[Unset, int] = UNSET,
limit: Union[Unset, int] = 1000,
direction: Union[Unset, LogsDirection] = UNSET,
level: Union[Unset, LogLevel] = UNSET,
search: Union[Unset, str] = UNSET,
) -> Response[Union[Error, SandboxLogsV2Response]]:
"""Get sandbox logs
Args:
sandbox_id (str):
cursor (Union[Unset, int]):
limit (Union[Unset, int]): Default: 1000.
direction (Union[Unset, LogsDirection]): Direction of the logs that should be returned
level (Union[Unset, LogLevel]): State of the sandbox
search (Union[Unset, 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, SandboxLogsV2Response]]
"""
kwargs = _get_kwargs(
sandbox_id=sandbox_id,
cursor=cursor,
limit=limit,
direction=direction,
level=level,
search=search,
)
response = client.get_httpx_client().request(
**kwargs,
)
return _build_response(client=client, response=response)
def sync(
sandbox_id: str,
*,
client: AuthenticatedClient,
cursor: Union[Unset, int] = UNSET,
limit: Union[Unset, int] = 1000,
direction: Union[Unset, LogsDirection] = UNSET,
level: Union[Unset, LogLevel] = UNSET,
search: Union[Unset, str] = UNSET,
) -> Optional[Union[Error, SandboxLogsV2Response]]:
"""Get sandbox logs
Args:
sandbox_id (str):
cursor (Union[Unset, int]):
limit (Union[Unset, int]): Default: 1000.
direction (Union[Unset, LogsDirection]): Direction of the logs that should be returned
level (Union[Unset, LogLevel]): State of the sandbox
search (Union[Unset, 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, SandboxLogsV2Response]
"""
return sync_detailed(
sandbox_id=sandbox_id,
client=client,
cursor=cursor,
limit=limit,
direction=direction,
level=level,
search=search,
).parsed
async def asyncio_detailed(
sandbox_id: str,
*,
client: AuthenticatedClient,
cursor: Union[Unset, int] = UNSET,
limit: Union[Unset, int] = 1000,
direction: Union[Unset, LogsDirection] = UNSET,
level: Union[Unset, LogLevel] = UNSET,
search: Union[Unset, str] = UNSET,
) -> Response[Union[Error, SandboxLogsV2Response]]:
"""Get sandbox logs
Args:
sandbox_id (str):
cursor (Union[Unset, int]):
limit (Union[Unset, int]): Default: 1000.
direction (Union[Unset, LogsDirection]): Direction of the logs that should be returned
level (Union[Unset, LogLevel]): State of the sandbox
search (Union[Unset, 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, SandboxLogsV2Response]]
"""
kwargs = _get_kwargs(
sandbox_id=sandbox_id,
cursor=cursor,
limit=limit,
direction=direction,
level=level,
search=search,
)
response = await client.get_async_httpx_client().request(**kwargs)
return _build_response(client=client, response=response)
async def asyncio(
sandbox_id: str,
*,
client: AuthenticatedClient,
cursor: Union[Unset, int] = UNSET,
limit: Union[Unset, int] = 1000,
direction: Union[Unset, LogsDirection] = UNSET,
level: Union[Unset, LogLevel] = UNSET,
search: Union[Unset, str] = UNSET,
) -> Optional[Union[Error, SandboxLogsV2Response]]:
"""Get sandbox logs
Args:
sandbox_id (str):
cursor (Union[Unset, int]):
limit (Union[Unset, int]): Default: 1000.
direction (Union[Unset, LogsDirection]): Direction of the logs that should be returned
level (Union[Unset, LogLevel]): State of the sandbox
search (Union[Unset, 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, SandboxLogsV2Response]
"""
return (
await asyncio_detailed(
sandbox_id=sandbox_id,
client=client,
cursor=cursor,
limit=limit,
direction=direction,
level=level,
search=search,
)
).parsed
@@ -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.new_sandbox import NewSandbox
from ...models.sandbox import Sandbox
from ...types import Response
def _get_kwargs(
*,
body: NewSandbox,
) -> dict[str, Any]:
headers: dict[str, Any] = {}
_kwargs: dict[str, Any] = {
"method": "post",
"url": "/sandboxes",
}
_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 == 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 == 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(
*,
client: AuthenticatedClient,
body: NewSandbox,
) -> Response[Union[Error, Sandbox]]:
"""Create a sandbox from the template
Args:
body (NewSandbox):
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(
body=body,
)
response = client.get_httpx_client().request(
**kwargs,
)
return _build_response(client=client, response=response)
def sync(
*,
client: AuthenticatedClient,
body: NewSandbox,
) -> Optional[Union[Error, Sandbox]]:
"""Create a sandbox from the template
Args:
body (NewSandbox):
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(
client=client,
body=body,
).parsed
async def asyncio_detailed(
*,
client: AuthenticatedClient,
body: NewSandbox,
) -> Response[Union[Error, Sandbox]]:
"""Create a sandbox from the template
Args:
body (NewSandbox):
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(
body=body,
)
response = await client.get_async_httpx_client().request(**kwargs)
return _build_response(client=client, response=response)
async def asyncio(
*,
client: AuthenticatedClient,
body: NewSandbox,
) -> Optional[Union[Error, Sandbox]]:
"""Create a sandbox from the template
Args:
body (NewSandbox):
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(
client=client,
body=body,
)
).parsed
@@ -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
@@ -0,0 +1,187 @@
from http import HTTPStatus
from typing import Any, Optional, Union, cast
import httpx
from ... import errors
from ...client import AuthenticatedClient, Client
from ...models.error import Error
from ...models.sandbox_pause_request import SandboxPauseRequest
from ...types import Response
def _get_kwargs(
sandbox_id: str,
*,
body: SandboxPauseRequest,
) -> dict[str, Any]:
headers: dict[str, Any] = {}
_kwargs: dict[str, Any] = {
"method": "post",
"url": f"/sandboxes/{sandbox_id}/pause",
}
_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[Any, Error]]:
if response.status_code == 204:
response_204 = cast(Any, None)
return response_204
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 == 409:
response_409 = Error.from_dict(response.json())
return response_409
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[Any, Error]]:
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: SandboxPauseRequest,
) -> Response[Union[Any, Error]]:
"""Pause the sandbox
Args:
sandbox_id (str):
body (SandboxPauseRequest):
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[Any, Error]]
"""
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: SandboxPauseRequest,
) -> Optional[Union[Any, Error]]:
"""Pause the sandbox
Args:
sandbox_id (str):
body (SandboxPauseRequest):
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[Any, Error]
"""
return sync_detailed(
sandbox_id=sandbox_id,
client=client,
body=body,
).parsed
async def asyncio_detailed(
sandbox_id: str,
*,
client: AuthenticatedClient,
body: SandboxPauseRequest,
) -> Response[Union[Any, Error]]:
"""Pause the sandbox
Args:
sandbox_id (str):
body (SandboxPauseRequest):
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[Any, Error]]
"""
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: SandboxPauseRequest,
) -> Optional[Union[Any, Error]]:
"""Pause the sandbox
Args:
sandbox_id (str):
body (SandboxPauseRequest):
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[Any, Error]
"""
return (
await asyncio_detailed(
sandbox_id=sandbox_id,
client=client,
body=body,
)
).parsed
@@ -0,0 +1,181 @@
from http import HTTPStatus
from typing import Any, Optional, Union, cast
import httpx
from ... import errors
from ...client import AuthenticatedClient, Client
from ...models.error import Error
from ...models.post_sandboxes_sandbox_id_refreshes_body import (
PostSandboxesSandboxIDRefreshesBody,
)
from ...types import Response
def _get_kwargs(
sandbox_id: str,
*,
body: PostSandboxesSandboxIDRefreshesBody,
) -> dict[str, Any]:
headers: dict[str, Any] = {}
_kwargs: dict[str, Any] = {
"method": "post",
"url": f"/sandboxes/{sandbox_id}/refreshes",
}
_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[Any, Error]]:
if response.status_code == 204:
response_204 = cast(Any, None)
return response_204
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 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[Any, Error]]:
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: PostSandboxesSandboxIDRefreshesBody,
) -> Response[Union[Any, Error]]:
"""Refresh the sandbox extending its time to live
Args:
sandbox_id (str):
body (PostSandboxesSandboxIDRefreshesBody):
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[Any, Error]]
"""
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: PostSandboxesSandboxIDRefreshesBody,
) -> Optional[Union[Any, Error]]:
"""Refresh the sandbox extending its time to live
Args:
sandbox_id (str):
body (PostSandboxesSandboxIDRefreshesBody):
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[Any, Error]
"""
return sync_detailed(
sandbox_id=sandbox_id,
client=client,
body=body,
).parsed
async def asyncio_detailed(
sandbox_id: str,
*,
client: AuthenticatedClient,
body: PostSandboxesSandboxIDRefreshesBody,
) -> Response[Union[Any, Error]]:
"""Refresh the sandbox extending its time to live
Args:
sandbox_id (str):
body (PostSandboxesSandboxIDRefreshesBody):
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[Any, Error]]
"""
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: PostSandboxesSandboxIDRefreshesBody,
) -> Optional[Union[Any, Error]]:
"""Refresh the sandbox extending its time to live
Args:
sandbox_id (str):
body (PostSandboxesSandboxIDRefreshesBody):
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[Any, Error]
"""
return (
await asyncio_detailed(
sandbox_id=sandbox_id,
client=client,
body=body,
)
).parsed
@@ -0,0 +1,189 @@
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.resumed_sandbox import ResumedSandbox
from ...models.sandbox import Sandbox
from ...types import Response
def _get_kwargs(
sandbox_id: str,
*,
body: ResumedSandbox,
) -> dict[str, Any]:
headers: dict[str, Any] = {}
_kwargs: dict[str, Any] = {
"method": "post",
"url": f"/sandboxes/{sandbox_id}/resume",
}
_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 == 201:
response_201 = Sandbox.from_dict(response.json())
return response_201
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 == 409:
response_409 = Error.from_dict(response.json())
return response_409
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: ResumedSandbox,
) -> Response[Union[Error, Sandbox]]:
"""Resume the sandbox
Args:
sandbox_id (str):
body (ResumedSandbox):
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: ResumedSandbox,
) -> Optional[Union[Error, Sandbox]]:
"""Resume the sandbox
Args:
sandbox_id (str):
body (ResumedSandbox):
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: ResumedSandbox,
) -> Response[Union[Error, Sandbox]]:
"""Resume the sandbox
Args:
sandbox_id (str):
body (ResumedSandbox):
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: ResumedSandbox,
) -> Optional[Union[Error, Sandbox]]:
"""Resume the sandbox
Args:
sandbox_id (str):
body (ResumedSandbox):
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
@@ -0,0 +1,195 @@
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.post_sandboxes_sandbox_id_snapshots_body import (
PostSandboxesSandboxIDSnapshotsBody,
)
from ...models.snapshot_info import SnapshotInfo
from ...types import Response
def _get_kwargs(
sandbox_id: str,
*,
body: PostSandboxesSandboxIDSnapshotsBody,
) -> dict[str, Any]:
headers: dict[str, Any] = {}
_kwargs: dict[str, Any] = {
"method": "post",
"url": f"/sandboxes/{sandbox_id}/snapshots",
}
_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, SnapshotInfo]]:
if response.status_code == 201:
response_201 = SnapshotInfo.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, SnapshotInfo]]:
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: PostSandboxesSandboxIDSnapshotsBody,
) -> Response[Union[Error, SnapshotInfo]]:
"""Create a persistent snapshot from the sandbox's current state. Snapshots can be used to create new
sandboxes and persist beyond the original sandbox's lifetime.
Args:
sandbox_id (str):
body (PostSandboxesSandboxIDSnapshotsBody):
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, SnapshotInfo]]
"""
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: PostSandboxesSandboxIDSnapshotsBody,
) -> Optional[Union[Error, SnapshotInfo]]:
"""Create a persistent snapshot from the sandbox's current state. Snapshots can be used to create new
sandboxes and persist beyond the original sandbox's lifetime.
Args:
sandbox_id (str):
body (PostSandboxesSandboxIDSnapshotsBody):
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, SnapshotInfo]
"""
return sync_detailed(
sandbox_id=sandbox_id,
client=client,
body=body,
).parsed
async def asyncio_detailed(
sandbox_id: str,
*,
client: AuthenticatedClient,
body: PostSandboxesSandboxIDSnapshotsBody,
) -> Response[Union[Error, SnapshotInfo]]:
"""Create a persistent snapshot from the sandbox's current state. Snapshots can be used to create new
sandboxes and persist beyond the original sandbox's lifetime.
Args:
sandbox_id (str):
body (PostSandboxesSandboxIDSnapshotsBody):
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, SnapshotInfo]]
"""
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: PostSandboxesSandboxIDSnapshotsBody,
) -> Optional[Union[Error, SnapshotInfo]]:
"""Create a persistent snapshot from the sandbox's current state. Snapshots can be used to create new
sandboxes and persist beyond the original sandbox's lifetime.
Args:
sandbox_id (str):
body (PostSandboxesSandboxIDSnapshotsBody):
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, SnapshotInfo]
"""
return (
await asyncio_detailed(
sandbox_id=sandbox_id,
client=client,
body=body,
)
).parsed
@@ -0,0 +1,193 @@
from http import HTTPStatus
from typing import Any, Optional, Union, cast
import httpx
from ... import errors
from ...client import AuthenticatedClient, Client
from ...models.error import Error
from ...models.post_sandboxes_sandbox_id_timeout_body import (
PostSandboxesSandboxIDTimeoutBody,
)
from ...types import Response
def _get_kwargs(
sandbox_id: str,
*,
body: PostSandboxesSandboxIDTimeoutBody,
) -> dict[str, Any]:
headers: dict[str, Any] = {}
_kwargs: dict[str, Any] = {
"method": "post",
"url": f"/sandboxes/{sandbox_id}/timeout",
}
_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[Any, Error]]:
if response.status_code == 204:
response_204 = cast(Any, None)
return response_204
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[Any, Error]]:
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: PostSandboxesSandboxIDTimeoutBody,
) -> Response[Union[Any, Error]]:
"""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.
Args:
sandbox_id (str):
body (PostSandboxesSandboxIDTimeoutBody):
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[Any, Error]]
"""
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: PostSandboxesSandboxIDTimeoutBody,
) -> Optional[Union[Any, Error]]:
"""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.
Args:
sandbox_id (str):
body (PostSandboxesSandboxIDTimeoutBody):
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[Any, Error]
"""
return sync_detailed(
sandbox_id=sandbox_id,
client=client,
body=body,
).parsed
async def asyncio_detailed(
sandbox_id: str,
*,
client: AuthenticatedClient,
body: PostSandboxesSandboxIDTimeoutBody,
) -> Response[Union[Any, Error]]:
"""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.
Args:
sandbox_id (str):
body (PostSandboxesSandboxIDTimeoutBody):
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[Any, Error]]
"""
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: PostSandboxesSandboxIDTimeoutBody,
) -> Optional[Union[Any, Error]]:
"""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.
Args:
sandbox_id (str):
body (PostSandboxesSandboxIDTimeoutBody):
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[Any, Error]
"""
return (
await asyncio_detailed(
sandbox_id=sandbox_id,
client=client,
body=body,
)
).parsed
@@ -0,0 +1,199 @@
from http import HTTPStatus
from typing import Any, Optional, Union, cast
import httpx
from ... import errors
from ...client import AuthenticatedClient, Client
from ...models.error import Error
from ...models.sandbox_network_update_config import SandboxNetworkUpdateConfig
from ...types import Response
def _get_kwargs(
sandbox_id: str,
*,
body: SandboxNetworkUpdateConfig,
) -> dict[str, Any]:
headers: dict[str, Any] = {}
_kwargs: dict[str, Any] = {
"method": "put",
"url": f"/sandboxes/{sandbox_id}/network",
}
_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[Any, Error]]:
if response.status_code == 204:
response_204 = cast(Any, None)
return response_204
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 == 409:
response_409 = Error.from_dict(response.json())
return response_409
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[Any, Error]]:
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: SandboxNetworkUpdateConfig,
) -> Response[Union[Any, Error]]:
"""Update the network configuration for a running sandbox. Replaces the current egress rules with the
provided configuration. Omitting field clears it.
Args:
sandbox_id (str):
body (SandboxNetworkUpdateConfig): Network configuration update for a running sandbox.
Replaces the current egress rules with the provided configuration. Omitting a field clears
it.
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[Any, Error]]
"""
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: SandboxNetworkUpdateConfig,
) -> Optional[Union[Any, Error]]:
"""Update the network configuration for a running sandbox. Replaces the current egress rules with the
provided configuration. Omitting field clears it.
Args:
sandbox_id (str):
body (SandboxNetworkUpdateConfig): Network configuration update for a running sandbox.
Replaces the current egress rules with the provided configuration. Omitting a field clears
it.
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[Any, Error]
"""
return sync_detailed(
sandbox_id=sandbox_id,
client=client,
body=body,
).parsed
async def asyncio_detailed(
sandbox_id: str,
*,
client: AuthenticatedClient,
body: SandboxNetworkUpdateConfig,
) -> Response[Union[Any, Error]]:
"""Update the network configuration for a running sandbox. Replaces the current egress rules with the
provided configuration. Omitting field clears it.
Args:
sandbox_id (str):
body (SandboxNetworkUpdateConfig): Network configuration update for a running sandbox.
Replaces the current egress rules with the provided configuration. Omitting a field clears
it.
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[Any, Error]]
"""
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: SandboxNetworkUpdateConfig,
) -> Optional[Union[Any, Error]]:
"""Update the network configuration for a running sandbox. Replaces the current egress rules with the
provided configuration. Omitting field clears it.
Args:
sandbox_id (str):
body (SandboxNetworkUpdateConfig): Network configuration update for a running sandbox.
Replaces the current egress rules with the provided configuration. Omitting a field clears
it.
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[Any, Error]
"""
return (
await asyncio_detailed(
sandbox_id=sandbox_id,
client=client,
body=body,
)
).parsed
@@ -0,0 +1 @@
"""Contains endpoint functions for accessing the API"""
@@ -0,0 +1,202 @@
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.snapshot_info import SnapshotInfo
from ...types import UNSET, Response, Unset
def _get_kwargs(
*,
sandbox_id: Union[Unset, str] = UNSET,
limit: Union[Unset, int] = 100,
next_token: Union[Unset, str] = UNSET,
) -> dict[str, Any]:
params: dict[str, Any] = {}
params["sandboxID"] = sandbox_id
params["limit"] = limit
params["nextToken"] = next_token
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": "/snapshots",
"params": params,
}
return _kwargs
def _parse_response(
*, client: Union[AuthenticatedClient, Client], response: httpx.Response
) -> Optional[Union[Error, list["SnapshotInfo"]]]:
if response.status_code == 200:
response_200 = []
_response_200 = response.json()
for response_200_item_data in _response_200:
response_200_item = SnapshotInfo.from_dict(response_200_item_data)
response_200.append(response_200_item)
return response_200
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, list["SnapshotInfo"]]]:
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,
sandbox_id: Union[Unset, str] = UNSET,
limit: Union[Unset, int] = 100,
next_token: Union[Unset, str] = UNSET,
) -> Response[Union[Error, list["SnapshotInfo"]]]:
"""List all snapshots for the team
Args:
sandbox_id (Union[Unset, str]): Filter snapshots by source sandbox ID
limit (Union[Unset, int]): Default: 100.
next_token (Union[Unset, 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['SnapshotInfo']]]
"""
kwargs = _get_kwargs(
sandbox_id=sandbox_id,
limit=limit,
next_token=next_token,
)
response = client.get_httpx_client().request(
**kwargs,
)
return _build_response(client=client, response=response)
def sync(
*,
client: AuthenticatedClient,
sandbox_id: Union[Unset, str] = UNSET,
limit: Union[Unset, int] = 100,
next_token: Union[Unset, str] = UNSET,
) -> Optional[Union[Error, list["SnapshotInfo"]]]:
"""List all snapshots for the team
Args:
sandbox_id (Union[Unset, str]): Filter snapshots by source sandbox ID
limit (Union[Unset, int]): Default: 100.
next_token (Union[Unset, 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['SnapshotInfo']]
"""
return sync_detailed(
client=client,
sandbox_id=sandbox_id,
limit=limit,
next_token=next_token,
).parsed
async def asyncio_detailed(
*,
client: AuthenticatedClient,
sandbox_id: Union[Unset, str] = UNSET,
limit: Union[Unset, int] = 100,
next_token: Union[Unset, str] = UNSET,
) -> Response[Union[Error, list["SnapshotInfo"]]]:
"""List all snapshots for the team
Args:
sandbox_id (Union[Unset, str]): Filter snapshots by source sandbox ID
limit (Union[Unset, int]): Default: 100.
next_token (Union[Unset, 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['SnapshotInfo']]]
"""
kwargs = _get_kwargs(
sandbox_id=sandbox_id,
limit=limit,
next_token=next_token,
)
response = await client.get_async_httpx_client().request(**kwargs)
return _build_response(client=client, response=response)
async def asyncio(
*,
client: AuthenticatedClient,
sandbox_id: Union[Unset, str] = UNSET,
limit: Union[Unset, int] = 100,
next_token: Union[Unset, str] = UNSET,
) -> Optional[Union[Error, list["SnapshotInfo"]]]:
"""List all snapshots for the team
Args:
sandbox_id (Union[Unset, str]): Filter snapshots by source sandbox ID
limit (Union[Unset, int]): Default: 100.
next_token (Union[Unset, 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['SnapshotInfo']]
"""
return (
await asyncio_detailed(
client=client,
sandbox_id=sandbox_id,
limit=limit,
next_token=next_token,
)
).parsed
+1
View File
@@ -0,0 +1 @@
"""Contains endpoint functions for accessing the API"""
@@ -0,0 +1,174 @@
from http import HTTPStatus
from typing import Any, Optional, Union, cast
import httpx
from ... import errors
from ...client import AuthenticatedClient, Client
from ...models.delete_template_tags_request import DeleteTemplateTagsRequest
from ...models.error import Error
from ...types import Response
def _get_kwargs(
*,
body: DeleteTemplateTagsRequest,
) -> dict[str, Any]:
headers: dict[str, Any] = {}
_kwargs: dict[str, Any] = {
"method": "delete",
"url": "/templates/tags",
}
_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[Any, Error]]:
if response.status_code == 204:
response_204 = cast(Any, None)
return response_204
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[Any, Error]]:
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: DeleteTemplateTagsRequest,
) -> Response[Union[Any, Error]]:
"""Delete multiple tags from templates
Args:
body (DeleteTemplateTagsRequest):
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[Any, Error]]
"""
kwargs = _get_kwargs(
body=body,
)
response = client.get_httpx_client().request(
**kwargs,
)
return _build_response(client=client, response=response)
def sync(
*,
client: AuthenticatedClient,
body: DeleteTemplateTagsRequest,
) -> Optional[Union[Any, Error]]:
"""Delete multiple tags from templates
Args:
body (DeleteTemplateTagsRequest):
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[Any, Error]
"""
return sync_detailed(
client=client,
body=body,
).parsed
async def asyncio_detailed(
*,
client: AuthenticatedClient,
body: DeleteTemplateTagsRequest,
) -> Response[Union[Any, Error]]:
"""Delete multiple tags from templates
Args:
body (DeleteTemplateTagsRequest):
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[Any, Error]]
"""
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: DeleteTemplateTagsRequest,
) -> Optional[Union[Any, Error]]:
"""Delete multiple tags from templates
Args:
body (DeleteTemplateTagsRequest):
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[Any, Error]
"""
return (
await asyncio_detailed(
client=client,
body=body,
)
).parsed
@@ -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_tag import TemplateTag
from ...types import Response
def _get_kwargs(
template_id: str,
) -> dict[str, Any]:
_kwargs: dict[str, Any] = {
"method": "get",
"url": f"/templates/{template_id}/tags",
}
return _kwargs
def _parse_response(
*, client: Union[AuthenticatedClient, Client], response: httpx.Response
) -> Optional[Union[Error, list["TemplateTag"]]]:
if response.status_code == 200:
response_200 = []
_response_200 = response.json()
for response_200_item_data in _response_200:
response_200_item = TemplateTag.from_dict(response_200_item_data)
response_200.append(response_200_item)
return response_200
if response.status_code == 401:
response_401 = Error.from_dict(response.json())
return response_401
if response.status_code == 403:
response_403 = Error.from_dict(response.json())
return response_403
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, list["TemplateTag"]]]:
return Response(
status_code=HTTPStatus(response.status_code),
content=response.content,
headers=response.headers,
parsed=_parse_response(client=client, response=response),
)
def sync_detailed(
template_id: str,
*,
client: AuthenticatedClient,
) -> Response[Union[Error, list["TemplateTag"]]]:
"""List all tags for a template
Args:
template_id (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['TemplateTag']]]
"""
kwargs = _get_kwargs(
template_id=template_id,
)
response = client.get_httpx_client().request(
**kwargs,
)
return _build_response(client=client, response=response)
def sync(
template_id: str,
*,
client: AuthenticatedClient,
) -> Optional[Union[Error, list["TemplateTag"]]]:
"""List all tags for a template
Args:
template_id (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['TemplateTag']]
"""
return sync_detailed(
template_id=template_id,
client=client,
).parsed
async def asyncio_detailed(
template_id: str,
*,
client: AuthenticatedClient,
) -> Response[Union[Error, list["TemplateTag"]]]:
"""List all tags for a template
Args:
template_id (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['TemplateTag']]]
"""
kwargs = _get_kwargs(
template_id=template_id,
)
response = await client.get_async_httpx_client().request(**kwargs)
return _build_response(client=client, response=response)
async def asyncio(
template_id: str,
*,
client: AuthenticatedClient,
) -> Optional[Union[Error, list["TemplateTag"]]]:
"""List all tags for a template
Args:
template_id (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['TemplateTag']]
"""
return (
await asyncio_detailed(
template_id=template_id,
client=client,
)
).parsed
@@ -0,0 +1,176 @@
from http import HTTPStatus
from typing import Any, Optional, Union
import httpx
from ... import errors
from ...client import AuthenticatedClient, Client
from ...models.assign_template_tags_request import AssignTemplateTagsRequest
from ...models.assigned_template_tags import AssignedTemplateTags
from ...models.error import Error
from ...types import Response
def _get_kwargs(
*,
body: AssignTemplateTagsRequest,
) -> dict[str, Any]:
headers: dict[str, Any] = {}
_kwargs: dict[str, Any] = {
"method": "post",
"url": "/templates/tags",
}
_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[AssignedTemplateTags, Error]]:
if response.status_code == 201:
response_201 = AssignedTemplateTags.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[AssignedTemplateTags, Error]]:
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: AssignTemplateTagsRequest,
) -> Response[Union[AssignedTemplateTags, Error]]:
"""Assign tag(s) to a template build
Args:
body (AssignTemplateTagsRequest):
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[AssignedTemplateTags, Error]]
"""
kwargs = _get_kwargs(
body=body,
)
response = client.get_httpx_client().request(
**kwargs,
)
return _build_response(client=client, response=response)
def sync(
*,
client: AuthenticatedClient,
body: AssignTemplateTagsRequest,
) -> Optional[Union[AssignedTemplateTags, Error]]:
"""Assign tag(s) to a template build
Args:
body (AssignTemplateTagsRequest):
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[AssignedTemplateTags, Error]
"""
return sync_detailed(
client=client,
body=body,
).parsed
async def asyncio_detailed(
*,
client: AuthenticatedClient,
body: AssignTemplateTagsRequest,
) -> Response[Union[AssignedTemplateTags, Error]]:
"""Assign tag(s) to a template build
Args:
body (AssignTemplateTagsRequest):
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[AssignedTemplateTags, Error]]
"""
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: AssignTemplateTagsRequest,
) -> Optional[Union[AssignedTemplateTags, Error]]:
"""Assign tag(s) to a template build
Args:
body (AssignTemplateTagsRequest):
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[AssignedTemplateTags, Error]
"""
return (
await asyncio_detailed(
client=client,
body=body,
)
).parsed
@@ -0,0 +1 @@
"""Contains endpoint functions for accessing the API"""
@@ -0,0 +1,157 @@
from http import HTTPStatus
from typing import Any, Optional, Union, cast
import httpx
from ... import errors
from ...client import AuthenticatedClient, Client
from ...models.error import Error
from ...types import Response
def _get_kwargs(
template_id: str,
) -> dict[str, Any]:
_kwargs: dict[str, Any] = {
"method": "delete",
"url": f"/templates/{template_id}",
}
return _kwargs
def _parse_response(
*, client: Union[AuthenticatedClient, Client], response: httpx.Response
) -> Optional[Union[Any, Error]]:
if response.status_code == 204:
response_204 = cast(Any, None)
return response_204
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[Any, Error]]:
return Response(
status_code=HTTPStatus(response.status_code),
content=response.content,
headers=response.headers,
parsed=_parse_response(client=client, response=response),
)
def sync_detailed(
template_id: str,
*,
client: AuthenticatedClient,
) -> Response[Union[Any, Error]]:
"""Delete a template
Args:
template_id (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[Any, Error]]
"""
kwargs = _get_kwargs(
template_id=template_id,
)
response = client.get_httpx_client().request(
**kwargs,
)
return _build_response(client=client, response=response)
def sync(
template_id: str,
*,
client: AuthenticatedClient,
) -> Optional[Union[Any, Error]]:
"""Delete a template
Args:
template_id (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[Any, Error]
"""
return sync_detailed(
template_id=template_id,
client=client,
).parsed
async def asyncio_detailed(
template_id: str,
*,
client: AuthenticatedClient,
) -> Response[Union[Any, Error]]:
"""Delete a template
Args:
template_id (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[Any, Error]]
"""
kwargs = _get_kwargs(
template_id=template_id,
)
response = await client.get_async_httpx_client().request(**kwargs)
return _build_response(client=client, response=response)
async def asyncio(
template_id: str,
*,
client: AuthenticatedClient,
) -> Optional[Union[Any, Error]]:
"""Delete a template
Args:
template_id (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[Any, Error]
"""
return (
await asyncio_detailed(
template_id=template_id,
client=client,
)
).parsed
@@ -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 import Template
from ...types import UNSET, Response, Unset
def _get_kwargs(
*,
team_id: Union[Unset, str] = UNSET,
) -> dict[str, Any]:
params: dict[str, Any] = {}
params["teamID"] = team_id
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": "/templates",
"params": params,
}
return _kwargs
def _parse_response(
*, client: Union[AuthenticatedClient, Client], response: httpx.Response
) -> Optional[Union[Error, list["Template"]]]:
if response.status_code == 200:
response_200 = []
_response_200 = response.json()
for response_200_item_data in _response_200:
response_200_item = Template.from_dict(response_200_item_data)
response_200.append(response_200_item)
return response_200
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, list["Template"]]]:
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,
team_id: Union[Unset, str] = UNSET,
) -> Response[Union[Error, list["Template"]]]:
"""List all templates
Args:
team_id (Union[Unset, str]): Identifier of the team
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['Template']]]
"""
kwargs = _get_kwargs(
team_id=team_id,
)
response = client.get_httpx_client().request(
**kwargs,
)
return _build_response(client=client, response=response)
def sync(
*,
client: AuthenticatedClient,
team_id: Union[Unset, str] = UNSET,
) -> Optional[Union[Error, list["Template"]]]:
"""List all templates
Args:
team_id (Union[Unset, str]): Identifier of the team
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['Template']]
"""
return sync_detailed(
client=client,
team_id=team_id,
).parsed
async def asyncio_detailed(
*,
client: AuthenticatedClient,
team_id: Union[Unset, str] = UNSET,
) -> Response[Union[Error, list["Template"]]]:
"""List all templates
Args:
team_id (Union[Unset, str]): Identifier of the team
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['Template']]]
"""
kwargs = _get_kwargs(
team_id=team_id,
)
response = await client.get_async_httpx_client().request(**kwargs)
return _build_response(client=client, response=response)
async def asyncio(
*,
client: AuthenticatedClient,
team_id: Union[Unset, str] = UNSET,
) -> Optional[Union[Error, list["Template"]]]:
"""List all templates
Args:
team_id (Union[Unset, str]): Identifier of the team
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['Template']]
"""
return (
await asyncio_detailed(
client=client,
team_id=team_id,
)
).parsed
@@ -0,0 +1,167 @@
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_alias_response import TemplateAliasResponse
from ...types import Response
def _get_kwargs(
alias: str,
) -> dict[str, Any]:
_kwargs: dict[str, Any] = {
"method": "get",
"url": f"/templates/aliases/{alias}",
}
return _kwargs
def _parse_response(
*, client: Union[AuthenticatedClient, Client], response: httpx.Response
) -> Optional[Union[Error, TemplateAliasResponse]]:
if response.status_code == 200:
response_200 = TemplateAliasResponse.from_dict(response.json())
return response_200
if response.status_code == 400:
response_400 = Error.from_dict(response.json())
return response_400
if response.status_code == 403:
response_403 = Error.from_dict(response.json())
return response_403
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, TemplateAliasResponse]]:
return Response(
status_code=HTTPStatus(response.status_code),
content=response.content,
headers=response.headers,
parsed=_parse_response(client=client, response=response),
)
def sync_detailed(
alias: str,
*,
client: AuthenticatedClient,
) -> Response[Union[Error, TemplateAliasResponse]]:
"""Check if template with given alias exists
Args:
alias (str): Template alias
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, TemplateAliasResponse]]
"""
kwargs = _get_kwargs(
alias=alias,
)
response = client.get_httpx_client().request(
**kwargs,
)
return _build_response(client=client, response=response)
def sync(
alias: str,
*,
client: AuthenticatedClient,
) -> Optional[Union[Error, TemplateAliasResponse]]:
"""Check if template with given alias exists
Args:
alias (str): Template alias
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, TemplateAliasResponse]
"""
return sync_detailed(
alias=alias,
client=client,
).parsed
async def asyncio_detailed(
alias: str,
*,
client: AuthenticatedClient,
) -> Response[Union[Error, TemplateAliasResponse]]:
"""Check if template with given alias exists
Args:
alias (str): Template alias
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, TemplateAliasResponse]]
"""
kwargs = _get_kwargs(
alias=alias,
)
response = await client.get_async_httpx_client().request(**kwargs)
return _build_response(client=client, response=response)
async def asyncio(
alias: str,
*,
client: AuthenticatedClient,
) -> Optional[Union[Error, TemplateAliasResponse]]:
"""Check if template with given alias exists
Args:
alias (str): Template alias
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, TemplateAliasResponse]
"""
return (
await asyncio_detailed(
alias=alias,
client=client,
)
).parsed
@@ -0,0 +1,195 @@
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_with_builds import TemplateWithBuilds
from ...types import UNSET, Response, Unset
def _get_kwargs(
template_id: str,
*,
next_token: Union[Unset, str] = UNSET,
limit: Union[Unset, int] = 100,
) -> dict[str, Any]:
params: dict[str, Any] = {}
params["nextToken"] = next_token
params["limit"] = limit
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"/templates/{template_id}",
"params": params,
}
return _kwargs
def _parse_response(
*, client: Union[AuthenticatedClient, Client], response: httpx.Response
) -> Optional[Union[Error, TemplateWithBuilds]]:
if response.status_code == 200:
response_200 = TemplateWithBuilds.from_dict(response.json())
return response_200
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, TemplateWithBuilds]]:
return Response(
status_code=HTTPStatus(response.status_code),
content=response.content,
headers=response.headers,
parsed=_parse_response(client=client, response=response),
)
def sync_detailed(
template_id: str,
*,
client: AuthenticatedClient,
next_token: Union[Unset, str] = UNSET,
limit: Union[Unset, int] = 100,
) -> Response[Union[Error, TemplateWithBuilds]]:
"""List all builds for a template
Args:
template_id (str):
next_token (Union[Unset, str]):
limit (Union[Unset, int]): Default: 100.
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, TemplateWithBuilds]]
"""
kwargs = _get_kwargs(
template_id=template_id,
next_token=next_token,
limit=limit,
)
response = client.get_httpx_client().request(
**kwargs,
)
return _build_response(client=client, response=response)
def sync(
template_id: str,
*,
client: AuthenticatedClient,
next_token: Union[Unset, str] = UNSET,
limit: Union[Unset, int] = 100,
) -> Optional[Union[Error, TemplateWithBuilds]]:
"""List all builds for a template
Args:
template_id (str):
next_token (Union[Unset, str]):
limit (Union[Unset, int]): Default: 100.
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, TemplateWithBuilds]
"""
return sync_detailed(
template_id=template_id,
client=client,
next_token=next_token,
limit=limit,
).parsed
async def asyncio_detailed(
template_id: str,
*,
client: AuthenticatedClient,
next_token: Union[Unset, str] = UNSET,
limit: Union[Unset, int] = 100,
) -> Response[Union[Error, TemplateWithBuilds]]:
"""List all builds for a template
Args:
template_id (str):
next_token (Union[Unset, str]):
limit (Union[Unset, int]): Default: 100.
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, TemplateWithBuilds]]
"""
kwargs = _get_kwargs(
template_id=template_id,
next_token=next_token,
limit=limit,
)
response = await client.get_async_httpx_client().request(**kwargs)
return _build_response(client=client, response=response)
async def asyncio(
template_id: str,
*,
client: AuthenticatedClient,
next_token: Union[Unset, str] = UNSET,
limit: Union[Unset, int] = 100,
) -> Optional[Union[Error, TemplateWithBuilds]]:
"""List all builds for a template
Args:
template_id (str):
next_token (Union[Unset, str]):
limit (Union[Unset, int]): Default: 100.
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, TemplateWithBuilds]
"""
return (
await asyncio_detailed(
template_id=template_id,
client=client,
next_token=next_token,
limit=limit,
)
).parsed
@@ -0,0 +1,272 @@
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.log_level import LogLevel
from ...models.logs_direction import LogsDirection
from ...models.logs_source import LogsSource
from ...models.template_build_logs_response import TemplateBuildLogsResponse
from ...types import UNSET, Response, Unset
def _get_kwargs(
template_id: str,
build_id: str,
*,
cursor: Union[Unset, int] = UNSET,
limit: Union[Unset, int] = 100,
direction: Union[Unset, LogsDirection] = UNSET,
level: Union[Unset, LogLevel] = UNSET,
source: Union[Unset, LogsSource] = UNSET,
) -> dict[str, Any]:
params: dict[str, Any] = {}
params["cursor"] = cursor
params["limit"] = limit
json_direction: Union[Unset, str] = UNSET
if not isinstance(direction, Unset):
json_direction = direction.value
params["direction"] = json_direction
json_level: Union[Unset, str] = UNSET
if not isinstance(level, Unset):
json_level = level.value
params["level"] = json_level
json_source: Union[Unset, str] = UNSET
if not isinstance(source, Unset):
json_source = source.value
params["source"] = json_source
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"/templates/{template_id}/builds/{build_id}/logs",
"params": params,
}
return _kwargs
def _parse_response(
*, client: Union[AuthenticatedClient, Client], response: httpx.Response
) -> Optional[Union[Error, TemplateBuildLogsResponse]]:
if response.status_code == 200:
response_200 = TemplateBuildLogsResponse.from_dict(response.json())
return response_200
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, TemplateBuildLogsResponse]]:
return Response(
status_code=HTTPStatus(response.status_code),
content=response.content,
headers=response.headers,
parsed=_parse_response(client=client, response=response),
)
def sync_detailed(
template_id: str,
build_id: str,
*,
client: AuthenticatedClient,
cursor: Union[Unset, int] = UNSET,
limit: Union[Unset, int] = 100,
direction: Union[Unset, LogsDirection] = UNSET,
level: Union[Unset, LogLevel] = UNSET,
source: Union[Unset, LogsSource] = UNSET,
) -> Response[Union[Error, TemplateBuildLogsResponse]]:
"""Get template build logs
Args:
template_id (str):
build_id (str):
cursor (Union[Unset, int]):
limit (Union[Unset, int]): Default: 100.
direction (Union[Unset, LogsDirection]): Direction of the logs that should be returned
level (Union[Unset, LogLevel]): State of the sandbox
source (Union[Unset, LogsSource]): Source of the logs that should be returned
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, TemplateBuildLogsResponse]]
"""
kwargs = _get_kwargs(
template_id=template_id,
build_id=build_id,
cursor=cursor,
limit=limit,
direction=direction,
level=level,
source=source,
)
response = client.get_httpx_client().request(
**kwargs,
)
return _build_response(client=client, response=response)
def sync(
template_id: str,
build_id: str,
*,
client: AuthenticatedClient,
cursor: Union[Unset, int] = UNSET,
limit: Union[Unset, int] = 100,
direction: Union[Unset, LogsDirection] = UNSET,
level: Union[Unset, LogLevel] = UNSET,
source: Union[Unset, LogsSource] = UNSET,
) -> Optional[Union[Error, TemplateBuildLogsResponse]]:
"""Get template build logs
Args:
template_id (str):
build_id (str):
cursor (Union[Unset, int]):
limit (Union[Unset, int]): Default: 100.
direction (Union[Unset, LogsDirection]): Direction of the logs that should be returned
level (Union[Unset, LogLevel]): State of the sandbox
source (Union[Unset, LogsSource]): Source of the logs that should be returned
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, TemplateBuildLogsResponse]
"""
return sync_detailed(
template_id=template_id,
build_id=build_id,
client=client,
cursor=cursor,
limit=limit,
direction=direction,
level=level,
source=source,
).parsed
async def asyncio_detailed(
template_id: str,
build_id: str,
*,
client: AuthenticatedClient,
cursor: Union[Unset, int] = UNSET,
limit: Union[Unset, int] = 100,
direction: Union[Unset, LogsDirection] = UNSET,
level: Union[Unset, LogLevel] = UNSET,
source: Union[Unset, LogsSource] = UNSET,
) -> Response[Union[Error, TemplateBuildLogsResponse]]:
"""Get template build logs
Args:
template_id (str):
build_id (str):
cursor (Union[Unset, int]):
limit (Union[Unset, int]): Default: 100.
direction (Union[Unset, LogsDirection]): Direction of the logs that should be returned
level (Union[Unset, LogLevel]): State of the sandbox
source (Union[Unset, LogsSource]): Source of the logs that should be returned
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, TemplateBuildLogsResponse]]
"""
kwargs = _get_kwargs(
template_id=template_id,
build_id=build_id,
cursor=cursor,
limit=limit,
direction=direction,
level=level,
source=source,
)
response = await client.get_async_httpx_client().request(**kwargs)
return _build_response(client=client, response=response)
async def asyncio(
template_id: str,
build_id: str,
*,
client: AuthenticatedClient,
cursor: Union[Unset, int] = UNSET,
limit: Union[Unset, int] = 100,
direction: Union[Unset, LogsDirection] = UNSET,
level: Union[Unset, LogLevel] = UNSET,
source: Union[Unset, LogsSource] = UNSET,
) -> Optional[Union[Error, TemplateBuildLogsResponse]]:
"""Get template build logs
Args:
template_id (str):
build_id (str):
cursor (Union[Unset, int]):
limit (Union[Unset, int]): Default: 100.
direction (Union[Unset, LogsDirection]): Direction of the logs that should be returned
level (Union[Unset, LogLevel]): State of the sandbox
source (Union[Unset, LogsSource]): Source of the logs that should be returned
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, TemplateBuildLogsResponse]
"""
return (
await asyncio_detailed(
template_id=template_id,
build_id=build_id,
client=client,
cursor=cursor,
limit=limit,
direction=direction,
level=level,
source=source,
)
).parsed
@@ -0,0 +1,232 @@
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.log_level import LogLevel
from ...models.template_build_info import TemplateBuildInfo
from ...types import UNSET, Response, Unset
def _get_kwargs(
template_id: str,
build_id: str,
*,
logs_offset: Union[Unset, int] = 0,
limit: Union[Unset, int] = 100,
level: Union[Unset, LogLevel] = UNSET,
) -> dict[str, Any]:
params: dict[str, Any] = {}
params["logsOffset"] = logs_offset
params["limit"] = limit
json_level: Union[Unset, str] = UNSET
if not isinstance(level, Unset):
json_level = level.value
params["level"] = json_level
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"/templates/{template_id}/builds/{build_id}/status",
"params": params,
}
return _kwargs
def _parse_response(
*, client: Union[AuthenticatedClient, Client], response: httpx.Response
) -> Optional[Union[Error, TemplateBuildInfo]]:
if response.status_code == 200:
response_200 = TemplateBuildInfo.from_dict(response.json())
return response_200
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, TemplateBuildInfo]]:
return Response(
status_code=HTTPStatus(response.status_code),
content=response.content,
headers=response.headers,
parsed=_parse_response(client=client, response=response),
)
def sync_detailed(
template_id: str,
build_id: str,
*,
client: AuthenticatedClient,
logs_offset: Union[Unset, int] = 0,
limit: Union[Unset, int] = 100,
level: Union[Unset, LogLevel] = UNSET,
) -> Response[Union[Error, TemplateBuildInfo]]:
"""Get template build info
Args:
template_id (str):
build_id (str):
logs_offset (Union[Unset, int]): Default: 0.
limit (Union[Unset, int]): Default: 100.
level (Union[Unset, LogLevel]): State of the sandbox
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, TemplateBuildInfo]]
"""
kwargs = _get_kwargs(
template_id=template_id,
build_id=build_id,
logs_offset=logs_offset,
limit=limit,
level=level,
)
response = client.get_httpx_client().request(
**kwargs,
)
return _build_response(client=client, response=response)
def sync(
template_id: str,
build_id: str,
*,
client: AuthenticatedClient,
logs_offset: Union[Unset, int] = 0,
limit: Union[Unset, int] = 100,
level: Union[Unset, LogLevel] = UNSET,
) -> Optional[Union[Error, TemplateBuildInfo]]:
"""Get template build info
Args:
template_id (str):
build_id (str):
logs_offset (Union[Unset, int]): Default: 0.
limit (Union[Unset, int]): Default: 100.
level (Union[Unset, LogLevel]): State of the sandbox
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, TemplateBuildInfo]
"""
return sync_detailed(
template_id=template_id,
build_id=build_id,
client=client,
logs_offset=logs_offset,
limit=limit,
level=level,
).parsed
async def asyncio_detailed(
template_id: str,
build_id: str,
*,
client: AuthenticatedClient,
logs_offset: Union[Unset, int] = 0,
limit: Union[Unset, int] = 100,
level: Union[Unset, LogLevel] = UNSET,
) -> Response[Union[Error, TemplateBuildInfo]]:
"""Get template build info
Args:
template_id (str):
build_id (str):
logs_offset (Union[Unset, int]): Default: 0.
limit (Union[Unset, int]): Default: 100.
level (Union[Unset, LogLevel]): State of the sandbox
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, TemplateBuildInfo]]
"""
kwargs = _get_kwargs(
template_id=template_id,
build_id=build_id,
logs_offset=logs_offset,
limit=limit,
level=level,
)
response = await client.get_async_httpx_client().request(**kwargs)
return _build_response(client=client, response=response)
async def asyncio(
template_id: str,
build_id: str,
*,
client: AuthenticatedClient,
logs_offset: Union[Unset, int] = 0,
limit: Union[Unset, int] = 100,
level: Union[Unset, LogLevel] = UNSET,
) -> Optional[Union[Error, TemplateBuildInfo]]:
"""Get template build info
Args:
template_id (str):
build_id (str):
logs_offset (Union[Unset, int]): Default: 0.
limit (Union[Unset, int]): Default: 100.
level (Union[Unset, LogLevel]): State of the sandbox
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, TemplateBuildInfo]
"""
return (
await asyncio_detailed(
template_id=template_id,
build_id=build_id,
client=client,
logs_offset=logs_offset,
limit=limit,
level=level,
)
).parsed
@@ -0,0 +1,180 @@
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_file_upload import TemplateBuildFileUpload
from ...types import Response
def _get_kwargs(
template_id: str,
hash_: str,
) -> dict[str, Any]:
_kwargs: dict[str, Any] = {
"method": "get",
"url": f"/templates/{template_id}/files/{hash_}",
}
return _kwargs
def _parse_response(
*, client: Union[AuthenticatedClient, Client], response: httpx.Response
) -> Optional[Union[Error, TemplateBuildFileUpload]]:
if response.status_code == 201:
response_201 = TemplateBuildFileUpload.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, TemplateBuildFileUpload]]:
return Response(
status_code=HTTPStatus(response.status_code),
content=response.content,
headers=response.headers,
parsed=_parse_response(client=client, response=response),
)
def sync_detailed(
template_id: str,
hash_: str,
*,
client: AuthenticatedClient,
) -> Response[Union[Error, TemplateBuildFileUpload]]:
"""Get an upload link for a tar file containing build layer files
Args:
template_id (str):
hash_ (str): Hash of the files
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, TemplateBuildFileUpload]]
"""
kwargs = _get_kwargs(
template_id=template_id,
hash_=hash_,
)
response = client.get_httpx_client().request(
**kwargs,
)
return _build_response(client=client, response=response)
def sync(
template_id: str,
hash_: str,
*,
client: AuthenticatedClient,
) -> Optional[Union[Error, TemplateBuildFileUpload]]:
"""Get an upload link for a tar file containing build layer files
Args:
template_id (str):
hash_ (str): Hash of the files
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, TemplateBuildFileUpload]
"""
return sync_detailed(
template_id=template_id,
hash_=hash_,
client=client,
).parsed
async def asyncio_detailed(
template_id: str,
hash_: str,
*,
client: AuthenticatedClient,
) -> Response[Union[Error, TemplateBuildFileUpload]]:
"""Get an upload link for a tar file containing build layer files
Args:
template_id (str):
hash_ (str): Hash of the files
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, TemplateBuildFileUpload]]
"""
kwargs = _get_kwargs(
template_id=template_id,
hash_=hash_,
)
response = await client.get_async_httpx_client().request(**kwargs)
return _build_response(client=client, response=response)
async def asyncio(
template_id: str,
hash_: str,
*,
client: AuthenticatedClient,
) -> Optional[Union[Error, TemplateBuildFileUpload]]:
"""Get an upload link for a tar file containing build layer files
Args:
template_id (str):
hash_ (str): Hash of the files
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, TemplateBuildFileUpload]
"""
return (
await asyncio_detailed(
template_id=template_id,
hash_=hash_,
client=client,
)
).parsed
@@ -0,0 +1,183 @@
from http import HTTPStatus
from typing import Any, Optional, Union, cast
import httpx
from ... import errors
from ...client import AuthenticatedClient, Client
from ...models.error import Error
from ...models.template_update_request import TemplateUpdateRequest
from ...types import Response
def _get_kwargs(
template_id: str,
*,
body: TemplateUpdateRequest,
) -> dict[str, Any]:
headers: dict[str, Any] = {}
_kwargs: dict[str, Any] = {
"method": "patch",
"url": f"/templates/{template_id}",
}
_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[Any, Error]]:
if response.status_code == 200:
response_200 = cast(Any, None)
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())
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[Any, Error]]:
return Response(
status_code=HTTPStatus(response.status_code),
content=response.content,
headers=response.headers,
parsed=_parse_response(client=client, response=response),
)
def sync_detailed(
template_id: str,
*,
client: AuthenticatedClient,
body: TemplateUpdateRequest,
) -> Response[Union[Any, Error]]:
"""Update template
Args:
template_id (str):
body (TemplateUpdateRequest):
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[Any, Error]]
"""
kwargs = _get_kwargs(
template_id=template_id,
body=body,
)
response = client.get_httpx_client().request(
**kwargs,
)
return _build_response(client=client, response=response)
def sync(
template_id: str,
*,
client: AuthenticatedClient,
body: TemplateUpdateRequest,
) -> Optional[Union[Any, Error]]:
"""Update template
Args:
template_id (str):
body (TemplateUpdateRequest):
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[Any, Error]
"""
return sync_detailed(
template_id=template_id,
client=client,
body=body,
).parsed
async def asyncio_detailed(
template_id: str,
*,
client: AuthenticatedClient,
body: TemplateUpdateRequest,
) -> Response[Union[Any, Error]]:
"""Update template
Args:
template_id (str):
body (TemplateUpdateRequest):
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[Any, Error]]
"""
kwargs = _get_kwargs(
template_id=template_id,
body=body,
)
response = await client.get_async_httpx_client().request(**kwargs)
return _build_response(client=client, response=response)
async def asyncio(
template_id: str,
*,
client: AuthenticatedClient,
body: TemplateUpdateRequest,
) -> Optional[Union[Any, Error]]:
"""Update template
Args:
template_id (str):
body (TemplateUpdateRequest):
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[Any, Error]
"""
return (
await asyncio_detailed(
template_id=template_id,
client=client,
body=body,
)
).parsed
@@ -0,0 +1,185 @@
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_update_request import TemplateUpdateRequest
from ...models.template_update_response import TemplateUpdateResponse
from ...types import Response
def _get_kwargs(
template_id: str,
*,
body: TemplateUpdateRequest,
) -> dict[str, Any]:
headers: dict[str, Any] = {}
_kwargs: dict[str, Any] = {
"method": "patch",
"url": f"/v2/templates/{template_id}",
}
_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, TemplateUpdateResponse]]:
if response.status_code == 200:
response_200 = TemplateUpdateResponse.from_dict(response.json())
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())
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, TemplateUpdateResponse]]:
return Response(
status_code=HTTPStatus(response.status_code),
content=response.content,
headers=response.headers,
parsed=_parse_response(client=client, response=response),
)
def sync_detailed(
template_id: str,
*,
client: AuthenticatedClient,
body: TemplateUpdateRequest,
) -> Response[Union[Error, TemplateUpdateResponse]]:
"""Update template
Args:
template_id (str):
body (TemplateUpdateRequest):
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, TemplateUpdateResponse]]
"""
kwargs = _get_kwargs(
template_id=template_id,
body=body,
)
response = client.get_httpx_client().request(
**kwargs,
)
return _build_response(client=client, response=response)
def sync(
template_id: str,
*,
client: AuthenticatedClient,
body: TemplateUpdateRequest,
) -> Optional[Union[Error, TemplateUpdateResponse]]:
"""Update template
Args:
template_id (str):
body (TemplateUpdateRequest):
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, TemplateUpdateResponse]
"""
return sync_detailed(
template_id=template_id,
client=client,
body=body,
).parsed
async def asyncio_detailed(
template_id: str,
*,
client: AuthenticatedClient,
body: TemplateUpdateRequest,
) -> Response[Union[Error, TemplateUpdateResponse]]:
"""Update template
Args:
template_id (str):
body (TemplateUpdateRequest):
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, TemplateUpdateResponse]]
"""
kwargs = _get_kwargs(
template_id=template_id,
body=body,
)
response = await client.get_async_httpx_client().request(**kwargs)
return _build_response(client=client, response=response)
async def asyncio(
template_id: str,
*,
client: AuthenticatedClient,
body: TemplateUpdateRequest,
) -> Optional[Union[Error, TemplateUpdateResponse]]:
"""Update template
Args:
template_id (str):
body (TemplateUpdateRequest):
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, TemplateUpdateResponse]
"""
return (
await asyncio_detailed(
template_id=template_id,
client=client,
body=body,
)
).parsed
@@ -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 import TemplateBuildRequest
from ...models.template_legacy import TemplateLegacy
from ...types import Response
def _get_kwargs(
*,
body: TemplateBuildRequest,
) -> dict[str, Any]:
headers: dict[str, Any] = {}
_kwargs: dict[str, Any] = {
"method": "post",
"url": "/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, TemplateLegacy]]:
if response.status_code == 202:
response_202 = TemplateLegacy.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, TemplateLegacy]]:
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: TemplateBuildRequest,
) -> Response[Union[Error, TemplateLegacy]]:
"""Create a new template
Args:
body (TemplateBuildRequest):
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, TemplateLegacy]]
"""
kwargs = _get_kwargs(
body=body,
)
response = client.get_httpx_client().request(
**kwargs,
)
return _build_response(client=client, response=response)
def sync(
*,
client: AuthenticatedClient,
body: TemplateBuildRequest,
) -> Optional[Union[Error, TemplateLegacy]]:
"""Create a new template
Args:
body (TemplateBuildRequest):
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, TemplateLegacy]
"""
return sync_detailed(
client=client,
body=body,
).parsed
async def asyncio_detailed(
*,
client: AuthenticatedClient,
body: TemplateBuildRequest,
) -> Response[Union[Error, TemplateLegacy]]:
"""Create a new template
Args:
body (TemplateBuildRequest):
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, TemplateLegacy]]
"""
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: TemplateBuildRequest,
) -> Optional[Union[Error, TemplateLegacy]]:
"""Create a new template
Args:
body (TemplateBuildRequest):
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, TemplateLegacy]
"""
return (
await asyncio_detailed(
client=client,
body=body,
)
).parsed
@@ -0,0 +1,181 @@
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 import TemplateBuildRequest
from ...models.template_legacy import TemplateLegacy
from ...types import Response
def _get_kwargs(
template_id: str,
*,
body: TemplateBuildRequest,
) -> dict[str, Any]:
headers: dict[str, Any] = {}
_kwargs: dict[str, Any] = {
"method": "post",
"url": f"/templates/{template_id}",
}
_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, TemplateLegacy]]:
if response.status_code == 202:
response_202 = TemplateLegacy.from_dict(response.json())
return response_202
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, TemplateLegacy]]:
return Response(
status_code=HTTPStatus(response.status_code),
content=response.content,
headers=response.headers,
parsed=_parse_response(client=client, response=response),
)
def sync_detailed(
template_id: str,
*,
client: AuthenticatedClient,
body: TemplateBuildRequest,
) -> Response[Union[Error, TemplateLegacy]]:
"""Rebuild an template
Args:
template_id (str):
body (TemplateBuildRequest):
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, TemplateLegacy]]
"""
kwargs = _get_kwargs(
template_id=template_id,
body=body,
)
response = client.get_httpx_client().request(
**kwargs,
)
return _build_response(client=client, response=response)
def sync(
template_id: str,
*,
client: AuthenticatedClient,
body: TemplateBuildRequest,
) -> Optional[Union[Error, TemplateLegacy]]:
"""Rebuild an template
Args:
template_id (str):
body (TemplateBuildRequest):
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, TemplateLegacy]
"""
return sync_detailed(
template_id=template_id,
client=client,
body=body,
).parsed
async def asyncio_detailed(
template_id: str,
*,
client: AuthenticatedClient,
body: TemplateBuildRequest,
) -> Response[Union[Error, TemplateLegacy]]:
"""Rebuild an template
Args:
template_id (str):
body (TemplateBuildRequest):
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, TemplateLegacy]]
"""
kwargs = _get_kwargs(
template_id=template_id,
body=body,
)
response = await client.get_async_httpx_client().request(**kwargs)
return _build_response(client=client, response=response)
async def asyncio(
template_id: str,
*,
client: AuthenticatedClient,
body: TemplateBuildRequest,
) -> Optional[Union[Error, TemplateLegacy]]:
"""Rebuild an template
Args:
template_id (str):
body (TemplateBuildRequest):
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, TemplateLegacy]
"""
return (
await asyncio_detailed(
template_id=template_id,
client=client,
body=body,
)
).parsed
@@ -0,0 +1,170 @@
from http import HTTPStatus
from typing import Any, Optional, Union, cast
import httpx
from ... import errors
from ...client import AuthenticatedClient, Client
from ...models.error import Error
from ...types import Response
def _get_kwargs(
template_id: str,
build_id: str,
) -> dict[str, Any]:
_kwargs: dict[str, Any] = {
"method": "post",
"url": f"/templates/{template_id}/builds/{build_id}",
}
return _kwargs
def _parse_response(
*, client: Union[AuthenticatedClient, Client], response: httpx.Response
) -> Optional[Union[Any, Error]]:
if response.status_code == 202:
response_202 = cast(Any, None)
return response_202
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[Any, Error]]:
return Response(
status_code=HTTPStatus(response.status_code),
content=response.content,
headers=response.headers,
parsed=_parse_response(client=client, response=response),
)
def sync_detailed(
template_id: str,
build_id: str,
*,
client: AuthenticatedClient,
) -> Response[Union[Any, Error]]:
"""Start the build
Args:
template_id (str):
build_id (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[Any, Error]]
"""
kwargs = _get_kwargs(
template_id=template_id,
build_id=build_id,
)
response = client.get_httpx_client().request(
**kwargs,
)
return _build_response(client=client, response=response)
def sync(
template_id: str,
build_id: str,
*,
client: AuthenticatedClient,
) -> Optional[Union[Any, Error]]:
"""Start the build
Args:
template_id (str):
build_id (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[Any, Error]
"""
return sync_detailed(
template_id=template_id,
build_id=build_id,
client=client,
).parsed
async def asyncio_detailed(
template_id: str,
build_id: str,
*,
client: AuthenticatedClient,
) -> Response[Union[Any, Error]]:
"""Start the build
Args:
template_id (str):
build_id (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[Any, Error]]
"""
kwargs = _get_kwargs(
template_id=template_id,
build_id=build_id,
)
response = await client.get_async_httpx_client().request(**kwargs)
return _build_response(client=client, response=response)
async def asyncio(
template_id: str,
build_id: str,
*,
client: AuthenticatedClient,
) -> Optional[Union[Any, Error]]:
"""Start the build
Args:
template_id (str):
build_id (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[Any, Error]
"""
return (
await asyncio_detailed(
template_id=template_id,
build_id=build_id,
client=client,
)
).parsed
@@ -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_v2 import TemplateBuildRequestV2
from ...models.template_legacy import TemplateLegacy
from ...types import Response
def _get_kwargs(
*,
body: TemplateBuildRequestV2,
) -> dict[str, Any]:
headers: dict[str, Any] = {}
_kwargs: dict[str, Any] = {
"method": "post",
"url": "/v2/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, TemplateLegacy]]:
if response.status_code == 202:
response_202 = TemplateLegacy.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, TemplateLegacy]]:
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: TemplateBuildRequestV2,
) -> Response[Union[Error, TemplateLegacy]]:
"""Create a new template
Args:
body (TemplateBuildRequestV2):
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, TemplateLegacy]]
"""
kwargs = _get_kwargs(
body=body,
)
response = client.get_httpx_client().request(
**kwargs,
)
return _build_response(client=client, response=response)
def sync(
*,
client: AuthenticatedClient,
body: TemplateBuildRequestV2,
) -> Optional[Union[Error, TemplateLegacy]]:
"""Create a new template
Args:
body (TemplateBuildRequestV2):
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, TemplateLegacy]
"""
return sync_detailed(
client=client,
body=body,
).parsed
async def asyncio_detailed(
*,
client: AuthenticatedClient,
body: TemplateBuildRequestV2,
) -> Response[Union[Error, TemplateLegacy]]:
"""Create a new template
Args:
body (TemplateBuildRequestV2):
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, TemplateLegacy]]
"""
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: TemplateBuildRequestV2,
) -> Optional[Union[Error, TemplateLegacy]]:
"""Create a new template
Args:
body (TemplateBuildRequestV2):
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, TemplateLegacy]
"""
return (
await asyncio_detailed(
client=client,
body=body,
)
).parsed
@@ -0,0 +1,176 @@
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 == 403:
response_403 = Error.from_dict(response.json())
return response_403
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
@@ -0,0 +1,192 @@
from http import HTTPStatus
from typing import Any, Optional, Union, cast
import httpx
from ... import errors
from ...client import AuthenticatedClient, Client
from ...models.error import Error
from ...models.template_build_start_v2 import TemplateBuildStartV2
from ...types import Response
def _get_kwargs(
template_id: str,
build_id: str,
*,
body: TemplateBuildStartV2,
) -> dict[str, Any]:
headers: dict[str, Any] = {}
_kwargs: dict[str, Any] = {
"method": "post",
"url": f"/v2/templates/{template_id}/builds/{build_id}",
}
_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[Any, Error]]:
if response.status_code == 202:
response_202 = cast(Any, None)
return response_202
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[Any, Error]]:
return Response(
status_code=HTTPStatus(response.status_code),
content=response.content,
headers=response.headers,
parsed=_parse_response(client=client, response=response),
)
def sync_detailed(
template_id: str,
build_id: str,
*,
client: AuthenticatedClient,
body: TemplateBuildStartV2,
) -> Response[Union[Any, Error]]:
"""Start the build
Args:
template_id (str):
build_id (str):
body (TemplateBuildStartV2):
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[Any, Error]]
"""
kwargs = _get_kwargs(
template_id=template_id,
build_id=build_id,
body=body,
)
response = client.get_httpx_client().request(
**kwargs,
)
return _build_response(client=client, response=response)
def sync(
template_id: str,
build_id: str,
*,
client: AuthenticatedClient,
body: TemplateBuildStartV2,
) -> Optional[Union[Any, Error]]:
"""Start the build
Args:
template_id (str):
build_id (str):
body (TemplateBuildStartV2):
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[Any, Error]
"""
return sync_detailed(
template_id=template_id,
build_id=build_id,
client=client,
body=body,
).parsed
async def asyncio_detailed(
template_id: str,
build_id: str,
*,
client: AuthenticatedClient,
body: TemplateBuildStartV2,
) -> Response[Union[Any, Error]]:
"""Start the build
Args:
template_id (str):
build_id (str):
body (TemplateBuildStartV2):
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[Any, Error]]
"""
kwargs = _get_kwargs(
template_id=template_id,
build_id=build_id,
body=body,
)
response = await client.get_async_httpx_client().request(**kwargs)
return _build_response(client=client, response=response)
async def asyncio(
template_id: str,
build_id: str,
*,
client: AuthenticatedClient,
body: TemplateBuildStartV2,
) -> Optional[Union[Any, Error]]:
"""Start the build
Args:
template_id (str):
build_id (str):
body (TemplateBuildStartV2):
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[Any, Error]
"""
return (
await asyncio_detailed(
template_id=template_id,
build_id=build_id,
client=client,
body=body,
)
).parsed
@@ -0,0 +1 @@
"""Contains endpoint functions for accessing the API"""
@@ -0,0 +1,161 @@
from http import HTTPStatus
from typing import Any, Optional, Union, cast
import httpx
from ... import errors
from ...client import AuthenticatedClient, Client
from ...models.error import Error
from ...types import Response
def _get_kwargs(
volume_id: str,
) -> dict[str, Any]:
_kwargs: dict[str, Any] = {
"method": "delete",
"url": f"/volumes/{volume_id}",
}
return _kwargs
def _parse_response(
*, client: Union[AuthenticatedClient, Client], response: httpx.Response
) -> Optional[Union[Any, Error]]:
if response.status_code == 204:
response_204 = cast(Any, None)
return response_204
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[Any, Error]]:
return Response(
status_code=HTTPStatus(response.status_code),
content=response.content,
headers=response.headers,
parsed=_parse_response(client=client, response=response),
)
def sync_detailed(
volume_id: str,
*,
client: AuthenticatedClient,
) -> Response[Union[Any, Error]]:
"""Delete a team volume
Args:
volume_id (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[Any, Error]]
"""
kwargs = _get_kwargs(
volume_id=volume_id,
)
response = client.get_httpx_client().request(
**kwargs,
)
return _build_response(client=client, response=response)
def sync(
volume_id: str,
*,
client: AuthenticatedClient,
) -> Optional[Union[Any, Error]]:
"""Delete a team volume
Args:
volume_id (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[Any, Error]
"""
return sync_detailed(
volume_id=volume_id,
client=client,
).parsed
async def asyncio_detailed(
volume_id: str,
*,
client: AuthenticatedClient,
) -> Response[Union[Any, Error]]:
"""Delete a team volume
Args:
volume_id (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[Any, Error]]
"""
kwargs = _get_kwargs(
volume_id=volume_id,
)
response = await client.get_async_httpx_client().request(**kwargs)
return _build_response(client=client, response=response)
async def asyncio(
volume_id: str,
*,
client: AuthenticatedClient,
) -> Optional[Union[Any, Error]]:
"""Delete a team volume
Args:
volume_id (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[Any, Error]
"""
return (
await asyncio_detailed(
volume_id=volume_id,
client=client,
)
).parsed
@@ -0,0 +1,140 @@
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.volume import Volume
from ...types import Response
def _get_kwargs() -> dict[str, Any]:
_kwargs: dict[str, Any] = {
"method": "get",
"url": "/volumes",
}
return _kwargs
def _parse_response(
*, client: Union[AuthenticatedClient, Client], response: httpx.Response
) -> Optional[Union[Error, list["Volume"]]]:
if response.status_code == 200:
response_200 = []
_response_200 = response.json()
for response_200_item_data in _response_200:
response_200_item = Volume.from_dict(response_200_item_data)
response_200.append(response_200_item)
return response_200
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, list["Volume"]]]:
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,
) -> Response[Union[Error, list["Volume"]]]:
"""List all team volumes
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['Volume']]]
"""
kwargs = _get_kwargs()
response = client.get_httpx_client().request(
**kwargs,
)
return _build_response(client=client, response=response)
def sync(
*,
client: AuthenticatedClient,
) -> Optional[Union[Error, list["Volume"]]]:
"""List all team volumes
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['Volume']]
"""
return sync_detailed(
client=client,
).parsed
async def asyncio_detailed(
*,
client: AuthenticatedClient,
) -> Response[Union[Error, list["Volume"]]]:
"""List all team volumes
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['Volume']]]
"""
kwargs = _get_kwargs()
response = await client.get_async_httpx_client().request(**kwargs)
return _build_response(client=client, response=response)
async def asyncio(
*,
client: AuthenticatedClient,
) -> Optional[Union[Error, list["Volume"]]]:
"""List all team volumes
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['Volume']]
"""
return (
await asyncio_detailed(
client=client,
)
).parsed
@@ -0,0 +1,163 @@
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.volume_and_token import VolumeAndToken
from ...types import Response
def _get_kwargs(
volume_id: str,
) -> dict[str, Any]:
_kwargs: dict[str, Any] = {
"method": "get",
"url": f"/volumes/{volume_id}",
}
return _kwargs
def _parse_response(
*, client: Union[AuthenticatedClient, Client], response: httpx.Response
) -> Optional[Union[Error, VolumeAndToken]]:
if response.status_code == 200:
response_200 = VolumeAndToken.from_dict(response.json())
return response_200
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, VolumeAndToken]]:
return Response(
status_code=HTTPStatus(response.status_code),
content=response.content,
headers=response.headers,
parsed=_parse_response(client=client, response=response),
)
def sync_detailed(
volume_id: str,
*,
client: AuthenticatedClient,
) -> Response[Union[Error, VolumeAndToken]]:
"""Get team volume info
Args:
volume_id (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, VolumeAndToken]]
"""
kwargs = _get_kwargs(
volume_id=volume_id,
)
response = client.get_httpx_client().request(
**kwargs,
)
return _build_response(client=client, response=response)
def sync(
volume_id: str,
*,
client: AuthenticatedClient,
) -> Optional[Union[Error, VolumeAndToken]]:
"""Get team volume info
Args:
volume_id (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, VolumeAndToken]
"""
return sync_detailed(
volume_id=volume_id,
client=client,
).parsed
async def asyncio_detailed(
volume_id: str,
*,
client: AuthenticatedClient,
) -> Response[Union[Error, VolumeAndToken]]:
"""Get team volume info
Args:
volume_id (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, VolumeAndToken]]
"""
kwargs = _get_kwargs(
volume_id=volume_id,
)
response = await client.get_async_httpx_client().request(**kwargs)
return _build_response(client=client, response=response)
async def asyncio(
volume_id: str,
*,
client: AuthenticatedClient,
) -> Optional[Union[Error, VolumeAndToken]]:
"""Get team volume info
Args:
volume_id (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, VolumeAndToken]
"""
return (
await asyncio_detailed(
volume_id=volume_id,
client=client,
)
).parsed
@@ -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.new_volume import NewVolume
from ...models.volume_and_token import VolumeAndToken
from ...types import Response
def _get_kwargs(
*,
body: NewVolume,
) -> dict[str, Any]:
headers: dict[str, Any] = {}
_kwargs: dict[str, Any] = {
"method": "post",
"url": "/volumes",
}
_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, VolumeAndToken]]:
if response.status_code == 201:
response_201 = VolumeAndToken.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 == 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, VolumeAndToken]]:
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: NewVolume,
) -> Response[Union[Error, VolumeAndToken]]:
"""Create a new team volume
Args:
body (NewVolume):
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, VolumeAndToken]]
"""
kwargs = _get_kwargs(
body=body,
)
response = client.get_httpx_client().request(
**kwargs,
)
return _build_response(client=client, response=response)
def sync(
*,
client: AuthenticatedClient,
body: NewVolume,
) -> Optional[Union[Error, VolumeAndToken]]:
"""Create a new team volume
Args:
body (NewVolume):
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, VolumeAndToken]
"""
return sync_detailed(
client=client,
body=body,
).parsed
async def asyncio_detailed(
*,
client: AuthenticatedClient,
body: NewVolume,
) -> Response[Union[Error, VolumeAndToken]]:
"""Create a new team volume
Args:
body (NewVolume):
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, VolumeAndToken]]
"""
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: NewVolume,
) -> Optional[Union[Error, VolumeAndToken]]:
"""Create a new team volume
Args:
body (NewVolume):
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, VolumeAndToken]
"""
return (
await asyncio_detailed(
client=client,
body=body,
)
).parsed
+286
View File
@@ -0,0 +1,286 @@
import ssl
from typing import Any, Optional, Union
import httpx
from attrs import define, evolve, field
@define
class Client:
"""A class for keeping track of data related to the API
The following are accepted as keyword arguments and will be used to construct httpx Clients internally:
``base_url``: The base URL for the API, all requests are made to a relative path to this URL
``cookies``: A dictionary of cookies to be sent with every request
``headers``: A dictionary of headers to be sent with every request
``timeout``: The maximum amount of a time a request can take. API functions will raise
httpx.TimeoutException if this is exceeded.
``verify_ssl``: Whether or not to verify the SSL certificate of the API server. This should be True in production,
but can be set to False for testing purposes.
``follow_redirects``: Whether or not to follow redirects. Default value is False.
``httpx_args``: A dictionary of additional arguments to be passed to the ``httpx.Client`` and ``httpx.AsyncClient`` constructor.
Attributes:
raise_on_unexpected_status: Whether or not to raise an errors.UnexpectedStatus if the API returns a
status code that was not documented in the source OpenAPI document. Can also be provided as a keyword
argument to the constructor.
"""
raise_on_unexpected_status: bool = field(default=False, kw_only=True)
_base_url: str = field(alias="base_url")
_cookies: dict[str, str] = field(factory=dict, kw_only=True, alias="cookies")
_headers: dict[str, str] = field(factory=dict, kw_only=True, alias="headers")
_timeout: Optional[httpx.Timeout] = field(
default=None, kw_only=True, alias="timeout"
)
_verify_ssl: Union[str, bool, ssl.SSLContext] = field(
default=True, kw_only=True, alias="verify_ssl"
)
_follow_redirects: bool = field(
default=False, kw_only=True, alias="follow_redirects"
)
_httpx_args: dict[str, Any] = field(factory=dict, kw_only=True, alias="httpx_args")
_client: Optional[httpx.Client] = field(default=None, init=False)
_async_client: Optional[httpx.AsyncClient] = field(default=None, init=False)
def with_headers(self, headers: dict[str, str]) -> "Client":
"""Get a new client matching this one with additional headers"""
if self._client is not None:
self._client.headers.update(headers)
if self._async_client is not None:
self._async_client.headers.update(headers)
return evolve(self, headers={**self._headers, **headers})
def with_cookies(self, cookies: dict[str, str]) -> "Client":
"""Get a new client matching this one with additional cookies"""
if self._client is not None:
self._client.cookies.update(cookies)
if self._async_client is not None:
self._async_client.cookies.update(cookies)
return evolve(self, cookies={**self._cookies, **cookies})
def with_timeout(self, timeout: httpx.Timeout) -> "Client":
"""Get a new client matching this one with a new timeout (in seconds)"""
if self._client is not None:
self._client.timeout = timeout
if self._async_client is not None:
self._async_client.timeout = timeout
return evolve(self, timeout=timeout)
def set_httpx_client(self, client: httpx.Client) -> "Client":
"""Manually set the underlying httpx.Client
**NOTE**: This will override any other settings on the client, including cookies, headers, and timeout.
"""
self._client = client
return self
def get_httpx_client(self) -> httpx.Client:
"""Get the underlying httpx.Client, constructing a new one if not previously set"""
if self._client is None:
self._client = httpx.Client(
base_url=self._base_url,
cookies=self._cookies,
headers=self._headers,
timeout=self._timeout,
verify=self._verify_ssl,
follow_redirects=self._follow_redirects,
**self._httpx_args,
)
return self._client
def __enter__(self) -> "Client":
"""Enter a context manager for self.client—you cannot enter twice (see httpx docs)"""
self.get_httpx_client().__enter__()
return self
def __exit__(self, *args: Any, **kwargs: Any) -> None:
"""Exit a context manager for internal httpx.Client (see httpx docs)"""
self.get_httpx_client().__exit__(*args, **kwargs)
def set_async_httpx_client(self, async_client: httpx.AsyncClient) -> "Client":
"""Manually the underlying httpx.AsyncClient
**NOTE**: This will override any other settings on the client, including cookies, headers, and timeout.
"""
self._async_client = async_client
return self
def get_async_httpx_client(self) -> httpx.AsyncClient:
"""Get the underlying httpx.AsyncClient, constructing a new one if not previously set"""
if self._async_client is None:
self._async_client = httpx.AsyncClient(
base_url=self._base_url,
cookies=self._cookies,
headers=self._headers,
timeout=self._timeout,
verify=self._verify_ssl,
follow_redirects=self._follow_redirects,
**self._httpx_args,
)
return self._async_client
async def __aenter__(self) -> "Client":
"""Enter a context manager for underlying httpx.AsyncClient—you cannot enter twice (see httpx docs)"""
await self.get_async_httpx_client().__aenter__()
return self
async def __aexit__(self, *args: Any, **kwargs: Any) -> None:
"""Exit a context manager for underlying httpx.AsyncClient (see httpx docs)"""
await self.get_async_httpx_client().__aexit__(*args, **kwargs)
@define
class AuthenticatedClient:
"""A Client which has been authenticated for use on secured endpoints
The following are accepted as keyword arguments and will be used to construct httpx Clients internally:
``base_url``: The base URL for the API, all requests are made to a relative path to this URL
``cookies``: A dictionary of cookies to be sent with every request
``headers``: A dictionary of headers to be sent with every request
``timeout``: The maximum amount of a time a request can take. API functions will raise
httpx.TimeoutException if this is exceeded.
``verify_ssl``: Whether or not to verify the SSL certificate of the API server. This should be True in production,
but can be set to False for testing purposes.
``follow_redirects``: Whether or not to follow redirects. Default value is False.
``httpx_args``: A dictionary of additional arguments to be passed to the ``httpx.Client`` and ``httpx.AsyncClient`` constructor.
Attributes:
raise_on_unexpected_status: Whether or not to raise an errors.UnexpectedStatus if the API returns a
status code that was not documented in the source OpenAPI document. Can also be provided as a keyword
argument to the constructor.
token: The token to use for authentication
prefix: The prefix to use for the Authorization header
auth_header_name: The name of the Authorization header
"""
raise_on_unexpected_status: bool = field(default=False, kw_only=True)
_base_url: str = field(alias="base_url")
_cookies: dict[str, str] = field(factory=dict, kw_only=True, alias="cookies")
_headers: dict[str, str] = field(factory=dict, kw_only=True, alias="headers")
_timeout: Optional[httpx.Timeout] = field(
default=None, kw_only=True, alias="timeout"
)
_verify_ssl: Union[str, bool, ssl.SSLContext] = field(
default=True, kw_only=True, alias="verify_ssl"
)
_follow_redirects: bool = field(
default=False, kw_only=True, alias="follow_redirects"
)
_httpx_args: dict[str, Any] = field(factory=dict, kw_only=True, alias="httpx_args")
_client: Optional[httpx.Client] = field(default=None, init=False)
_async_client: Optional[httpx.AsyncClient] = field(default=None, init=False)
token: str
prefix: str = "Bearer"
auth_header_name: str = "Authorization"
def with_headers(self, headers: dict[str, str]) -> "AuthenticatedClient":
"""Get a new client matching this one with additional headers"""
if self._client is not None:
self._client.headers.update(headers)
if self._async_client is not None:
self._async_client.headers.update(headers)
return evolve(self, headers={**self._headers, **headers})
def with_cookies(self, cookies: dict[str, str]) -> "AuthenticatedClient":
"""Get a new client matching this one with additional cookies"""
if self._client is not None:
self._client.cookies.update(cookies)
if self._async_client is not None:
self._async_client.cookies.update(cookies)
return evolve(self, cookies={**self._cookies, **cookies})
def with_timeout(self, timeout: httpx.Timeout) -> "AuthenticatedClient":
"""Get a new client matching this one with a new timeout (in seconds)"""
if self._client is not None:
self._client.timeout = timeout
if self._async_client is not None:
self._async_client.timeout = timeout
return evolve(self, timeout=timeout)
def set_httpx_client(self, client: httpx.Client) -> "AuthenticatedClient":
"""Manually set the underlying httpx.Client
**NOTE**: This will override any other settings on the client, including cookies, headers, and timeout.
"""
self._client = client
return self
def get_httpx_client(self) -> httpx.Client:
"""Get the underlying httpx.Client, constructing a new one if not previously set"""
if self._client is None:
self._headers[self.auth_header_name] = (
f"{self.prefix} {self.token}" if self.prefix else self.token
)
self._client = httpx.Client(
base_url=self._base_url,
cookies=self._cookies,
headers=self._headers,
timeout=self._timeout,
verify=self._verify_ssl,
follow_redirects=self._follow_redirects,
**self._httpx_args,
)
return self._client
def __enter__(self) -> "AuthenticatedClient":
"""Enter a context manager for self.client—you cannot enter twice (see httpx docs)"""
self.get_httpx_client().__enter__()
return self
def __exit__(self, *args: Any, **kwargs: Any) -> None:
"""Exit a context manager for internal httpx.Client (see httpx docs)"""
self.get_httpx_client().__exit__(*args, **kwargs)
def set_async_httpx_client(
self, async_client: httpx.AsyncClient
) -> "AuthenticatedClient":
"""Manually the underlying httpx.AsyncClient
**NOTE**: This will override any other settings on the client, including cookies, headers, and timeout.
"""
self._async_client = async_client
return self
def get_async_httpx_client(self) -> httpx.AsyncClient:
"""Get the underlying httpx.AsyncClient, constructing a new one if not previously set"""
if self._async_client is None:
self._headers[self.auth_header_name] = (
f"{self.prefix} {self.token}" if self.prefix else self.token
)
self._async_client = httpx.AsyncClient(
base_url=self._base_url,
cookies=self._cookies,
headers=self._headers,
timeout=self._timeout,
verify=self._verify_ssl,
follow_redirects=self._follow_redirects,
**self._httpx_args,
)
return self._async_client
async def __aenter__(self) -> "AuthenticatedClient":
"""Enter a context manager for underlying httpx.AsyncClient—you cannot enter twice (see httpx docs)"""
await self.get_async_httpx_client().__aenter__()
return self
async def __aexit__(self, *args: Any, **kwargs: Any) -> None:
"""Exit a context manager for underlying httpx.AsyncClient (see httpx docs)"""
await self.get_async_httpx_client().__aexit__(*args, **kwargs)
+16
View File
@@ -0,0 +1,16 @@
"""Contains shared errors types that can be raised from API functions"""
class UnexpectedStatus(Exception):
"""Raised by api functions when the response status an undocumented status and Client.raise_on_unexpected_status is True"""
def __init__(self, status_code: int, content: bytes):
self.status_code = status_code
self.content = content
super().__init__(
f"Unexpected status code: {status_code}\n\nResponse content:\n{content.decode(errors='ignore')}"
)
__all__ = ["UnexpectedStatus"]
+185
View File
@@ -0,0 +1,185 @@
"""Contains all the data models used in inputs/outputs"""
from .admin_build_cancel_result import AdminBuildCancelResult
from .admin_sandbox_kill_result import AdminSandboxKillResult
from .assign_template_tags_request import AssignTemplateTagsRequest
from .assigned_template_tags import AssignedTemplateTags
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 .delete_template_tags_request import DeleteTemplateTagsRequest
from .disk_metrics import DiskMetrics
from .error import Error
from .gcp_registry import GCPRegistry
from .gcp_registry_type import GCPRegistryType
from .general_registry import GeneralRegistry
from .general_registry_type import GeneralRegistryType
from .identifier_masking_details import IdentifierMaskingDetails
from .listed_sandbox import ListedSandbox
from .log_level import LogLevel
from .logs_direction import LogsDirection
from .logs_source import LogsSource
from .machine_info import MachineInfo
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
from .new_volume import NewVolume
from .node import Node
from .node_detail import NodeDetail
from .node_metrics import NodeMetrics
from .node_status import NodeStatus
from .node_status_change import NodeStatusChange
from .post_sandboxes_sandbox_id_refreshes_body import (
PostSandboxesSandboxIDRefreshesBody,
)
from .post_sandboxes_sandbox_id_snapshots_body import (
PostSandboxesSandboxIDSnapshotsBody,
)
from .post_sandboxes_sandbox_id_timeout_body import PostSandboxesSandboxIDTimeoutBody
from .resumed_sandbox import ResumedSandbox
from .sandbox import Sandbox
from .sandbox_auto_resume_config import SandboxAutoResumeConfig
from .sandbox_detail import SandboxDetail
from .sandbox_lifecycle import SandboxLifecycle
from .sandbox_log import SandboxLog
from .sandbox_log_entry import SandboxLogEntry
from .sandbox_log_entry_fields import SandboxLogEntryFields
from .sandbox_logs import SandboxLogs
from .sandbox_logs_v2_response import SandboxLogsV2Response
from .sandbox_metric import SandboxMetric
from .sandbox_network_config import SandboxNetworkConfig
from .sandbox_network_config_rules import SandboxNetworkConfigRules
from .sandbox_network_rule import SandboxNetworkRule
from .sandbox_network_transform import SandboxNetworkTransform
from .sandbox_network_transform_headers import SandboxNetworkTransformHeaders
from .sandbox_network_update_config import SandboxNetworkUpdateConfig
from .sandbox_network_update_config_rules import SandboxNetworkUpdateConfigRules
from .sandbox_on_timeout import SandboxOnTimeout
from .sandbox_pause_request import SandboxPauseRequest
from .sandbox_state import SandboxState
from .sandbox_volume_mount import SandboxVolumeMount
from .sandboxes_with_metrics import SandboxesWithMetrics
from .snapshot_info import SnapshotInfo
from .team import Team
from .team_api_key import TeamAPIKey
from .team_metric import TeamMetric
from .team_user import TeamUser
from .template import Template
from .template_alias_response import TemplateAliasResponse
from .template_build import TemplateBuild
from .template_build_file_upload import TemplateBuildFileUpload
from .template_build_info import TemplateBuildInfo
from .template_build_logs_response import TemplateBuildLogsResponse
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_tag import TemplateTag
from .template_update_request import TemplateUpdateRequest
from .template_update_response import TemplateUpdateResponse
from .template_with_builds import TemplateWithBuilds
from .update_team_api_key import UpdateTeamAPIKey
from .volume import Volume
from .volume_and_token import VolumeAndToken
from .volume_token import VolumeToken
__all__ = (
"AdminBuildCancelResult",
"AdminSandboxKillResult",
"AssignedTemplateTags",
"AssignTemplateTagsRequest",
"AWSRegistry",
"AWSRegistryType",
"BuildLogEntry",
"BuildStatusReason",
"ConnectSandbox",
"CreatedAccessToken",
"CreatedTeamAPIKey",
"DeleteTemplateTagsRequest",
"DiskMetrics",
"Error",
"GCPRegistry",
"GCPRegistryType",
"GeneralRegistry",
"GeneralRegistryType",
"IdentifierMaskingDetails",
"ListedSandbox",
"LogLevel",
"LogsDirection",
"LogsSource",
"MachineInfo",
"MaxTeamMetric",
"McpType0",
"NewAccessToken",
"NewSandbox",
"NewTeamAPIKey",
"NewVolume",
"Node",
"NodeDetail",
"NodeMetrics",
"NodeStatus",
"NodeStatusChange",
"PostSandboxesSandboxIDRefreshesBody",
"PostSandboxesSandboxIDSnapshotsBody",
"PostSandboxesSandboxIDTimeoutBody",
"ResumedSandbox",
"Sandbox",
"SandboxAutoResumeConfig",
"SandboxDetail",
"SandboxesWithMetrics",
"SandboxLifecycle",
"SandboxLog",
"SandboxLogEntry",
"SandboxLogEntryFields",
"SandboxLogs",
"SandboxLogsV2Response",
"SandboxMetric",
"SandboxNetworkConfig",
"SandboxNetworkConfigRules",
"SandboxNetworkRule",
"SandboxNetworkTransform",
"SandboxNetworkTransformHeaders",
"SandboxNetworkUpdateConfig",
"SandboxNetworkUpdateConfigRules",
"SandboxOnTimeout",
"SandboxPauseRequest",
"SandboxState",
"SandboxVolumeMount",
"SnapshotInfo",
"Team",
"TeamAPIKey",
"TeamMetric",
"TeamUser",
"Template",
"TemplateAliasResponse",
"TemplateBuild",
"TemplateBuildFileUpload",
"TemplateBuildInfo",
"TemplateBuildLogsResponse",
"TemplateBuildRequest",
"TemplateBuildRequestV2",
"TemplateBuildRequestV3",
"TemplateBuildStartV2",
"TemplateBuildStatus",
"TemplateLegacy",
"TemplateRequestResponseV3",
"TemplateStep",
"TemplateTag",
"TemplateUpdateRequest",
"TemplateUpdateResponse",
"TemplateWithBuilds",
"UpdateTeamAPIKey",
"Volume",
"VolumeAndToken",
"VolumeToken",
)
@@ -0,0 +1,67 @@
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="AdminBuildCancelResult")
@_attrs_define
class AdminBuildCancelResult:
"""
Attributes:
cancelled_count (int): Number of builds successfully cancelled
failed_count (int): Number of builds that failed to cancel
"""
cancelled_count: int
failed_count: int
additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict)
def to_dict(self) -> dict[str, Any]:
cancelled_count = self.cancelled_count
failed_count = self.failed_count
field_dict: dict[str, Any] = {}
field_dict.update(self.additional_properties)
field_dict.update(
{
"cancelledCount": cancelled_count,
"failedCount": failed_count,
}
)
return field_dict
@classmethod
def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T:
d = dict(src_dict)
cancelled_count = d.pop("cancelledCount")
failed_count = d.pop("failedCount")
admin_build_cancel_result = cls(
cancelled_count=cancelled_count,
failed_count=failed_count,
)
admin_build_cancel_result.additional_properties = d
return admin_build_cancel_result
@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
@@ -0,0 +1,67 @@
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="AdminSandboxKillResult")
@_attrs_define
class AdminSandboxKillResult:
"""
Attributes:
failed_count (int): Number of sandboxes that failed to kill
killed_count (int): Number of sandboxes successfully killed
"""
failed_count: int
killed_count: int
additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict)
def to_dict(self) -> dict[str, Any]:
failed_count = self.failed_count
killed_count = self.killed_count
field_dict: dict[str, Any] = {}
field_dict.update(self.additional_properties)
field_dict.update(
{
"failedCount": failed_count,
"killedCount": killed_count,
}
)
return field_dict
@classmethod
def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T:
d = dict(src_dict)
failed_count = d.pop("failedCount")
killed_count = d.pop("killedCount")
admin_sandbox_kill_result = cls(
failed_count=failed_count,
killed_count=killed_count,
)
admin_sandbox_kill_result.additional_properties = d
return admin_sandbox_kill_result
@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
@@ -0,0 +1,67 @@
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="AssignTemplateTagsRequest")
@_attrs_define
class AssignTemplateTagsRequest:
"""
Attributes:
tags (list[str]): Tags to assign to the template
target (str): Target template in "name:tag" format
"""
tags: list[str]
target: str
additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict)
def to_dict(self) -> dict[str, Any]:
tags = self.tags
target = self.target
field_dict: dict[str, Any] = {}
field_dict.update(self.additional_properties)
field_dict.update(
{
"tags": tags,
"target": target,
}
)
return field_dict
@classmethod
def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T:
d = dict(src_dict)
tags = cast(list[str], d.pop("tags"))
target = d.pop("target")
assign_template_tags_request = cls(
tags=tags,
target=target,
)
assign_template_tags_request.additional_properties = d
return assign_template_tags_request
@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
@@ -0,0 +1,68 @@
from collections.abc import Mapping
from typing import Any, TypeVar, cast
from uuid import UUID
from attrs import define as _attrs_define
from attrs import field as _attrs_field
T = TypeVar("T", bound="AssignedTemplateTags")
@_attrs_define
class AssignedTemplateTags:
"""
Attributes:
build_id (UUID): Identifier of the build associated with these tags
tags (list[str]): Assigned tags of the template
"""
build_id: UUID
tags: list[str]
additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict)
def to_dict(self) -> dict[str, Any]:
build_id = str(self.build_id)
tags = self.tags
field_dict: dict[str, Any] = {}
field_dict.update(self.additional_properties)
field_dict.update(
{
"buildID": build_id,
"tags": tags,
}
)
return field_dict
@classmethod
def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T:
d = dict(src_dict)
build_id = UUID(d.pop("buildID"))
tags = cast(list[str], d.pop("tags"))
assigned_template_tags = cls(
build_id=build_id,
tags=tags,
)
assigned_template_tags.additional_properties = d
return assigned_template_tags
@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
@@ -0,0 +1,85 @@
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 ..models.aws_registry_type import AWSRegistryType
T = TypeVar("T", bound="AWSRegistry")
@_attrs_define
class AWSRegistry:
"""
Attributes:
aws_access_key_id (str): AWS Access Key ID for ECR authentication
aws_region (str): AWS Region where the ECR registry is located
aws_secret_access_key (str): AWS Secret Access Key for ECR authentication
type_ (AWSRegistryType): Type of registry authentication
"""
aws_access_key_id: str
aws_region: str
aws_secret_access_key: str
type_: AWSRegistryType
additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict)
def to_dict(self) -> dict[str, Any]:
aws_access_key_id = self.aws_access_key_id
aws_region = self.aws_region
aws_secret_access_key = self.aws_secret_access_key
type_ = self.type_.value
field_dict: dict[str, Any] = {}
field_dict.update(self.additional_properties)
field_dict.update(
{
"awsAccessKeyId": aws_access_key_id,
"awsRegion": aws_region,
"awsSecretAccessKey": aws_secret_access_key,
"type": type_,
}
)
return field_dict
@classmethod
def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T:
d = dict(src_dict)
aws_access_key_id = d.pop("awsAccessKeyId")
aws_region = d.pop("awsRegion")
aws_secret_access_key = d.pop("awsSecretAccessKey")
type_ = AWSRegistryType(d.pop("type"))
aws_registry = cls(
aws_access_key_id=aws_access_key_id,
aws_region=aws_region,
aws_secret_access_key=aws_secret_access_key,
type_=type_,
)
aws_registry.additional_properties = d
return aws_registry
@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
@@ -0,0 +1,8 @@
from enum import Enum
class AWSRegistryType(str, Enum):
AWS = "aws"
def __str__(self) -> str:
return str(self.value)
@@ -0,0 +1,89 @@
import datetime
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 dateutil.parser import isoparse
from ..models.log_level import LogLevel
from ..types import UNSET, Unset
T = TypeVar("T", bound="BuildLogEntry")
@_attrs_define
class BuildLogEntry:
"""
Attributes:
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]:
level = self.level.value
message = self.message
timestamp = self.timestamp.isoformat()
step = self.step
field_dict: dict[str, Any] = {}
field_dict.update(self.additional_properties)
field_dict.update(
{
"level": level,
"message": message,
"timestamp": timestamp,
}
)
if step is not UNSET:
field_dict["step"] = step
return field_dict
@classmethod
def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T:
d = dict(src_dict)
level = LogLevel(d.pop("level"))
message = d.pop("message")
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
return build_log_entry
@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
@@ -0,0 +1,95 @@
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 ..types import UNSET, Unset
if TYPE_CHECKING:
from ..models.build_log_entry import BuildLogEntry
T = TypeVar("T", bound="BuildStatusReason")
@_attrs_define
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] = {}
field_dict.update(self.additional_properties)
field_dict.update(
{
"message": message,
}
)
if log_entries is not UNSET:
field_dict["logEntries"] = log_entries
if step is not UNSET:
field_dict["step"] = step
return field_dict
@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,
)
build_status_reason.additional_properties = d
return build_status_reason
@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
@@ -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
@@ -0,0 +1,100 @@
import datetime
from collections.abc import Mapping
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")
@_attrs_define
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): The fully created access token
"""
created_at: datetime.datetime
id: UUID
mask: "IdentifierMaskingDetails"
name: str
token: str
additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict)
def to_dict(self) -> dict[str, Any]:
created_at = self.created_at.isoformat()
id = str(self.id)
mask = self.mask.to_dict()
name = self.name
token = self.token
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,
}
)
return field_dict
@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")
created_access_token = cls(
created_at=created_at,
id=id,
mask=mask,
name=name,
token=token,
)
created_access_token.additional_properties = d
return created_access_token
@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
@@ -0,0 +1,166 @@
import datetime
from collections.abc import Mapping
from typing import TYPE_CHECKING, Any, TypeVar, Union, cast
from uuid import UUID
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
T = TypeVar("T", bound="CreatedTeamAPIKey")
@_attrs_define
class CreatedTeamAPIKey:
"""
Attributes:
created_at (datetime.datetime): Timestamp of API key creation
id (UUID): Identifier of the API key
key (str): Raw value of the API key
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
id: UUID
key: str
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]:
from ..models.team_user import TeamUser
created_at = self.created_at.isoformat()
id = str(self.id)
key = self.key
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
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
field_dict: dict[str, Any] = {}
field_dict.update(self.additional_properties)
field_dict.update(
{
"createdAt": created_at,
"id": id,
"key": key,
"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"))
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()
created_by_type_1 = TeamUser.from_dict(data)
return created_by_type_1
except: # noqa: E722
pass
return cast(Union["TeamUser", None, Unset], data)
created_by = _parse_created_by(d.pop("createdBy", UNSET))
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()
last_used_type_0 = isoparse(data)
return last_used_type_0
except: # noqa: E722
pass
return cast(Union[None, Unset, datetime.datetime], data)
last_used = _parse_last_used(d.pop("lastUsed", UNSET))
created_team_api_key = cls(
created_at=created_at,
id=id,
key=key,
mask=mask,
name=name,
created_by=created_by,
last_used=last_used,
)
created_team_api_key.additional_properties = d
return created_team_api_key
@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
@@ -0,0 +1,67 @@
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="DeleteTemplateTagsRequest")
@_attrs_define
class DeleteTemplateTagsRequest:
"""
Attributes:
name (str): Name of the template
tags (list[str]): Tags to delete
"""
name: str
tags: list[str]
additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict)
def to_dict(self) -> dict[str, Any]:
name = self.name
tags = self.tags
field_dict: dict[str, Any] = {}
field_dict.update(self.additional_properties)
field_dict.update(
{
"name": name,
"tags": tags,
}
)
return field_dict
@classmethod
def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T:
d = dict(src_dict)
name = d.pop("name")
tags = cast(list[str], d.pop("tags"))
delete_template_tags_request = cls(
name=name,
tags=tags,
)
delete_template_tags_request.additional_properties = d
return delete_template_tags_request
@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
@@ -0,0 +1,91 @@
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="DiskMetrics")
@_attrs_define
class DiskMetrics:
"""
Attributes:
device (str): Device name
filesystem_type (str): Filesystem type (e.g., ext4, xfs)
mount_point (str): Mount point of the disk
total_bytes (int): Total space in bytes
used_bytes (int): Used space in bytes
"""
device: str
filesystem_type: str
mount_point: str
total_bytes: int
used_bytes: int
additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict)
def to_dict(self) -> dict[str, Any]:
device = self.device
filesystem_type = self.filesystem_type
mount_point = self.mount_point
total_bytes = self.total_bytes
used_bytes = self.used_bytes
field_dict: dict[str, Any] = {}
field_dict.update(self.additional_properties)
field_dict.update(
{
"device": device,
"filesystemType": filesystem_type,
"mountPoint": mount_point,
"totalBytes": total_bytes,
"usedBytes": used_bytes,
}
)
return field_dict
@classmethod
def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T:
d = dict(src_dict)
device = d.pop("device")
filesystem_type = d.pop("filesystemType")
mount_point = d.pop("mountPoint")
total_bytes = d.pop("totalBytes")
used_bytes = d.pop("usedBytes")
disk_metrics = cls(
device=device,
filesystem_type=filesystem_type,
mount_point=mount_point,
total_bytes=total_bytes,
used_bytes=used_bytes,
)
disk_metrics.additional_properties = d
return disk_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
+67
View File
@@ -0,0 +1,67 @@
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="Error")
@_attrs_define
class Error:
"""
Attributes:
code (int): Error code
message (str): Error
"""
code: int
message: str
additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict)
def to_dict(self) -> dict[str, Any]:
code = self.code
message = self.message
field_dict: dict[str, Any] = {}
field_dict.update(self.additional_properties)
field_dict.update(
{
"code": code,
"message": message,
}
)
return field_dict
@classmethod
def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T:
d = dict(src_dict)
code = d.pop("code")
message = d.pop("message")
error = cls(
code=code,
message=message,
)
error.additional_properties = d
return error
@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
@@ -0,0 +1,69 @@
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 ..models.gcp_registry_type import GCPRegistryType
T = TypeVar("T", bound="GCPRegistry")
@_attrs_define
class GCPRegistry:
"""
Attributes:
service_account_json (str): Service Account JSON for GCP authentication
type_ (GCPRegistryType): Type of registry authentication
"""
service_account_json: str
type_: GCPRegistryType
additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict)
def to_dict(self) -> dict[str, Any]:
service_account_json = self.service_account_json
type_ = self.type_.value
field_dict: dict[str, Any] = {}
field_dict.update(self.additional_properties)
field_dict.update(
{
"serviceAccountJson": service_account_json,
"type": type_,
}
)
return field_dict
@classmethod
def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T:
d = dict(src_dict)
service_account_json = d.pop("serviceAccountJson")
type_ = GCPRegistryType(d.pop("type"))
gcp_registry = cls(
service_account_json=service_account_json,
type_=type_,
)
gcp_registry.additional_properties = d
return gcp_registry
@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
@@ -0,0 +1,8 @@
from enum import Enum
class GCPRegistryType(str, Enum):
GCP = "gcp"
def __str__(self) -> str:
return str(self.value)
@@ -0,0 +1,77 @@
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 ..models.general_registry_type import GeneralRegistryType
T = TypeVar("T", bound="GeneralRegistry")
@_attrs_define
class GeneralRegistry:
"""
Attributes:
password (str): Password to use for the registry
type_ (GeneralRegistryType): Type of registry authentication
username (str): Username to use for the registry
"""
password: str
type_: GeneralRegistryType
username: str
additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict)
def to_dict(self) -> dict[str, Any]:
password = self.password
type_ = self.type_.value
username = self.username
field_dict: dict[str, Any] = {}
field_dict.update(self.additional_properties)
field_dict.update(
{
"password": password,
"type": type_,
"username": username,
}
)
return field_dict
@classmethod
def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T:
d = dict(src_dict)
password = d.pop("password")
type_ = GeneralRegistryType(d.pop("type"))
username = d.pop("username")
general_registry = cls(
password=password,
type_=type_,
username=username,
)
general_registry.additional_properties = d
return general_registry
@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
@@ -0,0 +1,8 @@
from enum import Enum
class GeneralRegistryType(str, Enum):
REGISTRY = "registry"
def __str__(self) -> str:
return str(self.value)
@@ -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
@@ -0,0 +1,179 @@
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 ..models.sandbox_state import SandboxState
from ..types import UNSET, Unset
if TYPE_CHECKING:
from ..models.sandbox_volume_mount import SandboxVolumeMount
T = TypeVar("T", bound="ListedSandbox")
@_attrs_define
class ListedSandbox:
"""
Attributes:
client_id (str): Identifier of the client
cpu_count (int): CPU cores for the sandbox
disk_size_mb (int): Disk size for the sandbox in MiB
end_at (datetime.datetime): Time when the sandbox will expire
envd_version (str): Version of the envd running in the sandbox
memory_mb (int): Memory for the sandbox in MiB
sandbox_id (str): Identifier of the sandbox
started_at (datetime.datetime): Time when the sandbox was started
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
metadata (Union[Unset, Any]):
volume_mounts (Union[Unset, list['SandboxVolumeMount']]):
"""
client_id: str
cpu_count: int
disk_size_mb: int
end_at: datetime.datetime
envd_version: str
memory_mb: int
sandbox_id: str
started_at: datetime.datetime
state: SandboxState
template_id: str
alias: Union[Unset, str] = UNSET
metadata: Union[Unset, Any] = UNSET
volume_mounts: Union[Unset, list["SandboxVolumeMount"]] = 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
disk_size_mb = self.disk_size_mb
end_at = self.end_at.isoformat()
envd_version = self.envd_version
memory_mb = self.memory_mb
sandbox_id = self.sandbox_id
started_at = self.started_at.isoformat()
state = self.state.value
template_id = self.template_id
alias = self.alias
metadata = self.metadata
volume_mounts: Union[Unset, list[dict[str, Any]]] = UNSET
if not isinstance(self.volume_mounts, Unset):
volume_mounts = []
for volume_mounts_item_data in self.volume_mounts:
volume_mounts_item = volume_mounts_item_data.to_dict()
volume_mounts.append(volume_mounts_item)
field_dict: dict[str, Any] = {}
field_dict.update(self.additional_properties)
field_dict.update(
{
"clientID": client_id,
"cpuCount": cpu_count,
"diskSizeMB": disk_size_mb,
"endAt": end_at,
"envdVersion": envd_version,
"memoryMB": memory_mb,
"sandboxID": sandbox_id,
"startedAt": started_at,
"state": state,
"templateID": template_id,
}
)
if alias is not UNSET:
field_dict["alias"] = alias
if metadata is not UNSET:
field_dict["metadata"] = metadata
if volume_mounts is not UNSET:
field_dict["volumeMounts"] = volume_mounts
return field_dict
@classmethod
def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T:
from ..models.sandbox_volume_mount import SandboxVolumeMount
d = dict(src_dict)
client_id = d.pop("clientID")
cpu_count = d.pop("cpuCount")
disk_size_mb = d.pop("diskSizeMB")
end_at = isoparse(d.pop("endAt"))
envd_version = d.pop("envdVersion")
memory_mb = d.pop("memoryMB")
sandbox_id = d.pop("sandboxID")
started_at = isoparse(d.pop("startedAt"))
state = SandboxState(d.pop("state"))
template_id = d.pop("templateID")
alias = d.pop("alias", UNSET)
metadata = d.pop("metadata", UNSET)
volume_mounts = []
_volume_mounts = d.pop("volumeMounts", UNSET)
for volume_mounts_item_data in _volume_mounts or []:
volume_mounts_item = SandboxVolumeMount.from_dict(volume_mounts_item_data)
volume_mounts.append(volume_mounts_item)
listed_sandbox = cls(
client_id=client_id,
cpu_count=cpu_count,
disk_size_mb=disk_size_mb,
end_at=end_at,
envd_version=envd_version,
memory_mb=memory_mb,
sandbox_id=sandbox_id,
started_at=started_at,
state=state,
template_id=template_id,
alias=alias,
metadata=metadata,
volume_mounts=volume_mounts,
)
listed_sandbox.additional_properties = d
return listed_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
+11
View File
@@ -0,0 +1,11 @@
from enum import Enum
class LogLevel(str, Enum):
DEBUG = "debug"
ERROR = "error"
INFO = "info"
WARN = "warn"
def __str__(self) -> str:
return str(self.value)
@@ -0,0 +1,9 @@
from enum import Enum
class LogsDirection(str, Enum):
BACKWARD = "backward"
FORWARD = "forward"
def __str__(self) -> str:
return str(self.value)
@@ -0,0 +1,9 @@
from enum import Enum
class LogsSource(str, Enum):
PERSISTENT = "persistent"
TEMPORARY = "temporary"
def __str__(self) -> str:
return str(self.value)
@@ -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="MachineInfo")
@_attrs_define
class MachineInfo:
"""
Attributes:
cpu_architecture (str): CPU architecture of the node
cpu_family (str): CPU family of the node
cpu_model (str): CPU model of the node
cpu_model_name (str): CPU model name of the node
"""
cpu_architecture: str
cpu_family: str
cpu_model: str
cpu_model_name: str
additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict)
def to_dict(self) -> dict[str, Any]:
cpu_architecture = self.cpu_architecture
cpu_family = self.cpu_family
cpu_model = self.cpu_model
cpu_model_name = self.cpu_model_name
field_dict: dict[str, Any] = {}
field_dict.update(self.additional_properties)
field_dict.update(
{
"cpuArchitecture": cpu_architecture,
"cpuFamily": cpu_family,
"cpuModel": cpu_model,
"cpuModelName": cpu_model_name,
}
)
return field_dict
@classmethod
def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T:
d = dict(src_dict)
cpu_architecture = d.pop("cpuArchitecture")
cpu_family = d.pop("cpuFamily")
cpu_model = d.pop("cpuModel")
cpu_model_name = d.pop("cpuModelName")
machine_info = cls(
cpu_architecture=cpu_architecture,
cpu_family=cpu_family,
cpu_model=cpu_model,
cpu_model_name=cpu_model_name,
)
machine_info.additional_properties = d
return machine_info
@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
@@ -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
+44
View File
@@ -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
@@ -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="NewAccessToken")
@_attrs_define
class NewAccessToken:
"""
Attributes:
name (str): Name of the access token
"""
name: str
additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict)
def to_dict(self) -> dict[str, Any]:
name = self.name
field_dict: dict[str, Any] = {}
field_dict.update(self.additional_properties)
field_dict.update(
{
"name": name,
}
)
return field_dict
@classmethod
def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T:
d = dict(src_dict)
name = d.pop("name")
new_access_token = cls(
name=name,
)
new_access_token.additional_properties = d
return new_access_token
@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
+224
View File
@@ -0,0 +1,224 @@
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 ..types import UNSET, Unset
if TYPE_CHECKING:
from ..models.mcp_type_0 import McpType0
from ..models.sandbox_auto_resume_config import SandboxAutoResumeConfig
from ..models.sandbox_network_config import SandboxNetworkConfig
from ..models.sandbox_volume_mount import SandboxVolumeMount
T = TypeVar("T", bound="NewSandbox")
@_attrs_define
class NewSandbox:
"""
Attributes:
template_id (str): Identifier of the required template
allow_internet_access (Union[Unset, bool]): Allow sandbox to access the internet. When set to false, it behaves
the same as specifying denyOut to 0.0.0.0/0 in the network config.
auto_pause (Union[Unset, bool]): Automatically pauses the sandbox after the timeout Default: False.
auto_pause_memory (Union[Unset, bool]): Controls the snapshot kind taken when the sandbox auto-pauses on timeout
(only relevant when autoPause is true). When false, the auto-pause drops the in-memory state and persists only
the filesystem (a filesystem-only snapshot); resuming it cold-boots (reboots) the sandbox from disk. Such a
snapshot cannot be auto-resumed by traffic and must be resumed explicitly, so it cannot be combined with
autoResume. Defaults to true (full memory snapshot). Default: True.
auto_resume (Union[Unset, SandboxAutoResumeConfig]): Auto-resume configuration for paused sandboxes.
env_vars (Union[Unset, Any]):
mcp (Union['McpType0', None, Unset]): MCP configuration for the sandbox
metadata (Union[Unset, Any]):
network (Union[Unset, SandboxNetworkConfig]):
secure (Union[Unset, bool]): Secure all system communication with sandbox
timeout (Union[Unset, int]): Time to live for the sandbox in seconds. Default: 15.
volume_mounts (Union[Unset, list['SandboxVolumeMount']]):
"""
template_id: str
allow_internet_access: Union[Unset, bool] = UNSET
auto_pause: Union[Unset, bool] = False
auto_pause_memory: Union[Unset, bool] = True
auto_resume: Union[Unset, "SandboxAutoResumeConfig"] = UNSET
env_vars: Union[Unset, Any] = UNSET
mcp: Union["McpType0", None, Unset] = UNSET
metadata: Union[Unset, Any] = UNSET
network: Union[Unset, "SandboxNetworkConfig"] = UNSET
secure: Union[Unset, bool] = UNSET
timeout: Union[Unset, int] = 15
volume_mounts: Union[Unset, list["SandboxVolumeMount"]] = UNSET
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
auto_pause = self.auto_pause
auto_pause_memory = self.auto_pause_memory
auto_resume: Union[Unset, dict[str, Any]] = UNSET
if not isinstance(self.auto_resume, Unset):
auto_resume = self.auto_resume.to_dict()
env_vars = self.env_vars
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
network: Union[Unset, dict[str, Any]] = UNSET
if not isinstance(self.network, Unset):
network = self.network.to_dict()
secure = self.secure
timeout = self.timeout
volume_mounts: Union[Unset, list[dict[str, Any]]] = UNSET
if not isinstance(self.volume_mounts, Unset):
volume_mounts = []
for volume_mounts_item_data in self.volume_mounts:
volume_mounts_item = volume_mounts_item_data.to_dict()
volume_mounts.append(volume_mounts_item)
field_dict: dict[str, Any] = {}
field_dict.update(self.additional_properties)
field_dict.update(
{
"templateID": template_id,
}
)
if allow_internet_access is not UNSET:
field_dict["allow_internet_access"] = allow_internet_access
if auto_pause is not UNSET:
field_dict["autoPause"] = auto_pause
if auto_pause_memory is not UNSET:
field_dict["autoPauseMemory"] = auto_pause_memory
if auto_resume is not UNSET:
field_dict["autoResume"] = auto_resume
if env_vars is not UNSET:
field_dict["envVars"] = env_vars
if mcp is not UNSET:
field_dict["mcp"] = mcp
if metadata is not UNSET:
field_dict["metadata"] = metadata
if network is not UNSET:
field_dict["network"] = network
if secure is not UNSET:
field_dict["secure"] = secure
if timeout is not UNSET:
field_dict["timeout"] = timeout
if volume_mounts is not UNSET:
field_dict["volumeMounts"] = volume_mounts
return field_dict
@classmethod
def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T:
from ..models.mcp_type_0 import McpType0
from ..models.sandbox_auto_resume_config import SandboxAutoResumeConfig
from ..models.sandbox_network_config import SandboxNetworkConfig
from ..models.sandbox_volume_mount import SandboxVolumeMount
d = dict(src_dict)
template_id = d.pop("templateID")
allow_internet_access = d.pop("allow_internet_access", UNSET)
auto_pause = d.pop("autoPause", UNSET)
auto_pause_memory = d.pop("autoPauseMemory", UNSET)
_auto_resume = d.pop("autoResume", UNSET)
auto_resume: Union[Unset, SandboxAutoResumeConfig]
if isinstance(_auto_resume, Unset):
auto_resume = UNSET
else:
auto_resume = SandboxAutoResumeConfig.from_dict(_auto_resume)
env_vars = d.pop("envVars", 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)
_network = d.pop("network", UNSET)
network: Union[Unset, SandboxNetworkConfig]
if isinstance(_network, Unset):
network = UNSET
else:
network = SandboxNetworkConfig.from_dict(_network)
secure = d.pop("secure", UNSET)
timeout = d.pop("timeout", UNSET)
volume_mounts = []
_volume_mounts = d.pop("volumeMounts", UNSET)
for volume_mounts_item_data in _volume_mounts or []:
volume_mounts_item = SandboxVolumeMount.from_dict(volume_mounts_item_data)
volume_mounts.append(volume_mounts_item)
new_sandbox = cls(
template_id=template_id,
allow_internet_access=allow_internet_access,
auto_pause=auto_pause,
auto_pause_memory=auto_pause_memory,
auto_resume=auto_resume,
env_vars=env_vars,
mcp=mcp,
metadata=metadata,
network=network,
secure=secure,
timeout=timeout,
volume_mounts=volume_mounts,
)
new_sandbox.additional_properties = d
return new_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
@@ -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="NewTeamAPIKey")
@_attrs_define
class NewTeamAPIKey:
"""
Attributes:
name (str): Name of the API key
"""
name: str
additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict)
def to_dict(self) -> dict[str, Any]:
name = self.name
field_dict: dict[str, Any] = {}
field_dict.update(self.additional_properties)
field_dict.update(
{
"name": name,
}
)
return field_dict
@classmethod
def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T:
d = dict(src_dict)
name = d.pop("name")
new_team_api_key = cls(
name=name,
)
new_team_api_key.additional_properties = d
return new_team_api_key
@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
+59
View File
@@ -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="NewVolume")
@_attrs_define
class NewVolume:
"""
Attributes:
name (str): Name of the volume
"""
name: str
additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict)
def to_dict(self) -> dict[str, Any]:
name = self.name
field_dict: dict[str, Any] = {}
field_dict.update(self.additional_properties)
field_dict.update(
{
"name": name,
}
)
return field_dict
@classmethod
def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T:
d = dict(src_dict)
name = d.pop("name")
new_volume = cls(
name=name,
)
new_volume.additional_properties = d
return new_volume
@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
+160
View File
@@ -0,0 +1,160 @@
from collections.abc import Mapping
from typing import TYPE_CHECKING, Any, TypeVar
from attrs import define as _attrs_define
from attrs import field as _attrs_field
from ..models.node_status import NodeStatus
if TYPE_CHECKING:
from ..models.machine_info import MachineInfo
from ..models.node_metrics import NodeMetrics
T = TypeVar("T", bound="Node")
@_attrs_define
class Node:
"""
Attributes:
cluster_id (str): Identifier of the cluster
commit (str): Commit of the orchestrator
create_fails (int): Number of sandbox create fails
create_successes (int): Number of sandbox create successes
id (str): Identifier of the node
machine_info (MachineInfo):
metrics (NodeMetrics): Node metrics
sandbox_count (int): Number of sandboxes running on the node
sandbox_starting_count (int): Number of starting Sandboxes
service_instance_id (str): Service instance identifier of the node
status (NodeStatus): Status of the node.
- draining: the node is bound to be shut down. It will not accept new sandboxes and will stop once all existing
sandboxes are done.
- standby: the node is not actively used, but it can return to ready and continue serving traffic.
version (str): Version of the orchestrator
"""
cluster_id: str
commit: str
create_fails: int
create_successes: int
id: str
machine_info: "MachineInfo"
metrics: "NodeMetrics"
sandbox_count: int
sandbox_starting_count: int
service_instance_id: str
status: NodeStatus
version: str
additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict)
def to_dict(self) -> dict[str, Any]:
cluster_id = self.cluster_id
commit = self.commit
create_fails = self.create_fails
create_successes = self.create_successes
id = self.id
machine_info = self.machine_info.to_dict()
metrics = self.metrics.to_dict()
sandbox_count = self.sandbox_count
sandbox_starting_count = self.sandbox_starting_count
service_instance_id = self.service_instance_id
status = self.status.value
version = self.version
field_dict: dict[str, Any] = {}
field_dict.update(self.additional_properties)
field_dict.update(
{
"clusterID": cluster_id,
"commit": commit,
"createFails": create_fails,
"createSuccesses": create_successes,
"id": id,
"machineInfo": machine_info,
"metrics": metrics,
"sandboxCount": sandbox_count,
"sandboxStartingCount": sandbox_starting_count,
"serviceInstanceID": service_instance_id,
"status": status,
"version": version,
}
)
return field_dict
@classmethod
def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T:
from ..models.machine_info import MachineInfo
from ..models.node_metrics import NodeMetrics
d = dict(src_dict)
cluster_id = d.pop("clusterID")
commit = d.pop("commit")
create_fails = d.pop("createFails")
create_successes = d.pop("createSuccesses")
id = d.pop("id")
machine_info = MachineInfo.from_dict(d.pop("machineInfo"))
metrics = NodeMetrics.from_dict(d.pop("metrics"))
sandbox_count = d.pop("sandboxCount")
sandbox_starting_count = d.pop("sandboxStartingCount")
service_instance_id = d.pop("serviceInstanceID")
status = NodeStatus(d.pop("status"))
version = d.pop("version")
node = cls(
cluster_id=cluster_id,
commit=commit,
create_fails=create_fails,
create_successes=create_successes,
id=id,
machine_info=machine_info,
metrics=metrics,
sandbox_count=sandbox_count,
sandbox_starting_count=sandbox_starting_count,
service_instance_id=service_instance_id,
status=status,
version=version,
)
node.additional_properties = d
return node
@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
+160
View File
@@ -0,0 +1,160 @@
from collections.abc import Mapping
from typing import TYPE_CHECKING, Any, TypeVar, cast
from attrs import define as _attrs_define
from attrs import field as _attrs_field
from ..models.node_status import NodeStatus
if TYPE_CHECKING:
from ..models.machine_info import MachineInfo
from ..models.node_metrics import NodeMetrics
T = TypeVar("T", bound="NodeDetail")
@_attrs_define
class NodeDetail:
"""
Attributes:
cached_builds (list[str]): List of cached builds id on the node
cluster_id (str): Identifier of the cluster
commit (str): Commit of the orchestrator
create_fails (int): Number of sandbox create fails
create_successes (int): Number of sandbox create successes
id (str): Identifier of the node
machine_info (MachineInfo):
metrics (NodeMetrics): Node metrics
sandbox_count (int): Number of sandboxes running on the node
service_instance_id (str): Service instance identifier of the node
status (NodeStatus): Status of the node.
- draining: the node is bound to be shut down. It will not accept new sandboxes and will stop once all existing
sandboxes are done.
- standby: the node is not actively used, but it can return to ready and continue serving traffic.
version (str): Version of the orchestrator
"""
cached_builds: list[str]
cluster_id: str
commit: str
create_fails: int
create_successes: int
id: str
machine_info: "MachineInfo"
metrics: "NodeMetrics"
sandbox_count: int
service_instance_id: str
status: NodeStatus
version: str
additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict)
def to_dict(self) -> dict[str, Any]:
cached_builds = self.cached_builds
cluster_id = self.cluster_id
commit = self.commit
create_fails = self.create_fails
create_successes = self.create_successes
id = self.id
machine_info = self.machine_info.to_dict()
metrics = self.metrics.to_dict()
sandbox_count = self.sandbox_count
service_instance_id = self.service_instance_id
status = self.status.value
version = self.version
field_dict: dict[str, Any] = {}
field_dict.update(self.additional_properties)
field_dict.update(
{
"cachedBuilds": cached_builds,
"clusterID": cluster_id,
"commit": commit,
"createFails": create_fails,
"createSuccesses": create_successes,
"id": id,
"machineInfo": machine_info,
"metrics": metrics,
"sandboxCount": sandbox_count,
"serviceInstanceID": service_instance_id,
"status": status,
"version": version,
}
)
return field_dict
@classmethod
def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T:
from ..models.machine_info import MachineInfo
from ..models.node_metrics import NodeMetrics
d = dict(src_dict)
cached_builds = cast(list[str], d.pop("cachedBuilds"))
cluster_id = d.pop("clusterID")
commit = d.pop("commit")
create_fails = d.pop("createFails")
create_successes = d.pop("createSuccesses")
id = d.pop("id")
machine_info = MachineInfo.from_dict(d.pop("machineInfo"))
metrics = NodeMetrics.from_dict(d.pop("metrics"))
sandbox_count = d.pop("sandboxCount")
service_instance_id = d.pop("serviceInstanceID")
status = NodeStatus(d.pop("status"))
version = d.pop("version")
node_detail = cls(
cached_builds=cached_builds,
cluster_id=cluster_id,
commit=commit,
create_fails=create_fails,
create_successes=create_successes,
id=id,
machine_info=machine_info,
metrics=metrics,
sandbox_count=sandbox_count,
service_instance_id=service_instance_id,
status=status,
version=version,
)
node_detail.additional_properties = d
return node_detail
@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
+122
View File
@@ -0,0 +1,122 @@
from collections.abc import Mapping
from typing import TYPE_CHECKING, Any, TypeVar
from attrs import define as _attrs_define
from attrs import field as _attrs_field
if TYPE_CHECKING:
from ..models.disk_metrics import DiskMetrics
T = TypeVar("T", bound="NodeMetrics")
@_attrs_define
class NodeMetrics:
"""Node metrics
Attributes:
allocated_cpu (int): Number of allocated CPU cores
allocated_memory_bytes (int): Amount of allocated memory in bytes
cpu_count (int): Total number of CPU cores on the node
cpu_percent (int): Node CPU usage percentage
disks (list['DiskMetrics']): Detailed metrics for each disk/mount point
memory_total_bytes (int): Total node memory in bytes
memory_used_bytes (int): Node memory used in bytes
"""
allocated_cpu: int
allocated_memory_bytes: int
cpu_count: int
cpu_percent: int
disks: list["DiskMetrics"]
memory_total_bytes: int
memory_used_bytes: int
additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict)
def to_dict(self) -> dict[str, Any]:
allocated_cpu = self.allocated_cpu
allocated_memory_bytes = self.allocated_memory_bytes
cpu_count = self.cpu_count
cpu_percent = self.cpu_percent
disks = []
for disks_item_data in self.disks:
disks_item = disks_item_data.to_dict()
disks.append(disks_item)
memory_total_bytes = self.memory_total_bytes
memory_used_bytes = self.memory_used_bytes
field_dict: dict[str, Any] = {}
field_dict.update(self.additional_properties)
field_dict.update(
{
"allocatedCPU": allocated_cpu,
"allocatedMemoryBytes": allocated_memory_bytes,
"cpuCount": cpu_count,
"cpuPercent": cpu_percent,
"disks": disks,
"memoryTotalBytes": memory_total_bytes,
"memoryUsedBytes": memory_used_bytes,
}
)
return field_dict
@classmethod
def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T:
from ..models.disk_metrics import DiskMetrics
d = dict(src_dict)
allocated_cpu = d.pop("allocatedCPU")
allocated_memory_bytes = d.pop("allocatedMemoryBytes")
cpu_count = d.pop("cpuCount")
cpu_percent = d.pop("cpuPercent")
disks = []
_disks = d.pop("disks")
for disks_item_data in _disks:
disks_item = DiskMetrics.from_dict(disks_item_data)
disks.append(disks_item)
memory_total_bytes = d.pop("memoryTotalBytes")
memory_used_bytes = d.pop("memoryUsedBytes")
node_metrics = cls(
allocated_cpu=allocated_cpu,
allocated_memory_bytes=allocated_memory_bytes,
cpu_count=cpu_count,
cpu_percent=cpu_percent,
disks=disks,
memory_total_bytes=memory_total_bytes,
memory_used_bytes=memory_used_bytes,
)
node_metrics.additional_properties = d
return node_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
+12
View File
@@ -0,0 +1,12 @@
from enum import Enum
class NodeStatus(str, Enum):
CONNECTING = "connecting"
DRAINING = "draining"
READY = "ready"
STANDBY = "standby"
UNHEALTHY = "unhealthy"
def __str__(self) -> str:
return str(self.value)
@@ -0,0 +1,82 @@
from collections.abc import Mapping
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")
@_attrs_define
class NodeStatusChange:
"""
Attributes:
status (NodeStatus): Status of the node.
- draining: the node is bound to be shut down. It will not accept new sandboxes and will stop once all existing
sandboxes are done.
- standby: the node is not actively used, but it can return to ready and continue serving traffic.
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(
{
"status": status,
}
)
if cluster_id is not UNSET:
field_dict["clusterID"] = cluster_id
return field_dict
@classmethod
def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T:
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
return node_status_change
@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
@@ -0,0 +1,59 @@
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="PostSandboxesSandboxIDRefreshesBody")
@_attrs_define
class PostSandboxesSandboxIDRefreshesBody:
"""
Attributes:
duration (Union[Unset, int]): Duration for which the sandbox should be kept alive in seconds
"""
duration: Union[Unset, int] = UNSET
additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict)
def to_dict(self) -> dict[str, Any]:
duration = self.duration
field_dict: dict[str, Any] = {}
field_dict.update(self.additional_properties)
field_dict.update({})
if duration is not UNSET:
field_dict["duration"] = duration
return field_dict
@classmethod
def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T:
d = dict(src_dict)
duration = d.pop("duration", UNSET)
post_sandboxes_sandbox_id_refreshes_body = cls(
duration=duration,
)
post_sandboxes_sandbox_id_refreshes_body.additional_properties = d
return post_sandboxes_sandbox_id_refreshes_body
@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
@@ -0,0 +1,60 @@
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="PostSandboxesSandboxIDSnapshotsBody")
@_attrs_define
class PostSandboxesSandboxIDSnapshotsBody:
"""
Attributes:
name (Union[Unset, str]): Optional name for the snapshot template. If a snapshot template with this name already
exists, a new build will be assigned to the existing template instead of creating a new one.
"""
name: Union[Unset, str] = UNSET
additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict)
def to_dict(self) -> dict[str, Any]:
name = self.name
field_dict: dict[str, Any] = {}
field_dict.update(self.additional_properties)
field_dict.update({})
if name is not UNSET:
field_dict["name"] = name
return field_dict
@classmethod
def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T:
d = dict(src_dict)
name = d.pop("name", UNSET)
post_sandboxes_sandbox_id_snapshots_body = cls(
name=name,
)
post_sandboxes_sandbox_id_snapshots_body.additional_properties = d
return post_sandboxes_sandbox_id_snapshots_body
@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
@@ -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="PostSandboxesSandboxIDTimeoutBody")
@_attrs_define
class PostSandboxesSandboxIDTimeoutBody:
"""
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")
post_sandboxes_sandbox_id_timeout_body = cls(
timeout=timeout,
)
post_sandboxes_sandbox_id_timeout_body.additional_properties = d
return post_sandboxes_sandbox_id_timeout_body
@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
@@ -0,0 +1,68 @@
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="ResumedSandbox")
@_attrs_define
class ResumedSandbox:
"""
Attributes:
auto_pause (Union[Unset, bool]): Automatically pauses the sandbox after the timeout
timeout (Union[Unset, int]): Time to live for the sandbox in seconds. Default: 15.
"""
auto_pause: 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]:
auto_pause = self.auto_pause
timeout = self.timeout
field_dict: dict[str, Any] = {}
field_dict.update(self.additional_properties)
field_dict.update({})
if auto_pause is not UNSET:
field_dict["autoPause"] = auto_pause
if timeout is not UNSET:
field_dict["timeout"] = timeout
return field_dict
@classmethod
def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T:
d = dict(src_dict)
auto_pause = d.pop("autoPause", UNSET)
timeout = d.pop("timeout", UNSET)
resumed_sandbox = cls(
auto_pause=auto_pause,
timeout=timeout,
)
resumed_sandbox.additional_properties = d
return resumed_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
+145
View File
@@ -0,0 +1,145 @@
from collections.abc import Mapping
from typing import Any, TypeVar, Union, cast
from attrs import define as _attrs_define
from attrs import field as _attrs_field
from ..types import UNSET, Unset
T = TypeVar("T", bound="Sandbox")
@_attrs_define
class Sandbox:
"""
Attributes:
client_id (str): Identifier of the client
envd_version (str): Version of the envd running in the 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
traffic_access_token (Union[None, Unset, str]): Token required for accessing sandbox via proxy.
"""
client_id: str
envd_version: str
sandbox_id: str
template_id: str
alias: Union[Unset, str] = UNSET
domain: Union[None, Unset, str] = UNSET
envd_access_token: Union[Unset, str] = UNSET
traffic_access_token: Union[None, Unset, str] = UNSET
additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict)
def to_dict(self) -> dict[str, Any]:
client_id = self.client_id
envd_version = self.envd_version
sandbox_id = self.sandbox_id
template_id = self.template_id
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
traffic_access_token: Union[None, Unset, str]
if isinstance(self.traffic_access_token, Unset):
traffic_access_token = UNSET
else:
traffic_access_token = self.traffic_access_token
field_dict: dict[str, Any] = {}
field_dict.update(self.additional_properties)
field_dict.update(
{
"clientID": client_id,
"envdVersion": envd_version,
"sandboxID": sandbox_id,
"templateID": template_id,
}
)
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 traffic_access_token is not UNSET:
field_dict["trafficAccessToken"] = traffic_access_token
return field_dict
@classmethod
def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T:
d = dict(src_dict)
client_id = d.pop("clientID")
envd_version = d.pop("envdVersion")
sandbox_id = d.pop("sandboxID")
template_id = d.pop("templateID")
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)
def _parse_traffic_access_token(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)
traffic_access_token = _parse_traffic_access_token(
d.pop("trafficAccessToken", UNSET)
)
sandbox = cls(
client_id=client_id,
envd_version=envd_version,
sandbox_id=sandbox_id,
template_id=template_id,
alias=alias,
domain=domain,
envd_access_token=envd_access_token,
traffic_access_token=traffic_access_token,
)
sandbox.additional_properties = d
return 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
@@ -0,0 +1,60 @@
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="SandboxAutoResumeConfig")
@_attrs_define
class SandboxAutoResumeConfig:
"""Auto-resume configuration for paused sandboxes.
Attributes:
enabled (bool): Auto-resume enabled flag for paused sandboxes. Default false.
"""
enabled: bool
additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict)
def to_dict(self) -> dict[str, Any]:
enabled = self.enabled
field_dict: dict[str, Any] = {}
field_dict.update(self.additional_properties)
field_dict.update(
{
"enabled": enabled,
}
)
return field_dict
@classmethod
def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T:
d = dict(src_dict)
enabled = d.pop("enabled")
sandbox_auto_resume_config = cls(
enabled=enabled,
)
sandbox_auto_resume_config.additional_properties = d
return sandbox_auto_resume_config
@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
@@ -0,0 +1,267 @@
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
from ..models.sandbox_state import SandboxState
from ..types import UNSET, Unset
if TYPE_CHECKING:
from ..models.sandbox_lifecycle import SandboxLifecycle
from ..models.sandbox_network_config import SandboxNetworkConfig
from ..models.sandbox_volume_mount import SandboxVolumeMount
T = TypeVar("T", bound="SandboxDetail")
@_attrs_define
class SandboxDetail:
"""
Attributes:
client_id (str): Identifier of the client
cpu_count (int): CPU cores for the sandbox
disk_size_mb (int): Disk size for the sandbox in MiB
end_at (datetime.datetime): Time when the sandbox will expire
envd_version (str): Version of the envd running in the sandbox
memory_mb (int): Memory for the sandbox in MiB
sandbox_id (str): Identifier of the sandbox
started_at (datetime.datetime): Time when the sandbox was started
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
allow_internet_access (Union[None, Unset, bool]): Whether internet access was explicitly enabled or disabled for
the sandbox. Null means it was not explicitly set.
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
lifecycle (Union[Unset, SandboxLifecycle]): Sandbox lifecycle policy returned by sandbox info.
metadata (Union[Unset, Any]):
network (Union[Unset, SandboxNetworkConfig]):
volume_mounts (Union[Unset, list['SandboxVolumeMount']]):
"""
client_id: str
cpu_count: int
disk_size_mb: int
end_at: datetime.datetime
envd_version: str
memory_mb: int
sandbox_id: str
started_at: datetime.datetime
state: SandboxState
template_id: str
alias: Union[Unset, str] = UNSET
allow_internet_access: Union[None, Unset, bool] = UNSET
domain: Union[None, Unset, str] = UNSET
envd_access_token: Union[Unset, str] = UNSET
lifecycle: Union[Unset, "SandboxLifecycle"] = UNSET
metadata: Union[Unset, Any] = UNSET
network: Union[Unset, "SandboxNetworkConfig"] = UNSET
volume_mounts: Union[Unset, list["SandboxVolumeMount"]] = 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
disk_size_mb = self.disk_size_mb
end_at = self.end_at.isoformat()
envd_version = self.envd_version
memory_mb = self.memory_mb
sandbox_id = self.sandbox_id
started_at = self.started_at.isoformat()
state = self.state.value
template_id = self.template_id
alias = self.alias
allow_internet_access: Union[None, Unset, bool]
if isinstance(self.allow_internet_access, Unset):
allow_internet_access = UNSET
else:
allow_internet_access = self.allow_internet_access
domain: Union[None, Unset, str]
if isinstance(self.domain, Unset):
domain = UNSET
else:
domain = self.domain
envd_access_token = self.envd_access_token
lifecycle: Union[Unset, dict[str, Any]] = UNSET
if not isinstance(self.lifecycle, Unset):
lifecycle = self.lifecycle.to_dict()
metadata = self.metadata
network: Union[Unset, dict[str, Any]] = UNSET
if not isinstance(self.network, Unset):
network = self.network.to_dict()
volume_mounts: Union[Unset, list[dict[str, Any]]] = UNSET
if not isinstance(self.volume_mounts, Unset):
volume_mounts = []
for volume_mounts_item_data in self.volume_mounts:
volume_mounts_item = volume_mounts_item_data.to_dict()
volume_mounts.append(volume_mounts_item)
field_dict: dict[str, Any] = {}
field_dict.update(self.additional_properties)
field_dict.update(
{
"clientID": client_id,
"cpuCount": cpu_count,
"diskSizeMB": disk_size_mb,
"endAt": end_at,
"envdVersion": envd_version,
"memoryMB": memory_mb,
"sandboxID": sandbox_id,
"startedAt": started_at,
"state": state,
"templateID": template_id,
}
)
if alias is not UNSET:
field_dict["alias"] = alias
if allow_internet_access is not UNSET:
field_dict["allowInternetAccess"] = allow_internet_access
if domain is not UNSET:
field_dict["domain"] = domain
if envd_access_token is not UNSET:
field_dict["envdAccessToken"] = envd_access_token
if lifecycle is not UNSET:
field_dict["lifecycle"] = lifecycle
if metadata is not UNSET:
field_dict["metadata"] = metadata
if network is not UNSET:
field_dict["network"] = network
if volume_mounts is not UNSET:
field_dict["volumeMounts"] = volume_mounts
return field_dict
@classmethod
def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T:
from ..models.sandbox_lifecycle import SandboxLifecycle
from ..models.sandbox_network_config import SandboxNetworkConfig
from ..models.sandbox_volume_mount import SandboxVolumeMount
d = dict(src_dict)
client_id = d.pop("clientID")
cpu_count = d.pop("cpuCount")
disk_size_mb = d.pop("diskSizeMB")
end_at = isoparse(d.pop("endAt"))
envd_version = d.pop("envdVersion")
memory_mb = d.pop("memoryMB")
sandbox_id = d.pop("sandboxID")
started_at = isoparse(d.pop("startedAt"))
state = SandboxState(d.pop("state"))
template_id = d.pop("templateID")
alias = d.pop("alias", UNSET)
def _parse_allow_internet_access(data: object) -> Union[None, Unset, bool]:
if data is None:
return data
if isinstance(data, Unset):
return data
return cast(Union[None, Unset, bool], data)
allow_internet_access = _parse_allow_internet_access(
d.pop("allowInternetAccess", 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)
_lifecycle = d.pop("lifecycle", UNSET)
lifecycle: Union[Unset, SandboxLifecycle]
if isinstance(_lifecycle, Unset):
lifecycle = UNSET
else:
lifecycle = SandboxLifecycle.from_dict(_lifecycle)
metadata = d.pop("metadata", UNSET)
_network = d.pop("network", UNSET)
network: Union[Unset, SandboxNetworkConfig]
if isinstance(_network, Unset):
network = UNSET
else:
network = SandboxNetworkConfig.from_dict(_network)
volume_mounts = []
_volume_mounts = d.pop("volumeMounts", UNSET)
for volume_mounts_item_data in _volume_mounts or []:
volume_mounts_item = SandboxVolumeMount.from_dict(volume_mounts_item_data)
volume_mounts.append(volume_mounts_item)
sandbox_detail = cls(
client_id=client_id,
cpu_count=cpu_count,
disk_size_mb=disk_size_mb,
end_at=end_at,
envd_version=envd_version,
memory_mb=memory_mb,
sandbox_id=sandbox_id,
started_at=started_at,
state=state,
template_id=template_id,
alias=alias,
allow_internet_access=allow_internet_access,
domain=domain,
envd_access_token=envd_access_token,
lifecycle=lifecycle,
metadata=metadata,
network=network,
volume_mounts=volume_mounts,
)
sandbox_detail.additional_properties = d
return sandbox_detail
@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
@@ -0,0 +1,70 @@
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 ..models.sandbox_on_timeout import SandboxOnTimeout
T = TypeVar("T", bound="SandboxLifecycle")
@_attrs_define
class SandboxLifecycle:
"""Sandbox lifecycle policy returned by sandbox info.
Attributes:
auto_resume (bool): Whether the sandbox can auto-resume.
on_timeout (SandboxOnTimeout): Action taken when the sandbox times out.
"""
auto_resume: bool
on_timeout: SandboxOnTimeout
additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict)
def to_dict(self) -> dict[str, Any]:
auto_resume = self.auto_resume
on_timeout = self.on_timeout.value
field_dict: dict[str, Any] = {}
field_dict.update(self.additional_properties)
field_dict.update(
{
"autoResume": auto_resume,
"onTimeout": on_timeout,
}
)
return field_dict
@classmethod
def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T:
d = dict(src_dict)
auto_resume = d.pop("autoResume")
on_timeout = SandboxOnTimeout(d.pop("onTimeout"))
sandbox_lifecycle = cls(
auto_resume=auto_resume,
on_timeout=on_timeout,
)
sandbox_lifecycle.additional_properties = d
return sandbox_lifecycle
@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
+70
View File
@@ -0,0 +1,70 @@
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="SandboxLog")
@_attrs_define
class SandboxLog:
"""Log entry with timestamp and line
Attributes:
line (str): Log line content
timestamp (datetime.datetime): Timestamp of the log entry
"""
line: str
timestamp: datetime.datetime
additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict)
def to_dict(self) -> dict[str, Any]:
line = self.line
timestamp = self.timestamp.isoformat()
field_dict: dict[str, Any] = {}
field_dict.update(self.additional_properties)
field_dict.update(
{
"line": line,
"timestamp": timestamp,
}
)
return field_dict
@classmethod
def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T:
d = dict(src_dict)
line = d.pop("line")
timestamp = isoparse(d.pop("timestamp"))
sandbox_log = cls(
line=line,
timestamp=timestamp,
)
sandbox_log.additional_properties = d
return sandbox_log
@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
@@ -0,0 +1,93 @@
import datetime
from collections.abc import Mapping
from typing import TYPE_CHECKING, Any, TypeVar
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
if TYPE_CHECKING:
from ..models.sandbox_log_entry_fields import SandboxLogEntryFields
T = TypeVar("T", bound="SandboxLogEntry")
@_attrs_define
class SandboxLogEntry:
"""
Attributes:
fields (SandboxLogEntryFields):
level (LogLevel): State of the sandbox
message (str): Log message content
timestamp (datetime.datetime): Timestamp of the log entry
"""
fields: "SandboxLogEntryFields"
level: LogLevel
message: str
timestamp: datetime.datetime
additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict)
def to_dict(self) -> dict[str, Any]:
fields = self.fields.to_dict()
level = self.level.value
message = self.message
timestamp = self.timestamp.isoformat()
field_dict: dict[str, Any] = {}
field_dict.update(self.additional_properties)
field_dict.update(
{
"fields": fields,
"level": level,
"message": message,
"timestamp": timestamp,
}
)
return field_dict
@classmethod
def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T:
from ..models.sandbox_log_entry_fields import SandboxLogEntryFields
d = dict(src_dict)
fields = SandboxLogEntryFields.from_dict(d.pop("fields"))
level = LogLevel(d.pop("level"))
message = d.pop("message")
timestamp = isoparse(d.pop("timestamp"))
sandbox_log_entry = cls(
fields=fields,
level=level,
message=message,
timestamp=timestamp,
)
sandbox_log_entry.additional_properties = d
return sandbox_log_entry
@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
@@ -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="SandboxLogEntryFields")
@_attrs_define
class SandboxLogEntryFields:
""" """
additional_properties: dict[str, str] = _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)
sandbox_log_entry_fields = cls()
sandbox_log_entry_fields.additional_properties = d
return sandbox_log_entry_fields
@property
def additional_keys(self) -> list[str]:
return list(self.additional_properties.keys())
def __getitem__(self, key: str) -> str:
return self.additional_properties[key]
def __setitem__(self, key: str, value: str) -> 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
@@ -0,0 +1,91 @@
from collections.abc import Mapping
from typing import TYPE_CHECKING, Any, TypeVar
from attrs import define as _attrs_define
from attrs import field as _attrs_field
if TYPE_CHECKING:
from ..models.sandbox_log import SandboxLog
from ..models.sandbox_log_entry import SandboxLogEntry
T = TypeVar("T", bound="SandboxLogs")
@_attrs_define
class SandboxLogs:
"""
Attributes:
log_entries (list['SandboxLogEntry']): Structured logs of the sandbox
logs (list['SandboxLog']): Logs of the sandbox
"""
log_entries: list["SandboxLogEntry"]
logs: list["SandboxLog"]
additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict)
def to_dict(self) -> dict[str, Any]:
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)
logs = []
for logs_item_data in self.logs:
logs_item = logs_item_data.to_dict()
logs.append(logs_item)
field_dict: dict[str, Any] = {}
field_dict.update(self.additional_properties)
field_dict.update(
{
"logEntries": log_entries,
"logs": logs,
}
)
return field_dict
@classmethod
def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T:
from ..models.sandbox_log import SandboxLog
from ..models.sandbox_log_entry import SandboxLogEntry
d = dict(src_dict)
log_entries = []
_log_entries = d.pop("logEntries")
for log_entries_item_data in _log_entries:
log_entries_item = SandboxLogEntry.from_dict(log_entries_item_data)
log_entries.append(log_entries_item)
logs = []
_logs = d.pop("logs")
for logs_item_data in _logs:
logs_item = SandboxLog.from_dict(logs_item_data)
logs.append(logs_item)
sandbox_logs = cls(
log_entries=log_entries,
logs=logs,
)
sandbox_logs.additional_properties = d
return sandbox_logs
@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
@@ -0,0 +1,73 @@
from collections.abc import Mapping
from typing import TYPE_CHECKING, Any, TypeVar
from attrs import define as _attrs_define
from attrs import field as _attrs_field
if TYPE_CHECKING:
from ..models.sandbox_log_entry import SandboxLogEntry
T = TypeVar("T", bound="SandboxLogsV2Response")
@_attrs_define
class SandboxLogsV2Response:
"""
Attributes:
logs (list['SandboxLogEntry']): Sandbox logs structured
"""
logs: list["SandboxLogEntry"]
additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict)
def to_dict(self) -> dict[str, Any]:
logs = []
for logs_item_data in self.logs:
logs_item = logs_item_data.to_dict()
logs.append(logs_item)
field_dict: dict[str, Any] = {}
field_dict.update(self.additional_properties)
field_dict.update(
{
"logs": logs,
}
)
return field_dict
@classmethod
def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T:
from ..models.sandbox_log_entry import SandboxLogEntry
d = dict(src_dict)
logs = []
_logs = d.pop("logs")
for logs_item_data in _logs:
logs_item = SandboxLogEntry.from_dict(logs_item_data)
logs.append(logs_item)
sandbox_logs_v2_response = cls(
logs=logs,
)
sandbox_logs_v2_response.additional_properties = d
return sandbox_logs_v2_response
@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
@@ -0,0 +1,126 @@
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="SandboxMetric")
@_attrs_define
class SandboxMetric:
"""Metric entry with timestamp and line
Attributes:
cpu_count (int): Number of CPU cores
cpu_used_pct (float): CPU usage percentage
disk_total (int): Total disk space in bytes
disk_used (int): Disk used in bytes
mem_cache (int): Cached memory (page cache) in bytes
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
cpu_used_pct: float
disk_total: int
disk_used: int
mem_cache: int
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]:
cpu_count = self.cpu_count
cpu_used_pct = self.cpu_used_pct
disk_total = self.disk_total
disk_used = self.disk_used
mem_cache = self.mem_cache
mem_total = self.mem_total
mem_used = self.mem_used
timestamp = self.timestamp.isoformat()
timestamp_unix = self.timestamp_unix
field_dict: dict[str, Any] = {}
field_dict.update(self.additional_properties)
field_dict.update(
{
"cpuCount": cpu_count,
"cpuUsedPct": cpu_used_pct,
"diskTotal": disk_total,
"diskUsed": disk_used,
"memCache": mem_cache,
"memTotal": mem_total,
"memUsed": mem_used,
"timestamp": timestamp,
"timestampUnix": timestamp_unix,
}
)
return field_dict
@classmethod
def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T:
d = dict(src_dict)
cpu_count = d.pop("cpuCount")
cpu_used_pct = d.pop("cpuUsedPct")
disk_total = d.pop("diskTotal")
disk_used = d.pop("diskUsed")
mem_cache = d.pop("memCache")
mem_total = d.pop("memTotal")
mem_used = d.pop("memUsed")
timestamp = isoparse(d.pop("timestamp"))
timestamp_unix = d.pop("timestampUnix")
sandbox_metric = cls(
cpu_count=cpu_count,
cpu_used_pct=cpu_used_pct,
disk_total=disk_total,
disk_used=disk_used,
mem_cache=mem_cache,
mem_total=mem_total,
mem_used=mem_used,
timestamp=timestamp,
timestamp_unix=timestamp_unix,
)
sandbox_metric.additional_properties = d
return sandbox_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
@@ -0,0 +1,118 @@
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 ..types import UNSET, Unset
if TYPE_CHECKING:
from ..models.sandbox_network_config_rules import SandboxNetworkConfigRules
T = TypeVar("T", bound="SandboxNetworkConfig")
@_attrs_define
class SandboxNetworkConfig:
"""
Attributes:
allow_out (Union[Unset, list[str]]): List of allowed destinations for egress traffic. Each entry can be a CIDR
block (e.g. "8.8.8.8/32"), a bare IP address (e.g. "8.8.8.8"), or a domain name (e.g. "example.com",
"*.example.com"). Allowed entries always take precedence over denied entries.
allow_public_traffic (Union[Unset, bool]): Specify if the sandbox URLs should be accessible only with
authentication. Default: True.
deny_out (Union[Unset, list[str]]): List of denied CIDR blocks or IP addresses for egress traffic. Domain names
are not supported for deny rules.
mask_request_host (Union[Unset, str]): Specify host mask which will be used for all sandbox requests
rules (Union[Unset, SandboxNetworkConfigRules]): Per-domain transform rules applied to matching egress
HTTP/HTTPS requests. Keys are domains (e.g. "api.example.com", "example.com"). A domain listed here is not
automatically allowed - use allowOut to permit the traffic.
"""
allow_out: Union[Unset, list[str]] = UNSET
allow_public_traffic: Union[Unset, bool] = True
deny_out: Union[Unset, list[str]] = UNSET
mask_request_host: Union[Unset, str] = UNSET
rules: Union[Unset, "SandboxNetworkConfigRules"] = UNSET
additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict)
def to_dict(self) -> dict[str, Any]:
allow_out: Union[Unset, list[str]] = UNSET
if not isinstance(self.allow_out, Unset):
allow_out = self.allow_out
allow_public_traffic = self.allow_public_traffic
deny_out: Union[Unset, list[str]] = UNSET
if not isinstance(self.deny_out, Unset):
deny_out = self.deny_out
mask_request_host = self.mask_request_host
rules: Union[Unset, dict[str, Any]] = UNSET
if not isinstance(self.rules, Unset):
rules = self.rules.to_dict()
field_dict: dict[str, Any] = {}
field_dict.update(self.additional_properties)
field_dict.update({})
if allow_out is not UNSET:
field_dict["allowOut"] = allow_out
if allow_public_traffic is not UNSET:
field_dict["allowPublicTraffic"] = allow_public_traffic
if deny_out is not UNSET:
field_dict["denyOut"] = deny_out
if mask_request_host is not UNSET:
field_dict["maskRequestHost"] = mask_request_host
if rules is not UNSET:
field_dict["rules"] = rules
return field_dict
@classmethod
def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T:
from ..models.sandbox_network_config_rules import SandboxNetworkConfigRules
d = dict(src_dict)
allow_out = cast(list[str], d.pop("allowOut", UNSET))
allow_public_traffic = d.pop("allowPublicTraffic", UNSET)
deny_out = cast(list[str], d.pop("denyOut", UNSET))
mask_request_host = d.pop("maskRequestHost", UNSET)
_rules = d.pop("rules", UNSET)
rules: Union[Unset, SandboxNetworkConfigRules]
if isinstance(_rules, Unset):
rules = UNSET
else:
rules = SandboxNetworkConfigRules.from_dict(_rules)
sandbox_network_config = cls(
allow_out=allow_out,
allow_public_traffic=allow_public_traffic,
deny_out=deny_out,
mask_request_host=mask_request_host,
rules=rules,
)
sandbox_network_config.additional_properties = d
return sandbox_network_config
@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
@@ -0,0 +1,72 @@
from collections.abc import Mapping
from typing import TYPE_CHECKING, Any, TypeVar
from attrs import define as _attrs_define
from attrs import field as _attrs_field
if TYPE_CHECKING:
from ..models.sandbox_network_rule import SandboxNetworkRule
T = TypeVar("T", bound="SandboxNetworkConfigRules")
@_attrs_define
class SandboxNetworkConfigRules:
"""Per-domain transform rules applied to matching egress HTTP/HTTPS requests. Keys are domains (e.g. "api.example.com",
"example.com"). A domain listed here is not automatically allowed - use allowOut to permit the traffic.
"""
additional_properties: dict[str, list["SandboxNetworkRule"]] = _attrs_field(
init=False, factory=dict
)
def to_dict(self) -> dict[str, Any]:
field_dict: dict[str, Any] = {}
for prop_name, prop in self.additional_properties.items():
field_dict[prop_name] = []
for additional_property_item_data in prop:
additional_property_item = additional_property_item_data.to_dict()
field_dict[prop_name].append(additional_property_item)
return field_dict
@classmethod
def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T:
from ..models.sandbox_network_rule import SandboxNetworkRule
d = dict(src_dict)
sandbox_network_config_rules = cls()
additional_properties = {}
for prop_name, prop_dict in d.items():
additional_property = []
_additional_property = prop_dict
for additional_property_item_data in _additional_property:
additional_property_item = SandboxNetworkRule.from_dict(
additional_property_item_data
)
additional_property.append(additional_property_item)
additional_properties[prop_name] = additional_property
sandbox_network_config_rules.additional_properties = additional_properties
return sandbox_network_config_rules
@property
def additional_keys(self) -> list[str]:
return list(self.additional_properties.keys())
def __getitem__(self, key: str) -> list["SandboxNetworkRule"]:
return self.additional_properties[key]
def __setitem__(self, key: str, value: list["SandboxNetworkRule"]) -> 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

Some files were not shown because too many files have changed in this diff Show More