feat/enh: group export endpoint

This commit is contained in:
Timothy Jaeryang Baek 2025-11-27 04:44:01 -05:00
parent 28659f6af5
commit 09b6ea38c5

View file

@ -106,6 +106,32 @@ async def get_group_by_id(id: str, user=Depends(get_admin_user)):
) )
############################
# ExportGroupById
############################
class GroupExportResponse(GroupResponse):
user_ids: list[str] = []
pass
@router.get("/id/{id}/export", response_model=Optional[GroupExportResponse])
async def export_group_by_id(id: str, user=Depends(get_admin_user)):
group = Groups.get_group_by_id(id)
if group:
return GroupExportResponse(
**group.model_dump(),
member_count=Groups.get_group_member_count_by_id(group.id),
user_ids=Groups.get_group_user_ids_by_id(group.id),
)
else:
raise HTTPException(
status_code=status.HTTP_401_UNAUTHORIZED,
detail=ERROR_MESSAGES.NOT_FOUND,
)
############################ ############################
# UpdateGroupById # UpdateGroupById
############################ ############################