
    =Ki"x                        S r SSKJr  SSKJrJr  SSK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	KJr  SS
 jrSS jr " S S5      r g)zEMain SandboxClient class for interacting with the sandbox server API.    )annotations)AnyOptionalN)utils)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VolumeMountSpec)Sandboxc                 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    [/var/www/html/dynamic-report/venv/lib/python3.13/site-packages/langsmith/sandbox/_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)?SandboxClient+   aW  Client for interacting with the Sandbox Server API.

This client provides a simple interface for managing sandboxes and templates.

Example:
    # Uses LANGSMITH_ENDPOINT and LANGSMITH_API_KEY from environment
    client = SandboxClient()

    # Or with explicit configuration
    client = SandboxClient(
        api_endpoint="https://api.smith.langchain.com/v2/sandboxes",
        api_key="your-api-key",
    )

    # Create a sandbox and run commands
    with client.sandbox(template_name="python-sandbox") as sandbox:
        result = 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)aX  Initialize the SandboxClient.

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Client_http)selfr)   r*   r+   resolved_api_keyr-   s         r   __init__SandboxClient.__init__@   sS      'E*C*EMMcR"<&:&<("$#3K \\'C
r!   c                8    U R                   R                  5         g)zClose the HTTP client.N)r2   closer3   s    r   r8   SandboxClient.closeX   s    

r!   c                     U R                   R                  (       d  U R                   R                  5         gg! [         a     gf = f)z,Close the HTTP client on garbage collection.N)r2   	is_closedr8   	Exceptionr9   s    r   __del__SandboxClient.__del__\   s;    	::''

  " ( 		s   59 
AAc                    U $ )zEnter context manager.r$   r9   s    r   	__enter__SandboxClient.__enter__d   s    r!   c                $    U R                  5         g)zExit context manager.N)r8   )r3   exc_typeexc_valexc_tbs       r   __exit__SandboxClient.__exit__h   s     	

r!   <   )r*   c               n   U R                    S3nUUSUS.n U R                  R                  XEUS-   S9nUR                  5         [        R
                  " UR                  5       5      $ ! [        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)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*   Failed to connect to server: N)r.   r2   postraise_for_statusr   	from_dictrQ   r0   ConnectErrorr   HTTPStatusErrorr   )r3   rL   rM   r*   urlpayloadresponsees           r   create_volumeSandboxClient.create_volumeu   s    0  ) "	
		zzs'B,OH%%'##HMMO44!! 	U(+H)LMSTT$$ 	(+	s$   AA) )B4=BB4#B//B4c                   U R                    SU 3n U R                  R                  U5      nUR                  5         [        R
                  " UR                  5       5      $ ! [        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)	zGet a volume by name.

Args:
    name: Volume name.

Returns:
    Volume.

Raises:
    ResourceNotFoundError: If volume not found.
    SandboxClientError: For other errors.
	/volumes/rR   N  Volume '' not foundvolumeresource_type)r.   r2   getrT   r   rU   rQ   r0   rV   r   rW   rZ   status_coder	   r   r3   rL   rX   rZ   r[   s        r   
get_volumeSandboxClient.get_volume   s      	$0	zz~~c*H%%'##HMMO44!! 	U(+H)LMSTT$$ 	zz%%,+tfK0 %Q'	$   AA" "C6BC5CCc                    U R                    S3n U R                  R                  U5      nUR                  5         UR	                  5       nUR                  S/ 5       Vs/ s H  n[
        R                  " U5      PM     s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)z1List all volumes.

Returns:
    List of Volumes.
rK   volumesrR   Nr`   API endpoint not found: %. Check that api_endpoint is correct.)r.   r2   rf   rT   rQ   r   rU   r0   rV   r   rW   rZ   rg   r
   r   )r3   rX   rZ   datavr[   s         r   list_volumesSandboxClient.list_volumes   s      )	zz~~c*H%%'==?D15)R1HI1HAF$$Q'1HIII!! 	U(+H)LMSTT$$ 	zz%%,%.se 4: ;  %Q'	6   AB   B B B C=B++C=6C88C=c                   U R                    SU 3n U R                  R                  U5      nUR                  5         g! [        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)zDelete a volume.

Args:
    name: Volume name.

Raises:
    ResourceNotFoundError: If volume not found.
    ResourceInUseError: If volume is referenced by templates.
    SandboxClientError: For other errors.
r_   rR   Nr`   ra   rb   rc   rd     messager.   r2   deleterT   r0   rV   r   rW   rZ   rg   r	   r   r   r   r3   rL   rX   rZ   r[   rp   s         r   delete_volumeSandboxClient.delete_volume   s      	$0	(zz((-H%%'!! 	U(+H)LMSTT$$ 	(zz%%,+tfK0 zz%%,+A.(iQWXX$Q''	("   +? C*A""C*9A'C%%C*)new_namerM   c                  U R                    SU 3n0 nUb  X%S'   Ub  X5S'   U(       d  U R                  U5      $  U R                  R                  XES9nUR	                  5         [
        R                  " UR                  5       5      $ ! [        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)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.
r_   NrL   rM   rQ   rR   r`   ra   rb   rc   rd   i  rw   VolumeResize)
error_typerv   )r.   ri   r2   patchrT   r   rU   rQ   r0   rV   r   rW   rZ   rg   r	   r   r   r   r   )	r3   rL   r~   rM   rX   rY   rZ   r[   rp   s	            r   update_volumeSandboxClient.update_volume   si   6  	$0"$&FO"FO??4((	zz''':H%%'##HMMO44!! 	U(+H)LMSTT$$ 	zz%%,+tfK0 zz%%,+A.%d9o.QWXXzz%%,+A./O8 %Q'	s%   AB E"B++E"BE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n
U
R                  5         [        R                  " U
R                  5       5      $ s  sn	f ! [        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)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   )rL   image	resourcesr   r   )volume_name
mount_pathr   r   rR   N)r.   r   r   r2   rS   rT   r   rU   rQ   r0   rV   r   rW   r   )r3   rL   r   r   r   r   r   rX   rY   vmrZ   r[   s               r   create_templateSandboxClient.create_template2  s    :  
+  #
 .5K + (('B !#bmmL'(GO$
	zzs9H%%'",,X]]_==( !! 	U(+H)LMSTT$$ 	$Q'	s*   #B)AB. .C9CC9(C44C9c                   U R                    SU 3n U R                  R                  U5      nUR                  5         [        R
                  " UR                  5       5      $ ! [        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)	zGet a SandboxTemplate by name.

Args:
    name: Template name.

Returns:
    SandboxTemplate.

Raises:
    ResourceNotFoundError: If template not found.
    SandboxClientError: For other errors.
/templates/rR   Nr`   
Template 'rb   templaterd   )r.   r2   rf   rT   r   rU   rQ   r0   rV   r   rW   rZ   rg   r	   r   rh   s        r   get_templateSandboxClient.get_templatek  s      D62	zz~~c*H%%'",,X]]_==!! 	U(+H)LMSTT$$ 	zz%%,+ k2* %Q'	rk   c                    U R                    S3n U R                  R                  U5      nUR                  5         UR	                  5       nUR                  S/ 5       Vs/ s H  n[
        R                  " U5      PM     s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)zCList all SandboxTemplates.

Returns:
    List of SandboxTemplates.
r   	templatesrR   Nr`   rn   ro   )r.   r2   rf   rT   rQ   r   rU   r0   rV   r   rW   rZ   rg   r
   r   )r3   rX   rZ   rp   tr[   s         r   list_templatesSandboxClient.list_templates  s      
+	zz~~c*H%%'==?D:>((;PR:ST:SQO--a0:STTT!! 	U(+H)LMSTT$$ 	zz%%,%.se 4: ;  %Q'	rt   c                  U R                    SU 3nSU0n U R                  R                  X4S9nUR                  5         [        R
                  " UR                  5       5      $ ! [        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)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   rL   r   rR   Nr`   r   rb   r   rd   rv   rw   )r.   r2   r   rT   r   rU   rQ   r0   rV   r   rW   rZ   rg   r	   r   r   r   )r3   rL   r~   rX   rY   rZ   r[   rp   s           r   update_templateSandboxClient.update_template  s     D628$	zz''':H%%'",,X]]_==!! 	U(+H)LMSTT$$ 	zz%%,+ k2* zz%%,+A./O: %Q'	s%   AA$ $D8BDA(DDc                   U R                    SU 3n U R                  R                  U5      nUR                  5         g! [        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)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   rR   Nr`   r   rb   r   rd   rv   rw   rx   rz   s         r   delete_templateSandboxClient.delete_template  s      D62	(zz((-H%%'!! 	U(+H)LMSTT$$ 
	(zz%%,+ k2* zz%%,+A.(O: %Q''
	(r}   rO   c               t   U R                    S3nUUUSUS.n US-   nU R                  R                  XVUS9nUR                  5         [        R
                  " UR                  5       5      $ ! [        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)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)rL   template_namereplicasrN   r*   rO   rP   rR   N)r.   r2   rS   rT   r   rU   rQ   r0   rV   r   rW   r   )
r3   rL   r   r   r*   rX   rY   http_timeoutrZ   r[   s
             r   create_poolSandboxClient.create_pool  s    :  ' * "#

	"R<Lzzs,OH%%'>>(--/22!! 	U(+H)LMSTT$$ 	a 	s$   AA, ,B7 BB7&B22B7c                   U R                    SU 3n U R                  R                  U5      nUR                  5         [        R
                  " UR                  5       5      $ ! [        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)	zGet a Pool by name.

Args:
    name: Pool name.

Returns:
    Pool.

Raises:
    ResourceNotFoundError: If pool not found.
    SandboxClientError: For other errors.
/pools/rR   Nr`   Pool 'rb   poolrd   )r.   r2   rf   rT   r   rU   rQ   r0   rV   r   rW   rZ   rg   r	   r   rh   s        r   get_poolSandboxClient.get_pool  s      v.	zz~~c*H%%'>>(--/22!! 	U(+H)LMSTT$$ 	zz%%,+TF+.f %Q'	rk   c                    U R                    S3n U R                  R                  U5      nUR                  5         UR	                  5       nUR                  S/ 5       Vs/ s H  n[
        R                  " U5      PM     s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)z-List all Pools.

Returns:
    List of Pools.
r   poolsrR   Nr`   rn   ro   )r.   r2   rf   rT   rQ   r   rU   r0   rV   r   rW   rZ   rg   r
   r   )r3   rX   rZ   rp   pr[   s         r   
list_poolsSandboxClient.list_pools7  s      '	zz~~c*H%%'==?D/3xx/DE/D!DNN1%/DEEE!! 	U(+H)LMSTT$$ 	zz%%,%.se 4: ;  %Q'	rt   )r~   r   c               d   U R                    SU 3n0 nUb  X%S'   Ub  X5S'   U(       d  U R                  U5      $  U R                  R                  XES9nUR	                  5         [
        R                  " UR                  5       5      $ ! [        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)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   NrL   r   r   rR   r`   r   rb   r   rd   rv   rw   )r.   r   r2   r   rT   r   rU   rQ   r0   rV   r   rW   rZ   rg   r	   r   r   r   )	r3   rL   r~   r   rX   rY   rZ   r[   rp   s	            r   update_poolSandboxClient.update_poolO  s8   6  v."$&FO"*J==&&	zz''':H%%'>>(--/22!! 	U(+H)LMSTT$$ 	zz%%,+TF+.f zz%%,+A./O6 a 	s%   AB D/B++D/A(D**D/c                t   U R                    SU 3n U R                  R                  U5      nUR                  5         g! [        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)	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   rR   Nr`   r   rb   r   rd   r.   r2   ry   rT   r0   rV   r   rW   rZ   rg   r	   r   rh   s        r   delete_poolSandboxClient.delete_pool  s      v.
	(zz((-H%%'!! 	U(+H)LMSTT$$ 	(zz%%,+TF+.f %Q''	(!   +? B7A""B794B22B7)rL   r*   c               6    U R                  UUUS9nSUl        U$ )a  Create a sandbox and return a Sandbox instance.

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

    with client.sandbox(template_name="my-template") as sandbox:
        result = 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:
    Sandbox instance.

Raises:
    ResourceTimeoutError: If timeout waiting for sandbox to be ready.
    SandboxCreationError: If sandbox creation fails.
    SandboxClientError: For other errors.
)r   rL   r*   T)create_sandbox_auto_delete)r3   r   rL   r*   sbs        r   sandboxSandboxClient.sandbox  s0    >   ' ! 

 	r!   c                  U R                    S3nUSUS.nU(       a  X%S'    U R                  R                  XEUS-   S9nUR                  5         [        R
                  " UR                  5       U SS9$ ! [        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)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 Sandbox.

Raises:
    ResourceTimeoutError: If timeout waiting for sandbox to be ready.
    SandboxCreationError: If sandbox creation fails.
    SandboxClientError: For other errors.
/boxesT)r   rN   r*   rL   rO   rP   Fclientauto_deleterR   N)r.   r2   rS   rT   r   rU   rQ   r0   rV   r   rW   r   )r3   r   rL   r*   rX   rY   rZ   r[   s           r   r   SandboxClient.create_sandbox  s    2  ' +"#

 "FO		zzs'B,OH%%'$$X]]_TuUU!! 	U(+H)LMSTT$$ 	)!,	s$   AA3 3B>BB>-B99B>c                   U R                    SU 3n U R                  R                  U5      nUR                  5         [        R
                  " UR                  5       U SS9$ ! [        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)zGet a Sandbox by name.

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

Args:
    name: Sandbox name.

Returns:
    Sandbox.

Raises:
    ResourceNotFoundError: If sandbox not found.
    SandboxClientError: For other errors.
/boxes/Fr   rR   Nr`   	Sandbox 'rb   r   rd   )r.   r2   rf   rT   r   rU   rQ   r0   rV   r   rW   rZ   rg   r	   r   rh   s        r   get_sandboxSandboxClient.get_sandbox  s      v.	zz~~c*H%%'$$X]]_TuUU!! 	U(+H)LMSTT$$ 	zz%%,+v[1 %Q'	rk   c           	        U R                    S3n U R                  R                  U5      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$ 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)
z5List all Sandboxes.

Returns:
    List of Sandboxes.
r   	sandboxesFr   rR   Nr`   rn   ro   )r.   r2   rf   rT   rQ   r   rU   r0   rV   r   rW   rZ   rg   r
   r   )r3   rX   rZ   rp   cr[   s         r   list_sandboxesSandboxClient.list_sandboxes  s     '	zz~~c*H%%'==?D +r22A !!!eD2   !! 	U(+H)LMSTT$$ 	zz%%,%.se 4: ;  %Q'	s6   AB  B?B B C<B**C<6C77C<c                  U R                    SU 3nSU0n U R                  R                  X4S9nUR                  5         [        R
                  " UR                  5       U SS9$ ! [        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)a)  Update a sandbox's display name.

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

Returns:
    Updated Sandbox.

Raises:
    ResourceNotFoundError: If sandbox not found.
    ResourceNameConflictError: If new_name is already in use.
    SandboxClientError: For other errors.
r   rL   r   Fr   rR   Nr`   r   rb   r   rd   rv   zSandbox name 'z' already in use)r.   r2   r   rT   r   rU   rQ   r0   rV   r   rW   rZ   rg   r	   r   r   )r3   rL   r~   rX   rY   rZ   r[   s          r   update_sandboxSandboxClient.update_sandbox6  s     v.8$	zz''':H%%'$$X]]_TuUU!! 	U(+H)LMSTT$$ 	zz%%,+v[1 zz%%,/$XJ.>?"+  %Q'	s%   AA$ $D8BDAC<<Dc                t   U R                    SU 3n U R                  R                  U5      nUR                  5         g! [        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)	zDelete a Sandbox.

Args:
    name: Sandbox name.

Raises:
    ResourceNotFoundError: If sandbox not found.
    SandboxClientError: For other errors.
r   rR   Nr`   r   rb   r   rd   r   rh   s        r   delete_sandboxSandboxClient.delete_sandbox[  s      v.
	(zz((-H%%'!! 	U(+H)LMSTT$$ 	(zz%%,+v[1 %Q''	(r   )r/   r.   r2   )r)   Optional[str]r*   floatr+   r   )returnNone)r   r'   )rD   zOptional[type]rE   zOptional[BaseException]rF   zOptional[Any]r   r   )rL   strrM   r   r*   intr   r   )rL   r   r   r   )r   zlist[Volume])rL   r   r   r   )rL   r   r~   r   rM   r   r   r   )rL   r   r   r   r   r   r   r   r   r   r   zOptional[list[VolumeMountSpec]]r   r   )rL   r   r   r   )r   zlist[SandboxTemplate])rL   r   r~   r   r   r   )
rL   r   r   r   r   r   r*   r   r   r   )rL   r   r   r   )r   z
list[Pool])rL   r   r~   r   r   zOptional[int]r   r   )r   r   rL   r   r*   r   r   r   )rL   r   r   r   )r   zlist[Sandbox])rL   r   r~   r   r   r   ) __name__
__module____qualname____firstlineno____doc__r5   r8   r>   rA   rG   r\   ri   rr   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'   +   sR   . '+!%D $D 	D
 D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 #,, 	,
 , 
,\>6#J(r!   r'   )r   r   )r   r   )!r   
__future__r   typingr   r   r0   	langsmithr   r   langsmith.sandbox._exceptionsr   r   r	   r
   r   r   langsmith.sandbox._helpersr   r   r   r   r   langsmith.sandbox._modelsr   r   r   r   langsmith.sandbox._sandboxr   r    r%   r'   r$   r!   r   <module>r      sJ    K "    '   U T ..+
F( F(r!   