Ë
    uPêjô  ã                   ó–   — U d dl Z d dlmZmZ d dlmZmZ d dlZd dlm	Z	  e j                  d«      Zeed<   deddfd	„Z G d
„ de«      Zy)é    N)ÚABCÚabstractmethod)ÚAnyÚFinal)Úverbose_loggeru+   (^|/)\.\.(/|$)|[\x00-\x1f\x7f-\x9fÂ…â€¨â€©]Ú_UNSAFE_SECRET_NAME_PATTERNÚsecret_nameÚreturnc                 óJ   — t         j                  | «      rt        d| ›�«      ‚y)a&  
    Validate a secret name before it is used by a secret manager integration.

    Rejects ".." only as a path segment (bounded by "/" or the start/end of the
    string, e.g. "../x", "x/..", or exactly ".."), not as a plain substring, so
    names like "release-1.0..2" are not rejected.
    zInvalid secret_name N)r   ÚsearchÚ
ValueError)r	   s    úp/home/oem/CyberBrain26-unified/.venv/lib/python3.12/site-packages/litellm/secret_managers/base_secret_manager.pyÚraise_if_unsafe_secret_namer      s*   € ô #×)Ñ)¨+Ô6ÜÐ/°¨Ð?Ó@Ð@ð 7ó    c                   óØ  — e Zd ZdZe	 	 ddededz  deej                  z  dz  dedz  fd„«       Z
e	 	 ddededz  deej                  z  dz  dedz  fd„«       Ze	 	 	 	 dded	ed
edz  dedz  deej                  z  dz  deez  dz  deeef   fd„«       Ze	 	 	 ddededz  dedz  deej                  z  dz  def
d„«       Z	 	 ddededededz  deej                  z  dz  defd„Zy)ÚBaseSecretManagerzD
    Abstract base class for secret management implementations.
    Nr	   Úoptional_paramsÚtimeoutr
   c              ƒ   ó   K  — y­w)aœ  
        Asynchronously read a secret from the secret manager.

        Args:
            secret_name (str): Name/path of the secret to read
            optional_params (Optional[dict]): Additional parameters specific to the secret manager
            timeout (Optional[Union[float, httpx.Timeout]]): Request timeout

        Returns:
            Optional[str]: The secret value if found, None otherwise
        N© ©Úselfr	   r   r   s       r   Úasync_read_secretz#BaseSecretManager.async_read_secret   ó   è ø� ùó   ‚c                  ó   — y)a›  
        Synchronously read a secret from the secret manager.

        Args:
            secret_name (str): Name/path of the secret to read
            optional_params (Optional[dict]): Additional parameters specific to the secret manager
            timeout (Optional[Union[float, httpx.Timeout]]): Request timeout

        Returns:
            Optional[str]: The secret value if found, None otherwise
        Nr   r   s       r   Úsync_read_secretz"BaseSecretManager.sync_read_secret0   s   � r   Úsecret_valueÚdescriptionÚtagsc              ƒ   ó   K  — y­w)a+  
        Asynchronously write a secret to the secret manager.

        Args:
            secret_name (str): Name/path of the secret to write
            secret_value (str): Value to store
            description (Optional[str]): Description of the secret. Some secret managers allow storing a description with the secret.
            optional_params (Optional[dict]): Additional parameters specific to the secret manager
            timeout (Optional[Union[float, httpx.Timeout]]): Request timeout
            tags: Optional dict or list of tags to apply, e.g.
                  {"Environment": "Prod", "Owner": "AI-Platform"} or
                  [{"Key": "Environment", "Value": "Prod"}]
        Returns:
            Dict[str, Any]: Response from the secret manager containing write operation details
        Nr   )r   r	   r   r   r   r   r    s          r   Úasync_write_secretz$BaseSecretManager.async_write_secretC   r   r   Úrecovery_window_in_daysc              ƒ   ó   K  — y­w)aÃ  
        Async function to delete a secret from the secret manager

        Args:
            secret_name: Name of the secret to delete
            recovery_window_in_days: Number of days before permanent deletion (default: 7)
            optional_params: Additional parameters specific to the secret manager
            timeout: Request timeout

        Returns:
            dict: Response from the secret manager containing deletion details
        Nr   )r   r	   r#   r   r   s        r   Úasync_delete_secretz%BaseSecretManager.async_delete_secret]   r   r   Úcurrent_secret_nameÚnew_secret_nameÚnew_secret_valuec              ƒ   óÀ  K  — 	 | j                  |||¬«      ƒ d{  –—† }|€t        d|› d�«      ‚| j                  ||d|› �||¬«      ƒ d{  –—† }| j                  |||¬«      ƒ d{  –—† }|€t        d|› �«      ‚| j                  |d||¬	«      ƒ d{  –—†  |S 7 Œ�7 ŒQ7 Œ77 Œ# t        j
                  $ rZ}	t        j                  d
t        |	j                  j                  «      «       t        d|	j                  j                  › �«      ‚d}	~	wt        j                  $ r t        d«      ‚t        $ r%}
t        j                  d
t        |
«      «       ‚ d}
~
ww xY w­w)ak  
        Async function to rotate a secret by creating a new one and deleting the old one.
        This allows for both value and name changes during rotation.

        Args:
            current_secret_name: Current name of the secret
            new_secret_name: New name for the secret
            new_secret_value: New value for the secret
            optional_params: Additional AWS parameters
            timeout: Request timeout

        Returns:
            dict: Response containing the new secret details

        Raises:
            ValueError: If the secret doesn't exist or if there's an HTTP error
        )r	   r   r   NzCurrent secret z
 not foundzRotated from )r	   r   r   r   r   zFailed to verify new secret é   )r	   r#   r   r   z0Error rotating secret in AWS Secrets Manager: %szHTTP error occurred: zTimeout error occurred)r   r   r"   r%   ÚhttpxÚHTTPStatusErrorr   Ú	exceptionÚstrÚresponseÚtextÚTimeoutExceptionÚ	Exception)r   r&   r'   r(   r   r   Ú
old_secretÚcreate_responseÚ
new_secretÚerrÚes              r   Úasync_rotate_secretz%BaseSecretManager.async_rotate_secretr   s¦  è ø€ ð22	à&*×&<Ñ&<Ø/Ø /Øð '=ó '÷ !ˆJð Ð!Ü  ?Ð3FÐ2GÀzÐ!RÓSÐSð ,0×+BÑ+BØ+Ø-Ø+Ð,?Ð+@ÐAØ /Øð ,Có ,÷ &ˆOð '+×&<Ñ&<Ø+Ø /Øð '=ó '÷ !ˆJð Ð!Ü Ð#?ÀÐ?PÐ!QÓRÐRð ×*Ñ*Ø/Ø()Ø /Øð	 +ó ÷ ð ð #Ð"ðI!øð&øð!øðùô ×$Ñ$ò 	JÜ×$Ñ$ØBÜ�C—L‘L×%Ñ%Ó&ôô Ð4°S·\±\×5FÑ5FÐ4GÐHÓIÐIûÜ×%Ñ%ò 	7ÜÐ5Ó6Ð6Üò 	Ü×$Ñ$Ð%WÔY\Ð]^ÓY_Ô`Øûð	üs{   ‚E„B% ›Bœ1B% ÁBÁB% Á)B!Á*,B% ÂB#ÂB% ÂEÂB% ÂB% Â!B% Â#B% Â%EÂ8ADÄ)EÄ6 EÅEÅE)NN)NNNN)r*   NN)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   r.   ÚdictÚfloatr+   ÚTimeoutr   r   Úlistr   r"   Úintr%   r8   r   r   r   r   r      s	  „ ñð ð (,Ø04ñ	àðð  ™ðð ˜Ÿ™Ñ&¨Ñ-ð	ð
 
ˆt‰òó ðð$ ð (,Ø04ñ	àðð  ™ðð ˜Ÿ™Ñ&¨Ñ-ð	ð
 
ˆt‰òó ðð$ ð
 #'Ø'+Ø04Ø#'ñàðð ðð ˜4‘Zð	ð
  ™ðð ˜Ÿ™Ñ&¨Ñ-ðð �T‰k˜DÑ ðð 
ˆc�3ˆh‰òó ðð2 ð /0Ø'+Ø04ñàðð "% t¡ðð  ™ð	ð
 ˜Ÿ™Ñ&¨Ñ-ðð 
òó ðð2 (,Ø04ñKà ðKð ðKð ð	Kð
  ™ðKð ˜Ÿ™Ñ&¨Ñ-ðKð 
ôKr   r   )ÚreÚabcr   r   Útypingr   r   r+   Úlitellmr   Úcompiler   Ú__annotations__r.   r   r   r   r   r   ú<module>rH      sO   ðÜ 	ß #ß ã å "à%/ R§Z¡ZÐ0^Ó%_Ð ˜UÓ _ð	A¨Sð 	A°Tó 	Aôe˜õ er   