-
Notifications
You must be signed in to change notification settings - Fork 899
Expand file tree
/
Copy pathnew_sandbox.py
More file actions
181 lines (140 loc) · 5.93 KB
/
new_sandbox.py
File metadata and controls
181 lines (140 loc) · 5.93 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
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_network_config import SandboxNetworkConfig
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_resume (Union[Unset, Any]): Auto-resume configuration for paused sandboxes. Use {"policy": "any"} to allow any request. Omit or use {"policy": "off"} to disable auto-resume.
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.
"""
template_id: str
allow_internet_access: Union[Unset, bool] = UNSET
auto_pause: Union[Unset, bool] = False
auto_resume: Union[Unset, Any] = 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
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_resume = self.auto_resume
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
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_resume is not UNSET and auto_resume is not None:
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
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_network_config import SandboxNetworkConfig
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_resume = d.pop("autoResume", UNSET)
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)
new_sandbox = cls(
template_id=template_id,
allow_internet_access=allow_internet_access,
auto_pause=auto_pause,
auto_resume=auto_resume,
env_vars=env_vars,
mcp=mcp,
metadata=metadata,
network=network,
secure=secure,
timeout=timeout,
)
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