22
33from __future__ import annotations
44
5- from typing import Dict , List , Iterable , Optional
5+ from typing import Dict , List , Iterable , Optional , TypedDict
66
77import httpx
88
2828from ..types .shared_params .launch_parameters import LaunchParameters
2929from ..types .shared_params .code_mount_parameters import CodeMountParameters
3030
31- __all__ = ["BlueprintsResource" , "AsyncBlueprintsResource" ]
31+
32+ # Type for request arguments that combine polling config with additional request options
33+ class BlueprintRequestArgs (TypedDict , total = False ):
34+ polling_config : PollingConfig | None
35+ # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
36+ # The extra values given here take precedence over values defined on the client or passed to this method.
37+ extra_headers : Headers | None
38+ extra_query : Query | None
39+ extra_body : Body | None
40+ timeout : float | httpx .Timeout | None | NotGiven
41+
42+
43+ __all__ = ["BlueprintsResource" , "AsyncBlueprintsResource" , "BlueprintRequestArgs" ]
3244
3345
3446class BlueprintsResource (SyncAPIResource ):
@@ -188,13 +200,10 @@ def await_build_complete(
188200 PollingTimeout: If polling times out before blueprint is built
189201 RunloopError: If blueprint enters a non-built terminal state
190202 """
203+
191204 def retrieve_blueprint () -> BlueprintView :
192205 return self .retrieve (
193- id ,
194- extra_headers = extra_headers ,
195- extra_query = extra_query ,
196- extra_body = extra_body ,
197- timeout = timeout
206+ id , extra_headers = extra_headers , extra_query = extra_query , extra_body = extra_body , timeout = timeout
198207 )
199208
200209 def is_done_building (blueprint : BlueprintView ) -> bool :
@@ -203,44 +212,23 @@ def is_done_building(blueprint: BlueprintView) -> bool:
203212 blueprint = poll_until (retrieve_blueprint , is_done_building , polling_config )
204213
205214 if blueprint .status != "build_complete" :
206- raise RunloopError (
207- f"Blueprint entered non-built terminal state: { blueprint .status } "
208- )
215+ raise RunloopError (f"Blueprint entered non-built terminal state: { blueprint .status } " )
209216
210217 return blueprint
211218
212219 def create_and_await_build_complete (
213220 self ,
214221 * ,
215- name : str ,
216- code_mounts : Optional [Iterable [CodeMountParameters ]] | NotGiven = NOT_GIVEN ,
217- dockerfile : Optional [str ] | NotGiven = NOT_GIVEN ,
218- file_mounts : Optional [Dict [str , str ]] | NotGiven = NOT_GIVEN ,
219- launch_parameters : Optional [LaunchParameters ] | NotGiven = NOT_GIVEN ,
220- system_setup_commands : Optional [List [str ]] | NotGiven = NOT_GIVEN ,
221- polling_config : PollingConfig | None = None ,
222- # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
223- # The extra values given here take precedence over values defined on the client or passed to this method.
224- extra_headers : Headers | None = None ,
225- extra_query : Query | None = None ,
226- extra_body : Body | None = None ,
227- timeout : float | httpx .Timeout | None | NotGiven = NOT_GIVEN ,
228- idempotency_key : str | None = None ,
222+ create_args : blueprint_create_params .BlueprintCreateParams ,
223+ request_args : BlueprintRequestArgs | None = None ,
229224 ) -> BlueprintView :
230225 """Create a new Blueprint and wait for it to finish building.
231226
227+ This is a wrapper around the `create` method that waits for the blueprint to finish building.
228+
232229 Args:
233- dockerfile: The Dockerfile contents to use for building the Blueprint
234- file_mounts: Files to mount into the Blueprint
235- launch_parameters: Launch parameters for Devboxes created from this Blueprint
236- name: Name for the Blueprint
237- system_setup_commands: Commands to run during Blueprint build
238- polling_config: Optional polling configuration
239- extra_headers: Send extra headers
240- extra_query: Add additional query parameters to the request
241- extra_body: Add additional JSON properties to the request
242- timeout: Override the client-level default timeout for this request, in seconds
243- idempotency_key: Specify a custom idempotency key for this request
230+ create_args: Arguments to pass to the `create` method. See the `create` method for detailed documentation.
231+ request_args: Optional request arguments including polling configuration and additional request options
244232
245233 Returns:
246234 The built blueprint
@@ -249,27 +237,19 @@ def create_and_await_build_complete(
249237 PollingTimeout: If polling times out before blueprint is built
250238 RunloopError: If blueprint enters a non-built terminal state
251239 """
252- blueprint = self .create (
253- name = name ,
254- dockerfile = dockerfile ,
255- code_mounts = code_mounts ,
256- file_mounts = file_mounts ,
257- launch_parameters = launch_parameters ,
258- system_setup_commands = system_setup_commands ,
259- extra_headers = extra_headers ,
260- extra_query = extra_query ,
261- extra_body = extra_body ,
262- timeout = timeout ,
263- idempotency_key = idempotency_key ,
264- )
240+ # Pass all create_args to the underlying create method
241+ blueprint = self .create (** create_args )
242+
243+ if request_args is None :
244+ request_args = {}
265245
266246 return self .await_build_complete (
267247 blueprint .id ,
268- polling_config = polling_config ,
269- extra_headers = extra_headers ,
270- extra_query = extra_query ,
271- extra_body = extra_body ,
272- timeout = timeout ,
248+ polling_config = request_args . get ( " polling_config" , None ) ,
249+ extra_headers = request_args . get ( " extra_headers" , None ) ,
250+ extra_query = request_args . get ( " extra_query" , None ) ,
251+ extra_body = request_args . get ( " extra_body" , None ) ,
252+ timeout = request_args . get ( " timeout" , None ) ,
273253 )
274254
275255 def list (
@@ -597,7 +577,7 @@ async def retrieve(
597577 ),
598578 cast_to = BlueprintView ,
599579 )
600-
580+
601581 async def await_build_complete (
602582 self ,
603583 id : str ,
@@ -627,13 +607,10 @@ async def await_build_complete(
627607 PollingTimeout: If polling times out before blueprint is built
628608 RunloopError: If blueprint enters a non-built terminal state
629609 """
610+
630611 async def retrieve_blueprint () -> BlueprintView :
631612 return await self .retrieve (
632- id ,
633- extra_headers = extra_headers ,
634- extra_query = extra_query ,
635- extra_body = extra_body ,
636- timeout = timeout
613+ id , extra_headers = extra_headers , extra_query = extra_query , extra_body = extra_body , timeout = timeout
637614 )
638615
639616 def is_done_building (blueprint : BlueprintView ) -> bool :
@@ -642,44 +619,23 @@ def is_done_building(blueprint: BlueprintView) -> bool:
642619 blueprint = await async_poll_until (retrieve_blueprint , is_done_building , polling_config )
643620
644621 if blueprint .status != "build_complete" :
645- raise RunloopError (
646- f"Blueprint entered non-built terminal state: { blueprint .status } "
647- )
622+ raise RunloopError (f"Blueprint entered non-built terminal state: { blueprint .status } " )
648623
649624 return blueprint
650625
651626 async def create_and_await_build_complete (
652627 self ,
653628 * ,
654- name : str ,
655- code_mounts : Optional [Iterable [CodeMountParameters ]] | NotGiven = NOT_GIVEN ,
656- dockerfile : Optional [str ] | NotGiven = NOT_GIVEN ,
657- file_mounts : Optional [Dict [str , str ]] | NotGiven = NOT_GIVEN ,
658- launch_parameters : Optional [LaunchParameters ] | NotGiven = NOT_GIVEN ,
659- system_setup_commands : Optional [List [str ]] | NotGiven = NOT_GIVEN ,
660- polling_config : PollingConfig | None = None ,
661- # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
662- # The extra values given here take precedence over values defined on the client or passed to this method.
663- extra_headers : Headers | None = None ,
664- extra_query : Query | None = None ,
665- extra_body : Body | None = None ,
666- timeout : float | httpx .Timeout | None | NotGiven = NOT_GIVEN ,
667- idempotency_key : str | None = None ,
629+ create_args : blueprint_create_params .BlueprintCreateParams ,
630+ request_args : BlueprintRequestArgs | None = None ,
668631 ) -> BlueprintView :
669632 """Create a new Blueprint and wait for it to finish building.
670633
634+ This is a wrapper around the `create` method that waits for the blueprint to finish building.
635+
671636 Args:
672- dockerfile: The Dockerfile contents to use for building the Blueprint
673- file_mounts: Files to mount into the Blueprint
674- launch_parameters: Launch parameters for Devboxes created from this Blueprint
675- name: Name for the Blueprint
676- system_setup_commands: Commands to run during Blueprint build
677- polling_config: Optional polling configuration
678- extra_headers: Send extra headers
679- extra_query: Add additional query parameters to the request
680- extra_body: Add additional JSON properties to the request
681- timeout: Override the client-level default timeout for this request, in seconds
682- idempotency_key: Specify a custom idempotency key for this request
637+ create_args: Arguments to pass to the `create` method. See the `create` method for detailed documentation.
638+ request_args: Optional request arguments including polling configuration and additional request options
683639
684640 Returns:
685641 The built blueprint
@@ -688,27 +644,20 @@ async def create_and_await_build_complete(
688644 PollingTimeout: If polling times out before blueprint is built
689645 RunloopError: If blueprint enters a non-built terminal state
690646 """
691- blueprint = await self .create (
692- name = name ,
693- dockerfile = dockerfile ,
694- code_mounts = code_mounts ,
695- file_mounts = file_mounts ,
696- launch_parameters = launch_parameters ,
697- system_setup_commands = system_setup_commands ,
698- extra_headers = extra_headers ,
699- extra_query = extra_query ,
700- extra_body = extra_body ,
701- timeout = timeout ,
702- idempotency_key = idempotency_key ,
703- )
647+ # Pass all create_args to the underlying create method
648+ blueprint = await self .create (** create_args )
649+
650+ # Extract polling config and other request args
651+ if request_args is None :
652+ request_args = {}
704653
705654 return await self .await_build_complete (
706655 blueprint .id ,
707- polling_config = polling_config ,
708- extra_headers = extra_headers ,
709- extra_query = extra_query ,
710- extra_body = extra_body ,
711- timeout = timeout ,
656+ polling_config = request_args . get ( " polling_config" , None ) ,
657+ extra_headers = request_args . get ( " extra_headers" , None ) ,
658+ extra_query = request_args . get ( " extra_query" , None ) ,
659+ extra_body = request_args . get ( " extra_body" , None ) ,
660+ timeout = request_args . get ( " timeout" , None ) ,
712661 )
713662
714663 def list (
0 commit comments