Ë
    tPêjw  ã                   ó<   — d dl mZmZ d dlZddlmZ  G d„ d«      Zy)é    )ÚAnyÚFinalNé   )ÚUnauthorizedErrorc                   óF  — e Zd Zddededz  defd„Zdeeef   fd„Z	 ddedeee	f   e
j                  z  fd	„Z	 dd
edeee	f   deee	f   dedeee	f   e
j                  z  f
d„Z	 dd
ededeee	f   e
j                  z  fd„Z	 dd
ededeee	f   e
j                  z  fd„Zy)ÚCredentialsManagementClientNÚbase_urlÚapi_keyÚtimeoutc                 óL   — |j                  d«      | _        || _        || _        y)af  
        Initialize the CredentialsManagementClient.

        Args:
            base_url (str): The base URL of the LiteLLM proxy server (e.g., "http://localhost:8000")
            api_key (Optional[str]): API key for authentication. If provided, it will be sent as a Bearer token.
            timeout (int): Request timeout in seconds (default: 30)
        ú/N)ÚrstripÚ	_base_urlÚ_api_keyÚ_timeout)Úselfr	   r
   r   s       úe/home/oem/CyberBrain26-unified/.venv/lib/python3.12/site-packages/litellm/proxy/client/credentials.pyÚ__init__z$CredentialsManagementClient.__init__	   s"   € ð "Ÿ™¨Ó-ˆŒØˆŒØˆ�ó    Úreturnc                 óJ   — ddi}| j                   rd| j                   › �|d<   |S )z¬
        Get the headers for API requests, including authorization if api_key is set.

        Returns:
            Dict[str, str]: Headers to use for API requests
        zContent-Typezapplication/jsonzBearer ÚAuthorization)r   )r   Úheaderss     r   Ú_get_headersz(CredentialsManagementClient._get_headers   s0   € ð )Ð*<Ð=ˆØ�=Š=Ø)0°·±°Ð'@ˆG�OÑ$Øˆr   Úreturn_requestc                 óÈ  — | j                   › d�}t        j                  d|| j                  «       ¬«      }|r|S t        j                  «       }	 |j                  |j                  «       | j                  ¬«      }|j                  «        |j                  «       S # t        j                  j                  $ r*}|j                  j                  dk(  rt        |«      ‚‚ d}~ww xY w)a  
        List all credentials.

        Args:
            return_request (bool): If True, returns the prepared request object instead of executing it

        Returns:
            Union[Dict[str, Any], requests.Request]: Either the response from the server or
            a prepared request object if return_request is True

        Raises:
            UnauthorizedError: If the request fails with a 401 status code
            requests.exceptions.RequestException: If the request fails with any other error
        ú/credentialsÚGET©r   ©r   é‘  N©r   ÚrequestsÚRequestr   ÚSessionÚsendÚpreparer   Úraise_for_statusÚjsonÚ
exceptionsÚ	HTTPErrorÚresponseÚstatus_coder   )r   r   ÚurlÚrequestÚsessionr,   Úes          r   Úlistz CredentialsManagementClient.list"   s¾   € ð$ Ÿ™Ð' |Ð4ˆä!×)Ñ)¨%°¸d×>OÑ>OÓ>QÔRˆáØˆNä!×)Ñ)Ó+ˆð	Ø%Ÿl™l¨7¯?©?Ó+<ÀdÇmÁm˜lÓTˆHØ×%Ñ%Ô'Ø—=‘=“?Ð"øÜ×"Ñ"×,Ñ,ò 	Ø�z‰z×%Ñ%¨Ò,Ü'¨Ó*Ð*Øûð	ús   ÁA
B ÂC!Â7%CÃC!Úcredential_nameÚcredential_infoÚcredential_valuesc                 óÖ  — | j                   › d�}|||dœ}t        j                  d|| j                  «       |¬«      }|r|S t        j                  «       }	 |j                  |j                  «       | j                  ¬«      }	|	j                  «        |	j                  «       S # t        j                  j                  $ r*}
|
j                  j                  dk(  rt        |
«      ‚‚ d}
~
ww xY w)aå  
        Create a new credential.

        Args:
            credential_name (str): Name of the credential
            credential_info (Dict[str, Any]): Additional information about the credential
            credential_values (Dict[str, Any]): Values for the credential
            return_request (bool): If True, returns the prepared request object instead of executing it

        Returns:
            Union[Dict[str, Any], requests.Request]: Either the response from the server or
            a prepared request object if return_request is True

        Raises:
            UnauthorizedError: If the request fails with a 401 status code
            requests.exceptions.RequestException: If the request fails with any other error
        r   )r3   r4   r5   ÚPOST)r   r)   r    r!   Nr"   )r   r3   r4   r5   r   r.   Údatar/   r0   r,   r1   s              r   Úcreatez"CredentialsManagementClient.createE   sÕ   € ð0 Ÿ™Ð' |Ð4ˆð  /Ø.Ø!2ñ
ˆô "×)Ñ)¨&°#¸t×?PÑ?PÓ?RÐY]Ô^ˆáØˆNä!×)Ñ)Ó+ˆð	Ø%Ÿl™l¨7¯?©?Ó+<ÀdÇmÁm˜lÓTˆHØ×%Ñ%Ô'Ø—=‘=“?Ð"øÜ×"Ñ"×,Ñ,ò 	Ø�z‰z×%Ñ%¨Ò,Ü'¨Ó*Ð*Øûð	ús   ÁA
B! Â!C(Â>%C#Ã#C(c                 óÌ  — | j                   › d|› �}t        j                  d|| j                  «       ¬«      }|r|S t        j                  «       }	 |j                  |j                  «       | j                  ¬«      }|j                  «        |j                  «       S # t        j                  j                  $ r*}|j                  j                  dk(  rt        |«      ‚‚ d}~ww xY w)aO  
        Delete a credential by name.

        Args:
            credential_name (str): Name of the credential to delete
            return_request (bool): If True, returns the prepared request object instead of executing it

        Returns:
            Union[Dict[str, Any], requests.Request]: Either the response from the server or
            a prepared request object if return_request is True

        Raises:
            UnauthorizedError: If the request fails with a 401 status code
            requests.exceptions.RequestException: If the request fails with any other error
        z/credentials/ÚDELETEr   r    r!   Nr"   ©r   r3   r   r.   r/   r0   r,   r1   s           r   Údeletez"CredentialsManagementClient.deletet   sÃ   € ð( Ÿ™Ð' }°_Ð4EÐFˆä!×)Ñ)¨(°CÀ×ARÑARÓATÔUˆáØˆNä!×)Ñ)Ó+ˆð	Ø%Ÿl™l¨7¯?©?Ó+<ÀdÇmÁm˜lÓTˆHØ×%Ñ%Ô'Ø—=‘=“?Ð"øÜ×"Ñ"×,Ñ,ò 	Ø�z‰z×%Ñ%¨Ò,Ü'¨Ó*Ð*Øûð	úó   ÁA
B ÂC#Â9%CÃC#c                 óÌ  — | j                   › d|› �}t        j                  d|| j                  «       ¬«      }|r|S t        j                  «       }	 |j                  |j                  «       | j                  ¬«      }|j                  «        |j                  «       S # t        j                  j                  $ r*}|j                  j                  dk(  rt        |«      ‚‚ d}~ww xY w)aN  
        Get a credential by name.

        Args:
            credential_name (str): Name of the credential to retrieve
            return_request (bool): If True, returns the prepared request object instead of executing it

        Returns:
            Union[Dict[str, Any], requests.Request]: Either the response from the server or
            a prepared request object if return_request is True

        Raises:
            UnauthorizedError: If the request fails with a 401 status code
            requests.exceptions.RequestException: If the request fails with any other error
        z/credentials/by_name/r   r   r    r!   Nr"   r<   s           r   ÚgetzCredentialsManagementClient.get™   sÄ   € ð( Ÿ™Ð'Ð'<¸_Ð<MÐNˆä!×)Ñ)¨%°¸d×>OÑ>OÓ>QÔRˆáØˆNä!×)Ñ)Ó+ˆð	Ø%Ÿl™l¨7¯?©?Ó+<ÀdÇmÁm˜lÓTˆHØ×%Ñ%Ô'Ø—=‘=“?Ð"øÜ×"Ñ"×,Ñ,ò 	Ø�z‰z×%Ñ%¨Ò,Ü'¨Ó*Ð*Øûð	úr>   )Né   )F)Ú__name__Ú
__module__Ú__qualname__ÚstrÚintr   Údictr   Úboolr   r#   r$   r2   r9   r=   r@   © r   r   r   r      s5  „ ñ  ð  ¨s°T©zð  È3ó  ð
˜d 3¨ 8™nó 
ð  %ñ!àð!ð 
ˆc�3ˆh‰˜(×*Ñ*Ñ	*ó!ðP  %ñ-àð-ð ˜c 3˜h™ð-ð    S ™>ð	-ð
 ð-ð 
ˆc�3ˆh‰˜(×*Ñ*Ñ	*ó-ðd  %ñ#àð#ð ð#ð 
ˆc�3ˆh‰˜(×*Ñ*Ñ	*ó	#ðP  %ñ#àð#ð ð#ð 
ˆc�3ˆh‰˜(×*Ñ*Ñ	*ô	#r   r   )Útypingr   r   r#   r*   r   r   rI   r   r   ú<module>rK      s   ðß ã å )÷tò tr   