@@ -84,11 +84,11 @@ class Sandbox(BaseModel):
8484 """配置对象,用于子类的 data_api 初始化 / Config object for data_api initialization"""
8585
8686 @classmethod
87- def __get_client (cls ):
87+ def __get_client (cls , config : Optional [ Config ] = None ):
8888 """获取 Sandbox 客户端"""
8989 from .client import SandboxClient
9090
91- return SandboxClient ()
91+ return SandboxClient (config = config )
9292
9393 @classmethod
9494 @overload
@@ -250,7 +250,7 @@ async def create_async(
250250 )
251251
252252 # 创建 Sandbox(返回基类实例)
253- base_sandbox = await cls .__get_client ().create_sandbox_async (
253+ base_sandbox = await cls .__get_client (config = config ).create_sandbox_async (
254254 template_name = template_name ,
255255 sandbox_idle_timeout_seconds = sandbox_idle_timeout_seconds ,
256256 sandbox_id = sandbox_id ,
@@ -326,7 +326,7 @@ def create(
326326 )
327327
328328 # 创建 Sandbox(返回基类实例)
329- base_sandbox = cls .__get_client ().create_sandbox (
329+ base_sandbox = cls .__get_client (config = config ).create_sandbox (
330330 template_name = template_name ,
331331 sandbox_idle_timeout_seconds = sandbox_idle_timeout_seconds ,
332332 sandbox_id = sandbox_id ,
@@ -377,7 +377,7 @@ async def stop_by_id_async(
377377 """
378378 if sandbox_id is None :
379379 raise ValueError ("sandbox_id is required" )
380- return await cls .__get_client ().stop_sandbox_async (
380+ return await cls .__get_client (config = config ).stop_sandbox_async (
381381 sandbox_id , config = config
382382 )
383383
@@ -394,7 +394,7 @@ def stop_by_id(cls, sandbox_id: str, config: Optional[Config] = None):
394394 """
395395 if sandbox_id is None :
396396 raise ValueError ("sandbox_id is required" )
397- return cls .__get_client ().stop_sandbox (sandbox_id , config = config )
397+ return cls .__get_client (config = config ).stop_sandbox (sandbox_id , config = config )
398398
399399 @classmethod
400400 async def delete_by_id_async (
@@ -411,7 +411,7 @@ async def delete_by_id_async(
411411 """
412412 if sandbox_id is None :
413413 raise ValueError ("sandbox_id is required" )
414- return await cls .__get_client ().delete_sandbox_async (
414+ return await cls .__get_client (config = config ).delete_sandbox_async (
415415 sandbox_id , config = config
416416 )
417417
@@ -428,7 +428,7 @@ def delete_by_id(cls, sandbox_id: str, config: Optional[Config] = None):
428428 """
429429 if sandbox_id is None :
430430 raise ValueError ("sandbox_id is required" )
431- return cls .__get_client ().delete_sandbox (sandbox_id , config = config )
431+ return cls .__get_client (config = config ).delete_sandbox (sandbox_id , config = config )
432432
433433 @classmethod
434434 async def list_async (
@@ -445,7 +445,7 @@ async def list_async(
445445 Returns:
446446 ListSandboxesOutput: Sandbox 列表结果
447447 """
448- return await cls .__get_client ().list_sandboxes_async (input , config )
448+ return await cls .__get_client (config = config ).list_sandboxes_async (input , config )
449449
450450 @classmethod
451451 def list (
@@ -462,7 +462,7 @@ def list(
462462 Returns:
463463 ListSandboxesOutput: Sandbox 列表结果
464464 """
465- return cls .__get_client ().list_sandboxes (input , config )
465+ return cls .__get_client (config = config ).list_sandboxes (input , config )
466466
467467 @classmethod
468468 @overload
@@ -570,7 +570,7 @@ async def connect_async(
570570 raise ValueError ("sandbox_id is required" )
571571
572572 # 先获取 sandbox 信息
573- sandbox = await cls .__get_client ().get_sandbox_async (
573+ sandbox = await cls .__get_client (config = config ).get_sandbox_async (
574574 sandbox_id , config = config
575575 )
576576
@@ -640,7 +640,7 @@ def connect(
640640 raise ValueError ("sandbox_id is required" )
641641
642642 # 先获取 sandbox 信息
643- sandbox = cls .__get_client ().get_sandbox (sandbox_id , config = config )
643+ sandbox = cls .__get_client (config = config ).get_sandbox (sandbox_id , config = config )
644644
645645 resolved_type = template_type
646646 if resolved_type is None :
@@ -695,7 +695,7 @@ async def create_template_async(
695695 """
696696 if input .template_type is None :
697697 raise ValueError ("template_type is required" )
698- return await cls .__get_client ().create_template_async (
698+ return await cls .__get_client (config = config ).create_template_async (
699699 input , config = config
700700 )
701701
@@ -714,7 +714,7 @@ def create_template(
714714 """
715715 if input .template_type is None :
716716 raise ValueError ("template_type is required" )
717- return cls .__get_client ().create_template (input , config = config )
717+ return cls .__get_client (config = config ).create_template (input , config = config )
718718
719719 @classmethod
720720 async def get_template_async (
@@ -731,7 +731,7 @@ async def get_template_async(
731731 """
732732 if template_name is None :
733733 raise ValueError ("template_name is required" )
734- return await cls .__get_client ().get_template_async (
734+ return await cls .__get_client (config = config ).get_template_async (
735735 template_name , config = config
736736 )
737737
@@ -750,7 +750,7 @@ def get_template(
750750 """
751751 if template_name is None :
752752 raise ValueError ("template_name is required" )
753- return cls .__get_client ().get_template (template_name , config = config )
753+ return cls .__get_client (config = config ).get_template (template_name , config = config )
754754
755755 @classmethod
756756 async def update_template_async (
@@ -771,7 +771,7 @@ async def update_template_async(
771771 """
772772 if template_name is None :
773773 raise ValueError ("template_name is required" )
774- return await cls .__get_client ().update_template_async (
774+ return await cls .__get_client (config = config ).update_template_async (
775775 template_name , input , config = config
776776 )
777777
@@ -794,7 +794,7 @@ def update_template(
794794 """
795795 if template_name is None :
796796 raise ValueError ("template_name is required" )
797- return cls .__get_client ().update_template (
797+ return cls .__get_client (config = config ).update_template (
798798 template_name , input , config = config
799799 )
800800
@@ -813,7 +813,7 @@ async def delete_template_async(
813813 """
814814 if template_name is None :
815815 raise ValueError ("template_name is required" )
816- return await cls .__get_client ().delete_template_async (
816+ return await cls .__get_client (config = config ).delete_template_async (
817817 template_name , config = config
818818 )
819819
@@ -832,7 +832,7 @@ def delete_template(
832832 """
833833 if template_name is None :
834834 raise ValueError ("template_name is required" )
835- return cls .__get_client ().delete_template (template_name , config = config )
835+ return cls .__get_client (config = config ).delete_template (template_name , config = config )
836836
837837 @classmethod
838838 async def list_templates_async (
@@ -849,7 +849,7 @@ async def list_templates_async(
849849 Returns:
850850 List[Template]: Template 列表
851851 """
852- return await cls .__get_client ().list_templates_async (
852+ return await cls .__get_client (config = config ).list_templates_async (
853853 input , config = config
854854 )
855855
@@ -868,7 +868,7 @@ def list_templates(
868868 Returns:
869869 List[Template]: Template 列表
870870 """
871- return cls .__get_client ().list_templates (input , config = config )
871+ return cls .__get_client (config = config ).list_templates (input , config = config )
872872
873873 async def get_async (self ):
874874 if self .sandbox_id is None :
0 commit comments