From 927d36148f5c82ba3f85cd79f81cf4c211bd6d7b Mon Sep 17 00:00:00 2001 From: Krrish Dholakia Date: Thu, 9 May 2024 13:21:00 -0700 Subject: [PATCH] feat(proxy_server.py): expose new `/team/list` endpoint Closes https://github.com/BerriAI/litellm/issues/3523 --- litellm/proxy/proxy_server.py | 37 +++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/litellm/proxy/proxy_server.py b/litellm/proxy/proxy_server.py index 1ba29dcc6..0456881cd 100644 --- a/litellm/proxy/proxy_server.py +++ b/litellm/proxy/proxy_server.py @@ -7313,6 +7313,43 @@ async def unblock_team( return record +@router.get( + "/team/list", tags=["team management"], dependencies=[Depends(user_api_key_auth)] +) +async def list_team( + user_api_key_dict: UserAPIKeyAuth = Depends(user_api_key_auth), +): + """ + [Admin-only] List all available teams + + ``` + curl --location --request GET 'http://0.0.0.0:4000/team/list' \ + --header 'Authorization: Bearer sk-1234' + ``` + """ + global prisma_client + + if user_api_key_dict.user_role != "proxy_admin": + raise HTTPException( + status_code=401, + detail={ + "error": "Admin-only endpoint. Your user role={}".format( + user_api_key_dict.user_role + ) + }, + ) + + if prisma_client is None: + raise HTTPException( + status_code=400, + detail={"error": CommonProxyErrors.db_not_connected_error.value}, + ) + + response = await prisma_client.db.litellm_teamtable.find_many() + + return response + + #### ORGANIZATION MANAGEMENT ####