Ë
    uPêj¿  ã                   óâ   — U d Z ddlmZmZ ddlmZmZmZmZm	Z	 ddl
mZ ddlmZ ddlmZmZ ddlmZ erddlmZ eej,                     Ze	ed	<    G d
„ de«      Z G d„ de«      Z G d„ d«      Zy)a  
Credentials repository for database operations on LiteLLM_CredentialsTable.

This is the only place that talks to ``litellm_credentialstable``. Encryption of
credential values is the caller's responsibility (see ``CredentialHelperUtils``),
so reads return the stored values verbatim.
é    )ÚMappingÚSequence)ÚTYPE_CHECKINGÚAnyÚFinalÚProtocolÚ	TypeAlias)ÚCredentialItem)Ú"wrap_table_actions_for_config_sync)ÚDbRecordÚrecord_to_dict)ÚTableActions)ÚmodelsÚ_CredentialsTablec                   ó   — e Zd Zedd„«       Zy)Ú_PrismaCredentialsDbc                  ó   — y ©N© ©Úselfs    úp/home/oem/CyberBrain26-unified/.venv/lib/python3.12/site-packages/litellm/repositories/credentials_repository.pyÚlitellm_credentialstablez-_PrismaCredentialsDb.litellm_credentialstable   s   € Ø?Bó    N©Úreturnr   )Ú__name__Ú
__module__Ú__qualname__Úpropertyr   r   r   r   r   r      s   „ ØÚBó ÙBr   r   c                   ó"   — e Zd Zedefd„«       Zy)Ú_PrismaClientViewr   c                  ó   — y r   r   r   s    r   Údbz_PrismaClientView.db   s   € Ø*-r   N)r   r   r   r    r   r$   r   r   r   r"   r"      s   „ ØØ-Ð(Ò-ó Ù-r   r"   c                   óÚ   — e Zd ZdZdefd„Zedefd„«       Zedd„«       Z	e
dedz  dedz  fd	„«       Zded
   fd„Zdeeef   dd
fd„Zdededz  fd„Zdedeeef   ddfd„Zdeddfd„Zy)ÚCredentialsRepositoryzIRepository for credentials database operations, keyed by credential name.Úprisma_clientc                 ó   — || _         y r   )Ú_prisma_client)r   r'   s     r   Ú__init__zCredentialsRepository.__init__$   s
   € Ø+ˆÕr   r   c                 óL   — | j                   €t        d«      ‚| j                   }|S )NzFNo DB Connected. See - https://docs.litellm.ai/docs/proxy/virtual_keys)r)   ÚRuntimeError)r   Úclients     r   r'   z#CredentialsRepository.prisma_client'   s*   € à×ÑÐ&ÜÐgÓhÐhØ+/×+>Ñ+>ˆØˆr   c                 óX   — t        | j                  j                  j                  d¬«      S )Nr   )ÚactionsÚ
table_name)r   r'   r$   r   r   s    r   ÚtablezCredentialsRepository.table.   s'   € ä1Ø×&Ñ&×)Ñ)×BÑBØ1ô
ð 	
r   ÚrecordNc                 ó¢   — | €y t        | «      }t        j                  |d   |j                  d«      xs i |j                  d«      xs i dœ«      S )NÚcredential_nameÚcredential_valuesÚcredential_info)r4   r5   r6   )r   r
   Úmodel_validateÚget)r2   Údatas     r   Ú	_to_modelzCredentialsRepository._to_model5   sY   € àˆ>ØÜ$ VÓ,ˆÜ×,Ñ,à#'Ð(9Ñ#:Ø%)§X¡XÐ.AÓ%BÒ%HÀbØ#'§8¡8Ð,=Ó#>Ò#DÀ"ñó
ð 	
r   z&prisma_models.LiteLLM_CredentialsTablec              ƒ   óR   K  — | j                   j                  «       ƒ d {  –—† S 7 Œ­wr   )r1   Ú	find_manyr   s    r   Úfind_allzCredentialsRepository.find_allB   s   è ø€ Ø—Z‘Z×)Ñ)Ó+×+Ð+Ð+ús   ‚' %¡'r9   c              ƒ   óV   K  — | j                   j                  |¬«      ƒ d {  –—† S 7 Œ­w)N)r9   )r1   Úcreate)r   r9   s     r   r?   zCredentialsRepository.createE   s$   è ø€ Ø—Z‘Z×&Ñ&¨DÐ&Ó1×1Ð1Ð1ús   ‚ )¢'£)r4   c              ƒ   ó|   K  — | j                   j                  d|i¬«      ƒ d {  –—† }| j                  |«      S 7 Œ­w©Nr4   )Úwhere)r1   Úfind_uniquer:   )r   r4   r2   s      r   Úfind_by_namez"CredentialsRepository.find_by_nameH   s;   è ø€ Ø"Ÿj™j×4Ñ4Ð<MÈÐ;_Ð4Ó`×`ˆØ�~‰~˜fÓ%Ð%ð aús   ‚"<¤:¥<z-prisma_models.LiteLLM_CredentialsTable | Nonec              ƒ   ó\   K  — | j                   j                  d|i|¬«      ƒ d {  –—† S 7 Œ­w)Nr4   )rB   r9   )r1   Úupdate)r   r4   r9   s      r   Úupdate_by_namez$CredentialsRepository.update_by_nameL   s/   è ø€ ð —Z‘Z×&Ñ&Ð.?ÀÐ-QÐX\Ð&Ó]×]Ð]Ð]ús   ‚#,¥*¦,c              ƒ   óZ   K  — | j                   j                  d|i¬«      ƒ d {  –—† S 7 Œ­wrA   )r1   Údelete)r   r4   s     r   Údelete_by_namez$CredentialsRepository.delete_by_nameQ   s*   è ø€ Ø—Z‘Z×&Ñ&Ð.?ÀÐ-QÐ&ÓR×RÐRÐRús   ‚"+¤)¥+r   )r   r   r   Ú__doc__r   r*   r    r"   r'   r1   Ústaticmethodr   r
   r:   r   r=   r   ÚstrÚobjectr?   rD   rG   rJ   r   r   r   r&   r&   !   sô   „ ÙSð, có ,ð ðÐ0ò ó ðð ò
ó ð
ð ð

˜( T™/ð 

¨n¸tÑ.Cò 

ó ð

ð, Ð)QÑ Ró ,ð2 ¨¨f¨Ñ!5ð 2Ð:bó 2ð&°#ð &¸.È4Ñ:Oó &ð^Ø"ð^Ø*1°#°v°+Ñ*>ð^à	8ó^ð
S°Cð SÐ<kô Sr   r&   N)rK   Úcollections.abcr   r   Útypingr   r   r   r   r	   Úlitellm.models.credentialsr
   Ú-litellm.proxy.common_utils.config_sync_pubsubr   Ú$litellm.repositories.base_repositoryr   r   Ú%litellm.repositories.prisma_protocolsr   Úprismar   Úprisma_modelsÚLiteLLM_CredentialsTabler   Ú__annotations__r   r"   r&   r   r   r   ú<module>rY      sc   ðò÷ .ß AÕ Aå 5Ý \ß IÝ >áÝ.à#/°×0VÑ0VÑ#WÐ�yÓWôC˜8ô Cô
.˜ô .÷
1Sò 1Sr   