scalebox-sdk 0.1.24__py3-none-any.whl → 1.0.1__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.
- scalebox/__init__.py +2 -2
- scalebox/api/__init__.py +130 -128
- scalebox/api/client/__init__.py +8 -8
- scalebox/api/client/api/sandboxes/get_sandboxes_sandbox_id_metrics.py +2 -2
- scalebox/api/client/api/sandboxes/post_sandboxes.py +2 -2
- scalebox/api/client/api/sandboxes/post_sandboxes_sandbox_id_connect.py +193 -0
- scalebox/api/client/client.py +288 -288
- scalebox/api/client/models/connect_sandbox.py +59 -0
- scalebox/api/client/models/error.py +2 -2
- scalebox/api/client/models/listed_sandbox.py +19 -1
- scalebox/api/client/models/new_sandbox.py +10 -0
- scalebox/api/client/models/sandbox.py +138 -125
- scalebox/api/client/models/sandbox_detail.py +24 -0
- scalebox/api/client/types.py +46 -46
- scalebox/cli.py +125 -125
- scalebox/client/aclient.py +57 -57
- scalebox/client/client.py +102 -102
- scalebox/code_interpreter/__init__.py +12 -12
- scalebox/code_interpreter/charts.py +230 -230
- scalebox/code_interpreter/constants.py +3 -3
- scalebox/code_interpreter/exceptions.py +13 -13
- scalebox/code_interpreter/models.py +485 -485
- scalebox/connection_config.py +34 -1
- scalebox/csx_connect/__init__.py +1 -1
- scalebox/csx_connect/client.py +485 -485
- scalebox/csx_desktop/main.py +651 -651
- scalebox/exceptions.py +83 -83
- scalebox/generated/api.py +61 -61
- scalebox/generated/api_pb2.py +203 -203
- scalebox/generated/api_pb2.pyi +956 -956
- scalebox/generated/api_pb2_connect.py +1407 -1407
- scalebox/generated/rpc.py +50 -50
- scalebox/sandbox/main.py +146 -139
- scalebox/sandbox/sandbox_api.py +105 -91
- scalebox/sandbox/signature.py +40 -40
- scalebox/sandbox/utils.py +34 -34
- scalebox/sandbox_async/commands/command.py +307 -307
- scalebox/sandbox_async/commands/command_handle.py +187 -187
- scalebox/sandbox_async/commands/pty.py +187 -187
- scalebox/sandbox_async/filesystem/filesystem.py +557 -557
- scalebox/sandbox_async/filesystem/watch_handle.py +61 -61
- scalebox/sandbox_async/main.py +228 -46
- scalebox/sandbox_async/sandbox_api.py +124 -3
- scalebox/sandbox_async/utils.py +7 -7
- scalebox/sandbox_sync/__init__.py +2 -2
- scalebox/sandbox_sync/commands/command.py +300 -300
- scalebox/sandbox_sync/commands/command_handle.py +150 -150
- scalebox/sandbox_sync/commands/pty.py +181 -181
- scalebox/sandbox_sync/filesystem/filesystem.py +3 -3
- scalebox/sandbox_sync/filesystem/watch_handle.py +66 -66
- scalebox/sandbox_sync/main.py +208 -133
- scalebox/sandbox_sync/sandbox_api.py +119 -3
- scalebox/test/CODE_INTERPRETER_TESTS_READY.md +323 -323
- scalebox/test/README.md +329 -329
- scalebox/test/bedrock_openai_adapter.py +67 -0
- scalebox/test/code_interpreter_test.py +34 -34
- scalebox/test/code_interpreter_test_sync.py +34 -34
- scalebox/test/run_stress_code_interpreter_sync.py +166 -0
- scalebox/test/simple_upload_example.py +123 -0
- scalebox/test/stabitiy_test.py +310 -0
- scalebox/test/test_browser_use.py +25 -0
- scalebox/test/test_browser_use_scalebox.py +61 -0
- scalebox/test/test_code_interpreter_sync_comprehensive.py +115 -65
- scalebox/test/test_connect_pause_async.py +277 -0
- scalebox/test/test_connect_pause_sync.py +267 -0
- scalebox/test/test_desktop_sandbox_sf.py +117 -0
- scalebox/test/test_download_url.py +49 -0
- scalebox/test/test_sandbox_async_comprehensive.py +1 -1
- scalebox/test/test_sandbox_object_storage_example.py +146 -0
- scalebox/test/test_sandbox_object_storage_example_async.py +156 -0
- scalebox/test/test_sf.py +137 -0
- scalebox/test/test_watch_dir_async.py +56 -0
- scalebox/test/testacreate.py +1 -1
- scalebox/test/testagetinfo.py +1 -1
- scalebox/test/testcomputeuse.py +243 -243
- scalebox/test/testsandbox_api.py +13 -0
- scalebox/test/testsandbox_sync.py +1 -1
- scalebox/test/upload_100mb_example.py +355 -0
- scalebox/utils/httpcoreclient.py +297 -297
- scalebox/utils/httpxclient.py +403 -403
- scalebox/version.py +2 -2
- {scalebox_sdk-0.1.24.dist-info → scalebox_sdk-1.0.1.dist-info}/METADATA +1 -1
- {scalebox_sdk-0.1.24.dist-info → scalebox_sdk-1.0.1.dist-info}/RECORD +87 -69
- {scalebox_sdk-0.1.24.dist-info → scalebox_sdk-1.0.1.dist-info}/WHEEL +1 -1
- {scalebox_sdk-0.1.24.dist-info → scalebox_sdk-1.0.1.dist-info}/entry_points.txt +0 -0
- {scalebox_sdk-0.1.24.dist-info → scalebox_sdk-1.0.1.dist-info}/licenses/LICENSE +0 -0
- {scalebox_sdk-0.1.24.dist-info → scalebox_sdk-1.0.1.dist-info}/top_level.txt +0 -0
|
@@ -1,1407 +1,1407 @@
|
|
|
1
|
-
# Generated Connect client code
|
|
2
|
-
|
|
3
|
-
from __future__ import annotations
|
|
4
|
-
|
|
5
|
-
import sys
|
|
6
|
-
import typing
|
|
7
|
-
from collections.abc import AsyncIterator, Iterable, Iterator
|
|
8
|
-
|
|
9
|
-
import aiohttp
|
|
10
|
-
import urllib3
|
|
11
|
-
from connectrpc.client_async import AsyncConnectClient
|
|
12
|
-
from connectrpc.client_connect import ConnectProtocolError
|
|
13
|
-
from connectrpc.client_protocol import ConnectProtocol
|
|
14
|
-
from connectrpc.client_sync import ConnectClient
|
|
15
|
-
from connectrpc.headers import HeaderInput
|
|
16
|
-
from connectrpc.server import (
|
|
17
|
-
ClientRequest,
|
|
18
|
-
ClientStream,
|
|
19
|
-
ServerResponse,
|
|
20
|
-
ServerStream,
|
|
21
|
-
)
|
|
22
|
-
from connectrpc.server_sync import ConnectWSGI
|
|
23
|
-
from connectrpc.streams import AsyncStreamOutput, StreamInput, StreamOutput
|
|
24
|
-
from connectrpc.unary import ClientStreamingOutput, UnaryOutput
|
|
25
|
-
|
|
26
|
-
if typing.TYPE_CHECKING:
|
|
27
|
-
# wsgiref.types was added in Python 3.11.
|
|
28
|
-
if sys.version_info >= (3, 11):
|
|
29
|
-
from wsgiref.types import WSGIApplication
|
|
30
|
-
else:
|
|
31
|
-
from _typeshed.wsgi import WSGIApplication
|
|
32
|
-
|
|
33
|
-
from . import api_pb2
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
class FilesystemClient:
|
|
37
|
-
def __init__(
|
|
38
|
-
self,
|
|
39
|
-
base_url: str,
|
|
40
|
-
http_client: urllib3.PoolManager | None = None,
|
|
41
|
-
protocol: ConnectProtocol = ConnectProtocol.CONNECT_PROTOBUF,
|
|
42
|
-
):
|
|
43
|
-
self.base_url = base_url
|
|
44
|
-
self._connect_client = ConnectClient(http_client, protocol)
|
|
45
|
-
|
|
46
|
-
def call_stat(
|
|
47
|
-
self,
|
|
48
|
-
req: api_pb2.StatRequest,
|
|
49
|
-
extra_headers: HeaderInput | None = None,
|
|
50
|
-
timeout_seconds: float | None = None,
|
|
51
|
-
) -> UnaryOutput[api_pb2.StatResponse]:
|
|
52
|
-
"""Low-level method to call Stat, granting access to errors and metadata"""
|
|
53
|
-
url = self.base_url + "/sandboxagent.Filesystem/Stat"
|
|
54
|
-
return self._connect_client.call_unary(
|
|
55
|
-
url, req, api_pb2.StatResponse, extra_headers, timeout_seconds
|
|
56
|
-
)
|
|
57
|
-
|
|
58
|
-
def stat(
|
|
59
|
-
self,
|
|
60
|
-
req: api_pb2.StatRequest,
|
|
61
|
-
extra_headers: HeaderInput | None = None,
|
|
62
|
-
timeout_seconds: float | None = None,
|
|
63
|
-
) -> api_pb2.StatResponse:
|
|
64
|
-
response = self.call_stat(req, extra_headers, timeout_seconds)
|
|
65
|
-
err = response.error()
|
|
66
|
-
if err is not None:
|
|
67
|
-
raise err
|
|
68
|
-
msg = response.message()
|
|
69
|
-
if msg is None:
|
|
70
|
-
raise ConnectProtocolError("missing response message")
|
|
71
|
-
return msg
|
|
72
|
-
|
|
73
|
-
def call_make_dir(
|
|
74
|
-
self,
|
|
75
|
-
req: api_pb2.MakeDirRequest,
|
|
76
|
-
extra_headers: HeaderInput | None = None,
|
|
77
|
-
timeout_seconds: float | None = None,
|
|
78
|
-
) -> UnaryOutput[api_pb2.MakeDirResponse]:
|
|
79
|
-
"""Low-level method to call MakeDir, granting access to errors and metadata"""
|
|
80
|
-
url = self.base_url + "/sandboxagent.Filesystem/MakeDir"
|
|
81
|
-
return self._connect_client.call_unary(
|
|
82
|
-
url, req, api_pb2.MakeDirResponse, extra_headers, timeout_seconds
|
|
83
|
-
)
|
|
84
|
-
|
|
85
|
-
def make_dir(
|
|
86
|
-
self,
|
|
87
|
-
req: api_pb2.MakeDirRequest,
|
|
88
|
-
extra_headers: HeaderInput | None = None,
|
|
89
|
-
timeout_seconds: float | None = None,
|
|
90
|
-
) -> api_pb2.MakeDirResponse:
|
|
91
|
-
response = self.call_make_dir(req, extra_headers, timeout_seconds)
|
|
92
|
-
err = response.error()
|
|
93
|
-
if err is not None:
|
|
94
|
-
raise err
|
|
95
|
-
msg = response.message()
|
|
96
|
-
if msg is None:
|
|
97
|
-
raise ConnectProtocolError("missing response message")
|
|
98
|
-
return msg
|
|
99
|
-
|
|
100
|
-
def call_move(
|
|
101
|
-
self,
|
|
102
|
-
req: api_pb2.MoveRequest,
|
|
103
|
-
extra_headers: HeaderInput | None = None,
|
|
104
|
-
timeout_seconds: float | None = None,
|
|
105
|
-
) -> UnaryOutput[api_pb2.MoveResponse]:
|
|
106
|
-
"""Low-level method to call Move, granting access to errors and metadata"""
|
|
107
|
-
url = self.base_url + "/sandboxagent.Filesystem/Move"
|
|
108
|
-
return self._connect_client.call_unary(
|
|
109
|
-
url, req, api_pb2.MoveResponse, extra_headers, timeout_seconds
|
|
110
|
-
)
|
|
111
|
-
|
|
112
|
-
def move(
|
|
113
|
-
self,
|
|
114
|
-
req: api_pb2.MoveRequest,
|
|
115
|
-
extra_headers: HeaderInput | None = None,
|
|
116
|
-
timeout_seconds: float | None = None,
|
|
117
|
-
) -> api_pb2.MoveResponse:
|
|
118
|
-
response = self.call_move(req, extra_headers, timeout_seconds)
|
|
119
|
-
err = response.error()
|
|
120
|
-
if err is not None:
|
|
121
|
-
raise err
|
|
122
|
-
msg = response.message()
|
|
123
|
-
if msg is None:
|
|
124
|
-
raise ConnectProtocolError("missing response message")
|
|
125
|
-
return msg
|
|
126
|
-
|
|
127
|
-
def call_list_dir(
|
|
128
|
-
self,
|
|
129
|
-
req: api_pb2.ListDirRequest,
|
|
130
|
-
extra_headers: HeaderInput | None = None,
|
|
131
|
-
timeout_seconds: float | None = None,
|
|
132
|
-
) -> UnaryOutput[api_pb2.ListDirResponse]:
|
|
133
|
-
"""Low-level method to call ListDir, granting access to errors and metadata"""
|
|
134
|
-
url = self.base_url + "/sandboxagent.Filesystem/ListDir"
|
|
135
|
-
return self._connect_client.call_unary(
|
|
136
|
-
url, req, api_pb2.ListDirResponse, extra_headers, timeout_seconds
|
|
137
|
-
)
|
|
138
|
-
|
|
139
|
-
def list_dir(
|
|
140
|
-
self,
|
|
141
|
-
req: api_pb2.ListDirRequest,
|
|
142
|
-
extra_headers: HeaderInput | None = None,
|
|
143
|
-
timeout_seconds: float | None = None,
|
|
144
|
-
) -> api_pb2.ListDirResponse:
|
|
145
|
-
response = self.call_list_dir(req, extra_headers, timeout_seconds)
|
|
146
|
-
err = response.error()
|
|
147
|
-
if err is not None:
|
|
148
|
-
raise err
|
|
149
|
-
msg = response.message()
|
|
150
|
-
if msg is None:
|
|
151
|
-
raise ConnectProtocolError("missing response message")
|
|
152
|
-
return msg
|
|
153
|
-
|
|
154
|
-
def call_remove(
|
|
155
|
-
self,
|
|
156
|
-
req: api_pb2.RemoveRequest,
|
|
157
|
-
extra_headers: HeaderInput | None = None,
|
|
158
|
-
timeout_seconds: float | None = None,
|
|
159
|
-
) -> UnaryOutput[api_pb2.RemoveResponse]:
|
|
160
|
-
"""Low-level method to call Remove, granting access to errors and metadata"""
|
|
161
|
-
url = self.base_url + "/sandboxagent.Filesystem/Remove"
|
|
162
|
-
return self._connect_client.call_unary(
|
|
163
|
-
url, req, api_pb2.RemoveResponse, extra_headers, timeout_seconds
|
|
164
|
-
)
|
|
165
|
-
|
|
166
|
-
def remove(
|
|
167
|
-
self,
|
|
168
|
-
req: api_pb2.RemoveRequest,
|
|
169
|
-
extra_headers: HeaderInput | None = None,
|
|
170
|
-
timeout_seconds: float | None = None,
|
|
171
|
-
) -> api_pb2.RemoveResponse:
|
|
172
|
-
response = self.call_remove(req, extra_headers, timeout_seconds)
|
|
173
|
-
err = response.error()
|
|
174
|
-
if err is not None:
|
|
175
|
-
raise err
|
|
176
|
-
msg = response.message()
|
|
177
|
-
if msg is None:
|
|
178
|
-
raise ConnectProtocolError("missing response message")
|
|
179
|
-
return msg
|
|
180
|
-
|
|
181
|
-
def watch_dir(
|
|
182
|
-
self,
|
|
183
|
-
req: api_pb2.WatchDirRequest,
|
|
184
|
-
extra_headers: HeaderInput | None = None,
|
|
185
|
-
timeout_seconds: float | None = None,
|
|
186
|
-
) -> Iterator[api_pb2.WatchDirResponse]:
|
|
187
|
-
return self._watch_dir_iterator(req, extra_headers, timeout_seconds)
|
|
188
|
-
|
|
189
|
-
def _watch_dir_iterator(
|
|
190
|
-
self,
|
|
191
|
-
req: api_pb2.WatchDirRequest,
|
|
192
|
-
extra_headers: HeaderInput | None = None,
|
|
193
|
-
timeout_seconds: float | None = None,
|
|
194
|
-
) -> Iterator[api_pb2.WatchDirResponse]:
|
|
195
|
-
stream_output = self.call_watch_dir(req, extra_headers)
|
|
196
|
-
err = stream_output.error()
|
|
197
|
-
if err is not None:
|
|
198
|
-
raise err
|
|
199
|
-
yield from stream_output
|
|
200
|
-
err = stream_output.error()
|
|
201
|
-
if err is not None:
|
|
202
|
-
raise err
|
|
203
|
-
|
|
204
|
-
def call_watch_dir(
|
|
205
|
-
self,
|
|
206
|
-
req: api_pb2.WatchDirRequest,
|
|
207
|
-
extra_headers: HeaderInput | None = None,
|
|
208
|
-
timeout_seconds: float | None = None,
|
|
209
|
-
) -> StreamOutput[api_pb2.WatchDirResponse]:
|
|
210
|
-
"""Low-level method to call WatchDir, granting access to errors and metadata"""
|
|
211
|
-
url = self.base_url + "/sandboxagent.Filesystem/WatchDir"
|
|
212
|
-
return self._connect_client.call_server_streaming(
|
|
213
|
-
url, req, api_pb2.WatchDirResponse, extra_headers, timeout_seconds
|
|
214
|
-
)
|
|
215
|
-
|
|
216
|
-
def call_create_watcher(
|
|
217
|
-
self,
|
|
218
|
-
req: api_pb2.CreateWatcherRequest,
|
|
219
|
-
extra_headers: HeaderInput | None = None,
|
|
220
|
-
timeout_seconds: float | None = None,
|
|
221
|
-
) -> UnaryOutput[api_pb2.CreateWatcherResponse]:
|
|
222
|
-
"""Low-level method to call CreateWatcher, granting access to errors and metadata"""
|
|
223
|
-
url = self.base_url + "/sandboxagent.Filesystem/CreateWatcher"
|
|
224
|
-
return self._connect_client.call_unary(
|
|
225
|
-
url, req, api_pb2.CreateWatcherResponse, extra_headers, timeout_seconds
|
|
226
|
-
)
|
|
227
|
-
|
|
228
|
-
def create_watcher(
|
|
229
|
-
self,
|
|
230
|
-
req: api_pb2.CreateWatcherRequest,
|
|
231
|
-
extra_headers: HeaderInput | None = None,
|
|
232
|
-
timeout_seconds: float | None = None,
|
|
233
|
-
) -> api_pb2.CreateWatcherResponse:
|
|
234
|
-
response = self.call_create_watcher(req, extra_headers, timeout_seconds)
|
|
235
|
-
err = response.error()
|
|
236
|
-
if err is not None:
|
|
237
|
-
raise err
|
|
238
|
-
msg = response.message()
|
|
239
|
-
if msg is None:
|
|
240
|
-
raise ConnectProtocolError("missing response message")
|
|
241
|
-
return msg
|
|
242
|
-
|
|
243
|
-
def call_get_watcher_events(
|
|
244
|
-
self,
|
|
245
|
-
req: api_pb2.GetWatcherEventsRequest,
|
|
246
|
-
extra_headers: HeaderInput | None = None,
|
|
247
|
-
timeout_seconds: float | None = None,
|
|
248
|
-
) -> UnaryOutput[api_pb2.GetWatcherEventsResponse]:
|
|
249
|
-
"""Low-level method to call GetWatcherEvents, granting access to errors and metadata"""
|
|
250
|
-
url = self.base_url + "/sandboxagent.Filesystem/GetWatcherEvents"
|
|
251
|
-
return self._connect_client.call_unary(
|
|
252
|
-
url, req, api_pb2.GetWatcherEventsResponse, extra_headers, timeout_seconds
|
|
253
|
-
)
|
|
254
|
-
|
|
255
|
-
def get_watcher_events(
|
|
256
|
-
self,
|
|
257
|
-
req: api_pb2.GetWatcherEventsRequest,
|
|
258
|
-
extra_headers: HeaderInput | None = None,
|
|
259
|
-
timeout_seconds: float | None = None,
|
|
260
|
-
) -> api_pb2.GetWatcherEventsResponse:
|
|
261
|
-
response = self.call_get_watcher_events(req, extra_headers, timeout_seconds)
|
|
262
|
-
err = response.error()
|
|
263
|
-
if err is not None:
|
|
264
|
-
raise err
|
|
265
|
-
msg = response.message()
|
|
266
|
-
if msg is None:
|
|
267
|
-
raise ConnectProtocolError("missing response message")
|
|
268
|
-
return msg
|
|
269
|
-
|
|
270
|
-
def call_remove_watcher(
|
|
271
|
-
self,
|
|
272
|
-
req: api_pb2.RemoveWatcherRequest,
|
|
273
|
-
extra_headers: HeaderInput | None = None,
|
|
274
|
-
timeout_seconds: float | None = None,
|
|
275
|
-
) -> UnaryOutput[api_pb2.RemoveWatcherResponse]:
|
|
276
|
-
"""Low-level method to call RemoveWatcher, granting access to errors and metadata"""
|
|
277
|
-
url = self.base_url + "/sandboxagent.Filesystem/RemoveWatcher"
|
|
278
|
-
return self._connect_client.call_unary(
|
|
279
|
-
url, req, api_pb2.RemoveWatcherResponse, extra_headers, timeout_seconds
|
|
280
|
-
)
|
|
281
|
-
|
|
282
|
-
def remove_watcher(
|
|
283
|
-
self,
|
|
284
|
-
req: api_pb2.RemoveWatcherRequest,
|
|
285
|
-
extra_headers: HeaderInput | None = None,
|
|
286
|
-
timeout_seconds: float | None = None,
|
|
287
|
-
) -> api_pb2.RemoveWatcherResponse:
|
|
288
|
-
response = self.call_remove_watcher(req, extra_headers, timeout_seconds)
|
|
289
|
-
err = response.error()
|
|
290
|
-
if err is not None:
|
|
291
|
-
raise err
|
|
292
|
-
msg = response.message()
|
|
293
|
-
if msg is None:
|
|
294
|
-
raise ConnectProtocolError("missing response message")
|
|
295
|
-
return msg
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
class AsyncFilesystemClient:
|
|
299
|
-
def __init__(
|
|
300
|
-
self,
|
|
301
|
-
base_url: str,
|
|
302
|
-
http_client: aiohttp.ClientSession,
|
|
303
|
-
protocol: ConnectProtocol = ConnectProtocol.CONNECT_PROTOBUF,
|
|
304
|
-
):
|
|
305
|
-
self.base_url = base_url
|
|
306
|
-
self._connect_client = AsyncConnectClient(http_client, protocol)
|
|
307
|
-
|
|
308
|
-
async def call_stat(
|
|
309
|
-
self,
|
|
310
|
-
req: api_pb2.StatRequest,
|
|
311
|
-
extra_headers: HeaderInput | None = None,
|
|
312
|
-
timeout_seconds: float | None = None,
|
|
313
|
-
) -> UnaryOutput[api_pb2.StatResponse]:
|
|
314
|
-
"""Low-level method to call Stat, granting access to errors and metadata"""
|
|
315
|
-
url = self.base_url + "/sandboxagent.Filesystem/Stat"
|
|
316
|
-
return await self._connect_client.call_unary(
|
|
317
|
-
url, req, api_pb2.StatResponse, extra_headers, timeout_seconds
|
|
318
|
-
)
|
|
319
|
-
|
|
320
|
-
async def stat(
|
|
321
|
-
self,
|
|
322
|
-
req: api_pb2.StatRequest,
|
|
323
|
-
extra_headers: HeaderInput | None = None,
|
|
324
|
-
timeout_seconds: float | None = None,
|
|
325
|
-
) -> api_pb2.StatResponse:
|
|
326
|
-
response = await self.call_stat(req, extra_headers, timeout_seconds)
|
|
327
|
-
err = response.error()
|
|
328
|
-
if err is not None:
|
|
329
|
-
raise err
|
|
330
|
-
msg = response.message()
|
|
331
|
-
if msg is None:
|
|
332
|
-
raise ConnectProtocolError("missing response message")
|
|
333
|
-
return msg
|
|
334
|
-
|
|
335
|
-
async def call_make_dir(
|
|
336
|
-
self,
|
|
337
|
-
req: api_pb2.MakeDirRequest,
|
|
338
|
-
extra_headers: HeaderInput | None = None,
|
|
339
|
-
timeout_seconds: float | None = None,
|
|
340
|
-
) -> UnaryOutput[api_pb2.MakeDirResponse]:
|
|
341
|
-
"""Low-level method to call MakeDir, granting access to errors and metadata"""
|
|
342
|
-
url = self.base_url + "/sandboxagent.Filesystem/MakeDir"
|
|
343
|
-
return await self._connect_client.call_unary(
|
|
344
|
-
url, req, api_pb2.MakeDirResponse, extra_headers, timeout_seconds
|
|
345
|
-
)
|
|
346
|
-
|
|
347
|
-
async def make_dir(
|
|
348
|
-
self,
|
|
349
|
-
req: api_pb2.MakeDirRequest,
|
|
350
|
-
extra_headers: HeaderInput | None = None,
|
|
351
|
-
timeout_seconds: float | None = None,
|
|
352
|
-
) -> api_pb2.MakeDirResponse:
|
|
353
|
-
response = await self.call_make_dir(req, extra_headers, timeout_seconds)
|
|
354
|
-
err = response.error()
|
|
355
|
-
if err is not None:
|
|
356
|
-
raise err
|
|
357
|
-
msg = response.message()
|
|
358
|
-
if msg is None:
|
|
359
|
-
raise ConnectProtocolError("missing response message")
|
|
360
|
-
return msg
|
|
361
|
-
|
|
362
|
-
async def call_move(
|
|
363
|
-
self,
|
|
364
|
-
req: api_pb2.MoveRequest,
|
|
365
|
-
extra_headers: HeaderInput | None = None,
|
|
366
|
-
timeout_seconds: float | None = None,
|
|
367
|
-
) -> UnaryOutput[api_pb2.MoveResponse]:
|
|
368
|
-
"""Low-level method to call Move, granting access to errors and metadata"""
|
|
369
|
-
url = self.base_url + "/sandboxagent.Filesystem/Move"
|
|
370
|
-
return await self._connect_client.call_unary(
|
|
371
|
-
url, req, api_pb2.MoveResponse, extra_headers, timeout_seconds
|
|
372
|
-
)
|
|
373
|
-
|
|
374
|
-
async def move(
|
|
375
|
-
self,
|
|
376
|
-
req: api_pb2.MoveRequest,
|
|
377
|
-
extra_headers: HeaderInput | None = None,
|
|
378
|
-
timeout_seconds: float | None = None,
|
|
379
|
-
) -> api_pb2.MoveResponse:
|
|
380
|
-
response = await self.call_move(req, extra_headers, timeout_seconds)
|
|
381
|
-
err = response.error()
|
|
382
|
-
if err is not None:
|
|
383
|
-
raise err
|
|
384
|
-
msg = response.message()
|
|
385
|
-
if msg is None:
|
|
386
|
-
raise ConnectProtocolError("missing response message")
|
|
387
|
-
return msg
|
|
388
|
-
|
|
389
|
-
async def call_list_dir(
|
|
390
|
-
self,
|
|
391
|
-
req: api_pb2.ListDirRequest,
|
|
392
|
-
extra_headers: HeaderInput | None = None,
|
|
393
|
-
timeout_seconds: float | None = None,
|
|
394
|
-
) -> UnaryOutput[api_pb2.ListDirResponse]:
|
|
395
|
-
"""Low-level method to call ListDir, granting access to errors and metadata"""
|
|
396
|
-
url = self.base_url + "/sandboxagent.Filesystem/ListDir"
|
|
397
|
-
return await self._connect_client.call_unary(
|
|
398
|
-
url, req, api_pb2.ListDirResponse, extra_headers, timeout_seconds
|
|
399
|
-
)
|
|
400
|
-
|
|
401
|
-
async def list_dir(
|
|
402
|
-
self,
|
|
403
|
-
req: api_pb2.ListDirRequest,
|
|
404
|
-
extra_headers: HeaderInput | None = None,
|
|
405
|
-
timeout_seconds: float | None = None,
|
|
406
|
-
) -> api_pb2.ListDirResponse:
|
|
407
|
-
response = await self.call_list_dir(req, extra_headers, timeout_seconds)
|
|
408
|
-
err = response.error()
|
|
409
|
-
if err is not None:
|
|
410
|
-
raise err
|
|
411
|
-
msg = response.message()
|
|
412
|
-
if msg is None:
|
|
413
|
-
raise ConnectProtocolError("missing response message")
|
|
414
|
-
return msg
|
|
415
|
-
|
|
416
|
-
async def call_remove(
|
|
417
|
-
self,
|
|
418
|
-
req: api_pb2.RemoveRequest,
|
|
419
|
-
extra_headers: HeaderInput | None = None,
|
|
420
|
-
timeout_seconds: float | None = None,
|
|
421
|
-
) -> UnaryOutput[api_pb2.RemoveResponse]:
|
|
422
|
-
"""Low-level method to call Remove, granting access to errors and metadata"""
|
|
423
|
-
url = self.base_url + "/sandboxagent.Filesystem/Remove"
|
|
424
|
-
return await self._connect_client.call_unary(
|
|
425
|
-
url, req, api_pb2.RemoveResponse, extra_headers, timeout_seconds
|
|
426
|
-
)
|
|
427
|
-
|
|
428
|
-
async def remove(
|
|
429
|
-
self,
|
|
430
|
-
req: api_pb2.RemoveRequest,
|
|
431
|
-
extra_headers: HeaderInput | None = None,
|
|
432
|
-
timeout_seconds: float | None = None,
|
|
433
|
-
) -> api_pb2.RemoveResponse:
|
|
434
|
-
response = await self.call_remove(req, extra_headers, timeout_seconds)
|
|
435
|
-
err = response.error()
|
|
436
|
-
if err is not None:
|
|
437
|
-
raise err
|
|
438
|
-
msg = response.message()
|
|
439
|
-
if msg is None:
|
|
440
|
-
raise ConnectProtocolError("missing response message")
|
|
441
|
-
return msg
|
|
442
|
-
|
|
443
|
-
def watch_dir(
|
|
444
|
-
self,
|
|
445
|
-
req: api_pb2.WatchDirRequest,
|
|
446
|
-
extra_headers: HeaderInput | None = None,
|
|
447
|
-
timeout_seconds: float | None = None,
|
|
448
|
-
) -> AsyncIterator[api_pb2.WatchDirResponse]:
|
|
449
|
-
return self._watch_dir_iterator(req, extra_headers, timeout_seconds)
|
|
450
|
-
|
|
451
|
-
async def _watch_dir_iterator(
|
|
452
|
-
self,
|
|
453
|
-
req: api_pb2.WatchDirRequest,
|
|
454
|
-
extra_headers: HeaderInput | None = None,
|
|
455
|
-
timeout_seconds: float | None = None,
|
|
456
|
-
) -> AsyncIterator[api_pb2.WatchDirResponse]:
|
|
457
|
-
stream_output = await self.call_watch_dir(req, extra_headers)
|
|
458
|
-
err = stream_output.error()
|
|
459
|
-
if err is not None:
|
|
460
|
-
raise err
|
|
461
|
-
async with stream_output as stream:
|
|
462
|
-
async for response in stream:
|
|
463
|
-
yield response
|
|
464
|
-
err = stream.error()
|
|
465
|
-
if err is not None:
|
|
466
|
-
raise err
|
|
467
|
-
|
|
468
|
-
async def call_watch_dir(
|
|
469
|
-
self,
|
|
470
|
-
req: api_pb2.WatchDirRequest,
|
|
471
|
-
extra_headers: HeaderInput | None = None,
|
|
472
|
-
timeout_seconds: float | None = None,
|
|
473
|
-
) -> AsyncStreamOutput[api_pb2.WatchDirResponse]:
|
|
474
|
-
"""Low-level method to call WatchDir, granting access to errors and metadata"""
|
|
475
|
-
url = self.base_url + "/sandboxagent.Filesystem/WatchDir"
|
|
476
|
-
return await self._connect_client.call_server_streaming(
|
|
477
|
-
url, req, api_pb2.WatchDirResponse, extra_headers, timeout_seconds
|
|
478
|
-
)
|
|
479
|
-
|
|
480
|
-
async def call_create_watcher(
|
|
481
|
-
self,
|
|
482
|
-
req: api_pb2.CreateWatcherRequest,
|
|
483
|
-
extra_headers: HeaderInput | None = None,
|
|
484
|
-
timeout_seconds: float | None = None,
|
|
485
|
-
) -> UnaryOutput[api_pb2.CreateWatcherResponse]:
|
|
486
|
-
"""Low-level method to call CreateWatcher, granting access to errors and metadata"""
|
|
487
|
-
url = self.base_url + "/sandboxagent.Filesystem/CreateWatcher"
|
|
488
|
-
return await self._connect_client.call_unary(
|
|
489
|
-
url, req, api_pb2.CreateWatcherResponse, extra_headers, timeout_seconds
|
|
490
|
-
)
|
|
491
|
-
|
|
492
|
-
async def create_watcher(
|
|
493
|
-
self,
|
|
494
|
-
req: api_pb2.CreateWatcherRequest,
|
|
495
|
-
extra_headers: HeaderInput | None = None,
|
|
496
|
-
timeout_seconds: float | None = None,
|
|
497
|
-
) -> api_pb2.CreateWatcherResponse:
|
|
498
|
-
response = await self.call_create_watcher(req, extra_headers, timeout_seconds)
|
|
499
|
-
err = response.error()
|
|
500
|
-
if err is not None:
|
|
501
|
-
raise err
|
|
502
|
-
msg = response.message()
|
|
503
|
-
if msg is None:
|
|
504
|
-
raise ConnectProtocolError("missing response message")
|
|
505
|
-
return msg
|
|
506
|
-
|
|
507
|
-
async def call_get_watcher_events(
|
|
508
|
-
self,
|
|
509
|
-
req: api_pb2.GetWatcherEventsRequest,
|
|
510
|
-
extra_headers: HeaderInput | None = None,
|
|
511
|
-
timeout_seconds: float | None = None,
|
|
512
|
-
) -> UnaryOutput[api_pb2.GetWatcherEventsResponse]:
|
|
513
|
-
"""Low-level method to call GetWatcherEvents, granting access to errors and metadata"""
|
|
514
|
-
url = self.base_url + "/sandboxagent.Filesystem/GetWatcherEvents"
|
|
515
|
-
return await self._connect_client.call_unary(
|
|
516
|
-
url, req, api_pb2.GetWatcherEventsResponse, extra_headers, timeout_seconds
|
|
517
|
-
)
|
|
518
|
-
|
|
519
|
-
async def get_watcher_events(
|
|
520
|
-
self,
|
|
521
|
-
req: api_pb2.GetWatcherEventsRequest,
|
|
522
|
-
extra_headers: HeaderInput | None = None,
|
|
523
|
-
timeout_seconds: float | None = None,
|
|
524
|
-
) -> api_pb2.GetWatcherEventsResponse:
|
|
525
|
-
response = await self.call_get_watcher_events(
|
|
526
|
-
req, extra_headers, timeout_seconds
|
|
527
|
-
)
|
|
528
|
-
err = response.error()
|
|
529
|
-
if err is not None:
|
|
530
|
-
raise err
|
|
531
|
-
msg = response.message()
|
|
532
|
-
if msg is None:
|
|
533
|
-
raise ConnectProtocolError("missing response message")
|
|
534
|
-
return msg
|
|
535
|
-
|
|
536
|
-
async def call_remove_watcher(
|
|
537
|
-
self,
|
|
538
|
-
req: api_pb2.RemoveWatcherRequest,
|
|
539
|
-
extra_headers: HeaderInput | None = None,
|
|
540
|
-
timeout_seconds: float | None = None,
|
|
541
|
-
) -> UnaryOutput[api_pb2.RemoveWatcherResponse]:
|
|
542
|
-
"""Low-level method to call RemoveWatcher, granting access to errors and metadata"""
|
|
543
|
-
url = self.base_url + "/sandboxagent.Filesystem/RemoveWatcher"
|
|
544
|
-
return await self._connect_client.call_unary(
|
|
545
|
-
url, req, api_pb2.RemoveWatcherResponse, extra_headers, timeout_seconds
|
|
546
|
-
)
|
|
547
|
-
|
|
548
|
-
async def remove_watcher(
|
|
549
|
-
self,
|
|
550
|
-
req: api_pb2.RemoveWatcherRequest,
|
|
551
|
-
extra_headers: HeaderInput | None = None,
|
|
552
|
-
timeout_seconds: float | None = None,
|
|
553
|
-
) -> api_pb2.RemoveWatcherResponse:
|
|
554
|
-
response = await self.call_remove_watcher(req, extra_headers, timeout_seconds)
|
|
555
|
-
err = response.error()
|
|
556
|
-
if err is not None:
|
|
557
|
-
raise err
|
|
558
|
-
msg = response.message()
|
|
559
|
-
if msg is None:
|
|
560
|
-
raise ConnectProtocolError("missing response message")
|
|
561
|
-
return msg
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
@typing.runtime_checkable
|
|
565
|
-
class FilesystemProtocol(typing.Protocol):
|
|
566
|
-
def stat(
|
|
567
|
-
self, req: ClientRequest[api_pb2.StatRequest]
|
|
568
|
-
) -> ServerResponse[api_pb2.StatResponse]: ...
|
|
569
|
-
def make_dir(
|
|
570
|
-
self, req: ClientRequest[api_pb2.MakeDirRequest]
|
|
571
|
-
) -> ServerResponse[api_pb2.MakeDirResponse]: ...
|
|
572
|
-
def move(
|
|
573
|
-
self, req: ClientRequest[api_pb2.MoveRequest]
|
|
574
|
-
) -> ServerResponse[api_pb2.MoveResponse]: ...
|
|
575
|
-
def list_dir(
|
|
576
|
-
self, req: ClientRequest[api_pb2.ListDirRequest]
|
|
577
|
-
) -> ServerResponse[api_pb2.ListDirResponse]: ...
|
|
578
|
-
def remove(
|
|
579
|
-
self, req: ClientRequest[api_pb2.RemoveRequest]
|
|
580
|
-
) -> ServerResponse[api_pb2.RemoveResponse]: ...
|
|
581
|
-
def watch_dir(
|
|
582
|
-
self, req: ClientRequest[api_pb2.WatchDirRequest]
|
|
583
|
-
) -> ServerStream[api_pb2.WatchDirResponse]: ...
|
|
584
|
-
def create_watcher(
|
|
585
|
-
self, req: ClientRequest[api_pb2.CreateWatcherRequest]
|
|
586
|
-
) -> ServerResponse[api_pb2.CreateWatcherResponse]: ...
|
|
587
|
-
def get_watcher_events(
|
|
588
|
-
self, req: ClientRequest[api_pb2.GetWatcherEventsRequest]
|
|
589
|
-
) -> ServerResponse[api_pb2.GetWatcherEventsResponse]: ...
|
|
590
|
-
def remove_watcher(
|
|
591
|
-
self, req: ClientRequest[api_pb2.RemoveWatcherRequest]
|
|
592
|
-
) -> ServerResponse[api_pb2.RemoveWatcherResponse]: ...
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
FILESYSTEM_PATH_PREFIX = "/sandboxagent.Filesystem"
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
def wsgi_filesystem(implementation: FilesystemProtocol) -> WSGIApplication:
|
|
599
|
-
app = ConnectWSGI()
|
|
600
|
-
app.register_unary_rpc(
|
|
601
|
-
"/sandboxagent.Filesystem/Stat", implementation.stat, api_pb2.StatRequest
|
|
602
|
-
)
|
|
603
|
-
app.register_unary_rpc(
|
|
604
|
-
"/sandboxagent.Filesystem/MakeDir",
|
|
605
|
-
implementation.make_dir,
|
|
606
|
-
api_pb2.MakeDirRequest,
|
|
607
|
-
)
|
|
608
|
-
app.register_unary_rpc(
|
|
609
|
-
"/sandboxagent.Filesystem/Move", implementation.move, api_pb2.MoveRequest
|
|
610
|
-
)
|
|
611
|
-
app.register_unary_rpc(
|
|
612
|
-
"/sandboxagent.Filesystem/ListDir",
|
|
613
|
-
implementation.list_dir,
|
|
614
|
-
api_pb2.ListDirRequest,
|
|
615
|
-
)
|
|
616
|
-
app.register_unary_rpc(
|
|
617
|
-
"/sandboxagent.Filesystem/Remove", implementation.remove, api_pb2.RemoveRequest
|
|
618
|
-
)
|
|
619
|
-
app.register_server_streaming_rpc(
|
|
620
|
-
"/sandboxagent.Filesystem/WatchDir",
|
|
621
|
-
implementation.watch_dir,
|
|
622
|
-
api_pb2.WatchDirRequest,
|
|
623
|
-
)
|
|
624
|
-
app.register_unary_rpc(
|
|
625
|
-
"/sandboxagent.Filesystem/CreateWatcher",
|
|
626
|
-
implementation.create_watcher,
|
|
627
|
-
api_pb2.CreateWatcherRequest,
|
|
628
|
-
)
|
|
629
|
-
app.register_unary_rpc(
|
|
630
|
-
"/sandboxagent.Filesystem/GetWatcherEvents",
|
|
631
|
-
implementation.get_watcher_events,
|
|
632
|
-
api_pb2.GetWatcherEventsRequest,
|
|
633
|
-
)
|
|
634
|
-
app.register_unary_rpc(
|
|
635
|
-
"/sandboxagent.Filesystem/RemoveWatcher",
|
|
636
|
-
implementation.remove_watcher,
|
|
637
|
-
api_pb2.RemoveWatcherRequest,
|
|
638
|
-
)
|
|
639
|
-
return app
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
class ProcessClient:
|
|
643
|
-
def __init__(
|
|
644
|
-
self,
|
|
645
|
-
base_url: str,
|
|
646
|
-
http_client: urllib3.PoolManager | None = None,
|
|
647
|
-
protocol: ConnectProtocol = ConnectProtocol.CONNECT_PROTOBUF,
|
|
648
|
-
):
|
|
649
|
-
self.base_url = base_url
|
|
650
|
-
self._connect_client = ConnectClient(http_client, protocol)
|
|
651
|
-
|
|
652
|
-
def call_list(
|
|
653
|
-
self,
|
|
654
|
-
req: api_pb2.ListRequest,
|
|
655
|
-
extra_headers: HeaderInput | None = None,
|
|
656
|
-
timeout_seconds: float | None = None,
|
|
657
|
-
) -> UnaryOutput[api_pb2.ListResponse]:
|
|
658
|
-
"""Low-level method to call List, granting access to errors and metadata"""
|
|
659
|
-
url = self.base_url + "/sandboxagent.Process/List"
|
|
660
|
-
return self._connect_client.call_unary(
|
|
661
|
-
url, req, api_pb2.ListResponse, extra_headers, timeout_seconds
|
|
662
|
-
)
|
|
663
|
-
|
|
664
|
-
def list(
|
|
665
|
-
self,
|
|
666
|
-
req: api_pb2.ListRequest,
|
|
667
|
-
extra_headers: HeaderInput | None = None,
|
|
668
|
-
timeout_seconds: float | None = None,
|
|
669
|
-
) -> api_pb2.ListResponse:
|
|
670
|
-
response = self.call_list(req, extra_headers, timeout_seconds)
|
|
671
|
-
err = response.error()
|
|
672
|
-
if err is not None:
|
|
673
|
-
raise err
|
|
674
|
-
msg = response.message()
|
|
675
|
-
if msg is None:
|
|
676
|
-
raise ConnectProtocolError("missing response message")
|
|
677
|
-
return msg
|
|
678
|
-
|
|
679
|
-
def connect(
|
|
680
|
-
self,
|
|
681
|
-
req: api_pb2.ConnectRequest,
|
|
682
|
-
extra_headers: HeaderInput | None = None,
|
|
683
|
-
timeout_seconds: float | None = None,
|
|
684
|
-
) -> Iterator[api_pb2.ConnectResponse]:
|
|
685
|
-
return self._connect_iterator(req, extra_headers, timeout_seconds)
|
|
686
|
-
|
|
687
|
-
def _connect_iterator(
|
|
688
|
-
self,
|
|
689
|
-
req: api_pb2.ConnectRequest,
|
|
690
|
-
extra_headers: HeaderInput | None = None,
|
|
691
|
-
timeout_seconds: float | None = None,
|
|
692
|
-
) -> Iterator[api_pb2.ConnectResponse]:
|
|
693
|
-
stream_output = self.call_connect(req, extra_headers,timeout_seconds)
|
|
694
|
-
err = stream_output.error()
|
|
695
|
-
if err is not None:
|
|
696
|
-
raise err
|
|
697
|
-
yield from stream_output
|
|
698
|
-
err = stream_output.error()
|
|
699
|
-
if err is not None:
|
|
700
|
-
raise err
|
|
701
|
-
|
|
702
|
-
def call_connect(
|
|
703
|
-
self,
|
|
704
|
-
req: api_pb2.ConnectRequest,
|
|
705
|
-
extra_headers: HeaderInput | None = None,
|
|
706
|
-
timeout_seconds: float | None = None,
|
|
707
|
-
) -> StreamOutput[api_pb2.ConnectResponse]:
|
|
708
|
-
"""Low-level method to call Connect, granting access to errors and metadata"""
|
|
709
|
-
url = self.base_url + "/sandboxagent.Process/Connect"
|
|
710
|
-
return self._connect_client.call_server_streaming(
|
|
711
|
-
url, req, api_pb2.ConnectResponse, extra_headers, timeout_seconds
|
|
712
|
-
)
|
|
713
|
-
|
|
714
|
-
def start(
|
|
715
|
-
self,
|
|
716
|
-
req: api_pb2.StartRequest,
|
|
717
|
-
extra_headers: HeaderInput | None = None,
|
|
718
|
-
timeout_seconds: float | None = None,
|
|
719
|
-
) -> Iterator[api_pb2.StartResponse]:
|
|
720
|
-
return self._start_iterator(req, extra_headers, timeout_seconds)
|
|
721
|
-
|
|
722
|
-
def _start_iterator(
|
|
723
|
-
self,
|
|
724
|
-
req: api_pb2.StartRequest,
|
|
725
|
-
extra_headers: HeaderInput | None = None,
|
|
726
|
-
timeout_seconds: float | None = None,
|
|
727
|
-
) -> Iterator[api_pb2.StartResponse]:
|
|
728
|
-
stream_output = self.call_start(req, extra_headers,timeout_seconds)
|
|
729
|
-
err = stream_output.error()
|
|
730
|
-
if err is not None:
|
|
731
|
-
raise err
|
|
732
|
-
yield from stream_output
|
|
733
|
-
err = stream_output.error()
|
|
734
|
-
if err is not None:
|
|
735
|
-
raise err
|
|
736
|
-
|
|
737
|
-
def call_start(
|
|
738
|
-
self,
|
|
739
|
-
req: api_pb2.StartRequest,
|
|
740
|
-
extra_headers: HeaderInput | None = None,
|
|
741
|
-
timeout_seconds: float | None = None,
|
|
742
|
-
) -> StreamOutput[api_pb2.StartResponse]:
|
|
743
|
-
"""Low-level method to call Start, granting access to errors and metadata"""
|
|
744
|
-
url = self.base_url + "/sandboxagent.Process/Start"
|
|
745
|
-
return self._connect_client.call_server_streaming(
|
|
746
|
-
url, req, api_pb2.StartResponse, extra_headers, timeout_seconds
|
|
747
|
-
)
|
|
748
|
-
|
|
749
|
-
def call_update(
|
|
750
|
-
self,
|
|
751
|
-
req: api_pb2.UpdateRequest,
|
|
752
|
-
extra_headers: HeaderInput | None = None,
|
|
753
|
-
timeout_seconds: float | None = None,
|
|
754
|
-
) -> UnaryOutput[api_pb2.UpdateResponse]:
|
|
755
|
-
"""Low-level method to call Update, granting access to errors and metadata"""
|
|
756
|
-
url = self.base_url + "/sandboxagent.Process/Update"
|
|
757
|
-
return self._connect_client.call_unary(
|
|
758
|
-
url, req, api_pb2.UpdateResponse, extra_headers, timeout_seconds
|
|
759
|
-
)
|
|
760
|
-
|
|
761
|
-
def update(
|
|
762
|
-
self,
|
|
763
|
-
req: api_pb2.UpdateRequest,
|
|
764
|
-
extra_headers: HeaderInput | None = None,
|
|
765
|
-
timeout_seconds: float | None = None,
|
|
766
|
-
) -> api_pb2.UpdateResponse:
|
|
767
|
-
response = self.call_update(req, extra_headers, timeout_seconds)
|
|
768
|
-
err = response.error()
|
|
769
|
-
if err is not None:
|
|
770
|
-
raise err
|
|
771
|
-
msg = response.message()
|
|
772
|
-
if msg is None:
|
|
773
|
-
raise ConnectProtocolError("missing response message")
|
|
774
|
-
return msg
|
|
775
|
-
|
|
776
|
-
def call_stream_input(
|
|
777
|
-
self,
|
|
778
|
-
reqs: Iterable[api_pb2.StreamInputRequest],
|
|
779
|
-
extra_headers: HeaderInput | None = None,
|
|
780
|
-
timeout_seconds: float | None = None,
|
|
781
|
-
) -> ClientStreamingOutput[api_pb2.StreamInputResponse]:
|
|
782
|
-
"""Low-level method to call StreamInput, granting access to errors and metadata"""
|
|
783
|
-
url = self.base_url + "/sandboxagent.Process/StreamInput"
|
|
784
|
-
return self._connect_client.call_client_streaming(
|
|
785
|
-
url, reqs, api_pb2.StreamInputResponse, extra_headers, timeout_seconds
|
|
786
|
-
)
|
|
787
|
-
|
|
788
|
-
def stream_input(
|
|
789
|
-
self,
|
|
790
|
-
reqs: Iterable[api_pb2.StreamInputRequest],
|
|
791
|
-
extra_headers: HeaderInput | None = None,
|
|
792
|
-
timeout_seconds: float | None = None,
|
|
793
|
-
) -> api_pb2.StreamInputResponse:
|
|
794
|
-
client_stream_output = self.call_stream_input(reqs, extra_headers)
|
|
795
|
-
err = client_stream_output.error()
|
|
796
|
-
if err is not None:
|
|
797
|
-
raise err
|
|
798
|
-
msg = client_stream_output.message()
|
|
799
|
-
if msg is None:
|
|
800
|
-
raise RuntimeError("ClientStreamOutput has empty error and message")
|
|
801
|
-
return msg
|
|
802
|
-
|
|
803
|
-
def call_send_input(
|
|
804
|
-
self,
|
|
805
|
-
req: api_pb2.SendInputRequest,
|
|
806
|
-
extra_headers: HeaderInput | None = None,
|
|
807
|
-
timeout_seconds: float | None = None,
|
|
808
|
-
) -> UnaryOutput[api_pb2.SendInputResponse]:
|
|
809
|
-
"""Low-level method to call SendInput, granting access to errors and metadata"""
|
|
810
|
-
url = self.base_url + "/sandboxagent.Process/SendInput"
|
|
811
|
-
return self._connect_client.call_unary(
|
|
812
|
-
url, req, api_pb2.SendInputResponse, extra_headers, timeout_seconds
|
|
813
|
-
)
|
|
814
|
-
|
|
815
|
-
def send_input(
|
|
816
|
-
self,
|
|
817
|
-
req: api_pb2.SendInputRequest,
|
|
818
|
-
extra_headers: HeaderInput | None = None,
|
|
819
|
-
timeout_seconds: float | None = None,
|
|
820
|
-
) -> api_pb2.SendInputResponse:
|
|
821
|
-
response = self.call_send_input(req, extra_headers, timeout_seconds)
|
|
822
|
-
err = response.error()
|
|
823
|
-
if err is not None:
|
|
824
|
-
raise err
|
|
825
|
-
msg = response.message()
|
|
826
|
-
if msg is None:
|
|
827
|
-
raise ConnectProtocolError("missing response message")
|
|
828
|
-
return msg
|
|
829
|
-
|
|
830
|
-
def call_send_signal(
|
|
831
|
-
self,
|
|
832
|
-
req: api_pb2.SendSignalRequest,
|
|
833
|
-
extra_headers: HeaderInput | None = None,
|
|
834
|
-
timeout_seconds: float | None = None,
|
|
835
|
-
) -> UnaryOutput[api_pb2.SendSignalResponse]:
|
|
836
|
-
"""Low-level method to call SendSignal, granting access to errors and metadata"""
|
|
837
|
-
url = self.base_url + "/sandboxagent.Process/SendSignal"
|
|
838
|
-
return self._connect_client.call_unary(
|
|
839
|
-
url, req, api_pb2.SendSignalResponse, extra_headers, timeout_seconds
|
|
840
|
-
)
|
|
841
|
-
|
|
842
|
-
def send_signal(
|
|
843
|
-
self,
|
|
844
|
-
req: api_pb2.SendSignalRequest,
|
|
845
|
-
extra_headers: HeaderInput | None = None,
|
|
846
|
-
timeout_seconds: float | None = None,
|
|
847
|
-
) -> api_pb2.SendSignalResponse:
|
|
848
|
-
response = self.call_send_signal(req, extra_headers, timeout_seconds)
|
|
849
|
-
err = response.error()
|
|
850
|
-
if err is not None:
|
|
851
|
-
raise err
|
|
852
|
-
msg = response.message()
|
|
853
|
-
if msg is None:
|
|
854
|
-
raise ConnectProtocolError("missing response message")
|
|
855
|
-
return msg
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
class AsyncProcessClient:
|
|
859
|
-
def __init__(
|
|
860
|
-
self,
|
|
861
|
-
base_url: str,
|
|
862
|
-
http_client: aiohttp.ClientSession,
|
|
863
|
-
protocol: ConnectProtocol = ConnectProtocol.CONNECT_PROTOBUF,
|
|
864
|
-
):
|
|
865
|
-
self.base_url = base_url
|
|
866
|
-
self._connect_client = AsyncConnectClient(http_client, protocol)
|
|
867
|
-
|
|
868
|
-
async def call_list(
|
|
869
|
-
self,
|
|
870
|
-
req: api_pb2.ListRequest,
|
|
871
|
-
extra_headers: HeaderInput | None = None,
|
|
872
|
-
timeout_seconds: float | None = None,
|
|
873
|
-
) -> UnaryOutput[api_pb2.ListResponse]:
|
|
874
|
-
"""Low-level method to call List, granting access to errors and metadata"""
|
|
875
|
-
url = self.base_url + "/sandboxagent.Process/List"
|
|
876
|
-
return await self._connect_client.call_unary(
|
|
877
|
-
url, req, api_pb2.ListResponse, extra_headers, timeout_seconds
|
|
878
|
-
)
|
|
879
|
-
|
|
880
|
-
async def list(
|
|
881
|
-
self,
|
|
882
|
-
req: api_pb2.ListRequest,
|
|
883
|
-
extra_headers: HeaderInput | None = None,
|
|
884
|
-
timeout_seconds: float | None = None,
|
|
885
|
-
) -> api_pb2.ListResponse:
|
|
886
|
-
response = await self.call_list(req, extra_headers, timeout_seconds)
|
|
887
|
-
err = response.error()
|
|
888
|
-
if err is not None:
|
|
889
|
-
raise err
|
|
890
|
-
msg = response.message()
|
|
891
|
-
if msg is None:
|
|
892
|
-
raise ConnectProtocolError("missing response message")
|
|
893
|
-
return msg
|
|
894
|
-
|
|
895
|
-
def connect(
|
|
896
|
-
self,
|
|
897
|
-
req: api_pb2.ConnectRequest,
|
|
898
|
-
extra_headers: HeaderInput | None = None,
|
|
899
|
-
timeout_seconds: float | None = None,
|
|
900
|
-
) -> AsyncIterator[api_pb2.ConnectResponse]:
|
|
901
|
-
return self._connect_iterator(req, extra_headers, timeout_seconds)
|
|
902
|
-
|
|
903
|
-
async def _connect_iterator(
|
|
904
|
-
self,
|
|
905
|
-
req: api_pb2.ConnectRequest,
|
|
906
|
-
extra_headers: HeaderInput | None = None,
|
|
907
|
-
timeout_seconds: float | None = None,
|
|
908
|
-
) -> AsyncIterator[api_pb2.ConnectResponse]:
|
|
909
|
-
stream_output = await self.call_connect(req, extra_headers)
|
|
910
|
-
err = stream_output.error()
|
|
911
|
-
if err is not None:
|
|
912
|
-
raise err
|
|
913
|
-
async with stream_output as stream:
|
|
914
|
-
async for response in stream:
|
|
915
|
-
yield response
|
|
916
|
-
err = stream.error()
|
|
917
|
-
if err is not None:
|
|
918
|
-
raise err
|
|
919
|
-
|
|
920
|
-
async def call_connect(
|
|
921
|
-
self,
|
|
922
|
-
req: api_pb2.ConnectRequest,
|
|
923
|
-
extra_headers: HeaderInput | None = None,
|
|
924
|
-
timeout_seconds: float | None = None,
|
|
925
|
-
) -> AsyncStreamOutput[api_pb2.ConnectResponse]:
|
|
926
|
-
"""Low-level method to call Connect, granting access to errors and metadata"""
|
|
927
|
-
url = self.base_url + "/sandboxagent.Process/Connect"
|
|
928
|
-
return await self._connect_client.call_server_streaming(
|
|
929
|
-
url, req, api_pb2.ConnectResponse, extra_headers, timeout_seconds
|
|
930
|
-
)
|
|
931
|
-
|
|
932
|
-
def start(
|
|
933
|
-
self,
|
|
934
|
-
req: api_pb2.StartRequest,
|
|
935
|
-
extra_headers: HeaderInput | None = None,
|
|
936
|
-
timeout_seconds: float | None = None,
|
|
937
|
-
) -> AsyncIterator[api_pb2.StartResponse]:
|
|
938
|
-
return self._start_iterator(req, extra_headers, timeout_seconds)
|
|
939
|
-
|
|
940
|
-
async def _start_iterator(
|
|
941
|
-
self,
|
|
942
|
-
req: api_pb2.StartRequest,
|
|
943
|
-
extra_headers: HeaderInput | None = None,
|
|
944
|
-
timeout_seconds: float | None = None,
|
|
945
|
-
) -> AsyncIterator[api_pb2.StartResponse]:
|
|
946
|
-
stream_output = await self.call_start(req, extra_headers,timeout_seconds)
|
|
947
|
-
err = stream_output.error()
|
|
948
|
-
if err is not None:
|
|
949
|
-
raise err
|
|
950
|
-
async with stream_output as stream:
|
|
951
|
-
async for response in stream:
|
|
952
|
-
yield response
|
|
953
|
-
err = stream.error()
|
|
954
|
-
if err is not None:
|
|
955
|
-
raise err
|
|
956
|
-
|
|
957
|
-
async def call_start(
|
|
958
|
-
self,
|
|
959
|
-
req: api_pb2.StartRequest,
|
|
960
|
-
extra_headers: HeaderInput | None = None,
|
|
961
|
-
timeout_seconds: float | None = None,
|
|
962
|
-
) -> AsyncStreamOutput[api_pb2.StartResponse]:
|
|
963
|
-
"""Low-level method to call Start, granting access to errors and metadata"""
|
|
964
|
-
url = self.base_url + "/sandboxagent.Process/Start"
|
|
965
|
-
return await self._connect_client.call_server_streaming(
|
|
966
|
-
url, req, api_pb2.StartResponse, extra_headers, timeout_seconds
|
|
967
|
-
)
|
|
968
|
-
|
|
969
|
-
async def call_update(
|
|
970
|
-
self,
|
|
971
|
-
req: api_pb2.UpdateRequest,
|
|
972
|
-
extra_headers: HeaderInput | None = None,
|
|
973
|
-
timeout_seconds: float | None = None,
|
|
974
|
-
) -> UnaryOutput[api_pb2.UpdateResponse]:
|
|
975
|
-
"""Low-level method to call Update, granting access to errors and metadata"""
|
|
976
|
-
url = self.base_url + "/sandboxagent.Process/Update"
|
|
977
|
-
return await self._connect_client.call_unary(
|
|
978
|
-
url, req, api_pb2.UpdateResponse, extra_headers, timeout_seconds
|
|
979
|
-
)
|
|
980
|
-
|
|
981
|
-
async def update(
|
|
982
|
-
self,
|
|
983
|
-
req: api_pb2.UpdateRequest,
|
|
984
|
-
extra_headers: HeaderInput | None = None,
|
|
985
|
-
timeout_seconds: float | None = None,
|
|
986
|
-
) -> api_pb2.UpdateResponse:
|
|
987
|
-
response = await self.call_update(req, extra_headers, timeout_seconds)
|
|
988
|
-
err = response.error()
|
|
989
|
-
if err is not None:
|
|
990
|
-
raise err
|
|
991
|
-
msg = response.message()
|
|
992
|
-
if msg is None:
|
|
993
|
-
raise ConnectProtocolError("missing response message")
|
|
994
|
-
return msg
|
|
995
|
-
|
|
996
|
-
async def call_stream_input(
|
|
997
|
-
self,
|
|
998
|
-
reqs: StreamInput[api_pb2.StreamInputRequest],
|
|
999
|
-
extra_headers: HeaderInput | None = None,
|
|
1000
|
-
timeout_seconds: float | None = None,
|
|
1001
|
-
) -> ClientStreamingOutput[api_pb2.StreamInputResponse]:
|
|
1002
|
-
"""Low-level method to call StreamInput, granting access to errors and metadata"""
|
|
1003
|
-
url = self.base_url + "/sandboxagent.Process/StreamInput"
|
|
1004
|
-
return await self._connect_client.call_client_streaming(
|
|
1005
|
-
url, reqs, api_pb2.StreamInputResponse, extra_headers, timeout_seconds
|
|
1006
|
-
)
|
|
1007
|
-
|
|
1008
|
-
async def stream_input(
|
|
1009
|
-
self,
|
|
1010
|
-
reqs: StreamInput[api_pb2.StreamInputRequest],
|
|
1011
|
-
extra_headers: HeaderInput | None = None,
|
|
1012
|
-
timeout_seconds: float | None = None,
|
|
1013
|
-
) -> api_pb2.StreamInputResponse:
|
|
1014
|
-
client_stream_output = await self.call_stream_input(reqs, extra_headers)
|
|
1015
|
-
err = client_stream_output.error()
|
|
1016
|
-
if err is not None:
|
|
1017
|
-
raise err
|
|
1018
|
-
msg = client_stream_output.message()
|
|
1019
|
-
if msg is None:
|
|
1020
|
-
raise RuntimeError("ClientStreamOutput has empty error and message")
|
|
1021
|
-
return msg
|
|
1022
|
-
|
|
1023
|
-
async def call_send_input(
|
|
1024
|
-
self,
|
|
1025
|
-
req: api_pb2.SendInputRequest,
|
|
1026
|
-
extra_headers: HeaderInput | None = None,
|
|
1027
|
-
timeout_seconds: float | None = None,
|
|
1028
|
-
) -> UnaryOutput[api_pb2.SendInputResponse]:
|
|
1029
|
-
"""Low-level method to call SendInput, granting access to errors and metadata"""
|
|
1030
|
-
url = self.base_url + "/sandboxagent.Process/SendInput"
|
|
1031
|
-
return await self._connect_client.call_unary(
|
|
1032
|
-
url, req, api_pb2.SendInputResponse, extra_headers, timeout_seconds
|
|
1033
|
-
)
|
|
1034
|
-
|
|
1035
|
-
async def send_input(
|
|
1036
|
-
self,
|
|
1037
|
-
req: api_pb2.SendInputRequest,
|
|
1038
|
-
extra_headers: HeaderInput | None = None,
|
|
1039
|
-
timeout_seconds: float | None = None,
|
|
1040
|
-
) -> api_pb2.SendInputResponse:
|
|
1041
|
-
response = await self.call_send_input(req, extra_headers, timeout_seconds)
|
|
1042
|
-
err = response.error()
|
|
1043
|
-
if err is not None:
|
|
1044
|
-
raise err
|
|
1045
|
-
msg = response.message()
|
|
1046
|
-
if msg is None:
|
|
1047
|
-
raise ConnectProtocolError("missing response message")
|
|
1048
|
-
return msg
|
|
1049
|
-
|
|
1050
|
-
async def call_send_signal(
|
|
1051
|
-
self,
|
|
1052
|
-
req: api_pb2.SendSignalRequest,
|
|
1053
|
-
extra_headers: HeaderInput | None = None,
|
|
1054
|
-
timeout_seconds: float | None = None,
|
|
1055
|
-
) -> UnaryOutput[api_pb2.SendSignalResponse]:
|
|
1056
|
-
"""Low-level method to call SendSignal, granting access to errors and metadata"""
|
|
1057
|
-
url = self.base_url + "/sandboxagent.Process/SendSignal"
|
|
1058
|
-
return await self._connect_client.call_unary(
|
|
1059
|
-
url, req, api_pb2.SendSignalResponse, extra_headers, timeout_seconds
|
|
1060
|
-
)
|
|
1061
|
-
|
|
1062
|
-
async def send_signal(
|
|
1063
|
-
self,
|
|
1064
|
-
req: api_pb2.SendSignalRequest,
|
|
1065
|
-
extra_headers: HeaderInput | None = None,
|
|
1066
|
-
timeout_seconds: float | None = None,
|
|
1067
|
-
) -> api_pb2.SendSignalResponse:
|
|
1068
|
-
response = await self.call_send_signal(req, extra_headers, timeout_seconds)
|
|
1069
|
-
err = response.error()
|
|
1070
|
-
if err is not None:
|
|
1071
|
-
raise err
|
|
1072
|
-
msg = response.message()
|
|
1073
|
-
if msg is None:
|
|
1074
|
-
raise ConnectProtocolError("missing response message")
|
|
1075
|
-
return msg
|
|
1076
|
-
|
|
1077
|
-
|
|
1078
|
-
@typing.runtime_checkable
|
|
1079
|
-
class ProcessProtocol(typing.Protocol):
|
|
1080
|
-
def list(
|
|
1081
|
-
self, req: ClientRequest[api_pb2.ListRequest]
|
|
1082
|
-
) -> ServerResponse[api_pb2.ListResponse]: ...
|
|
1083
|
-
def connect(
|
|
1084
|
-
self, req: ClientRequest[api_pb2.ConnectRequest]
|
|
1085
|
-
) -> ServerStream[api_pb2.ConnectResponse]: ...
|
|
1086
|
-
def start(
|
|
1087
|
-
self, req: ClientRequest[api_pb2.StartRequest]
|
|
1088
|
-
) -> ServerStream[api_pb2.StartResponse]: ...
|
|
1089
|
-
def update(
|
|
1090
|
-
self, req: ClientRequest[api_pb2.UpdateRequest]
|
|
1091
|
-
) -> ServerResponse[api_pb2.UpdateResponse]: ...
|
|
1092
|
-
def stream_input(
|
|
1093
|
-
self, req: ClientStream[api_pb2.StreamInputRequest]
|
|
1094
|
-
) -> ServerResponse[api_pb2.StreamInputResponse]: ...
|
|
1095
|
-
def send_input(
|
|
1096
|
-
self, req: ClientRequest[api_pb2.SendInputRequest]
|
|
1097
|
-
) -> ServerResponse[api_pb2.SendInputResponse]: ...
|
|
1098
|
-
def send_signal(
|
|
1099
|
-
self, req: ClientRequest[api_pb2.SendSignalRequest]
|
|
1100
|
-
) -> ServerResponse[api_pb2.SendSignalResponse]: ...
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
PROCESS_PATH_PREFIX = "/sandboxagent.Process"
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
def wsgi_process(implementation: ProcessProtocol) -> WSGIApplication:
|
|
1107
|
-
app = ConnectWSGI()
|
|
1108
|
-
app.register_unary_rpc(
|
|
1109
|
-
"/sandboxagent.Process/List", implementation.list, api_pb2.ListRequest
|
|
1110
|
-
)
|
|
1111
|
-
app.register_server_streaming_rpc(
|
|
1112
|
-
"/sandboxagent.Process/Connect", implementation.connect, api_pb2.ConnectRequest
|
|
1113
|
-
)
|
|
1114
|
-
app.register_server_streaming_rpc(
|
|
1115
|
-
"/sandboxagent.Process/Start", implementation.start, api_pb2.StartRequest
|
|
1116
|
-
)
|
|
1117
|
-
app.register_unary_rpc(
|
|
1118
|
-
"/sandboxagent.Process/Update", implementation.update, api_pb2.UpdateRequest
|
|
1119
|
-
)
|
|
1120
|
-
app.register_client_streaming_rpc(
|
|
1121
|
-
"/sandboxagent.Process/StreamInput",
|
|
1122
|
-
implementation.stream_input,
|
|
1123
|
-
api_pb2.StreamInputRequest,
|
|
1124
|
-
)
|
|
1125
|
-
app.register_unary_rpc(
|
|
1126
|
-
"/sandboxagent.Process/SendInput",
|
|
1127
|
-
implementation.send_input,
|
|
1128
|
-
api_pb2.SendInputRequest,
|
|
1129
|
-
)
|
|
1130
|
-
app.register_unary_rpc(
|
|
1131
|
-
"/sandboxagent.Process/SendSignal",
|
|
1132
|
-
implementation.send_signal,
|
|
1133
|
-
api_pb2.SendSignalRequest,
|
|
1134
|
-
)
|
|
1135
|
-
return app
|
|
1136
|
-
|
|
1137
|
-
|
|
1138
|
-
class ExecutionServiceClient:
|
|
1139
|
-
def __init__(
|
|
1140
|
-
self,
|
|
1141
|
-
base_url: str,
|
|
1142
|
-
http_client: urllib3.PoolManager | None = None,
|
|
1143
|
-
protocol: ConnectProtocol = ConnectProtocol.CONNECT_PROTOBUF,
|
|
1144
|
-
):
|
|
1145
|
-
self.base_url = base_url
|
|
1146
|
-
self._connect_client = ConnectClient(http_client, protocol)
|
|
1147
|
-
|
|
1148
|
-
def execute(
|
|
1149
|
-
self,
|
|
1150
|
-
req: api_pb2.ExecuteRequest,
|
|
1151
|
-
extra_headers: HeaderInput | None = None,
|
|
1152
|
-
timeout_seconds: float | None = None,
|
|
1153
|
-
) -> Iterator[api_pb2.ExecuteResponse]:
|
|
1154
|
-
return self._execute_iterator(req, extra_headers, timeout_seconds)
|
|
1155
|
-
|
|
1156
|
-
def _execute_iterator(
|
|
1157
|
-
self,
|
|
1158
|
-
req: api_pb2.ExecuteRequest,
|
|
1159
|
-
extra_headers: HeaderInput | None = None,
|
|
1160
|
-
timeout_seconds: float | None = None,
|
|
1161
|
-
) -> Iterator[api_pb2.ExecuteResponse]:
|
|
1162
|
-
stream_output = self.call_execute(req, extra_headers)
|
|
1163
|
-
err = stream_output.error()
|
|
1164
|
-
if err is not None:
|
|
1165
|
-
raise err
|
|
1166
|
-
yield from stream_output
|
|
1167
|
-
err = stream_output.error()
|
|
1168
|
-
if err is not None:
|
|
1169
|
-
raise err
|
|
1170
|
-
|
|
1171
|
-
def call_execute(
|
|
1172
|
-
self,
|
|
1173
|
-
req: api_pb2.ExecuteRequest,
|
|
1174
|
-
extra_headers: HeaderInput | None = None,
|
|
1175
|
-
timeout_seconds: float | None = None,
|
|
1176
|
-
) -> StreamOutput[api_pb2.ExecuteResponse]:
|
|
1177
|
-
"""Low-level method to call Execute, granting access to errors and metadata"""
|
|
1178
|
-
url = self.base_url + "/sandboxagent.ExecutionService/Execute"
|
|
1179
|
-
return self._connect_client.call_server_streaming(
|
|
1180
|
-
url, req, api_pb2.ExecuteResponse, extra_headers, timeout_seconds
|
|
1181
|
-
)
|
|
1182
|
-
|
|
1183
|
-
|
|
1184
|
-
class AsyncExecutionServiceClient:
|
|
1185
|
-
def __init__(
|
|
1186
|
-
self,
|
|
1187
|
-
base_url: str,
|
|
1188
|
-
http_client: aiohttp.ClientSession,
|
|
1189
|
-
protocol: ConnectProtocol = ConnectProtocol.CONNECT_PROTOBUF,
|
|
1190
|
-
):
|
|
1191
|
-
self.base_url = base_url
|
|
1192
|
-
self._connect_client = AsyncConnectClient(http_client, protocol)
|
|
1193
|
-
|
|
1194
|
-
def execute(
|
|
1195
|
-
self,
|
|
1196
|
-
req: api_pb2.ExecuteRequest,
|
|
1197
|
-
extra_headers: HeaderInput | None = None,
|
|
1198
|
-
timeout_seconds: float | None = None,
|
|
1199
|
-
) -> AsyncIterator[api_pb2.ExecuteResponse]:
|
|
1200
|
-
return self._execute_iterator(req, extra_headers, timeout_seconds)
|
|
1201
|
-
|
|
1202
|
-
async def _execute_iterator(
|
|
1203
|
-
self,
|
|
1204
|
-
req: api_pb2.ExecuteRequest,
|
|
1205
|
-
extra_headers: HeaderInput | None = None,
|
|
1206
|
-
timeout_seconds: float | None = None,
|
|
1207
|
-
) -> AsyncIterator[api_pb2.ExecuteResponse]:
|
|
1208
|
-
stream_output = await self.call_execute(req, extra_headers)
|
|
1209
|
-
err = stream_output.error()
|
|
1210
|
-
if err is not None:
|
|
1211
|
-
raise err
|
|
1212
|
-
async with stream_output as stream:
|
|
1213
|
-
async for response in stream:
|
|
1214
|
-
yield response
|
|
1215
|
-
err = stream.error()
|
|
1216
|
-
if err is not None:
|
|
1217
|
-
raise err
|
|
1218
|
-
|
|
1219
|
-
async def call_execute(
|
|
1220
|
-
self,
|
|
1221
|
-
req: api_pb2.ExecuteRequest,
|
|
1222
|
-
extra_headers: HeaderInput | None = None,
|
|
1223
|
-
timeout_seconds: float | None = None,
|
|
1224
|
-
) -> AsyncStreamOutput[api_pb2.ExecuteResponse]:
|
|
1225
|
-
"""Low-level method to call Execute, granting access to errors and metadata"""
|
|
1226
|
-
url = self.base_url + "/sandboxagent.ExecutionService/Execute"
|
|
1227
|
-
return await self._connect_client.call_server_streaming(
|
|
1228
|
-
url, req, api_pb2.ExecuteResponse, extra_headers, timeout_seconds
|
|
1229
|
-
)
|
|
1230
|
-
|
|
1231
|
-
|
|
1232
|
-
@typing.runtime_checkable
|
|
1233
|
-
class ExecutionServiceProtocol(typing.Protocol):
|
|
1234
|
-
def execute(
|
|
1235
|
-
self, req: ClientRequest[api_pb2.ExecuteRequest]
|
|
1236
|
-
) -> ServerStream[api_pb2.ExecuteResponse]: ...
|
|
1237
|
-
|
|
1238
|
-
|
|
1239
|
-
EXECUTION_SERVICE_PATH_PREFIX = "/sandboxagent.ExecutionService"
|
|
1240
|
-
|
|
1241
|
-
|
|
1242
|
-
def wsgi_execution_service(implementation: ExecutionServiceProtocol) -> WSGIApplication:
|
|
1243
|
-
app = ConnectWSGI()
|
|
1244
|
-
app.register_server_streaming_rpc(
|
|
1245
|
-
"/sandboxagent.ExecutionService/Execute",
|
|
1246
|
-
implementation.execute,
|
|
1247
|
-
api_pb2.ExecuteRequest,
|
|
1248
|
-
)
|
|
1249
|
-
return app
|
|
1250
|
-
|
|
1251
|
-
|
|
1252
|
-
class ContextServiceClient:
|
|
1253
|
-
def __init__(
|
|
1254
|
-
self,
|
|
1255
|
-
base_url: str,
|
|
1256
|
-
http_client: urllib3.PoolManager | None = None,
|
|
1257
|
-
protocol: ConnectProtocol = ConnectProtocol.CONNECT_PROTOBUF,
|
|
1258
|
-
):
|
|
1259
|
-
self.base_url = base_url
|
|
1260
|
-
self._connect_client = ConnectClient(http_client, protocol)
|
|
1261
|
-
|
|
1262
|
-
def call_create_context(
|
|
1263
|
-
self,
|
|
1264
|
-
req: api_pb2.CreateContextRequest,
|
|
1265
|
-
extra_headers: HeaderInput | None = None,
|
|
1266
|
-
timeout_seconds: float | None = None,
|
|
1267
|
-
) -> UnaryOutput[api_pb2.Context]:
|
|
1268
|
-
"""Low-level method to call CreateContext, granting access to errors and metadata"""
|
|
1269
|
-
url = self.base_url + "/sandboxagent.ContextService/CreateContext"
|
|
1270
|
-
return self._connect_client.call_unary(
|
|
1271
|
-
url, req, api_pb2.Context, extra_headers, timeout_seconds
|
|
1272
|
-
)
|
|
1273
|
-
|
|
1274
|
-
def create_context(
|
|
1275
|
-
self,
|
|
1276
|
-
req: api_pb2.CreateContextRequest,
|
|
1277
|
-
extra_headers: HeaderInput | None = None,
|
|
1278
|
-
timeout_seconds: float | None = None,
|
|
1279
|
-
) -> api_pb2.Context:
|
|
1280
|
-
response = self.call_create_context(req, extra_headers, timeout_seconds)
|
|
1281
|
-
err = response.error()
|
|
1282
|
-
if err is not None:
|
|
1283
|
-
raise err
|
|
1284
|
-
msg = response.message()
|
|
1285
|
-
if msg is None:
|
|
1286
|
-
raise ConnectProtocolError("missing response message")
|
|
1287
|
-
return msg
|
|
1288
|
-
|
|
1289
|
-
def call_destroy_context(
|
|
1290
|
-
self,
|
|
1291
|
-
req: api_pb2.DestroyContextRequest,
|
|
1292
|
-
extra_headers: HeaderInput | None = None,
|
|
1293
|
-
timeout_seconds: float | None = None,
|
|
1294
|
-
) -> UnaryOutput[api_pb2.DestroyContextResponse]:
|
|
1295
|
-
"""Low-level method to call DestroyContext, granting access to errors and metadata"""
|
|
1296
|
-
url = self.base_url + "/sandboxagent.ContextService/DestroyContext"
|
|
1297
|
-
return self._connect_client.call_unary(
|
|
1298
|
-
url, req, api_pb2.DestroyContextResponse, extra_headers, timeout_seconds
|
|
1299
|
-
)
|
|
1300
|
-
|
|
1301
|
-
def destroy_context(
|
|
1302
|
-
self,
|
|
1303
|
-
req: api_pb2.DestroyContextRequest,
|
|
1304
|
-
extra_headers: HeaderInput | None = None,
|
|
1305
|
-
timeout_seconds: float | None = None,
|
|
1306
|
-
) -> api_pb2.DestroyContextResponse:
|
|
1307
|
-
response = self.call_destroy_context(req, extra_headers, timeout_seconds)
|
|
1308
|
-
err = response.error()
|
|
1309
|
-
if err is not None:
|
|
1310
|
-
raise err
|
|
1311
|
-
msg = response.message()
|
|
1312
|
-
if msg is None:
|
|
1313
|
-
raise ConnectProtocolError("missing response message")
|
|
1314
|
-
return msg
|
|
1315
|
-
|
|
1316
|
-
|
|
1317
|
-
class AsyncContextServiceClient:
|
|
1318
|
-
def __init__(
|
|
1319
|
-
self,
|
|
1320
|
-
base_url: str,
|
|
1321
|
-
http_client: aiohttp.ClientSession,
|
|
1322
|
-
protocol: ConnectProtocol = ConnectProtocol.CONNECT_PROTOBUF,
|
|
1323
|
-
):
|
|
1324
|
-
self.base_url = base_url
|
|
1325
|
-
self._connect_client = AsyncConnectClient(http_client, protocol)
|
|
1326
|
-
|
|
1327
|
-
async def call_create_context(
|
|
1328
|
-
self,
|
|
1329
|
-
req: api_pb2.CreateContextRequest,
|
|
1330
|
-
extra_headers: HeaderInput | None = None,
|
|
1331
|
-
timeout_seconds: float | None = None,
|
|
1332
|
-
) -> UnaryOutput[api_pb2.Context]:
|
|
1333
|
-
"""Low-level method to call CreateContext, granting access to errors and metadata"""
|
|
1334
|
-
url = self.base_url + "/sandboxagent.ContextService/CreateContext"
|
|
1335
|
-
return await self._connect_client.call_unary(
|
|
1336
|
-
url, req, api_pb2.Context, extra_headers, timeout_seconds
|
|
1337
|
-
)
|
|
1338
|
-
|
|
1339
|
-
async def create_context(
|
|
1340
|
-
self,
|
|
1341
|
-
req: api_pb2.CreateContextRequest,
|
|
1342
|
-
extra_headers: HeaderInput | None = None,
|
|
1343
|
-
timeout_seconds: float | None = None,
|
|
1344
|
-
) -> api_pb2.Context:
|
|
1345
|
-
response = await self.call_create_context(req, extra_headers, timeout_seconds)
|
|
1346
|
-
err = response.error()
|
|
1347
|
-
if err is not None:
|
|
1348
|
-
raise err
|
|
1349
|
-
msg = response.message()
|
|
1350
|
-
if msg is None:
|
|
1351
|
-
raise ConnectProtocolError("missing response message")
|
|
1352
|
-
return msg
|
|
1353
|
-
|
|
1354
|
-
async def call_destroy_context(
|
|
1355
|
-
self,
|
|
1356
|
-
req: api_pb2.DestroyContextRequest,
|
|
1357
|
-
extra_headers: HeaderInput | None = None,
|
|
1358
|
-
timeout_seconds: float | None = None,
|
|
1359
|
-
) -> UnaryOutput[api_pb2.DestroyContextResponse]:
|
|
1360
|
-
"""Low-level method to call DestroyContext, granting access to errors and metadata"""
|
|
1361
|
-
url = self.base_url + "/sandboxagent.ContextService/DestroyContext"
|
|
1362
|
-
return await self._connect_client.call_unary(
|
|
1363
|
-
url, req, api_pb2.DestroyContextResponse, extra_headers, timeout_seconds
|
|
1364
|
-
)
|
|
1365
|
-
|
|
1366
|
-
async def destroy_context(
|
|
1367
|
-
self,
|
|
1368
|
-
req: api_pb2.DestroyContextRequest,
|
|
1369
|
-
extra_headers: HeaderInput | None = None,
|
|
1370
|
-
timeout_seconds: float | None = None,
|
|
1371
|
-
) -> api_pb2.DestroyContextResponse:
|
|
1372
|
-
response = await self.call_destroy_context(req, extra_headers, timeout_seconds)
|
|
1373
|
-
err = response.error()
|
|
1374
|
-
if err is not None:
|
|
1375
|
-
raise err
|
|
1376
|
-
msg = response.message()
|
|
1377
|
-
if msg is None:
|
|
1378
|
-
raise ConnectProtocolError("missing response message")
|
|
1379
|
-
return msg
|
|
1380
|
-
|
|
1381
|
-
|
|
1382
|
-
@typing.runtime_checkable
|
|
1383
|
-
class ContextServiceProtocol(typing.Protocol):
|
|
1384
|
-
def create_context(
|
|
1385
|
-
self, req: ClientRequest[api_pb2.CreateContextRequest]
|
|
1386
|
-
) -> ServerResponse[api_pb2.Context]: ...
|
|
1387
|
-
def destroy_context(
|
|
1388
|
-
self, req: ClientRequest[api_pb2.DestroyContextRequest]
|
|
1389
|
-
) -> ServerResponse[api_pb2.DestroyContextResponse]: ...
|
|
1390
|
-
|
|
1391
|
-
|
|
1392
|
-
CONTEXT_SERVICE_PATH_PREFIX = "/sandboxagent.ContextService"
|
|
1393
|
-
|
|
1394
|
-
|
|
1395
|
-
def wsgi_context_service(implementation: ContextServiceProtocol) -> WSGIApplication:
|
|
1396
|
-
app = ConnectWSGI()
|
|
1397
|
-
app.register_unary_rpc(
|
|
1398
|
-
"/sandboxagent.ContextService/CreateContext",
|
|
1399
|
-
implementation.create_context,
|
|
1400
|
-
api_pb2.CreateContextRequest,
|
|
1401
|
-
)
|
|
1402
|
-
app.register_unary_rpc(
|
|
1403
|
-
"/sandboxagent.ContextService/DestroyContext",
|
|
1404
|
-
implementation.destroy_context,
|
|
1405
|
-
api_pb2.DestroyContextRequest,
|
|
1406
|
-
)
|
|
1407
|
-
return app
|
|
1
|
+
# Generated Connect client code
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
import sys
|
|
6
|
+
import typing
|
|
7
|
+
from collections.abc import AsyncIterator, Iterable, Iterator
|
|
8
|
+
|
|
9
|
+
import aiohttp
|
|
10
|
+
import urllib3
|
|
11
|
+
from connectrpc.client_async import AsyncConnectClient
|
|
12
|
+
from connectrpc.client_connect import ConnectProtocolError
|
|
13
|
+
from connectrpc.client_protocol import ConnectProtocol
|
|
14
|
+
from connectrpc.client_sync import ConnectClient
|
|
15
|
+
from connectrpc.headers import HeaderInput
|
|
16
|
+
from connectrpc.server import (
|
|
17
|
+
ClientRequest,
|
|
18
|
+
ClientStream,
|
|
19
|
+
ServerResponse,
|
|
20
|
+
ServerStream,
|
|
21
|
+
)
|
|
22
|
+
from connectrpc.server_sync import ConnectWSGI
|
|
23
|
+
from connectrpc.streams import AsyncStreamOutput, StreamInput, StreamOutput
|
|
24
|
+
from connectrpc.unary import ClientStreamingOutput, UnaryOutput
|
|
25
|
+
|
|
26
|
+
if typing.TYPE_CHECKING:
|
|
27
|
+
# wsgiref.types was added in Python 3.11.
|
|
28
|
+
if sys.version_info >= (3, 11):
|
|
29
|
+
from wsgiref.types import WSGIApplication
|
|
30
|
+
else:
|
|
31
|
+
from _typeshed.wsgi import WSGIApplication
|
|
32
|
+
|
|
33
|
+
from . import api_pb2
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
class FilesystemClient:
|
|
37
|
+
def __init__(
|
|
38
|
+
self,
|
|
39
|
+
base_url: str,
|
|
40
|
+
http_client: urllib3.PoolManager | None = None,
|
|
41
|
+
protocol: ConnectProtocol = ConnectProtocol.CONNECT_PROTOBUF,
|
|
42
|
+
):
|
|
43
|
+
self.base_url = base_url
|
|
44
|
+
self._connect_client = ConnectClient(http_client, protocol)
|
|
45
|
+
|
|
46
|
+
def call_stat(
|
|
47
|
+
self,
|
|
48
|
+
req: api_pb2.StatRequest,
|
|
49
|
+
extra_headers: HeaderInput | None = None,
|
|
50
|
+
timeout_seconds: float | None = None,
|
|
51
|
+
) -> UnaryOutput[api_pb2.StatResponse]:
|
|
52
|
+
"""Low-level method to call Stat, granting access to errors and metadata"""
|
|
53
|
+
url = self.base_url + "/sandboxagent.Filesystem/Stat"
|
|
54
|
+
return self._connect_client.call_unary(
|
|
55
|
+
url, req, api_pb2.StatResponse, extra_headers, timeout_seconds
|
|
56
|
+
)
|
|
57
|
+
|
|
58
|
+
def stat(
|
|
59
|
+
self,
|
|
60
|
+
req: api_pb2.StatRequest,
|
|
61
|
+
extra_headers: HeaderInput | None = None,
|
|
62
|
+
timeout_seconds: float | None = None,
|
|
63
|
+
) -> api_pb2.StatResponse:
|
|
64
|
+
response = self.call_stat(req, extra_headers, timeout_seconds)
|
|
65
|
+
err = response.error()
|
|
66
|
+
if err is not None:
|
|
67
|
+
raise err
|
|
68
|
+
msg = response.message()
|
|
69
|
+
if msg is None:
|
|
70
|
+
raise ConnectProtocolError("missing response message")
|
|
71
|
+
return msg
|
|
72
|
+
|
|
73
|
+
def call_make_dir(
|
|
74
|
+
self,
|
|
75
|
+
req: api_pb2.MakeDirRequest,
|
|
76
|
+
extra_headers: HeaderInput | None = None,
|
|
77
|
+
timeout_seconds: float | None = None,
|
|
78
|
+
) -> UnaryOutput[api_pb2.MakeDirResponse]:
|
|
79
|
+
"""Low-level method to call MakeDir, granting access to errors and metadata"""
|
|
80
|
+
url = self.base_url + "/sandboxagent.Filesystem/MakeDir"
|
|
81
|
+
return self._connect_client.call_unary(
|
|
82
|
+
url, req, api_pb2.MakeDirResponse, extra_headers, timeout_seconds
|
|
83
|
+
)
|
|
84
|
+
|
|
85
|
+
def make_dir(
|
|
86
|
+
self,
|
|
87
|
+
req: api_pb2.MakeDirRequest,
|
|
88
|
+
extra_headers: HeaderInput | None = None,
|
|
89
|
+
timeout_seconds: float | None = None,
|
|
90
|
+
) -> api_pb2.MakeDirResponse:
|
|
91
|
+
response = self.call_make_dir(req, extra_headers, timeout_seconds)
|
|
92
|
+
err = response.error()
|
|
93
|
+
if err is not None:
|
|
94
|
+
raise err
|
|
95
|
+
msg = response.message()
|
|
96
|
+
if msg is None:
|
|
97
|
+
raise ConnectProtocolError("missing response message")
|
|
98
|
+
return msg
|
|
99
|
+
|
|
100
|
+
def call_move(
|
|
101
|
+
self,
|
|
102
|
+
req: api_pb2.MoveRequest,
|
|
103
|
+
extra_headers: HeaderInput | None = None,
|
|
104
|
+
timeout_seconds: float | None = None,
|
|
105
|
+
) -> UnaryOutput[api_pb2.MoveResponse]:
|
|
106
|
+
"""Low-level method to call Move, granting access to errors and metadata"""
|
|
107
|
+
url = self.base_url + "/sandboxagent.Filesystem/Move"
|
|
108
|
+
return self._connect_client.call_unary(
|
|
109
|
+
url, req, api_pb2.MoveResponse, extra_headers, timeout_seconds
|
|
110
|
+
)
|
|
111
|
+
|
|
112
|
+
def move(
|
|
113
|
+
self,
|
|
114
|
+
req: api_pb2.MoveRequest,
|
|
115
|
+
extra_headers: HeaderInput | None = None,
|
|
116
|
+
timeout_seconds: float | None = None,
|
|
117
|
+
) -> api_pb2.MoveResponse:
|
|
118
|
+
response = self.call_move(req, extra_headers, timeout_seconds)
|
|
119
|
+
err = response.error()
|
|
120
|
+
if err is not None:
|
|
121
|
+
raise err
|
|
122
|
+
msg = response.message()
|
|
123
|
+
if msg is None:
|
|
124
|
+
raise ConnectProtocolError("missing response message")
|
|
125
|
+
return msg
|
|
126
|
+
|
|
127
|
+
def call_list_dir(
|
|
128
|
+
self,
|
|
129
|
+
req: api_pb2.ListDirRequest,
|
|
130
|
+
extra_headers: HeaderInput | None = None,
|
|
131
|
+
timeout_seconds: float | None = None,
|
|
132
|
+
) -> UnaryOutput[api_pb2.ListDirResponse]:
|
|
133
|
+
"""Low-level method to call ListDir, granting access to errors and metadata"""
|
|
134
|
+
url = self.base_url + "/sandboxagent.Filesystem/ListDir"
|
|
135
|
+
return self._connect_client.call_unary(
|
|
136
|
+
url, req, api_pb2.ListDirResponse, extra_headers, timeout_seconds
|
|
137
|
+
)
|
|
138
|
+
|
|
139
|
+
def list_dir(
|
|
140
|
+
self,
|
|
141
|
+
req: api_pb2.ListDirRequest,
|
|
142
|
+
extra_headers: HeaderInput | None = None,
|
|
143
|
+
timeout_seconds: float | None = None,
|
|
144
|
+
) -> api_pb2.ListDirResponse:
|
|
145
|
+
response = self.call_list_dir(req, extra_headers, timeout_seconds)
|
|
146
|
+
err = response.error()
|
|
147
|
+
if err is not None:
|
|
148
|
+
raise err
|
|
149
|
+
msg = response.message()
|
|
150
|
+
if msg is None:
|
|
151
|
+
raise ConnectProtocolError("missing response message")
|
|
152
|
+
return msg
|
|
153
|
+
|
|
154
|
+
def call_remove(
|
|
155
|
+
self,
|
|
156
|
+
req: api_pb2.RemoveRequest,
|
|
157
|
+
extra_headers: HeaderInput | None = None,
|
|
158
|
+
timeout_seconds: float | None = None,
|
|
159
|
+
) -> UnaryOutput[api_pb2.RemoveResponse]:
|
|
160
|
+
"""Low-level method to call Remove, granting access to errors and metadata"""
|
|
161
|
+
url = self.base_url + "/sandboxagent.Filesystem/Remove"
|
|
162
|
+
return self._connect_client.call_unary(
|
|
163
|
+
url, req, api_pb2.RemoveResponse, extra_headers, timeout_seconds
|
|
164
|
+
)
|
|
165
|
+
|
|
166
|
+
def remove(
|
|
167
|
+
self,
|
|
168
|
+
req: api_pb2.RemoveRequest,
|
|
169
|
+
extra_headers: HeaderInput | None = None,
|
|
170
|
+
timeout_seconds: float | None = None,
|
|
171
|
+
) -> api_pb2.RemoveResponse:
|
|
172
|
+
response = self.call_remove(req, extra_headers, timeout_seconds)
|
|
173
|
+
err = response.error()
|
|
174
|
+
if err is not None:
|
|
175
|
+
raise err
|
|
176
|
+
msg = response.message()
|
|
177
|
+
if msg is None:
|
|
178
|
+
raise ConnectProtocolError("missing response message")
|
|
179
|
+
return msg
|
|
180
|
+
|
|
181
|
+
def watch_dir(
|
|
182
|
+
self,
|
|
183
|
+
req: api_pb2.WatchDirRequest,
|
|
184
|
+
extra_headers: HeaderInput | None = None,
|
|
185
|
+
timeout_seconds: float | None = None,
|
|
186
|
+
) -> Iterator[api_pb2.WatchDirResponse]:
|
|
187
|
+
return self._watch_dir_iterator(req, extra_headers, timeout_seconds)
|
|
188
|
+
|
|
189
|
+
def _watch_dir_iterator(
|
|
190
|
+
self,
|
|
191
|
+
req: api_pb2.WatchDirRequest,
|
|
192
|
+
extra_headers: HeaderInput | None = None,
|
|
193
|
+
timeout_seconds: float | None = None,
|
|
194
|
+
) -> Iterator[api_pb2.WatchDirResponse]:
|
|
195
|
+
stream_output = self.call_watch_dir(req, extra_headers)
|
|
196
|
+
err = stream_output.error()
|
|
197
|
+
if err is not None:
|
|
198
|
+
raise err
|
|
199
|
+
yield from stream_output
|
|
200
|
+
err = stream_output.error()
|
|
201
|
+
if err is not None:
|
|
202
|
+
raise err
|
|
203
|
+
|
|
204
|
+
def call_watch_dir(
|
|
205
|
+
self,
|
|
206
|
+
req: api_pb2.WatchDirRequest,
|
|
207
|
+
extra_headers: HeaderInput | None = None,
|
|
208
|
+
timeout_seconds: float | None = None,
|
|
209
|
+
) -> StreamOutput[api_pb2.WatchDirResponse]:
|
|
210
|
+
"""Low-level method to call WatchDir, granting access to errors and metadata"""
|
|
211
|
+
url = self.base_url + "/sandboxagent.Filesystem/WatchDir"
|
|
212
|
+
return self._connect_client.call_server_streaming(
|
|
213
|
+
url, req, api_pb2.WatchDirResponse, extra_headers, timeout_seconds
|
|
214
|
+
)
|
|
215
|
+
|
|
216
|
+
def call_create_watcher(
|
|
217
|
+
self,
|
|
218
|
+
req: api_pb2.CreateWatcherRequest,
|
|
219
|
+
extra_headers: HeaderInput | None = None,
|
|
220
|
+
timeout_seconds: float | None = None,
|
|
221
|
+
) -> UnaryOutput[api_pb2.CreateWatcherResponse]:
|
|
222
|
+
"""Low-level method to call CreateWatcher, granting access to errors and metadata"""
|
|
223
|
+
url = self.base_url + "/sandboxagent.Filesystem/CreateWatcher"
|
|
224
|
+
return self._connect_client.call_unary(
|
|
225
|
+
url, req, api_pb2.CreateWatcherResponse, extra_headers, timeout_seconds
|
|
226
|
+
)
|
|
227
|
+
|
|
228
|
+
def create_watcher(
|
|
229
|
+
self,
|
|
230
|
+
req: api_pb2.CreateWatcherRequest,
|
|
231
|
+
extra_headers: HeaderInput | None = None,
|
|
232
|
+
timeout_seconds: float | None = None,
|
|
233
|
+
) -> api_pb2.CreateWatcherResponse:
|
|
234
|
+
response = self.call_create_watcher(req, extra_headers, timeout_seconds)
|
|
235
|
+
err = response.error()
|
|
236
|
+
if err is not None:
|
|
237
|
+
raise err
|
|
238
|
+
msg = response.message()
|
|
239
|
+
if msg is None:
|
|
240
|
+
raise ConnectProtocolError("missing response message")
|
|
241
|
+
return msg
|
|
242
|
+
|
|
243
|
+
def call_get_watcher_events(
|
|
244
|
+
self,
|
|
245
|
+
req: api_pb2.GetWatcherEventsRequest,
|
|
246
|
+
extra_headers: HeaderInput | None = None,
|
|
247
|
+
timeout_seconds: float | None = None,
|
|
248
|
+
) -> UnaryOutput[api_pb2.GetWatcherEventsResponse]:
|
|
249
|
+
"""Low-level method to call GetWatcherEvents, granting access to errors and metadata"""
|
|
250
|
+
url = self.base_url + "/sandboxagent.Filesystem/GetWatcherEvents"
|
|
251
|
+
return self._connect_client.call_unary(
|
|
252
|
+
url, req, api_pb2.GetWatcherEventsResponse, extra_headers, timeout_seconds
|
|
253
|
+
)
|
|
254
|
+
|
|
255
|
+
def get_watcher_events(
|
|
256
|
+
self,
|
|
257
|
+
req: api_pb2.GetWatcherEventsRequest,
|
|
258
|
+
extra_headers: HeaderInput | None = None,
|
|
259
|
+
timeout_seconds: float | None = None,
|
|
260
|
+
) -> api_pb2.GetWatcherEventsResponse:
|
|
261
|
+
response = self.call_get_watcher_events(req, extra_headers, timeout_seconds)
|
|
262
|
+
err = response.error()
|
|
263
|
+
if err is not None:
|
|
264
|
+
raise err
|
|
265
|
+
msg = response.message()
|
|
266
|
+
if msg is None:
|
|
267
|
+
raise ConnectProtocolError("missing response message")
|
|
268
|
+
return msg
|
|
269
|
+
|
|
270
|
+
def call_remove_watcher(
|
|
271
|
+
self,
|
|
272
|
+
req: api_pb2.RemoveWatcherRequest,
|
|
273
|
+
extra_headers: HeaderInput | None = None,
|
|
274
|
+
timeout_seconds: float | None = None,
|
|
275
|
+
) -> UnaryOutput[api_pb2.RemoveWatcherResponse]:
|
|
276
|
+
"""Low-level method to call RemoveWatcher, granting access to errors and metadata"""
|
|
277
|
+
url = self.base_url + "/sandboxagent.Filesystem/RemoveWatcher"
|
|
278
|
+
return self._connect_client.call_unary(
|
|
279
|
+
url, req, api_pb2.RemoveWatcherResponse, extra_headers, timeout_seconds
|
|
280
|
+
)
|
|
281
|
+
|
|
282
|
+
def remove_watcher(
|
|
283
|
+
self,
|
|
284
|
+
req: api_pb2.RemoveWatcherRequest,
|
|
285
|
+
extra_headers: HeaderInput | None = None,
|
|
286
|
+
timeout_seconds: float | None = None,
|
|
287
|
+
) -> api_pb2.RemoveWatcherResponse:
|
|
288
|
+
response = self.call_remove_watcher(req, extra_headers, timeout_seconds)
|
|
289
|
+
err = response.error()
|
|
290
|
+
if err is not None:
|
|
291
|
+
raise err
|
|
292
|
+
msg = response.message()
|
|
293
|
+
if msg is None:
|
|
294
|
+
raise ConnectProtocolError("missing response message")
|
|
295
|
+
return msg
|
|
296
|
+
|
|
297
|
+
|
|
298
|
+
class AsyncFilesystemClient:
|
|
299
|
+
def __init__(
|
|
300
|
+
self,
|
|
301
|
+
base_url: str,
|
|
302
|
+
http_client: aiohttp.ClientSession,
|
|
303
|
+
protocol: ConnectProtocol = ConnectProtocol.CONNECT_PROTOBUF,
|
|
304
|
+
):
|
|
305
|
+
self.base_url = base_url
|
|
306
|
+
self._connect_client = AsyncConnectClient(http_client, protocol)
|
|
307
|
+
|
|
308
|
+
async def call_stat(
|
|
309
|
+
self,
|
|
310
|
+
req: api_pb2.StatRequest,
|
|
311
|
+
extra_headers: HeaderInput | None = None,
|
|
312
|
+
timeout_seconds: float | None = None,
|
|
313
|
+
) -> UnaryOutput[api_pb2.StatResponse]:
|
|
314
|
+
"""Low-level method to call Stat, granting access to errors and metadata"""
|
|
315
|
+
url = self.base_url + "/sandboxagent.Filesystem/Stat"
|
|
316
|
+
return await self._connect_client.call_unary(
|
|
317
|
+
url, req, api_pb2.StatResponse, extra_headers, timeout_seconds
|
|
318
|
+
)
|
|
319
|
+
|
|
320
|
+
async def stat(
|
|
321
|
+
self,
|
|
322
|
+
req: api_pb2.StatRequest,
|
|
323
|
+
extra_headers: HeaderInput | None = None,
|
|
324
|
+
timeout_seconds: float | None = None,
|
|
325
|
+
) -> api_pb2.StatResponse:
|
|
326
|
+
response = await self.call_stat(req, extra_headers, timeout_seconds)
|
|
327
|
+
err = response.error()
|
|
328
|
+
if err is not None:
|
|
329
|
+
raise err
|
|
330
|
+
msg = response.message()
|
|
331
|
+
if msg is None:
|
|
332
|
+
raise ConnectProtocolError("missing response message")
|
|
333
|
+
return msg
|
|
334
|
+
|
|
335
|
+
async def call_make_dir(
|
|
336
|
+
self,
|
|
337
|
+
req: api_pb2.MakeDirRequest,
|
|
338
|
+
extra_headers: HeaderInput | None = None,
|
|
339
|
+
timeout_seconds: float | None = None,
|
|
340
|
+
) -> UnaryOutput[api_pb2.MakeDirResponse]:
|
|
341
|
+
"""Low-level method to call MakeDir, granting access to errors and metadata"""
|
|
342
|
+
url = self.base_url + "/sandboxagent.Filesystem/MakeDir"
|
|
343
|
+
return await self._connect_client.call_unary(
|
|
344
|
+
url, req, api_pb2.MakeDirResponse, extra_headers, timeout_seconds
|
|
345
|
+
)
|
|
346
|
+
|
|
347
|
+
async def make_dir(
|
|
348
|
+
self,
|
|
349
|
+
req: api_pb2.MakeDirRequest,
|
|
350
|
+
extra_headers: HeaderInput | None = None,
|
|
351
|
+
timeout_seconds: float | None = None,
|
|
352
|
+
) -> api_pb2.MakeDirResponse:
|
|
353
|
+
response = await self.call_make_dir(req, extra_headers, timeout_seconds)
|
|
354
|
+
err = response.error()
|
|
355
|
+
if err is not None:
|
|
356
|
+
raise err
|
|
357
|
+
msg = response.message()
|
|
358
|
+
if msg is None:
|
|
359
|
+
raise ConnectProtocolError("missing response message")
|
|
360
|
+
return msg
|
|
361
|
+
|
|
362
|
+
async def call_move(
|
|
363
|
+
self,
|
|
364
|
+
req: api_pb2.MoveRequest,
|
|
365
|
+
extra_headers: HeaderInput | None = None,
|
|
366
|
+
timeout_seconds: float | None = None,
|
|
367
|
+
) -> UnaryOutput[api_pb2.MoveResponse]:
|
|
368
|
+
"""Low-level method to call Move, granting access to errors and metadata"""
|
|
369
|
+
url = self.base_url + "/sandboxagent.Filesystem/Move"
|
|
370
|
+
return await self._connect_client.call_unary(
|
|
371
|
+
url, req, api_pb2.MoveResponse, extra_headers, timeout_seconds
|
|
372
|
+
)
|
|
373
|
+
|
|
374
|
+
async def move(
|
|
375
|
+
self,
|
|
376
|
+
req: api_pb2.MoveRequest,
|
|
377
|
+
extra_headers: HeaderInput | None = None,
|
|
378
|
+
timeout_seconds: float | None = None,
|
|
379
|
+
) -> api_pb2.MoveResponse:
|
|
380
|
+
response = await self.call_move(req, extra_headers, timeout_seconds)
|
|
381
|
+
err = response.error()
|
|
382
|
+
if err is not None:
|
|
383
|
+
raise err
|
|
384
|
+
msg = response.message()
|
|
385
|
+
if msg is None:
|
|
386
|
+
raise ConnectProtocolError("missing response message")
|
|
387
|
+
return msg
|
|
388
|
+
|
|
389
|
+
async def call_list_dir(
|
|
390
|
+
self,
|
|
391
|
+
req: api_pb2.ListDirRequest,
|
|
392
|
+
extra_headers: HeaderInput | None = None,
|
|
393
|
+
timeout_seconds: float | None = None,
|
|
394
|
+
) -> UnaryOutput[api_pb2.ListDirResponse]:
|
|
395
|
+
"""Low-level method to call ListDir, granting access to errors and metadata"""
|
|
396
|
+
url = self.base_url + "/sandboxagent.Filesystem/ListDir"
|
|
397
|
+
return await self._connect_client.call_unary(
|
|
398
|
+
url, req, api_pb2.ListDirResponse, extra_headers, timeout_seconds
|
|
399
|
+
)
|
|
400
|
+
|
|
401
|
+
async def list_dir(
|
|
402
|
+
self,
|
|
403
|
+
req: api_pb2.ListDirRequest,
|
|
404
|
+
extra_headers: HeaderInput | None = None,
|
|
405
|
+
timeout_seconds: float | None = None,
|
|
406
|
+
) -> api_pb2.ListDirResponse:
|
|
407
|
+
response = await self.call_list_dir(req, extra_headers, timeout_seconds)
|
|
408
|
+
err = response.error()
|
|
409
|
+
if err is not None:
|
|
410
|
+
raise err
|
|
411
|
+
msg = response.message()
|
|
412
|
+
if msg is None:
|
|
413
|
+
raise ConnectProtocolError("missing response message")
|
|
414
|
+
return msg
|
|
415
|
+
|
|
416
|
+
async def call_remove(
|
|
417
|
+
self,
|
|
418
|
+
req: api_pb2.RemoveRequest,
|
|
419
|
+
extra_headers: HeaderInput | None = None,
|
|
420
|
+
timeout_seconds: float | None = None,
|
|
421
|
+
) -> UnaryOutput[api_pb2.RemoveResponse]:
|
|
422
|
+
"""Low-level method to call Remove, granting access to errors and metadata"""
|
|
423
|
+
url = self.base_url + "/sandboxagent.Filesystem/Remove"
|
|
424
|
+
return await self._connect_client.call_unary(
|
|
425
|
+
url, req, api_pb2.RemoveResponse, extra_headers, timeout_seconds
|
|
426
|
+
)
|
|
427
|
+
|
|
428
|
+
async def remove(
|
|
429
|
+
self,
|
|
430
|
+
req: api_pb2.RemoveRequest,
|
|
431
|
+
extra_headers: HeaderInput | None = None,
|
|
432
|
+
timeout_seconds: float | None = None,
|
|
433
|
+
) -> api_pb2.RemoveResponse:
|
|
434
|
+
response = await self.call_remove(req, extra_headers, timeout_seconds)
|
|
435
|
+
err = response.error()
|
|
436
|
+
if err is not None:
|
|
437
|
+
raise err
|
|
438
|
+
msg = response.message()
|
|
439
|
+
if msg is None:
|
|
440
|
+
raise ConnectProtocolError("missing response message")
|
|
441
|
+
return msg
|
|
442
|
+
|
|
443
|
+
def watch_dir(
|
|
444
|
+
self,
|
|
445
|
+
req: api_pb2.WatchDirRequest,
|
|
446
|
+
extra_headers: HeaderInput | None = None,
|
|
447
|
+
timeout_seconds: float | None = None,
|
|
448
|
+
) -> AsyncIterator[api_pb2.WatchDirResponse]:
|
|
449
|
+
return self._watch_dir_iterator(req, extra_headers, timeout_seconds)
|
|
450
|
+
|
|
451
|
+
async def _watch_dir_iterator(
|
|
452
|
+
self,
|
|
453
|
+
req: api_pb2.WatchDirRequest,
|
|
454
|
+
extra_headers: HeaderInput | None = None,
|
|
455
|
+
timeout_seconds: float | None = None,
|
|
456
|
+
) -> AsyncIterator[api_pb2.WatchDirResponse]:
|
|
457
|
+
stream_output = await self.call_watch_dir(req, extra_headers)
|
|
458
|
+
err = stream_output.error()
|
|
459
|
+
if err is not None:
|
|
460
|
+
raise err
|
|
461
|
+
async with stream_output as stream:
|
|
462
|
+
async for response in stream:
|
|
463
|
+
yield response
|
|
464
|
+
err = stream.error()
|
|
465
|
+
if err is not None:
|
|
466
|
+
raise err
|
|
467
|
+
|
|
468
|
+
async def call_watch_dir(
|
|
469
|
+
self,
|
|
470
|
+
req: api_pb2.WatchDirRequest,
|
|
471
|
+
extra_headers: HeaderInput | None = None,
|
|
472
|
+
timeout_seconds: float | None = None,
|
|
473
|
+
) -> AsyncStreamOutput[api_pb2.WatchDirResponse]:
|
|
474
|
+
"""Low-level method to call WatchDir, granting access to errors and metadata"""
|
|
475
|
+
url = self.base_url + "/sandboxagent.Filesystem/WatchDir"
|
|
476
|
+
return await self._connect_client.call_server_streaming(
|
|
477
|
+
url, req, api_pb2.WatchDirResponse, extra_headers, timeout_seconds
|
|
478
|
+
)
|
|
479
|
+
|
|
480
|
+
async def call_create_watcher(
|
|
481
|
+
self,
|
|
482
|
+
req: api_pb2.CreateWatcherRequest,
|
|
483
|
+
extra_headers: HeaderInput | None = None,
|
|
484
|
+
timeout_seconds: float | None = None,
|
|
485
|
+
) -> UnaryOutput[api_pb2.CreateWatcherResponse]:
|
|
486
|
+
"""Low-level method to call CreateWatcher, granting access to errors and metadata"""
|
|
487
|
+
url = self.base_url + "/sandboxagent.Filesystem/CreateWatcher"
|
|
488
|
+
return await self._connect_client.call_unary(
|
|
489
|
+
url, req, api_pb2.CreateWatcherResponse, extra_headers, timeout_seconds
|
|
490
|
+
)
|
|
491
|
+
|
|
492
|
+
async def create_watcher(
|
|
493
|
+
self,
|
|
494
|
+
req: api_pb2.CreateWatcherRequest,
|
|
495
|
+
extra_headers: HeaderInput | None = None,
|
|
496
|
+
timeout_seconds: float | None = None,
|
|
497
|
+
) -> api_pb2.CreateWatcherResponse:
|
|
498
|
+
response = await self.call_create_watcher(req, extra_headers, timeout_seconds)
|
|
499
|
+
err = response.error()
|
|
500
|
+
if err is not None:
|
|
501
|
+
raise err
|
|
502
|
+
msg = response.message()
|
|
503
|
+
if msg is None:
|
|
504
|
+
raise ConnectProtocolError("missing response message")
|
|
505
|
+
return msg
|
|
506
|
+
|
|
507
|
+
async def call_get_watcher_events(
|
|
508
|
+
self,
|
|
509
|
+
req: api_pb2.GetWatcherEventsRequest,
|
|
510
|
+
extra_headers: HeaderInput | None = None,
|
|
511
|
+
timeout_seconds: float | None = None,
|
|
512
|
+
) -> UnaryOutput[api_pb2.GetWatcherEventsResponse]:
|
|
513
|
+
"""Low-level method to call GetWatcherEvents, granting access to errors and metadata"""
|
|
514
|
+
url = self.base_url + "/sandboxagent.Filesystem/GetWatcherEvents"
|
|
515
|
+
return await self._connect_client.call_unary(
|
|
516
|
+
url, req, api_pb2.GetWatcherEventsResponse, extra_headers, timeout_seconds
|
|
517
|
+
)
|
|
518
|
+
|
|
519
|
+
async def get_watcher_events(
|
|
520
|
+
self,
|
|
521
|
+
req: api_pb2.GetWatcherEventsRequest,
|
|
522
|
+
extra_headers: HeaderInput | None = None,
|
|
523
|
+
timeout_seconds: float | None = None,
|
|
524
|
+
) -> api_pb2.GetWatcherEventsResponse:
|
|
525
|
+
response = await self.call_get_watcher_events(
|
|
526
|
+
req, extra_headers, timeout_seconds
|
|
527
|
+
)
|
|
528
|
+
err = response.error()
|
|
529
|
+
if err is not None:
|
|
530
|
+
raise err
|
|
531
|
+
msg = response.message()
|
|
532
|
+
if msg is None:
|
|
533
|
+
raise ConnectProtocolError("missing response message")
|
|
534
|
+
return msg
|
|
535
|
+
|
|
536
|
+
async def call_remove_watcher(
|
|
537
|
+
self,
|
|
538
|
+
req: api_pb2.RemoveWatcherRequest,
|
|
539
|
+
extra_headers: HeaderInput | None = None,
|
|
540
|
+
timeout_seconds: float | None = None,
|
|
541
|
+
) -> UnaryOutput[api_pb2.RemoveWatcherResponse]:
|
|
542
|
+
"""Low-level method to call RemoveWatcher, granting access to errors and metadata"""
|
|
543
|
+
url = self.base_url + "/sandboxagent.Filesystem/RemoveWatcher"
|
|
544
|
+
return await self._connect_client.call_unary(
|
|
545
|
+
url, req, api_pb2.RemoveWatcherResponse, extra_headers, timeout_seconds
|
|
546
|
+
)
|
|
547
|
+
|
|
548
|
+
async def remove_watcher(
|
|
549
|
+
self,
|
|
550
|
+
req: api_pb2.RemoveWatcherRequest,
|
|
551
|
+
extra_headers: HeaderInput | None = None,
|
|
552
|
+
timeout_seconds: float | None = None,
|
|
553
|
+
) -> api_pb2.RemoveWatcherResponse:
|
|
554
|
+
response = await self.call_remove_watcher(req, extra_headers, timeout_seconds)
|
|
555
|
+
err = response.error()
|
|
556
|
+
if err is not None:
|
|
557
|
+
raise err
|
|
558
|
+
msg = response.message()
|
|
559
|
+
if msg is None:
|
|
560
|
+
raise ConnectProtocolError("missing response message")
|
|
561
|
+
return msg
|
|
562
|
+
|
|
563
|
+
|
|
564
|
+
@typing.runtime_checkable
|
|
565
|
+
class FilesystemProtocol(typing.Protocol):
|
|
566
|
+
def stat(
|
|
567
|
+
self, req: ClientRequest[api_pb2.StatRequest]
|
|
568
|
+
) -> ServerResponse[api_pb2.StatResponse]: ...
|
|
569
|
+
def make_dir(
|
|
570
|
+
self, req: ClientRequest[api_pb2.MakeDirRequest]
|
|
571
|
+
) -> ServerResponse[api_pb2.MakeDirResponse]: ...
|
|
572
|
+
def move(
|
|
573
|
+
self, req: ClientRequest[api_pb2.MoveRequest]
|
|
574
|
+
) -> ServerResponse[api_pb2.MoveResponse]: ...
|
|
575
|
+
def list_dir(
|
|
576
|
+
self, req: ClientRequest[api_pb2.ListDirRequest]
|
|
577
|
+
) -> ServerResponse[api_pb2.ListDirResponse]: ...
|
|
578
|
+
def remove(
|
|
579
|
+
self, req: ClientRequest[api_pb2.RemoveRequest]
|
|
580
|
+
) -> ServerResponse[api_pb2.RemoveResponse]: ...
|
|
581
|
+
def watch_dir(
|
|
582
|
+
self, req: ClientRequest[api_pb2.WatchDirRequest]
|
|
583
|
+
) -> ServerStream[api_pb2.WatchDirResponse]: ...
|
|
584
|
+
def create_watcher(
|
|
585
|
+
self, req: ClientRequest[api_pb2.CreateWatcherRequest]
|
|
586
|
+
) -> ServerResponse[api_pb2.CreateWatcherResponse]: ...
|
|
587
|
+
def get_watcher_events(
|
|
588
|
+
self, req: ClientRequest[api_pb2.GetWatcherEventsRequest]
|
|
589
|
+
) -> ServerResponse[api_pb2.GetWatcherEventsResponse]: ...
|
|
590
|
+
def remove_watcher(
|
|
591
|
+
self, req: ClientRequest[api_pb2.RemoveWatcherRequest]
|
|
592
|
+
) -> ServerResponse[api_pb2.RemoveWatcherResponse]: ...
|
|
593
|
+
|
|
594
|
+
|
|
595
|
+
FILESYSTEM_PATH_PREFIX = "/sandboxagent.Filesystem"
|
|
596
|
+
|
|
597
|
+
|
|
598
|
+
def wsgi_filesystem(implementation: FilesystemProtocol) -> WSGIApplication:
|
|
599
|
+
app = ConnectWSGI()
|
|
600
|
+
app.register_unary_rpc(
|
|
601
|
+
"/sandboxagent.Filesystem/Stat", implementation.stat, api_pb2.StatRequest
|
|
602
|
+
)
|
|
603
|
+
app.register_unary_rpc(
|
|
604
|
+
"/sandboxagent.Filesystem/MakeDir",
|
|
605
|
+
implementation.make_dir,
|
|
606
|
+
api_pb2.MakeDirRequest,
|
|
607
|
+
)
|
|
608
|
+
app.register_unary_rpc(
|
|
609
|
+
"/sandboxagent.Filesystem/Move", implementation.move, api_pb2.MoveRequest
|
|
610
|
+
)
|
|
611
|
+
app.register_unary_rpc(
|
|
612
|
+
"/sandboxagent.Filesystem/ListDir",
|
|
613
|
+
implementation.list_dir,
|
|
614
|
+
api_pb2.ListDirRequest,
|
|
615
|
+
)
|
|
616
|
+
app.register_unary_rpc(
|
|
617
|
+
"/sandboxagent.Filesystem/Remove", implementation.remove, api_pb2.RemoveRequest
|
|
618
|
+
)
|
|
619
|
+
app.register_server_streaming_rpc(
|
|
620
|
+
"/sandboxagent.Filesystem/WatchDir",
|
|
621
|
+
implementation.watch_dir,
|
|
622
|
+
api_pb2.WatchDirRequest,
|
|
623
|
+
)
|
|
624
|
+
app.register_unary_rpc(
|
|
625
|
+
"/sandboxagent.Filesystem/CreateWatcher",
|
|
626
|
+
implementation.create_watcher,
|
|
627
|
+
api_pb2.CreateWatcherRequest,
|
|
628
|
+
)
|
|
629
|
+
app.register_unary_rpc(
|
|
630
|
+
"/sandboxagent.Filesystem/GetWatcherEvents",
|
|
631
|
+
implementation.get_watcher_events,
|
|
632
|
+
api_pb2.GetWatcherEventsRequest,
|
|
633
|
+
)
|
|
634
|
+
app.register_unary_rpc(
|
|
635
|
+
"/sandboxagent.Filesystem/RemoveWatcher",
|
|
636
|
+
implementation.remove_watcher,
|
|
637
|
+
api_pb2.RemoveWatcherRequest,
|
|
638
|
+
)
|
|
639
|
+
return app
|
|
640
|
+
|
|
641
|
+
|
|
642
|
+
class ProcessClient:
|
|
643
|
+
def __init__(
|
|
644
|
+
self,
|
|
645
|
+
base_url: str,
|
|
646
|
+
http_client: urllib3.PoolManager | None = None,
|
|
647
|
+
protocol: ConnectProtocol = ConnectProtocol.CONNECT_PROTOBUF,
|
|
648
|
+
):
|
|
649
|
+
self.base_url = base_url
|
|
650
|
+
self._connect_client = ConnectClient(http_client, protocol)
|
|
651
|
+
|
|
652
|
+
def call_list(
|
|
653
|
+
self,
|
|
654
|
+
req: api_pb2.ListRequest,
|
|
655
|
+
extra_headers: HeaderInput | None = None,
|
|
656
|
+
timeout_seconds: float | None = None,
|
|
657
|
+
) -> UnaryOutput[api_pb2.ListResponse]:
|
|
658
|
+
"""Low-level method to call List, granting access to errors and metadata"""
|
|
659
|
+
url = self.base_url + "/sandboxagent.Process/List"
|
|
660
|
+
return self._connect_client.call_unary(
|
|
661
|
+
url, req, api_pb2.ListResponse, extra_headers, timeout_seconds
|
|
662
|
+
)
|
|
663
|
+
|
|
664
|
+
def list(
|
|
665
|
+
self,
|
|
666
|
+
req: api_pb2.ListRequest,
|
|
667
|
+
extra_headers: HeaderInput | None = None,
|
|
668
|
+
timeout_seconds: float | None = None,
|
|
669
|
+
) -> api_pb2.ListResponse:
|
|
670
|
+
response = self.call_list(req, extra_headers, timeout_seconds)
|
|
671
|
+
err = response.error()
|
|
672
|
+
if err is not None:
|
|
673
|
+
raise err
|
|
674
|
+
msg = response.message()
|
|
675
|
+
if msg is None:
|
|
676
|
+
raise ConnectProtocolError("missing response message")
|
|
677
|
+
return msg
|
|
678
|
+
|
|
679
|
+
def connect(
|
|
680
|
+
self,
|
|
681
|
+
req: api_pb2.ConnectRequest,
|
|
682
|
+
extra_headers: HeaderInput | None = None,
|
|
683
|
+
timeout_seconds: float | None = None,
|
|
684
|
+
) -> Iterator[api_pb2.ConnectResponse]:
|
|
685
|
+
return self._connect_iterator(req, extra_headers, timeout_seconds)
|
|
686
|
+
|
|
687
|
+
def _connect_iterator(
|
|
688
|
+
self,
|
|
689
|
+
req: api_pb2.ConnectRequest,
|
|
690
|
+
extra_headers: HeaderInput | None = None,
|
|
691
|
+
timeout_seconds: float | None = None,
|
|
692
|
+
) -> Iterator[api_pb2.ConnectResponse]:
|
|
693
|
+
stream_output = self.call_connect(req, extra_headers,timeout_seconds)
|
|
694
|
+
err = stream_output.error()
|
|
695
|
+
if err is not None:
|
|
696
|
+
raise err
|
|
697
|
+
yield from stream_output
|
|
698
|
+
err = stream_output.error()
|
|
699
|
+
if err is not None:
|
|
700
|
+
raise err
|
|
701
|
+
|
|
702
|
+
def call_connect(
|
|
703
|
+
self,
|
|
704
|
+
req: api_pb2.ConnectRequest,
|
|
705
|
+
extra_headers: HeaderInput | None = None,
|
|
706
|
+
timeout_seconds: float | None = None,
|
|
707
|
+
) -> StreamOutput[api_pb2.ConnectResponse]:
|
|
708
|
+
"""Low-level method to call Connect, granting access to errors and metadata"""
|
|
709
|
+
url = self.base_url + "/sandboxagent.Process/Connect"
|
|
710
|
+
return self._connect_client.call_server_streaming(
|
|
711
|
+
url, req, api_pb2.ConnectResponse, extra_headers, timeout_seconds
|
|
712
|
+
)
|
|
713
|
+
|
|
714
|
+
def start(
|
|
715
|
+
self,
|
|
716
|
+
req: api_pb2.StartRequest,
|
|
717
|
+
extra_headers: HeaderInput | None = None,
|
|
718
|
+
timeout_seconds: float | None = None,
|
|
719
|
+
) -> Iterator[api_pb2.StartResponse]:
|
|
720
|
+
return self._start_iterator(req, extra_headers, timeout_seconds)
|
|
721
|
+
|
|
722
|
+
def _start_iterator(
|
|
723
|
+
self,
|
|
724
|
+
req: api_pb2.StartRequest,
|
|
725
|
+
extra_headers: HeaderInput | None = None,
|
|
726
|
+
timeout_seconds: float | None = None,
|
|
727
|
+
) -> Iterator[api_pb2.StartResponse]:
|
|
728
|
+
stream_output = self.call_start(req, extra_headers,timeout_seconds)
|
|
729
|
+
err = stream_output.error()
|
|
730
|
+
if err is not None:
|
|
731
|
+
raise err
|
|
732
|
+
yield from stream_output
|
|
733
|
+
err = stream_output.error()
|
|
734
|
+
if err is not None:
|
|
735
|
+
raise err
|
|
736
|
+
|
|
737
|
+
def call_start(
|
|
738
|
+
self,
|
|
739
|
+
req: api_pb2.StartRequest,
|
|
740
|
+
extra_headers: HeaderInput | None = None,
|
|
741
|
+
timeout_seconds: float | None = None,
|
|
742
|
+
) -> StreamOutput[api_pb2.StartResponse]:
|
|
743
|
+
"""Low-level method to call Start, granting access to errors and metadata"""
|
|
744
|
+
url = self.base_url + "/sandboxagent.Process/Start"
|
|
745
|
+
return self._connect_client.call_server_streaming(
|
|
746
|
+
url, req, api_pb2.StartResponse, extra_headers, timeout_seconds
|
|
747
|
+
)
|
|
748
|
+
|
|
749
|
+
def call_update(
|
|
750
|
+
self,
|
|
751
|
+
req: api_pb2.UpdateRequest,
|
|
752
|
+
extra_headers: HeaderInput | None = None,
|
|
753
|
+
timeout_seconds: float | None = None,
|
|
754
|
+
) -> UnaryOutput[api_pb2.UpdateResponse]:
|
|
755
|
+
"""Low-level method to call Update, granting access to errors and metadata"""
|
|
756
|
+
url = self.base_url + "/sandboxagent.Process/Update"
|
|
757
|
+
return self._connect_client.call_unary(
|
|
758
|
+
url, req, api_pb2.UpdateResponse, extra_headers, timeout_seconds
|
|
759
|
+
)
|
|
760
|
+
|
|
761
|
+
def update(
|
|
762
|
+
self,
|
|
763
|
+
req: api_pb2.UpdateRequest,
|
|
764
|
+
extra_headers: HeaderInput | None = None,
|
|
765
|
+
timeout_seconds: float | None = None,
|
|
766
|
+
) -> api_pb2.UpdateResponse:
|
|
767
|
+
response = self.call_update(req, extra_headers, timeout_seconds)
|
|
768
|
+
err = response.error()
|
|
769
|
+
if err is not None:
|
|
770
|
+
raise err
|
|
771
|
+
msg = response.message()
|
|
772
|
+
if msg is None:
|
|
773
|
+
raise ConnectProtocolError("missing response message")
|
|
774
|
+
return msg
|
|
775
|
+
|
|
776
|
+
def call_stream_input(
|
|
777
|
+
self,
|
|
778
|
+
reqs: Iterable[api_pb2.StreamInputRequest],
|
|
779
|
+
extra_headers: HeaderInput | None = None,
|
|
780
|
+
timeout_seconds: float | None = None,
|
|
781
|
+
) -> ClientStreamingOutput[api_pb2.StreamInputResponse]:
|
|
782
|
+
"""Low-level method to call StreamInput, granting access to errors and metadata"""
|
|
783
|
+
url = self.base_url + "/sandboxagent.Process/StreamInput"
|
|
784
|
+
return self._connect_client.call_client_streaming(
|
|
785
|
+
url, reqs, api_pb2.StreamInputResponse, extra_headers, timeout_seconds
|
|
786
|
+
)
|
|
787
|
+
|
|
788
|
+
def stream_input(
|
|
789
|
+
self,
|
|
790
|
+
reqs: Iterable[api_pb2.StreamInputRequest],
|
|
791
|
+
extra_headers: HeaderInput | None = None,
|
|
792
|
+
timeout_seconds: float | None = None,
|
|
793
|
+
) -> api_pb2.StreamInputResponse:
|
|
794
|
+
client_stream_output = self.call_stream_input(reqs, extra_headers)
|
|
795
|
+
err = client_stream_output.error()
|
|
796
|
+
if err is not None:
|
|
797
|
+
raise err
|
|
798
|
+
msg = client_stream_output.message()
|
|
799
|
+
if msg is None:
|
|
800
|
+
raise RuntimeError("ClientStreamOutput has empty error and message")
|
|
801
|
+
return msg
|
|
802
|
+
|
|
803
|
+
def call_send_input(
|
|
804
|
+
self,
|
|
805
|
+
req: api_pb2.SendInputRequest,
|
|
806
|
+
extra_headers: HeaderInput | None = None,
|
|
807
|
+
timeout_seconds: float | None = None,
|
|
808
|
+
) -> UnaryOutput[api_pb2.SendInputResponse]:
|
|
809
|
+
"""Low-level method to call SendInput, granting access to errors and metadata"""
|
|
810
|
+
url = self.base_url + "/sandboxagent.Process/SendInput"
|
|
811
|
+
return self._connect_client.call_unary(
|
|
812
|
+
url, req, api_pb2.SendInputResponse, extra_headers, timeout_seconds
|
|
813
|
+
)
|
|
814
|
+
|
|
815
|
+
def send_input(
|
|
816
|
+
self,
|
|
817
|
+
req: api_pb2.SendInputRequest,
|
|
818
|
+
extra_headers: HeaderInput | None = None,
|
|
819
|
+
timeout_seconds: float | None = None,
|
|
820
|
+
) -> api_pb2.SendInputResponse:
|
|
821
|
+
response = self.call_send_input(req, extra_headers, timeout_seconds)
|
|
822
|
+
err = response.error()
|
|
823
|
+
if err is not None:
|
|
824
|
+
raise err
|
|
825
|
+
msg = response.message()
|
|
826
|
+
if msg is None:
|
|
827
|
+
raise ConnectProtocolError("missing response message")
|
|
828
|
+
return msg
|
|
829
|
+
|
|
830
|
+
def call_send_signal(
|
|
831
|
+
self,
|
|
832
|
+
req: api_pb2.SendSignalRequest,
|
|
833
|
+
extra_headers: HeaderInput | None = None,
|
|
834
|
+
timeout_seconds: float | None = None,
|
|
835
|
+
) -> UnaryOutput[api_pb2.SendSignalResponse]:
|
|
836
|
+
"""Low-level method to call SendSignal, granting access to errors and metadata"""
|
|
837
|
+
url = self.base_url + "/sandboxagent.Process/SendSignal"
|
|
838
|
+
return self._connect_client.call_unary(
|
|
839
|
+
url, req, api_pb2.SendSignalResponse, extra_headers, timeout_seconds
|
|
840
|
+
)
|
|
841
|
+
|
|
842
|
+
def send_signal(
|
|
843
|
+
self,
|
|
844
|
+
req: api_pb2.SendSignalRequest,
|
|
845
|
+
extra_headers: HeaderInput | None = None,
|
|
846
|
+
timeout_seconds: float | None = None,
|
|
847
|
+
) -> api_pb2.SendSignalResponse:
|
|
848
|
+
response = self.call_send_signal(req, extra_headers, timeout_seconds)
|
|
849
|
+
err = response.error()
|
|
850
|
+
if err is not None:
|
|
851
|
+
raise err
|
|
852
|
+
msg = response.message()
|
|
853
|
+
if msg is None:
|
|
854
|
+
raise ConnectProtocolError("missing response message")
|
|
855
|
+
return msg
|
|
856
|
+
|
|
857
|
+
|
|
858
|
+
class AsyncProcessClient:
|
|
859
|
+
def __init__(
|
|
860
|
+
self,
|
|
861
|
+
base_url: str,
|
|
862
|
+
http_client: aiohttp.ClientSession,
|
|
863
|
+
protocol: ConnectProtocol = ConnectProtocol.CONNECT_PROTOBUF,
|
|
864
|
+
):
|
|
865
|
+
self.base_url = base_url
|
|
866
|
+
self._connect_client = AsyncConnectClient(http_client, protocol)
|
|
867
|
+
|
|
868
|
+
async def call_list(
|
|
869
|
+
self,
|
|
870
|
+
req: api_pb2.ListRequest,
|
|
871
|
+
extra_headers: HeaderInput | None = None,
|
|
872
|
+
timeout_seconds: float | None = None,
|
|
873
|
+
) -> UnaryOutput[api_pb2.ListResponse]:
|
|
874
|
+
"""Low-level method to call List, granting access to errors and metadata"""
|
|
875
|
+
url = self.base_url + "/sandboxagent.Process/List"
|
|
876
|
+
return await self._connect_client.call_unary(
|
|
877
|
+
url, req, api_pb2.ListResponse, extra_headers, timeout_seconds
|
|
878
|
+
)
|
|
879
|
+
|
|
880
|
+
async def list(
|
|
881
|
+
self,
|
|
882
|
+
req: api_pb2.ListRequest,
|
|
883
|
+
extra_headers: HeaderInput | None = None,
|
|
884
|
+
timeout_seconds: float | None = None,
|
|
885
|
+
) -> api_pb2.ListResponse:
|
|
886
|
+
response = await self.call_list(req, extra_headers, timeout_seconds)
|
|
887
|
+
err = response.error()
|
|
888
|
+
if err is not None:
|
|
889
|
+
raise err
|
|
890
|
+
msg = response.message()
|
|
891
|
+
if msg is None:
|
|
892
|
+
raise ConnectProtocolError("missing response message")
|
|
893
|
+
return msg
|
|
894
|
+
|
|
895
|
+
def connect(
|
|
896
|
+
self,
|
|
897
|
+
req: api_pb2.ConnectRequest,
|
|
898
|
+
extra_headers: HeaderInput | None = None,
|
|
899
|
+
timeout_seconds: float | None = None,
|
|
900
|
+
) -> AsyncIterator[api_pb2.ConnectResponse]:
|
|
901
|
+
return self._connect_iterator(req, extra_headers, timeout_seconds)
|
|
902
|
+
|
|
903
|
+
async def _connect_iterator(
|
|
904
|
+
self,
|
|
905
|
+
req: api_pb2.ConnectRequest,
|
|
906
|
+
extra_headers: HeaderInput | None = None,
|
|
907
|
+
timeout_seconds: float | None = None,
|
|
908
|
+
) -> AsyncIterator[api_pb2.ConnectResponse]:
|
|
909
|
+
stream_output = await self.call_connect(req, extra_headers)
|
|
910
|
+
err = stream_output.error()
|
|
911
|
+
if err is not None:
|
|
912
|
+
raise err
|
|
913
|
+
async with stream_output as stream:
|
|
914
|
+
async for response in stream:
|
|
915
|
+
yield response
|
|
916
|
+
err = stream.error()
|
|
917
|
+
if err is not None:
|
|
918
|
+
raise err
|
|
919
|
+
|
|
920
|
+
async def call_connect(
|
|
921
|
+
self,
|
|
922
|
+
req: api_pb2.ConnectRequest,
|
|
923
|
+
extra_headers: HeaderInput | None = None,
|
|
924
|
+
timeout_seconds: float | None = None,
|
|
925
|
+
) -> AsyncStreamOutput[api_pb2.ConnectResponse]:
|
|
926
|
+
"""Low-level method to call Connect, granting access to errors and metadata"""
|
|
927
|
+
url = self.base_url + "/sandboxagent.Process/Connect"
|
|
928
|
+
return await self._connect_client.call_server_streaming(
|
|
929
|
+
url, req, api_pb2.ConnectResponse, extra_headers, timeout_seconds
|
|
930
|
+
)
|
|
931
|
+
|
|
932
|
+
def start(
|
|
933
|
+
self,
|
|
934
|
+
req: api_pb2.StartRequest,
|
|
935
|
+
extra_headers: HeaderInput | None = None,
|
|
936
|
+
timeout_seconds: float | None = None,
|
|
937
|
+
) -> AsyncIterator[api_pb2.StartResponse]:
|
|
938
|
+
return self._start_iterator(req, extra_headers, timeout_seconds)
|
|
939
|
+
|
|
940
|
+
async def _start_iterator(
|
|
941
|
+
self,
|
|
942
|
+
req: api_pb2.StartRequest,
|
|
943
|
+
extra_headers: HeaderInput | None = None,
|
|
944
|
+
timeout_seconds: float | None = None,
|
|
945
|
+
) -> AsyncIterator[api_pb2.StartResponse]:
|
|
946
|
+
stream_output = await self.call_start(req, extra_headers,timeout_seconds)
|
|
947
|
+
err = stream_output.error()
|
|
948
|
+
if err is not None:
|
|
949
|
+
raise err
|
|
950
|
+
async with stream_output as stream:
|
|
951
|
+
async for response in stream:
|
|
952
|
+
yield response
|
|
953
|
+
err = stream.error()
|
|
954
|
+
if err is not None:
|
|
955
|
+
raise err
|
|
956
|
+
|
|
957
|
+
async def call_start(
|
|
958
|
+
self,
|
|
959
|
+
req: api_pb2.StartRequest,
|
|
960
|
+
extra_headers: HeaderInput | None = None,
|
|
961
|
+
timeout_seconds: float | None = None,
|
|
962
|
+
) -> AsyncStreamOutput[api_pb2.StartResponse]:
|
|
963
|
+
"""Low-level method to call Start, granting access to errors and metadata"""
|
|
964
|
+
url = self.base_url + "/sandboxagent.Process/Start"
|
|
965
|
+
return await self._connect_client.call_server_streaming(
|
|
966
|
+
url, req, api_pb2.StartResponse, extra_headers, timeout_seconds
|
|
967
|
+
)
|
|
968
|
+
|
|
969
|
+
async def call_update(
|
|
970
|
+
self,
|
|
971
|
+
req: api_pb2.UpdateRequest,
|
|
972
|
+
extra_headers: HeaderInput | None = None,
|
|
973
|
+
timeout_seconds: float | None = None,
|
|
974
|
+
) -> UnaryOutput[api_pb2.UpdateResponse]:
|
|
975
|
+
"""Low-level method to call Update, granting access to errors and metadata"""
|
|
976
|
+
url = self.base_url + "/sandboxagent.Process/Update"
|
|
977
|
+
return await self._connect_client.call_unary(
|
|
978
|
+
url, req, api_pb2.UpdateResponse, extra_headers, timeout_seconds
|
|
979
|
+
)
|
|
980
|
+
|
|
981
|
+
async def update(
|
|
982
|
+
self,
|
|
983
|
+
req: api_pb2.UpdateRequest,
|
|
984
|
+
extra_headers: HeaderInput | None = None,
|
|
985
|
+
timeout_seconds: float | None = None,
|
|
986
|
+
) -> api_pb2.UpdateResponse:
|
|
987
|
+
response = await self.call_update(req, extra_headers, timeout_seconds)
|
|
988
|
+
err = response.error()
|
|
989
|
+
if err is not None:
|
|
990
|
+
raise err
|
|
991
|
+
msg = response.message()
|
|
992
|
+
if msg is None:
|
|
993
|
+
raise ConnectProtocolError("missing response message")
|
|
994
|
+
return msg
|
|
995
|
+
|
|
996
|
+
async def call_stream_input(
|
|
997
|
+
self,
|
|
998
|
+
reqs: StreamInput[api_pb2.StreamInputRequest],
|
|
999
|
+
extra_headers: HeaderInput | None = None,
|
|
1000
|
+
timeout_seconds: float | None = None,
|
|
1001
|
+
) -> ClientStreamingOutput[api_pb2.StreamInputResponse]:
|
|
1002
|
+
"""Low-level method to call StreamInput, granting access to errors and metadata"""
|
|
1003
|
+
url = self.base_url + "/sandboxagent.Process/StreamInput"
|
|
1004
|
+
return await self._connect_client.call_client_streaming(
|
|
1005
|
+
url, reqs, api_pb2.StreamInputResponse, extra_headers, timeout_seconds
|
|
1006
|
+
)
|
|
1007
|
+
|
|
1008
|
+
async def stream_input(
|
|
1009
|
+
self,
|
|
1010
|
+
reqs: StreamInput[api_pb2.StreamInputRequest],
|
|
1011
|
+
extra_headers: HeaderInput | None = None,
|
|
1012
|
+
timeout_seconds: float | None = None,
|
|
1013
|
+
) -> api_pb2.StreamInputResponse:
|
|
1014
|
+
client_stream_output = await self.call_stream_input(reqs, extra_headers)
|
|
1015
|
+
err = client_stream_output.error()
|
|
1016
|
+
if err is not None:
|
|
1017
|
+
raise err
|
|
1018
|
+
msg = client_stream_output.message()
|
|
1019
|
+
if msg is None:
|
|
1020
|
+
raise RuntimeError("ClientStreamOutput has empty error and message")
|
|
1021
|
+
return msg
|
|
1022
|
+
|
|
1023
|
+
async def call_send_input(
|
|
1024
|
+
self,
|
|
1025
|
+
req: api_pb2.SendInputRequest,
|
|
1026
|
+
extra_headers: HeaderInput | None = None,
|
|
1027
|
+
timeout_seconds: float | None = None,
|
|
1028
|
+
) -> UnaryOutput[api_pb2.SendInputResponse]:
|
|
1029
|
+
"""Low-level method to call SendInput, granting access to errors and metadata"""
|
|
1030
|
+
url = self.base_url + "/sandboxagent.Process/SendInput"
|
|
1031
|
+
return await self._connect_client.call_unary(
|
|
1032
|
+
url, req, api_pb2.SendInputResponse, extra_headers, timeout_seconds
|
|
1033
|
+
)
|
|
1034
|
+
|
|
1035
|
+
async def send_input(
|
|
1036
|
+
self,
|
|
1037
|
+
req: api_pb2.SendInputRequest,
|
|
1038
|
+
extra_headers: HeaderInput | None = None,
|
|
1039
|
+
timeout_seconds: float | None = None,
|
|
1040
|
+
) -> api_pb2.SendInputResponse:
|
|
1041
|
+
response = await self.call_send_input(req, extra_headers, timeout_seconds)
|
|
1042
|
+
err = response.error()
|
|
1043
|
+
if err is not None:
|
|
1044
|
+
raise err
|
|
1045
|
+
msg = response.message()
|
|
1046
|
+
if msg is None:
|
|
1047
|
+
raise ConnectProtocolError("missing response message")
|
|
1048
|
+
return msg
|
|
1049
|
+
|
|
1050
|
+
async def call_send_signal(
|
|
1051
|
+
self,
|
|
1052
|
+
req: api_pb2.SendSignalRequest,
|
|
1053
|
+
extra_headers: HeaderInput | None = None,
|
|
1054
|
+
timeout_seconds: float | None = None,
|
|
1055
|
+
) -> UnaryOutput[api_pb2.SendSignalResponse]:
|
|
1056
|
+
"""Low-level method to call SendSignal, granting access to errors and metadata"""
|
|
1057
|
+
url = self.base_url + "/sandboxagent.Process/SendSignal"
|
|
1058
|
+
return await self._connect_client.call_unary(
|
|
1059
|
+
url, req, api_pb2.SendSignalResponse, extra_headers, timeout_seconds
|
|
1060
|
+
)
|
|
1061
|
+
|
|
1062
|
+
async def send_signal(
|
|
1063
|
+
self,
|
|
1064
|
+
req: api_pb2.SendSignalRequest,
|
|
1065
|
+
extra_headers: HeaderInput | None = None,
|
|
1066
|
+
timeout_seconds: float | None = None,
|
|
1067
|
+
) -> api_pb2.SendSignalResponse:
|
|
1068
|
+
response = await self.call_send_signal(req, extra_headers, timeout_seconds)
|
|
1069
|
+
err = response.error()
|
|
1070
|
+
if err is not None:
|
|
1071
|
+
raise err
|
|
1072
|
+
msg = response.message()
|
|
1073
|
+
if msg is None:
|
|
1074
|
+
raise ConnectProtocolError("missing response message")
|
|
1075
|
+
return msg
|
|
1076
|
+
|
|
1077
|
+
|
|
1078
|
+
@typing.runtime_checkable
|
|
1079
|
+
class ProcessProtocol(typing.Protocol):
|
|
1080
|
+
def list(
|
|
1081
|
+
self, req: ClientRequest[api_pb2.ListRequest]
|
|
1082
|
+
) -> ServerResponse[api_pb2.ListResponse]: ...
|
|
1083
|
+
def connect(
|
|
1084
|
+
self, req: ClientRequest[api_pb2.ConnectRequest]
|
|
1085
|
+
) -> ServerStream[api_pb2.ConnectResponse]: ...
|
|
1086
|
+
def start(
|
|
1087
|
+
self, req: ClientRequest[api_pb2.StartRequest]
|
|
1088
|
+
) -> ServerStream[api_pb2.StartResponse]: ...
|
|
1089
|
+
def update(
|
|
1090
|
+
self, req: ClientRequest[api_pb2.UpdateRequest]
|
|
1091
|
+
) -> ServerResponse[api_pb2.UpdateResponse]: ...
|
|
1092
|
+
def stream_input(
|
|
1093
|
+
self, req: ClientStream[api_pb2.StreamInputRequest]
|
|
1094
|
+
) -> ServerResponse[api_pb2.StreamInputResponse]: ...
|
|
1095
|
+
def send_input(
|
|
1096
|
+
self, req: ClientRequest[api_pb2.SendInputRequest]
|
|
1097
|
+
) -> ServerResponse[api_pb2.SendInputResponse]: ...
|
|
1098
|
+
def send_signal(
|
|
1099
|
+
self, req: ClientRequest[api_pb2.SendSignalRequest]
|
|
1100
|
+
) -> ServerResponse[api_pb2.SendSignalResponse]: ...
|
|
1101
|
+
|
|
1102
|
+
|
|
1103
|
+
PROCESS_PATH_PREFIX = "/sandboxagent.Process"
|
|
1104
|
+
|
|
1105
|
+
|
|
1106
|
+
def wsgi_process(implementation: ProcessProtocol) -> WSGIApplication:
|
|
1107
|
+
app = ConnectWSGI()
|
|
1108
|
+
app.register_unary_rpc(
|
|
1109
|
+
"/sandboxagent.Process/List", implementation.list, api_pb2.ListRequest
|
|
1110
|
+
)
|
|
1111
|
+
app.register_server_streaming_rpc(
|
|
1112
|
+
"/sandboxagent.Process/Connect", implementation.connect, api_pb2.ConnectRequest
|
|
1113
|
+
)
|
|
1114
|
+
app.register_server_streaming_rpc(
|
|
1115
|
+
"/sandboxagent.Process/Start", implementation.start, api_pb2.StartRequest
|
|
1116
|
+
)
|
|
1117
|
+
app.register_unary_rpc(
|
|
1118
|
+
"/sandboxagent.Process/Update", implementation.update, api_pb2.UpdateRequest
|
|
1119
|
+
)
|
|
1120
|
+
app.register_client_streaming_rpc(
|
|
1121
|
+
"/sandboxagent.Process/StreamInput",
|
|
1122
|
+
implementation.stream_input,
|
|
1123
|
+
api_pb2.StreamInputRequest,
|
|
1124
|
+
)
|
|
1125
|
+
app.register_unary_rpc(
|
|
1126
|
+
"/sandboxagent.Process/SendInput",
|
|
1127
|
+
implementation.send_input,
|
|
1128
|
+
api_pb2.SendInputRequest,
|
|
1129
|
+
)
|
|
1130
|
+
app.register_unary_rpc(
|
|
1131
|
+
"/sandboxagent.Process/SendSignal",
|
|
1132
|
+
implementation.send_signal,
|
|
1133
|
+
api_pb2.SendSignalRequest,
|
|
1134
|
+
)
|
|
1135
|
+
return app
|
|
1136
|
+
|
|
1137
|
+
|
|
1138
|
+
class ExecutionServiceClient:
|
|
1139
|
+
def __init__(
|
|
1140
|
+
self,
|
|
1141
|
+
base_url: str,
|
|
1142
|
+
http_client: urllib3.PoolManager | None = None,
|
|
1143
|
+
protocol: ConnectProtocol = ConnectProtocol.CONNECT_PROTOBUF,
|
|
1144
|
+
):
|
|
1145
|
+
self.base_url = base_url
|
|
1146
|
+
self._connect_client = ConnectClient(http_client, protocol)
|
|
1147
|
+
|
|
1148
|
+
def execute(
|
|
1149
|
+
self,
|
|
1150
|
+
req: api_pb2.ExecuteRequest,
|
|
1151
|
+
extra_headers: HeaderInput | None = None,
|
|
1152
|
+
timeout_seconds: float | None = None,
|
|
1153
|
+
) -> Iterator[api_pb2.ExecuteResponse]:
|
|
1154
|
+
return self._execute_iterator(req, extra_headers, timeout_seconds)
|
|
1155
|
+
|
|
1156
|
+
def _execute_iterator(
|
|
1157
|
+
self,
|
|
1158
|
+
req: api_pb2.ExecuteRequest,
|
|
1159
|
+
extra_headers: HeaderInput | None = None,
|
|
1160
|
+
timeout_seconds: float | None = None,
|
|
1161
|
+
) -> Iterator[api_pb2.ExecuteResponse]:
|
|
1162
|
+
stream_output = self.call_execute(req, extra_headers)
|
|
1163
|
+
err = stream_output.error()
|
|
1164
|
+
if err is not None:
|
|
1165
|
+
raise err
|
|
1166
|
+
yield from stream_output
|
|
1167
|
+
err = stream_output.error()
|
|
1168
|
+
if err is not None:
|
|
1169
|
+
raise err
|
|
1170
|
+
|
|
1171
|
+
def call_execute(
|
|
1172
|
+
self,
|
|
1173
|
+
req: api_pb2.ExecuteRequest,
|
|
1174
|
+
extra_headers: HeaderInput | None = None,
|
|
1175
|
+
timeout_seconds: float | None = None,
|
|
1176
|
+
) -> StreamOutput[api_pb2.ExecuteResponse]:
|
|
1177
|
+
"""Low-level method to call Execute, granting access to errors and metadata"""
|
|
1178
|
+
url = self.base_url + "/sandboxagent.ExecutionService/Execute"
|
|
1179
|
+
return self._connect_client.call_server_streaming(
|
|
1180
|
+
url, req, api_pb2.ExecuteResponse, extra_headers, timeout_seconds
|
|
1181
|
+
)
|
|
1182
|
+
|
|
1183
|
+
|
|
1184
|
+
class AsyncExecutionServiceClient:
|
|
1185
|
+
def __init__(
|
|
1186
|
+
self,
|
|
1187
|
+
base_url: str,
|
|
1188
|
+
http_client: aiohttp.ClientSession,
|
|
1189
|
+
protocol: ConnectProtocol = ConnectProtocol.CONNECT_PROTOBUF,
|
|
1190
|
+
):
|
|
1191
|
+
self.base_url = base_url
|
|
1192
|
+
self._connect_client = AsyncConnectClient(http_client, protocol)
|
|
1193
|
+
|
|
1194
|
+
def execute(
|
|
1195
|
+
self,
|
|
1196
|
+
req: api_pb2.ExecuteRequest,
|
|
1197
|
+
extra_headers: HeaderInput | None = None,
|
|
1198
|
+
timeout_seconds: float | None = None,
|
|
1199
|
+
) -> AsyncIterator[api_pb2.ExecuteResponse]:
|
|
1200
|
+
return self._execute_iterator(req, extra_headers, timeout_seconds)
|
|
1201
|
+
|
|
1202
|
+
async def _execute_iterator(
|
|
1203
|
+
self,
|
|
1204
|
+
req: api_pb2.ExecuteRequest,
|
|
1205
|
+
extra_headers: HeaderInput | None = None,
|
|
1206
|
+
timeout_seconds: float | None = None,
|
|
1207
|
+
) -> AsyncIterator[api_pb2.ExecuteResponse]:
|
|
1208
|
+
stream_output = await self.call_execute(req, extra_headers)
|
|
1209
|
+
err = stream_output.error()
|
|
1210
|
+
if err is not None:
|
|
1211
|
+
raise err
|
|
1212
|
+
async with stream_output as stream:
|
|
1213
|
+
async for response in stream:
|
|
1214
|
+
yield response
|
|
1215
|
+
err = stream.error()
|
|
1216
|
+
if err is not None:
|
|
1217
|
+
raise err
|
|
1218
|
+
|
|
1219
|
+
async def call_execute(
|
|
1220
|
+
self,
|
|
1221
|
+
req: api_pb2.ExecuteRequest,
|
|
1222
|
+
extra_headers: HeaderInput | None = None,
|
|
1223
|
+
timeout_seconds: float | None = None,
|
|
1224
|
+
) -> AsyncStreamOutput[api_pb2.ExecuteResponse]:
|
|
1225
|
+
"""Low-level method to call Execute, granting access to errors and metadata"""
|
|
1226
|
+
url = self.base_url + "/sandboxagent.ExecutionService/Execute"
|
|
1227
|
+
return await self._connect_client.call_server_streaming(
|
|
1228
|
+
url, req, api_pb2.ExecuteResponse, extra_headers, timeout_seconds
|
|
1229
|
+
)
|
|
1230
|
+
|
|
1231
|
+
|
|
1232
|
+
@typing.runtime_checkable
|
|
1233
|
+
class ExecutionServiceProtocol(typing.Protocol):
|
|
1234
|
+
def execute(
|
|
1235
|
+
self, req: ClientRequest[api_pb2.ExecuteRequest]
|
|
1236
|
+
) -> ServerStream[api_pb2.ExecuteResponse]: ...
|
|
1237
|
+
|
|
1238
|
+
|
|
1239
|
+
EXECUTION_SERVICE_PATH_PREFIX = "/sandboxagent.ExecutionService"
|
|
1240
|
+
|
|
1241
|
+
|
|
1242
|
+
def wsgi_execution_service(implementation: ExecutionServiceProtocol) -> WSGIApplication:
|
|
1243
|
+
app = ConnectWSGI()
|
|
1244
|
+
app.register_server_streaming_rpc(
|
|
1245
|
+
"/sandboxagent.ExecutionService/Execute",
|
|
1246
|
+
implementation.execute,
|
|
1247
|
+
api_pb2.ExecuteRequest,
|
|
1248
|
+
)
|
|
1249
|
+
return app
|
|
1250
|
+
|
|
1251
|
+
|
|
1252
|
+
class ContextServiceClient:
|
|
1253
|
+
def __init__(
|
|
1254
|
+
self,
|
|
1255
|
+
base_url: str,
|
|
1256
|
+
http_client: urllib3.PoolManager | None = None,
|
|
1257
|
+
protocol: ConnectProtocol = ConnectProtocol.CONNECT_PROTOBUF,
|
|
1258
|
+
):
|
|
1259
|
+
self.base_url = base_url
|
|
1260
|
+
self._connect_client = ConnectClient(http_client, protocol)
|
|
1261
|
+
|
|
1262
|
+
def call_create_context(
|
|
1263
|
+
self,
|
|
1264
|
+
req: api_pb2.CreateContextRequest,
|
|
1265
|
+
extra_headers: HeaderInput | None = None,
|
|
1266
|
+
timeout_seconds: float | None = None,
|
|
1267
|
+
) -> UnaryOutput[api_pb2.Context]:
|
|
1268
|
+
"""Low-level method to call CreateContext, granting access to errors and metadata"""
|
|
1269
|
+
url = self.base_url + "/sandboxagent.ContextService/CreateContext"
|
|
1270
|
+
return self._connect_client.call_unary(
|
|
1271
|
+
url, req, api_pb2.Context, extra_headers, timeout_seconds
|
|
1272
|
+
)
|
|
1273
|
+
|
|
1274
|
+
def create_context(
|
|
1275
|
+
self,
|
|
1276
|
+
req: api_pb2.CreateContextRequest,
|
|
1277
|
+
extra_headers: HeaderInput | None = None,
|
|
1278
|
+
timeout_seconds: float | None = None,
|
|
1279
|
+
) -> api_pb2.Context:
|
|
1280
|
+
response = self.call_create_context(req, extra_headers, timeout_seconds)
|
|
1281
|
+
err = response.error()
|
|
1282
|
+
if err is not None:
|
|
1283
|
+
raise err
|
|
1284
|
+
msg = response.message()
|
|
1285
|
+
if msg is None:
|
|
1286
|
+
raise ConnectProtocolError("missing response message")
|
|
1287
|
+
return msg
|
|
1288
|
+
|
|
1289
|
+
def call_destroy_context(
|
|
1290
|
+
self,
|
|
1291
|
+
req: api_pb2.DestroyContextRequest,
|
|
1292
|
+
extra_headers: HeaderInput | None = None,
|
|
1293
|
+
timeout_seconds: float | None = None,
|
|
1294
|
+
) -> UnaryOutput[api_pb2.DestroyContextResponse]:
|
|
1295
|
+
"""Low-level method to call DestroyContext, granting access to errors and metadata"""
|
|
1296
|
+
url = self.base_url + "/sandboxagent.ContextService/DestroyContext"
|
|
1297
|
+
return self._connect_client.call_unary(
|
|
1298
|
+
url, req, api_pb2.DestroyContextResponse, extra_headers, timeout_seconds
|
|
1299
|
+
)
|
|
1300
|
+
|
|
1301
|
+
def destroy_context(
|
|
1302
|
+
self,
|
|
1303
|
+
req: api_pb2.DestroyContextRequest,
|
|
1304
|
+
extra_headers: HeaderInput | None = None,
|
|
1305
|
+
timeout_seconds: float | None = None,
|
|
1306
|
+
) -> api_pb2.DestroyContextResponse:
|
|
1307
|
+
response = self.call_destroy_context(req, extra_headers, timeout_seconds)
|
|
1308
|
+
err = response.error()
|
|
1309
|
+
if err is not None:
|
|
1310
|
+
raise err
|
|
1311
|
+
msg = response.message()
|
|
1312
|
+
if msg is None:
|
|
1313
|
+
raise ConnectProtocolError("missing response message")
|
|
1314
|
+
return msg
|
|
1315
|
+
|
|
1316
|
+
|
|
1317
|
+
class AsyncContextServiceClient:
|
|
1318
|
+
def __init__(
|
|
1319
|
+
self,
|
|
1320
|
+
base_url: str,
|
|
1321
|
+
http_client: aiohttp.ClientSession,
|
|
1322
|
+
protocol: ConnectProtocol = ConnectProtocol.CONNECT_PROTOBUF,
|
|
1323
|
+
):
|
|
1324
|
+
self.base_url = base_url
|
|
1325
|
+
self._connect_client = AsyncConnectClient(http_client, protocol)
|
|
1326
|
+
|
|
1327
|
+
async def call_create_context(
|
|
1328
|
+
self,
|
|
1329
|
+
req: api_pb2.CreateContextRequest,
|
|
1330
|
+
extra_headers: HeaderInput | None = None,
|
|
1331
|
+
timeout_seconds: float | None = None,
|
|
1332
|
+
) -> UnaryOutput[api_pb2.Context]:
|
|
1333
|
+
"""Low-level method to call CreateContext, granting access to errors and metadata"""
|
|
1334
|
+
url = self.base_url + "/sandboxagent.ContextService/CreateContext"
|
|
1335
|
+
return await self._connect_client.call_unary(
|
|
1336
|
+
url, req, api_pb2.Context, extra_headers, timeout_seconds
|
|
1337
|
+
)
|
|
1338
|
+
|
|
1339
|
+
async def create_context(
|
|
1340
|
+
self,
|
|
1341
|
+
req: api_pb2.CreateContextRequest,
|
|
1342
|
+
extra_headers: HeaderInput | None = None,
|
|
1343
|
+
timeout_seconds: float | None = None,
|
|
1344
|
+
) -> api_pb2.Context:
|
|
1345
|
+
response = await self.call_create_context(req, extra_headers, timeout_seconds)
|
|
1346
|
+
err = response.error()
|
|
1347
|
+
if err is not None:
|
|
1348
|
+
raise err
|
|
1349
|
+
msg = response.message()
|
|
1350
|
+
if msg is None:
|
|
1351
|
+
raise ConnectProtocolError("missing response message")
|
|
1352
|
+
return msg
|
|
1353
|
+
|
|
1354
|
+
async def call_destroy_context(
|
|
1355
|
+
self,
|
|
1356
|
+
req: api_pb2.DestroyContextRequest,
|
|
1357
|
+
extra_headers: HeaderInput | None = None,
|
|
1358
|
+
timeout_seconds: float | None = None,
|
|
1359
|
+
) -> UnaryOutput[api_pb2.DestroyContextResponse]:
|
|
1360
|
+
"""Low-level method to call DestroyContext, granting access to errors and metadata"""
|
|
1361
|
+
url = self.base_url + "/sandboxagent.ContextService/DestroyContext"
|
|
1362
|
+
return await self._connect_client.call_unary(
|
|
1363
|
+
url, req, api_pb2.DestroyContextResponse, extra_headers, timeout_seconds
|
|
1364
|
+
)
|
|
1365
|
+
|
|
1366
|
+
async def destroy_context(
|
|
1367
|
+
self,
|
|
1368
|
+
req: api_pb2.DestroyContextRequest,
|
|
1369
|
+
extra_headers: HeaderInput | None = None,
|
|
1370
|
+
timeout_seconds: float | None = None,
|
|
1371
|
+
) -> api_pb2.DestroyContextResponse:
|
|
1372
|
+
response = await self.call_destroy_context(req, extra_headers, timeout_seconds)
|
|
1373
|
+
err = response.error()
|
|
1374
|
+
if err is not None:
|
|
1375
|
+
raise err
|
|
1376
|
+
msg = response.message()
|
|
1377
|
+
if msg is None:
|
|
1378
|
+
raise ConnectProtocolError("missing response message")
|
|
1379
|
+
return msg
|
|
1380
|
+
|
|
1381
|
+
|
|
1382
|
+
@typing.runtime_checkable
|
|
1383
|
+
class ContextServiceProtocol(typing.Protocol):
|
|
1384
|
+
def create_context(
|
|
1385
|
+
self, req: ClientRequest[api_pb2.CreateContextRequest]
|
|
1386
|
+
) -> ServerResponse[api_pb2.Context]: ...
|
|
1387
|
+
def destroy_context(
|
|
1388
|
+
self, req: ClientRequest[api_pb2.DestroyContextRequest]
|
|
1389
|
+
) -> ServerResponse[api_pb2.DestroyContextResponse]: ...
|
|
1390
|
+
|
|
1391
|
+
|
|
1392
|
+
CONTEXT_SERVICE_PATH_PREFIX = "/sandboxagent.ContextService"
|
|
1393
|
+
|
|
1394
|
+
|
|
1395
|
+
def wsgi_context_service(implementation: ContextServiceProtocol) -> WSGIApplication:
|
|
1396
|
+
app = ConnectWSGI()
|
|
1397
|
+
app.register_unary_rpc(
|
|
1398
|
+
"/sandboxagent.ContextService/CreateContext",
|
|
1399
|
+
implementation.create_context,
|
|
1400
|
+
api_pb2.CreateContextRequest,
|
|
1401
|
+
)
|
|
1402
|
+
app.register_unary_rpc(
|
|
1403
|
+
"/sandboxagent.ContextService/DestroyContext",
|
|
1404
|
+
implementation.destroy_context,
|
|
1405
|
+
api_pb2.DestroyContextRequest,
|
|
1406
|
+
)
|
|
1407
|
+
return app
|