|
27 | 27 | devbox_list_params, |
28 | 28 | devbox_create_params, |
29 | 29 | devbox_update_params, |
| 30 | + devbox_execute_params, |
30 | 31 | devbox_upload_file_params, |
31 | 32 | devbox_execute_sync_params, |
32 | 33 | devbox_create_tunnel_params, |
@@ -719,6 +720,72 @@ def download_file( |
719 | 720 | cast_to=BinaryAPIResponse, |
720 | 721 | ) |
721 | 722 |
|
| 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 | + |
722 | 789 | def execute_async( |
723 | 790 | self, |
724 | 791 | id: str, |
@@ -1981,6 +2048,72 @@ async def download_file( |
1981 | 2048 | cast_to=AsyncBinaryAPIResponse, |
1982 | 2049 | ) |
1983 | 2050 |
|
| 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 | + |
1984 | 2117 | async def execute_async( |
1985 | 2118 | self, |
1986 | 2119 | id: str, |
@@ -2690,6 +2823,9 @@ def __init__(self, devboxes: DevboxesResource) -> None: |
2690 | 2823 | devboxes.download_file, |
2691 | 2824 | BinaryAPIResponse, |
2692 | 2825 | ) |
| 2826 | + self.execute = to_raw_response_wrapper( |
| 2827 | + devboxes.execute, |
| 2828 | + ) |
2693 | 2829 | self.execute_async = to_raw_response_wrapper( |
2694 | 2830 | devboxes.execute_async, |
2695 | 2831 | ) |
@@ -2784,6 +2920,9 @@ def __init__(self, devboxes: AsyncDevboxesResource) -> None: |
2784 | 2920 | devboxes.download_file, |
2785 | 2921 | AsyncBinaryAPIResponse, |
2786 | 2922 | ) |
| 2923 | + self.execute = async_to_raw_response_wrapper( |
| 2924 | + devboxes.execute, |
| 2925 | + ) |
2787 | 2926 | self.execute_async = async_to_raw_response_wrapper( |
2788 | 2927 | devboxes.execute_async, |
2789 | 2928 | ) |
@@ -2878,6 +3017,9 @@ def __init__(self, devboxes: DevboxesResource) -> None: |
2878 | 3017 | devboxes.download_file, |
2879 | 3018 | StreamedBinaryAPIResponse, |
2880 | 3019 | ) |
| 3020 | + self.execute = to_streamed_response_wrapper( |
| 3021 | + devboxes.execute, |
| 3022 | + ) |
2881 | 3023 | self.execute_async = to_streamed_response_wrapper( |
2882 | 3024 | devboxes.execute_async, |
2883 | 3025 | ) |
@@ -2972,6 +3114,9 @@ def __init__(self, devboxes: AsyncDevboxesResource) -> None: |
2972 | 3114 | devboxes.download_file, |
2973 | 3115 | AsyncStreamedBinaryAPIResponse, |
2974 | 3116 | ) |
| 3117 | + self.execute = async_to_streamed_response_wrapper( |
| 3118 | + devboxes.execute, |
| 3119 | + ) |
2975 | 3120 | self.execute_async = async_to_streamed_response_wrapper( |
2976 | 3121 | devboxes.execute_async, |
2977 | 3122 | ) |
|
0 commit comments