Ë
    tPêj�  ã                   óì  — U d Z ddlZddlZddlZddlZddlmZmZ ddlmZm	Z	m
Z
 ddlmZ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mZmZmZ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'm(Z(m)Z) ddl*m+Z+m,Z, ddl-m.Z.m/Z/ ddl0m1Z1 ddl2m3Z3  e«       Z4e
e5d<   dZ6e
e5d<   de7defd„Z8d5d„Z9de	de	fd„Z:deddfd„Z;de<defd„Z=d6d„Z>de7d e	d!e	d"e d#e7dz  ddfd$„Z?d%e@de7defd&„ZAe4j…                  d'd(g ee"«      g¬)«      e1 ee"«       edd*¬+«      fded,ede7d"e d#e7dz  f
d-„«       «       ZCe4j‰                  d.d(g ee"«      ge¬/«      e1	 d7d,ede7d0e7d"ee  ee"«      f   d#ee7dz   ed*¬+«      f   f
d1„«       «       ZEe4j…                  d2d(g ee"«      g¬)«      e1 ee"«       edd*¬+«      fd,ede7d"e d#e7dz  fd3„«       «       ZFe4j�                  d'd(g ee"«      g¬)«      e1 ee"«      fd,ede7d"e fd4„«       «       ZHy)8zc
Endpoints to control callbacks per team

Use this when each team should control its own callbacks
é    N)ÚdatetimeÚtimezone)Ú	AnnotatedÚAnyÚFinal)Ú	APIRouterÚDependsÚHeaderÚHTTPExceptionÚRequestÚstatus)Úverbose_proxy_logger)Úuuid)
ÚAddTeamCallbackÚLiteLLM_AuditLogsÚLiteLLM_TeamTableÚLitellmTableNamesÚProxyErrorTypesÚProxyExceptionÚTeamCallbackDeleteResponseÚTeamCallbackDeleteResponseDataÚTeamCallbackMetadataÚUserAPIKeyAuth)Úuser_api_key_auth)Úcallback_config_error)Ú_CALLBACK_VAR_ENCRYPTED_PREFIXÚdecrypt_callback_varsÚencrypt_callback_varsÚis_sensitive_callback_key)Ú _get_validated_callback_metadataÚ(convert_key_logging_metadata_to_callback)Ú_refresh_cached_teamÚ_verify_team_access)Úmanagement_endpoint_wrapper)ÚTeamRepositoryÚrouterz***REDACTED***Ú_CALLBACK_VARS_REDACTEDÚmessageÚreturnc                 ó    — t        dd| i¬«      S )Né�  Úerror©Ústatus_codeÚdetail©r   )r(   s    ú/home/oem/CyberBrain26-unified/.venv/lib/python3.12/site-packages/litellm/proxy/management_endpoints/team_callback_endpoints.pyÚ_callback_config_errorr2   7   s   € Ü S°'¸7Ð1CÔDÐDó    Údatac                 ó^   — t        | j                  | j                  «      }|�t        |«      ‚y ©N)r   Úcallback_nameÚcallback_varsr2   )r4   r,   s     r1   Ú_validate_team_callbackr9   ;   s0   € Ü(¨×);Ñ);¸T×=OÑ=OÓP€EØÐÜ$ UÓ+Ð+ð r3   Úmetadatac                 ó  — t        | t        «      s| S t        j                  | «      }|j	                  d«      }t        |t
        «      rS|D ]N  }t        |t        «      sŒt        |j	                  d«      t        «      sŒ4|d   D �ci c]	  }|t        “Œ c}|d<   ŒP |j	                  d«      }t        |t        «      r:t        |j	                  d«      t        «      r|d   D �ci c]	  }|t        “Œ c}|d<   |S c c}w c c}w )ay  Strip secret values out of a team-metadata snapshot before audit logging.

    Both ``team_metadata["logging"]`` (list of ``AddTeamCallback`` dicts) and
    ``team_metadata["callback_settings"]["callback_vars"]`` carry provider
    credentials such as ``langfuse_secret_key``, ``langsmith_api_key``, and
    ``gcs_path_service_account``.  Persisting them verbatim into
    ``LiteLLM_AuditLogs`` would let anyone with read access to the audit
    table harvest team callback credentials, so we replace each value with
    a fixed marker.  The keys themselves are kept so the audit reader can
    still see *which* fields changed.
    Úloggingr8   Úcallback_settings)Ú
isinstanceÚdictÚcopyÚdeepcopyÚgetÚlistr'   )r:   ÚredactedÚlogging_entriesÚentryÚkr=   s         r1   Ú_redact_callback_secretsrH   A   sï   € ô �h¤Ô%ØˆÜ—m‘m HÓ-€HØ%Ÿ\™\¨)Ó4€OÜ�/¤4Ô(Ø$ò 	fˆEÜ˜%¤Õ&¬:°e·i±iÀÓ6PÔRVÕ+WØNSÐTcÑNdÖ)eÈ¨!Ô-DÑ*DÒ)e��oÒ&ð	fð  (Ÿ|™|Ð,?Ó@ÐÜÐ#¤TÔ*¬zÐ:K×:OÑ:OÐP_Ó:`ÔbfÔ/gØRcÐdsÑRtÖ-uÈQ¨aÔ1HÑ.HÒ-uÐ˜/Ñ*Ø€Oùò	 *fùò .vs   ÂC9Ã#C>Ú	callbacksc                 óê   — | j                   syt        | j                   «      D ]N  }| j                   |   }t        |«      st        |«      j	                  t
        «      sŒ<t        | j                   |<   ŒP y)aû  Mask credential-bearing callback vars in place, keeping the rest readable.

    ``callback_vars`` mixes credentials (``langsmith_api_key``,
    ``langfuse_secret_key``, ``gcs_path_service_account``) with plain
    configuration (project names, bucket names, hosts). The configuration is
    what makes a read of this endpoint useful, so only the sensitive keys are
    replaced, using the same marker as the audit-log redaction above.

    A value that still carries the encrypted prefix here failed to decrypt, so
    it is masked too. Handing back a ciphertext blob under a key that is not
    classified as sensitive would give the caller something it cannot use and
    cannot tell apart from a real value.

    Masking in place rather than rebuilding the mapping keeps this under the
    LIT002 mutable-collection-construction budget. It is safe because the only
    caller passes an object it just built from a decrypted deep copy of the
    row, so nothing here is reachable from the team's stored metadata.
    N)r8   Útupler   ÚstrÚ
startswithr   r'   )rI   ÚkeyÚvalues      r1   Ú_mask_sensitive_callback_varsrP   [   sf   € ð& ×"Ò"ØÜ�Y×,Ñ,Ó-ò CˆØ×'Ñ'¨Ñ,ˆÜ$ SÔ)¬S°«Z×-BÑ-BÔCaÕ-bÜ+BˆI×#Ñ# CÒ(ñCr3   Úteam_metadatac                 óœ  — t        | t        «      s
t        «       S t        | «      }|j	                  d«      }|�Rt        «       }t        |t
        «      r|ndD ]0  }t        |t        «      sŒt        |d¬«      }|€Œ$t        ||¬«      }Œ2 n6|j	                  d«      }t        |t        «      rt        di |¤Žn	t        «       }t        |«       |S )a  Report the callbacks that are actually in effect for a team.

    A team's callback config can live in either of two metadata slots.
    ``metadata["logging"]`` holds the ``AddTeamCallback`` entries written by
    ``POST /team/{team_id}/callback`` and by the Admin UI, while
    ``metadata["callback_settings"]`` holds the older ``TeamCallbackMetadata``
    shape. Request-time resolution in ``_get_dynamic_logging_metadata`` treats
    the two as mutually exclusive: a populated ``logging`` slot wins outright
    and ``callback_settings`` is consulted only as the deprecated fallback.
    This reader applies the same precedence so it reports what a request would
    really do. Merging the two instead would report a ``callback_settings``
    entry as active for a team whose requests never fire it.

    Credential ``callback_vars`` are stored encrypted, so they are decrypted
    before being masked by key; a value encrypted under a key that is no longer
    classified as sensitive would otherwise come back as raw ciphertext.
    r<   © zteam-level read)ÚitemÚsource)r4   Úteam_callback_settings_objr=   )	r>   r?   r   r   rB   rC   r    r!   rP   )rQ   Ú	decryptedrE   ÚresolvedrF   Úcallbackr=   s          r1   Ú_resolve_team_callbacksrZ   v   sÍ   € ô$ �m¤TÔ*Ü#Ó%Ð%ä,¨]Ó;€IØ&Ÿ]™]¨9Ó5€OàÐ"Ü'Ó)ˆÜ(2°?ÄDÔ(I‘_Èrò 	tˆEÜ˜e¤TÔ*ØÜ7¸UÐK\Ô]ˆHØÐØÜ?ÀXÐjrÔs‰Hñ	tð $-§=¡=Ð1DÓ#EÐä9CÐDUÔW[Ô9\Ô Ñ5Ð#4Ò5ÔbvÓbxð 	ô " (Ô+Ø€Or3   c                 óx   — | j                  «       ry| j                  «       }|�t        j                  d|«       yy)u0  Surface a fire-and-forget audit-log task failure.

    ``asyncio.create_task`` swallows exceptions silently â€” if the audit
    write fails (transient DB error etc.) we'd otherwise lose the row
    without any signal.  Log at warning level so the operator sees there's
    a gap in the audit trail.
    Nz+Failed to write team-callback audit log: %s)Ú	cancelledÚ	exceptionr   Úwarning)ÚtaskÚexcs     r1   Ú_log_audit_task_exceptionra   ¡   s9   € ð ‡~�~ÔØØ—‘Ó!€CØ
€Ü×$Ñ$Ð%RÐTWÕXð r3   Úteam_idÚbefore_metadataÚafter_metadataÚuser_api_key_dictÚlitellm_changed_byc              ƒ   ó"  K  — ddl m}m} ddlm}  |«       syt        |«      }t        |«      }	t        j                   |t        t        t        j                  «       «      t        j                  t        j                  «      |xs |j                   xs ||j"                  t$        j&                  | dt)        j*                  d|	it        ¬«      t)        j*                  d|it        ¬«      ¬«	      ¬	«      «      }
|
j-                  t.        «       y­w)
aõ  Emit an audit-log row for a team-callback mutation.

    Mirrors the ``store_audit_logs``-gated pattern used in
    ``team_endpoints.py``: the call is async-fire-and-forget and is a no-op
    when audit logging is not enabled on the proxy.  Captured under
    ``LitellmTableNames.TEAM_TABLE_NAME`` so the row co-locates with other
    team mutations in the audit table.

    Callback secrets are redacted before serialization so the audit table
    cannot itself become a credential-harvest sink.
    r   )Úcreate_audit_log_for_updateÚis_audit_logging_enabled)Úlitellm_proxy_admin_nameNÚupdatedr:   )Údefault)	ÚidÚ
updated_atÚ
changed_byÚchanged_by_api_keyÚ
table_nameÚ	object_idÚactionÚupdated_valuesÚbefore_value)Úrequest_data)Ú+litellm.proxy.management_helpers.audit_logsrh   ri   Úlitellm.proxy.proxy_serverrj   rH   ÚasyncioÚcreate_taskr   rL   r   Úuuid4r   Únowr   ÚutcÚuser_idÚapi_keyr   ÚTEAM_TABLE_NAMEÚjsonÚdumpsÚadd_done_callbackra   )rb   rc   rd   re   rf   rh   ri   rj   Úredacted_beforeÚredacted_afterr_   s              r1   Ú_emit_team_callback_audit_logr†   °   sÑ   è ø€ ÷&õ Dá#Ô%Øä5°oÓF€OÜ4°^ÓD€Nä×%Ñ%Ù#Ü*Ü”t—z‘z“|Ó$Ü#Ÿ<™<¬¯©Ó5Ø-ÒfÐ1B×1JÑ1JÒfÐNfØ#4×#<Ñ#<Ü,×<Ñ<Ø!Ø Ü#Ÿz™z¨:°~Ð*FÔPSÔTÜ!ŸZ™Z¨°_Ð(EÌsÔSô
ô	
ó€Dð 	×ÑÔ4Õ5ùs   ‚DDr.   c                 ó    — t        | d|i¬«      S )zMBuild the ``{"error": ...}`` failure body the team callback endpoints return.r,   r-   r0   )r.   r(   s     r1   Ú_callback_errorrˆ   á   s   € äØØ˜Ð!ôð r3   z/team/{team_id:path}/callbackzteam management)ÚtagsÚdependenciesz�The litellm-changed-by header enables tracking of actions performed by authorized users on behalf of other users, providing an audit trail for accountability)ÚdescriptionÚhttp_requestc           
   ƒ   óœ  K  — 	 ddl m} ddlm}m}m} |€#t        dd|j                  j                  i¬«      ‚|j                  |dd	¬
«      ƒ d{  –—† }	|	€t        ddd|› d�i¬«      ‚t        t        d$i |	j                  «       ¤Ž|¬«      ƒ d{  –—†  t        | «       |	j                  }
|
j                  d«      }|�t!        |t"        «      sg }|D ]‡  }|j                  d«      | j$                  k(  sŒ"|j                  d«      | j&                  k(  sŒAt)        d| j$                  › d|› d| j&                  › �t*        j,                  t.        j0                  d¬«      ‚ t3        j4                  |
«      }|j7                  | j                  «       «       ||
d<   t9        |
«      }
t;        j<                  |
«      }t?        |«      j@                  jC                  d|id|iddi¬«      ƒ d{  –—† }|€tE        dd|› d�«      ‚tG        |||¬«      ƒ d{  –—†  tI        |||
||¬«      ƒ d{  –—†  d|dœS 7 �Œá7 �Œ£7 ŒO7 Œ)7 Œ# t        $ r}|‚d}~wt(        $ r}|‚d}~wtJ        $ rg}tM        jN                  d|«       t)        d tQ        |«      z   t.        jR                  j                  tU        |d!d"«      t*        jV                  ¬#«      ‚d}~ww xY w­w)%aé  
    Add a success/failure callback to a team

    Use this if if you want different teams to have different success/failure callbacks

    Parameters:
    - callback_name (Literal["langfuse", "langsmith", "gcs"], required): The name of the callback to add
    - callback_type (Literal["success", "failure", "success_and_failure"], required): The type of callback to add. One of:
        - "success": Callback for successful LLM calls
        - "failure": Callback for failed LLM calls
        - "success_and_failure": Callback for both successful and failed LLM calls
    - callback_vars (StandardCallbackDynamicParams, required): A dictionary of variables to pass to the callback
        - langfuse_public_key: The public key for the Langfuse callback
        - langfuse_secret_key: The secret key for the Langfuse callback
        - langfuse_secret: The secret for the Langfuse callback
        - langfuse_host: The host for the Langfuse callback
        - langfuse_environment: The tracing environment for the Langfuse callback (lowercase; falls back to LANGFUSE_TRACING_ENVIRONMENT)
        - gcs_bucket_name: The name of the GCS bucket
        - gcs_path_service_account: The path to the GCS service account
        - langsmith_api_key: The API key for the Langsmith callback
        - langsmith_project: The project for the Langsmith callback
        - langsmith_base_url: The base URL for the Langsmith callback

    Example curl:
    ```
    curl -X POST 'http:/localhost:4000/team/dbe2f686-a686-4896-864a-4c3924458709/callback'         -H 'Content-Type: application/json'         -H 'Authorization: Bearer sk-1234'         -d '{
        "callback_name": "langfuse",
        "callback_type": "success",
        "callback_vars": {"langfuse_public_key": "pk-lf-xxxx1", "langfuse_secret_key": "sk-xxxxx"}
        
    }'
    ```

    This means for the team where team_id = dbe2f686-a686-4896-864a-4c3924458709, all LLM calls will be logged to langfuse using the public key pk-lf-xxxx1 and the secret key sk-xxxxx

    r   ©ÚCommonProxyErrors©Úprisma_clientÚproxy_logging_objÚuser_api_key_cacheNéô  r,   r-   ÚteamÚfind_unique©rb   rq   Ú
query_typer+   ú
Team id = z0 does not exist. Please use a different team id.©Úteam_objre   r<   r7   Úcallback_typeúcallback_name = z9 already exists in team_callback_settings, for team_id = z and event = )r(   ÚcodeÚtypeÚparamrb   r:   Úobject_permissionT©Úwherer4   Úinclude©Úteam_rowr“   r’   ©rb   rc   rd   re   rf   Úsuccess©r   r4   zGlitellm.proxy.proxy_server.add_team_callbacks(): Exception occured - %súInternal Server Error, r    ÚNone©r(   rŸ   r    rž   rS   ),Úlitellm.proxy._typesr�   rx   r‘   r’   r“   r   Údb_not_connected_errorrO   Úget_datar#   r   Ú
model_dumpr9   r:   rB   r>   rC   r7   rœ   r   r   ÚHTTP_400_BAD_REQUESTr   Úbad_request_errorr@   rA   Úappendr   r�   r‚   r%   ÚtableÚupdaterˆ   r"   r†   Ú	Exceptionr   r]   rL   Úinternal_server_errorÚgetattrÚHTTP_500_INTERNAL_SERVER_ERROR)r4   rŒ   rb   re   rf   r�   r‘   r’   r“   Ú_existing_teamrQ   Úteam_callback_settingsrY   rc   Úteam_metadata_jsonÚnew_team_rowÚes                    r1   Úadd_team_callbacksr¿   é   s6  è ø€ ðnf
Ý:÷	
ñ 	
ð Ð ÜØØÐ!2×!IÑ!I×!OÑ!OÐPôð ð  -×5Ñ5¸gÐRXÐerÐ5Ós×sˆØÐ!ÜØØ :¨g¨YÐ6fÐ!gÐhôð ô "Ü&ÑE¨×)BÑ)BÓ)DÑEØ/ô
÷ 	
ð 	
ô
 	  Ô%ð '×/Ñ/ˆØ-:×->Ñ->¸yÓ-IÐØ!Ð)´Ð<RÔTXÔ1YØ%'Ð"ð /ò 
	ˆHà—‘˜_Ó-°×1CÑ1CÓCØ—L‘L Ó1°T×5GÑ5GÓGä$Ø.¨t×/AÑ/AÐ.BÐB{ð  }Dð  |Eð  ERð  SW÷  Señ  Seð  Rfð  gÜ×4Ñ4Ü(×:Ñ:Ø)ô	ð ð
	ô "&§¡¨}Ó!=ˆØ×%Ñ% d§o¡oÓ&7Ô8à#9ˆ�iÑ Ü-¨mÓ<ˆÜ$(§J¡J¨}Ó$=Ðä$2°=Ó$A×$GÑ$G×$NÑ$NØ˜gÐ&ØÐ0Ð1ð )¨$Ð/ð %Oó %
÷ 
ˆð ÐÜ! #¨°G°9Ð<lÐ'mÓnÐnô #Ø!Ø1Ø/ô
÷ 	
ð 	
ô ,ØØ+Ø(Ø/Ø1ô
÷ 	
ð 	
ð  Ø ñ
ð 	
ðO tùð	
ùðB
øð	
øð	
ùô ò ØˆûÜò ØˆûÜò 
Ü×&Ñ&Ð'pÐrsÔtÜØ-´°A³Ñ6Ü ×6Ñ6×<Ñ<Ü˜!˜W fÓ-Ü×6Ñ6ô	
ð 	
ûð
üs«   ‚K„AH= ÁH1ÁA H= ÂH4ÂA#H= Ã6H= ÄCH= Ç'H7Ç('H= ÈH9ÈH= È'H;È(H= È0KÈ1H= È4H= È7H= È9H= È;H= È=	K	ÉIÉK	ÉIÉK	É"A"KËK	Ë	Kz-/team/{team_id:path}/callback/{callback_name})r‰   rŠ   Úresponse_modelr7   c              ƒ   ó¬  K  — 	 ddl m} ddlm}m}m} |€ t        d|j                  j                  «      ‚|j                  |dd¬«      ƒ d{  –—† }	|	€t        d	d
|› d�«      ‚t        t        di |	j                  «       ¤Ž|¬«      ƒ d{  –—†  |	j                  }
|
j                  d«      }t        |t         «      r|nd}|D �cg c])  }t        |t"        «      r|j                  d«      |k(  rŒ(|‘Œ+ }}t%        |«      t%        |«      k(  rt        d	d|› d|› d�«      ‚i |
¥d|i¥}t'        |«      }t)        j*                  |«      }t-        |«      j.                  j1                  d|id|iddi¬«      ƒ d{  –—† }|€t        d	d
|› d�«      ‚t3        |||¬«      ƒ d{  –—†  t5        ||
|||¬«      ƒ d{  –—†  t7        |«      }t9        dd|› d|› �t;        |t=        |j>                  xs d«      t=        |j@                  xs d«      ¬«      ¬«      }|S 7 �ŒÊ7 �Œ�c c}w 7 Œª7 Œ„7 Œn# tB        $ r ‚ tD        $ r ‚ tF        $ rŽ}tI        jJ                  d |«       tI        jL                  tO        jP                  «       «       tE        d!tS        |«      z   tT        jV                  j                  tY        |d"d#«      tZ        j\                  ¬$«      ‚d}~ww xY w­w)%aÑ  
    Remove a single callback from a team

    The team's other callbacks stay registered and keep firing. Use this instead of
    POST /team/{team_id}/disable_logging, which clears every callback on the team at once.

    Every entry registered under this callback_name is removed, across callback types, so a
    callback registered for both "success" and "failure" is deregistered by one call.

    Parameters:
    - team_id (str, required): The unique identifier for the team
    - callback_name (str, required): The name of the callback to remove, matched exactly as it was
      registered with POST /team/{team_id}/callback (e.g. "langfuse", "langsmith", "gcs")

    Example curl:
    ```
    curl -X DELETE 'http://localhost:4000/team/dbe2f686-a686-4896-864a-4c3924458709/callback/langsmith'         -H 'Authorization: Bearer sk-1234'
    ```

    Covers callbacks registered through POST /team/{team_id}/callback and the Admin UI. Teams still
    on the deprecated callback_settings metadata shape hold no such entries, so this returns 404 for
    them; POST /team/{team_id}/disable_logging remains the way to clear those.

    Returns 404 if the team does not exist, or if callback_name is not registered for the team.
    r   rŽ   r�   Nr”   r•   r–   r—   é”  r™   ú does not exist.rš   r<   rS   r7   r�   z! is not registered for team_id = ú.rb   r:   r¡   Tr¢   z- does not exist. Error removing team callbackr¥   r§   r¨   z	Callback z removed for team ©rb   Úsuccess_callbacksÚfailure_callbacks©r   r(   r4   zJlitellm.proxy.proxy_server.delete_team_callback(): Exception occurred - %srª   r    r«   r¬   )/r­   r�   rx   r‘   r’   r“   rˆ   r®   rO   r¯   r#   r   r°   r:   rB   r>   rC   r?   Úlenr   r�   r‚   r%   r´   rµ   r"   r†   rZ   r   r   rK   Úsuccess_callbackÚfailure_callbackr   r   r¶   r   r,   ÚdebugÚ	tracebackÚ
format_excrL   r   r·   r¸   r   r¹   )rŒ   rb   r7   re   rf   r�   r‘   r’   r“   rº   rQ   Úregistered_callbacksÚentriesrF   Úremaining_callbacksÚupdated_metadataÚencrypted_metadatar¼   Úupdated_teamÚ	survivingÚresponser¾   s                         r1   Údelete_team_callbackr×   ‰  s)  è ø€ ðZaÝ:÷	
ñ 	
ð Ð Ü! #Ð'8×'OÑ'O×'UÑ'UÓVÐVà&3×&<Ñ&<Ø¨¸=ð '=ó '
÷ !
ˆð Ð!Ü! #¨°G°9Ð<LÐ'MÓNÐNô
 "Ü&ÑE¨×)BÑ)BÓ)DÑEØ/ô
÷ 	
ð 	
ð
  .×6Ñ6ˆØ&3×&7Ñ&7¸	Ó&BÐÜ1;Ð<PÔRVÔ1WÑ-Ð]_ˆð  'ö&
Ø¬z¸%ÄÔ/FÈ5Ï9É9ÐUdÓKeÐivÓKvŠEð&
Ðð &
ô Ð"Ó#¤s¨7£|Ò3Ü! #Ð)9¸-¸ÐHiÐjqÐirÐrsÐ'tÓuÐuà"S ]Ð"S°IÐ?RÑ"SÐÜ$9Ð:JÓ$KÐÜ$(§J¡JÐ/AÓ$BÐä$2°=Ó$A×$GÑ$G×$NÑ$NØ˜gÐ&ØÐ0Ð1ð )¨$Ð/ð %Oó %
÷ 
ˆð ÐÜ! #¨°G°9Ð<iÐ'jÓkÐkô #Ø!Ø1Ø/ô
÷ 	
ð 	
ô ,ØØ)Ø-Ø/Ø1ô
÷ 	
ð 	
ô 3Ð3EÓFˆ	ä4ØØ ˜Ð.@ÀÀ	ÐJÜ/ØÜ"'¨	×(BÑ(BÒ(HÀbÓ"IÜ"'¨	×(BÑ(BÒ(HÀbÓ"Iôô
ˆð6 ˆðm!
ùð	
ûò&
ð
øð	
øð	
ùô, ò ð 	Üò ØÜò 
Ü×"Ñ"Ð#oÐqrÔsÜ×"Ñ"¤9×#7Ñ#7Ó#9Ô:ÜØ-´°A³Ñ6Ü ×6Ñ6×<Ñ<Ü˜!˜W fÓ-Ü×6Ñ6ô	
ð 	
ûð
üs˜   ‚K„A	H( ÁHÁ=H( ÂHÂ9H( Ã)HÃ/HÃ3BH( Å7H"Å8'H( ÆH$Æ H( Æ7H&Æ8AH( ÈKÈH( ÈH( ÈH( È$H( È&H( È(KÉB	KËKËKz/team/{team_id}/disable_loggingc           
   ƒ   ó’  K  — 	 ddl m}m}m} |€t	        dddi¬«      ‚|j                  |dd	¬
«      ƒ d{  –—† }|€t	        ddd|› d�i¬«      ‚t        t        d"i |j                  «       ¤Ž|¬«      ƒ d{  –—†  |j                  }t        j                  |«      }	|j                  di «      }
t        d"i |
¤Ž}g |_        g |_        |j                  «       |d<   g |d<   t!        |«      }t#        j$                  |«      }t'        |«      j(                  j+                  d|id|iddi¬«      ƒ d{  –—† }|€t	        ddd|› d�i¬«      ‚t-        |||¬«      ƒ d{  –—†  t/        ||	|||¬«      ƒ d{  –—†  dd|› �|j0                  g g dœdœS 7 �ŒY7 �Œ7 Œd7 Œ;7 Œ%# t        $ r ‚ t2        $ r ‚ t4        $ rŽ}t7        j8                  d|«       t7        j:                  t=        j>                  «       «       t3        dtA        |«      z   tB        jD                  jF                  tI        |dd «      tJ        jL                  ¬!«      ‚d}~ww xY w­w)#aç  
    Disable all logging callbacks for a team

    Callbacks registered through POST /team/{team_id}/callback and the Admin UI are cleared, so
    re-enabling logging means registering them again with their callback_vars

    Parameters:
    - team_id (str, required): The unique identifier for the team

    Example curl:
    ```
    curl -X POST 'http://localhost:4000/team/dbe2f686-a686-4896-864a-4c3924458709/disable_logging'         -H 'Authorization: Bearer sk-1234'
    ```


    r   r�   Nr”   r,   úNo db connectedr-   r•   r–   r—   rÂ   r™   rÃ   rš   r=   r<   rb   r:   r¡   Tr¢   z, does not exist. Error updating team loggingr¥   r§   r¨   zLogging disabled for team rÅ   rÈ   zJlitellm.proxy.proxy_server.disable_team_logging(): Exception occurred - %srª   r    r«   r¬   rS   )'rx   r‘   r’   r“   r   r¯   r#   r   r°   r:   r@   rA   rB   r   rÊ   rË   r   r�   r‚   r%   r´   rµ   r"   r†   rb   r   r¶   r   r,   rÌ   rÍ   rÎ   rL   r   r·   rO   r¸   r   r¹   )rŒ   rb   re   rf   r‘   r’   r“   rº   rQ   rc   r»   rV   r¼   rÔ   r¾   s                  r1   Údisable_team_loggingrÚ     s¹  è ø€ ð@h
÷	
ñ 	
ð Ð Ü¨C¸ÐBSÐ8TÔUÐUð  -×5Ñ5¸gÐRXÐerÐ5Ós×sˆØÐ!ÜØØ :¨g¨YÐ6FÐ!GÐHôð ô "Ü&ÑE¨×)BÑ)BÓ)DÑEØ/ô
÷ 	
ð 	
ð '×/Ñ/ˆÜ!%§¡¨}Ó!=ˆØ(5×(9Ñ(9Ð:MÈrÓ(RÐÜ,@Ñ,ZÐCYÑ,ZÐ"ð 79Ð"Ô3Ø68Ð"Ô3ð .H×-RÑ-RÓ-TˆÐ)Ñ*ð $&ˆ�iÑ Ü-¨mÓ<ˆÜ$(§J¡J¨}Ó$=Ðô %3°=Ó$A×$GÑ$G×$NÑ$NØ˜gÐ&ØÐ0Ð1ð )¨$Ð/ð %Oó %
÷ 
ˆð ÐÜØØ :¨g¨YÐ6bÐ!cÐdôð ô #Ø!Ø1Ø/ô
÷ 	
ð 	
ô ,ØØ+Ø(Ø/Ø1ô
÷ 	
ð 	
ð  Ø3°G°9Ð=à'×/Ñ/Ø%'Ø%'ññ
ð 	
ðI tùð	
ùð0
øð"	
øð	
ùô$ ò ð 	Üò ØÜò 
Ü×"Ñ"Ð#oÐqrÔsÜ×"Ñ"¤9×#7Ñ#7Ó#9Ô:ÜØ-´°A³Ñ6Ü ×6Ñ6×<Ñ<Ü˜!˜W fÓ-Ü×6Ñ6ô	
ð 	
ûð
üsƒ   ‚I„2F ¶F·A F Á7FÁ8B8F Ä0FÄ1*F ÅFÅF Å3FÅ4F ÆIÆF ÆF ÆF ÆF ÆF ÆIÆ6B	H?È?IÉIc              ƒ   óÈ  K  — 	 ddl m} |€t        dddi¬«      ‚|j                  |dd	¬
«      ƒ d{  –—† }|€t        ddd|› d�i¬«      ‚t	        t        di |j                  «       ¤Ž|¬«      ƒ d{  –—†  t        |j                  «      }d||j                  |j                  |j                  dœdœS 7 Œ‚7 ŒC# t        $ r ‚ t        $ r ‚ t        $ �r
}t        j                  d|«       t        j                   t#        j$                  «       «       t'        |t        «      rZt        t)        |dd|› d�«      t*        j,                  j.                  t)        |dd«      t)        |dt0        j2                  «      ¬«      ‚t'        |t        «      r|‚t        dt5        |«      z   t*        j,                  j.                  t)        |dd«      t0        j2                  ¬«      ‚d}~ww xY w­w)a¾  
    Get the success/failure callbacks and variables for a team

    Parameters:
    - team_id (str, required): The unique identifier for the team

    Example curl:
    ```
    curl -X GET 'http://localhost:4000/team/dbe2f686-a686-4896-864a-4c3924458709/callback'         -H 'Authorization: Bearer sk-1234'
    ```

    This will return the callback settings for the team with id dbe2f686-a686-4896-864a-4c3924458709

    Covers callbacks registered through POST /team/{team_id}/callback and the Admin UI as well as
    teams still on the deprecated callback_settings shape, resolved from the team's stored metadata
    with the same precedence used at request time. A key-level logging config overrides the team's
    at request time and is not reflected here. Credential-bearing callback_vars are returned masked
    as `***REDACTED***`

    Returns {
            "status": "success",
            "data": {
                "team_id": team_id,
                "success_callbacks": team_callback_settings_obj.success_callback,
                "failure_callbacks": team_callback_settings_obj.failure_callback,
                "callback_vars": team_callback_settings_obj.callback_vars,
            },
        }
    r   )r‘   Nr”   r,   rÙ   r-   r•   r–   r—   rÂ   r™   rÃ   rš   r¨   )rb   rÆ   rÇ   r8   r©   zHlitellm.proxy.proxy_server.get_team_callbacks(): Exception occurred - %sr/   zInternal Server Error(ú)r    r«   r.   r¬   rª   rS   )rx   r‘   r   r¯   r#   r   r°   rZ   r:   rÊ   rË   r8   r   r¶   r   r,   rÌ   rÍ   rÎ   r>   r¸   r   r·   rO   r   r¹   rL   )rŒ   rb   re   r‘   rº   rV   r¾   s          r1   Úget_team_callbacksrÝ   ¥  så  è ø€ ðR:
Ý<àÐ Ü¨C¸ÐBSÐ8TÔUÐUð  -×5Ñ5¸gÐRXÐerÐ5Ós×sˆØÐ!ÜØØ :¨g¨YÐ6FÐ!GÐHôð ô "Ü&ÑE¨×)BÑ)BÓ)DÑEØ/ô
÷ 	
ð 	
ô
 -DÀN×D[ÑD[Ó,\Ð"ð  à"Ø%?×%PÑ%PØ%?×%PÑ%PØ!;×!IÑ!Iñ	ñ
ð 	
ð# tøð	
ùô" ò ð 	Üò ØÜó 
Ü×"Ñ"Ð#mÐopÔqÜ×"Ñ"¤9×#7Ñ#7Ó#9Ô:Ü�aœÔ'Ü Ü  8Ð/EÀaÀSÈÐ-JÓKÜ$×:Ñ:×@Ñ@Ü˜a ¨&Ó1Ü˜Q ¬v×/TÑ/TÓUô	ð ô ˜œ>Ô*ØˆGÜØ-´°A³Ñ6Ü ×6Ñ6×<Ñ<Ü˜!˜W fÓ-Ü×6Ñ6ô	
ð 	
ûð
üsM   ‚G"„.B9 ²B5³A B9 Á3B7Á4A B9 Â4G"Â5B9 Â7B9 Â9GÃDGÇGÇG")r4   r   r)   N)r_   zasyncio.Task[None]r)   Nr6   )IÚ__doc__ry   r@   r�   rÍ   r   r   Útypingr   r   r   Úfastapir   r	   r
   r   r   r   Úlitellm._loggingr   Úlitellm._uuidr   r­   r   r   r   r   r   r   r   r   r   r   Ú$litellm.proxy.auth.user_api_key_authr   Ú5litellm.proxy.common_utils.callback_config_validationr   Ú)litellm.proxy.common_utils.callback_utilsr   r   r   r   Ú$litellm.proxy.litellm_pre_call_utilsr    r!   Ú1litellm.proxy.management_endpoints.team_endpointsr"   r#   Ú&litellm.proxy.management_helpers.utilsr$   Ú$litellm.repositories.team_repositoryr%   r&   Ú__annotations__r'   rL   r2   r9   rH   rP   ÚobjectrZ   ra   r†   Úintrˆ   Úpostr¿   Údeleter×   rÚ   rB   rÝ   rS   r3   r1   ú<module>rï      su  ðòó Û Û Û ß 'ß (Ñ (ç N× Nå 1Ý ÷÷ ÷ õ CÝ W÷ó ÷÷õ OÝ ?á“€ˆÓ ð "2Ð ˜Ó 1ðE Cð E¨Mó Eó,ð sð ¨só ð4CÐ-Að CÀdó Cð6(¨6ð (Ð6Jó (óVYð.6àð.6ð ð.6ð ð	.6ð
 &ð.6ð ˜d™
ð.6ð 
ó.6ðb ð ¨sð °}ó ð ‡�Ø#Ø
Ð	ÙÐ+Ó,Ð-ð ó ð
 ñ
 )0Ð0AÓ(BÙ%+Øð tô&ñW
Ø
ðW
àðW
ð ðW
ð &ð	W
ð
 ˜d™
òW
ó óðW
ðt ‡�Ø3Ø
Ð	ÙÐ+Ó,Ð-Ø-ð	 ó ð ð 	ñGØðGàðGð ðGð ! ±Ð9JÓ1KÐ!KÑLð	Gð
 "Øˆd‰
Ùð xô	
ð	ñòGó óðGðT ‡�Ø%Ø
Ð	ÙÐ+Ó,Ð-ð ó ð
 ñ )0Ð0AÓ(BÙ%+Øð tô&ñ	B
ØðB
àðB
ð &ðB
ð ˜d™
ò	B
ó óðB
ðJ ‡�Ø#Ø
Ð	ÙÐ+Ó,Ð-ð ó ð
 ñ )0Ð0AÓ(Bñ]
Øð]
àð]
ð &ò]
ó óñ]
r3   