MCPcopy Create free account
hub / github.com/AgentOps-AI/agentops / delete_org

Function delete_org

app/api/agentops/opsboard/views/orgs.py:823–847  ·  view source on GitHub ↗

Delete an organization. User must be the owner. Organization cannot be deleted if it still contains projects.

(
    *,
    request: Request,
    org_id: str,
    orm: Session = Depends(get_orm_session),
)

Source from the content-addressed store, hash-verified

821
822
823def delete_org(
824 *,
825 request: Request,
826 org_id: str,
827 orm: Session = Depends(get_orm_session),
828) -> StatusResponse:
829 """
830 Delete an organization. User must be the owner.
831 Organization cannot be deleted if it still contains projects.
832 """
833 org: Optional[OrgModel] = OrgModel.get_by_id(orm, org_id)
834
835 if not org or not org.is_user_owner(request.state.session.user_id):
836 raise HTTPException(status_code=403, detail="Organization cannot be deleted")
837
838 if org.projects:
839 raise HTTPException(
840 status_code=400,
841 detail="Organization cannot be deleted while it still contains projects",
842 )
843
844 orm.delete(org)
845 orm.commit()
846
847 return StatusResponse(message="Organization deleted")
848
849
850class UpdateMemberLicensesBody(pydantic.BaseModel):

Callers 3

test_delete_orgFunction · 0.90

Calls 4

is_user_ownerMethod · 0.80
StatusResponseClass · 0.50
get_by_idMethod · 0.45
deleteMethod · 0.45

Tested by 3

test_delete_orgFunction · 0.72

Used in the wild real call sites across dependent graphs

searching dependent graphs…