runloop_api_client 0.61.0__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.
Files changed (187) hide show
  1. runloop_api_client/__init__.py +92 -0
  2. runloop_api_client/_base_client.py +1995 -0
  3. runloop_api_client/_client.py +668 -0
  4. runloop_api_client/_compat.py +219 -0
  5. runloop_api_client/_constants.py +14 -0
  6. runloop_api_client/_exceptions.py +108 -0
  7. runloop_api_client/_files.py +123 -0
  8. runloop_api_client/_models.py +835 -0
  9. runloop_api_client/_qs.py +150 -0
  10. runloop_api_client/_resource.py +43 -0
  11. runloop_api_client/_response.py +832 -0
  12. runloop_api_client/_streaming.py +520 -0
  13. runloop_api_client/_types.py +260 -0
  14. runloop_api_client/_utils/__init__.py +64 -0
  15. runloop_api_client/_utils/_compat.py +45 -0
  16. runloop_api_client/_utils/_datetime_parse.py +136 -0
  17. runloop_api_client/_utils/_logs.py +25 -0
  18. runloop_api_client/_utils/_proxy.py +65 -0
  19. runloop_api_client/_utils/_reflection.py +42 -0
  20. runloop_api_client/_utils/_resources_proxy.py +24 -0
  21. runloop_api_client/_utils/_streams.py +12 -0
  22. runloop_api_client/_utils/_sync.py +86 -0
  23. runloop_api_client/_utils/_transform.py +457 -0
  24. runloop_api_client/_utils/_typing.py +156 -0
  25. runloop_api_client/_utils/_utils.py +421 -0
  26. runloop_api_client/_version.py +4 -0
  27. runloop_api_client/lib/.keep +4 -0
  28. runloop_api_client/lib/polling.py +75 -0
  29. runloop_api_client/lib/polling_async.py +60 -0
  30. runloop_api_client/pagination.py +761 -0
  31. runloop_api_client/py.typed +0 -0
  32. runloop_api_client/resources/__init__.py +103 -0
  33. runloop_api_client/resources/benchmarks/__init__.py +33 -0
  34. runloop_api_client/resources/benchmarks/benchmarks.py +982 -0
  35. runloop_api_client/resources/benchmarks/runs.py +587 -0
  36. runloop_api_client/resources/blueprints.py +1206 -0
  37. runloop_api_client/resources/devboxes/__init__.py +89 -0
  38. runloop_api_client/resources/devboxes/browsers.py +267 -0
  39. runloop_api_client/resources/devboxes/computers.py +648 -0
  40. runloop_api_client/resources/devboxes/devboxes.py +3414 -0
  41. runloop_api_client/resources/devboxes/disk_snapshots.py +519 -0
  42. runloop_api_client/resources/devboxes/executions.py +1059 -0
  43. runloop_api_client/resources/devboxes/logs.py +197 -0
  44. runloop_api_client/resources/objects.py +860 -0
  45. runloop_api_client/resources/repositories.py +717 -0
  46. runloop_api_client/resources/scenarios/__init__.py +47 -0
  47. runloop_api_client/resources/scenarios/runs.py +949 -0
  48. runloop_api_client/resources/scenarios/scenarios.py +1079 -0
  49. runloop_api_client/resources/scenarios/scorers.py +629 -0
  50. runloop_api_client/resources/secrets.py +500 -0
  51. runloop_api_client/types/__init__.py +95 -0
  52. runloop_api_client/types/benchmark_create_params.py +40 -0
  53. runloop_api_client/types/benchmark_definitions_params.py +15 -0
  54. runloop_api_client/types/benchmark_list_params.py +15 -0
  55. runloop_api_client/types/benchmark_list_public_params.py +15 -0
  56. runloop_api_client/types/benchmark_run_list_view.py +19 -0
  57. runloop_api_client/types/benchmark_run_view.py +51 -0
  58. runloop_api_client/types/benchmark_start_run_params.py +25 -0
  59. runloop_api_client/types/benchmark_update_params.py +40 -0
  60. runloop_api_client/types/benchmark_view.py +45 -0
  61. runloop_api_client/types/benchmarks/__init__.py +6 -0
  62. runloop_api_client/types/benchmarks/run_list_params.py +18 -0
  63. runloop_api_client/types/benchmarks/run_list_scenario_runs_params.py +18 -0
  64. runloop_api_client/types/blueprint_build_log.py +16 -0
  65. runloop_api_client/types/blueprint_build_logs_list_view.py +16 -0
  66. runloop_api_client/types/blueprint_build_parameters.py +87 -0
  67. runloop_api_client/types/blueprint_create_params.py +90 -0
  68. runloop_api_client/types/blueprint_list_params.py +18 -0
  69. runloop_api_client/types/blueprint_list_public_params.py +18 -0
  70. runloop_api_client/types/blueprint_list_view.py +19 -0
  71. runloop_api_client/types/blueprint_preview_params.py +90 -0
  72. runloop_api_client/types/blueprint_preview_view.py +10 -0
  73. runloop_api_client/types/blueprint_view.py +86 -0
  74. runloop_api_client/types/devbox_async_execution_detail_view.py +40 -0
  75. runloop_api_client/types/devbox_create_params.py +70 -0
  76. runloop_api_client/types/devbox_create_ssh_key_response.py +16 -0
  77. runloop_api_client/types/devbox_create_tunnel_params.py +12 -0
  78. runloop_api_client/types/devbox_download_file_params.py +15 -0
  79. runloop_api_client/types/devbox_execute_async_params.py +25 -0
  80. runloop_api_client/types/devbox_execute_params.py +34 -0
  81. runloop_api_client/types/devbox_execute_sync_params.py +25 -0
  82. runloop_api_client/types/devbox_execution_detail_view.py +24 -0
  83. runloop_api_client/types/devbox_list_disk_snapshots_params.py +29 -0
  84. runloop_api_client/types/devbox_list_params.py +20 -0
  85. runloop_api_client/types/devbox_list_view.py +19 -0
  86. runloop_api_client/types/devbox_read_file_contents_params.py +15 -0
  87. runloop_api_client/types/devbox_read_file_contents_response.py +7 -0
  88. runloop_api_client/types/devbox_remove_tunnel_params.py +12 -0
  89. runloop_api_client/types/devbox_snapshot_disk_async_params.py +16 -0
  90. runloop_api_client/types/devbox_snapshot_disk_params.py +16 -0
  91. runloop_api_client/types/devbox_snapshot_list_view.py +19 -0
  92. runloop_api_client/types/devbox_snapshot_view.py +24 -0
  93. runloop_api_client/types/devbox_tunnel_view.py +16 -0
  94. runloop_api_client/types/devbox_update_params.py +16 -0
  95. runloop_api_client/types/devbox_upload_file_params.py +19 -0
  96. runloop_api_client/types/devbox_view.py +94 -0
  97. runloop_api_client/types/devbox_wait_for_command_params.py +25 -0
  98. runloop_api_client/types/devbox_write_file_contents_params.py +18 -0
  99. runloop_api_client/types/devboxes/__init__.py +32 -0
  100. runloop_api_client/types/devboxes/browser_create_params.py +13 -0
  101. runloop_api_client/types/devboxes/browser_view.py +25 -0
  102. runloop_api_client/types/devboxes/computer_create_params.py +24 -0
  103. runloop_api_client/types/devboxes/computer_keyboard_interaction_params.py +16 -0
  104. runloop_api_client/types/devboxes/computer_keyboard_interaction_response.py +15 -0
  105. runloop_api_client/types/devboxes/computer_mouse_interaction_params.py +30 -0
  106. runloop_api_client/types/devboxes/computer_mouse_interaction_response.py +15 -0
  107. runloop_api_client/types/devboxes/computer_screen_interaction_params.py +12 -0
  108. runloop_api_client/types/devboxes/computer_screen_interaction_response.py +15 -0
  109. runloop_api_client/types/devboxes/computer_view.py +19 -0
  110. runloop_api_client/types/devboxes/devbox_logs_list_view.py +39 -0
  111. runloop_api_client/types/devboxes/devbox_snapshot_async_status_view.py +20 -0
  112. runloop_api_client/types/devboxes/disk_snapshot_list_params.py +29 -0
  113. runloop_api_client/types/devboxes/disk_snapshot_update_params.py +16 -0
  114. runloop_api_client/types/devboxes/execution_execute_async_params.py +25 -0
  115. runloop_api_client/types/devboxes/execution_execute_sync_params.py +25 -0
  116. runloop_api_client/types/devboxes/execution_kill_params.py +18 -0
  117. runloop_api_client/types/devboxes/execution_retrieve_params.py +14 -0
  118. runloop_api_client/types/devboxes/execution_stream_stderr_updates_params.py +14 -0
  119. runloop_api_client/types/devboxes/execution_stream_stdout_updates_params.py +14 -0
  120. runloop_api_client/types/devboxes/execution_update_chunk.py +15 -0
  121. runloop_api_client/types/devboxes/log_list_params.py +15 -0
  122. runloop_api_client/types/input_context.py +15 -0
  123. runloop_api_client/types/input_context_param.py +16 -0
  124. runloop_api_client/types/input_context_update_param.py +16 -0
  125. runloop_api_client/types/object_create_params.py +19 -0
  126. runloop_api_client/types/object_download_params.py +12 -0
  127. runloop_api_client/types/object_download_url_view.py +10 -0
  128. runloop_api_client/types/object_list_params.py +27 -0
  129. runloop_api_client/types/object_list_public_params.py +27 -0
  130. runloop_api_client/types/object_list_view.py +22 -0
  131. runloop_api_client/types/object_view.py +28 -0
  132. runloop_api_client/types/repository_connection_list_view.py +19 -0
  133. runloop_api_client/types/repository_connection_view.py +16 -0
  134. runloop_api_client/types/repository_create_params.py +22 -0
  135. runloop_api_client/types/repository_inspection_details.py +77 -0
  136. runloop_api_client/types/repository_inspection_list_view.py +13 -0
  137. runloop_api_client/types/repository_list_params.py +21 -0
  138. runloop_api_client/types/repository_manifest_view.py +158 -0
  139. runloop_api_client/types/repository_refresh_params.py +16 -0
  140. runloop_api_client/types/scenario_create_params.py +53 -0
  141. runloop_api_client/types/scenario_definition_list_view.py +19 -0
  142. runloop_api_client/types/scenario_environment.py +25 -0
  143. runloop_api_client/types/scenario_environment_param.py +27 -0
  144. runloop_api_client/types/scenario_list_params.py +21 -0
  145. runloop_api_client/types/scenario_list_public_params.py +18 -0
  146. runloop_api_client/types/scenario_run_list_view.py +19 -0
  147. runloop_api_client/types/scenario_run_view.py +50 -0
  148. runloop_api_client/types/scenario_start_run_params.py +28 -0
  149. runloop_api_client/types/scenario_update_params.py +46 -0
  150. runloop_api_client/types/scenario_view.py +57 -0
  151. runloop_api_client/types/scenarios/__init__.py +14 -0
  152. runloop_api_client/types/scenarios/run_list_params.py +18 -0
  153. runloop_api_client/types/scenarios/scorer_create_params.py +18 -0
  154. runloop_api_client/types/scenarios/scorer_create_response.py +16 -0
  155. runloop_api_client/types/scenarios/scorer_list_params.py +15 -0
  156. runloop_api_client/types/scenarios/scorer_list_response.py +16 -0
  157. runloop_api_client/types/scenarios/scorer_retrieve_response.py +16 -0
  158. runloop_api_client/types/scenarios/scorer_update_params.py +18 -0
  159. runloop_api_client/types/scenarios/scorer_update_response.py +16 -0
  160. runloop_api_client/types/scenarios/scorer_validate_params.py +17 -0
  161. runloop_api_client/types/scenarios/scorer_validate_response.py +23 -0
  162. runloop_api_client/types/scoring_contract.py +13 -0
  163. runloop_api_client/types/scoring_contract_param.py +15 -0
  164. runloop_api_client/types/scoring_contract_result_view.py +16 -0
  165. runloop_api_client/types/scoring_contract_update_param.py +15 -0
  166. runloop_api_client/types/scoring_function.py +135 -0
  167. runloop_api_client/types/scoring_function_param.py +131 -0
  168. runloop_api_client/types/scoring_function_result_view.py +21 -0
  169. runloop_api_client/types/secret_create_params.py +23 -0
  170. runloop_api_client/types/secret_list_params.py +12 -0
  171. runloop_api_client/types/secret_list_view.py +22 -0
  172. runloop_api_client/types/secret_update_params.py +16 -0
  173. runloop_api_client/types/secret_view.py +22 -0
  174. runloop_api_client/types/shared/__init__.py +6 -0
  175. runloop_api_client/types/shared/after_idle.py +15 -0
  176. runloop_api_client/types/shared/code_mount_parameters.py +24 -0
  177. runloop_api_client/types/shared/launch_parameters.py +79 -0
  178. runloop_api_client/types/shared/run_profile.py +33 -0
  179. runloop_api_client/types/shared_params/__init__.py +6 -0
  180. runloop_api_client/types/shared_params/after_idle.py +15 -0
  181. runloop_api_client/types/shared_params/code_mount_parameters.py +25 -0
  182. runloop_api_client/types/shared_params/launch_parameters.py +81 -0
  183. runloop_api_client/types/shared_params/run_profile.py +34 -0
  184. runloop_api_client-0.61.0.dist-info/METADATA +496 -0
  185. runloop_api_client-0.61.0.dist-info/RECORD +187 -0
  186. runloop_api_client-0.61.0.dist-info/WHEEL +4 -0
  187. runloop_api_client-0.61.0.dist-info/licenses/LICENSE +7 -0
@@ -0,0 +1,3414 @@
1
+ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2
+
3
+ from __future__ import annotations
4
+
5
+ import typing_extensions
6
+ from typing import Dict, List, Mapping, Iterable, Optional, TypedDict, cast
7
+ from typing_extensions import Literal
8
+
9
+ import httpx
10
+
11
+ # uuid_utils is not typed
12
+ from uuid_utils import uuid7 # type: ignore
13
+
14
+ from .logs import (
15
+ LogsResource,
16
+ AsyncLogsResource,
17
+ LogsResourceWithRawResponse,
18
+ AsyncLogsResourceWithRawResponse,
19
+ LogsResourceWithStreamingResponse,
20
+ AsyncLogsResourceWithStreamingResponse,
21
+ )
22
+ from ...types import (
23
+ devbox_list_params,
24
+ devbox_create_params,
25
+ devbox_update_params,
26
+ devbox_execute_params,
27
+ devbox_upload_file_params,
28
+ devbox_execute_sync_params,
29
+ devbox_create_tunnel_params,
30
+ devbox_download_file_params,
31
+ devbox_execute_async_params,
32
+ devbox_remove_tunnel_params,
33
+ devbox_snapshot_disk_params,
34
+ devbox_wait_for_command_params,
35
+ devbox_read_file_contents_params,
36
+ devbox_list_disk_snapshots_params,
37
+ devbox_snapshot_disk_async_params,
38
+ devbox_write_file_contents_params,
39
+ )
40
+ from ..._types import NOT_GIVEN, Body, Omit, Query, Headers, NotGiven, FileTypes, omit, not_given
41
+ from ..._utils import is_given, extract_files, maybe_transform, deepcopy_minimal, async_maybe_transform
42
+ from .browsers import (
43
+ BrowsersResource,
44
+ AsyncBrowsersResource,
45
+ BrowsersResourceWithRawResponse,
46
+ AsyncBrowsersResourceWithRawResponse,
47
+ BrowsersResourceWithStreamingResponse,
48
+ AsyncBrowsersResourceWithStreamingResponse,
49
+ )
50
+ from ..._compat import cached_property
51
+ from .computers import (
52
+ ComputersResource,
53
+ AsyncComputersResource,
54
+ ComputersResourceWithRawResponse,
55
+ AsyncComputersResourceWithRawResponse,
56
+ ComputersResourceWithStreamingResponse,
57
+ AsyncComputersResourceWithStreamingResponse,
58
+ )
59
+ from .executions import (
60
+ ExecutionsResource,
61
+ AsyncExecutionsResource,
62
+ ExecutionsResourceWithRawResponse,
63
+ AsyncExecutionsResourceWithRawResponse,
64
+ ExecutionsResourceWithStreamingResponse,
65
+ AsyncExecutionsResourceWithStreamingResponse,
66
+ )
67
+ from ..._resource import SyncAPIResource, AsyncAPIResource
68
+ from ..._response import (
69
+ BinaryAPIResponse,
70
+ AsyncBinaryAPIResponse,
71
+ StreamedBinaryAPIResponse,
72
+ AsyncStreamedBinaryAPIResponse,
73
+ to_raw_response_wrapper,
74
+ to_streamed_response_wrapper,
75
+ async_to_raw_response_wrapper,
76
+ to_custom_raw_response_wrapper,
77
+ async_to_streamed_response_wrapper,
78
+ to_custom_streamed_response_wrapper,
79
+ async_to_custom_raw_response_wrapper,
80
+ async_to_custom_streamed_response_wrapper,
81
+ )
82
+ from ..._constants import DEFAULT_TIMEOUT
83
+ from ...pagination import (
84
+ SyncDevboxesCursorIDPage,
85
+ AsyncDevboxesCursorIDPage,
86
+ SyncDiskSnapshotsCursorIDPage,
87
+ AsyncDiskSnapshotsCursorIDPage,
88
+ )
89
+ from ..._exceptions import RunloopError, APIStatusError, APITimeoutError
90
+ from ...lib.polling import PollingConfig, poll_until
91
+ from ..._base_client import AsyncPaginator, make_request_options
92
+ from .disk_snapshots import (
93
+ DiskSnapshotsResource,
94
+ AsyncDiskSnapshotsResource,
95
+ DiskSnapshotsResourceWithRawResponse,
96
+ AsyncDiskSnapshotsResourceWithRawResponse,
97
+ DiskSnapshotsResourceWithStreamingResponse,
98
+ AsyncDiskSnapshotsResourceWithStreamingResponse,
99
+ )
100
+ from ...lib.polling_async import async_poll_until
101
+ from ...types.devbox_view import DevboxView
102
+ from ...types.devbox_tunnel_view import DevboxTunnelView
103
+ from ...types.devbox_snapshot_view import DevboxSnapshotView
104
+ from ...types.shared.launch_parameters import LaunchParameters as SharedLaunchParameters
105
+ from ...types.devbox_execution_detail_view import DevboxExecutionDetailView
106
+ from ...types.devbox_create_ssh_key_response import DevboxCreateSSHKeyResponse
107
+ from ...types.shared_params.launch_parameters import LaunchParameters
108
+ from ...types.devbox_async_execution_detail_view import DevboxAsyncExecutionDetailView
109
+ from ...types.shared_params.code_mount_parameters import CodeMountParameters
110
+
111
+ __all__ = ["DevboxesResource", "AsyncDevboxesResource", "DevboxRequestArgs"]
112
+
113
+ DEVBOX_BOOTING_STATES = frozenset(("provisioning", "initializing"))
114
+
115
+
116
+ # Type for request arguments that combine polling config with additional request options
117
+ class DevboxRequestArgs(TypedDict, total=False):
118
+ polling_config: PollingConfig | None
119
+ extra_headers: Headers | None
120
+ extra_query: Query | None
121
+ extra_body: Body | None
122
+ timeout: float | httpx.Timeout | None | NotGiven
123
+
124
+
125
+ def placeholder_devbox_view(id: str) -> DevboxView:
126
+ return DevboxView(
127
+ id=id,
128
+ status="provisioning",
129
+ capabilities=[],
130
+ create_time_ms=0,
131
+ launch_parameters=SharedLaunchParameters(),
132
+ metadata={},
133
+ state_transitions=[],
134
+ )
135
+
136
+
137
+ class DevboxesResource(SyncAPIResource):
138
+ @cached_property
139
+ def disk_snapshots(self) -> DiskSnapshotsResource:
140
+ return DiskSnapshotsResource(self._client)
141
+
142
+ @cached_property
143
+ def browsers(self) -> BrowsersResource:
144
+ return BrowsersResource(self._client)
145
+
146
+ @cached_property
147
+ def computers(self) -> ComputersResource:
148
+ return ComputersResource(self._client)
149
+
150
+ @cached_property
151
+ def logs(self) -> LogsResource:
152
+ return LogsResource(self._client)
153
+
154
+ @cached_property
155
+ def executions(self) -> ExecutionsResource:
156
+ return ExecutionsResource(self._client)
157
+
158
+ @cached_property
159
+ def with_raw_response(self) -> DevboxesResourceWithRawResponse:
160
+ """
161
+ This property can be used as a prefix for any HTTP method call to return
162
+ the raw response object instead of the parsed content.
163
+
164
+ For more information, see https://www.github.com/runloopai/api-client-python#accessing-raw-response-data-eg-headers
165
+ """
166
+ return DevboxesResourceWithRawResponse(self)
167
+
168
+ @cached_property
169
+ def with_streaming_response(self) -> DevboxesResourceWithStreamingResponse:
170
+ """
171
+ An alternative to `.with_raw_response` that doesn't eagerly read the response body.
172
+
173
+ For more information, see https://www.github.com/runloopai/api-client-python#with_streaming_response
174
+ """
175
+ return DevboxesResourceWithStreamingResponse(self)
176
+
177
+ def create(
178
+ self,
179
+ *,
180
+ blueprint_id: Optional[str] | Omit = omit,
181
+ blueprint_name: Optional[str] | Omit = omit,
182
+ code_mounts: Optional[Iterable[CodeMountParameters]] | Omit = omit,
183
+ entrypoint: Optional[str] | Omit = omit,
184
+ environment_variables: Optional[Dict[str, str]] | Omit = omit,
185
+ file_mounts: Optional[Dict[str, str]] | Omit = omit,
186
+ launch_parameters: Optional[LaunchParameters] | Omit = omit,
187
+ metadata: Optional[Dict[str, str]] | Omit = omit,
188
+ name: Optional[str] | Omit = omit,
189
+ repo_connection_id: Optional[str] | Omit = omit,
190
+ secrets: Optional[Dict[str, str]] | Omit = omit,
191
+ snapshot_id: Optional[str] | Omit = omit,
192
+ # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
193
+ # The extra values given here take precedence over values defined on the client or passed to this method.
194
+ extra_headers: Headers | None = None,
195
+ extra_query: Query | None = None,
196
+ extra_body: Body | None = None,
197
+ timeout: float | httpx.Timeout | None | NotGiven = not_given,
198
+ idempotency_key: str | None = None,
199
+ ) -> DevboxView:
200
+ """Create a Devbox and begin the boot process.
201
+
202
+ The Devbox will initially launch in
203
+ the 'provisioning' state while Runloop allocates the necessary infrastructure.
204
+ It will transition to the 'initializing' state while the booted Devbox runs any
205
+ Runloop or user defined set up scripts. Finally, the Devbox will transition to
206
+ the 'running' state when it is ready for use.
207
+
208
+ Args:
209
+ blueprint_id: Blueprint ID to use for the Devbox. If none set, the Devbox will be created with
210
+ the default Runloop Devbox image. Only one of (Snapshot ID, Blueprint ID,
211
+ Blueprint name) should be specified.
212
+
213
+ blueprint_name: Name of Blueprint to use for the Devbox. When set, this will load the latest
214
+ successfully built Blueprint with the given name. Only one of (Snapshot ID,
215
+ Blueprint ID, Blueprint name) should be specified.
216
+
217
+ code_mounts: A list of code mounts to be included in the Devbox.
218
+
219
+ entrypoint: (Optional) When specified, the Devbox will run this script as its main
220
+ executable. The devbox lifecycle will be bound to entrypoint, shutting down when
221
+ the process is complete.
222
+
223
+ environment_variables: (Optional) Environment variables used to configure your Devbox.
224
+
225
+ file_mounts: (Optional) Map of paths and file contents to write before setup..
226
+
227
+ launch_parameters: Parameters to configure the resources and launch time behavior of the Devbox.
228
+
229
+ metadata: User defined metadata to attach to the devbox for organization.
230
+
231
+ name: (Optional) A user specified name to give the Devbox.
232
+
233
+ repo_connection_id: Repository connection id the devbox should source its base image from.
234
+
235
+ secrets: (Optional) Map of environment variable names to secret names. The secret values
236
+ will be securely injected as environment variables in the Devbox. Example:
237
+ {"DB_PASS": "DATABASE_PASSWORD"} sets environment variable 'DB_PASS' to the
238
+ value of secret 'DATABASE_PASSWORD'.
239
+
240
+ snapshot_id: Snapshot ID to use for the Devbox. Only one of (Snapshot ID, Blueprint ID,
241
+ Blueprint name) should be specified.
242
+
243
+ extra_headers: Send extra headers
244
+
245
+ extra_query: Add additional query parameters to the request
246
+
247
+ extra_body: Add additional JSON properties to the request
248
+
249
+ timeout: Override the client-level default timeout for this request, in seconds
250
+
251
+ idempotency_key: Specify a custom idempotency key for this request
252
+ """
253
+ return self._post(
254
+ "/v1/devboxes",
255
+ body=maybe_transform(
256
+ {
257
+ "blueprint_id": blueprint_id,
258
+ "blueprint_name": blueprint_name,
259
+ "code_mounts": code_mounts,
260
+ "entrypoint": entrypoint,
261
+ "environment_variables": environment_variables,
262
+ "file_mounts": file_mounts,
263
+ "launch_parameters": launch_parameters,
264
+ "metadata": metadata,
265
+ "name": name,
266
+ "repo_connection_id": repo_connection_id,
267
+ "secrets": secrets,
268
+ "snapshot_id": snapshot_id,
269
+ },
270
+ devbox_create_params.DevboxCreateParams,
271
+ ),
272
+ options=make_request_options(
273
+ extra_headers=extra_headers,
274
+ extra_query=extra_query,
275
+ extra_body=extra_body,
276
+ timeout=timeout,
277
+ idempotency_key=idempotency_key,
278
+ ),
279
+ cast_to=DevboxView,
280
+ )
281
+
282
+ def retrieve(
283
+ self,
284
+ id: str,
285
+ *,
286
+ # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
287
+ # The extra values given here take precedence over values defined on the client or passed to this method.
288
+ extra_headers: Headers | None = None,
289
+ extra_query: Query | None = None,
290
+ extra_body: Body | None = None,
291
+ timeout: float | httpx.Timeout | None | NotGiven = not_given,
292
+ ) -> DevboxView:
293
+ """
294
+ Get the latest details and status of a Devbox.
295
+
296
+ Args:
297
+ extra_headers: Send extra headers
298
+
299
+ extra_query: Add additional query parameters to the request
300
+
301
+ extra_body: Add additional JSON properties to the request
302
+
303
+ timeout: Override the client-level default timeout for this request, in seconds
304
+ """
305
+ if not id:
306
+ raise ValueError(f"Expected a non-empty value for `id` but received {id!r}")
307
+ return self._get(
308
+ f"/v1/devboxes/{id}",
309
+ options=make_request_options(
310
+ extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
311
+ ),
312
+ cast_to=DevboxView,
313
+ )
314
+
315
+ def update(
316
+ self,
317
+ id: str,
318
+ *,
319
+ metadata: Optional[Dict[str, str]] | Omit = omit,
320
+ name: Optional[str] | Omit = omit,
321
+ # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
322
+ # The extra values given here take precedence over values defined on the client or passed to this method.
323
+ extra_headers: Headers | None = None,
324
+ extra_query: Query | None = None,
325
+ extra_body: Body | None = None,
326
+ timeout: float | httpx.Timeout | None | NotGiven = not_given,
327
+ idempotency_key: str | None = None,
328
+ ) -> DevboxView:
329
+ """
330
+ Updates a devbox by doing a complete update the existing name,metadata fields.
331
+ It does not patch partial values.
332
+
333
+ Args:
334
+ metadata: User defined metadata to attach to the devbox for organization.
335
+
336
+ name: (Optional) A user specified name to give the Devbox.
337
+
338
+ extra_headers: Send extra headers
339
+
340
+ extra_query: Add additional query parameters to the request
341
+
342
+ extra_body: Add additional JSON properties to the request
343
+
344
+ timeout: Override the client-level default timeout for this request, in seconds
345
+
346
+ idempotency_key: Specify a custom idempotency key for this request
347
+ """
348
+ if not id:
349
+ raise ValueError(f"Expected a non-empty value for `id` but received {id!r}")
350
+ return self._post(
351
+ f"/v1/devboxes/{id}",
352
+ body=maybe_transform(
353
+ {
354
+ "metadata": metadata,
355
+ "name": name,
356
+ },
357
+ devbox_update_params.DevboxUpdateParams,
358
+ ),
359
+ options=make_request_options(
360
+ extra_headers=extra_headers,
361
+ extra_query=extra_query,
362
+ extra_body=extra_body,
363
+ timeout=timeout,
364
+ idempotency_key=idempotency_key,
365
+ ),
366
+ cast_to=DevboxView,
367
+ )
368
+
369
+ def await_running(
370
+ self,
371
+ id: str,
372
+ *,
373
+ # Use polling_config to configure the "long" polling behavior.
374
+ polling_config: PollingConfig | None = None,
375
+ ) -> DevboxView:
376
+ """Wait for a devbox to be in running state.
377
+
378
+ Args:
379
+ id: The ID of the devbox to wait for
380
+ config: Optional polling configuration
381
+ extra_headers: Send extra headers
382
+ extra_query: Add additional query parameters to the request
383
+ extra_body: Add additional JSON properties to the request
384
+ timeout: Override the client-level default timeout for this request, in seconds
385
+
386
+ Returns:
387
+ The devbox in running state
388
+
389
+ Raises:
390
+ PollingTimeout: If polling times out before devbox is running
391
+ RunloopError: If devbox enters a non-running terminal state
392
+ """
393
+
394
+ def wait_for_devbox_status() -> DevboxView:
395
+ # This wait_for_status endpoint polls the devbox status for 10 seconds until it reaches either running or failure.
396
+ # If it's neither, it will throw an error.
397
+ return self._post(
398
+ f"/v1/devboxes/{id}/wait_for_status",
399
+ body={"statuses": ["running", "failure", "shutdown"]},
400
+ cast_to=DevboxView,
401
+ )
402
+
403
+ def handle_timeout_error(error: Exception) -> DevboxView:
404
+ # Handle timeout errors by returning current devbox state to continue polling
405
+ if isinstance(error, APITimeoutError) or (
406
+ isinstance(error, APIStatusError) and error.response.status_code == 408
407
+ ):
408
+ # Return a placeholder result to continue polling
409
+ return placeholder_devbox_view(id)
410
+
411
+ # Re-raise other errors to stop polling
412
+ raise error
413
+
414
+ def is_done_booting(devbox: DevboxView) -> bool:
415
+ return devbox.status not in DEVBOX_BOOTING_STATES
416
+
417
+ devbox = poll_until(wait_for_devbox_status, is_done_booting, polling_config, handle_timeout_error)
418
+
419
+ if devbox.status != "running":
420
+ raise RunloopError(f"Devbox entered non-running terminal state: {devbox.status}")
421
+
422
+ return devbox
423
+
424
+ def create_and_await_running(
425
+ self,
426
+ *,
427
+ blueprint_id: Optional[str] | NotGiven = NOT_GIVEN,
428
+ blueprint_name: Optional[str] | NotGiven = NOT_GIVEN,
429
+ code_mounts: Optional[Iterable[CodeMountParameters]] | NotGiven = NOT_GIVEN,
430
+ entrypoint: Optional[str] | NotGiven = NOT_GIVEN,
431
+ environment_variables: Optional[Dict[str, str]] | NotGiven = NOT_GIVEN,
432
+ file_mounts: Optional[Dict[str, str]] | NotGiven = NOT_GIVEN,
433
+ launch_parameters: Optional[LaunchParameters] | NotGiven = NOT_GIVEN,
434
+ metadata: Optional[Dict[str, str]] | NotGiven = NOT_GIVEN,
435
+ name: Optional[str] | NotGiven = NOT_GIVEN,
436
+ polling_config: PollingConfig | None = None,
437
+ repo_connection_id: Optional[str] | NotGiven = NOT_GIVEN,
438
+ secrets: Optional[Dict[str, str]] | NotGiven = NOT_GIVEN,
439
+ snapshot_id: Optional[str] | NotGiven = NOT_GIVEN,
440
+ # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
441
+ # The extra values given here take precedence over values defined on the client or passed to this method.
442
+ extra_headers: Headers | None = None,
443
+ extra_query: Query | None = None,
444
+ extra_body: Body | None = None,
445
+ timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
446
+ idempotency_key: str | None = None,
447
+ ) -> DevboxView:
448
+ """Create a new devbox and wait for it to be in running state.
449
+
450
+ This is a wrapper around the `create` method that waits for the devbox to reach running state.
451
+
452
+ Args:
453
+ create_args: Arguments to pass to the `create` method. See the `create` method for detailed documentation.
454
+ request_args: Optional request arguments including polling configuration and additional request options
455
+
456
+ Returns:
457
+ The devbox in running state
458
+
459
+ Raises:
460
+ PollingTimeout: If polling times out before devbox is running
461
+ RunloopError: If devbox enters a non-running terminal state
462
+ """
463
+ # Pass all create_args to the underlying create method
464
+ devbox = self.create(
465
+ blueprint_id=blueprint_id,
466
+ blueprint_name=blueprint_name,
467
+ code_mounts=code_mounts,
468
+ entrypoint=entrypoint,
469
+ environment_variables=environment_variables,
470
+ file_mounts=file_mounts,
471
+ launch_parameters=launch_parameters,
472
+ metadata=metadata,
473
+ name=name,
474
+ repo_connection_id=repo_connection_id,
475
+ secrets=secrets,
476
+ snapshot_id=snapshot_id,
477
+ extra_headers=extra_headers,
478
+ extra_query=extra_query,
479
+ extra_body=extra_body,
480
+ timeout=timeout,
481
+ idempotency_key=idempotency_key,
482
+ )
483
+
484
+ return self.await_running(
485
+ devbox.id,
486
+ polling_config=polling_config,
487
+ )
488
+
489
+ def list(
490
+ self,
491
+ *,
492
+ limit: int | Omit = omit,
493
+ starting_after: str | Omit = omit,
494
+ status: Literal[
495
+ "provisioning", "initializing", "running", "suspending", "suspended", "resuming", "failure", "shutdown"
496
+ ]
497
+ | Omit = omit,
498
+ # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
499
+ # The extra values given here take precedence over values defined on the client or passed to this method.
500
+ extra_headers: Headers | None = None,
501
+ extra_query: Query | None = None,
502
+ extra_body: Body | None = None,
503
+ timeout: float | httpx.Timeout | None | NotGiven = not_given,
504
+ ) -> SyncDevboxesCursorIDPage[DevboxView]:
505
+ """
506
+ List all Devboxes while optionally filtering by status.
507
+
508
+ Args:
509
+ limit: The limit of items to return. Default is 20.
510
+
511
+ starting_after: Load the next page of data starting after the item with the given ID.
512
+
513
+ status: Filter by status
514
+
515
+ extra_headers: Send extra headers
516
+
517
+ extra_query: Add additional query parameters to the request
518
+
519
+ extra_body: Add additional JSON properties to the request
520
+
521
+ timeout: Override the client-level default timeout for this request, in seconds
522
+ """
523
+ return self._get_api_list(
524
+ "/v1/devboxes",
525
+ page=SyncDevboxesCursorIDPage[DevboxView],
526
+ options=make_request_options(
527
+ extra_headers=extra_headers,
528
+ extra_query=extra_query,
529
+ extra_body=extra_body,
530
+ timeout=timeout,
531
+ query=maybe_transform(
532
+ {
533
+ "limit": limit,
534
+ "starting_after": starting_after,
535
+ "status": status,
536
+ },
537
+ devbox_list_params.DevboxListParams,
538
+ ),
539
+ ),
540
+ model=DevboxView,
541
+ )
542
+
543
+ def create_ssh_key(
544
+ self,
545
+ id: str,
546
+ *,
547
+ # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
548
+ # The extra values given here take precedence over values defined on the client or passed to this method.
549
+ extra_headers: Headers | None = None,
550
+ extra_query: Query | None = None,
551
+ extra_body: Body | None = None,
552
+ timeout: float | httpx.Timeout | None | NotGiven = not_given,
553
+ idempotency_key: str | None = None,
554
+ ) -> DevboxCreateSSHKeyResponse:
555
+ """
556
+ Create an SSH key for a Devbox to enable remote access.
557
+
558
+ Args:
559
+ extra_headers: Send extra headers
560
+
561
+ extra_query: Add additional query parameters to the request
562
+
563
+ extra_body: Add additional JSON properties to the request
564
+
565
+ timeout: Override the client-level default timeout for this request, in seconds
566
+
567
+ idempotency_key: Specify a custom idempotency key for this request
568
+ """
569
+ if not id:
570
+ raise ValueError(f"Expected a non-empty value for `id` but received {id!r}")
571
+ return self._post(
572
+ f"/v1/devboxes/{id}/create_ssh_key",
573
+ options=make_request_options(
574
+ extra_headers=extra_headers,
575
+ extra_query=extra_query,
576
+ extra_body=extra_body,
577
+ timeout=timeout,
578
+ idempotency_key=idempotency_key,
579
+ ),
580
+ cast_to=DevboxCreateSSHKeyResponse,
581
+ )
582
+
583
+ def create_tunnel(
584
+ self,
585
+ id: str,
586
+ *,
587
+ port: int,
588
+ # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
589
+ # The extra values given here take precedence over values defined on the client or passed to this method.
590
+ extra_headers: Headers | None = None,
591
+ extra_query: Query | None = None,
592
+ extra_body: Body | None = None,
593
+ timeout: float | httpx.Timeout | None | NotGiven = not_given,
594
+ idempotency_key: str | None = None,
595
+ ) -> DevboxTunnelView:
596
+ """
597
+ Create a live tunnel to an available port on the Devbox.
598
+
599
+ Args:
600
+ port: Devbox port that tunnel will expose.
601
+
602
+ extra_headers: Send extra headers
603
+
604
+ extra_query: Add additional query parameters to the request
605
+
606
+ extra_body: Add additional JSON properties to the request
607
+
608
+ timeout: Override the client-level default timeout for this request, in seconds
609
+
610
+ idempotency_key: Specify a custom idempotency key for this request
611
+ """
612
+ if not id:
613
+ raise ValueError(f"Expected a non-empty value for `id` but received {id!r}")
614
+ return self._post(
615
+ f"/v1/devboxes/{id}/create_tunnel",
616
+ body=maybe_transform({"port": port}, devbox_create_tunnel_params.DevboxCreateTunnelParams),
617
+ options=make_request_options(
618
+ extra_headers=extra_headers,
619
+ extra_query=extra_query,
620
+ extra_body=extra_body,
621
+ timeout=timeout,
622
+ idempotency_key=idempotency_key,
623
+ ),
624
+ cast_to=DevboxTunnelView,
625
+ )
626
+
627
+ def delete_disk_snapshot(
628
+ self,
629
+ id: str,
630
+ *,
631
+ # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
632
+ # The extra values given here take precedence over values defined on the client or passed to this method.
633
+ extra_headers: Headers | None = None,
634
+ extra_query: Query | None = None,
635
+ extra_body: Body | None = None,
636
+ timeout: float | httpx.Timeout | None | NotGiven = not_given,
637
+ idempotency_key: str | None = None,
638
+ ) -> object:
639
+ """
640
+ Delete a previously taken disk snapshot of a Devbox.
641
+
642
+ Args:
643
+ extra_headers: Send extra headers
644
+
645
+ extra_query: Add additional query parameters to the request
646
+
647
+ extra_body: Add additional JSON properties to the request
648
+
649
+ timeout: Override the client-level default timeout for this request, in seconds
650
+
651
+ idempotency_key: Specify a custom idempotency key for this request
652
+ """
653
+ if not id:
654
+ raise ValueError(f"Expected a non-empty value for `id` but received {id!r}")
655
+ return self._post(
656
+ f"/v1/devboxes/disk_snapshots/{id}/delete",
657
+ options=make_request_options(
658
+ extra_headers=extra_headers,
659
+ extra_query=extra_query,
660
+ extra_body=extra_body,
661
+ timeout=timeout,
662
+ idempotency_key=idempotency_key,
663
+ ),
664
+ cast_to=object,
665
+ )
666
+
667
+ def download_file(
668
+ self,
669
+ id: str,
670
+ *,
671
+ path: str,
672
+ # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
673
+ # The extra values given here take precedence over values defined on the client or passed to this method.
674
+ extra_headers: Headers | None = None,
675
+ extra_query: Query | None = None,
676
+ extra_body: Body | None = None,
677
+ timeout: float | httpx.Timeout | None | NotGiven = not_given,
678
+ idempotency_key: str | None = None,
679
+ ) -> BinaryAPIResponse:
680
+ """
681
+ Download file contents of any type (binary, text, etc) from a specified path on
682
+ the Devbox.
683
+
684
+ Args:
685
+ path: The path on the Devbox filesystem to read the file from. Path is relative to
686
+ user home directory.
687
+
688
+ extra_headers: Send extra headers
689
+
690
+ extra_query: Add additional query parameters to the request
691
+
692
+ extra_body: Add additional JSON properties to the request
693
+
694
+ timeout: Override the client-level default timeout for this request, in seconds
695
+
696
+ idempotency_key: Specify a custom idempotency key for this request
697
+ """
698
+ if not id:
699
+ raise ValueError(f"Expected a non-empty value for `id` but received {id!r}")
700
+ if not is_given(timeout) and self._client.timeout == DEFAULT_TIMEOUT:
701
+ timeout = 600
702
+ extra_headers = {"Accept": "application/octet-stream", **(extra_headers or {})}
703
+ return self._post(
704
+ f"/v1/devboxes/{id}/download_file",
705
+ body=maybe_transform({"path": path}, devbox_download_file_params.DevboxDownloadFileParams),
706
+ options=make_request_options(
707
+ extra_headers=extra_headers,
708
+ extra_query=extra_query,
709
+ extra_body=extra_body,
710
+ timeout=timeout,
711
+ idempotency_key=idempotency_key,
712
+ ),
713
+ cast_to=BinaryAPIResponse,
714
+ )
715
+
716
+ def execute(
717
+ self,
718
+ id: str,
719
+ *,
720
+ command: str,
721
+ command_id: str,
722
+ optimistic_timeout: Optional[int] | Omit = omit,
723
+ shell_name: Optional[str] | Omit = omit,
724
+ # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
725
+ # The extra values given here take precedence over values defined on the client or passed to this method.
726
+ extra_headers: Headers | None = None,
727
+ extra_query: Query | None = None,
728
+ extra_body: Body | None = None,
729
+ timeout: float | httpx.Timeout | None | NotGiven = not_given,
730
+ idempotency_key: str | None = None,
731
+ ) -> DevboxAsyncExecutionDetailView:
732
+ """
733
+ Execute a command with a known command ID on a devbox, optimistically waiting
734
+ for it to complete within the specified timeout. If it completes in time, return
735
+ the result. If not, return a status indicating the command is still running.
736
+
737
+ Args:
738
+ command: The command to execute via the Devbox shell. By default, commands are run from
739
+ the user home directory unless shell_name is specified. If shell_name is
740
+ specified the command is run from the directory based on the recent state of the
741
+ persistent shell.
742
+
743
+ command_id: The command ID for idempotency and tracking
744
+
745
+ optimistic_timeout: Timeout in seconds to wait for command completion. Operation is not killed. Max
746
+ is 600 seconds.
747
+
748
+ shell_name: The name of the persistent shell to create or use if already created. When using
749
+ a persistent shell, the command will run from the directory at the end of the
750
+ previous command and environment variables will be preserved.
751
+
752
+ extra_headers: Send extra headers
753
+
754
+ extra_query: Add additional query parameters to the request
755
+
756
+ extra_body: Add additional JSON properties to the request
757
+
758
+ timeout: Override the client-level default timeout for this request, in seconds
759
+
760
+ idempotency_key: Specify a custom idempotency key for this request
761
+ """
762
+ if not id:
763
+ raise ValueError(f"Expected a non-empty value for `id` but received {id!r}")
764
+ if not is_given(timeout) and self._client.timeout == DEFAULT_TIMEOUT:
765
+ timeout = 600
766
+ return self._post(
767
+ f"/v1/devboxes/{id}/execute",
768
+ body=maybe_transform(
769
+ {
770
+ "command": command,
771
+ "command_id": command_id,
772
+ "optimistic_timeout": optimistic_timeout,
773
+ "shell_name": shell_name,
774
+ },
775
+ devbox_execute_params.DevboxExecuteParams,
776
+ ),
777
+ options=make_request_options(
778
+ extra_headers=extra_headers,
779
+ extra_query=extra_query,
780
+ extra_body=extra_body,
781
+ timeout=timeout,
782
+ idempotency_key=idempotency_key,
783
+ ),
784
+ cast_to=DevboxAsyncExecutionDetailView,
785
+ )
786
+
787
+ def execute_and_await_completion(
788
+ self,
789
+ devbox_id: str,
790
+ *,
791
+ command: str,
792
+ shell_name: Optional[str] | NotGiven = NOT_GIVEN,
793
+ polling_config: PollingConfig | None = None,
794
+ # The following are forwarded to the initial execute request
795
+ extra_headers: Headers | None = None,
796
+ extra_query: Query | None = None,
797
+ extra_body: Body | None = None,
798
+ timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
799
+ idempotency_key: str | None = None,
800
+ ) -> DevboxAsyncExecutionDetailView:
801
+ """
802
+ Execute a command and wait for it to complete with optimal latency for long running commands.
803
+
804
+ This method launches an execution with a generated command_id and first attempts to
805
+ return the result within the initial request's timeout. If the execution is not yet
806
+ complete, it switches to using wait_for_command to minimize latency while waiting.
807
+ """
808
+ command_id = str(uuid7()) # type: ignore
809
+ execution = self.execute(
810
+ devbox_id,
811
+ command=command,
812
+ command_id=command_id,
813
+ shell_name=shell_name,
814
+ extra_headers=extra_headers,
815
+ extra_query=extra_query,
816
+ extra_body=extra_body,
817
+ timeout=timeout,
818
+ idempotency_key=idempotency_key,
819
+ )
820
+ if execution.status == "completed":
821
+ return execution
822
+
823
+ def handle_timeout_error(error: Exception) -> DevboxAsyncExecutionDetailView:
824
+ if isinstance(error, APITimeoutError) or (
825
+ isinstance(error, APIStatusError) and error.response.status_code == 408
826
+ ):
827
+ return execution
828
+ raise error
829
+
830
+ def is_done(result: DevboxAsyncExecutionDetailView) -> bool:
831
+ return result.status == "completed"
832
+
833
+ return poll_until(
834
+ lambda: self.wait_for_command(execution.execution_id, devbox_id=devbox_id, statuses=["completed"]),
835
+ is_done,
836
+ polling_config,
837
+ handle_timeout_error,
838
+ )
839
+
840
+ def execute_async(
841
+ self,
842
+ id: str,
843
+ *,
844
+ command: str,
845
+ shell_name: Optional[str] | Omit = omit,
846
+ # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
847
+ # The extra values given here take precedence over values defined on the client or passed to this method.
848
+ extra_headers: Headers | None = None,
849
+ extra_query: Query | None = None,
850
+ extra_body: Body | None = None,
851
+ timeout: float | httpx.Timeout | None | NotGiven = not_given,
852
+ idempotency_key: str | None = None,
853
+ ) -> DevboxAsyncExecutionDetailView:
854
+ """
855
+ Execute the given command in the Devbox shell asynchronously and returns the
856
+ execution that can be used to track the command's progress.
857
+
858
+ Args:
859
+ command: The command to execute via the Devbox shell. By default, commands are run from
860
+ the user home directory unless shell_name is specified. If shell_name is
861
+ specified the command is run from the directory based on the recent state of the
862
+ persistent shell.
863
+
864
+ shell_name: The name of the persistent shell to create or use if already created. When using
865
+ a persistent shell, the command will run from the directory at the end of the
866
+ previous command and environment variables will be preserved.
867
+
868
+ extra_headers: Send extra headers
869
+
870
+ extra_query: Add additional query parameters to the request
871
+
872
+ extra_body: Add additional JSON properties to the request
873
+
874
+ timeout: Override the client-level default timeout for this request, in seconds
875
+
876
+ idempotency_key: Specify a custom idempotency key for this request
877
+ """
878
+ if not id:
879
+ raise ValueError(f"Expected a non-empty value for `id` but received {id!r}")
880
+ return self._post(
881
+ f"/v1/devboxes/{id}/execute_async",
882
+ body=maybe_transform(
883
+ {
884
+ "command": command,
885
+ "shell_name": shell_name,
886
+ },
887
+ devbox_execute_async_params.DevboxExecuteAsyncParams,
888
+ ),
889
+ options=make_request_options(
890
+ extra_headers=extra_headers,
891
+ extra_query=extra_query,
892
+ extra_body=extra_body,
893
+ timeout=timeout,
894
+ idempotency_key=idempotency_key,
895
+ ),
896
+ cast_to=DevboxAsyncExecutionDetailView,
897
+ )
898
+
899
+ @typing_extensions.deprecated("deprecated")
900
+ def execute_sync(
901
+ self,
902
+ id: str,
903
+ *,
904
+ command: str,
905
+ shell_name: Optional[str] | Omit = omit,
906
+ # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
907
+ # The extra values given here take precedence over values defined on the client or passed to this method.
908
+ extra_headers: Headers | None = None,
909
+ extra_query: Query | None = None,
910
+ extra_body: Body | None = None,
911
+ timeout: float | httpx.Timeout | None | NotGiven = not_given,
912
+ idempotency_key: str | None = None,
913
+ ) -> DevboxExecutionDetailView:
914
+ """
915
+ Execute a bash command in the Devbox shell, await the command completion and
916
+ return the output.
917
+
918
+ Args:
919
+ command: The command to execute via the Devbox shell. By default, commands are run from
920
+ the user home directory unless shell_name is specified. If shell_name is
921
+ specified the command is run from the directory based on the recent state of the
922
+ persistent shell.
923
+
924
+ shell_name: The name of the persistent shell to create or use if already created. When using
925
+ a persistent shell, the command will run from the directory at the end of the
926
+ previous command and environment variables will be preserved.
927
+
928
+ extra_headers: Send extra headers
929
+
930
+ extra_query: Add additional query parameters to the request
931
+
932
+ extra_body: Add additional JSON properties to the request
933
+
934
+ timeout: Override the client-level default timeout for this request, in seconds
935
+
936
+ idempotency_key: Specify a custom idempotency key for this request
937
+ """
938
+ if not id:
939
+ raise ValueError(f"Expected a non-empty value for `id` but received {id!r}")
940
+ if not is_given(timeout) and self._client.timeout == DEFAULT_TIMEOUT:
941
+ timeout = 600
942
+ return self._post(
943
+ f"/v1/devboxes/{id}/execute_sync",
944
+ body=maybe_transform(
945
+ {
946
+ "command": command,
947
+ "shell_name": shell_name,
948
+ },
949
+ devbox_execute_sync_params.DevboxExecuteSyncParams,
950
+ ),
951
+ options=make_request_options(
952
+ extra_headers=extra_headers,
953
+ extra_query=extra_query,
954
+ extra_body=extra_body,
955
+ timeout=timeout,
956
+ idempotency_key=idempotency_key,
957
+ ),
958
+ cast_to=DevboxExecutionDetailView,
959
+ )
960
+
961
+ def keep_alive(
962
+ self,
963
+ id: str,
964
+ *,
965
+ # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
966
+ # The extra values given here take precedence over values defined on the client or passed to this method.
967
+ extra_headers: Headers | None = None,
968
+ extra_query: Query | None = None,
969
+ extra_body: Body | None = None,
970
+ timeout: float | httpx.Timeout | None | NotGiven = not_given,
971
+ idempotency_key: str | None = None,
972
+ ) -> object:
973
+ """
974
+ Send a 'Keep Alive' signal to a running Devbox that is configured to shutdown on
975
+ idle so the idle time resets.
976
+
977
+ Args:
978
+ extra_headers: Send extra headers
979
+
980
+ extra_query: Add additional query parameters to the request
981
+
982
+ extra_body: Add additional JSON properties to the request
983
+
984
+ timeout: Override the client-level default timeout for this request, in seconds
985
+
986
+ idempotency_key: Specify a custom idempotency key for this request
987
+ """
988
+ if not id:
989
+ raise ValueError(f"Expected a non-empty value for `id` but received {id!r}")
990
+ return self._post(
991
+ f"/v1/devboxes/{id}/keep_alive",
992
+ options=make_request_options(
993
+ extra_headers=extra_headers,
994
+ extra_query=extra_query,
995
+ extra_body=extra_body,
996
+ timeout=timeout,
997
+ idempotency_key=idempotency_key,
998
+ ),
999
+ cast_to=object,
1000
+ )
1001
+
1002
+ def list_disk_snapshots(
1003
+ self,
1004
+ *,
1005
+ devbox_id: str | Omit = omit,
1006
+ limit: int | Omit = omit,
1007
+ metadata_key: str | Omit = omit,
1008
+ metadata_key_in: str | Omit = omit,
1009
+ starting_after: str | Omit = omit,
1010
+ # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
1011
+ # The extra values given here take precedence over values defined on the client or passed to this method.
1012
+ extra_headers: Headers | None = None,
1013
+ extra_query: Query | None = None,
1014
+ extra_body: Body | None = None,
1015
+ timeout: float | httpx.Timeout | None | NotGiven = not_given,
1016
+ ) -> SyncDiskSnapshotsCursorIDPage[DevboxSnapshotView]:
1017
+ """
1018
+ List all snapshots of a Devbox while optionally filtering by Devbox ID and
1019
+ metadata.
1020
+
1021
+ Args:
1022
+ devbox_id: Devbox ID to filter by.
1023
+
1024
+ limit: The limit of items to return. Default is 20.
1025
+
1026
+ metadata_key: Filter snapshots by metadata key-value pair. Can be used multiple times for
1027
+ different keys.
1028
+
1029
+ metadata_key_in: Filter snapshots by metadata key with multiple possible values (OR condition).
1030
+
1031
+ starting_after: Load the next page of data starting after the item with the given ID.
1032
+
1033
+ extra_headers: Send extra headers
1034
+
1035
+ extra_query: Add additional query parameters to the request
1036
+
1037
+ extra_body: Add additional JSON properties to the request
1038
+
1039
+ timeout: Override the client-level default timeout for this request, in seconds
1040
+ """
1041
+ return self._get_api_list(
1042
+ "/v1/devboxes/disk_snapshots",
1043
+ page=SyncDiskSnapshotsCursorIDPage[DevboxSnapshotView],
1044
+ options=make_request_options(
1045
+ extra_headers=extra_headers,
1046
+ extra_query=extra_query,
1047
+ extra_body=extra_body,
1048
+ timeout=timeout,
1049
+ query=maybe_transform(
1050
+ {
1051
+ "devbox_id": devbox_id,
1052
+ "limit": limit,
1053
+ "metadata_key": metadata_key,
1054
+ "metadata_key_in": metadata_key_in,
1055
+ "starting_after": starting_after,
1056
+ },
1057
+ devbox_list_disk_snapshots_params.DevboxListDiskSnapshotsParams,
1058
+ ),
1059
+ ),
1060
+ model=DevboxSnapshotView,
1061
+ )
1062
+
1063
+ def read_file_contents(
1064
+ self,
1065
+ id: str,
1066
+ *,
1067
+ file_path: str,
1068
+ # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
1069
+ # The extra values given here take precedence over values defined on the client or passed to this method.
1070
+ extra_headers: Headers | None = None,
1071
+ extra_query: Query | None = None,
1072
+ extra_body: Body | None = None,
1073
+ timeout: float | httpx.Timeout | None | NotGiven = not_given,
1074
+ idempotency_key: str | None = None,
1075
+ ) -> str:
1076
+ """Read file contents from a file on a Devbox as a UTF-8.
1077
+
1078
+ Note 'downloadFile'
1079
+ should be used for large files (greater than 100MB). Returns the file contents
1080
+ as a UTF-8 string.
1081
+
1082
+ Args:
1083
+ file_path: The path on the Devbox filesystem to read the file from. Path is relative to
1084
+ user home directory.
1085
+
1086
+ extra_headers: Send extra headers
1087
+
1088
+ extra_query: Add additional query parameters to the request
1089
+
1090
+ extra_body: Add additional JSON properties to the request
1091
+
1092
+ timeout: Override the client-level default timeout for this request, in seconds
1093
+
1094
+ idempotency_key: Specify a custom idempotency key for this request
1095
+ """
1096
+ if not id:
1097
+ raise ValueError(f"Expected a non-empty value for `id` but received {id!r}")
1098
+ if not is_given(timeout) and self._client.timeout == DEFAULT_TIMEOUT:
1099
+ timeout = 600
1100
+ extra_headers = {"Accept": "text/plain", **(extra_headers or {})}
1101
+ return self._post(
1102
+ f"/v1/devboxes/{id}/read_file_contents",
1103
+ body=maybe_transform(
1104
+ {"file_path": file_path}, devbox_read_file_contents_params.DevboxReadFileContentsParams
1105
+ ),
1106
+ options=make_request_options(
1107
+ extra_headers=extra_headers,
1108
+ extra_query=extra_query,
1109
+ extra_body=extra_body,
1110
+ timeout=timeout,
1111
+ idempotency_key=idempotency_key,
1112
+ ),
1113
+ cast_to=str,
1114
+ )
1115
+
1116
+ def remove_tunnel(
1117
+ self,
1118
+ id: str,
1119
+ *,
1120
+ port: int,
1121
+ # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
1122
+ # The extra values given here take precedence over values defined on the client or passed to this method.
1123
+ extra_headers: Headers | None = None,
1124
+ extra_query: Query | None = None,
1125
+ extra_body: Body | None = None,
1126
+ timeout: float | httpx.Timeout | None | NotGiven = not_given,
1127
+ idempotency_key: str | None = None,
1128
+ ) -> object:
1129
+ """
1130
+ Remove a previously opened tunnel on the Devbox.
1131
+
1132
+ Args:
1133
+ port: Devbox port that tunnel will expose.
1134
+
1135
+ extra_headers: Send extra headers
1136
+
1137
+ extra_query: Add additional query parameters to the request
1138
+
1139
+ extra_body: Add additional JSON properties to the request
1140
+
1141
+ timeout: Override the client-level default timeout for this request, in seconds
1142
+
1143
+ idempotency_key: Specify a custom idempotency key for this request
1144
+ """
1145
+ if not id:
1146
+ raise ValueError(f"Expected a non-empty value for `id` but received {id!r}")
1147
+ return self._post(
1148
+ f"/v1/devboxes/{id}/remove_tunnel",
1149
+ body=maybe_transform({"port": port}, devbox_remove_tunnel_params.DevboxRemoveTunnelParams),
1150
+ options=make_request_options(
1151
+ extra_headers=extra_headers,
1152
+ extra_query=extra_query,
1153
+ extra_body=extra_body,
1154
+ timeout=timeout,
1155
+ idempotency_key=idempotency_key,
1156
+ ),
1157
+ cast_to=object,
1158
+ )
1159
+
1160
+ def resume(
1161
+ self,
1162
+ id: str,
1163
+ *,
1164
+ # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
1165
+ # The extra values given here take precedence over values defined on the client or passed to this method.
1166
+ extra_headers: Headers | None = None,
1167
+ extra_query: Query | None = None,
1168
+ extra_body: Body | None = None,
1169
+ timeout: float | httpx.Timeout | None | NotGiven = not_given,
1170
+ idempotency_key: str | None = None,
1171
+ ) -> DevboxView:
1172
+ """Resume a suspended Devbox with the disk state captured as suspend time.
1173
+
1174
+ Note
1175
+ that any previously running processes or daemons will need to be restarted using
1176
+ the Devbox shell tools.
1177
+
1178
+ Args:
1179
+ extra_headers: Send extra headers
1180
+
1181
+ extra_query: Add additional query parameters to the request
1182
+
1183
+ extra_body: Add additional JSON properties to the request
1184
+
1185
+ timeout: Override the client-level default timeout for this request, in seconds
1186
+
1187
+ idempotency_key: Specify a custom idempotency key for this request
1188
+ """
1189
+ if not id:
1190
+ raise ValueError(f"Expected a non-empty value for `id` but received {id!r}")
1191
+ return self._post(
1192
+ f"/v1/devboxes/{id}/resume",
1193
+ options=make_request_options(
1194
+ extra_headers=extra_headers,
1195
+ extra_query=extra_query,
1196
+ extra_body=extra_body,
1197
+ timeout=timeout,
1198
+ idempotency_key=idempotency_key,
1199
+ ),
1200
+ cast_to=DevboxView,
1201
+ )
1202
+
1203
+ def shutdown(
1204
+ self,
1205
+ id: str,
1206
+ *,
1207
+ # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
1208
+ # The extra values given here take precedence over values defined on the client or passed to this method.
1209
+ extra_headers: Headers | None = None,
1210
+ extra_query: Query | None = None,
1211
+ extra_body: Body | None = None,
1212
+ timeout: float | httpx.Timeout | None | NotGiven = not_given,
1213
+ idempotency_key: str | None = None,
1214
+ ) -> DevboxView:
1215
+ """Shutdown a running Devbox.
1216
+
1217
+ This will permanently stop the Devbox. If you want to
1218
+ save the state of the Devbox, you should take a snapshot before shutting down or
1219
+ should suspend the Devbox instead of shutting down.
1220
+
1221
+ Args:
1222
+ extra_headers: Send extra headers
1223
+
1224
+ extra_query: Add additional query parameters to the request
1225
+
1226
+ extra_body: Add additional JSON properties to the request
1227
+
1228
+ timeout: Override the client-level default timeout for this request, in seconds
1229
+
1230
+ idempotency_key: Specify a custom idempotency key for this request
1231
+ """
1232
+ if not id:
1233
+ raise ValueError(f"Expected a non-empty value for `id` but received {id!r}")
1234
+ return self._post(
1235
+ f"/v1/devboxes/{id}/shutdown",
1236
+ options=make_request_options(
1237
+ extra_headers=extra_headers,
1238
+ extra_query=extra_query,
1239
+ extra_body=extra_body,
1240
+ timeout=timeout,
1241
+ idempotency_key=idempotency_key,
1242
+ ),
1243
+ cast_to=DevboxView,
1244
+ )
1245
+
1246
+ def snapshot_disk(
1247
+ self,
1248
+ id: str,
1249
+ *,
1250
+ metadata: Optional[Dict[str, str]] | Omit = omit,
1251
+ name: Optional[str] | Omit = omit,
1252
+ # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
1253
+ # The extra values given here take precedence over values defined on the client or passed to this method.
1254
+ extra_headers: Headers | None = None,
1255
+ extra_query: Query | None = None,
1256
+ extra_body: Body | None = None,
1257
+ timeout: float | httpx.Timeout | None | NotGiven = not_given,
1258
+ idempotency_key: str | None = None,
1259
+ ) -> DevboxSnapshotView:
1260
+ """
1261
+ Create a disk snapshot of a devbox with the specified name and metadata to
1262
+ enable launching future Devboxes with the same disk state.
1263
+
1264
+ Args:
1265
+ metadata: (Optional) Metadata used to describe the snapshot
1266
+
1267
+ name: (Optional) A user specified name to give the snapshot
1268
+
1269
+ extra_headers: Send extra headers
1270
+
1271
+ extra_query: Add additional query parameters to the request
1272
+
1273
+ extra_body: Add additional JSON properties to the request
1274
+
1275
+ timeout: Override the client-level default timeout for this request, in seconds
1276
+
1277
+ idempotency_key: Specify a custom idempotency key for this request
1278
+ """
1279
+ if not id:
1280
+ raise ValueError(f"Expected a non-empty value for `id` but received {id!r}")
1281
+ if not is_given(timeout) and self._client.timeout == DEFAULT_TIMEOUT:
1282
+ timeout = 600
1283
+ return self._post(
1284
+ f"/v1/devboxes/{id}/snapshot_disk",
1285
+ body=maybe_transform(
1286
+ {
1287
+ "metadata": metadata,
1288
+ "name": name,
1289
+ },
1290
+ devbox_snapshot_disk_params.DevboxSnapshotDiskParams,
1291
+ ),
1292
+ options=make_request_options(
1293
+ extra_headers=extra_headers,
1294
+ extra_query=extra_query,
1295
+ extra_body=extra_body,
1296
+ timeout=timeout,
1297
+ idempotency_key=idempotency_key,
1298
+ ),
1299
+ cast_to=DevboxSnapshotView,
1300
+ )
1301
+
1302
+ def snapshot_disk_async(
1303
+ self,
1304
+ id: str,
1305
+ *,
1306
+ metadata: Optional[Dict[str, str]] | Omit = omit,
1307
+ name: Optional[str] | Omit = omit,
1308
+ # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
1309
+ # The extra values given here take precedence over values defined on the client or passed to this method.
1310
+ extra_headers: Headers | None = None,
1311
+ extra_query: Query | None = None,
1312
+ extra_body: Body | None = None,
1313
+ timeout: float | httpx.Timeout | None | NotGiven = not_given,
1314
+ idempotency_key: str | None = None,
1315
+ ) -> DevboxSnapshotView:
1316
+ """
1317
+ Start an asynchronous disk snapshot of a devbox with the specified name and
1318
+ metadata. The snapshot operation will continue in the background and can be
1319
+ monitored using the query endpoint.
1320
+
1321
+ Args:
1322
+ metadata: (Optional) Metadata used to describe the snapshot
1323
+
1324
+ name: (Optional) A user specified name to give the snapshot
1325
+
1326
+ extra_headers: Send extra headers
1327
+
1328
+ extra_query: Add additional query parameters to the request
1329
+
1330
+ extra_body: Add additional JSON properties to the request
1331
+
1332
+ timeout: Override the client-level default timeout for this request, in seconds
1333
+
1334
+ idempotency_key: Specify a custom idempotency key for this request
1335
+ """
1336
+ if not id:
1337
+ raise ValueError(f"Expected a non-empty value for `id` but received {id!r}")
1338
+ return self._post(
1339
+ f"/v1/devboxes/{id}/snapshot_disk_async",
1340
+ body=maybe_transform(
1341
+ {
1342
+ "metadata": metadata,
1343
+ "name": name,
1344
+ },
1345
+ devbox_snapshot_disk_async_params.DevboxSnapshotDiskAsyncParams,
1346
+ ),
1347
+ options=make_request_options(
1348
+ extra_headers=extra_headers,
1349
+ extra_query=extra_query,
1350
+ extra_body=extra_body,
1351
+ timeout=timeout,
1352
+ idempotency_key=idempotency_key,
1353
+ ),
1354
+ cast_to=DevboxSnapshotView,
1355
+ )
1356
+
1357
+ def suspend(
1358
+ self,
1359
+ id: str,
1360
+ *,
1361
+ # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
1362
+ # The extra values given here take precedence over values defined on the client or passed to this method.
1363
+ extra_headers: Headers | None = None,
1364
+ extra_query: Query | None = None,
1365
+ extra_body: Body | None = None,
1366
+ timeout: float | httpx.Timeout | None | NotGiven = not_given,
1367
+ idempotency_key: str | None = None,
1368
+ ) -> DevboxView:
1369
+ """
1370
+ Suspend a running Devbox and create a disk snapshot to enable resuming the
1371
+ Devbox later with the same disk. Note this will not snapshot memory state such
1372
+ as running processes.
1373
+
1374
+ Args:
1375
+ extra_headers: Send extra headers
1376
+
1377
+ extra_query: Add additional query parameters to the request
1378
+
1379
+ extra_body: Add additional JSON properties to the request
1380
+
1381
+ timeout: Override the client-level default timeout for this request, in seconds
1382
+
1383
+ idempotency_key: Specify a custom idempotency key for this request
1384
+ """
1385
+ if not id:
1386
+ raise ValueError(f"Expected a non-empty value for `id` but received {id!r}")
1387
+ return self._post(
1388
+ f"/v1/devboxes/{id}/suspend",
1389
+ options=make_request_options(
1390
+ extra_headers=extra_headers,
1391
+ extra_query=extra_query,
1392
+ extra_body=extra_body,
1393
+ timeout=timeout,
1394
+ idempotency_key=idempotency_key,
1395
+ ),
1396
+ cast_to=DevboxView,
1397
+ )
1398
+
1399
+ def upload_file(
1400
+ self,
1401
+ id: str,
1402
+ *,
1403
+ path: str,
1404
+ file: FileTypes | Omit = omit,
1405
+ # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
1406
+ # The extra values given here take precedence over values defined on the client or passed to this method.
1407
+ extra_headers: Headers | None = None,
1408
+ extra_query: Query | None = None,
1409
+ extra_body: Body | None = None,
1410
+ timeout: float | httpx.Timeout | None | NotGiven = not_given,
1411
+ idempotency_key: str | None = None,
1412
+ ) -> object:
1413
+ """Upload file contents of any type (binary, text, etc) to a Devbox.
1414
+
1415
+ Note this API
1416
+ is suitable for large files (larger than 100MB) and efficiently uploads files
1417
+ via multipart form data.
1418
+
1419
+ Args:
1420
+ path: The path to write the file to on the Devbox. Path is relative to user home
1421
+ directory.
1422
+
1423
+ extra_headers: Send extra headers
1424
+
1425
+ extra_query: Add additional query parameters to the request
1426
+
1427
+ extra_body: Add additional JSON properties to the request
1428
+
1429
+ timeout: Override the client-level default timeout for this request, in seconds
1430
+
1431
+ idempotency_key: Specify a custom idempotency key for this request
1432
+ """
1433
+ if not id:
1434
+ raise ValueError(f"Expected a non-empty value for `id` but received {id!r}")
1435
+ if not is_given(timeout) and self._client.timeout == DEFAULT_TIMEOUT:
1436
+ timeout = 600
1437
+ body = deepcopy_minimal(
1438
+ {
1439
+ "path": path,
1440
+ "file": file,
1441
+ }
1442
+ )
1443
+ files = extract_files(cast(Mapping[str, object], body), paths=[["file"]])
1444
+ # It should be noted that the actual Content-Type header that will be
1445
+ # sent to the server will contain a `boundary` parameter, e.g.
1446
+ # multipart/form-data; boundary=---abc--
1447
+ extra_headers = {"Content-Type": "multipart/form-data", **(extra_headers or {})}
1448
+ return self._post(
1449
+ f"/v1/devboxes/{id}/upload_file",
1450
+ body=maybe_transform(body, devbox_upload_file_params.DevboxUploadFileParams),
1451
+ files=files,
1452
+ options=make_request_options(
1453
+ extra_headers=extra_headers,
1454
+ extra_query=extra_query,
1455
+ extra_body=extra_body,
1456
+ timeout=timeout,
1457
+ idempotency_key=idempotency_key,
1458
+ ),
1459
+ cast_to=object,
1460
+ )
1461
+
1462
+ def wait_for_command(
1463
+ self,
1464
+ execution_id: str,
1465
+ *,
1466
+ devbox_id: str,
1467
+ statuses: List[Literal["queued", "running", "completed"]],
1468
+ timeout_seconds: Optional[int] | Omit = omit,
1469
+ # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
1470
+ # The extra values given here take precedence over values defined on the client or passed to this method.
1471
+ extra_headers: Headers | None = None,
1472
+ extra_query: Query | None = None,
1473
+ extra_body: Body | None = None,
1474
+ timeout: float | httpx.Timeout | None | NotGiven = not_given,
1475
+ idempotency_key: str | None = None,
1476
+ ) -> DevboxAsyncExecutionDetailView:
1477
+ """
1478
+ Polls the asynchronous execution's status until it reaches one of the desired
1479
+ statuses or times out. Defaults to 60 seconds.
1480
+
1481
+ Args:
1482
+ statuses: The command execution statuses to wait for. At least one status must be
1483
+ provided. The command will be returned as soon as it reaches any of the provided
1484
+ statuses.
1485
+
1486
+ timeout_seconds: (Optional) Timeout in seconds to wait for the status, up to 60 seconds. Defaults
1487
+ to 60 seconds.
1488
+
1489
+ extra_headers: Send extra headers
1490
+
1491
+ extra_query: Add additional query parameters to the request
1492
+
1493
+ extra_body: Add additional JSON properties to the request
1494
+
1495
+ timeout: Override the client-level default timeout for this request, in seconds
1496
+
1497
+ idempotency_key: Specify a custom idempotency key for this request
1498
+ """
1499
+ if not devbox_id:
1500
+ raise ValueError(f"Expected a non-empty value for `devbox_id` but received {devbox_id!r}")
1501
+ if not execution_id:
1502
+ raise ValueError(f"Expected a non-empty value for `execution_id` but received {execution_id!r}")
1503
+ return self._post(
1504
+ f"/v1/devboxes/{devbox_id}/executions/{execution_id}/wait_for_status",
1505
+ body=maybe_transform(
1506
+ {
1507
+ "statuses": statuses,
1508
+ "timeout_seconds": timeout_seconds,
1509
+ },
1510
+ devbox_wait_for_command_params.DevboxWaitForCommandParams,
1511
+ ),
1512
+ options=make_request_options(
1513
+ extra_headers=extra_headers,
1514
+ extra_query=extra_query,
1515
+ extra_body=extra_body,
1516
+ timeout=timeout,
1517
+ idempotency_key=idempotency_key,
1518
+ ),
1519
+ cast_to=DevboxAsyncExecutionDetailView,
1520
+ )
1521
+
1522
+ def write_file_contents(
1523
+ self,
1524
+ id: str,
1525
+ *,
1526
+ contents: str,
1527
+ file_path: str,
1528
+ # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
1529
+ # The extra values given here take precedence over values defined on the client or passed to this method.
1530
+ extra_headers: Headers | None = None,
1531
+ extra_query: Query | None = None,
1532
+ extra_body: Body | None = None,
1533
+ timeout: float | httpx.Timeout | None | NotGiven = not_given,
1534
+ idempotency_key: str | None = None,
1535
+ ) -> DevboxExecutionDetailView:
1536
+ """Write UTF-8 string contents to a file at path on the Devbox.
1537
+
1538
+ Note for large
1539
+ files (larger than 100MB), the upload_file endpoint must be used.
1540
+
1541
+ Args:
1542
+ contents: The UTF-8 string contents to write to the file.
1543
+
1544
+ file_path: The path to write the file to on the Devbox. Path is relative to user home
1545
+ directory.
1546
+
1547
+ extra_headers: Send extra headers
1548
+
1549
+ extra_query: Add additional query parameters to the request
1550
+
1551
+ extra_body: Add additional JSON properties to the request
1552
+
1553
+ timeout: Override the client-level default timeout for this request, in seconds
1554
+
1555
+ idempotency_key: Specify a custom idempotency key for this request
1556
+ """
1557
+ if not id:
1558
+ raise ValueError(f"Expected a non-empty value for `id` but received {id!r}")
1559
+ if not is_given(timeout) and self._client.timeout == DEFAULT_TIMEOUT:
1560
+ timeout = 600
1561
+ return self._post(
1562
+ f"/v1/devboxes/{id}/write_file_contents",
1563
+ body=maybe_transform(
1564
+ {
1565
+ "contents": contents,
1566
+ "file_path": file_path,
1567
+ },
1568
+ devbox_write_file_contents_params.DevboxWriteFileContentsParams,
1569
+ ),
1570
+ options=make_request_options(
1571
+ extra_headers=extra_headers,
1572
+ extra_query=extra_query,
1573
+ extra_body=extra_body,
1574
+ timeout=timeout,
1575
+ idempotency_key=idempotency_key,
1576
+ ),
1577
+ cast_to=DevboxExecutionDetailView,
1578
+ )
1579
+
1580
+
1581
+ class AsyncDevboxesResource(AsyncAPIResource):
1582
+ @cached_property
1583
+ def disk_snapshots(self) -> AsyncDiskSnapshotsResource:
1584
+ return AsyncDiskSnapshotsResource(self._client)
1585
+
1586
+ @cached_property
1587
+ def browsers(self) -> AsyncBrowsersResource:
1588
+ return AsyncBrowsersResource(self._client)
1589
+
1590
+ @cached_property
1591
+ def computers(self) -> AsyncComputersResource:
1592
+ return AsyncComputersResource(self._client)
1593
+
1594
+ @cached_property
1595
+ def logs(self) -> AsyncLogsResource:
1596
+ return AsyncLogsResource(self._client)
1597
+
1598
+ @cached_property
1599
+ def executions(self) -> AsyncExecutionsResource:
1600
+ return AsyncExecutionsResource(self._client)
1601
+
1602
+ @cached_property
1603
+ def with_raw_response(self) -> AsyncDevboxesResourceWithRawResponse:
1604
+ """
1605
+ This property can be used as a prefix for any HTTP method call to return
1606
+ the raw response object instead of the parsed content.
1607
+
1608
+ For more information, see https://www.github.com/runloopai/api-client-python#accessing-raw-response-data-eg-headers
1609
+ """
1610
+ return AsyncDevboxesResourceWithRawResponse(self)
1611
+
1612
+ @cached_property
1613
+ def with_streaming_response(self) -> AsyncDevboxesResourceWithStreamingResponse:
1614
+ """
1615
+ An alternative to `.with_raw_response` that doesn't eagerly read the response body.
1616
+
1617
+ For more information, see https://www.github.com/runloopai/api-client-python#with_streaming_response
1618
+ """
1619
+ return AsyncDevboxesResourceWithStreamingResponse(self)
1620
+
1621
+ async def create(
1622
+ self,
1623
+ *,
1624
+ blueprint_id: Optional[str] | Omit = omit,
1625
+ blueprint_name: Optional[str] | Omit = omit,
1626
+ code_mounts: Optional[Iterable[CodeMountParameters]] | Omit = omit,
1627
+ entrypoint: Optional[str] | Omit = omit,
1628
+ environment_variables: Optional[Dict[str, str]] | Omit = omit,
1629
+ file_mounts: Optional[Dict[str, str]] | Omit = omit,
1630
+ launch_parameters: Optional[LaunchParameters] | Omit = omit,
1631
+ metadata: Optional[Dict[str, str]] | Omit = omit,
1632
+ name: Optional[str] | Omit = omit,
1633
+ repo_connection_id: Optional[str] | Omit = omit,
1634
+ secrets: Optional[Dict[str, str]] | Omit = omit,
1635
+ snapshot_id: Optional[str] | Omit = omit,
1636
+ # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
1637
+ # The extra values given here take precedence over values defined on the client or passed to this method.
1638
+ extra_headers: Headers | None = None,
1639
+ extra_query: Query | None = None,
1640
+ extra_body: Body | None = None,
1641
+ timeout: float | httpx.Timeout | None | NotGiven = not_given,
1642
+ idempotency_key: str | None = None,
1643
+ ) -> DevboxView:
1644
+ """Create a Devbox and begin the boot process.
1645
+
1646
+ The Devbox will initially launch in
1647
+ the 'provisioning' state while Runloop allocates the necessary infrastructure.
1648
+ It will transition to the 'initializing' state while the booted Devbox runs any
1649
+ Runloop or user defined set up scripts. Finally, the Devbox will transition to
1650
+ the 'running' state when it is ready for use.
1651
+
1652
+ Args:
1653
+ blueprint_id: Blueprint ID to use for the Devbox. If none set, the Devbox will be created with
1654
+ the default Runloop Devbox image. Only one of (Snapshot ID, Blueprint ID,
1655
+ Blueprint name) should be specified.
1656
+
1657
+ blueprint_name: Name of Blueprint to use for the Devbox. When set, this will load the latest
1658
+ successfully built Blueprint with the given name. Only one of (Snapshot ID,
1659
+ Blueprint ID, Blueprint name) should be specified.
1660
+
1661
+ code_mounts: A list of code mounts to be included in the Devbox.
1662
+
1663
+ entrypoint: (Optional) When specified, the Devbox will run this script as its main
1664
+ executable. The devbox lifecycle will be bound to entrypoint, shutting down when
1665
+ the process is complete.
1666
+
1667
+ environment_variables: (Optional) Environment variables used to configure your Devbox.
1668
+
1669
+ file_mounts: (Optional) Map of paths and file contents to write before setup..
1670
+
1671
+ launch_parameters: Parameters to configure the resources and launch time behavior of the Devbox.
1672
+
1673
+ metadata: User defined metadata to attach to the devbox for organization.
1674
+
1675
+ name: (Optional) A user specified name to give the Devbox.
1676
+
1677
+ repo_connection_id: Repository connection id the devbox should source its base image from.
1678
+
1679
+ secrets: (Optional) Map of environment variable names to secret names. The secret values
1680
+ will be securely injected as environment variables in the Devbox. Example:
1681
+ {"DB_PASS": "DATABASE_PASSWORD"} sets environment variable 'DB_PASS' to the
1682
+ value of secret 'DATABASE_PASSWORD'.
1683
+
1684
+ snapshot_id: Snapshot ID to use for the Devbox. Only one of (Snapshot ID, Blueprint ID,
1685
+ Blueprint name) should be specified.
1686
+
1687
+ extra_headers: Send extra headers
1688
+
1689
+ extra_query: Add additional query parameters to the request
1690
+
1691
+ extra_body: Add additional JSON properties to the request
1692
+
1693
+ timeout: Override the client-level default timeout for this request, in seconds
1694
+
1695
+ idempotency_key: Specify a custom idempotency key for this request
1696
+ """
1697
+ return await self._post(
1698
+ "/v1/devboxes",
1699
+ body=await async_maybe_transform(
1700
+ {
1701
+ "blueprint_id": blueprint_id,
1702
+ "blueprint_name": blueprint_name,
1703
+ "code_mounts": code_mounts,
1704
+ "entrypoint": entrypoint,
1705
+ "environment_variables": environment_variables,
1706
+ "file_mounts": file_mounts,
1707
+ "launch_parameters": launch_parameters,
1708
+ "metadata": metadata,
1709
+ "name": name,
1710
+ "repo_connection_id": repo_connection_id,
1711
+ "secrets": secrets,
1712
+ "snapshot_id": snapshot_id,
1713
+ },
1714
+ devbox_create_params.DevboxCreateParams,
1715
+ ),
1716
+ options=make_request_options(
1717
+ extra_headers=extra_headers,
1718
+ extra_query=extra_query,
1719
+ extra_body=extra_body,
1720
+ timeout=timeout,
1721
+ idempotency_key=idempotency_key,
1722
+ ),
1723
+ cast_to=DevboxView,
1724
+ )
1725
+
1726
+ async def retrieve(
1727
+ self,
1728
+ id: str,
1729
+ *,
1730
+ # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
1731
+ # The extra values given here take precedence over values defined on the client or passed to this method.
1732
+ extra_headers: Headers | None = None,
1733
+ extra_query: Query | None = None,
1734
+ extra_body: Body | None = None,
1735
+ timeout: float | httpx.Timeout | None | NotGiven = not_given,
1736
+ ) -> DevboxView:
1737
+ """
1738
+ Get the latest details and status of a Devbox.
1739
+
1740
+ Args:
1741
+ extra_headers: Send extra headers
1742
+
1743
+ extra_query: Add additional query parameters to the request
1744
+
1745
+ extra_body: Add additional JSON properties to the request
1746
+
1747
+ timeout: Override the client-level default timeout for this request, in seconds
1748
+ """
1749
+ if not id:
1750
+ raise ValueError(f"Expected a non-empty value for `id` but received {id!r}")
1751
+ return await self._get(
1752
+ f"/v1/devboxes/{id}",
1753
+ options=make_request_options(
1754
+ extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
1755
+ ),
1756
+ cast_to=DevboxView,
1757
+ )
1758
+
1759
+ async def create_and_await_running(
1760
+ self,
1761
+ *,
1762
+ blueprint_id: Optional[str] | NotGiven = NOT_GIVEN,
1763
+ blueprint_name: Optional[str] | NotGiven = NOT_GIVEN,
1764
+ code_mounts: Optional[Iterable[CodeMountParameters]] | NotGiven = NOT_GIVEN,
1765
+ entrypoint: Optional[str] | NotGiven = NOT_GIVEN,
1766
+ environment_variables: Optional[Dict[str, str]] | NotGiven = NOT_GIVEN,
1767
+ file_mounts: Optional[Dict[str, str]] | NotGiven = NOT_GIVEN,
1768
+ launch_parameters: Optional[LaunchParameters] | NotGiven = NOT_GIVEN,
1769
+ metadata: Optional[Dict[str, str]] | NotGiven = NOT_GIVEN,
1770
+ name: Optional[str] | NotGiven = NOT_GIVEN,
1771
+ polling_config: PollingConfig | None = None,
1772
+ repo_connection_id: Optional[str] | NotGiven = NOT_GIVEN,
1773
+ secrets: Optional[Dict[str, str]] | NotGiven = NOT_GIVEN,
1774
+ snapshot_id: Optional[str] | NotGiven = NOT_GIVEN,
1775
+ # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
1776
+ # The extra values given here take precedence over values defined on the client or passed to this method.
1777
+ extra_headers: Headers | None = None,
1778
+ extra_query: Query | None = None,
1779
+ extra_body: Body | None = None,
1780
+ timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
1781
+ idempotency_key: str | None = None,
1782
+ ) -> DevboxView:
1783
+ """Create a devbox and wait for it to be in running state.
1784
+
1785
+ This is a wrapper around the `create` method that waits for the devbox to reach running state.
1786
+
1787
+ Args:
1788
+ See the `create` method for detailed documentation.
1789
+ polling_config: Optional polling configuration
1790
+
1791
+ Returns:
1792
+ The devbox in running state
1793
+
1794
+ Raises:
1795
+ PollingTimeout: If polling times out before devbox is running
1796
+ RunloopError: If devbox enters a non-running terminal state
1797
+ """
1798
+
1799
+ # Pass all create_args, relevant request args to the underlying create method
1800
+ devbox = await self.create(
1801
+ blueprint_id=blueprint_id,
1802
+ blueprint_name=blueprint_name,
1803
+ code_mounts=code_mounts,
1804
+ entrypoint=entrypoint,
1805
+ environment_variables=environment_variables,
1806
+ file_mounts=file_mounts,
1807
+ launch_parameters=launch_parameters,
1808
+ metadata=metadata,
1809
+ name=name,
1810
+ repo_connection_id=repo_connection_id,
1811
+ secrets=secrets,
1812
+ snapshot_id=snapshot_id,
1813
+ extra_headers=extra_headers,
1814
+ extra_query=extra_query,
1815
+ extra_body=extra_body,
1816
+ timeout=timeout,
1817
+ idempotency_key=idempotency_key,
1818
+ )
1819
+
1820
+ return await self.await_running(
1821
+ devbox.id,
1822
+ polling_config=polling_config,
1823
+ )
1824
+
1825
+ async def await_running(
1826
+ self,
1827
+ id: str,
1828
+ *,
1829
+ # Use polling_config to configure the "long" polling behavior.
1830
+ polling_config: PollingConfig | None = None,
1831
+ ) -> DevboxView:
1832
+ """Wait for a devbox to be in running state.
1833
+
1834
+ Args:
1835
+ id: The ID of the devbox to wait for
1836
+ config: Optional polling configuration
1837
+ extra_headers: Send extra headers
1838
+ extra_query: Add additional query parameters to the request
1839
+ extra_body: Add additional JSON properties to the request
1840
+ timeout: Override the client-level default timeout for this request, in seconds
1841
+
1842
+ Returns:
1843
+ The devbox in running state
1844
+
1845
+ Raises:
1846
+ PollingTimeout: If polling times out before devbox is running
1847
+ RunloopError: If devbox enters a non-running terminal state
1848
+ """
1849
+
1850
+ async def wait_for_devbox_status() -> DevboxView:
1851
+ # This wait_for_status endpoint polls the devbox status for 10 seconds until it reaches either running or failure.
1852
+ # If it's neither, it will throw an error.
1853
+ try:
1854
+ return await self._post(
1855
+ f"/v1/devboxes/{id}/wait_for_status",
1856
+ body={"statuses": ["running", "failure", "shutdown"]},
1857
+ cast_to=DevboxView,
1858
+ )
1859
+ except (APITimeoutError, APIStatusError) as error:
1860
+ # Handle timeout errors by returning current devbox state to continue polling
1861
+ if isinstance(error, APITimeoutError) or error.response.status_code == 408:
1862
+ # Return a placeholder result to continue polling
1863
+ return placeholder_devbox_view(id)
1864
+
1865
+ # Re-raise other errors to stop polling
1866
+ raise
1867
+
1868
+ def is_done_booting(devbox: DevboxView) -> bool:
1869
+ return devbox.status not in DEVBOX_BOOTING_STATES
1870
+
1871
+ devbox = await async_poll_until(wait_for_devbox_status, is_done_booting, polling_config)
1872
+
1873
+ if devbox.status != "running":
1874
+ raise RunloopError(f"Devbox entered non-running terminal state: {devbox.status}")
1875
+
1876
+ return devbox
1877
+
1878
+ async def update(
1879
+ self,
1880
+ id: str,
1881
+ *,
1882
+ metadata: Optional[Dict[str, str]] | Omit = omit,
1883
+ name: Optional[str] | Omit = omit,
1884
+ # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
1885
+ # The extra values given here take precedence over values defined on the client or passed to this method.
1886
+ extra_headers: Headers | None = None,
1887
+ extra_query: Query | None = None,
1888
+ extra_body: Body | None = None,
1889
+ timeout: float | httpx.Timeout | None | NotGiven = not_given,
1890
+ idempotency_key: str | None = None,
1891
+ ) -> DevboxView:
1892
+ """
1893
+ Updates a devbox by doing a complete update the existing name,metadata fields.
1894
+ It does not patch partial values.
1895
+
1896
+ Args:
1897
+ metadata: User defined metadata to attach to the devbox for organization.
1898
+
1899
+ name: (Optional) A user specified name to give the Devbox.
1900
+
1901
+ extra_headers: Send extra headers
1902
+
1903
+ extra_query: Add additional query parameters to the request
1904
+
1905
+ extra_body: Add additional JSON properties to the request
1906
+
1907
+ timeout: Override the client-level default timeout for this request, in seconds
1908
+
1909
+ idempotency_key: Specify a custom idempotency key for this request
1910
+ """
1911
+ if not id:
1912
+ raise ValueError(f"Expected a non-empty value for `id` but received {id!r}")
1913
+ return await self._post(
1914
+ f"/v1/devboxes/{id}",
1915
+ body=await async_maybe_transform(
1916
+ {
1917
+ "metadata": metadata,
1918
+ "name": name,
1919
+ },
1920
+ devbox_update_params.DevboxUpdateParams,
1921
+ ),
1922
+ options=make_request_options(
1923
+ extra_headers=extra_headers,
1924
+ extra_query=extra_query,
1925
+ extra_body=extra_body,
1926
+ timeout=timeout,
1927
+ idempotency_key=idempotency_key,
1928
+ ),
1929
+ cast_to=DevboxView,
1930
+ )
1931
+
1932
+ def list(
1933
+ self,
1934
+ *,
1935
+ limit: int | Omit = omit,
1936
+ starting_after: str | Omit = omit,
1937
+ status: Literal[
1938
+ "provisioning", "initializing", "running", "suspending", "suspended", "resuming", "failure", "shutdown"
1939
+ ]
1940
+ | Omit = omit,
1941
+ # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
1942
+ # The extra values given here take precedence over values defined on the client or passed to this method.
1943
+ extra_headers: Headers | None = None,
1944
+ extra_query: Query | None = None,
1945
+ extra_body: Body | None = None,
1946
+ timeout: float | httpx.Timeout | None | NotGiven = not_given,
1947
+ ) -> AsyncPaginator[DevboxView, AsyncDevboxesCursorIDPage[DevboxView]]:
1948
+ """
1949
+ List all Devboxes while optionally filtering by status.
1950
+
1951
+ Args:
1952
+ limit: The limit of items to return. Default is 20.
1953
+
1954
+ starting_after: Load the next page of data starting after the item with the given ID.
1955
+
1956
+ status: Filter by status
1957
+
1958
+ extra_headers: Send extra headers
1959
+
1960
+ extra_query: Add additional query parameters to the request
1961
+
1962
+ extra_body: Add additional JSON properties to the request
1963
+
1964
+ timeout: Override the client-level default timeout for this request, in seconds
1965
+ """
1966
+ return self._get_api_list(
1967
+ "/v1/devboxes",
1968
+ page=AsyncDevboxesCursorIDPage[DevboxView],
1969
+ options=make_request_options(
1970
+ extra_headers=extra_headers,
1971
+ extra_query=extra_query,
1972
+ extra_body=extra_body,
1973
+ timeout=timeout,
1974
+ query=maybe_transform(
1975
+ {
1976
+ "limit": limit,
1977
+ "starting_after": starting_after,
1978
+ "status": status,
1979
+ },
1980
+ devbox_list_params.DevboxListParams,
1981
+ ),
1982
+ ),
1983
+ model=DevboxView,
1984
+ )
1985
+
1986
+ async def create_ssh_key(
1987
+ self,
1988
+ id: str,
1989
+ *,
1990
+ # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
1991
+ # The extra values given here take precedence over values defined on the client or passed to this method.
1992
+ extra_headers: Headers | None = None,
1993
+ extra_query: Query | None = None,
1994
+ extra_body: Body | None = None,
1995
+ timeout: float | httpx.Timeout | None | NotGiven = not_given,
1996
+ idempotency_key: str | None = None,
1997
+ ) -> DevboxCreateSSHKeyResponse:
1998
+ """
1999
+ Create an SSH key for a Devbox to enable remote access.
2000
+
2001
+ Args:
2002
+ extra_headers: Send extra headers
2003
+
2004
+ extra_query: Add additional query parameters to the request
2005
+
2006
+ extra_body: Add additional JSON properties to the request
2007
+
2008
+ timeout: Override the client-level default timeout for this request, in seconds
2009
+
2010
+ idempotency_key: Specify a custom idempotency key for this request
2011
+ """
2012
+ if not id:
2013
+ raise ValueError(f"Expected a non-empty value for `id` but received {id!r}")
2014
+ return await self._post(
2015
+ f"/v1/devboxes/{id}/create_ssh_key",
2016
+ options=make_request_options(
2017
+ extra_headers=extra_headers,
2018
+ extra_query=extra_query,
2019
+ extra_body=extra_body,
2020
+ timeout=timeout,
2021
+ idempotency_key=idempotency_key,
2022
+ ),
2023
+ cast_to=DevboxCreateSSHKeyResponse,
2024
+ )
2025
+
2026
+ async def create_tunnel(
2027
+ self,
2028
+ id: str,
2029
+ *,
2030
+ port: int,
2031
+ # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
2032
+ # The extra values given here take precedence over values defined on the client or passed to this method.
2033
+ extra_headers: Headers | None = None,
2034
+ extra_query: Query | None = None,
2035
+ extra_body: Body | None = None,
2036
+ timeout: float | httpx.Timeout | None | NotGiven = not_given,
2037
+ idempotency_key: str | None = None,
2038
+ ) -> DevboxTunnelView:
2039
+ """
2040
+ Create a live tunnel to an available port on the Devbox.
2041
+
2042
+ Args:
2043
+ port: Devbox port that tunnel will expose.
2044
+
2045
+ extra_headers: Send extra headers
2046
+
2047
+ extra_query: Add additional query parameters to the request
2048
+
2049
+ extra_body: Add additional JSON properties to the request
2050
+
2051
+ timeout: Override the client-level default timeout for this request, in seconds
2052
+
2053
+ idempotency_key: Specify a custom idempotency key for this request
2054
+ """
2055
+ if not id:
2056
+ raise ValueError(f"Expected a non-empty value for `id` but received {id!r}")
2057
+ return await self._post(
2058
+ f"/v1/devboxes/{id}/create_tunnel",
2059
+ body=await async_maybe_transform({"port": port}, devbox_create_tunnel_params.DevboxCreateTunnelParams),
2060
+ options=make_request_options(
2061
+ extra_headers=extra_headers,
2062
+ extra_query=extra_query,
2063
+ extra_body=extra_body,
2064
+ timeout=timeout,
2065
+ idempotency_key=idempotency_key,
2066
+ ),
2067
+ cast_to=DevboxTunnelView,
2068
+ )
2069
+
2070
+ async def delete_disk_snapshot(
2071
+ self,
2072
+ id: str,
2073
+ *,
2074
+ # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
2075
+ # The extra values given here take precedence over values defined on the client or passed to this method.
2076
+ extra_headers: Headers | None = None,
2077
+ extra_query: Query | None = None,
2078
+ extra_body: Body | None = None,
2079
+ timeout: float | httpx.Timeout | None | NotGiven = not_given,
2080
+ idempotency_key: str | None = None,
2081
+ ) -> object:
2082
+ """
2083
+ Delete a previously taken disk snapshot of a Devbox.
2084
+
2085
+ Args:
2086
+ extra_headers: Send extra headers
2087
+
2088
+ extra_query: Add additional query parameters to the request
2089
+
2090
+ extra_body: Add additional JSON properties to the request
2091
+
2092
+ timeout: Override the client-level default timeout for this request, in seconds
2093
+
2094
+ idempotency_key: Specify a custom idempotency key for this request
2095
+ """
2096
+ if not id:
2097
+ raise ValueError(f"Expected a non-empty value for `id` but received {id!r}")
2098
+ return await self._post(
2099
+ f"/v1/devboxes/disk_snapshots/{id}/delete",
2100
+ options=make_request_options(
2101
+ extra_headers=extra_headers,
2102
+ extra_query=extra_query,
2103
+ extra_body=extra_body,
2104
+ timeout=timeout,
2105
+ idempotency_key=idempotency_key,
2106
+ ),
2107
+ cast_to=object,
2108
+ )
2109
+
2110
+ async def download_file(
2111
+ self,
2112
+ id: str,
2113
+ *,
2114
+ path: str,
2115
+ # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
2116
+ # The extra values given here take precedence over values defined on the client or passed to this method.
2117
+ extra_headers: Headers | None = None,
2118
+ extra_query: Query | None = None,
2119
+ extra_body: Body | None = None,
2120
+ timeout: float | httpx.Timeout | None | NotGiven = not_given,
2121
+ idempotency_key: str | None = None,
2122
+ ) -> AsyncBinaryAPIResponse:
2123
+ """
2124
+ Download file contents of any type (binary, text, etc) from a specified path on
2125
+ the Devbox.
2126
+
2127
+ Args:
2128
+ path: The path on the Devbox filesystem to read the file from. Path is relative to
2129
+ user home directory.
2130
+
2131
+ extra_headers: Send extra headers
2132
+
2133
+ extra_query: Add additional query parameters to the request
2134
+
2135
+ extra_body: Add additional JSON properties to the request
2136
+
2137
+ timeout: Override the client-level default timeout for this request, in seconds
2138
+
2139
+ idempotency_key: Specify a custom idempotency key for this request
2140
+ """
2141
+ if not id:
2142
+ raise ValueError(f"Expected a non-empty value for `id` but received {id!r}")
2143
+ if not is_given(timeout) and self._client.timeout == DEFAULT_TIMEOUT:
2144
+ timeout = 600
2145
+ extra_headers = {"Accept": "application/octet-stream", **(extra_headers or {})}
2146
+ return await self._post(
2147
+ f"/v1/devboxes/{id}/download_file",
2148
+ body=await async_maybe_transform({"path": path}, devbox_download_file_params.DevboxDownloadFileParams),
2149
+ options=make_request_options(
2150
+ extra_headers=extra_headers,
2151
+ extra_query=extra_query,
2152
+ extra_body=extra_body,
2153
+ timeout=timeout,
2154
+ idempotency_key=idempotency_key,
2155
+ ),
2156
+ cast_to=AsyncBinaryAPIResponse,
2157
+ )
2158
+
2159
+ async def execute(
2160
+ self,
2161
+ id: str,
2162
+ *,
2163
+ command: str,
2164
+ command_id: str,
2165
+ optimistic_timeout: Optional[int] | Omit = omit,
2166
+ shell_name: Optional[str] | Omit = omit,
2167
+ # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
2168
+ # The extra values given here take precedence over values defined on the client or passed to this method.
2169
+ extra_headers: Headers | None = None,
2170
+ extra_query: Query | None = None,
2171
+ extra_body: Body | None = None,
2172
+ timeout: float | httpx.Timeout | None | NotGiven = not_given,
2173
+ idempotency_key: str | None = None,
2174
+ ) -> DevboxAsyncExecutionDetailView:
2175
+ """
2176
+ Execute a command with a known command ID on a devbox, optimistically waiting
2177
+ for it to complete within the specified timeout. If it completes in time, return
2178
+ the result. If not, return a status indicating the command is still running.
2179
+
2180
+ Args:
2181
+ command: The command to execute via the Devbox shell. By default, commands are run from
2182
+ the user home directory unless shell_name is specified. If shell_name is
2183
+ specified the command is run from the directory based on the recent state of the
2184
+ persistent shell.
2185
+
2186
+ command_id: The command ID for idempotency and tracking
2187
+
2188
+ optimistic_timeout: Timeout in seconds to wait for command completion. Operation is not killed. Max
2189
+ is 600 seconds.
2190
+
2191
+ shell_name: The name of the persistent shell to create or use if already created. When using
2192
+ a persistent shell, the command will run from the directory at the end of the
2193
+ previous command and environment variables will be preserved.
2194
+
2195
+ extra_headers: Send extra headers
2196
+
2197
+ extra_query: Add additional query parameters to the request
2198
+
2199
+ extra_body: Add additional JSON properties to the request
2200
+
2201
+ timeout: Override the client-level default timeout for this request, in seconds
2202
+
2203
+ idempotency_key: Specify a custom idempotency key for this request
2204
+ """
2205
+ if not id:
2206
+ raise ValueError(f"Expected a non-empty value for `id` but received {id!r}")
2207
+ if not is_given(timeout) and self._client.timeout == DEFAULT_TIMEOUT:
2208
+ timeout = 600
2209
+ return await self._post(
2210
+ f"/v1/devboxes/{id}/execute",
2211
+ body=await async_maybe_transform(
2212
+ {
2213
+ "command": command,
2214
+ "command_id": command_id,
2215
+ "optimistic_timeout": optimistic_timeout,
2216
+ "shell_name": shell_name,
2217
+ },
2218
+ devbox_execute_params.DevboxExecuteParams,
2219
+ ),
2220
+ options=make_request_options(
2221
+ extra_headers=extra_headers,
2222
+ extra_query=extra_query,
2223
+ extra_body=extra_body,
2224
+ timeout=timeout,
2225
+ idempotency_key=idempotency_key,
2226
+ ),
2227
+ cast_to=DevboxAsyncExecutionDetailView,
2228
+ )
2229
+
2230
+ async def execute_and_await_completion(
2231
+ self,
2232
+ devbox_id: str,
2233
+ *,
2234
+ command: str,
2235
+ shell_name: Optional[str] | NotGiven = NOT_GIVEN,
2236
+ polling_config: PollingConfig | None = None,
2237
+ # The following are forwarded to the initial execute request
2238
+ extra_headers: Headers | None = None,
2239
+ extra_query: Query | None = None,
2240
+ extra_body: Body | None = None,
2241
+ timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
2242
+ idempotency_key: str | None = None,
2243
+ ) -> DevboxAsyncExecutionDetailView:
2244
+ """
2245
+ Execute a command and wait for it to complete with optimal latency for long running commands.
2246
+
2247
+ This method launches an execution with a generated command_id and first attempts to
2248
+ return the result within the initial request's timeout. If the execution is not yet
2249
+ complete, it switches to using wait_for_command to minimize latency while waiting.
2250
+ """
2251
+
2252
+ command_id = str(uuid7()) # type: ignore
2253
+ execution = await self.execute(
2254
+ devbox_id,
2255
+ command=command,
2256
+ command_id=command_id,
2257
+ shell_name=shell_name,
2258
+ extra_headers=extra_headers,
2259
+ extra_query=extra_query,
2260
+ extra_body=extra_body,
2261
+ timeout=timeout,
2262
+ idempotency_key=idempotency_key,
2263
+ )
2264
+ if execution.status == "completed":
2265
+ return execution
2266
+
2267
+ def handle_timeout_error(error: Exception) -> DevboxAsyncExecutionDetailView:
2268
+ if isinstance(error, APITimeoutError) or (
2269
+ isinstance(error, APIStatusError) and error.response.status_code == 408
2270
+ ):
2271
+ return execution
2272
+ raise error
2273
+
2274
+ def is_done(result: DevboxAsyncExecutionDetailView) -> bool:
2275
+ return result.status == "completed"
2276
+
2277
+ return await async_poll_until(
2278
+ lambda: self.wait_for_command(execution.execution_id, devbox_id=devbox_id, statuses=["completed"]),
2279
+ is_done,
2280
+ polling_config,
2281
+ handle_timeout_error,
2282
+ )
2283
+
2284
+ async def execute_async(
2285
+ self,
2286
+ id: str,
2287
+ *,
2288
+ command: str,
2289
+ shell_name: Optional[str] | Omit = omit,
2290
+ # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
2291
+ # The extra values given here take precedence over values defined on the client or passed to this method.
2292
+ extra_headers: Headers | None = None,
2293
+ extra_query: Query | None = None,
2294
+ extra_body: Body | None = None,
2295
+ timeout: float | httpx.Timeout | None | NotGiven = not_given,
2296
+ idempotency_key: str | None = None,
2297
+ ) -> DevboxAsyncExecutionDetailView:
2298
+ """
2299
+ Execute the given command in the Devbox shell asynchronously and returns the
2300
+ execution that can be used to track the command's progress.
2301
+
2302
+ Args:
2303
+ command: The command to execute via the Devbox shell. By default, commands are run from
2304
+ the user home directory unless shell_name is specified. If shell_name is
2305
+ specified the command is run from the directory based on the recent state of the
2306
+ persistent shell.
2307
+
2308
+ shell_name: The name of the persistent shell to create or use if already created. When using
2309
+ a persistent shell, the command will run from the directory at the end of the
2310
+ previous command and environment variables will be preserved.
2311
+
2312
+ extra_headers: Send extra headers
2313
+
2314
+ extra_query: Add additional query parameters to the request
2315
+
2316
+ extra_body: Add additional JSON properties to the request
2317
+
2318
+ timeout: Override the client-level default timeout for this request, in seconds
2319
+
2320
+ idempotency_key: Specify a custom idempotency key for this request
2321
+ """
2322
+ if not id:
2323
+ raise ValueError(f"Expected a non-empty value for `id` but received {id!r}")
2324
+ return await self._post(
2325
+ f"/v1/devboxes/{id}/execute_async",
2326
+ body=await async_maybe_transform(
2327
+ {
2328
+ "command": command,
2329
+ "shell_name": shell_name,
2330
+ },
2331
+ devbox_execute_async_params.DevboxExecuteAsyncParams,
2332
+ ),
2333
+ options=make_request_options(
2334
+ extra_headers=extra_headers,
2335
+ extra_query=extra_query,
2336
+ extra_body=extra_body,
2337
+ timeout=timeout,
2338
+ idempotency_key=idempotency_key,
2339
+ ),
2340
+ cast_to=DevboxAsyncExecutionDetailView,
2341
+ )
2342
+
2343
+ @typing_extensions.deprecated("deprecated")
2344
+ async def execute_sync(
2345
+ self,
2346
+ id: str,
2347
+ *,
2348
+ command: str,
2349
+ shell_name: Optional[str] | Omit = omit,
2350
+ # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
2351
+ # The extra values given here take precedence over values defined on the client or passed to this method.
2352
+ extra_headers: Headers | None = None,
2353
+ extra_query: Query | None = None,
2354
+ extra_body: Body | None = None,
2355
+ timeout: float | httpx.Timeout | None | NotGiven = not_given,
2356
+ idempotency_key: str | None = None,
2357
+ ) -> DevboxExecutionDetailView:
2358
+ """
2359
+ Execute a bash command in the Devbox shell, await the command completion and
2360
+ return the output.
2361
+
2362
+ Args:
2363
+ command: The command to execute via the Devbox shell. By default, commands are run from
2364
+ the user home directory unless shell_name is specified. If shell_name is
2365
+ specified the command is run from the directory based on the recent state of the
2366
+ persistent shell.
2367
+
2368
+ shell_name: The name of the persistent shell to create or use if already created. When using
2369
+ a persistent shell, the command will run from the directory at the end of the
2370
+ previous command and environment variables will be preserved.
2371
+
2372
+ extra_headers: Send extra headers
2373
+
2374
+ extra_query: Add additional query parameters to the request
2375
+
2376
+ extra_body: Add additional JSON properties to the request
2377
+
2378
+ timeout: Override the client-level default timeout for this request, in seconds
2379
+
2380
+ idempotency_key: Specify a custom idempotency key for this request
2381
+ """
2382
+ if not id:
2383
+ raise ValueError(f"Expected a non-empty value for `id` but received {id!r}")
2384
+ if not is_given(timeout) and self._client.timeout == DEFAULT_TIMEOUT:
2385
+ timeout = 600
2386
+ return await self._post(
2387
+ f"/v1/devboxes/{id}/execute_sync",
2388
+ body=await async_maybe_transform(
2389
+ {
2390
+ "command": command,
2391
+ "shell_name": shell_name,
2392
+ },
2393
+ devbox_execute_sync_params.DevboxExecuteSyncParams,
2394
+ ),
2395
+ options=make_request_options(
2396
+ extra_headers=extra_headers,
2397
+ extra_query=extra_query,
2398
+ extra_body=extra_body,
2399
+ timeout=timeout,
2400
+ idempotency_key=idempotency_key,
2401
+ ),
2402
+ cast_to=DevboxExecutionDetailView,
2403
+ )
2404
+
2405
+ async def keep_alive(
2406
+ self,
2407
+ id: str,
2408
+ *,
2409
+ # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
2410
+ # The extra values given here take precedence over values defined on the client or passed to this method.
2411
+ extra_headers: Headers | None = None,
2412
+ extra_query: Query | None = None,
2413
+ extra_body: Body | None = None,
2414
+ timeout: float | httpx.Timeout | None | NotGiven = not_given,
2415
+ idempotency_key: str | None = None,
2416
+ ) -> object:
2417
+ """
2418
+ Send a 'Keep Alive' signal to a running Devbox that is configured to shutdown on
2419
+ idle so the idle time resets.
2420
+
2421
+ Args:
2422
+ extra_headers: Send extra headers
2423
+
2424
+ extra_query: Add additional query parameters to the request
2425
+
2426
+ extra_body: Add additional JSON properties to the request
2427
+
2428
+ timeout: Override the client-level default timeout for this request, in seconds
2429
+
2430
+ idempotency_key: Specify a custom idempotency key for this request
2431
+ """
2432
+ if not id:
2433
+ raise ValueError(f"Expected a non-empty value for `id` but received {id!r}")
2434
+ return await self._post(
2435
+ f"/v1/devboxes/{id}/keep_alive",
2436
+ options=make_request_options(
2437
+ extra_headers=extra_headers,
2438
+ extra_query=extra_query,
2439
+ extra_body=extra_body,
2440
+ timeout=timeout,
2441
+ idempotency_key=idempotency_key,
2442
+ ),
2443
+ cast_to=object,
2444
+ )
2445
+
2446
+ def list_disk_snapshots(
2447
+ self,
2448
+ *,
2449
+ devbox_id: str | Omit = omit,
2450
+ limit: int | Omit = omit,
2451
+ metadata_key: str | Omit = omit,
2452
+ metadata_key_in: str | Omit = omit,
2453
+ starting_after: str | Omit = omit,
2454
+ # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
2455
+ # The extra values given here take precedence over values defined on the client or passed to this method.
2456
+ extra_headers: Headers | None = None,
2457
+ extra_query: Query | None = None,
2458
+ extra_body: Body | None = None,
2459
+ timeout: float | httpx.Timeout | None | NotGiven = not_given,
2460
+ ) -> AsyncPaginator[DevboxSnapshotView, AsyncDiskSnapshotsCursorIDPage[DevboxSnapshotView]]:
2461
+ """
2462
+ List all snapshots of a Devbox while optionally filtering by Devbox ID and
2463
+ metadata.
2464
+
2465
+ Args:
2466
+ devbox_id: Devbox ID to filter by.
2467
+
2468
+ limit: The limit of items to return. Default is 20.
2469
+
2470
+ metadata_key: Filter snapshots by metadata key-value pair. Can be used multiple times for
2471
+ different keys.
2472
+
2473
+ metadata_key_in: Filter snapshots by metadata key with multiple possible values (OR condition).
2474
+
2475
+ starting_after: Load the next page of data starting after the item with the given ID.
2476
+
2477
+ extra_headers: Send extra headers
2478
+
2479
+ extra_query: Add additional query parameters to the request
2480
+
2481
+ extra_body: Add additional JSON properties to the request
2482
+
2483
+ timeout: Override the client-level default timeout for this request, in seconds
2484
+ """
2485
+ return self._get_api_list(
2486
+ "/v1/devboxes/disk_snapshots",
2487
+ page=AsyncDiskSnapshotsCursorIDPage[DevboxSnapshotView],
2488
+ options=make_request_options(
2489
+ extra_headers=extra_headers,
2490
+ extra_query=extra_query,
2491
+ extra_body=extra_body,
2492
+ timeout=timeout,
2493
+ query=maybe_transform(
2494
+ {
2495
+ "devbox_id": devbox_id,
2496
+ "limit": limit,
2497
+ "metadata_key": metadata_key,
2498
+ "metadata_key_in": metadata_key_in,
2499
+ "starting_after": starting_after,
2500
+ },
2501
+ devbox_list_disk_snapshots_params.DevboxListDiskSnapshotsParams,
2502
+ ),
2503
+ ),
2504
+ model=DevboxSnapshotView,
2505
+ )
2506
+
2507
+ async def read_file_contents(
2508
+ self,
2509
+ id: str,
2510
+ *,
2511
+ file_path: str,
2512
+ # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
2513
+ # The extra values given here take precedence over values defined on the client or passed to this method.
2514
+ extra_headers: Headers | None = None,
2515
+ extra_query: Query | None = None,
2516
+ extra_body: Body | None = None,
2517
+ timeout: float | httpx.Timeout | None | NotGiven = not_given,
2518
+ idempotency_key: str | None = None,
2519
+ ) -> str:
2520
+ """Read file contents from a file on a Devbox as a UTF-8.
2521
+
2522
+ Note 'downloadFile'
2523
+ should be used for large files (greater than 100MB). Returns the file contents
2524
+ as a UTF-8 string.
2525
+
2526
+ Args:
2527
+ file_path: The path on the Devbox filesystem to read the file from. Path is relative to
2528
+ user home directory.
2529
+
2530
+ extra_headers: Send extra headers
2531
+
2532
+ extra_query: Add additional query parameters to the request
2533
+
2534
+ extra_body: Add additional JSON properties to the request
2535
+
2536
+ timeout: Override the client-level default timeout for this request, in seconds
2537
+
2538
+ idempotency_key: Specify a custom idempotency key for this request
2539
+ """
2540
+ if not id:
2541
+ raise ValueError(f"Expected a non-empty value for `id` but received {id!r}")
2542
+ if not is_given(timeout) and self._client.timeout == DEFAULT_TIMEOUT:
2543
+ timeout = 600
2544
+ extra_headers = {"Accept": "text/plain", **(extra_headers or {})}
2545
+ return await self._post(
2546
+ f"/v1/devboxes/{id}/read_file_contents",
2547
+ body=await async_maybe_transform(
2548
+ {"file_path": file_path}, devbox_read_file_contents_params.DevboxReadFileContentsParams
2549
+ ),
2550
+ options=make_request_options(
2551
+ extra_headers=extra_headers,
2552
+ extra_query=extra_query,
2553
+ extra_body=extra_body,
2554
+ timeout=timeout,
2555
+ idempotency_key=idempotency_key,
2556
+ ),
2557
+ cast_to=str,
2558
+ )
2559
+
2560
+ async def remove_tunnel(
2561
+ self,
2562
+ id: str,
2563
+ *,
2564
+ port: int,
2565
+ # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
2566
+ # The extra values given here take precedence over values defined on the client or passed to this method.
2567
+ extra_headers: Headers | None = None,
2568
+ extra_query: Query | None = None,
2569
+ extra_body: Body | None = None,
2570
+ timeout: float | httpx.Timeout | None | NotGiven = not_given,
2571
+ idempotency_key: str | None = None,
2572
+ ) -> object:
2573
+ """
2574
+ Remove a previously opened tunnel on the Devbox.
2575
+
2576
+ Args:
2577
+ port: Devbox port that tunnel will expose.
2578
+
2579
+ extra_headers: Send extra headers
2580
+
2581
+ extra_query: Add additional query parameters to the request
2582
+
2583
+ extra_body: Add additional JSON properties to the request
2584
+
2585
+ timeout: Override the client-level default timeout for this request, in seconds
2586
+
2587
+ idempotency_key: Specify a custom idempotency key for this request
2588
+ """
2589
+ if not id:
2590
+ raise ValueError(f"Expected a non-empty value for `id` but received {id!r}")
2591
+ return await self._post(
2592
+ f"/v1/devboxes/{id}/remove_tunnel",
2593
+ body=await async_maybe_transform({"port": port}, devbox_remove_tunnel_params.DevboxRemoveTunnelParams),
2594
+ options=make_request_options(
2595
+ extra_headers=extra_headers,
2596
+ extra_query=extra_query,
2597
+ extra_body=extra_body,
2598
+ timeout=timeout,
2599
+ idempotency_key=idempotency_key,
2600
+ ),
2601
+ cast_to=object,
2602
+ )
2603
+
2604
+ async def resume(
2605
+ self,
2606
+ id: str,
2607
+ *,
2608
+ # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
2609
+ # The extra values given here take precedence over values defined on the client or passed to this method.
2610
+ extra_headers: Headers | None = None,
2611
+ extra_query: Query | None = None,
2612
+ extra_body: Body | None = None,
2613
+ timeout: float | httpx.Timeout | None | NotGiven = not_given,
2614
+ idempotency_key: str | None = None,
2615
+ ) -> DevboxView:
2616
+ """Resume a suspended Devbox with the disk state captured as suspend time.
2617
+
2618
+ Note
2619
+ that any previously running processes or daemons will need to be restarted using
2620
+ the Devbox shell tools.
2621
+
2622
+ Args:
2623
+ extra_headers: Send extra headers
2624
+
2625
+ extra_query: Add additional query parameters to the request
2626
+
2627
+ extra_body: Add additional JSON properties to the request
2628
+
2629
+ timeout: Override the client-level default timeout for this request, in seconds
2630
+
2631
+ idempotency_key: Specify a custom idempotency key for this request
2632
+ """
2633
+ if not id:
2634
+ raise ValueError(f"Expected a non-empty value for `id` but received {id!r}")
2635
+ return await self._post(
2636
+ f"/v1/devboxes/{id}/resume",
2637
+ options=make_request_options(
2638
+ extra_headers=extra_headers,
2639
+ extra_query=extra_query,
2640
+ extra_body=extra_body,
2641
+ timeout=timeout,
2642
+ idempotency_key=idempotency_key,
2643
+ ),
2644
+ cast_to=DevboxView,
2645
+ )
2646
+
2647
+ async def shutdown(
2648
+ self,
2649
+ id: str,
2650
+ *,
2651
+ # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
2652
+ # The extra values given here take precedence over values defined on the client or passed to this method.
2653
+ extra_headers: Headers | None = None,
2654
+ extra_query: Query | None = None,
2655
+ extra_body: Body | None = None,
2656
+ timeout: float | httpx.Timeout | None | NotGiven = not_given,
2657
+ idempotency_key: str | None = None,
2658
+ ) -> DevboxView:
2659
+ """Shutdown a running Devbox.
2660
+
2661
+ This will permanently stop the Devbox. If you want to
2662
+ save the state of the Devbox, you should take a snapshot before shutting down or
2663
+ should suspend the Devbox instead of shutting down.
2664
+
2665
+ Args:
2666
+ extra_headers: Send extra headers
2667
+
2668
+ extra_query: Add additional query parameters to the request
2669
+
2670
+ extra_body: Add additional JSON properties to the request
2671
+
2672
+ timeout: Override the client-level default timeout for this request, in seconds
2673
+
2674
+ idempotency_key: Specify a custom idempotency key for this request
2675
+ """
2676
+ if not id:
2677
+ raise ValueError(f"Expected a non-empty value for `id` but received {id!r}")
2678
+ return await self._post(
2679
+ f"/v1/devboxes/{id}/shutdown",
2680
+ options=make_request_options(
2681
+ extra_headers=extra_headers,
2682
+ extra_query=extra_query,
2683
+ extra_body=extra_body,
2684
+ timeout=timeout,
2685
+ idempotency_key=idempotency_key,
2686
+ ),
2687
+ cast_to=DevboxView,
2688
+ )
2689
+
2690
+ async def snapshot_disk(
2691
+ self,
2692
+ id: str,
2693
+ *,
2694
+ metadata: Optional[Dict[str, str]] | Omit = omit,
2695
+ name: Optional[str] | Omit = omit,
2696
+ # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
2697
+ # The extra values given here take precedence over values defined on the client or passed to this method.
2698
+ extra_headers: Headers | None = None,
2699
+ extra_query: Query | None = None,
2700
+ extra_body: Body | None = None,
2701
+ timeout: float | httpx.Timeout | None | NotGiven = not_given,
2702
+ idempotency_key: str | None = None,
2703
+ ) -> DevboxSnapshotView:
2704
+ """
2705
+ Create a disk snapshot of a devbox with the specified name and metadata to
2706
+ enable launching future Devboxes with the same disk state.
2707
+
2708
+ Args:
2709
+ metadata: (Optional) Metadata used to describe the snapshot
2710
+
2711
+ name: (Optional) A user specified name to give the snapshot
2712
+
2713
+ extra_headers: Send extra headers
2714
+
2715
+ extra_query: Add additional query parameters to the request
2716
+
2717
+ extra_body: Add additional JSON properties to the request
2718
+
2719
+ timeout: Override the client-level default timeout for this request, in seconds
2720
+
2721
+ idempotency_key: Specify a custom idempotency key for this request
2722
+ """
2723
+ if not id:
2724
+ raise ValueError(f"Expected a non-empty value for `id` but received {id!r}")
2725
+ if not is_given(timeout) and self._client.timeout == DEFAULT_TIMEOUT:
2726
+ timeout = 600
2727
+ return await self._post(
2728
+ f"/v1/devboxes/{id}/snapshot_disk",
2729
+ body=await async_maybe_transform(
2730
+ {
2731
+ "metadata": metadata,
2732
+ "name": name,
2733
+ },
2734
+ devbox_snapshot_disk_params.DevboxSnapshotDiskParams,
2735
+ ),
2736
+ options=make_request_options(
2737
+ extra_headers=extra_headers,
2738
+ extra_query=extra_query,
2739
+ extra_body=extra_body,
2740
+ timeout=timeout,
2741
+ idempotency_key=idempotency_key,
2742
+ ),
2743
+ cast_to=DevboxSnapshotView,
2744
+ )
2745
+
2746
+ async def snapshot_disk_async(
2747
+ self,
2748
+ id: str,
2749
+ *,
2750
+ metadata: Optional[Dict[str, str]] | Omit = omit,
2751
+ name: Optional[str] | Omit = omit,
2752
+ # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
2753
+ # The extra values given here take precedence over values defined on the client or passed to this method.
2754
+ extra_headers: Headers | None = None,
2755
+ extra_query: Query | None = None,
2756
+ extra_body: Body | None = None,
2757
+ timeout: float | httpx.Timeout | None | NotGiven = not_given,
2758
+ idempotency_key: str | None = None,
2759
+ ) -> DevboxSnapshotView:
2760
+ """
2761
+ Start an asynchronous disk snapshot of a devbox with the specified name and
2762
+ metadata. The snapshot operation will continue in the background and can be
2763
+ monitored using the query endpoint.
2764
+
2765
+ Args:
2766
+ metadata: (Optional) Metadata used to describe the snapshot
2767
+
2768
+ name: (Optional) A user specified name to give the snapshot
2769
+
2770
+ extra_headers: Send extra headers
2771
+
2772
+ extra_query: Add additional query parameters to the request
2773
+
2774
+ extra_body: Add additional JSON properties to the request
2775
+
2776
+ timeout: Override the client-level default timeout for this request, in seconds
2777
+
2778
+ idempotency_key: Specify a custom idempotency key for this request
2779
+ """
2780
+ if not id:
2781
+ raise ValueError(f"Expected a non-empty value for `id` but received {id!r}")
2782
+ return await self._post(
2783
+ f"/v1/devboxes/{id}/snapshot_disk_async",
2784
+ body=await async_maybe_transform(
2785
+ {
2786
+ "metadata": metadata,
2787
+ "name": name,
2788
+ },
2789
+ devbox_snapshot_disk_async_params.DevboxSnapshotDiskAsyncParams,
2790
+ ),
2791
+ options=make_request_options(
2792
+ extra_headers=extra_headers,
2793
+ extra_query=extra_query,
2794
+ extra_body=extra_body,
2795
+ timeout=timeout,
2796
+ idempotency_key=idempotency_key,
2797
+ ),
2798
+ cast_to=DevboxSnapshotView,
2799
+ )
2800
+
2801
+ async def suspend(
2802
+ self,
2803
+ id: str,
2804
+ *,
2805
+ # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
2806
+ # The extra values given here take precedence over values defined on the client or passed to this method.
2807
+ extra_headers: Headers | None = None,
2808
+ extra_query: Query | None = None,
2809
+ extra_body: Body | None = None,
2810
+ timeout: float | httpx.Timeout | None | NotGiven = not_given,
2811
+ idempotency_key: str | None = None,
2812
+ ) -> DevboxView:
2813
+ """
2814
+ Suspend a running Devbox and create a disk snapshot to enable resuming the
2815
+ Devbox later with the same disk. Note this will not snapshot memory state such
2816
+ as running processes.
2817
+
2818
+ Args:
2819
+ extra_headers: Send extra headers
2820
+
2821
+ extra_query: Add additional query parameters to the request
2822
+
2823
+ extra_body: Add additional JSON properties to the request
2824
+
2825
+ timeout: Override the client-level default timeout for this request, in seconds
2826
+
2827
+ idempotency_key: Specify a custom idempotency key for this request
2828
+ """
2829
+ if not id:
2830
+ raise ValueError(f"Expected a non-empty value for `id` but received {id!r}")
2831
+ return await self._post(
2832
+ f"/v1/devboxes/{id}/suspend",
2833
+ options=make_request_options(
2834
+ extra_headers=extra_headers,
2835
+ extra_query=extra_query,
2836
+ extra_body=extra_body,
2837
+ timeout=timeout,
2838
+ idempotency_key=idempotency_key,
2839
+ ),
2840
+ cast_to=DevboxView,
2841
+ )
2842
+
2843
+ async def upload_file(
2844
+ self,
2845
+ id: str,
2846
+ *,
2847
+ path: str,
2848
+ file: FileTypes | Omit = omit,
2849
+ # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
2850
+ # The extra values given here take precedence over values defined on the client or passed to this method.
2851
+ extra_headers: Headers | None = None,
2852
+ extra_query: Query | None = None,
2853
+ extra_body: Body | None = None,
2854
+ timeout: float | httpx.Timeout | None | NotGiven = not_given,
2855
+ idempotency_key: str | None = None,
2856
+ ) -> object:
2857
+ """Upload file contents of any type (binary, text, etc) to a Devbox.
2858
+
2859
+ Note this API
2860
+ is suitable for large files (larger than 100MB) and efficiently uploads files
2861
+ via multipart form data.
2862
+
2863
+ Args:
2864
+ path: The path to write the file to on the Devbox. Path is relative to user home
2865
+ directory.
2866
+
2867
+ extra_headers: Send extra headers
2868
+
2869
+ extra_query: Add additional query parameters to the request
2870
+
2871
+ extra_body: Add additional JSON properties to the request
2872
+
2873
+ timeout: Override the client-level default timeout for this request, in seconds
2874
+
2875
+ idempotency_key: Specify a custom idempotency key for this request
2876
+ """
2877
+ if not id:
2878
+ raise ValueError(f"Expected a non-empty value for `id` but received {id!r}")
2879
+ if not is_given(timeout) and self._client.timeout == DEFAULT_TIMEOUT:
2880
+ timeout = 600
2881
+ body = deepcopy_minimal(
2882
+ {
2883
+ "path": path,
2884
+ "file": file,
2885
+ }
2886
+ )
2887
+ files = extract_files(cast(Mapping[str, object], body), paths=[["file"]])
2888
+ # It should be noted that the actual Content-Type header that will be
2889
+ # sent to the server will contain a `boundary` parameter, e.g.
2890
+ # multipart/form-data; boundary=---abc--
2891
+ extra_headers = {"Content-Type": "multipart/form-data", **(extra_headers or {})}
2892
+ return await self._post(
2893
+ f"/v1/devboxes/{id}/upload_file",
2894
+ body=await async_maybe_transform(body, devbox_upload_file_params.DevboxUploadFileParams),
2895
+ files=files,
2896
+ options=make_request_options(
2897
+ extra_headers=extra_headers,
2898
+ extra_query=extra_query,
2899
+ extra_body=extra_body,
2900
+ timeout=timeout,
2901
+ idempotency_key=idempotency_key,
2902
+ ),
2903
+ cast_to=object,
2904
+ )
2905
+
2906
+ async def wait_for_command(
2907
+ self,
2908
+ execution_id: str,
2909
+ *,
2910
+ devbox_id: str,
2911
+ statuses: List[Literal["queued", "running", "completed"]],
2912
+ timeout_seconds: Optional[int] | Omit = omit,
2913
+ # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
2914
+ # The extra values given here take precedence over values defined on the client or passed to this method.
2915
+ extra_headers: Headers | None = None,
2916
+ extra_query: Query | None = None,
2917
+ extra_body: Body | None = None,
2918
+ timeout: float | httpx.Timeout | None | NotGiven = not_given,
2919
+ idempotency_key: str | None = None,
2920
+ ) -> DevboxAsyncExecutionDetailView:
2921
+ """
2922
+ Polls the asynchronous execution's status until it reaches one of the desired
2923
+ statuses or times out. Defaults to 60 seconds.
2924
+
2925
+ Args:
2926
+ statuses: The command execution statuses to wait for. At least one status must be
2927
+ provided. The command will be returned as soon as it reaches any of the provided
2928
+ statuses.
2929
+
2930
+ timeout_seconds: (Optional) Timeout in seconds to wait for the status, up to 60 seconds. Defaults
2931
+ to 60 seconds.
2932
+
2933
+ extra_headers: Send extra headers
2934
+
2935
+ extra_query: Add additional query parameters to the request
2936
+
2937
+ extra_body: Add additional JSON properties to the request
2938
+
2939
+ timeout: Override the client-level default timeout for this request, in seconds
2940
+
2941
+ idempotency_key: Specify a custom idempotency key for this request
2942
+ """
2943
+ if not devbox_id:
2944
+ raise ValueError(f"Expected a non-empty value for `devbox_id` but received {devbox_id!r}")
2945
+ if not execution_id:
2946
+ raise ValueError(f"Expected a non-empty value for `execution_id` but received {execution_id!r}")
2947
+ return await self._post(
2948
+ f"/v1/devboxes/{devbox_id}/executions/{execution_id}/wait_for_status",
2949
+ body=await async_maybe_transform(
2950
+ {
2951
+ "statuses": statuses,
2952
+ "timeout_seconds": timeout_seconds,
2953
+ },
2954
+ devbox_wait_for_command_params.DevboxWaitForCommandParams,
2955
+ ),
2956
+ options=make_request_options(
2957
+ extra_headers=extra_headers,
2958
+ extra_query=extra_query,
2959
+ extra_body=extra_body,
2960
+ timeout=timeout,
2961
+ idempotency_key=idempotency_key,
2962
+ ),
2963
+ cast_to=DevboxAsyncExecutionDetailView,
2964
+ )
2965
+
2966
+ async def write_file_contents(
2967
+ self,
2968
+ id: str,
2969
+ *,
2970
+ contents: str,
2971
+ file_path: str,
2972
+ # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
2973
+ # The extra values given here take precedence over values defined on the client or passed to this method.
2974
+ extra_headers: Headers | None = None,
2975
+ extra_query: Query | None = None,
2976
+ extra_body: Body | None = None,
2977
+ timeout: float | httpx.Timeout | None | NotGiven = not_given,
2978
+ idempotency_key: str | None = None,
2979
+ ) -> DevboxExecutionDetailView:
2980
+ """Write UTF-8 string contents to a file at path on the Devbox.
2981
+
2982
+ Note for large
2983
+ files (larger than 100MB), the upload_file endpoint must be used.
2984
+
2985
+ Args:
2986
+ contents: The UTF-8 string contents to write to the file.
2987
+
2988
+ file_path: The path to write the file to on the Devbox. Path is relative to user home
2989
+ directory.
2990
+
2991
+ extra_headers: Send extra headers
2992
+
2993
+ extra_query: Add additional query parameters to the request
2994
+
2995
+ extra_body: Add additional JSON properties to the request
2996
+
2997
+ timeout: Override the client-level default timeout for this request, in seconds
2998
+
2999
+ idempotency_key: Specify a custom idempotency key for this request
3000
+ """
3001
+ if not id:
3002
+ raise ValueError(f"Expected a non-empty value for `id` but received {id!r}")
3003
+ if not is_given(timeout) and self._client.timeout == DEFAULT_TIMEOUT:
3004
+ timeout = 600
3005
+ return await self._post(
3006
+ f"/v1/devboxes/{id}/write_file_contents",
3007
+ body=await async_maybe_transform(
3008
+ {
3009
+ "contents": contents,
3010
+ "file_path": file_path,
3011
+ },
3012
+ devbox_write_file_contents_params.DevboxWriteFileContentsParams,
3013
+ ),
3014
+ options=make_request_options(
3015
+ extra_headers=extra_headers,
3016
+ extra_query=extra_query,
3017
+ extra_body=extra_body,
3018
+ timeout=timeout,
3019
+ idempotency_key=idempotency_key,
3020
+ ),
3021
+ cast_to=DevboxExecutionDetailView,
3022
+ )
3023
+
3024
+
3025
+ class DevboxesResourceWithRawResponse:
3026
+ def __init__(self, devboxes: DevboxesResource) -> None:
3027
+ self._devboxes = devboxes
3028
+
3029
+ self.create = to_raw_response_wrapper(
3030
+ devboxes.create,
3031
+ )
3032
+ self.retrieve = to_raw_response_wrapper(
3033
+ devboxes.retrieve,
3034
+ )
3035
+ self.update = to_raw_response_wrapper(
3036
+ devboxes.update,
3037
+ )
3038
+ self.list = to_raw_response_wrapper(
3039
+ devboxes.list,
3040
+ )
3041
+ self.create_ssh_key = to_raw_response_wrapper(
3042
+ devboxes.create_ssh_key,
3043
+ )
3044
+ self.create_tunnel = to_raw_response_wrapper(
3045
+ devboxes.create_tunnel,
3046
+ )
3047
+ self.delete_disk_snapshot = to_raw_response_wrapper(
3048
+ devboxes.delete_disk_snapshot,
3049
+ )
3050
+ self.download_file = to_custom_raw_response_wrapper(
3051
+ devboxes.download_file,
3052
+ BinaryAPIResponse,
3053
+ )
3054
+ self.execute = to_raw_response_wrapper(
3055
+ devboxes.execute,
3056
+ )
3057
+ self.execute_async = to_raw_response_wrapper(
3058
+ devboxes.execute_async,
3059
+ )
3060
+ self.execute_sync = ( # pyright: ignore[reportDeprecated]
3061
+ to_raw_response_wrapper(
3062
+ devboxes.execute_sync, # pyright: ignore[reportDeprecated],
3063
+ )
3064
+ )
3065
+ self.keep_alive = to_raw_response_wrapper(
3066
+ devboxes.keep_alive,
3067
+ )
3068
+ self.list_disk_snapshots = to_raw_response_wrapper(
3069
+ devboxes.list_disk_snapshots,
3070
+ )
3071
+ self.read_file_contents = to_raw_response_wrapper(
3072
+ devboxes.read_file_contents,
3073
+ )
3074
+ self.remove_tunnel = to_raw_response_wrapper(
3075
+ devboxes.remove_tunnel,
3076
+ )
3077
+ self.resume = to_raw_response_wrapper(
3078
+ devboxes.resume,
3079
+ )
3080
+ self.shutdown = to_raw_response_wrapper(
3081
+ devboxes.shutdown,
3082
+ )
3083
+ self.snapshot_disk = to_raw_response_wrapper(
3084
+ devboxes.snapshot_disk,
3085
+ )
3086
+ self.snapshot_disk_async = to_raw_response_wrapper(
3087
+ devboxes.snapshot_disk_async,
3088
+ )
3089
+ self.suspend = to_raw_response_wrapper(
3090
+ devboxes.suspend,
3091
+ )
3092
+ self.upload_file = to_raw_response_wrapper(
3093
+ devboxes.upload_file,
3094
+ )
3095
+ self.wait_for_command = to_raw_response_wrapper(
3096
+ devboxes.wait_for_command,
3097
+ )
3098
+ self.write_file_contents = to_raw_response_wrapper(
3099
+ devboxes.write_file_contents,
3100
+ )
3101
+
3102
+ @cached_property
3103
+ def disk_snapshots(self) -> DiskSnapshotsResourceWithRawResponse:
3104
+ return DiskSnapshotsResourceWithRawResponse(self._devboxes.disk_snapshots)
3105
+
3106
+ @cached_property
3107
+ def browsers(self) -> BrowsersResourceWithRawResponse:
3108
+ return BrowsersResourceWithRawResponse(self._devboxes.browsers)
3109
+
3110
+ @cached_property
3111
+ def computers(self) -> ComputersResourceWithRawResponse:
3112
+ return ComputersResourceWithRawResponse(self._devboxes.computers)
3113
+
3114
+ @cached_property
3115
+ def logs(self) -> LogsResourceWithRawResponse:
3116
+ return LogsResourceWithRawResponse(self._devboxes.logs)
3117
+
3118
+ @cached_property
3119
+ def executions(self) -> ExecutionsResourceWithRawResponse:
3120
+ return ExecutionsResourceWithRawResponse(self._devboxes.executions)
3121
+
3122
+
3123
+ class AsyncDevboxesResourceWithRawResponse:
3124
+ def __init__(self, devboxes: AsyncDevboxesResource) -> None:
3125
+ self._devboxes = devboxes
3126
+
3127
+ self.create = async_to_raw_response_wrapper(
3128
+ devboxes.create,
3129
+ )
3130
+ self.retrieve = async_to_raw_response_wrapper(
3131
+ devboxes.retrieve,
3132
+ )
3133
+ self.update = async_to_raw_response_wrapper(
3134
+ devboxes.update,
3135
+ )
3136
+ self.list = async_to_raw_response_wrapper(
3137
+ devboxes.list,
3138
+ )
3139
+ self.create_ssh_key = async_to_raw_response_wrapper(
3140
+ devboxes.create_ssh_key,
3141
+ )
3142
+ self.create_tunnel = async_to_raw_response_wrapper(
3143
+ devboxes.create_tunnel,
3144
+ )
3145
+ self.delete_disk_snapshot = async_to_raw_response_wrapper(
3146
+ devboxes.delete_disk_snapshot,
3147
+ )
3148
+ self.download_file = async_to_custom_raw_response_wrapper(
3149
+ devboxes.download_file,
3150
+ AsyncBinaryAPIResponse,
3151
+ )
3152
+ self.execute = async_to_raw_response_wrapper(
3153
+ devboxes.execute,
3154
+ )
3155
+ self.execute_async = async_to_raw_response_wrapper(
3156
+ devboxes.execute_async,
3157
+ )
3158
+ self.execute_sync = ( # pyright: ignore[reportDeprecated]
3159
+ async_to_raw_response_wrapper(
3160
+ devboxes.execute_sync, # pyright: ignore[reportDeprecated],
3161
+ )
3162
+ )
3163
+ self.keep_alive = async_to_raw_response_wrapper(
3164
+ devboxes.keep_alive,
3165
+ )
3166
+ self.list_disk_snapshots = async_to_raw_response_wrapper(
3167
+ devboxes.list_disk_snapshots,
3168
+ )
3169
+ self.read_file_contents = async_to_raw_response_wrapper(
3170
+ devboxes.read_file_contents,
3171
+ )
3172
+ self.remove_tunnel = async_to_raw_response_wrapper(
3173
+ devboxes.remove_tunnel,
3174
+ )
3175
+ self.resume = async_to_raw_response_wrapper(
3176
+ devboxes.resume,
3177
+ )
3178
+ self.shutdown = async_to_raw_response_wrapper(
3179
+ devboxes.shutdown,
3180
+ )
3181
+ self.snapshot_disk = async_to_raw_response_wrapper(
3182
+ devboxes.snapshot_disk,
3183
+ )
3184
+ self.snapshot_disk_async = async_to_raw_response_wrapper(
3185
+ devboxes.snapshot_disk_async,
3186
+ )
3187
+ self.suspend = async_to_raw_response_wrapper(
3188
+ devboxes.suspend,
3189
+ )
3190
+ self.upload_file = async_to_raw_response_wrapper(
3191
+ devboxes.upload_file,
3192
+ )
3193
+ self.wait_for_command = async_to_raw_response_wrapper(
3194
+ devboxes.wait_for_command,
3195
+ )
3196
+ self.write_file_contents = async_to_raw_response_wrapper(
3197
+ devboxes.write_file_contents,
3198
+ )
3199
+
3200
+ @cached_property
3201
+ def disk_snapshots(self) -> AsyncDiskSnapshotsResourceWithRawResponse:
3202
+ return AsyncDiskSnapshotsResourceWithRawResponse(self._devboxes.disk_snapshots)
3203
+
3204
+ @cached_property
3205
+ def browsers(self) -> AsyncBrowsersResourceWithRawResponse:
3206
+ return AsyncBrowsersResourceWithRawResponse(self._devboxes.browsers)
3207
+
3208
+ @cached_property
3209
+ def computers(self) -> AsyncComputersResourceWithRawResponse:
3210
+ return AsyncComputersResourceWithRawResponse(self._devboxes.computers)
3211
+
3212
+ @cached_property
3213
+ def logs(self) -> AsyncLogsResourceWithRawResponse:
3214
+ return AsyncLogsResourceWithRawResponse(self._devboxes.logs)
3215
+
3216
+ @cached_property
3217
+ def executions(self) -> AsyncExecutionsResourceWithRawResponse:
3218
+ return AsyncExecutionsResourceWithRawResponse(self._devboxes.executions)
3219
+
3220
+
3221
+ class DevboxesResourceWithStreamingResponse:
3222
+ def __init__(self, devboxes: DevboxesResource) -> None:
3223
+ self._devboxes = devboxes
3224
+
3225
+ self.create = to_streamed_response_wrapper(
3226
+ devboxes.create,
3227
+ )
3228
+ self.retrieve = to_streamed_response_wrapper(
3229
+ devboxes.retrieve,
3230
+ )
3231
+ self.update = to_streamed_response_wrapper(
3232
+ devboxes.update,
3233
+ )
3234
+ self.list = to_streamed_response_wrapper(
3235
+ devboxes.list,
3236
+ )
3237
+ self.create_ssh_key = to_streamed_response_wrapper(
3238
+ devboxes.create_ssh_key,
3239
+ )
3240
+ self.create_tunnel = to_streamed_response_wrapper(
3241
+ devboxes.create_tunnel,
3242
+ )
3243
+ self.delete_disk_snapshot = to_streamed_response_wrapper(
3244
+ devboxes.delete_disk_snapshot,
3245
+ )
3246
+ self.download_file = to_custom_streamed_response_wrapper(
3247
+ devboxes.download_file,
3248
+ StreamedBinaryAPIResponse,
3249
+ )
3250
+ self.execute = to_streamed_response_wrapper(
3251
+ devboxes.execute,
3252
+ )
3253
+ self.execute_async = to_streamed_response_wrapper(
3254
+ devboxes.execute_async,
3255
+ )
3256
+ self.execute_sync = ( # pyright: ignore[reportDeprecated]
3257
+ to_streamed_response_wrapper(
3258
+ devboxes.execute_sync, # pyright: ignore[reportDeprecated],
3259
+ )
3260
+ )
3261
+ self.keep_alive = to_streamed_response_wrapper(
3262
+ devboxes.keep_alive,
3263
+ )
3264
+ self.list_disk_snapshots = to_streamed_response_wrapper(
3265
+ devboxes.list_disk_snapshots,
3266
+ )
3267
+ self.read_file_contents = to_streamed_response_wrapper(
3268
+ devboxes.read_file_contents,
3269
+ )
3270
+ self.remove_tunnel = to_streamed_response_wrapper(
3271
+ devboxes.remove_tunnel,
3272
+ )
3273
+ self.resume = to_streamed_response_wrapper(
3274
+ devboxes.resume,
3275
+ )
3276
+ self.shutdown = to_streamed_response_wrapper(
3277
+ devboxes.shutdown,
3278
+ )
3279
+ self.snapshot_disk = to_streamed_response_wrapper(
3280
+ devboxes.snapshot_disk,
3281
+ )
3282
+ self.snapshot_disk_async = to_streamed_response_wrapper(
3283
+ devboxes.snapshot_disk_async,
3284
+ )
3285
+ self.suspend = to_streamed_response_wrapper(
3286
+ devboxes.suspend,
3287
+ )
3288
+ self.upload_file = to_streamed_response_wrapper(
3289
+ devboxes.upload_file,
3290
+ )
3291
+ self.wait_for_command = to_streamed_response_wrapper(
3292
+ devboxes.wait_for_command,
3293
+ )
3294
+ self.write_file_contents = to_streamed_response_wrapper(
3295
+ devboxes.write_file_contents,
3296
+ )
3297
+
3298
+ @cached_property
3299
+ def disk_snapshots(self) -> DiskSnapshotsResourceWithStreamingResponse:
3300
+ return DiskSnapshotsResourceWithStreamingResponse(self._devboxes.disk_snapshots)
3301
+
3302
+ @cached_property
3303
+ def browsers(self) -> BrowsersResourceWithStreamingResponse:
3304
+ return BrowsersResourceWithStreamingResponse(self._devboxes.browsers)
3305
+
3306
+ @cached_property
3307
+ def computers(self) -> ComputersResourceWithStreamingResponse:
3308
+ return ComputersResourceWithStreamingResponse(self._devboxes.computers)
3309
+
3310
+ @cached_property
3311
+ def logs(self) -> LogsResourceWithStreamingResponse:
3312
+ return LogsResourceWithStreamingResponse(self._devboxes.logs)
3313
+
3314
+ @cached_property
3315
+ def executions(self) -> ExecutionsResourceWithStreamingResponse:
3316
+ return ExecutionsResourceWithStreamingResponse(self._devboxes.executions)
3317
+
3318
+
3319
+ class AsyncDevboxesResourceWithStreamingResponse:
3320
+ def __init__(self, devboxes: AsyncDevboxesResource) -> None:
3321
+ self._devboxes = devboxes
3322
+
3323
+ self.create = async_to_streamed_response_wrapper(
3324
+ devboxes.create,
3325
+ )
3326
+ self.retrieve = async_to_streamed_response_wrapper(
3327
+ devboxes.retrieve,
3328
+ )
3329
+ self.update = async_to_streamed_response_wrapper(
3330
+ devboxes.update,
3331
+ )
3332
+ self.list = async_to_streamed_response_wrapper(
3333
+ devboxes.list,
3334
+ )
3335
+ self.create_ssh_key = async_to_streamed_response_wrapper(
3336
+ devboxes.create_ssh_key,
3337
+ )
3338
+ self.create_tunnel = async_to_streamed_response_wrapper(
3339
+ devboxes.create_tunnel,
3340
+ )
3341
+ self.delete_disk_snapshot = async_to_streamed_response_wrapper(
3342
+ devboxes.delete_disk_snapshot,
3343
+ )
3344
+ self.download_file = async_to_custom_streamed_response_wrapper(
3345
+ devboxes.download_file,
3346
+ AsyncStreamedBinaryAPIResponse,
3347
+ )
3348
+ self.execute = async_to_streamed_response_wrapper(
3349
+ devboxes.execute,
3350
+ )
3351
+ self.execute_async = async_to_streamed_response_wrapper(
3352
+ devboxes.execute_async,
3353
+ )
3354
+ self.execute_sync = ( # pyright: ignore[reportDeprecated]
3355
+ async_to_streamed_response_wrapper(
3356
+ devboxes.execute_sync, # pyright: ignore[reportDeprecated],
3357
+ )
3358
+ )
3359
+ self.keep_alive = async_to_streamed_response_wrapper(
3360
+ devboxes.keep_alive,
3361
+ )
3362
+ self.list_disk_snapshots = async_to_streamed_response_wrapper(
3363
+ devboxes.list_disk_snapshots,
3364
+ )
3365
+ self.read_file_contents = async_to_streamed_response_wrapper(
3366
+ devboxes.read_file_contents,
3367
+ )
3368
+ self.remove_tunnel = async_to_streamed_response_wrapper(
3369
+ devboxes.remove_tunnel,
3370
+ )
3371
+ self.resume = async_to_streamed_response_wrapper(
3372
+ devboxes.resume,
3373
+ )
3374
+ self.shutdown = async_to_streamed_response_wrapper(
3375
+ devboxes.shutdown,
3376
+ )
3377
+ self.snapshot_disk = async_to_streamed_response_wrapper(
3378
+ devboxes.snapshot_disk,
3379
+ )
3380
+ self.snapshot_disk_async = async_to_streamed_response_wrapper(
3381
+ devboxes.snapshot_disk_async,
3382
+ )
3383
+ self.suspend = async_to_streamed_response_wrapper(
3384
+ devboxes.suspend,
3385
+ )
3386
+ self.upload_file = async_to_streamed_response_wrapper(
3387
+ devboxes.upload_file,
3388
+ )
3389
+ self.wait_for_command = async_to_streamed_response_wrapper(
3390
+ devboxes.wait_for_command,
3391
+ )
3392
+ self.write_file_contents = async_to_streamed_response_wrapper(
3393
+ devboxes.write_file_contents,
3394
+ )
3395
+
3396
+ @cached_property
3397
+ def disk_snapshots(self) -> AsyncDiskSnapshotsResourceWithStreamingResponse:
3398
+ return AsyncDiskSnapshotsResourceWithStreamingResponse(self._devboxes.disk_snapshots)
3399
+
3400
+ @cached_property
3401
+ def browsers(self) -> AsyncBrowsersResourceWithStreamingResponse:
3402
+ return AsyncBrowsersResourceWithStreamingResponse(self._devboxes.browsers)
3403
+
3404
+ @cached_property
3405
+ def computers(self) -> AsyncComputersResourceWithStreamingResponse:
3406
+ return AsyncComputersResourceWithStreamingResponse(self._devboxes.computers)
3407
+
3408
+ @cached_property
3409
+ def logs(self) -> AsyncLogsResourceWithStreamingResponse:
3410
+ return AsyncLogsResourceWithStreamingResponse(self._devboxes.logs)
3411
+
3412
+ @cached_property
3413
+ def executions(self) -> AsyncExecutionsResourceWithStreamingResponse:
3414
+ return AsyncExecutionsResourceWithStreamingResponse(self._devboxes.executions)