moru 0.1.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- moru/__init__.py +174 -0
- moru/api/__init__.py +164 -0
- moru/api/client/__init__.py +8 -0
- moru/api/client/api/__init__.py +1 -0
- moru/api/client/api/sandboxes/__init__.py +1 -0
- moru/api/client/api/sandboxes/delete_sandboxes_sandbox_id.py +161 -0
- moru/api/client/api/sandboxes/get_sandboxes.py +176 -0
- moru/api/client/api/sandboxes/get_sandboxes_metrics.py +173 -0
- moru/api/client/api/sandboxes/get_sandboxes_sandbox_id.py +163 -0
- moru/api/client/api/sandboxes/get_sandboxes_sandbox_id_logs.py +199 -0
- moru/api/client/api/sandboxes/get_sandboxes_sandbox_id_metrics.py +212 -0
- moru/api/client/api/sandboxes/get_v2_sandboxes.py +230 -0
- moru/api/client/api/sandboxes/post_sandboxes.py +172 -0
- moru/api/client/api/sandboxes/post_sandboxes_sandbox_id_connect.py +193 -0
- moru/api/client/api/sandboxes/post_sandboxes_sandbox_id_pause.py +165 -0
- moru/api/client/api/sandboxes/post_sandboxes_sandbox_id_refreshes.py +181 -0
- moru/api/client/api/sandboxes/post_sandboxes_sandbox_id_resume.py +189 -0
- moru/api/client/api/sandboxes/post_sandboxes_sandbox_id_timeout.py +193 -0
- moru/api/client/api/templates/__init__.py +1 -0
- moru/api/client/api/templates/delete_templates_template_id.py +157 -0
- moru/api/client/api/templates/get_templates.py +172 -0
- moru/api/client/api/templates/get_templates_template_id.py +195 -0
- moru/api/client/api/templates/get_templates_template_id_builds_build_id_status.py +217 -0
- moru/api/client/api/templates/get_templates_template_id_files_hash.py +180 -0
- moru/api/client/api/templates/patch_templates_template_id.py +183 -0
- moru/api/client/api/templates/post_templates.py +172 -0
- moru/api/client/api/templates/post_templates_template_id.py +181 -0
- moru/api/client/api/templates/post_templates_template_id_builds_build_id.py +170 -0
- moru/api/client/api/templates/post_v2_templates.py +172 -0
- moru/api/client/api/templates/post_v3_templates.py +172 -0
- moru/api/client/api/templates/post_v_2_templates_template_id_builds_build_id.py +192 -0
- moru/api/client/client.py +286 -0
- moru/api/client/errors.py +16 -0
- moru/api/client/models/__init__.py +123 -0
- moru/api/client/models/aws_registry.py +85 -0
- moru/api/client/models/aws_registry_type.py +8 -0
- moru/api/client/models/build_log_entry.py +89 -0
- moru/api/client/models/build_status_reason.py +95 -0
- moru/api/client/models/connect_sandbox.py +59 -0
- moru/api/client/models/created_access_token.py +100 -0
- moru/api/client/models/created_team_api_key.py +166 -0
- moru/api/client/models/disk_metrics.py +91 -0
- moru/api/client/models/error.py +67 -0
- moru/api/client/models/gcp_registry.py +69 -0
- moru/api/client/models/gcp_registry_type.py +8 -0
- moru/api/client/models/general_registry.py +77 -0
- moru/api/client/models/general_registry_type.py +8 -0
- moru/api/client/models/identifier_masking_details.py +83 -0
- moru/api/client/models/listed_sandbox.py +154 -0
- moru/api/client/models/log_level.py +11 -0
- moru/api/client/models/max_team_metric.py +78 -0
- moru/api/client/models/mcp_type_0.py +44 -0
- moru/api/client/models/new_access_token.py +59 -0
- moru/api/client/models/new_sandbox.py +172 -0
- moru/api/client/models/new_team_api_key.py +59 -0
- moru/api/client/models/node.py +155 -0
- moru/api/client/models/node_detail.py +165 -0
- moru/api/client/models/node_metrics.py +122 -0
- moru/api/client/models/node_status.py +11 -0
- moru/api/client/models/node_status_change.py +79 -0
- moru/api/client/models/post_sandboxes_sandbox_id_refreshes_body.py +59 -0
- moru/api/client/models/post_sandboxes_sandbox_id_timeout_body.py +59 -0
- moru/api/client/models/resumed_sandbox.py +68 -0
- moru/api/client/models/sandbox.py +145 -0
- moru/api/client/models/sandbox_detail.py +183 -0
- moru/api/client/models/sandbox_log.py +70 -0
- moru/api/client/models/sandbox_log_entry.py +93 -0
- moru/api/client/models/sandbox_log_entry_fields.py +44 -0
- moru/api/client/models/sandbox_logs.py +91 -0
- moru/api/client/models/sandbox_metric.py +118 -0
- moru/api/client/models/sandbox_network_config.py +92 -0
- moru/api/client/models/sandbox_state.py +9 -0
- moru/api/client/models/sandboxes_with_metrics.py +59 -0
- moru/api/client/models/team.py +83 -0
- moru/api/client/models/team_api_key.py +158 -0
- moru/api/client/models/team_metric.py +86 -0
- moru/api/client/models/team_user.py +68 -0
- moru/api/client/models/template.py +217 -0
- moru/api/client/models/template_build.py +139 -0
- moru/api/client/models/template_build_file_upload.py +70 -0
- moru/api/client/models/template_build_info.py +126 -0
- moru/api/client/models/template_build_request.py +115 -0
- moru/api/client/models/template_build_request_v2.py +88 -0
- moru/api/client/models/template_build_request_v3.py +88 -0
- moru/api/client/models/template_build_start_v2.py +184 -0
- moru/api/client/models/template_build_status.py +11 -0
- moru/api/client/models/template_legacy.py +207 -0
- moru/api/client/models/template_request_response_v3.py +83 -0
- moru/api/client/models/template_step.py +91 -0
- moru/api/client/models/template_update_request.py +59 -0
- moru/api/client/models/template_with_builds.py +148 -0
- moru/api/client/models/update_team_api_key.py +59 -0
- moru/api/client/py.typed +1 -0
- moru/api/client/types.py +54 -0
- moru/api/client_async/__init__.py +50 -0
- moru/api/client_sync/__init__.py +52 -0
- moru/api/metadata.py +14 -0
- moru/connection_config.py +217 -0
- moru/envd/api.py +59 -0
- moru/envd/filesystem/filesystem_connect.py +193 -0
- moru/envd/filesystem/filesystem_pb2.py +76 -0
- moru/envd/filesystem/filesystem_pb2.pyi +233 -0
- moru/envd/process/process_connect.py +155 -0
- moru/envd/process/process_pb2.py +92 -0
- moru/envd/process/process_pb2.pyi +304 -0
- moru/envd/rpc.py +61 -0
- moru/envd/versions.py +6 -0
- moru/exceptions.py +95 -0
- moru/sandbox/commands/command_handle.py +69 -0
- moru/sandbox/commands/main.py +39 -0
- moru/sandbox/filesystem/filesystem.py +94 -0
- moru/sandbox/filesystem/watch_handle.py +60 -0
- moru/sandbox/main.py +210 -0
- moru/sandbox/mcp.py +1120 -0
- moru/sandbox/network.py +8 -0
- moru/sandbox/sandbox_api.py +210 -0
- moru/sandbox/signature.py +45 -0
- moru/sandbox/utils.py +34 -0
- moru/sandbox_async/commands/command.py +336 -0
- moru/sandbox_async/commands/command_handle.py +196 -0
- moru/sandbox_async/commands/pty.py +240 -0
- moru/sandbox_async/filesystem/filesystem.py +531 -0
- moru/sandbox_async/filesystem/watch_handle.py +62 -0
- moru/sandbox_async/main.py +734 -0
- moru/sandbox_async/paginator.py +69 -0
- moru/sandbox_async/sandbox_api.py +325 -0
- moru/sandbox_async/utils.py +7 -0
- moru/sandbox_sync/commands/command.py +328 -0
- moru/sandbox_sync/commands/command_handle.py +150 -0
- moru/sandbox_sync/commands/pty.py +230 -0
- moru/sandbox_sync/filesystem/filesystem.py +518 -0
- moru/sandbox_sync/filesystem/watch_handle.py +69 -0
- moru/sandbox_sync/main.py +726 -0
- moru/sandbox_sync/paginator.py +69 -0
- moru/sandbox_sync/sandbox_api.py +308 -0
- moru/template/consts.py +30 -0
- moru/template/dockerfile_parser.py +275 -0
- moru/template/logger.py +232 -0
- moru/template/main.py +1360 -0
- moru/template/readycmd.py +138 -0
- moru/template/types.py +105 -0
- moru/template/utils.py +320 -0
- moru/template_async/build_api.py +202 -0
- moru/template_async/main.py +366 -0
- moru/template_sync/build_api.py +199 -0
- moru/template_sync/main.py +371 -0
- moru-0.1.0.dist-info/METADATA +63 -0
- moru-0.1.0.dist-info/RECORD +152 -0
- moru-0.1.0.dist-info/WHEEL +4 -0
- moru-0.1.0.dist-info/licenses/LICENSE +9 -0
- moru_connect/__init__.py +1 -0
- moru_connect/client.py +493 -0
|
@@ -0,0 +1,286 @@
|
|
|
1
|
+
import ssl
|
|
2
|
+
from typing import Any, Optional, Union
|
|
3
|
+
|
|
4
|
+
import httpx
|
|
5
|
+
from attrs import define, evolve, field
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
@define
|
|
9
|
+
class Client:
|
|
10
|
+
"""A class for keeping track of data related to the API
|
|
11
|
+
|
|
12
|
+
The following are accepted as keyword arguments and will be used to construct httpx Clients internally:
|
|
13
|
+
|
|
14
|
+
``base_url``: The base URL for the API, all requests are made to a relative path to this URL
|
|
15
|
+
|
|
16
|
+
``cookies``: A dictionary of cookies to be sent with every request
|
|
17
|
+
|
|
18
|
+
``headers``: A dictionary of headers to be sent with every request
|
|
19
|
+
|
|
20
|
+
``timeout``: The maximum amount of a time a request can take. API functions will raise
|
|
21
|
+
httpx.TimeoutException if this is exceeded.
|
|
22
|
+
|
|
23
|
+
``verify_ssl``: Whether or not to verify the SSL certificate of the API server. This should be True in production,
|
|
24
|
+
but can be set to False for testing purposes.
|
|
25
|
+
|
|
26
|
+
``follow_redirects``: Whether or not to follow redirects. Default value is False.
|
|
27
|
+
|
|
28
|
+
``httpx_args``: A dictionary of additional arguments to be passed to the ``httpx.Client`` and ``httpx.AsyncClient`` constructor.
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
Attributes:
|
|
32
|
+
raise_on_unexpected_status: Whether or not to raise an errors.UnexpectedStatus if the API returns a
|
|
33
|
+
status code that was not documented in the source OpenAPI document. Can also be provided as a keyword
|
|
34
|
+
argument to the constructor.
|
|
35
|
+
"""
|
|
36
|
+
|
|
37
|
+
raise_on_unexpected_status: bool = field(default=False, kw_only=True)
|
|
38
|
+
_base_url: str = field(alias="base_url")
|
|
39
|
+
_cookies: dict[str, str] = field(factory=dict, kw_only=True, alias="cookies")
|
|
40
|
+
_headers: dict[str, str] = field(factory=dict, kw_only=True, alias="headers")
|
|
41
|
+
_timeout: Optional[httpx.Timeout] = field(
|
|
42
|
+
default=None, kw_only=True, alias="timeout"
|
|
43
|
+
)
|
|
44
|
+
_verify_ssl: Union[str, bool, ssl.SSLContext] = field(
|
|
45
|
+
default=True, kw_only=True, alias="verify_ssl"
|
|
46
|
+
)
|
|
47
|
+
_follow_redirects: bool = field(
|
|
48
|
+
default=False, kw_only=True, alias="follow_redirects"
|
|
49
|
+
)
|
|
50
|
+
_httpx_args: dict[str, Any] = field(factory=dict, kw_only=True, alias="httpx_args")
|
|
51
|
+
_client: Optional[httpx.Client] = field(default=None, init=False)
|
|
52
|
+
_async_client: Optional[httpx.AsyncClient] = field(default=None, init=False)
|
|
53
|
+
|
|
54
|
+
def with_headers(self, headers: dict[str, str]) -> "Client":
|
|
55
|
+
"""Get a new client matching this one with additional headers"""
|
|
56
|
+
if self._client is not None:
|
|
57
|
+
self._client.headers.update(headers)
|
|
58
|
+
if self._async_client is not None:
|
|
59
|
+
self._async_client.headers.update(headers)
|
|
60
|
+
return evolve(self, headers={**self._headers, **headers})
|
|
61
|
+
|
|
62
|
+
def with_cookies(self, cookies: dict[str, str]) -> "Client":
|
|
63
|
+
"""Get a new client matching this one with additional cookies"""
|
|
64
|
+
if self._client is not None:
|
|
65
|
+
self._client.cookies.update(cookies)
|
|
66
|
+
if self._async_client is not None:
|
|
67
|
+
self._async_client.cookies.update(cookies)
|
|
68
|
+
return evolve(self, cookies={**self._cookies, **cookies})
|
|
69
|
+
|
|
70
|
+
def with_timeout(self, timeout: httpx.Timeout) -> "Client":
|
|
71
|
+
"""Get a new client matching this one with a new timeout (in seconds)"""
|
|
72
|
+
if self._client is not None:
|
|
73
|
+
self._client.timeout = timeout
|
|
74
|
+
if self._async_client is not None:
|
|
75
|
+
self._async_client.timeout = timeout
|
|
76
|
+
return evolve(self, timeout=timeout)
|
|
77
|
+
|
|
78
|
+
def set_httpx_client(self, client: httpx.Client) -> "Client":
|
|
79
|
+
"""Manually set the underlying httpx.Client
|
|
80
|
+
|
|
81
|
+
**NOTE**: This will override any other settings on the client, including cookies, headers, and timeout.
|
|
82
|
+
"""
|
|
83
|
+
self._client = client
|
|
84
|
+
return self
|
|
85
|
+
|
|
86
|
+
def get_httpx_client(self) -> httpx.Client:
|
|
87
|
+
"""Get the underlying httpx.Client, constructing a new one if not previously set"""
|
|
88
|
+
if self._client is None:
|
|
89
|
+
self._client = httpx.Client(
|
|
90
|
+
base_url=self._base_url,
|
|
91
|
+
cookies=self._cookies,
|
|
92
|
+
headers=self._headers,
|
|
93
|
+
timeout=self._timeout,
|
|
94
|
+
verify=self._verify_ssl,
|
|
95
|
+
follow_redirects=self._follow_redirects,
|
|
96
|
+
**self._httpx_args,
|
|
97
|
+
)
|
|
98
|
+
return self._client
|
|
99
|
+
|
|
100
|
+
def __enter__(self) -> "Client":
|
|
101
|
+
"""Enter a context manager for self.client—you cannot enter twice (see httpx docs)"""
|
|
102
|
+
self.get_httpx_client().__enter__()
|
|
103
|
+
return self
|
|
104
|
+
|
|
105
|
+
def __exit__(self, *args: Any, **kwargs: Any) -> None:
|
|
106
|
+
"""Exit a context manager for internal httpx.Client (see httpx docs)"""
|
|
107
|
+
self.get_httpx_client().__exit__(*args, **kwargs)
|
|
108
|
+
|
|
109
|
+
def set_async_httpx_client(self, async_client: httpx.AsyncClient) -> "Client":
|
|
110
|
+
"""Manually the underlying httpx.AsyncClient
|
|
111
|
+
|
|
112
|
+
**NOTE**: This will override any other settings on the client, including cookies, headers, and timeout.
|
|
113
|
+
"""
|
|
114
|
+
self._async_client = async_client
|
|
115
|
+
return self
|
|
116
|
+
|
|
117
|
+
def get_async_httpx_client(self) -> httpx.AsyncClient:
|
|
118
|
+
"""Get the underlying httpx.AsyncClient, constructing a new one if not previously set"""
|
|
119
|
+
if self._async_client is None:
|
|
120
|
+
self._async_client = httpx.AsyncClient(
|
|
121
|
+
base_url=self._base_url,
|
|
122
|
+
cookies=self._cookies,
|
|
123
|
+
headers=self._headers,
|
|
124
|
+
timeout=self._timeout,
|
|
125
|
+
verify=self._verify_ssl,
|
|
126
|
+
follow_redirects=self._follow_redirects,
|
|
127
|
+
**self._httpx_args,
|
|
128
|
+
)
|
|
129
|
+
return self._async_client
|
|
130
|
+
|
|
131
|
+
async def __aenter__(self) -> "Client":
|
|
132
|
+
"""Enter a context manager for underlying httpx.AsyncClient—you cannot enter twice (see httpx docs)"""
|
|
133
|
+
await self.get_async_httpx_client().__aenter__()
|
|
134
|
+
return self
|
|
135
|
+
|
|
136
|
+
async def __aexit__(self, *args: Any, **kwargs: Any) -> None:
|
|
137
|
+
"""Exit a context manager for underlying httpx.AsyncClient (see httpx docs)"""
|
|
138
|
+
await self.get_async_httpx_client().__aexit__(*args, **kwargs)
|
|
139
|
+
|
|
140
|
+
|
|
141
|
+
@define
|
|
142
|
+
class AuthenticatedClient:
|
|
143
|
+
"""A Client which has been authenticated for use on secured endpoints
|
|
144
|
+
|
|
145
|
+
The following are accepted as keyword arguments and will be used to construct httpx Clients internally:
|
|
146
|
+
|
|
147
|
+
``base_url``: The base URL for the API, all requests are made to a relative path to this URL
|
|
148
|
+
|
|
149
|
+
``cookies``: A dictionary of cookies to be sent with every request
|
|
150
|
+
|
|
151
|
+
``headers``: A dictionary of headers to be sent with every request
|
|
152
|
+
|
|
153
|
+
``timeout``: The maximum amount of a time a request can take. API functions will raise
|
|
154
|
+
httpx.TimeoutException if this is exceeded.
|
|
155
|
+
|
|
156
|
+
``verify_ssl``: Whether or not to verify the SSL certificate of the API server. This should be True in production,
|
|
157
|
+
but can be set to False for testing purposes.
|
|
158
|
+
|
|
159
|
+
``follow_redirects``: Whether or not to follow redirects. Default value is False.
|
|
160
|
+
|
|
161
|
+
``httpx_args``: A dictionary of additional arguments to be passed to the ``httpx.Client`` and ``httpx.AsyncClient`` constructor.
|
|
162
|
+
|
|
163
|
+
|
|
164
|
+
Attributes:
|
|
165
|
+
raise_on_unexpected_status: Whether or not to raise an errors.UnexpectedStatus if the API returns a
|
|
166
|
+
status code that was not documented in the source OpenAPI document. Can also be provided as a keyword
|
|
167
|
+
argument to the constructor.
|
|
168
|
+
token: The token to use for authentication
|
|
169
|
+
prefix: The prefix to use for the Authorization header
|
|
170
|
+
auth_header_name: The name of the Authorization header
|
|
171
|
+
"""
|
|
172
|
+
|
|
173
|
+
raise_on_unexpected_status: bool = field(default=False, kw_only=True)
|
|
174
|
+
_base_url: str = field(alias="base_url")
|
|
175
|
+
_cookies: dict[str, str] = field(factory=dict, kw_only=True, alias="cookies")
|
|
176
|
+
_headers: dict[str, str] = field(factory=dict, kw_only=True, alias="headers")
|
|
177
|
+
_timeout: Optional[httpx.Timeout] = field(
|
|
178
|
+
default=None, kw_only=True, alias="timeout"
|
|
179
|
+
)
|
|
180
|
+
_verify_ssl: Union[str, bool, ssl.SSLContext] = field(
|
|
181
|
+
default=True, kw_only=True, alias="verify_ssl"
|
|
182
|
+
)
|
|
183
|
+
_follow_redirects: bool = field(
|
|
184
|
+
default=False, kw_only=True, alias="follow_redirects"
|
|
185
|
+
)
|
|
186
|
+
_httpx_args: dict[str, Any] = field(factory=dict, kw_only=True, alias="httpx_args")
|
|
187
|
+
_client: Optional[httpx.Client] = field(default=None, init=False)
|
|
188
|
+
_async_client: Optional[httpx.AsyncClient] = field(default=None, init=False)
|
|
189
|
+
|
|
190
|
+
token: str
|
|
191
|
+
prefix: str = "Bearer"
|
|
192
|
+
auth_header_name: str = "Authorization"
|
|
193
|
+
|
|
194
|
+
def with_headers(self, headers: dict[str, str]) -> "AuthenticatedClient":
|
|
195
|
+
"""Get a new client matching this one with additional headers"""
|
|
196
|
+
if self._client is not None:
|
|
197
|
+
self._client.headers.update(headers)
|
|
198
|
+
if self._async_client is not None:
|
|
199
|
+
self._async_client.headers.update(headers)
|
|
200
|
+
return evolve(self, headers={**self._headers, **headers})
|
|
201
|
+
|
|
202
|
+
def with_cookies(self, cookies: dict[str, str]) -> "AuthenticatedClient":
|
|
203
|
+
"""Get a new client matching this one with additional cookies"""
|
|
204
|
+
if self._client is not None:
|
|
205
|
+
self._client.cookies.update(cookies)
|
|
206
|
+
if self._async_client is not None:
|
|
207
|
+
self._async_client.cookies.update(cookies)
|
|
208
|
+
return evolve(self, cookies={**self._cookies, **cookies})
|
|
209
|
+
|
|
210
|
+
def with_timeout(self, timeout: httpx.Timeout) -> "AuthenticatedClient":
|
|
211
|
+
"""Get a new client matching this one with a new timeout (in seconds)"""
|
|
212
|
+
if self._client is not None:
|
|
213
|
+
self._client.timeout = timeout
|
|
214
|
+
if self._async_client is not None:
|
|
215
|
+
self._async_client.timeout = timeout
|
|
216
|
+
return evolve(self, timeout=timeout)
|
|
217
|
+
|
|
218
|
+
def set_httpx_client(self, client: httpx.Client) -> "AuthenticatedClient":
|
|
219
|
+
"""Manually set the underlying httpx.Client
|
|
220
|
+
|
|
221
|
+
**NOTE**: This will override any other settings on the client, including cookies, headers, and timeout.
|
|
222
|
+
"""
|
|
223
|
+
self._client = client
|
|
224
|
+
return self
|
|
225
|
+
|
|
226
|
+
def get_httpx_client(self) -> httpx.Client:
|
|
227
|
+
"""Get the underlying httpx.Client, constructing a new one if not previously set"""
|
|
228
|
+
if self._client is None:
|
|
229
|
+
self._headers[self.auth_header_name] = (
|
|
230
|
+
f"{self.prefix} {self.token}" if self.prefix else self.token
|
|
231
|
+
)
|
|
232
|
+
self._client = httpx.Client(
|
|
233
|
+
base_url=self._base_url,
|
|
234
|
+
cookies=self._cookies,
|
|
235
|
+
headers=self._headers,
|
|
236
|
+
timeout=self._timeout,
|
|
237
|
+
verify=self._verify_ssl,
|
|
238
|
+
follow_redirects=self._follow_redirects,
|
|
239
|
+
**self._httpx_args,
|
|
240
|
+
)
|
|
241
|
+
return self._client
|
|
242
|
+
|
|
243
|
+
def __enter__(self) -> "AuthenticatedClient":
|
|
244
|
+
"""Enter a context manager for self.client—you cannot enter twice (see httpx docs)"""
|
|
245
|
+
self.get_httpx_client().__enter__()
|
|
246
|
+
return self
|
|
247
|
+
|
|
248
|
+
def __exit__(self, *args: Any, **kwargs: Any) -> None:
|
|
249
|
+
"""Exit a context manager for internal httpx.Client (see httpx docs)"""
|
|
250
|
+
self.get_httpx_client().__exit__(*args, **kwargs)
|
|
251
|
+
|
|
252
|
+
def set_async_httpx_client(
|
|
253
|
+
self, async_client: httpx.AsyncClient
|
|
254
|
+
) -> "AuthenticatedClient":
|
|
255
|
+
"""Manually the underlying httpx.AsyncClient
|
|
256
|
+
|
|
257
|
+
**NOTE**: This will override any other settings on the client, including cookies, headers, and timeout.
|
|
258
|
+
"""
|
|
259
|
+
self._async_client = async_client
|
|
260
|
+
return self
|
|
261
|
+
|
|
262
|
+
def get_async_httpx_client(self) -> httpx.AsyncClient:
|
|
263
|
+
"""Get the underlying httpx.AsyncClient, constructing a new one if not previously set"""
|
|
264
|
+
if self._async_client is None:
|
|
265
|
+
self._headers[self.auth_header_name] = (
|
|
266
|
+
f"{self.prefix} {self.token}" if self.prefix else self.token
|
|
267
|
+
)
|
|
268
|
+
self._async_client = httpx.AsyncClient(
|
|
269
|
+
base_url=self._base_url,
|
|
270
|
+
cookies=self._cookies,
|
|
271
|
+
headers=self._headers,
|
|
272
|
+
timeout=self._timeout,
|
|
273
|
+
verify=self._verify_ssl,
|
|
274
|
+
follow_redirects=self._follow_redirects,
|
|
275
|
+
**self._httpx_args,
|
|
276
|
+
)
|
|
277
|
+
return self._async_client
|
|
278
|
+
|
|
279
|
+
async def __aenter__(self) -> "AuthenticatedClient":
|
|
280
|
+
"""Enter a context manager for underlying httpx.AsyncClient—you cannot enter twice (see httpx docs)"""
|
|
281
|
+
await self.get_async_httpx_client().__aenter__()
|
|
282
|
+
return self
|
|
283
|
+
|
|
284
|
+
async def __aexit__(self, *args: Any, **kwargs: Any) -> None:
|
|
285
|
+
"""Exit a context manager for underlying httpx.AsyncClient (see httpx docs)"""
|
|
286
|
+
await self.get_async_httpx_client().__aexit__(*args, **kwargs)
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"""Contains shared errors types that can be raised from API functions"""
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
class UnexpectedStatus(Exception):
|
|
5
|
+
"""Raised by api functions when the response status an undocumented status and Client.raise_on_unexpected_status is True"""
|
|
6
|
+
|
|
7
|
+
def __init__(self, status_code: int, content: bytes):
|
|
8
|
+
self.status_code = status_code
|
|
9
|
+
self.content = content
|
|
10
|
+
|
|
11
|
+
super().__init__(
|
|
12
|
+
f"Unexpected status code: {status_code}\n\nResponse content:\n{content.decode(errors='ignore')}"
|
|
13
|
+
)
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
__all__ = ["UnexpectedStatus"]
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
"""Contains all the data models used in inputs/outputs"""
|
|
2
|
+
|
|
3
|
+
from .aws_registry import AWSRegistry
|
|
4
|
+
from .aws_registry_type import AWSRegistryType
|
|
5
|
+
from .build_log_entry import BuildLogEntry
|
|
6
|
+
from .build_status_reason import BuildStatusReason
|
|
7
|
+
from .connect_sandbox import ConnectSandbox
|
|
8
|
+
from .created_access_token import CreatedAccessToken
|
|
9
|
+
from .created_team_api_key import CreatedTeamAPIKey
|
|
10
|
+
from .disk_metrics import DiskMetrics
|
|
11
|
+
from .error import Error
|
|
12
|
+
from .gcp_registry import GCPRegistry
|
|
13
|
+
from .gcp_registry_type import GCPRegistryType
|
|
14
|
+
from .general_registry import GeneralRegistry
|
|
15
|
+
from .general_registry_type import GeneralRegistryType
|
|
16
|
+
from .identifier_masking_details import IdentifierMaskingDetails
|
|
17
|
+
from .listed_sandbox import ListedSandbox
|
|
18
|
+
from .log_level import LogLevel
|
|
19
|
+
from .max_team_metric import MaxTeamMetric
|
|
20
|
+
from .mcp_type_0 import McpType0
|
|
21
|
+
from .new_access_token import NewAccessToken
|
|
22
|
+
from .new_sandbox import NewSandbox
|
|
23
|
+
from .new_team_api_key import NewTeamAPIKey
|
|
24
|
+
from .node import Node
|
|
25
|
+
from .node_detail import NodeDetail
|
|
26
|
+
from .node_metrics import NodeMetrics
|
|
27
|
+
from .node_status import NodeStatus
|
|
28
|
+
from .node_status_change import NodeStatusChange
|
|
29
|
+
from .post_sandboxes_sandbox_id_refreshes_body import (
|
|
30
|
+
PostSandboxesSandboxIDRefreshesBody,
|
|
31
|
+
)
|
|
32
|
+
from .post_sandboxes_sandbox_id_timeout_body import PostSandboxesSandboxIDTimeoutBody
|
|
33
|
+
from .resumed_sandbox import ResumedSandbox
|
|
34
|
+
from .sandbox import Sandbox
|
|
35
|
+
from .sandbox_detail import SandboxDetail
|
|
36
|
+
from .sandbox_log import SandboxLog
|
|
37
|
+
from .sandbox_log_entry import SandboxLogEntry
|
|
38
|
+
from .sandbox_log_entry_fields import SandboxLogEntryFields
|
|
39
|
+
from .sandbox_logs import SandboxLogs
|
|
40
|
+
from .sandbox_metric import SandboxMetric
|
|
41
|
+
from .sandbox_network_config import SandboxNetworkConfig
|
|
42
|
+
from .sandbox_state import SandboxState
|
|
43
|
+
from .sandboxes_with_metrics import SandboxesWithMetrics
|
|
44
|
+
from .team import Team
|
|
45
|
+
from .team_api_key import TeamAPIKey
|
|
46
|
+
from .team_metric import TeamMetric
|
|
47
|
+
from .team_user import TeamUser
|
|
48
|
+
from .template import Template
|
|
49
|
+
from .template_build import TemplateBuild
|
|
50
|
+
from .template_build_file_upload import TemplateBuildFileUpload
|
|
51
|
+
from .template_build_info import TemplateBuildInfo
|
|
52
|
+
from .template_build_request import TemplateBuildRequest
|
|
53
|
+
from .template_build_request_v2 import TemplateBuildRequestV2
|
|
54
|
+
from .template_build_request_v3 import TemplateBuildRequestV3
|
|
55
|
+
from .template_build_start_v2 import TemplateBuildStartV2
|
|
56
|
+
from .template_build_status import TemplateBuildStatus
|
|
57
|
+
from .template_legacy import TemplateLegacy
|
|
58
|
+
from .template_request_response_v3 import TemplateRequestResponseV3
|
|
59
|
+
from .template_step import TemplateStep
|
|
60
|
+
from .template_update_request import TemplateUpdateRequest
|
|
61
|
+
from .template_with_builds import TemplateWithBuilds
|
|
62
|
+
from .update_team_api_key import UpdateTeamAPIKey
|
|
63
|
+
|
|
64
|
+
__all__ = (
|
|
65
|
+
"AWSRegistry",
|
|
66
|
+
"AWSRegistryType",
|
|
67
|
+
"BuildLogEntry",
|
|
68
|
+
"BuildStatusReason",
|
|
69
|
+
"ConnectSandbox",
|
|
70
|
+
"CreatedAccessToken",
|
|
71
|
+
"CreatedTeamAPIKey",
|
|
72
|
+
"DiskMetrics",
|
|
73
|
+
"Error",
|
|
74
|
+
"GCPRegistry",
|
|
75
|
+
"GCPRegistryType",
|
|
76
|
+
"GeneralRegistry",
|
|
77
|
+
"GeneralRegistryType",
|
|
78
|
+
"IdentifierMaskingDetails",
|
|
79
|
+
"ListedSandbox",
|
|
80
|
+
"LogLevel",
|
|
81
|
+
"MaxTeamMetric",
|
|
82
|
+
"McpType0",
|
|
83
|
+
"NewAccessToken",
|
|
84
|
+
"NewSandbox",
|
|
85
|
+
"NewTeamAPIKey",
|
|
86
|
+
"Node",
|
|
87
|
+
"NodeDetail",
|
|
88
|
+
"NodeMetrics",
|
|
89
|
+
"NodeStatus",
|
|
90
|
+
"NodeStatusChange",
|
|
91
|
+
"PostSandboxesSandboxIDRefreshesBody",
|
|
92
|
+
"PostSandboxesSandboxIDTimeoutBody",
|
|
93
|
+
"ResumedSandbox",
|
|
94
|
+
"Sandbox",
|
|
95
|
+
"SandboxDetail",
|
|
96
|
+
"SandboxesWithMetrics",
|
|
97
|
+
"SandboxLog",
|
|
98
|
+
"SandboxLogEntry",
|
|
99
|
+
"SandboxLogEntryFields",
|
|
100
|
+
"SandboxLogs",
|
|
101
|
+
"SandboxMetric",
|
|
102
|
+
"SandboxNetworkConfig",
|
|
103
|
+
"SandboxState",
|
|
104
|
+
"Team",
|
|
105
|
+
"TeamAPIKey",
|
|
106
|
+
"TeamMetric",
|
|
107
|
+
"TeamUser",
|
|
108
|
+
"Template",
|
|
109
|
+
"TemplateBuild",
|
|
110
|
+
"TemplateBuildFileUpload",
|
|
111
|
+
"TemplateBuildInfo",
|
|
112
|
+
"TemplateBuildRequest",
|
|
113
|
+
"TemplateBuildRequestV2",
|
|
114
|
+
"TemplateBuildRequestV3",
|
|
115
|
+
"TemplateBuildStartV2",
|
|
116
|
+
"TemplateBuildStatus",
|
|
117
|
+
"TemplateLegacy",
|
|
118
|
+
"TemplateRequestResponseV3",
|
|
119
|
+
"TemplateStep",
|
|
120
|
+
"TemplateUpdateRequest",
|
|
121
|
+
"TemplateWithBuilds",
|
|
122
|
+
"UpdateTeamAPIKey",
|
|
123
|
+
)
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
from collections.abc import Mapping
|
|
2
|
+
from typing import Any, TypeVar
|
|
3
|
+
|
|
4
|
+
from attrs import define as _attrs_define
|
|
5
|
+
from attrs import field as _attrs_field
|
|
6
|
+
|
|
7
|
+
from ..models.aws_registry_type import AWSRegistryType
|
|
8
|
+
|
|
9
|
+
T = TypeVar("T", bound="AWSRegistry")
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
@_attrs_define
|
|
13
|
+
class AWSRegistry:
|
|
14
|
+
"""
|
|
15
|
+
Attributes:
|
|
16
|
+
aws_access_key_id (str): AWS Access Key ID for ECR authentication
|
|
17
|
+
aws_region (str): AWS Region where the ECR registry is located
|
|
18
|
+
aws_secret_access_key (str): AWS Secret Access Key for ECR authentication
|
|
19
|
+
type_ (AWSRegistryType): Type of registry authentication
|
|
20
|
+
"""
|
|
21
|
+
|
|
22
|
+
aws_access_key_id: str
|
|
23
|
+
aws_region: str
|
|
24
|
+
aws_secret_access_key: str
|
|
25
|
+
type_: AWSRegistryType
|
|
26
|
+
additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict)
|
|
27
|
+
|
|
28
|
+
def to_dict(self) -> dict[str, Any]:
|
|
29
|
+
aws_access_key_id = self.aws_access_key_id
|
|
30
|
+
|
|
31
|
+
aws_region = self.aws_region
|
|
32
|
+
|
|
33
|
+
aws_secret_access_key = self.aws_secret_access_key
|
|
34
|
+
|
|
35
|
+
type_ = self.type_.value
|
|
36
|
+
|
|
37
|
+
field_dict: dict[str, Any] = {}
|
|
38
|
+
field_dict.update(self.additional_properties)
|
|
39
|
+
field_dict.update(
|
|
40
|
+
{
|
|
41
|
+
"awsAccessKeyId": aws_access_key_id,
|
|
42
|
+
"awsRegion": aws_region,
|
|
43
|
+
"awsSecretAccessKey": aws_secret_access_key,
|
|
44
|
+
"type": type_,
|
|
45
|
+
}
|
|
46
|
+
)
|
|
47
|
+
|
|
48
|
+
return field_dict
|
|
49
|
+
|
|
50
|
+
@classmethod
|
|
51
|
+
def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T:
|
|
52
|
+
d = dict(src_dict)
|
|
53
|
+
aws_access_key_id = d.pop("awsAccessKeyId")
|
|
54
|
+
|
|
55
|
+
aws_region = d.pop("awsRegion")
|
|
56
|
+
|
|
57
|
+
aws_secret_access_key = d.pop("awsSecretAccessKey")
|
|
58
|
+
|
|
59
|
+
type_ = AWSRegistryType(d.pop("type"))
|
|
60
|
+
|
|
61
|
+
aws_registry = cls(
|
|
62
|
+
aws_access_key_id=aws_access_key_id,
|
|
63
|
+
aws_region=aws_region,
|
|
64
|
+
aws_secret_access_key=aws_secret_access_key,
|
|
65
|
+
type_=type_,
|
|
66
|
+
)
|
|
67
|
+
|
|
68
|
+
aws_registry.additional_properties = d
|
|
69
|
+
return aws_registry
|
|
70
|
+
|
|
71
|
+
@property
|
|
72
|
+
def additional_keys(self) -> list[str]:
|
|
73
|
+
return list(self.additional_properties.keys())
|
|
74
|
+
|
|
75
|
+
def __getitem__(self, key: str) -> Any:
|
|
76
|
+
return self.additional_properties[key]
|
|
77
|
+
|
|
78
|
+
def __setitem__(self, key: str, value: Any) -> None:
|
|
79
|
+
self.additional_properties[key] = value
|
|
80
|
+
|
|
81
|
+
def __delitem__(self, key: str) -> None:
|
|
82
|
+
del self.additional_properties[key]
|
|
83
|
+
|
|
84
|
+
def __contains__(self, key: str) -> bool:
|
|
85
|
+
return key in self.additional_properties
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import datetime
|
|
2
|
+
from collections.abc import Mapping
|
|
3
|
+
from typing import Any, TypeVar, Union
|
|
4
|
+
|
|
5
|
+
from attrs import define as _attrs_define
|
|
6
|
+
from attrs import field as _attrs_field
|
|
7
|
+
from dateutil.parser import isoparse
|
|
8
|
+
|
|
9
|
+
from ..models.log_level import LogLevel
|
|
10
|
+
from ..types import UNSET, Unset
|
|
11
|
+
|
|
12
|
+
T = TypeVar("T", bound="BuildLogEntry")
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
@_attrs_define
|
|
16
|
+
class BuildLogEntry:
|
|
17
|
+
"""
|
|
18
|
+
Attributes:
|
|
19
|
+
level (LogLevel): State of the sandbox
|
|
20
|
+
message (str): Log message content
|
|
21
|
+
timestamp (datetime.datetime): Timestamp of the log entry
|
|
22
|
+
step (Union[Unset, str]): Step in the build process related to the log entry
|
|
23
|
+
"""
|
|
24
|
+
|
|
25
|
+
level: LogLevel
|
|
26
|
+
message: str
|
|
27
|
+
timestamp: datetime.datetime
|
|
28
|
+
step: Union[Unset, str] = UNSET
|
|
29
|
+
additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict)
|
|
30
|
+
|
|
31
|
+
def to_dict(self) -> dict[str, Any]:
|
|
32
|
+
level = self.level.value
|
|
33
|
+
|
|
34
|
+
message = self.message
|
|
35
|
+
|
|
36
|
+
timestamp = self.timestamp.isoformat()
|
|
37
|
+
|
|
38
|
+
step = self.step
|
|
39
|
+
|
|
40
|
+
field_dict: dict[str, Any] = {}
|
|
41
|
+
field_dict.update(self.additional_properties)
|
|
42
|
+
field_dict.update(
|
|
43
|
+
{
|
|
44
|
+
"level": level,
|
|
45
|
+
"message": message,
|
|
46
|
+
"timestamp": timestamp,
|
|
47
|
+
}
|
|
48
|
+
)
|
|
49
|
+
if step is not UNSET:
|
|
50
|
+
field_dict["step"] = step
|
|
51
|
+
|
|
52
|
+
return field_dict
|
|
53
|
+
|
|
54
|
+
@classmethod
|
|
55
|
+
def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T:
|
|
56
|
+
d = dict(src_dict)
|
|
57
|
+
level = LogLevel(d.pop("level"))
|
|
58
|
+
|
|
59
|
+
message = d.pop("message")
|
|
60
|
+
|
|
61
|
+
timestamp = isoparse(d.pop("timestamp"))
|
|
62
|
+
|
|
63
|
+
step = d.pop("step", UNSET)
|
|
64
|
+
|
|
65
|
+
build_log_entry = cls(
|
|
66
|
+
level=level,
|
|
67
|
+
message=message,
|
|
68
|
+
timestamp=timestamp,
|
|
69
|
+
step=step,
|
|
70
|
+
)
|
|
71
|
+
|
|
72
|
+
build_log_entry.additional_properties = d
|
|
73
|
+
return build_log_entry
|
|
74
|
+
|
|
75
|
+
@property
|
|
76
|
+
def additional_keys(self) -> list[str]:
|
|
77
|
+
return list(self.additional_properties.keys())
|
|
78
|
+
|
|
79
|
+
def __getitem__(self, key: str) -> Any:
|
|
80
|
+
return self.additional_properties[key]
|
|
81
|
+
|
|
82
|
+
def __setitem__(self, key: str, value: Any) -> None:
|
|
83
|
+
self.additional_properties[key] = value
|
|
84
|
+
|
|
85
|
+
def __delitem__(self, key: str) -> None:
|
|
86
|
+
del self.additional_properties[key]
|
|
87
|
+
|
|
88
|
+
def __contains__(self, key: str) -> bool:
|
|
89
|
+
return key in self.additional_properties
|