|
2 | 2 |
|
3 | 3 | from __future__ import annotations |
4 | 4 |
|
5 | | -from typing import Dict, Mapping, Iterable, Optional, TypedDict, cast |
| 5 | +from typing import Dict, List, Mapping, Iterable, Optional, TypedDict, cast |
6 | 6 | from typing_extensions import Literal |
7 | 7 |
|
8 | 8 | import httpx |
|
35 | 35 | devbox_execute_async_params, |
36 | 36 | devbox_remove_tunnel_params, |
37 | 37 | devbox_snapshot_disk_params, |
| 38 | + devbox_wait_for_command_params, |
38 | 39 | devbox_read_file_contents_params, |
39 | 40 | devbox_list_disk_snapshots_params, |
40 | 41 | devbox_snapshot_disk_async_params, |
@@ -1407,6 +1408,66 @@ def upload_file( |
1407 | 1408 | cast_to=object, |
1408 | 1409 | ) |
1409 | 1410 |
|
| 1411 | + def wait_for_command( |
| 1412 | + self, |
| 1413 | + id: str, |
| 1414 | + *, |
| 1415 | + statuses: List[ |
| 1416 | + Literal[ |
| 1417 | + "provisioning", "initializing", "running", "suspending", "suspended", "resuming", "failure", "shutdown" |
| 1418 | + ] |
| 1419 | + ], |
| 1420 | + timeout_seconds: Optional[int] | NotGiven = NOT_GIVEN, |
| 1421 | + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. |
| 1422 | + # The extra values given here take precedence over values defined on the client or passed to this method. |
| 1423 | + extra_headers: Headers | None = None, |
| 1424 | + extra_query: Query | None = None, |
| 1425 | + extra_body: Body | None = None, |
| 1426 | + timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, |
| 1427 | + idempotency_key: str | None = None, |
| 1428 | + ) -> DevboxView: |
| 1429 | + """ |
| 1430 | + Polls the Devbox's status until it reaches one of the desired statuses or times |
| 1431 | + out. |
| 1432 | +
|
| 1433 | + Args: |
| 1434 | + statuses: The Devbox statuses to wait for. At least one status must be provided. The |
| 1435 | + devbox will be returned as soon as it reaches any of the provided statuses. |
| 1436 | +
|
| 1437 | + timeout_seconds: (Optional) Timeout in seconds to wait for the status, up to 30 seconds. Defaults |
| 1438 | + to 10 seconds. |
| 1439 | +
|
| 1440 | + extra_headers: Send extra headers |
| 1441 | +
|
| 1442 | + extra_query: Add additional query parameters to the request |
| 1443 | +
|
| 1444 | + extra_body: Add additional JSON properties to the request |
| 1445 | +
|
| 1446 | + timeout: Override the client-level default timeout for this request, in seconds |
| 1447 | +
|
| 1448 | + idempotency_key: Specify a custom idempotency key for this request |
| 1449 | + """ |
| 1450 | + if not id: |
| 1451 | + raise ValueError(f"Expected a non-empty value for `id` but received {id!r}") |
| 1452 | + return self._post( |
| 1453 | + f"/v1/devboxes/{id}/wait_for_status", |
| 1454 | + body=maybe_transform( |
| 1455 | + { |
| 1456 | + "statuses": statuses, |
| 1457 | + "timeout_seconds": timeout_seconds, |
| 1458 | + }, |
| 1459 | + devbox_wait_for_command_params.DevboxWaitForCommandParams, |
| 1460 | + ), |
| 1461 | + options=make_request_options( |
| 1462 | + extra_headers=extra_headers, |
| 1463 | + extra_query=extra_query, |
| 1464 | + extra_body=extra_body, |
| 1465 | + timeout=timeout, |
| 1466 | + idempotency_key=idempotency_key, |
| 1467 | + ), |
| 1468 | + cast_to=DevboxView, |
| 1469 | + ) |
| 1470 | + |
1410 | 1471 | def write_file_contents( |
1411 | 1472 | self, |
1412 | 1473 | id: str, |
@@ -2735,6 +2796,66 @@ async def upload_file( |
2735 | 2796 | cast_to=object, |
2736 | 2797 | ) |
2737 | 2798 |
|
| 2799 | + async def wait_for_command( |
| 2800 | + self, |
| 2801 | + id: str, |
| 2802 | + *, |
| 2803 | + statuses: List[ |
| 2804 | + Literal[ |
| 2805 | + "provisioning", "initializing", "running", "suspending", "suspended", "resuming", "failure", "shutdown" |
| 2806 | + ] |
| 2807 | + ], |
| 2808 | + timeout_seconds: Optional[int] | NotGiven = NOT_GIVEN, |
| 2809 | + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. |
| 2810 | + # The extra values given here take precedence over values defined on the client or passed to this method. |
| 2811 | + extra_headers: Headers | None = None, |
| 2812 | + extra_query: Query | None = None, |
| 2813 | + extra_body: Body | None = None, |
| 2814 | + timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, |
| 2815 | + idempotency_key: str | None = None, |
| 2816 | + ) -> DevboxView: |
| 2817 | + """ |
| 2818 | + Polls the Devbox's status until it reaches one of the desired statuses or times |
| 2819 | + out. |
| 2820 | +
|
| 2821 | + Args: |
| 2822 | + statuses: The Devbox statuses to wait for. At least one status must be provided. The |
| 2823 | + devbox will be returned as soon as it reaches any of the provided statuses. |
| 2824 | +
|
| 2825 | + timeout_seconds: (Optional) Timeout in seconds to wait for the status, up to 30 seconds. Defaults |
| 2826 | + to 10 seconds. |
| 2827 | +
|
| 2828 | + extra_headers: Send extra headers |
| 2829 | +
|
| 2830 | + extra_query: Add additional query parameters to the request |
| 2831 | +
|
| 2832 | + extra_body: Add additional JSON properties to the request |
| 2833 | +
|
| 2834 | + timeout: Override the client-level default timeout for this request, in seconds |
| 2835 | +
|
| 2836 | + idempotency_key: Specify a custom idempotency key for this request |
| 2837 | + """ |
| 2838 | + if not id: |
| 2839 | + raise ValueError(f"Expected a non-empty value for `id` but received {id!r}") |
| 2840 | + return await self._post( |
| 2841 | + f"/v1/devboxes/{id}/wait_for_status", |
| 2842 | + body=await async_maybe_transform( |
| 2843 | + { |
| 2844 | + "statuses": statuses, |
| 2845 | + "timeout_seconds": timeout_seconds, |
| 2846 | + }, |
| 2847 | + devbox_wait_for_command_params.DevboxWaitForCommandParams, |
| 2848 | + ), |
| 2849 | + options=make_request_options( |
| 2850 | + extra_headers=extra_headers, |
| 2851 | + extra_query=extra_query, |
| 2852 | + extra_body=extra_body, |
| 2853 | + timeout=timeout, |
| 2854 | + idempotency_key=idempotency_key, |
| 2855 | + ), |
| 2856 | + cast_to=DevboxView, |
| 2857 | + ) |
| 2858 | + |
2738 | 2859 | async def write_file_contents( |
2739 | 2860 | self, |
2740 | 2861 | id: str, |
@@ -2862,6 +2983,9 @@ def __init__(self, devboxes: DevboxesResource) -> None: |
2862 | 2983 | self.upload_file = to_raw_response_wrapper( |
2863 | 2984 | devboxes.upload_file, |
2864 | 2985 | ) |
| 2986 | + self.wait_for_command = to_raw_response_wrapper( |
| 2987 | + devboxes.wait_for_command, |
| 2988 | + ) |
2865 | 2989 | self.write_file_contents = to_raw_response_wrapper( |
2866 | 2990 | devboxes.write_file_contents, |
2867 | 2991 | ) |
@@ -2959,6 +3083,9 @@ def __init__(self, devboxes: AsyncDevboxesResource) -> None: |
2959 | 3083 | self.upload_file = async_to_raw_response_wrapper( |
2960 | 3084 | devboxes.upload_file, |
2961 | 3085 | ) |
| 3086 | + self.wait_for_command = async_to_raw_response_wrapper( |
| 3087 | + devboxes.wait_for_command, |
| 3088 | + ) |
2962 | 3089 | self.write_file_contents = async_to_raw_response_wrapper( |
2963 | 3090 | devboxes.write_file_contents, |
2964 | 3091 | ) |
@@ -3056,6 +3183,9 @@ def __init__(self, devboxes: DevboxesResource) -> None: |
3056 | 3183 | self.upload_file = to_streamed_response_wrapper( |
3057 | 3184 | devboxes.upload_file, |
3058 | 3185 | ) |
| 3186 | + self.wait_for_command = to_streamed_response_wrapper( |
| 3187 | + devboxes.wait_for_command, |
| 3188 | + ) |
3059 | 3189 | self.write_file_contents = to_streamed_response_wrapper( |
3060 | 3190 | devboxes.write_file_contents, |
3061 | 3191 | ) |
@@ -3153,6 +3283,9 @@ def __init__(self, devboxes: AsyncDevboxesResource) -> None: |
3153 | 3283 | self.upload_file = async_to_streamed_response_wrapper( |
3154 | 3284 | devboxes.upload_file, |
3155 | 3285 | ) |
| 3286 | + self.wait_for_command = async_to_streamed_response_wrapper( |
| 3287 | + devboxes.wait_for_command, |
| 3288 | + ) |
3156 | 3289 | self.write_file_contents = async_to_streamed_response_wrapper( |
3157 | 3290 | devboxes.write_file_contents, |
3158 | 3291 | ) |
|
0 commit comments