o
    ưih                     @   sJ   d dl mZ d dlmZ d dlZd dlmZmZmZ dedefddZ	dS )	    )	timedelta)HTTPExceptionN)CommonProxyErrorsInvitationNewUserAPIKeyAuthdatauser_api_key_dictc              
      s   ddl m}m} |du rtddtjjidtj	 }|t
dd }z|jjj| j|||jp0|||jp5|d	d
I dH }|W S  tyc } zdt|v rUtdddidtddt|idd}~ww )zK
    Create an invitation for the user to onboard to LiteLLM Admin UI.
    r   )litellm_proxy_admin_nameprisma_clientNi  error)status_codedetail   )days)user_idZ
created_at
expires_atZ
created_byZ
updated_atZ
updated_by)r   z*Foreign key constraint failed on the fieldzYUser id does not exist in 'LiteLLM_UserTable'. Fix this by creating user via `/user/new`.i  )Zlitellm.proxy.proxy_serverr	   r
   r   r   Zdb_not_connected_errorvaluelitellmutilsZget_utc_datetimer   dbZlitellm_invitationlinkcreater   	Exceptionstr)r   r   r	   r
   current_timer   responsee r   g/home/app/Keep/.python/lib/python3.10/site-packages/litellm/proxy/management_helpers/user_invitation.pycreate_invitation_for_user	   s<   


r   )
datetimer   Zfastapir   r   Zlitellm.proxy._typesr   r   r   r   r   r   r   r   <module>   s    