Spaces:
Paused
Paused
Update admin_routes.py
Browse files- admin_routes.py +33 -0
admin_routes.py
CHANGED
|
@@ -620,6 +620,39 @@ async def delete_version(
|
|
| 620 |
log(f"✅ Version {version_id} deleted for project {project_id} by {username}")
|
| 621 |
return {"success": True}
|
| 622 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 623 |
# ===================== API Endpoints =====================
|
| 624 |
@router.get("/apis")
|
| 625 |
async def list_apis(
|
|
|
|
| 620 |
log(f"✅ Version {version_id} deleted for project {project_id} by {username}")
|
| 621 |
return {"success": True}
|
| 622 |
|
| 623 |
+
@router.get("/projects/{project_name}/versions")
|
| 624 |
+
async def get_project_versions(
|
| 625 |
+
project_name: str,
|
| 626 |
+
username: str = Depends(verify_token)
|
| 627 |
+
):
|
| 628 |
+
"""Get all versions of a project for testing"""
|
| 629 |
+
cfg = ConfigProvider.get()
|
| 630 |
+
|
| 631 |
+
# Find project
|
| 632 |
+
project = next((p for p in cfg.projects if p.name == project_name), None)
|
| 633 |
+
if not project:
|
| 634 |
+
raise HTTPException(status_code=404, detail=f"Project '{project_name}' not found")
|
| 635 |
+
|
| 636 |
+
# Return versions with their status
|
| 637 |
+
versions = []
|
| 638 |
+
for v in project.versions:
|
| 639 |
+
if not getattr(v, 'deleted', False):
|
| 640 |
+
versions.append({
|
| 641 |
+
"version_number": v.id,
|
| 642 |
+
"caption": v.caption,
|
| 643 |
+
"published": v.published,
|
| 644 |
+
"description": getattr(v, 'description', ''),
|
| 645 |
+
"intent_count": len(v.intents),
|
| 646 |
+
"created_date": getattr(v, 'created_date', None),
|
| 647 |
+
"is_current": v.published # Published version is current
|
| 648 |
+
})
|
| 649 |
+
|
| 650 |
+
return {
|
| 651 |
+
"project_name": project_name,
|
| 652 |
+
"project_caption": project.caption,
|
| 653 |
+
"versions": versions
|
| 654 |
+
}
|
| 655 |
+
|
| 656 |
# ===================== API Endpoints =====================
|
| 657 |
@router.get("/apis")
|
| 658 |
async def list_apis(
|