Skip to content

Commit f9e63d9

Browse files
feat(api): api update
1 parent 54549d7 commit f9e63d9

6 files changed

Lines changed: 289 additions & 2 deletions

File tree

.stats.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
configured_endpoints: 102
1+
configured_endpoints: 103
22
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/runloop-ai%2Frunloop-a8e2289b32b616e0bd7e15995a6553d0335bd21e30617a013d07450f8f5a7a20.yml
33
openapi_spec_hash: cd13a7af1ffe64c7ce8753f87786e01f
4-
config_hash: 457068371129b47b67f0f2d6b8267368
4+
config_hash: b9de5d96e095a7e749a8c1fc3536c308

api.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,7 @@ Methods:
9595
- <code title="post /v1/devboxes/{id}/create_tunnel">client.devboxes.<a href="./src/runloop_api_client/resources/devboxes/devboxes.py">create_tunnel</a>(id, \*\*<a href="src/runloop_api_client/types/devbox_create_tunnel_params.py">params</a>) -> <a href="./src/runloop_api_client/types/devbox_tunnel_view.py">DevboxTunnelView</a></code>
9696
- <code title="post /v1/devboxes/disk_snapshots/{id}/delete">client.devboxes.<a href="./src/runloop_api_client/resources/devboxes/devboxes.py">delete_disk_snapshot</a>(id) -> object</code>
9797
- <code title="post /v1/devboxes/{id}/download_file">client.devboxes.<a href="./src/runloop_api_client/resources/devboxes/devboxes.py">download_file</a>(id, \*\*<a href="src/runloop_api_client/types/devbox_download_file_params.py">params</a>) -> BinaryAPIResponse</code>
98+
- <code title="post /v1/devboxes/{id}/execute">client.devboxes.<a href="./src/runloop_api_client/resources/devboxes/devboxes.py">execute</a>(id, \*\*<a href="src/runloop_api_client/types/devbox_execute_params.py">params</a>) -> <a href="./src/runloop_api_client/types/devbox_async_execution_detail_view.py">DevboxAsyncExecutionDetailView</a></code>
9899
- <code title="post /v1/devboxes/{id}/execute_async">client.devboxes.<a href="./src/runloop_api_client/resources/devboxes/devboxes.py">execute_async</a>(id, \*\*<a href="src/runloop_api_client/types/devbox_execute_async_params.py">params</a>) -> <a href="./src/runloop_api_client/types/devbox_async_execution_detail_view.py">DevboxAsyncExecutionDetailView</a></code>
99100
- <code title="post /v1/devboxes/{id}/execute_sync">client.devboxes.<a href="./src/runloop_api_client/resources/devboxes/devboxes.py">execute_sync</a>(id, \*\*<a href="src/runloop_api_client/types/devbox_execute_sync_params.py">params</a>) -> <a href="./src/runloop_api_client/types/devbox_execution_detail_view.py">DevboxExecutionDetailView</a></code>
100101
- <code title="post /v1/devboxes/{id}/keep_alive">client.devboxes.<a href="./src/runloop_api_client/resources/devboxes/devboxes.py">keep_alive</a>(id) -> object</code>

src/runloop_api_client/resources/devboxes/devboxes.py

Lines changed: 145 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
devbox_list_params,
2828
devbox_create_params,
2929
devbox_update_params,
30+
devbox_execute_params,
3031
devbox_upload_file_params,
3132
devbox_execute_sync_params,
3233
devbox_create_tunnel_params,
@@ -719,6 +720,72 @@ def download_file(
719720
cast_to=BinaryAPIResponse,
720721
)
721722

723+
def execute(
724+
self,
725+
id: str,
726+
*,
727+
command: str,
728+
command_id: str,
729+
shell_name: Optional[str] | NotGiven = NOT_GIVEN,
730+
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
731+
# The extra values given here take precedence over values defined on the client or passed to this method.
732+
extra_headers: Headers | None = None,
733+
extra_query: Query | None = None,
734+
extra_body: Body | None = None,
735+
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
736+
idempotency_key: str | None = None,
737+
) -> DevboxAsyncExecutionDetailView:
738+
"""
739+
Execute a command with a known command ID on a devbox, optimistically waiting
740+
for it to complete within the specified timeout. If it completes in time, return
741+
the result. If not, return a status indicating the command is still running.
742+
743+
Args:
744+
command: The command to execute via the Devbox shell. By default, commands are run from
745+
the user home directory unless shell_name is specified. If shell_name is
746+
specified the command is run from the directory based on the recent state of the
747+
persistent shell.
748+
749+
command_id: The command ID for idempotency and tracking
750+
751+
shell_name: The name of the persistent shell to create or use if already created. When using
752+
a persistent shell, the command will run from the directory at the end of the
753+
previous command and environment variables will be preserved.
754+
755+
extra_headers: Send extra headers
756+
757+
extra_query: Add additional query parameters to the request
758+
759+
extra_body: Add additional JSON properties to the request
760+
761+
timeout: Override the client-level default timeout for this request, in seconds
762+
763+
idempotency_key: Specify a custom idempotency key for this request
764+
"""
765+
if not id:
766+
raise ValueError(f"Expected a non-empty value for `id` but received {id!r}")
767+
if not is_given(timeout) and self._client.timeout == DEFAULT_TIMEOUT:
768+
timeout = 600
769+
return self._post(
770+
f"/v1/devboxes/{id}/execute",
771+
body=maybe_transform(
772+
{
773+
"command": command,
774+
"command_id": command_id,
775+
"shell_name": shell_name,
776+
},
777+
devbox_execute_params.DevboxExecuteParams,
778+
),
779+
options=make_request_options(
780+
extra_headers=extra_headers,
781+
extra_query=extra_query,
782+
extra_body=extra_body,
783+
timeout=timeout,
784+
idempotency_key=idempotency_key,
785+
),
786+
cast_to=DevboxAsyncExecutionDetailView,
787+
)
788+
722789
def execute_async(
723790
self,
724791
id: str,
@@ -1981,6 +2048,72 @@ async def download_file(
19812048
cast_to=AsyncBinaryAPIResponse,
19822049
)
19832050

2051+
async def execute(
2052+
self,
2053+
id: str,
2054+
*,
2055+
command: str,
2056+
command_id: str,
2057+
shell_name: Optional[str] | NotGiven = NOT_GIVEN,
2058+
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
2059+
# The extra values given here take precedence over values defined on the client or passed to this method.
2060+
extra_headers: Headers | None = None,
2061+
extra_query: Query | None = None,
2062+
extra_body: Body | None = None,
2063+
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
2064+
idempotency_key: str | None = None,
2065+
) -> DevboxAsyncExecutionDetailView:
2066+
"""
2067+
Execute a command with a known command ID on a devbox, optimistically waiting
2068+
for it to complete within the specified timeout. If it completes in time, return
2069+
the result. If not, return a status indicating the command is still running.
2070+
2071+
Args:
2072+
command: The command to execute via the Devbox shell. By default, commands are run from
2073+
the user home directory unless shell_name is specified. If shell_name is
2074+
specified the command is run from the directory based on the recent state of the
2075+
persistent shell.
2076+
2077+
command_id: The command ID for idempotency and tracking
2078+
2079+
shell_name: The name of the persistent shell to create or use if already created. When using
2080+
a persistent shell, the command will run from the directory at the end of the
2081+
previous command and environment variables will be preserved.
2082+
2083+
extra_headers: Send extra headers
2084+
2085+
extra_query: Add additional query parameters to the request
2086+
2087+
extra_body: Add additional JSON properties to the request
2088+
2089+
timeout: Override the client-level default timeout for this request, in seconds
2090+
2091+
idempotency_key: Specify a custom idempotency key for this request
2092+
"""
2093+
if not id:
2094+
raise ValueError(f"Expected a non-empty value for `id` but received {id!r}")
2095+
if not is_given(timeout) and self._client.timeout == DEFAULT_TIMEOUT:
2096+
timeout = 600
2097+
return await self._post(
2098+
f"/v1/devboxes/{id}/execute",
2099+
body=await async_maybe_transform(
2100+
{
2101+
"command": command,
2102+
"command_id": command_id,
2103+
"shell_name": shell_name,
2104+
},
2105+
devbox_execute_params.DevboxExecuteParams,
2106+
),
2107+
options=make_request_options(
2108+
extra_headers=extra_headers,
2109+
extra_query=extra_query,
2110+
extra_body=extra_body,
2111+
timeout=timeout,
2112+
idempotency_key=idempotency_key,
2113+
),
2114+
cast_to=DevboxAsyncExecutionDetailView,
2115+
)
2116+
19842117
async def execute_async(
19852118
self,
19862119
id: str,
@@ -2690,6 +2823,9 @@ def __init__(self, devboxes: DevboxesResource) -> None:
26902823
devboxes.download_file,
26912824
BinaryAPIResponse,
26922825
)
2826+
self.execute = to_raw_response_wrapper(
2827+
devboxes.execute,
2828+
)
26932829
self.execute_async = to_raw_response_wrapper(
26942830
devboxes.execute_async,
26952831
)
@@ -2784,6 +2920,9 @@ def __init__(self, devboxes: AsyncDevboxesResource) -> None:
27842920
devboxes.download_file,
27852921
AsyncBinaryAPIResponse,
27862922
)
2923+
self.execute = async_to_raw_response_wrapper(
2924+
devboxes.execute,
2925+
)
27872926
self.execute_async = async_to_raw_response_wrapper(
27882927
devboxes.execute_async,
27892928
)
@@ -2878,6 +3017,9 @@ def __init__(self, devboxes: DevboxesResource) -> None:
28783017
devboxes.download_file,
28793018
StreamedBinaryAPIResponse,
28803019
)
3020+
self.execute = to_streamed_response_wrapper(
3021+
devboxes.execute,
3022+
)
28813023
self.execute_async = to_streamed_response_wrapper(
28823024
devboxes.execute_async,
28833025
)
@@ -2972,6 +3114,9 @@ def __init__(self, devboxes: AsyncDevboxesResource) -> None:
29723114
devboxes.download_file,
29733115
AsyncStreamedBinaryAPIResponse,
29743116
)
3117+
self.execute = async_to_streamed_response_wrapper(
3118+
devboxes.execute,
3119+
)
29753120
self.execute_async = async_to_streamed_response_wrapper(
29763121
devboxes.execute_async,
29773122
)

src/runloop_api_client/types/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141
from .secret_update_params import SecretUpdateParams as SecretUpdateParams
4242
from .benchmark_list_params import BenchmarkListParams as BenchmarkListParams
4343
from .blueprint_list_params import BlueprintListParams as BlueprintListParams
44+
from .devbox_execute_params import DevboxExecuteParams as DevboxExecuteParams
4445
from .blueprint_preview_view import BlueprintPreviewView as BlueprintPreviewView
4546
from .object_download_params import ObjectDownloadParams as ObjectDownloadParams
4647
from .repository_list_params import RepositoryListParams as RepositoryListParams
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2+
3+
from __future__ import annotations
4+
5+
from typing import Optional
6+
from typing_extensions import Required, TypedDict
7+
8+
__all__ = ["DevboxExecuteParams"]
9+
10+
11+
class DevboxExecuteParams(TypedDict, total=False):
12+
command: Required[str]
13+
"""The command to execute via the Devbox shell.
14+
15+
By default, commands are run from the user home directory unless shell_name is
16+
specified. If shell_name is specified the command is run from the directory
17+
based on the recent state of the persistent shell.
18+
"""
19+
20+
command_id: Required[str]
21+
"""The command ID for idempotency and tracking"""
22+
23+
shell_name: Optional[str]
24+
"""The name of the persistent shell to create or use if already created.
25+
26+
When using a persistent shell, the command will run from the directory at the
27+
end of the previous command and environment variables will be preserved.
28+
"""

tests/api_resources/test_devboxes.py

Lines changed: 112 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -405,6 +405,62 @@ def test_path_params_download_file(self, client: Runloop) -> None:
405405
path="path",
406406
)
407407

408+
@parametrize
409+
def test_method_execute(self, client: Runloop) -> None:
410+
devbox = client.devboxes.execute(
411+
id="id",
412+
command="command",
413+
command_id="command_id",
414+
)
415+
assert_matches_type(DevboxAsyncExecutionDetailView, devbox, path=["response"])
416+
417+
@parametrize
418+
def test_method_execute_with_all_params(self, client: Runloop) -> None:
419+
devbox = client.devboxes.execute(
420+
id="id",
421+
command="command",
422+
command_id="command_id",
423+
shell_name="shell_name",
424+
)
425+
assert_matches_type(DevboxAsyncExecutionDetailView, devbox, path=["response"])
426+
427+
@parametrize
428+
def test_raw_response_execute(self, client: Runloop) -> None:
429+
response = client.devboxes.with_raw_response.execute(
430+
id="id",
431+
command="command",
432+
command_id="command_id",
433+
)
434+
435+
assert response.is_closed is True
436+
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
437+
devbox = response.parse()
438+
assert_matches_type(DevboxAsyncExecutionDetailView, devbox, path=["response"])
439+
440+
@parametrize
441+
def test_streaming_response_execute(self, client: Runloop) -> None:
442+
with client.devboxes.with_streaming_response.execute(
443+
id="id",
444+
command="command",
445+
command_id="command_id",
446+
) as response:
447+
assert not response.is_closed
448+
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
449+
450+
devbox = response.parse()
451+
assert_matches_type(DevboxAsyncExecutionDetailView, devbox, path=["response"])
452+
453+
assert cast(Any, response.is_closed) is True
454+
455+
@parametrize
456+
def test_path_params_execute(self, client: Runloop) -> None:
457+
with pytest.raises(ValueError, match=r"Expected a non-empty value for `id` but received ''"):
458+
client.devboxes.with_raw_response.execute(
459+
id="",
460+
command="command",
461+
command_id="command_id",
462+
)
463+
408464
@parametrize
409465
def test_method_execute_async(self, client: Runloop) -> None:
410466
devbox = client.devboxes.execute_async(
@@ -1625,6 +1681,62 @@ async def test_path_params_download_file(self, async_client: AsyncRunloop) -> No
16251681
path="path",
16261682
)
16271683

1684+
@parametrize
1685+
async def test_method_execute(self, async_client: AsyncRunloop) -> None:
1686+
devbox = await async_client.devboxes.execute(
1687+
id="id",
1688+
command="command",
1689+
command_id="command_id",
1690+
)
1691+
assert_matches_type(DevboxAsyncExecutionDetailView, devbox, path=["response"])
1692+
1693+
@parametrize
1694+
async def test_method_execute_with_all_params(self, async_client: AsyncRunloop) -> None:
1695+
devbox = await async_client.devboxes.execute(
1696+
id="id",
1697+
command="command",
1698+
command_id="command_id",
1699+
shell_name="shell_name",
1700+
)
1701+
assert_matches_type(DevboxAsyncExecutionDetailView, devbox, path=["response"])
1702+
1703+
@parametrize
1704+
async def test_raw_response_execute(self, async_client: AsyncRunloop) -> None:
1705+
response = await async_client.devboxes.with_raw_response.execute(
1706+
id="id",
1707+
command="command",
1708+
command_id="command_id",
1709+
)
1710+
1711+
assert response.is_closed is True
1712+
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
1713+
devbox = await response.parse()
1714+
assert_matches_type(DevboxAsyncExecutionDetailView, devbox, path=["response"])
1715+
1716+
@parametrize
1717+
async def test_streaming_response_execute(self, async_client: AsyncRunloop) -> None:
1718+
async with async_client.devboxes.with_streaming_response.execute(
1719+
id="id",
1720+
command="command",
1721+
command_id="command_id",
1722+
) as response:
1723+
assert not response.is_closed
1724+
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
1725+
1726+
devbox = await response.parse()
1727+
assert_matches_type(DevboxAsyncExecutionDetailView, devbox, path=["response"])
1728+
1729+
assert cast(Any, response.is_closed) is True
1730+
1731+
@parametrize
1732+
async def test_path_params_execute(self, async_client: AsyncRunloop) -> None:
1733+
with pytest.raises(ValueError, match=r"Expected a non-empty value for `id` but received ''"):
1734+
await async_client.devboxes.with_raw_response.execute(
1735+
id="",
1736+
command="command",
1737+
command_id="command_id",
1738+
)
1739+
16281740
@parametrize
16291741
async def test_method_execute_async(self, async_client: AsyncRunloop) -> None:
16301742
devbox = await async_client.devboxes.execute_async(

0 commit comments

Comments
 (0)