
    hh                     H    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Z	y)    )	timedelta)HTTPExceptionN)CommonProxyErrorsInvitationNewUserAPIKeyAuthdatauser_api_key_dictc           	        K   ddl m}m} |'t        ddt        j
                  j                  i      t        j                  j                         }|t        d      z   }	 |j                  j                  j                  | j                  |||j                  xs |||j                  xs |d	
       d{   }|S 7 # t        $ r9}dt!        |      v rt        dddi      t        ddt!        |      i      d}~ww xY 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_id
created_at
expires_at
created_by
updated_at
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  )litellm.proxy.proxy_serverr   r   r   r   db_not_connected_errorvaluelitellmutilsget_utc_datetimer   dblitellm_invitationlinkcreater   	Exceptionstr)r   r	   r   r   current_timer   responsees           l/var/www/Befach/backend/env/lib/python3.12/site-packages/litellm/proxy/management_helpers/user_invitation.pycreate_invitation_for_userr'   	   s     S.EEKKL
 	

 ==113L	q 11JG&))@@GG<<*(/77S;S*/77S;S H 	
 	
 	
  G73q6Ax  Wc!f4EFFGs=   AD"AC 8B?9C >D?C 	D
4C>>DD)
datetimer   fastapir   r   litellm.proxy._typesr   r   r   r'        r&   <module>r-      s,     !  Q Q&G
&G%&Gr,   