feat - raise exception when creating team_id for exiting team_id

This commit is contained in:
Ishaan Jaff 2024-05-22 20:26:56 -07:00
parent b6b86dc539
commit 9ba7d26597

View file

@ -7454,7 +7454,7 @@ async def new_team(
Example Request: Example Request:
``` ```
curl --location 'http://0.0.0.0:8000/team/new' \ curl --location 'http://0.0.0.0:4000/team/new' \
--header 'Authorization: Bearer sk-1234' \ --header 'Authorization: Bearer sk-1234' \
@ -7475,6 +7475,18 @@ async def new_team(
if data.team_id is None: if data.team_id is None:
data.team_id = str(uuid.uuid4()) data.team_id = str(uuid.uuid4())
else:
# Check if team_id exists already
_existing_team_id = await prisma_client.get_data(
team_id=data.team_id, table_name="team", query_type="find_unique"
)
if _existing_team_id is not None:
raise HTTPException(
status_code=400,
detail={
"error": f"Team id = {data.team_id} already exists. Please use a different team id."
},
)
if ( if (
user_api_key_dict.user_role is None user_api_key_dict.user_role is None