codeset 0.1.0a1__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.
- codeset/__init__.py +90 -0
- codeset/_base_client.py +1985 -0
- codeset/_client.py +430 -0
- codeset/_compat.py +219 -0
- codeset/_constants.py +14 -0
- codeset/_exceptions.py +108 -0
- codeset/_files.py +123 -0
- codeset/_models.py +805 -0
- codeset/_qs.py +150 -0
- codeset/_resource.py +43 -0
- codeset/_response.py +830 -0
- codeset/_streaming.py +333 -0
- codeset/_types.py +219 -0
- codeset/_utils/__init__.py +57 -0
- codeset/_utils/_logs.py +25 -0
- codeset/_utils/_proxy.py +65 -0
- codeset/_utils/_reflection.py +42 -0
- codeset/_utils/_resources_proxy.py +24 -0
- codeset/_utils/_streams.py +12 -0
- codeset/_utils/_sync.py +86 -0
- codeset/_utils/_transform.py +447 -0
- codeset/_utils/_typing.py +151 -0
- codeset/_utils/_utils.py +422 -0
- codeset/_version.py +4 -0
- codeset/lib/.keep +4 -0
- codeset/py.typed +0 -0
- codeset/resources/__init__.py +47 -0
- codeset/resources/health.py +135 -0
- codeset/resources/samples.py +233 -0
- codeset/resources/sessions/__init__.py +33 -0
- codeset/resources/sessions/sessions.py +618 -0
- codeset/resources/sessions/verify.py +248 -0
- codeset/types/__init__.py +19 -0
- codeset/types/container_info.py +30 -0
- codeset/types/error_info.py +13 -0
- codeset/types/health_check_response.py +19 -0
- codeset/types/sample_download_params.py +14 -0
- codeset/types/sample_list_response.py +41 -0
- codeset/types/session.py +37 -0
- codeset/types/session_apply_diff_params.py +12 -0
- codeset/types/session_apply_diff_response.py +13 -0
- codeset/types/session_close_response.py +10 -0
- codeset/types/session_create_params.py +15 -0
- codeset/types/session_create_response.py +19 -0
- codeset/types/session_execute_command_params.py +15 -0
- codeset/types/session_execute_command_response.py +19 -0
- codeset/types/session_list_response.py +18 -0
- codeset/types/session_status.py +7 -0
- codeset/types/sessions/__init__.py +7 -0
- codeset/types/sessions/job_status.py +7 -0
- codeset/types/sessions/verify_start_response.py +19 -0
- codeset/types/sessions/verify_status_response.py +66 -0
- codeset-0.1.0a1.dist-info/METADATA +397 -0
- codeset-0.1.0a1.dist-info/RECORD +56 -0
- codeset-0.1.0a1.dist-info/WHEEL +4 -0
- codeset-0.1.0a1.dist-info/licenses/LICENSE +201 -0
@@ -0,0 +1,618 @@
|
|
1
|
+
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
2
|
+
|
3
|
+
from __future__ import annotations
|
4
|
+
|
5
|
+
import httpx
|
6
|
+
|
7
|
+
from .verify import (
|
8
|
+
VerifyResource,
|
9
|
+
AsyncVerifyResource,
|
10
|
+
VerifyResourceWithRawResponse,
|
11
|
+
AsyncVerifyResourceWithRawResponse,
|
12
|
+
VerifyResourceWithStreamingResponse,
|
13
|
+
AsyncVerifyResourceWithStreamingResponse,
|
14
|
+
)
|
15
|
+
from ...types import session_create_params, session_apply_diff_params, session_execute_command_params
|
16
|
+
from ..._types import NOT_GIVEN, Body, Query, Headers, NotGiven
|
17
|
+
from ..._utils import maybe_transform, async_maybe_transform
|
18
|
+
from ..._compat import cached_property
|
19
|
+
from ..._resource import SyncAPIResource, AsyncAPIResource
|
20
|
+
from ..._response import (
|
21
|
+
to_raw_response_wrapper,
|
22
|
+
to_streamed_response_wrapper,
|
23
|
+
async_to_raw_response_wrapper,
|
24
|
+
async_to_streamed_response_wrapper,
|
25
|
+
)
|
26
|
+
from ..._base_client import make_request_options
|
27
|
+
from ...types.session import Session
|
28
|
+
from ...types.session_list_response import SessionListResponse
|
29
|
+
from ...types.session_close_response import SessionCloseResponse
|
30
|
+
from ...types.session_create_response import SessionCreateResponse
|
31
|
+
from ...types.session_apply_diff_response import SessionApplyDiffResponse
|
32
|
+
from ...types.session_execute_command_response import SessionExecuteCommandResponse
|
33
|
+
|
34
|
+
__all__ = ["SessionsResource", "AsyncSessionsResource"]
|
35
|
+
|
36
|
+
|
37
|
+
class SessionsResource(SyncAPIResource):
|
38
|
+
@cached_property
|
39
|
+
def verify(self) -> VerifyResource:
|
40
|
+
return VerifyResource(self._client)
|
41
|
+
|
42
|
+
@cached_property
|
43
|
+
def with_raw_response(self) -> SessionsResourceWithRawResponse:
|
44
|
+
"""
|
45
|
+
This property can be used as a prefix for any HTTP method call to return
|
46
|
+
the raw response object instead of the parsed content.
|
47
|
+
|
48
|
+
For more information, see https://www.github.com/codeset-ai/codeset-sdk#accessing-raw-response-data-eg-headers
|
49
|
+
"""
|
50
|
+
return SessionsResourceWithRawResponse(self)
|
51
|
+
|
52
|
+
@cached_property
|
53
|
+
def with_streaming_response(self) -> SessionsResourceWithStreamingResponse:
|
54
|
+
"""
|
55
|
+
An alternative to `.with_raw_response` that doesn't eagerly read the response body.
|
56
|
+
|
57
|
+
For more information, see https://www.github.com/codeset-ai/codeset-sdk#with_streaming_response
|
58
|
+
"""
|
59
|
+
return SessionsResourceWithStreamingResponse(self)
|
60
|
+
|
61
|
+
def create(
|
62
|
+
self,
|
63
|
+
*,
|
64
|
+
sample_id: str,
|
65
|
+
ttl_minutes: int | NotGiven = NOT_GIVEN,
|
66
|
+
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
|
67
|
+
# The extra values given here take precedence over values defined on the client or passed to this method.
|
68
|
+
extra_headers: Headers | None = None,
|
69
|
+
extra_query: Query | None = None,
|
70
|
+
extra_body: Body | None = None,
|
71
|
+
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
|
72
|
+
) -> SessionCreateResponse:
|
73
|
+
"""
|
74
|
+
Create a new session
|
75
|
+
|
76
|
+
Args:
|
77
|
+
sample_id: Identifier of the sample to use for this session.
|
78
|
+
|
79
|
+
ttl_minutes: Time to live for the session in minutes (default: 30).
|
80
|
+
|
81
|
+
extra_headers: Send extra headers
|
82
|
+
|
83
|
+
extra_query: Add additional query parameters to the request
|
84
|
+
|
85
|
+
extra_body: Add additional JSON properties to the request
|
86
|
+
|
87
|
+
timeout: Override the client-level default timeout for this request, in seconds
|
88
|
+
"""
|
89
|
+
return self._post(
|
90
|
+
"/sessions",
|
91
|
+
body=maybe_transform(
|
92
|
+
{
|
93
|
+
"sample_id": sample_id,
|
94
|
+
"ttl_minutes": ttl_minutes,
|
95
|
+
},
|
96
|
+
session_create_params.SessionCreateParams,
|
97
|
+
),
|
98
|
+
options=make_request_options(
|
99
|
+
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
|
100
|
+
),
|
101
|
+
cast_to=SessionCreateResponse,
|
102
|
+
)
|
103
|
+
|
104
|
+
def retrieve(
|
105
|
+
self,
|
106
|
+
session_id: str,
|
107
|
+
*,
|
108
|
+
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
|
109
|
+
# The extra values given here take precedence over values defined on the client or passed to this method.
|
110
|
+
extra_headers: Headers | None = None,
|
111
|
+
extra_query: Query | None = None,
|
112
|
+
extra_body: Body | None = None,
|
113
|
+
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
|
114
|
+
) -> Session:
|
115
|
+
"""
|
116
|
+
Get session details
|
117
|
+
|
118
|
+
Args:
|
119
|
+
extra_headers: Send extra headers
|
120
|
+
|
121
|
+
extra_query: Add additional query parameters to the request
|
122
|
+
|
123
|
+
extra_body: Add additional JSON properties to the request
|
124
|
+
|
125
|
+
timeout: Override the client-level default timeout for this request, in seconds
|
126
|
+
"""
|
127
|
+
if not session_id:
|
128
|
+
raise ValueError(f"Expected a non-empty value for `session_id` but received {session_id!r}")
|
129
|
+
return self._get(
|
130
|
+
f"/sessions/{session_id}",
|
131
|
+
options=make_request_options(
|
132
|
+
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
|
133
|
+
),
|
134
|
+
cast_to=Session,
|
135
|
+
)
|
136
|
+
|
137
|
+
def list(
|
138
|
+
self,
|
139
|
+
*,
|
140
|
+
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
|
141
|
+
# The extra values given here take precedence over values defined on the client or passed to this method.
|
142
|
+
extra_headers: Headers | None = None,
|
143
|
+
extra_query: Query | None = None,
|
144
|
+
extra_body: Body | None = None,
|
145
|
+
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
|
146
|
+
) -> SessionListResponse:
|
147
|
+
"""List environment sessions"""
|
148
|
+
return self._get(
|
149
|
+
"/sessions",
|
150
|
+
options=make_request_options(
|
151
|
+
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
|
152
|
+
),
|
153
|
+
cast_to=SessionListResponse,
|
154
|
+
)
|
155
|
+
|
156
|
+
def apply_diff(
|
157
|
+
self,
|
158
|
+
session_id: str,
|
159
|
+
*,
|
160
|
+
diff: str,
|
161
|
+
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
|
162
|
+
# The extra values given here take precedence over values defined on the client or passed to this method.
|
163
|
+
extra_headers: Headers | None = None,
|
164
|
+
extra_query: Query | None = None,
|
165
|
+
extra_body: Body | None = None,
|
166
|
+
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
|
167
|
+
) -> SessionApplyDiffResponse:
|
168
|
+
"""
|
169
|
+
Apply a diff in an environment
|
170
|
+
|
171
|
+
Args:
|
172
|
+
diff: The diff to be applied, in unified format.
|
173
|
+
|
174
|
+
extra_headers: Send extra headers
|
175
|
+
|
176
|
+
extra_query: Add additional query parameters to the request
|
177
|
+
|
178
|
+
extra_body: Add additional JSON properties to the request
|
179
|
+
|
180
|
+
timeout: Override the client-level default timeout for this request, in seconds
|
181
|
+
"""
|
182
|
+
if not session_id:
|
183
|
+
raise ValueError(f"Expected a non-empty value for `session_id` but received {session_id!r}")
|
184
|
+
return self._post(
|
185
|
+
f"/sessions/{session_id}/apply",
|
186
|
+
body=maybe_transform({"diff": diff}, session_apply_diff_params.SessionApplyDiffParams),
|
187
|
+
options=make_request_options(
|
188
|
+
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
|
189
|
+
),
|
190
|
+
cast_to=SessionApplyDiffResponse,
|
191
|
+
)
|
192
|
+
|
193
|
+
def close(
|
194
|
+
self,
|
195
|
+
session_id: str,
|
196
|
+
*,
|
197
|
+
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
|
198
|
+
# The extra values given here take precedence over values defined on the client or passed to this method.
|
199
|
+
extra_headers: Headers | None = None,
|
200
|
+
extra_query: Query | None = None,
|
201
|
+
extra_body: Body | None = None,
|
202
|
+
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
|
203
|
+
) -> SessionCloseResponse:
|
204
|
+
"""
|
205
|
+
Close/delete an environment session
|
206
|
+
|
207
|
+
Args:
|
208
|
+
extra_headers: Send extra headers
|
209
|
+
|
210
|
+
extra_query: Add additional query parameters to the request
|
211
|
+
|
212
|
+
extra_body: Add additional JSON properties to the request
|
213
|
+
|
214
|
+
timeout: Override the client-level default timeout for this request, in seconds
|
215
|
+
"""
|
216
|
+
if not session_id:
|
217
|
+
raise ValueError(f"Expected a non-empty value for `session_id` but received {session_id!r}")
|
218
|
+
return self._delete(
|
219
|
+
f"/sessions/{session_id}",
|
220
|
+
options=make_request_options(
|
221
|
+
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
|
222
|
+
),
|
223
|
+
cast_to=SessionCloseResponse,
|
224
|
+
)
|
225
|
+
|
226
|
+
def execute_command(
|
227
|
+
self,
|
228
|
+
session_id: str,
|
229
|
+
*,
|
230
|
+
command: str,
|
231
|
+
command_timeout: int | NotGiven = NOT_GIVEN,
|
232
|
+
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
|
233
|
+
# The extra values given here take precedence over values defined on the client or passed to this method.
|
234
|
+
extra_headers: Headers | None = None,
|
235
|
+
extra_query: Query | None = None,
|
236
|
+
extra_body: Body | None = None,
|
237
|
+
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
|
238
|
+
) -> SessionExecuteCommandResponse:
|
239
|
+
"""
|
240
|
+
Execute a bash command in an environment
|
241
|
+
|
242
|
+
Args:
|
243
|
+
command: The bash command to execute.
|
244
|
+
|
245
|
+
command_timeout: Timeout for command execution in seconds (default: 300).
|
246
|
+
|
247
|
+
extra_headers: Send extra headers
|
248
|
+
|
249
|
+
extra_query: Add additional query parameters to the request
|
250
|
+
|
251
|
+
extra_body: Add additional JSON properties to the request
|
252
|
+
|
253
|
+
timeout: Override the client-level default timeout for this request, in seconds
|
254
|
+
"""
|
255
|
+
if not session_id:
|
256
|
+
raise ValueError(f"Expected a non-empty value for `session_id` but received {session_id!r}")
|
257
|
+
return self._post(
|
258
|
+
f"/sessions/{session_id}/exec",
|
259
|
+
body=maybe_transform(
|
260
|
+
{
|
261
|
+
"command": command,
|
262
|
+
"command_timeout": command_timeout,
|
263
|
+
},
|
264
|
+
session_execute_command_params.SessionExecuteCommandParams,
|
265
|
+
),
|
266
|
+
options=make_request_options(
|
267
|
+
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
|
268
|
+
),
|
269
|
+
cast_to=SessionExecuteCommandResponse,
|
270
|
+
)
|
271
|
+
|
272
|
+
|
273
|
+
class AsyncSessionsResource(AsyncAPIResource):
|
274
|
+
@cached_property
|
275
|
+
def verify(self) -> AsyncVerifyResource:
|
276
|
+
return AsyncVerifyResource(self._client)
|
277
|
+
|
278
|
+
@cached_property
|
279
|
+
def with_raw_response(self) -> AsyncSessionsResourceWithRawResponse:
|
280
|
+
"""
|
281
|
+
This property can be used as a prefix for any HTTP method call to return
|
282
|
+
the raw response object instead of the parsed content.
|
283
|
+
|
284
|
+
For more information, see https://www.github.com/codeset-ai/codeset-sdk#accessing-raw-response-data-eg-headers
|
285
|
+
"""
|
286
|
+
return AsyncSessionsResourceWithRawResponse(self)
|
287
|
+
|
288
|
+
@cached_property
|
289
|
+
def with_streaming_response(self) -> AsyncSessionsResourceWithStreamingResponse:
|
290
|
+
"""
|
291
|
+
An alternative to `.with_raw_response` that doesn't eagerly read the response body.
|
292
|
+
|
293
|
+
For more information, see https://www.github.com/codeset-ai/codeset-sdk#with_streaming_response
|
294
|
+
"""
|
295
|
+
return AsyncSessionsResourceWithStreamingResponse(self)
|
296
|
+
|
297
|
+
async def create(
|
298
|
+
self,
|
299
|
+
*,
|
300
|
+
sample_id: str,
|
301
|
+
ttl_minutes: int | NotGiven = NOT_GIVEN,
|
302
|
+
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
|
303
|
+
# The extra values given here take precedence over values defined on the client or passed to this method.
|
304
|
+
extra_headers: Headers | None = None,
|
305
|
+
extra_query: Query | None = None,
|
306
|
+
extra_body: Body | None = None,
|
307
|
+
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
|
308
|
+
) -> SessionCreateResponse:
|
309
|
+
"""
|
310
|
+
Create a new session
|
311
|
+
|
312
|
+
Args:
|
313
|
+
sample_id: Identifier of the sample to use for this session.
|
314
|
+
|
315
|
+
ttl_minutes: Time to live for the session in minutes (default: 30).
|
316
|
+
|
317
|
+
extra_headers: Send extra headers
|
318
|
+
|
319
|
+
extra_query: Add additional query parameters to the request
|
320
|
+
|
321
|
+
extra_body: Add additional JSON properties to the request
|
322
|
+
|
323
|
+
timeout: Override the client-level default timeout for this request, in seconds
|
324
|
+
"""
|
325
|
+
return await self._post(
|
326
|
+
"/sessions",
|
327
|
+
body=await async_maybe_transform(
|
328
|
+
{
|
329
|
+
"sample_id": sample_id,
|
330
|
+
"ttl_minutes": ttl_minutes,
|
331
|
+
},
|
332
|
+
session_create_params.SessionCreateParams,
|
333
|
+
),
|
334
|
+
options=make_request_options(
|
335
|
+
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
|
336
|
+
),
|
337
|
+
cast_to=SessionCreateResponse,
|
338
|
+
)
|
339
|
+
|
340
|
+
async def retrieve(
|
341
|
+
self,
|
342
|
+
session_id: str,
|
343
|
+
*,
|
344
|
+
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
|
345
|
+
# The extra values given here take precedence over values defined on the client or passed to this method.
|
346
|
+
extra_headers: Headers | None = None,
|
347
|
+
extra_query: Query | None = None,
|
348
|
+
extra_body: Body | None = None,
|
349
|
+
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
|
350
|
+
) -> Session:
|
351
|
+
"""
|
352
|
+
Get session details
|
353
|
+
|
354
|
+
Args:
|
355
|
+
extra_headers: Send extra headers
|
356
|
+
|
357
|
+
extra_query: Add additional query parameters to the request
|
358
|
+
|
359
|
+
extra_body: Add additional JSON properties to the request
|
360
|
+
|
361
|
+
timeout: Override the client-level default timeout for this request, in seconds
|
362
|
+
"""
|
363
|
+
if not session_id:
|
364
|
+
raise ValueError(f"Expected a non-empty value for `session_id` but received {session_id!r}")
|
365
|
+
return await self._get(
|
366
|
+
f"/sessions/{session_id}",
|
367
|
+
options=make_request_options(
|
368
|
+
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
|
369
|
+
),
|
370
|
+
cast_to=Session,
|
371
|
+
)
|
372
|
+
|
373
|
+
async def list(
|
374
|
+
self,
|
375
|
+
*,
|
376
|
+
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
|
377
|
+
# The extra values given here take precedence over values defined on the client or passed to this method.
|
378
|
+
extra_headers: Headers | None = None,
|
379
|
+
extra_query: Query | None = None,
|
380
|
+
extra_body: Body | None = None,
|
381
|
+
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
|
382
|
+
) -> SessionListResponse:
|
383
|
+
"""List environment sessions"""
|
384
|
+
return await self._get(
|
385
|
+
"/sessions",
|
386
|
+
options=make_request_options(
|
387
|
+
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
|
388
|
+
),
|
389
|
+
cast_to=SessionListResponse,
|
390
|
+
)
|
391
|
+
|
392
|
+
async def apply_diff(
|
393
|
+
self,
|
394
|
+
session_id: str,
|
395
|
+
*,
|
396
|
+
diff: str,
|
397
|
+
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
|
398
|
+
# The extra values given here take precedence over values defined on the client or passed to this method.
|
399
|
+
extra_headers: Headers | None = None,
|
400
|
+
extra_query: Query | None = None,
|
401
|
+
extra_body: Body | None = None,
|
402
|
+
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
|
403
|
+
) -> SessionApplyDiffResponse:
|
404
|
+
"""
|
405
|
+
Apply a diff in an environment
|
406
|
+
|
407
|
+
Args:
|
408
|
+
diff: The diff to be applied, in unified format.
|
409
|
+
|
410
|
+
extra_headers: Send extra headers
|
411
|
+
|
412
|
+
extra_query: Add additional query parameters to the request
|
413
|
+
|
414
|
+
extra_body: Add additional JSON properties to the request
|
415
|
+
|
416
|
+
timeout: Override the client-level default timeout for this request, in seconds
|
417
|
+
"""
|
418
|
+
if not session_id:
|
419
|
+
raise ValueError(f"Expected a non-empty value for `session_id` but received {session_id!r}")
|
420
|
+
return await self._post(
|
421
|
+
f"/sessions/{session_id}/apply",
|
422
|
+
body=await async_maybe_transform({"diff": diff}, session_apply_diff_params.SessionApplyDiffParams),
|
423
|
+
options=make_request_options(
|
424
|
+
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
|
425
|
+
),
|
426
|
+
cast_to=SessionApplyDiffResponse,
|
427
|
+
)
|
428
|
+
|
429
|
+
async def close(
|
430
|
+
self,
|
431
|
+
session_id: str,
|
432
|
+
*,
|
433
|
+
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
|
434
|
+
# The extra values given here take precedence over values defined on the client or passed to this method.
|
435
|
+
extra_headers: Headers | None = None,
|
436
|
+
extra_query: Query | None = None,
|
437
|
+
extra_body: Body | None = None,
|
438
|
+
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
|
439
|
+
) -> SessionCloseResponse:
|
440
|
+
"""
|
441
|
+
Close/delete an environment session
|
442
|
+
|
443
|
+
Args:
|
444
|
+
extra_headers: Send extra headers
|
445
|
+
|
446
|
+
extra_query: Add additional query parameters to the request
|
447
|
+
|
448
|
+
extra_body: Add additional JSON properties to the request
|
449
|
+
|
450
|
+
timeout: Override the client-level default timeout for this request, in seconds
|
451
|
+
"""
|
452
|
+
if not session_id:
|
453
|
+
raise ValueError(f"Expected a non-empty value for `session_id` but received {session_id!r}")
|
454
|
+
return await self._delete(
|
455
|
+
f"/sessions/{session_id}",
|
456
|
+
options=make_request_options(
|
457
|
+
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
|
458
|
+
),
|
459
|
+
cast_to=SessionCloseResponse,
|
460
|
+
)
|
461
|
+
|
462
|
+
async def execute_command(
|
463
|
+
self,
|
464
|
+
session_id: str,
|
465
|
+
*,
|
466
|
+
command: str,
|
467
|
+
command_timeout: int | NotGiven = NOT_GIVEN,
|
468
|
+
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
|
469
|
+
# The extra values given here take precedence over values defined on the client or passed to this method.
|
470
|
+
extra_headers: Headers | None = None,
|
471
|
+
extra_query: Query | None = None,
|
472
|
+
extra_body: Body | None = None,
|
473
|
+
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
|
474
|
+
) -> SessionExecuteCommandResponse:
|
475
|
+
"""
|
476
|
+
Execute a bash command in an environment
|
477
|
+
|
478
|
+
Args:
|
479
|
+
command: The bash command to execute.
|
480
|
+
|
481
|
+
command_timeout: Timeout for command execution in seconds (default: 300).
|
482
|
+
|
483
|
+
extra_headers: Send extra headers
|
484
|
+
|
485
|
+
extra_query: Add additional query parameters to the request
|
486
|
+
|
487
|
+
extra_body: Add additional JSON properties to the request
|
488
|
+
|
489
|
+
timeout: Override the client-level default timeout for this request, in seconds
|
490
|
+
"""
|
491
|
+
if not session_id:
|
492
|
+
raise ValueError(f"Expected a non-empty value for `session_id` but received {session_id!r}")
|
493
|
+
return await self._post(
|
494
|
+
f"/sessions/{session_id}/exec",
|
495
|
+
body=await async_maybe_transform(
|
496
|
+
{
|
497
|
+
"command": command,
|
498
|
+
"command_timeout": command_timeout,
|
499
|
+
},
|
500
|
+
session_execute_command_params.SessionExecuteCommandParams,
|
501
|
+
),
|
502
|
+
options=make_request_options(
|
503
|
+
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
|
504
|
+
),
|
505
|
+
cast_to=SessionExecuteCommandResponse,
|
506
|
+
)
|
507
|
+
|
508
|
+
|
509
|
+
class SessionsResourceWithRawResponse:
|
510
|
+
def __init__(self, sessions: SessionsResource) -> None:
|
511
|
+
self._sessions = sessions
|
512
|
+
|
513
|
+
self.create = to_raw_response_wrapper(
|
514
|
+
sessions.create,
|
515
|
+
)
|
516
|
+
self.retrieve = to_raw_response_wrapper(
|
517
|
+
sessions.retrieve,
|
518
|
+
)
|
519
|
+
self.list = to_raw_response_wrapper(
|
520
|
+
sessions.list,
|
521
|
+
)
|
522
|
+
self.apply_diff = to_raw_response_wrapper(
|
523
|
+
sessions.apply_diff,
|
524
|
+
)
|
525
|
+
self.close = to_raw_response_wrapper(
|
526
|
+
sessions.close,
|
527
|
+
)
|
528
|
+
self.execute_command = to_raw_response_wrapper(
|
529
|
+
sessions.execute_command,
|
530
|
+
)
|
531
|
+
|
532
|
+
@cached_property
|
533
|
+
def verify(self) -> VerifyResourceWithRawResponse:
|
534
|
+
return VerifyResourceWithRawResponse(self._sessions.verify)
|
535
|
+
|
536
|
+
|
537
|
+
class AsyncSessionsResourceWithRawResponse:
|
538
|
+
def __init__(self, sessions: AsyncSessionsResource) -> None:
|
539
|
+
self._sessions = sessions
|
540
|
+
|
541
|
+
self.create = async_to_raw_response_wrapper(
|
542
|
+
sessions.create,
|
543
|
+
)
|
544
|
+
self.retrieve = async_to_raw_response_wrapper(
|
545
|
+
sessions.retrieve,
|
546
|
+
)
|
547
|
+
self.list = async_to_raw_response_wrapper(
|
548
|
+
sessions.list,
|
549
|
+
)
|
550
|
+
self.apply_diff = async_to_raw_response_wrapper(
|
551
|
+
sessions.apply_diff,
|
552
|
+
)
|
553
|
+
self.close = async_to_raw_response_wrapper(
|
554
|
+
sessions.close,
|
555
|
+
)
|
556
|
+
self.execute_command = async_to_raw_response_wrapper(
|
557
|
+
sessions.execute_command,
|
558
|
+
)
|
559
|
+
|
560
|
+
@cached_property
|
561
|
+
def verify(self) -> AsyncVerifyResourceWithRawResponse:
|
562
|
+
return AsyncVerifyResourceWithRawResponse(self._sessions.verify)
|
563
|
+
|
564
|
+
|
565
|
+
class SessionsResourceWithStreamingResponse:
|
566
|
+
def __init__(self, sessions: SessionsResource) -> None:
|
567
|
+
self._sessions = sessions
|
568
|
+
|
569
|
+
self.create = to_streamed_response_wrapper(
|
570
|
+
sessions.create,
|
571
|
+
)
|
572
|
+
self.retrieve = to_streamed_response_wrapper(
|
573
|
+
sessions.retrieve,
|
574
|
+
)
|
575
|
+
self.list = to_streamed_response_wrapper(
|
576
|
+
sessions.list,
|
577
|
+
)
|
578
|
+
self.apply_diff = to_streamed_response_wrapper(
|
579
|
+
sessions.apply_diff,
|
580
|
+
)
|
581
|
+
self.close = to_streamed_response_wrapper(
|
582
|
+
sessions.close,
|
583
|
+
)
|
584
|
+
self.execute_command = to_streamed_response_wrapper(
|
585
|
+
sessions.execute_command,
|
586
|
+
)
|
587
|
+
|
588
|
+
@cached_property
|
589
|
+
def verify(self) -> VerifyResourceWithStreamingResponse:
|
590
|
+
return VerifyResourceWithStreamingResponse(self._sessions.verify)
|
591
|
+
|
592
|
+
|
593
|
+
class AsyncSessionsResourceWithStreamingResponse:
|
594
|
+
def __init__(self, sessions: AsyncSessionsResource) -> None:
|
595
|
+
self._sessions = sessions
|
596
|
+
|
597
|
+
self.create = async_to_streamed_response_wrapper(
|
598
|
+
sessions.create,
|
599
|
+
)
|
600
|
+
self.retrieve = async_to_streamed_response_wrapper(
|
601
|
+
sessions.retrieve,
|
602
|
+
)
|
603
|
+
self.list = async_to_streamed_response_wrapper(
|
604
|
+
sessions.list,
|
605
|
+
)
|
606
|
+
self.apply_diff = async_to_streamed_response_wrapper(
|
607
|
+
sessions.apply_diff,
|
608
|
+
)
|
609
|
+
self.close = async_to_streamed_response_wrapper(
|
610
|
+
sessions.close,
|
611
|
+
)
|
612
|
+
self.execute_command = async_to_streamed_response_wrapper(
|
613
|
+
sessions.execute_command,
|
614
|
+
)
|
615
|
+
|
616
|
+
@cached_property
|
617
|
+
def verify(self) -> AsyncVerifyResourceWithStreamingResponse:
|
618
|
+
return AsyncVerifyResourceWithStreamingResponse(self._sessions.verify)
|