Files
zeekay 0c7efccf40 feat: Add new Dockerfiles and improve containerization
- Add main Dockerfile for production builds
- Add Dockerfile.runtime for secure code execution
- Add Dockerfile.runtime.fixed with improved configuration
- Include .dockerignore for build optimization
- Add integration documentation and publishing guides
- Update API and CLI components for better runtime support
- Enhance sandbox and container management features
2025-08-16 23:03:39 -05:00

212 lines
11 KiB
Python
Generated

# coding: utf-8
"""
Runtime
Runtime AI platform API Docs
The version of the OpenAPI document: 1.0
Contact: [email protected]
Generated by OpenAPI Generator (https://openapi-generator.tech)
Do not edit the class manually.
""" # noqa: E501
from __future__ import annotations
import pprint
import re # noqa: F401
import json
from pydantic import BaseModel, ConfigDict, Field, StrictBool, StrictFloat, StrictInt, StrictStr, field_validator
from typing import Any, ClassVar, Dict, List, Optional, Union
from runtime_api_client.models.build_info import BuildInfo
from runtime_api_client.models.sandbox_desired_state import SandboxDesiredState
from runtime_api_client.models.sandbox_info import SandboxInfo
from runtime_api_client.models.sandbox_state import SandboxState
from runtime_api_client.models.sandbox_volume import SandboxVolume
from typing import Optional, Set
from typing_extensions import Self
class Workspace(BaseModel):
"""
Workspace
""" # noqa: E501
id: StrictStr = Field(description="The ID of the sandbox")
organization_id: StrictStr = Field(description="The organization ID of the sandbox", alias="organizationId")
snapshot: Optional[StrictStr] = Field(default=None, description="The snapshot used for the sandbox")
user: StrictStr = Field(description="The user associated with the project")
env: Dict[str, StrictStr] = Field(description="Environment variables for the sandbox")
labels: Dict[str, StrictStr] = Field(description="Labels for the sandbox")
public: StrictBool = Field(description="Whether the sandbox http preview is public")
target: StrictStr = Field(description="The target environment for the sandbox")
cpu: Union[StrictFloat, StrictInt] = Field(description="The CPU quota for the sandbox")
gpu: Union[StrictFloat, StrictInt] = Field(description="The GPU quota for the sandbox")
memory: Union[StrictFloat, StrictInt] = Field(description="The memory quota for the sandbox")
disk: Union[StrictFloat, StrictInt] = Field(description="The disk quota for the sandbox")
state: Optional[SandboxState] = Field(default=None, description="The state of the sandbox")
desired_state: Optional[SandboxDesiredState] = Field(default=None, description="The desired state of the sandbox", alias="desiredState")
error_reason: Optional[StrictStr] = Field(default=None, description="The error reason of the sandbox", alias="errorReason")
backup_state: Optional[StrictStr] = Field(default=None, description="The state of the backup", alias="backupState")
backup_created_at: Optional[StrictStr] = Field(default=None, description="The creation timestamp of the last backup", alias="backupCreatedAt")
auto_stop_interval: Optional[Union[StrictFloat, StrictInt]] = Field(default=None, description="Auto-stop interval in minutes (0 means disabled)", alias="autoStopInterval")
auto_archive_interval: Optional[Union[StrictFloat, StrictInt]] = Field(default=None, description="Auto-archive interval in minutes", alias="autoArchiveInterval")
auto_delete_interval: Optional[Union[StrictFloat, StrictInt]] = Field(default=None, description="Auto-delete interval in minutes (negative value means disabled, 0 means delete immediately upon stopping)", alias="autoDeleteInterval")
runner_domain: Optional[StrictStr] = Field(default=None, description="The domain name of the runner", alias="runnerDomain")
volumes: Optional[List[SandboxVolume]] = Field(default=None, description="Array of volumes attached to the sandbox")
build_info: Optional[BuildInfo] = Field(default=None, description="Build information for the sandbox", alias="buildInfo")
created_at: Optional[StrictStr] = Field(default=None, description="The creation timestamp of the sandbox", alias="createdAt")
updated_at: Optional[StrictStr] = Field(default=None, description="The last update timestamp of the sandbox", alias="updatedAt")
var_class: Optional[StrictStr] = Field(default=None, description="The class of the sandbox", alias="class")
daemon_version: Optional[StrictStr] = Field(default=None, description="The version of the daemon running in the sandbox", alias="daemonVersion")
name: StrictStr = Field(description="The name of the workspace")
image: Optional[StrictStr] = Field(default=None, description="The image used for the workspace")
snapshot_state: Optional[StrictStr] = Field(default=None, description="The state of the snapshot", alias="snapshotState")
snapshot_created_at: Optional[StrictStr] = Field(default=None, description="The creation timestamp of the last snapshot", alias="snapshotCreatedAt")
info: Optional[SandboxInfo] = Field(default=None, description="Additional information about the sandbox")
additional_properties: Dict[str, Any] = {}
__properties: ClassVar[List[str]] = ["id", "organizationId", "snapshot", "user", "env", "labels", "public", "target", "cpu", "gpu", "memory", "disk", "state", "desiredState", "errorReason", "backupState", "backupCreatedAt", "autoStopInterval", "autoArchiveInterval", "autoDeleteInterval", "runnerDomain", "volumes", "buildInfo", "createdAt", "updatedAt", "class", "daemonVersion", "name", "image", "snapshotState", "snapshotCreatedAt", "info"]
@field_validator('backup_state')
def backup_state_validate_enum(cls, value):
"""Validates the enum"""
if value is None:
return value
if value not in set(['None', 'Pending', 'InProgress', 'Completed', 'Error']):
raise ValueError("must be one of enum values ('None', 'Pending', 'InProgress', 'Completed', 'Error')")
return value
@field_validator('var_class')
def var_class_validate_enum(cls, value):
"""Validates the enum"""
if value is None:
return value
if value not in set(['small', 'medium', 'large']):
raise ValueError("must be one of enum values ('small', 'medium', 'large')")
return value
@field_validator('snapshot_state')
def snapshot_state_validate_enum(cls, value):
"""Validates the enum"""
if value is None:
return value
if value not in set(['None', 'Pending', 'InProgress', 'Completed', 'Error']):
raise ValueError("must be one of enum values ('None', 'Pending', 'InProgress', 'Completed', 'Error')")
return value
model_config = ConfigDict(
populate_by_name=True,
validate_assignment=True,
protected_namespaces=(),
)
def to_str(self) -> str:
"""Returns the string representation of the model using alias"""
return pprint.pformat(self.model_dump(by_alias=True))
def to_json(self) -> str:
"""Returns the JSON representation of the model using alias"""
# TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead
return json.dumps(self.to_dict())
@classmethod
def from_json(cls, json_str: str) -> Optional[Self]:
"""Create an instance of Workspace from a JSON string"""
return cls.from_dict(json.loads(json_str))
def to_dict(self) -> Dict[str, Any]:
"""Return the dictionary representation of the model using alias.
This has the following differences from calling pydantic's
`self.model_dump(by_alias=True)`:
* `None` is only added to the output dict for nullable fields that
were set at model initialization. Other fields with value `None`
are ignored.
* Fields in `self.additional_properties` are added to the output dict.
"""
excluded_fields: Set[str] = set([
"additional_properties",
])
_dict = self.model_dump(
by_alias=True,
exclude=excluded_fields,
exclude_none=True,
)
# override the default output from pydantic by calling `to_dict()` of each item in volumes (list)
_items = []
if self.volumes:
for _item_volumes in self.volumes:
if _item_volumes:
_items.append(_item_volumes.to_dict())
_dict['volumes'] = _items
# override the default output from pydantic by calling `to_dict()` of build_info
if self.build_info:
_dict['buildInfo'] = self.build_info.to_dict()
# override the default output from pydantic by calling `to_dict()` of info
if self.info:
_dict['info'] = self.info.to_dict()
# puts key-value pairs in additional_properties in the top level
if self.additional_properties is not None:
for _key, _value in self.additional_properties.items():
_dict[_key] = _value
return _dict
@classmethod
def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
"""Create an instance of Workspace from a dict"""
if obj is None:
return None
if not isinstance(obj, dict):
return cls.model_validate(obj)
_obj = cls.model_validate({
"id": obj.get("id"),
"organizationId": obj.get("organizationId"),
"snapshot": obj.get("snapshot"),
"user": obj.get("user"),
"env": obj.get("env"),
"labels": obj.get("labels"),
"public": obj.get("public"),
"target": obj.get("target"),
"cpu": obj.get("cpu"),
"gpu": obj.get("gpu"),
"memory": obj.get("memory"),
"disk": obj.get("disk"),
"state": obj.get("state"),
"desiredState": obj.get("desiredState"),
"errorReason": obj.get("errorReason"),
"backupState": obj.get("backupState"),
"backupCreatedAt": obj.get("backupCreatedAt"),
"autoStopInterval": obj.get("autoStopInterval"),
"autoArchiveInterval": obj.get("autoArchiveInterval"),
"autoDeleteInterval": obj.get("autoDeleteInterval"),
"runnerDomain": obj.get("runnerDomain"),
"volumes": [SandboxVolume.from_dict(_item) for _item in obj["volumes"]] if obj.get("volumes") is not None else None,
"buildInfo": BuildInfo.from_dict(obj["buildInfo"]) if obj.get("buildInfo") is not None else None,
"createdAt": obj.get("createdAt"),
"updatedAt": obj.get("updatedAt"),
"class": obj.get("class"),
"daemonVersion": obj.get("daemonVersion"),
"name": obj.get("name") if obj.get("name") is not None else '',
"image": obj.get("image"),
"snapshotState": obj.get("snapshotState"),
"snapshotCreatedAt": obj.get("snapshotCreatedAt"),
"info": SandboxInfo.from_dict(obj["info"]) if obj.get("info") is not None else None
})
# store additional fields in additional_properties
for _key in obj.keys():
if _key not in cls.__properties:
_obj.additional_properties[_key] = obj.get(_key)
return _obj