
    biw                        d Z ddlmZ ddlmZmZ ddlZddlmZ	 ddl
mZmZmZmZmZmZ ddlmZmZmZmZmZ ddlmZmZmZmZ dd	lmZ dd
ZddZ G d d      Z y)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                 X    t        j                  dd      } | j                  d       dS )zGet 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    c/home/obispo/Crisostomo_bridge/mision_env/lib/python3.12/site-packages/langsmith/sandbox/_client.py_get_default_api_endpointr       s.    
 
4UVDkk#}--    c                 ,    t        j                  d      S )z)Get the default API key from environment.API_KEY)r   r    r!   r   _get_default_api_keyr%   &   s    	**r!   c                     e Zd ZdZdddd	 	 	 	 	 d'dZd(dZd)dZ	 	 	 	 	 	 	 	 d*dZd	d
	 	 	 	 	 	 	 d+dZd,dZ	d-dZ
d.dZddd	 	 	 	 	 	 	 d/dZddddd	 	 	 	 	 	 	 	 	 	 	 	 	 d0dZd1dZd2dZd3dZd.dZdd
	 	 	 	 	 	 	 	 	 d4dZd5dZd6dZddd	 	 	 	 	 	 	 d7dZd.dZddd 	 	 	 	 	 	 	 d8d!Zddd 	 	 	 	 	 	 	 d8d"Zd9d#Zd:d$Zd;d%Zd.d&Zy)<SandboxClienta  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/api/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                   |xs
 t               j                  d      | _        |xs
 t               }i }|r||d<   t	        j
                  ||      | _        y)a  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%   httpxClient_http)selfr(   r)   r*   resolved_api_keyr,   s         r   __init__zSandboxClient.__init__@   sR      'E*C*EMMcR"<&:&<"$#3GK \\'7C
r!   c                8    | j                   j                          y)zClose the HTTP client.N)r0   closer1   s    r   r5   zSandboxClient.closeW   s    

r!   c                    | S )zEnter context manager.r$   r6   s    r   	__enter__zSandboxClient.__enter__[   s    r!   c                $    | j                          y)zExit context manager.N)r5   )r1   exc_typeexc_valexc_tbs       r   __exit__zSandboxClient.__exit___   s     	

r!   <   )r)   c               p   | j                    d}||d|d}	 | j                  j                  |||dz         }|j                          t	        j
                  |j                               S # t        j                  $ r}t        d|       |d}~wt        j                  $ r}t        |        d}~ww xY w)a6  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-   r0   postraise_for_statusr   	from_dictrF   r.   ConnectErrorr   HTTPStatusErrorr   )r1   rA   rB   r)   urlpayloadresponsees           r   create_volumezSandboxClient.create_volumel   s    0  ) "	
		zzs'B,OH%%'##HMMO44!! 	U(+H)LMSTT$$ 	(+	s$   AA, ,B5?BB5$B00B5c                   | j                    d| }	 | j                  j                  |      }|j                          t	        j
                  |j                               S # t        j                  $ r}t        d|       |d}~wt        j                  $ r<}|j                  j                  dk(  rt        d| dd      |t        |        d}~ww xY w)	zGet a volume by name.

        Args:
            name: Volume name.

        Returns:
            Volume.

        Raises:
            ResourceNotFoundError: If volume not found.
            SandboxClientError: For other errors.
        	/volumes/rG   N  Volume '' not foundvolumeresource_type)r-   r0   getrI   r   rJ   rF   r.   rK   r   rL   rO   status_coder	   r   r1   rA   rM   rO   rP   s        r   
get_volumezSandboxClient.get_volume   s      	$0	zz~~c*H%%'##HMMO44!! 	U(+H)LMSTT$$ 	zz%%,+tfK0 %Q'	$   AA! !C4BC7CCc                   | j                    d}	 | j                  j                  |      }|j                          |j	                         }|j                  dg       D cg c]  }t        j                  |       c}S c c}w # t        j                  $ r}t        d|       |d}~wt        j                  $ r:}|j                  j                  dk(  rt        d| d      |t        |        d}~ww xY w)zIList all volumes.

        Returns:
            List of Volumes.
        r@   volumesrG   NrT   API endpoint not found: %. Check that api_endpoint is correct.)r-   r0   rZ   rI   rF   r   rJ   r.   rK   r   rL   rO   r[   r
   r   )r1   rM   rO   datavrP   s         r   list_volumeszSandboxClient.list_volumes   s      )	zz~~c*H%%'==?D15)R1HIAF$$Q'III!! 	U(+H)LMSTT$$ 	zz%%,%.se 4: ;  %Q'	6   AB  A?<B ?B C6B&&C6<5C11C6c                   | j                    d| }	 | j                  j                  |      }|j                          y# t        j
                  $ r}t        d|       |d}~wt        j                  $ ru}|j                  j                  dk(  rt        d| dd      ||j                  j                  d	k(  rt        |      }t        |d
   d      |t        |       Y d}~yd}~ww xY w)a  Delete a volume.

        Args:
            name: Volume name.

        Raises:
            ResourceNotFoundError: If volume not found.
            ResourceInUseError: If volume is referenced by templates.
            SandboxClientError: For other errors.
        rS   rG   NrT   rU   rV   rW   rX     messager-   r0   deleterI   r.   rK   r   rL   rO   r[   r	   r   r   r   r1   rA   rM   rO   rP   rc   s         r   delete_volumezSandboxClient.delete_volume   s      	$0	(zz((-H%%'!! 	U(+H)LMSTT$$ 	(zz%%,+tfK0 zz%%,+A.(iQWXX$Q''	("   +? C,A!!C,7A+C''C,)new_namerB   c                  | j                    d| }i }|||d<   |||d<   |s| j                  |      S 	 | j                  j                  ||      }|j	                          t        j                  |j                               S # t        j                  $ r}t        d|       |d}~wt        j                  $ r}|j                  j                  dk(  rt        d| d	d
      ||j                  j                  dk(  rt        |      }t!        |d   d      ||j                  j                  dk(  rt        |      }t#        |d   d
      |t%        |        d}~ww xY w)a  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.
        rS   NrA   rB   rF   rG   rT   rU   rV   rW   rX   i  ri   VolumeResize)
error_typerh   )r-   r]   r0   patchrI   r   rJ   rF   r.   rK   r   rL   rO   r[   r	   r   r   r   r   )	r1   rA   ro   rB   rM   rN   rO   rP   rc   s	            r   update_volumezSandboxClient.update_volume   so   6  	$0"$&GFO"GFO??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                  | j                    d}||||dd}|r||d   d<   |r*|D 	cg c]  }	|	j                  |	j                  d c}	|d<   	 | j                  j	                  ||      }
|
j                          t        j                  |
j                               S c c}	w # t        j                  $ r}t        d	|       |d
}~wt        j                  $ r}t        |        d
}~ww xY w)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)rx   ry   )rA   image	resourcesr   rz   )volume_name
mount_pathr{   rq   rG   N)r-   r   r   r0   rH   rI   r   rJ   rF   r.   rK   r   rL   r   )r1   rA   r~   rx   ry   rz   r{   rM   rN   vmrO   rP   s               r   create_templatezSandboxClient.create_template)  s    :  
+  #
 .5GK + (( !#bmmL(GO$
	zzs9H%%'",,X]]_==( !! 	U(+H)LMSTT$$ 	$Q'	s*    B AB% %C.8CC.C))C.c                   | j                    d| }	 | j                  j                  |      }|j                          t	        j
                  |j                               S # t        j                  $ r}t        d|       |d}~wt        j                  $ r<}|j                  j                  dk(  rt        d| dd      |t        |        d}~ww xY w)	a  Get a SandboxTemplate by name.

        Args:
            name: Template name.

        Returns:
            SandboxTemplate.

        Raises:
            ResourceNotFoundError: If template not found.
            SandboxClientError: For other errors.
        /templates/rG   NrT   
Template 'rV   templaterX   )r-   r0   rZ   rI   r   rJ   rF   r.   rK   r   rL   rO   r[   r	   r   r\   s        r   get_templatezSandboxClient.get_templateb  s      D62	zz~~c*H%%'",,X]]_==!! 	U(+H)LMSTT$$ 	zz%%,+ k2* %Q'	r^   c                   | j                    d}	 | j                  j                  |      }|j                          |j	                         }|j                  dg       D cg c]  }t        j                  |       c}S c c}w # t        j                  $ r}t        d|       |d}~wt        j                  $ r:}|j                  j                  dk(  rt        d| d      |t        |        d}~ww xY w)z[List all SandboxTemplates.

        Returns:
            List of SandboxTemplates.
        r}   	templatesrG   NrT   ra   rb   )r-   r0   rZ   rI   rF   r   rJ   r.   rK   r   rL   rO   r[   r
   r   )r1   rM   rO   rc   trP   s         r   list_templateszSandboxClient.list_templates  s      
+	zz~~c*H%%'==?D:>((;PR:STQO--a0TTT!! 	U(+H)LMSTT$$ 	zz%%,%.se 4: ;  %Q'	rf   c               &   | j                    d| }d|i}	 | j                  j                  ||      }|j                          t	        j
                  |j                               S # t        j                  $ r}t        d|       |d}~wt        j                  $ rq}|j                  j                  dk(  rt        d| dd	
      ||j                  j                  dk(  rt        |      }t        |d   d	
      |t!        |        d}~ww xY w)a  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   rA   rq   rG   NrT   r   rV   r   rX   rh   ri   )r-   r0   rt   rI   r   rJ   rF   r.   rK   r   rL   rO   r[   r	   r   r   r   )r1   rA   ro   rM   rN   rO   rP   rc   s           r   update_templatez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:B		DA,DDc                   | j                    d| }	 | j                  j                  |      }|j                          y# t        j
                  $ r}t        d|       |d}~wt        j                  $ ru}|j                  j                  dk(  rt        d| dd      ||j                  j                  d	k(  rt        |      }t        |d
   d      |t        |       Y d}~yd}~ww xY w)a   Delete 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   rG   NrT   r   rV   r   rX   rh   ri   rj   rl   s         r   delete_templatezSandboxClient.delete_template  s      D62	(zz((-H%%'!! 	U(+H)LMSTT$$ 
	(zz%%,+ k2* zz%%,+A.(O: %Q''
	(rn   rD   c               v   | j                    d}|||d|d}	 |dz   }| j                  j                  |||      }|j                          t	        j
                  |j                               S # t        j                  $ r}	t        d|	       |	d}	~	wt        j                  $ r}	t        |	        d}	~	ww xY w)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)rA   template_namereplicasrC   r)   rD   rE   rG   N)r-   r0   rH   rI   r   rJ   rF   r.   rK   r   rL   r   )
r1   rA   r   r   r)   rM   rN   http_timeoutrO   rP   s
             r   create_poolzSandboxClient.create_pool  s    :  ' * "#

	"R<Lzzs,OH%%'>>(--/22!! 	U(+H)LMSTT$$ 	a 	s$   AA/ /B8BB8'B33B8c                   | j                    d| }	 | j                  j                  |      }|j                          t	        j
                  |j                               S # t        j                  $ r}t        d|       |d}~wt        j                  $ r<}|j                  j                  dk(  rt        d| dd      |t        |        d}~ww xY w)	zGet a Pool by name.

        Args:
            name: Pool name.

        Returns:
            Pool.

        Raises:
            ResourceNotFoundError: If pool not found.
            SandboxClientError: For other errors.
        /pools/rG   NrT   Pool 'rV   poolrX   )r-   r0   rZ   rI   r   rJ   rF   r.   rK   r   rL   rO   r[   r	   r   r\   s        r   get_poolzSandboxClient.get_pool  s      v.	zz~~c*H%%'>>(--/22!! 	U(+H)LMSTT$$ 	zz%%,+TF+.f %Q'	r^   c                   | j                    d}	 | j                  j                  |      }|j                          |j	                         }|j                  dg       D cg c]  }t        j                  |       c}S c c}w # t        j                  $ r}t        d|       |d}~wt        j                  $ r:}|j                  j                  dk(  rt        d| d      |t        |        d}~ww xY w)zEList all Pools.

        Returns:
            List of Pools.
        r   poolsrG   NrT   ra   rb   )r-   r0   rZ   rI   rF   r   rJ   r.   rK   r   rL   rO   r[   r
   r   )r1   rM   rO   rc   prP   s         r   
list_poolszSandboxClient.list_pools.  s      '	zz~~c*H%%'==?D/3xx/DE!DNN1%EEE!! 	U(+H)LMSTT$$ 	zz%%,%.se 4: ;  %Q'	rf   )ro   r   c               d   | j                    d| }i }|||d<   |||d<   |s| j                  |      S 	 | j                  j                  ||      }|j	                          t        j                  |j                               S # t        j                  $ r}t        d|       |d}~wt        j                  $ rq}|j                  j                  dk(  rt        d| d	d
      ||j                  j                  dk(  rt        |      }t!        |d   d
      |t#        |        d}~ww xY w)a  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   NrA   r   rq   rG   rT   r   rV   r   rX   rh   ri   )r-   r   r0   rt   rI   r   rJ   rF   r.   rK   r   rL   rO   r[   r	   r   r   r   )	r1   rA   ro   r   rM   rN   rO   rP   rc   s	            r   update_poolzSandboxClient.update_poolF  s>   6  v."$&GFO"*GJ==&&	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   | j                    d| }	 | j                  j                  |      }|j                          y# t        j
                  $ r}t        d|       |d}~wt        j                  $ r@}|j                  j                  dk(  rt        d| dd      |t        |       Y d}~yd}~ww xY w)	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   rG   NrT   r   rV   r   rX   r-   r0   rk   rI   r.   rK   r   rL   rO   r[   r	   r   r\   s        r   delete_poolzSandboxClient.delete_pool  s      v.
	(zz((-H%%'!! 	U(+H)LMSTT$$ 	(zz%%,+TF+.f %Q''	(!   +? B7A!!B776B22B7)rA   r)   c               <    | j                  |||      }d|_        |S )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   rA   r)   T)create_sandbox_auto_delete)r1   r   rA   r)   sbs        r   sandboxzSandboxClient.sandbox  s0    >   ' ! 

 	r!   c                  | j                    d}|d|d}|r||d<   	 | j                  j                  |||dz         }|j                          t	        j
                  |j                         | d      S # t        j                  $ r}t        d	|       |d
}~wt        j                  $ r}t        |        d
}~ww xY w)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   rC   r)   rA   rD   rE   Fclientauto_deleterG   N)r-   r0   rH   rI   r   rJ   rF   r.   rK   r   rL   r   )r1   r   rA   r)   rM   rN   rO   rP   s           r   r   zSandboxClient.create_sandbox  s    2  ' +"#

 "GFO		zzs'B,OH%%'$$X]]_TuUU!! 	U(+H)LMSTT$$ 	)!,	s$   AA5 5B>BB>-B99B>c                   | j                    d| }	 | j                  j                  |      }|j                          t	        j
                  |j                         | d      S # t        j                  $ r}t        d|       |d}~wt        j                  $ r<}|j                  j                  dk(  rt        d| dd	
      |t        |        d}~ww xY w)aF  Get 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   rG   NrT   	Sandbox 'rV   r   rX   )r-   r0   rZ   rI   r   rJ   rF   r.   rK   r   rL   rO   r[   r	   r   r\   s        r   get_sandboxzSandboxClient.get_sandbox  s      v.	zz~~c*H%%'$$X]]_TuUU!! 	U(+H)LMSTT$$ 	zz%%,+v[1 %Q'	s$   AA$ $C7BC7CCc                   | j                    d}	 | j                  j                  |      }|j                          |j	                         }|j                  dg       D cg c]  }t        j                  || d       c}S c c}w # t        j                  $ r}t        d|       |d}~wt        j                  $ r:}|j                  j                  dk(  rt        d| d	      |t        |        d}~ww xY w)
zMList all Sandboxes.

        Returns:
            List of Sandboxes.
        r   	sandboxesFr   rG   NrT   ra   rb   )r-   r0   rZ   rI   rF   r   rJ   r.   rK   r   rL   rO   r[   r
   r   )r1   rM   rO   rc   crP   s         r   list_sandboxeszSandboxClient.list_sandboxes  s      '	zz~~c*H%%'==?D +r2 !!!DeD   !! 	U(+H)LMSTT$$ 	zz%%,%.se 4: ;  %Q'	s6   AB  B?B B C9B))C9?5C44C9c                  | j                    d| }d|i}	 | j                  j                  ||      }|j                          t	        j
                  |j                         | d      S # t        j                  $ r}t        d|       |d}~wt        j                  $ rg}|j                  j                  dk(  rt        d	| d
d      ||j                  j                  dk(  rt        d| dd      |t        |        d}~ww xY w)ay  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   rA   rq   Fr   rG   NrT   r   rV   r   rX   rh   zSandbox name 'z' already in use)r-   r0   rt   rI   r   rJ   rF   r.   rK   r   rL   rO   r[   r	   r   r   )r1   rA   ro   rM   rN   rO   rP   s          r   update_sandboxzSandboxClient.update_sandbox-  s     v.8$	zz'''':H%%'$$X]]_TuUU!! 	U(+H)LMSTT$$ 	zz%%,+v[1 zz%%,/$XJ.>?"+  %Q'	s%   AA* *D	=BD	"A"DD	c                t   | j                    d| }	 | j                  j                  |      }|j                          y# t        j
                  $ r}t        d|       |d}~wt        j                  $ r@}|j                  j                  dk(  rt        d| dd      |t        |       Y d}~yd}~ww xY w)	zDelete a Sandbox.

        Args:
            name: Sandbox name.

        Raises:
            ResourceNotFoundError: If sandbox not found.
            SandboxClientError: For other errors.
        r   rG   NrT   r   rV   r   rX   r   r\   s        r   delete_sandboxzSandboxClient.delete_sandboxR  s      v.
	(zz((-H%%'!! 	U(+H)LMSTT$$ 	(zz%%,+v[1 %Q''	(r   )r(   Optional[str]r)   floatr*   r   )returnNone)r   r'   )r:   zOptional[type]r;   zOptional[BaseException]r<   zOptional[Any]r   r   )rA   strrB   r   r)   intr   r   )rA   r   r   r   )r   zlist[Volume])rA   r   r   r   )rA   r   ro   r   rB   r   r   r   )rA   r   r~   r   rx   r   ry   r   rz   r   r{   zOptional[list[VolumeMountSpec]]r   r   )rA   r   r   r   )r   zlist[SandboxTemplate])rA   r   ro   r   r   r   )
rA   r   r   r   r   r   r)   r   r   r   )rA   r   r   r   )r   z
list[Pool])rA   r   ro   r   r   zOptional[int]r   r   )r   r   rA   r   r)   r   r   r   )rA   r   r   r   )r   zlist[Sandbox])rA   r   ro   r   r   r   )__name__
__module____qualname____doc__r3   r5   r8   r=   rQ   r]   re   rm   ru   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r$   r!   r   r'   r'   +   sM   . '+!%D $D 	D
 D.  ) 	
 
$ ** *
 * 
*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   r.   	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 ..+
}( }(r!   