
    =Ki{                        S r SSKJr  SSKrSSKJrJr  SSKrSSKJ	r
  SSKJr  SSKJrJrJrJrJrJr  SSKJrJrJrJrJr  SS	KJrJrJrJr  SS
 jrSS jr  " S S5      r!g)zFAsync SandboxClient class for interacting with the sandbox server API.    )annotationsN)AnyOptional)utils)AsyncSandbox)ResourceInUseErrorResourceNameConflictErrorResourceNotFoundErrorSandboxAPIErrorSandboxConnectionErrorValidationError)handle_client_http_errorhandle_pool_errorhandle_sandbox_creation_errorhandle_volume_creation_errorparse_error_response)PoolSandboxTemplateVolumeVolumeMountSpecc                 T    [         R                  " SSS9n U R                  S5       S3$ )z~Get the default sandbox API endpoint from environment.

Derives the endpoint from LANGSMITH_ENDPOINT (or LANGCHAIN_ENDPOINT).
ENDPOINTzhttps://api.smith.langchain.com)default/z/v2/sandboxes)ls_utilsget_env_varrstrip)bases    a/var/www/html/dynamic-report/venv/lib/python3.13/site-packages/langsmith/sandbox/_async_client.py_get_default_api_endpointr       s.    
 
4UVDkk#}--    c                 .    [         R                  " S5      $ )z)Get the default API key from environment.API_KEY)r   r    r!   r   _get_default_api_keyr%   '   s    	**r!   c                     \ rS rSrSrSSSS.     S*S jjrS+S jrS+S jrS,S	 jr        S-S
 jr	SS.       S.S jjr
S/S jrS0S jrS1S jrSSS.       S2S jjrSSSSS.             S3S jjrS4S jrS5S jrS6S jrS1S jrSS.         S7S jjrS8S jrS9S jrSSS.       S:S  jjrS1S! jrSSS".       S;S# jjrSSS".       S;S$ jjrS<S% jrS=S& jrS>S' jrS1S( jrS)rg)?AsyncSandboxClient,   a  Async client for interacting with the Sandbox Server API.

This client provides an async interface for managing sandboxes and templates.

Example:
    # Uses LANGSMITH_ENDPOINT and LANGSMITH_API_KEY from environment
    async with AsyncSandboxClient() as client:
        # Create a sandbox and run commands
        async with await client.sandbox(template_name="python-sandbox") as sandbox:
            result = await sandbox.run("python --version")
            print(result.stdout)
Ng      $@)api_endpointtimeoutapi_keyc                   U=(       d
    [        5       R                  S5      U l        U=(       d
    [        5       nX@l        0 nU(       a  XES'   [
        R                  " X%S9U l        g)a]  Initialize the AsyncSandboxClient.

Args:
    api_endpoint: Full URL of the sandbox API endpoint. If not provided,
                  derived from LANGSMITH_ENDPOINT environment variable.
    timeout: Default HTTP timeout in seconds.
    api_key: API key for authentication. If not provided, uses
             LANGSMITH_API_KEY environment variable.
r   z	X-Api-Key)r*   headersN)r    r   	_base_urlr%   _api_keyhttpxAsyncClient_http)selfr)   r*   r+   resolved_api_keyr-   s         r   __init__AsyncSandboxClient.__init__:   sU      'E*C*EMMcR"<&:&<("$#3K &&wH
r!   c                T   #    U R                   R                  5       I Sh  vN   g N7f)zClose the async HTTP client.N)r2   acloser3   s    r   r8   AsyncSandboxClient.acloseR   s     jj!!!s   (&(c                    U R                   R                  (       dL   [        R                  " 5       nUR                  5       (       d   UR	                  U R                  5       5        ggg! [         a     gf = f! [         a     gf = f)a  Best-effort cleanup of the async HTTP client on garbage collection.

If an event loop is running, schedules ``aclose()`` as a task.
Otherwise the underlying sockets will be closed by the GC.
For deterministic cleanup, use ``async with`` or ``await aclose()``.
N)r2   	is_closedasyncioget_running_loopcreate_taskr8   RuntimeError	Exception)r3   loops     r   __del__AsyncSandboxClient.__del__V   sw    		::''"335D>>++((7 , (
 $  		s/   A: A	A* *
A74A: 6A77A: :
BBc                   #    U $ 7f)zEnter async context manager.r$   r9   s    r   
__aenter__AsyncSandboxClient.__aenter__h   s
     s   c                @   #    U R                  5       I Sh  vN   g N7f)zExit async context manager.N)r8   )r3   exc_typeexc_valexc_tbs       r   	__aexit__AsyncSandboxClient.__aexit__l   s      kkms   <   )r*   c                 #    U R                    S3nUUSUS.n U R                  R                  XEUS-   S9I Sh  vN nUR                  5         [        R
                  " UR                  5       5      $  N8! [        R                   a  n[        SU 35      UeSnAf[        R                   a  n[        U5        e SnAff = f7f)a  Create a new persistent volume.

Creates a persistent storage volume that can be referenced in templates.

Args:
    name: Volume name.
    size: Storage size (e.g., "1Gi", "10Gi").
    timeout: Timeout in seconds when waiting for ready (min: 5, max: 300).

Returns:
    Created Volume.

Raises:
    VolumeProvisioningError: If volume provisioning fails.
    ResourceTimeoutError: If volume doesn't become ready within timeout.
    SandboxClientError: For other errors.
/volumesT)namesizewait_for_readyr*      jsonr*   NFailed to connect to server: )r.   r2   postraise_for_statusr   	from_dictrV   r0   ConnectErrorr   HTTPStatusErrorr   )r3   rQ   rR   r*   urlpayloadresponsees           r   create_volume AsyncSandboxClient.create_volumey   s     0  ) "	
		!ZZ__SRT_UUH%%'##HMMO44 V !! 	U(+H)LMSTT$$ 	(+	sD   C A5 A37A5 2C3A5 5C 	BC /B;;C  Cc                  #    U R                    SU 3n U R                  R                  U5      I Sh  vN nUR                  5         [        R
                  " UR                  5       5      $  N8! [        R                   a  n[        SU 35      UeSnAf[        R                   a:  nUR                  R                  S:X  a  [        SU S3SS9Ue[        U5        e SnAff = f7f)	zGet a volume by name.

Args:
    name: Volume name.

Returns:
    Volume.

Raises:
    ResourceNotFoundError: If volume not found.
    SandboxClientError: For other errors.
	/volumes/NrW     Volume '' not foundvolumeresource_type)r.   r2   getrY   r   rZ   rV   r0   r[   r   r\   r_   status_coder
   r   r3   rQ   r]   r_   r`   s        r   
get_volumeAsyncSandboxClient.get_volume   s       	$0	!ZZ^^C00H%%'##HMMO44 1 !! 	U(+H)LMSTT$$ 	zz%%,+tfK0 %Q'	D   C%A. A,7A. +C%,A. .C"BC"(5CC""C%c                  #    U R                    S3n U R                  R                  U5      I Sh  vN nUR                  5         UR	                  5       nUR                  S/ 5       Vs/ s H  n[
        R                  " U5      PM     sn$  N[s  snf ! [        R                   a  n[        SU 35      UeSnAf[        R                   a;  nUR                  R                  S:X  a  [        SU S35      Ue[        U5        e SnAff = f7f)z1List all volumes.

Returns:
    List of Volumes.
rP   NvolumesrW   re   API endpoint not found: %. Check that api_endpoint is correct.)r.   r2   rk   rY   rV   r   rZ   r0   r[   r   r\   r_   rl   r   r   )r3   r]   r_   datavr`   s         r   list_volumesAsyncSandboxClient.list_volumes   s       )	!ZZ^^C00H%%'==?D15)R1HI1HAF$$Q'1HII 1 J!! 	U(+H)LMSTT$$ 	zz%%,%.se 4: ;  %Q'	V   DB B8B * B
B DB B D	(B77D	6DD		Dc                  #    U R                    SU 3n U R                  R                  U5      I Sh  vN nUR                  5         g N! [        R
                   a  n[        SU 35      UeSnAf[        R                   aq  nUR                  R                  S:X  a  [        SU S3SS9UeUR                  R                  S	:X  a  [        U5      n[        US
   SS9Ue[        U5         SnAgSnAff = f7f)zDelete a volume.

Args:
    name: Volume name.

Raises:
    ResourceNotFoundError: If volume not found.
    ResourceInUseError: If volume is referenced by templates.
    SandboxClientError: For other errors.
rd   NrW   re   rf   rg   rh   ri     messager.   r2   deleterY   r0   r[   r   r\   r_   rl   r
   r   r   r   r3   rQ   r]   r_   r`   ru   s         r   delete_volume AsyncSandboxClient.delete_volume   s       	$0	(!ZZ..s33H%%' 4!! 	U(+H)LMSTT$$ 	(zz%%,+tfK0 zz%%,+A.(iQWXX$Q''	(K   C9A A	A C9	A C6A..C6A'C1,C91C66C9)new_namerR   c                 #    U R                    SU 3n0 nUb  X%S'   Ub  X5S'   U(       d  U R                  U5      I Sh  vN $  U R                  R                  XES9I Sh  vN nUR	                  5         [
        R                  " UR                  5       5      $  NZ N:! [        R                   a  n[        SU 35      UeSnAf[        R                   a  nUR                  R                  S:X  a  [        SU S	3S
S9UeUR                  R                  S:X  a  [        U5      n[!        US   SS9UeUR                  R                  S:X  a  [        U5      n[#        US   S
S9Ue[%        U5        e SnAff = f7f)ax  Update a volume's name and/or size.

You can update the display name, size, or both in a single request.
Only storage size increases are allowed (storage backend limitation).

Args:
    name: Current volume name.
    new_name: New display name (optional).
    size: New storage size (must be >= current size). Optional.

Returns:
    Updated Volume.

Raises:
    ResourceNotFoundError: If volume not found.
    VolumeResizeError: If storage decrease attempted.
    ResourceNameConflictError: If new_name is already in use.
    SandboxQuotaExceededError: If storage quota would be exceeded.
    SandboxClientError: For other errors.
rd   NrQ   rR   rV   rW   re   rf   rg   rh   ri   i  r|   VolumeResize)
error_typer{   )r.   rn   r2   patchrY   r   rZ   rV   r0   r[   r   r\   r_   rl   r
   r   r   r	   r   )	r3   rQ   r   rR   r]   r^   r_   r`   ru   s	            r   update_volume AsyncSandboxClient.update_volume   s~    6  	$0"$&FO"FO...	!ZZ--c-@@H%%'##HMMO44 / A !! 	U(+H)LMSTT$$ 	zz%%,+tfK0 zz%%,+A.%d9o.QWXXzz%%,+A./O8 %Q'	sS   =E;B E;B !B"7B E;B E82CE8BE33E88E;500m512Mi)cpumemorystoragevolume_mountsc                 #    U R                    S3nUUUUS.S.nU(       a  XXS   S'   U(       a-  U V	s/ s H  n	U	R                  U	R                  S.PM     sn	US'    U R                  R	                  XxS9I S	h  vN n
U
R                  5         [        R                  " U
R                  5       5      $ s  sn	f  N=! [        R                   a  n[        S
U 35      UeS	nAf[        R                   a  n[        U5        e S	nAff = f7f)a]  Create a new SandboxTemplate.

Only the container image, resource limits, and volume mounts can be
configured. All other container details are handled by the server.

Args:
    name: Template name.
    image: Container image (e.g., "python:3.12-slim").
    cpu: CPU limit (e.g., "500m", "1", "2"). Default: "500m".
    memory: Memory limit (e.g., "256Mi", "1Gi"). Default: "512Mi".
    storage: Ephemeral storage limit (e.g., "1Gi"). Optional.
    volume_mounts: List of volumes to mount in the sandbox. Optional.

Returns:
    Created SandboxTemplate.

Raises:
    SandboxClientError: If creation fails.

/templates)r   r   )rQ   image	resourcesr   r   )volume_name
mount_pathr   r   NrW   )r.   r   r   r2   rX   rY   r   rZ   rV   r0   r[   r   r\   r   )r3   rQ   r   r   r   r   r   r]   r^   vmr_   r`   s               r   create_template"AsyncSandboxClient.create_template6  s
    :  
+  #
 .5K + (('B !#bmmL'(GO$
	!ZZ__S_??H%%'",,X]]_==( @ !! 	U(+H)LMSTT$$ 	$Q'	sR   2D#B3DB: :B8;7B: 2D8B: :DCD4D  DDc                  #    U R                    SU 3n U R                  R                  U5      I Sh  vN nUR                  5         [        R
                  " UR                  5       5      $  N8! [        R                   a  n[        SU 35      UeSnAf[        R                   a:  nUR                  R                  S:X  a  [        SU S3SS9Ue[        U5        e SnAff = f7f)	zGet a SandboxTemplate by name.

Args:
    name: Template name.

Returns:
    SandboxTemplate.

Raises:
    ResourceNotFoundError: If template not found.
    SandboxClientError: For other errors.
/templates/NrW   re   
Template 'rg   templateri   )r.   r2   rk   rY   r   rZ   rV   r0   r[   r   r\   r_   rl   r
   r   rm   s        r   get_templateAsyncSandboxClient.get_templateo  s       D62	!ZZ^^C00H%%'",,X]]_== 1 !! 	U(+H)LMSTT$$ 	zz%%,+ k2* %Q'	rp   c                  #    U R                    S3n U R                  R                  U5      I Sh  vN nUR                  5         UR	                  5       nUR                  S/ 5       Vs/ s H  n[
        R                  " U5      PM     sn$  N[s  snf ! [        R                   a  n[        SU 35      UeSnAf[        R                   a;  nUR                  R                  S:X  a  [        SU S35      Ue[        U5        e SnAff = f7f)zCList all SandboxTemplates.

Returns:
    List of SandboxTemplates.
r   N	templatesrW   re   rs   rt   )r.   r2   rk   rY   rV   r   rZ   r0   r[   r   r\   r_   rl   r   r   )r3   r]   r_   ru   tr`   s         r   list_templates!AsyncSandboxClient.list_templates  s       
+	!ZZ^^C00H%%'==?D:>((;PR:ST:SQO--a0:STT 1 U!! 	U(+H)LMSTT$$ 	zz%%,%.se 4: ;  %Q'	ry   c               8  #    U R                    SU 3nSU0n U R                  R                  X4S9I Sh  vN nUR                  5         [        R
                  " UR                  5       5      $  N8! [        R                   a  n[        SU 35      UeSnAf[        R                   am  nUR                  R                  S:X  a  [        SU S3S	S
9UeUR                  R                  S:X  a  [        U5      n[        US   S	S
9Ue[!        U5        e SnAff = f7f)a4  Update a template's display name.

Args:
    name: Current template name.
    new_name: New display name.

Returns:
    Updated SandboxTemplate.

Raises:
    ResourceNotFoundError: If template not found.
    ResourceNameConflictError: If new_name is already in use.
    SandboxClientError: For other errors.
r   rQ   r   NrW   re   r   rg   r   ri   r{   r|   )r.   r2   r   rY   r   rZ   rV   r0   r[   r   r\   r_   rl   r
   r   r	   r   )r3   rQ   r   r]   r^   r_   r`   ru   s           r   update_template"AsyncSandboxClient.update_template  s      D628$	!ZZ--c-@@H%%'",,X]]_== A !! 	U(+H)LMSTT$$ 	zz%%,+ k2* zz%%,+A./O: %Q'	sE   DA0 A.7A0 -D.A0 0DBD*A(DDDc                  #    U R                    SU 3n U R                  R                  U5      I Sh  vN nUR                  5         g N! [        R
                   a  n[        SU 35      UeSnAf[        R                   aq  nUR                  R                  S:X  a  [        SU S3SS9UeUR                  R                  S	:X  a  [        U5      n[        US
   SS9Ue[        U5         SnAgSnAff = f7f)zDelete a SandboxTemplate.

Args:
    name: Template name.

Raises:
    ResourceNotFoundError: If template not found.
    ResourceInUseError: If template is referenced by sandboxes or pools.
    SandboxClientError: For other errors.
r   NrW   re   r   rg   r   ri   r{   r|   r}   r   s         r   delete_template"AsyncSandboxClient.delete_template  s       D62	(!ZZ..s33H%%' 4!! 	U(+H)LMSTT$$ 
	(zz%%,+ k2* zz%%,+A.(O: %Q''
	(r   rT   c                 #    U R                    S3nUUUSUS.n US-   nU R                  R                  XVUS9I Sh  vN nUR                  5         [        R
                  " UR                  5       5      $  N8! [        R                   a  n	[        SU	 35      U	eSn	A	f[        R                   a  n	[        U	5        e Sn	A	ff = f7f)a  Create a new Sandbox Pool.

Pools pre-provision sandboxes from a template for faster startup.

Args:
    name: Pool name (lowercase letters, numbers, hyphens; max 63 chars).
    template_name: Name of the SandboxTemplate to use (no volume mounts).
    replicas: Number of sandboxes to pre-provision (1-100).
    timeout: Timeout in seconds when waiting for ready (10-600).

Returns:
    Created Pool.

Raises:
    ResourceNotFoundError: If template not found.
    ValidationError: If template has volumes attached.
    ResourceAlreadyExistsError: If pool with this name already exists.
    ResourceTimeoutError: If pool doesn't reach ready state within timeout.
    SandboxQuotaExceededError: If organization quota is exceeded.
    SandboxClientError: For other errors.
/poolsT)rQ   template_namereplicasrS   r*   rT   rU   NrW   )r.   r2   rX   rY   r   rZ   rV   r0   r[   r   r\   r   )
r3   rQ   r   r   r*   r]   r^   http_timeoutr_   r`   s
             r   create_poolAsyncSandboxClient.create_pool  s     :  ' * "#

	"R<L!ZZ__S_UUH%%'>>(--/22 V !! 	U(+H)LMSTT$$ 	a 	sD   C"A8 A67A8 5C6A8 8CBC2B>>CCc                  #    U R                    SU 3n U R                  R                  U5      I Sh  vN nUR                  5         [        R
                  " UR                  5       5      $  N8! [        R                   a  n[        SU 35      UeSnAf[        R                   a:  nUR                  R                  S:X  a  [        SU S3SS9Ue[        U5        e SnAff = f7f)	zGet a Pool by name.

Args:
    name: Pool name.

Returns:
    Pool.

Raises:
    ResourceNotFoundError: If pool not found.
    SandboxClientError: For other errors.
/pools/NrW   re   Pool 'rg   poolri   )r.   r2   rk   rY   r   rZ   rV   r0   r[   r   r\   r_   rl   r
   r   rm   s        r   get_poolAsyncSandboxClient.get_pool  s       v.	!ZZ^^C00H%%'>>(--/22 1 !! 	U(+H)LMSTT$$ 	zz%%,+TF+.f %Q'	rp   c                  #    U R                    S3n U R                  R                  U5      I Sh  vN nUR                  5         UR	                  5       nUR                  S/ 5       Vs/ s H  n[
        R                  " U5      PM     sn$  N[s  snf ! [        R                   a  n[        SU 35      UeSnAf[        R                   a;  nUR                  R                  S:X  a  [        SU S35      Ue[        U5        e SnAff = f7f)z-List all Pools.

Returns:
    List of Pools.
r   NpoolsrW   re   rs   rt   )r.   r2   rk   rY   rV   r   rZ   r0   r[   r   r\   r_   rl   r   r   )r3   r]   r_   ru   pr`   s         r   
list_poolsAsyncSandboxClient.list_pools;  s       '	!ZZ^^C00H%%'==?D/3xx/DE/D!DNN1%/DEE 1 F!! 	U(+H)LMSTT$$ 	zz%%,%.se 4: ;  %Q'	ry   )r   r   c                 #    U R                    SU 3n0 nUb  X%S'   Ub  X5S'   U(       d  U R                  U5      I Sh  vN $  U R                  R                  XES9I Sh  vN nUR	                  5         [
        R                  " UR                  5       5      $  NZ N:! [        R                   a  n[        SU 35      UeSnAf[        R                   am  nUR                  R                  S:X  a  [        SU S	3S
S9UeUR                  R                  S:X  a  [        U5      n[!        US   S
S9Ue[#        U5        e SnAff = f7f)aY  Update a Pool's name and/or replica count.

You can update the display name, replica count, or both.
The template reference cannot be changed after creation.

Args:
    name: Current pool name.
    new_name: New display name (optional).
    replicas: New number of replicas (0-100). Set to 0 to pause.

Returns:
    Updated Pool.

Raises:
    ResourceNotFoundError: If pool not found.
    ValidationError: If template was deleted.
    ResourceNameConflictError: If new_name is already in use.
    SandboxQuotaExceededError: If quota exceeded when scaling up.
    SandboxClientError: For other errors.
r   NrQ   r   r   rW   re   r   rg   r   ri   r{   r|   )r.   r   r2   r   rY   r   rZ   rV   r0   r[   r   r\   r_   rl   r
   r   r	   r   )	r3   rQ   r   r   r]   r^   r_   r`   ru   s	            r   update_poolAsyncSandboxClient.update_poolS  sM    6  v."$&FO"*Jt,,,	!ZZ--c-@@H%%'>>(--/22 - A !! 	U(+H)LMSTT$$ 	zz%%,+TF+.f zz%%,+A./O6 a 	sS   =EB EB !B"7B EB E2CEA(E  EEc                  #    U R                    SU 3n U R                  R                  U5      I Sh  vN nUR                  5         g N! [        R
                   a  n[        SU 35      UeSnAf[        R                   a>  nUR                  R                  S:X  a  [        SU S3SS9Ue[        U5         SnAgSnAff = f7f)	zDelete a Pool.

This will terminate all sandboxes in the pool.

Args:
    name: Pool name.

Raises:
    ResourceNotFoundError: If pool not found.
    SandboxClientError: For other errors.
r   NrW   re   r   rg   r   ri   r.   r2   r~   rY   r0   r[   r   r\   r_   rl   r
   r   rm   s        r   delete_poolAsyncSandboxClient.delete_pool  s       v.
	(!ZZ..s33H%%' 4!! 	U(+H)LMSTT$$ 	(zz%%,+TF+.f %Q''	(J   CA A	A C	A CA..C4B>9C>CC)rQ   r*   c               R   #    U R                  UUUS9I Sh  vN nSUl        U$  N7f)a<  Create a sandbox and return an AsyncSandbox instance.

This is the primary method for creating sandboxes. Use it as an
async context manager for automatic cleanup:

    async with await client.sandbox(template_name="my-template") as sandbox:
        result = await sandbox.run("echo hello")

The sandbox is automatically deleted when exiting the context manager.
For sandboxes with manual lifecycle management, use create_sandbox().

Args:
    template_name: Name of the SandboxTemplate to use.
    name: Optional sandbox name (auto-generated if not provided).
    timeout: Timeout in seconds when waiting for ready.

Returns:
    AsyncSandbox instance.

Raises:
    ResourceTimeoutError: If timeout waiting for sandbox to be ready.
    SandboxCreationError: If sandbox creation fails.
    SandboxClientError: For other errors.
)r   rQ   r*   NT)create_sandbox_auto_delete)r3   r   rQ   r*   sbs        r   sandboxAsyncSandboxClient.sandbox  s=     > &&' ' 
 

 	
s   '%'c                 #    U R                    S3nUSUS.nU(       a  X%S'    U R                  R                  XEUS-   S9I Sh  vN nUR                  5         [        R
                  " UR                  5       U SS	9$  N8! [        R                   a  n[        S
U 35      UeSnAf[        R                   a  n[        U5        e SnAff = f7f)a,  Create a new Sandbox.

The sandbox is NOT automatically deleted. Use delete_sandbox() for cleanup,
or use sandbox() for automatic cleanup with a context manager.

Args:
    template_name: Name of the SandboxTemplate to use.
    name: Optional sandbox name (auto-generated if not provided).
    timeout: Timeout in seconds when waiting for ready.

Returns:
    Created AsyncSandbox.

Raises:
    ResourceTimeoutError: If timeout waiting for sandbox to be ready.
    SandboxCreationError: If sandbox creation fails.
    SandboxClientError: For other errors.
/boxesT)r   rS   r*   rQ   rT   rU   NFclientauto_deleterW   )r.   r2   rX   rY   r   rZ   rV   r0   r[   r   r\   r   )r3   r   rQ   r*   r]   r^   r_   r`   s           r   r   !AsyncSandboxClient.create_sandbox  s     2  ' +"#

 "FO	!ZZ__SRT_UUH%%'))%  V
 !! 	U(+H)LMSTT$$ 	)!,	sF   !C A? A=7A? <C=A? ?C
B""C
9CC

Cc                  #    U R                    SU 3n U R                  R                  U5      I Sh  vN nUR                  5         [        R
                  " UR                  5       U SS9$  N8! [        R                   a  n[        SU 35      UeSnAf[        R                   a:  nUR                  R                  S:X  a  [        SU S3S	S
9Ue[        U5        e SnAff = f7f)a  Get a Sandbox by name.

The sandbox is NOT automatically deleted. Use delete_sandbox() for cleanup.

Args:
    name: Sandbox name.

Returns:
    AsyncSandbox.

Raises:
    ResourceNotFoundError: If sandbox not found.
    SandboxClientError: For other errors.
/boxes/NFr   rW   re   	Sandbox 'rg   r   ri   )r.   r2   rk   rY   r   rZ   rV   r0   r[   r   r\   r_   rl   r
   r   rm   s        r   get_sandboxAsyncSandboxClient.get_sandbox  s       v.	!ZZ^^C00H%%'))%  1
 !! 	U(+H)LMSTT$$ 	zz%%,+v[1 %Q'	rp   c           	       #    U R                    S3n U R                  R                  U5      I Sh  vN nUR                  5         UR	                  5       nUR                  S/ 5       Vs/ s H  n[
        R                  " X@SS9PM     sn$  NZs  snf ! [        R                   a  n[        SU 35      UeSnAf[        R                   a;  nUR                  R                  S:X  a  [        SU S	35      Ue[        U5        e SnAff = f7f)
z:List all Sandboxes.

Returns:
    List of AsyncSandboxes.
r   N	sandboxesFr   rW   re   rs   rt   )r.   r2   rk   rY   rV   r   rZ   r0   r[   r   r\   r_   rl   r   r   )r3   r]   r_   ru   cr`   s         r   list_sandboxes!AsyncSandboxClient.list_sandboxes#  s      '	!ZZ^^C00H%%'==?D +r22A &&q5I2  1 !! 	U(+H)LMSTT$$ 	zz%%,%.se 4: ;  %Q'	sV   DB B8B *B	B DB B D'B66D6DDDc               $  #    U R                    SU 3nSU0n U R                  R                  X4S9I Sh  vN nUR                  5         [        R
                  " UR                  5       U SS9$  N8! [        R                   a  n[        SU 35      UeSnAf[        R                   ac  nUR                  R                  S:X  a  [        S	U S
3SS9UeUR                  R                  S:X  a  [        SU S3SS9Ue[        U5        e SnAff = f7f)a.  Update a sandbox's display name.

Args:
    name: Current sandbox name.
    new_name: New display name.

Returns:
    Updated AsyncSandbox.

Raises:
    ResourceNotFoundError: If sandbox not found.
    ResourceNameConflictError: If new_name is already in use.
    SandboxClientError: For other errors.
r   rQ   r   NFr   rW   re   r   rg   r   ri   r{   zSandbox name 'z' already in use)r.   r2   r   rY   r   rZ   rV   r0   r[   r   r\   r_   rl   r
   r	   r   )r3   rQ   r   r]   r^   r_   r`   s          r   update_sandbox!AsyncSandboxClient.update_sandbox>  s'      v.8$	!ZZ--c-@@H%%'))%  A
 !! 	U(+H)LMSTT$$ 	zz%%,+v[1 zz%%,/$XJ.>?"+  %Q'	sE   DA0 A.7A0 -D.A0 0DBD*ADDDc                  #    U R                    SU 3n U R                  R                  U5      I Sh  vN nUR                  5         g N! [        R
                   a  n[        SU 35      UeSnAf[        R                   a>  nUR                  R                  S:X  a  [        SU S3SS9Ue[        U5         SnAgSnAff = f7f)	zDelete a Sandbox.

Args:
    name: Sandbox name.

Raises:
    ResourceNotFoundError: If sandbox not found.
    SandboxClientError: For other errors.
r   NrW   re   r   rg   r   ri   r   rm   s        r   delete_sandbox!AsyncSandboxClient.delete_sandboxe  s       v.
	(!ZZ..s33H%%' 4!! 	U(+H)LMSTT$$ 	(zz%%,+v[1 %Q''	(r   )r/   r.   r2   )r)   Optional[str]r*   floatr+   r   )returnNone)r   r'   )rI   zOptional[type]rJ   zOptional[BaseException]rK   zOptional[Any]r   r   )rQ   strrR   r   r*   intr   r   )rQ   r   r   r   )r   zlist[Volume])rQ   r   r   r   )rQ   r   r   r   rR   r   r   r   )rQ   r   r   r   r   r   r   r   r   r   r   zOptional[list[VolumeMountSpec]]r   r   )rQ   r   r   r   )r   zlist[SandboxTemplate])rQ   r   r   r   r   r   )
rQ   r   r   r   r   r   r*   r   r   r   )rQ   r   r   r   )r   z
list[Pool])rQ   r   r   r   r   zOptional[int]r   r   )r   r   rQ   r   r*   r   r   r   )rQ   r   r   r   )r   zlist[AsyncSandbox])rQ   r   r   r   r   r   ) __name__
__module____qualname____firstlineno____doc__r5   r8   rC   rF   rL   ra   rn   rw   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   __static_attributes__r$   r!   r   r'   r'   ,   sS     '+!%I $I 	I
 I0"$  ) 	
 
$ ** *
 * 
*X:0(@ #'"::  	:
 : 
:J !%9=77 7
 7 7 7 77 
7r:0#J(P 11 1 	1 1 
1f:8 #'"&88  	8
  8 
8t(D #%% 	%
 % 
%V #.. 	.
 . 
.`B6%N(r!   r'   )r   r   )r   r   )"r   
__future__r   r=   typingr   r   r0   	langsmithr   r    langsmith.sandbox._async_sandboxr   langsmith.sandbox._exceptionsr   r	   r
   r   r   r   langsmith.sandbox._helpersr   r   r   r   r   langsmith.sandbox._modelsr   r   r   r   r    r%   r'   r$   r!   r   <module>r      sM    L "     ' 9   U T.+
O( O(r!   