Spaces:
Paused
Paused
dushyantsingh0 commited on
Commit ·
e58f87e
1
Parent(s): da377dd
backend stabilization
Browse files- api/v1/ai.py +1 -1
- api/v1/attachments.py +4 -4
- api/v1/dashboard.py +5 -5
- api/v1/escalations.py +6 -6
- api/v1/feedback.py +2 -2
- api/v1/kb.py +7 -7
- api/v1/kb_insights.py +3 -3
- api/v1/messages.py +4 -4
- api/v1/nexus.py +3 -3
- api/v1/nexus_stream.py +1 -1
- api/v1/notifications.py +2 -2
- api/v1/projects.py +3 -3
- api/v1/system.py +4 -4
- api/v1/tickets.py +11 -9
- api/v1/users.py +4 -4
- api/v1/workspace.py +2 -2
- main.py +1 -1
- schemas/ticket.py +2 -2
api/v1/ai.py
CHANGED
|
@@ -17,7 +17,7 @@ from langchain.schema import HumanMessage, SystemMessage
|
|
| 17 |
|
| 18 |
router = APIRouter()
|
| 19 |
|
| 20 |
-
@router.get("/trace/{ticket_id}", response_model=AITraceResponse, dependencies=[Depends(require_roles(ALL_SC_ROLES))])
|
| 21 |
async def get_ticket_ai_trace(
|
| 22 |
ticket_id: UUID,
|
| 23 |
db: AsyncSession = Depends(get_db),
|
|
|
|
| 17 |
|
| 18 |
router = APIRouter()
|
| 19 |
|
| 20 |
+
@router.get("/trace/{ticket_id}/", response_model=AITraceResponse, dependencies=[Depends(require_roles(ALL_SC_ROLES))])
|
| 21 |
async def get_ticket_ai_trace(
|
| 22 |
ticket_id: UUID,
|
| 23 |
db: AsyncSession = Depends(get_db),
|
api/v1/attachments.py
CHANGED
|
@@ -24,7 +24,7 @@ router = APIRouter()
|
|
| 24 |
# UPLOAD_DIR = Path("uploads")
|
| 25 |
# UPLOAD_DIR.mkdir(exist_ok=True)
|
| 26 |
|
| 27 |
-
@router.post("/{ticket_id}/attachments", response_model=AttachmentResponse, status_code=status.HTTP_201_CREATED)
|
| 28 |
async def upload_attachment(
|
| 29 |
ticket_id: uuid.UUID,
|
| 30 |
file: UploadFile = File(...),
|
|
@@ -70,7 +70,7 @@ async def upload_attachment(
|
|
| 70 |
await db.refresh(new_attachment)
|
| 71 |
return new_attachment
|
| 72 |
|
| 73 |
-
@router.get("/{ticket_id}/attachments", response_model=List[AttachmentResponse])
|
| 74 |
async def list_attachments(
|
| 75 |
ticket_id: uuid.UUID,
|
| 76 |
current_user: User = Depends(get_current_user),
|
|
@@ -104,7 +104,7 @@ async def list_attachments(
|
|
| 104 |
att_res = await db.execute(att_stmt)
|
| 105 |
return att_res.scalars().all()
|
| 106 |
|
| 107 |
-
@router.get("/attachments/{attachment_id}/download")
|
| 108 |
async def download_attachment(
|
| 109 |
attachment_id: uuid.UUID,
|
| 110 |
current_user: User = Depends(get_current_user),
|
|
@@ -145,7 +145,7 @@ async def download_attachment(
|
|
| 145 |
media_type=attachment.content_type
|
| 146 |
)
|
| 147 |
|
| 148 |
-
@router.delete("/attachments/{attachment_id}", status_code=status.HTTP_200_OK)
|
| 149 |
async def delete_attachment(
|
| 150 |
attachment_id: uuid.UUID,
|
| 151 |
current_user: User = Depends(get_current_user),
|
|
|
|
| 24 |
# UPLOAD_DIR = Path("uploads")
|
| 25 |
# UPLOAD_DIR.mkdir(exist_ok=True)
|
| 26 |
|
| 27 |
+
@router.post("/{ticket_id}/attachments/", response_model=AttachmentResponse, status_code=status.HTTP_201_CREATED)
|
| 28 |
async def upload_attachment(
|
| 29 |
ticket_id: uuid.UUID,
|
| 30 |
file: UploadFile = File(...),
|
|
|
|
| 70 |
await db.refresh(new_attachment)
|
| 71 |
return new_attachment
|
| 72 |
|
| 73 |
+
@router.get("/{ticket_id}/attachments/", response_model=List[AttachmentResponse])
|
| 74 |
async def list_attachments(
|
| 75 |
ticket_id: uuid.UUID,
|
| 76 |
current_user: User = Depends(get_current_user),
|
|
|
|
| 104 |
att_res = await db.execute(att_stmt)
|
| 105 |
return att_res.scalars().all()
|
| 106 |
|
| 107 |
+
@router.get("/attachments/{attachment_id}/download/")
|
| 108 |
async def download_attachment(
|
| 109 |
attachment_id: uuid.UUID,
|
| 110 |
current_user: User = Depends(get_current_user),
|
|
|
|
| 145 |
media_type=attachment.content_type
|
| 146 |
)
|
| 147 |
|
| 148 |
+
@router.delete("/attachments/{attachment_id}/", status_code=status.HTTP_200_OK)
|
| 149 |
async def delete_attachment(
|
| 150 |
attachment_id: uuid.UUID,
|
| 151 |
current_user: User = Depends(get_current_user),
|
api/v1/dashboard.py
CHANGED
|
@@ -19,7 +19,7 @@ from typing import Any, Dict, List, Optional, Union
|
|
| 19 |
|
| 20 |
router = APIRouter()
|
| 21 |
|
| 22 |
-
@router.get("/stats")
|
| 23 |
async def get_dashboard_stats(
|
| 24 |
workspace_id: str = None,
|
| 25 |
current_user: User = Depends(get_current_user),
|
|
@@ -141,7 +141,7 @@ async def get_dashboard_stats(
|
|
| 141 |
return response
|
| 142 |
|
| 143 |
|
| 144 |
-
@router.get("/my-tickets", response_model=List[Union[TicketInternalResponse, TicketResponse]])
|
| 145 |
async def get_my_tickets(
|
| 146 |
current_user: User = Depends(get_current_user),
|
| 147 |
db: AsyncSession = Depends(get_db)
|
|
@@ -171,7 +171,7 @@ async def get_my_tickets(
|
|
| 171 |
return [await sanitize_ticket_response(t, current_user, db) for t in tickets]
|
| 172 |
|
| 173 |
|
| 174 |
-
@router.get("/agent-queue", response_model=List[Union[TicketInternalResponse, TicketResponse]])
|
| 175 |
async def get_agent_queue(
|
| 176 |
workspace_id: str = None,
|
| 177 |
current_user: User = Depends(get_current_user),
|
|
@@ -218,7 +218,7 @@ async def get_agent_queue(
|
|
| 218 |
return [await sanitize_ticket_response(t, current_user, db) for t in tickets]
|
| 219 |
|
| 220 |
|
| 221 |
-
@router.get("/ai-insights")
|
| 222 |
async def get_ai_insights(
|
| 223 |
workspace_id: str = None,
|
| 224 |
current_user: User = Depends(get_current_user),
|
|
@@ -309,7 +309,7 @@ async def get_ai_insights(
|
|
| 309 |
]
|
| 310 |
}
|
| 311 |
|
| 312 |
-
@router.post("/refresh-global")
|
| 313 |
async def refresh_global_insights(
|
| 314 |
current_user: User = Depends(get_current_user),
|
| 315 |
arq_pool = Depends(get_arq_pool)
|
|
|
|
| 19 |
|
| 20 |
router = APIRouter()
|
| 21 |
|
| 22 |
+
@router.get("/stats/")
|
| 23 |
async def get_dashboard_stats(
|
| 24 |
workspace_id: str = None,
|
| 25 |
current_user: User = Depends(get_current_user),
|
|
|
|
| 141 |
return response
|
| 142 |
|
| 143 |
|
| 144 |
+
@router.get("/my-tickets/", response_model=List[Union[TicketInternalResponse, TicketResponse]])
|
| 145 |
async def get_my_tickets(
|
| 146 |
current_user: User = Depends(get_current_user),
|
| 147 |
db: AsyncSession = Depends(get_db)
|
|
|
|
| 171 |
return [await sanitize_ticket_response(t, current_user, db) for t in tickets]
|
| 172 |
|
| 173 |
|
| 174 |
+
@router.get("/agent-queue/", response_model=List[Union[TicketInternalResponse, TicketResponse]])
|
| 175 |
async def get_agent_queue(
|
| 176 |
workspace_id: str = None,
|
| 177 |
current_user: User = Depends(get_current_user),
|
|
|
|
| 218 |
return [await sanitize_ticket_response(t, current_user, db) for t in tickets]
|
| 219 |
|
| 220 |
|
| 221 |
+
@router.get("/ai-insights/")
|
| 222 |
async def get_ai_insights(
|
| 223 |
workspace_id: str = None,
|
| 224 |
current_user: User = Depends(get_current_user),
|
|
|
|
| 309 |
]
|
| 310 |
}
|
| 311 |
|
| 312 |
+
@router.post("/refresh-global/")
|
| 313 |
async def refresh_global_insights(
|
| 314 |
current_user: User = Depends(get_current_user),
|
| 315 |
arq_pool = Depends(get_arq_pool)
|
api/v1/escalations.py
CHANGED
|
@@ -17,7 +17,7 @@ from schemas.escalation import EscalationRuleCreate, EscalationRuleUpdate, Escal
|
|
| 17 |
|
| 18 |
router = APIRouter()
|
| 19 |
|
| 20 |
-
@router.post("/rules", response_model=EscalationRuleResponse, status_code=status.HTTP_201_CREATED, dependencies=[Depends(require_roles(WORKSPACE_ADMIN_ROLES))])
|
| 21 |
async def create_escalation_rule(
|
| 22 |
payload: EscalationRuleCreate,
|
| 23 |
current_user: User = Depends(get_current_user),
|
|
@@ -50,7 +50,7 @@ async def create_escalation_rule(
|
|
| 50 |
await db.refresh(new_rule)
|
| 51 |
return new_rule
|
| 52 |
|
| 53 |
-
@router.get("/rules", response_model=List[EscalationRuleResponse], dependencies=[Depends(require_roles(ALL_SC_ROLES))])
|
| 54 |
async def list_escalation_rules(
|
| 55 |
workspace_id: UUID = None,
|
| 56 |
current_user: User = Depends(get_current_user),
|
|
@@ -69,7 +69,7 @@ async def list_escalation_rules(
|
|
| 69 |
result = await db.execute(stmt)
|
| 70 |
return result.scalars().all()
|
| 71 |
|
| 72 |
-
@router.patch("/rules/{rule_id}", response_model=EscalationRuleResponse, dependencies=[Depends(require_roles(WORKSPACE_ADMIN_ROLES))])
|
| 73 |
async def update_escalation_rule(
|
| 74 |
rule_id: UUID,
|
| 75 |
payload: EscalationRuleUpdate,
|
|
@@ -95,7 +95,7 @@ async def update_escalation_rule(
|
|
| 95 |
await db.refresh(rule)
|
| 96 |
return rule
|
| 97 |
|
| 98 |
-
@router.delete("/rules/{rule_id}", status_code=status.HTTP_204_NO_CONTENT, dependencies=[Depends(require_roles(WORKSPACE_ADMIN_ROLES))])
|
| 99 |
async def delete_escalation_rule(
|
| 100 |
rule_id: UUID,
|
| 101 |
current_user: User = Depends(get_current_user),
|
|
@@ -116,7 +116,7 @@ async def delete_escalation_rule(
|
|
| 116 |
await db.commit()
|
| 117 |
return None
|
| 118 |
|
| 119 |
-
@router.get("/audit", response_model=List[AuditLogResponse], dependencies=[Depends(require_roles(ALL_SC_ROLES))])
|
| 120 |
async def view_escalation_audit(
|
| 121 |
skip: int = 0, limit: int = 100,
|
| 122 |
current_user: User = Depends(get_current_user),
|
|
@@ -133,7 +133,7 @@ async def view_escalation_audit(
|
|
| 133 |
result = await db.execute(stmt)
|
| 134 |
return result.scalars().all()
|
| 135 |
|
| 136 |
-
@router.get("/breaches", dependencies=[Depends(require_roles(ALL_SC_ROLES))])
|
| 137 |
async def list_active_breaches(
|
| 138 |
current_user: User = Depends(get_current_user),
|
| 139 |
db: AsyncSession = Depends(get_db)
|
|
|
|
| 17 |
|
| 18 |
router = APIRouter()
|
| 19 |
|
| 20 |
+
@router.post("/rules/", response_model=EscalationRuleResponse, status_code=status.HTTP_201_CREATED, dependencies=[Depends(require_roles(WORKSPACE_ADMIN_ROLES))])
|
| 21 |
async def create_escalation_rule(
|
| 22 |
payload: EscalationRuleCreate,
|
| 23 |
current_user: User = Depends(get_current_user),
|
|
|
|
| 50 |
await db.refresh(new_rule)
|
| 51 |
return new_rule
|
| 52 |
|
| 53 |
+
@router.get("/rules/", response_model=List[EscalationRuleResponse], dependencies=[Depends(require_roles(ALL_SC_ROLES))])
|
| 54 |
async def list_escalation_rules(
|
| 55 |
workspace_id: UUID = None,
|
| 56 |
current_user: User = Depends(get_current_user),
|
|
|
|
| 69 |
result = await db.execute(stmt)
|
| 70 |
return result.scalars().all()
|
| 71 |
|
| 72 |
+
@router.patch("/rules/{rule_id}/", response_model=EscalationRuleResponse, dependencies=[Depends(require_roles(WORKSPACE_ADMIN_ROLES))])
|
| 73 |
async def update_escalation_rule(
|
| 74 |
rule_id: UUID,
|
| 75 |
payload: EscalationRuleUpdate,
|
|
|
|
| 95 |
await db.refresh(rule)
|
| 96 |
return rule
|
| 97 |
|
| 98 |
+
@router.delete("/rules/{rule_id}/", status_code=status.HTTP_204_NO_CONTENT, dependencies=[Depends(require_roles(WORKSPACE_ADMIN_ROLES))])
|
| 99 |
async def delete_escalation_rule(
|
| 100 |
rule_id: UUID,
|
| 101 |
current_user: User = Depends(get_current_user),
|
|
|
|
| 116 |
await db.commit()
|
| 117 |
return None
|
| 118 |
|
| 119 |
+
@router.get("/audit/", response_model=List[AuditLogResponse], dependencies=[Depends(require_roles(ALL_SC_ROLES))])
|
| 120 |
async def view_escalation_audit(
|
| 121 |
skip: int = 0, limit: int = 100,
|
| 122 |
current_user: User = Depends(get_current_user),
|
|
|
|
| 133 |
result = await db.execute(stmt)
|
| 134 |
return result.scalars().all()
|
| 135 |
|
| 136 |
+
@router.get("/breaches/", dependencies=[Depends(require_roles(ALL_SC_ROLES))])
|
| 137 |
async def list_active_breaches(
|
| 138 |
current_user: User = Depends(get_current_user),
|
| 139 |
db: AsyncSession = Depends(get_db)
|
api/v1/feedback.py
CHANGED
|
@@ -17,7 +17,7 @@ from schemas.feedback import FeedbackCreate, FeedbackResponse
|
|
| 17 |
|
| 18 |
router = APIRouter()
|
| 19 |
|
| 20 |
-
@router.post("/{ticket_id}/feedback", response_model=FeedbackResponse, status_code=status.HTTP_201_CREATED)
|
| 21 |
async def submit_feedback(
|
| 22 |
ticket_id: uuid.UUID,
|
| 23 |
payload: FeedbackCreate,
|
|
@@ -59,7 +59,7 @@ async def submit_feedback(
|
|
| 59 |
await db.refresh(new_feedback)
|
| 60 |
return new_feedback
|
| 61 |
|
| 62 |
-
@router.get("/{ticket_id}/feedback", response_model=FeedbackResponse)
|
| 63 |
async def get_ticket_feedback(
|
| 64 |
ticket_id: uuid.UUID,
|
| 65 |
current_user: User = Depends(get_current_user),
|
|
|
|
| 17 |
|
| 18 |
router = APIRouter()
|
| 19 |
|
| 20 |
+
@router.post("/{ticket_id}/feedback/", response_model=FeedbackResponse, status_code=status.HTTP_201_CREATED)
|
| 21 |
async def submit_feedback(
|
| 22 |
ticket_id: uuid.UUID,
|
| 23 |
payload: FeedbackCreate,
|
|
|
|
| 59 |
await db.refresh(new_feedback)
|
| 60 |
return new_feedback
|
| 61 |
|
| 62 |
+
@router.get("/{ticket_id}/feedback/", response_model=FeedbackResponse)
|
| 63 |
async def get_ticket_feedback(
|
| 64 |
ticket_id: uuid.UUID,
|
| 65 |
current_user: User = Depends(get_current_user),
|
api/v1/kb.py
CHANGED
|
@@ -102,7 +102,7 @@ async def list_kb_articles(
|
|
| 102 |
result = await db.execute(stmt)
|
| 103 |
return result.scalars().all()
|
| 104 |
|
| 105 |
-
@router.get("/categories", response_model=List[str])
|
| 106 |
async def list_kb_categories(
|
| 107 |
workspace_id: Optional[str] = None,
|
| 108 |
current_user: User = Depends(get_current_user),
|
|
@@ -303,7 +303,7 @@ async def execute_multimodal_search(db: AsyncSession, q: str, current_user: User
|
|
| 303 |
|
| 304 |
return final_output
|
| 305 |
|
| 306 |
-
@router.get("/search", response_model=KBSearchResponse)
|
| 307 |
async def search_kb_articles(
|
| 308 |
q: str,
|
| 309 |
category: Optional[str] = None,
|
|
@@ -395,7 +395,7 @@ async def search_kb_articles(
|
|
| 395 |
|
| 396 |
return res_data
|
| 397 |
|
| 398 |
-
@router.get("/{article_id}", response_model=KBArticleResponse)
|
| 399 |
async def get_kb_article(
|
| 400 |
article_id: UUID,
|
| 401 |
current_user: User = Depends(get_current_user),
|
|
@@ -413,7 +413,7 @@ async def get_kb_article(
|
|
| 413 |
raise HTTPException(status_code=404, detail="Article not found")
|
| 414 |
return article
|
| 415 |
|
| 416 |
-
@router.patch("/{article_id}", response_model=KBArticleResponse, dependencies=[Depends(require_roles(ALL_SC_ROLES))])
|
| 417 |
async def update_kb_article(
|
| 418 |
article_id: UUID,
|
| 419 |
payload: KBArticleUpdate,
|
|
@@ -469,7 +469,7 @@ async def update_kb_article(
|
|
| 469 |
|
| 470 |
return article
|
| 471 |
|
| 472 |
-
@router.delete("/{article_id}", status_code=status.HTTP_200_OK, dependencies=[Depends(require_roles(ALL_SC_ROLES))])
|
| 473 |
async def delete_kb_article(
|
| 474 |
article_id: UUID,
|
| 475 |
current_user: User = Depends(get_current_user),
|
|
@@ -511,7 +511,7 @@ async def delete_kb_article(
|
|
| 511 |
logger.info(f"KB Article and children inactivated: {article_id} by user {current_user.id}")
|
| 512 |
return {"status": "deleted"}
|
| 513 |
|
| 514 |
-
@router.post("/bulk-publish", status_code=status.HTTP_200_OK, dependencies=[Depends(require_roles(ALL_SC_ROLES))])
|
| 515 |
async def bulk_publish_articles(
|
| 516 |
payload: KBBulkSyncRequest,
|
| 517 |
background_tasks: BackgroundTasks,
|
|
@@ -580,7 +580,7 @@ async def bulk_publish_articles(
|
|
| 580 |
logger.info(f"Bulk Sync & Publish (Isolated): {results['created']} created, {results['updated']} updated for workspace {current_user.workspace_id}")
|
| 581 |
return {"status": "success", "summary": results}
|
| 582 |
|
| 583 |
-
@router.post("/bulk-unpublish", status_code=status.HTTP_200_OK, dependencies=[Depends(require_roles(ALL_SC_ROLES))])
|
| 584 |
async def bulk_unpublish_articles(
|
| 585 |
payload: KBBulkActionRequest,
|
| 586 |
current_user: User = Depends(get_current_user),
|
|
|
|
| 102 |
result = await db.execute(stmt)
|
| 103 |
return result.scalars().all()
|
| 104 |
|
| 105 |
+
@router.get("/categories/", response_model=List[str])
|
| 106 |
async def list_kb_categories(
|
| 107 |
workspace_id: Optional[str] = None,
|
| 108 |
current_user: User = Depends(get_current_user),
|
|
|
|
| 303 |
|
| 304 |
return final_output
|
| 305 |
|
| 306 |
+
@router.get("/search/", response_model=KBSearchResponse)
|
| 307 |
async def search_kb_articles(
|
| 308 |
q: str,
|
| 309 |
category: Optional[str] = None,
|
|
|
|
| 395 |
|
| 396 |
return res_data
|
| 397 |
|
| 398 |
+
@router.get("/{article_id}/", response_model=KBArticleResponse)
|
| 399 |
async def get_kb_article(
|
| 400 |
article_id: UUID,
|
| 401 |
current_user: User = Depends(get_current_user),
|
|
|
|
| 413 |
raise HTTPException(status_code=404, detail="Article not found")
|
| 414 |
return article
|
| 415 |
|
| 416 |
+
@router.patch("/{article_id}/", response_model=KBArticleResponse, dependencies=[Depends(require_roles(ALL_SC_ROLES))])
|
| 417 |
async def update_kb_article(
|
| 418 |
article_id: UUID,
|
| 419 |
payload: KBArticleUpdate,
|
|
|
|
| 469 |
|
| 470 |
return article
|
| 471 |
|
| 472 |
+
@router.delete("/{article_id}/", status_code=status.HTTP_200_OK, dependencies=[Depends(require_roles(ALL_SC_ROLES))])
|
| 473 |
async def delete_kb_article(
|
| 474 |
article_id: UUID,
|
| 475 |
current_user: User = Depends(get_current_user),
|
|
|
|
| 511 |
logger.info(f"KB Article and children inactivated: {article_id} by user {current_user.id}")
|
| 512 |
return {"status": "deleted"}
|
| 513 |
|
| 514 |
+
@router.post("/bulk-publish/", status_code=status.HTTP_200_OK, dependencies=[Depends(require_roles(ALL_SC_ROLES))])
|
| 515 |
async def bulk_publish_articles(
|
| 516 |
payload: KBBulkSyncRequest,
|
| 517 |
background_tasks: BackgroundTasks,
|
|
|
|
| 580 |
logger.info(f"Bulk Sync & Publish (Isolated): {results['created']} created, {results['updated']} updated for workspace {current_user.workspace_id}")
|
| 581 |
return {"status": "success", "summary": results}
|
| 582 |
|
| 583 |
+
@router.post("/bulk-unpublish/", status_code=status.HTTP_200_OK, dependencies=[Depends(require_roles(ALL_SC_ROLES))])
|
| 584 |
async def bulk_unpublish_articles(
|
| 585 |
payload: KBBulkActionRequest,
|
| 586 |
current_user: User = Depends(get_current_user),
|
api/v1/kb_insights.py
CHANGED
|
@@ -33,7 +33,7 @@ async def list_knowledge_insights(
|
|
| 33 |
result = await db.execute(stmt)
|
| 34 |
return result.scalars().all()
|
| 35 |
|
| 36 |
-
@router.patch("/{insight_id}", response_model=KnowledgeInsightResponse)
|
| 37 |
async def update_insight(
|
| 38 |
insight_id: UUID,
|
| 39 |
payload: KnowledgeInsightUpdate,
|
|
@@ -58,7 +58,7 @@ async def update_insight(
|
|
| 58 |
await db.commit()
|
| 59 |
return insight
|
| 60 |
|
| 61 |
-
@router.post("/{insight_id}/apply", response_model=KBArticleResponse)
|
| 62 |
async def apply_knowledge_insight(
|
| 63 |
insight_id: UUID,
|
| 64 |
current_user: User = Depends(get_current_user),
|
|
@@ -116,7 +116,7 @@ async def apply_knowledge_insight(
|
|
| 116 |
logger.info(f"Insight {insight_id} APPLIED by user {current_user.id}. Article: {new_article.id}")
|
| 117 |
return new_article
|
| 118 |
|
| 119 |
-
@router.post("/{insight_id}/dismiss")
|
| 120 |
async def dismiss_insight(
|
| 121 |
insight_id: UUID,
|
| 122 |
current_user: User = Depends(get_current_user),
|
|
|
|
| 33 |
result = await db.execute(stmt)
|
| 34 |
return result.scalars().all()
|
| 35 |
|
| 36 |
+
@router.patch("/{insight_id}/", response_model=KnowledgeInsightResponse)
|
| 37 |
async def update_insight(
|
| 38 |
insight_id: UUID,
|
| 39 |
payload: KnowledgeInsightUpdate,
|
|
|
|
| 58 |
await db.commit()
|
| 59 |
return insight
|
| 60 |
|
| 61 |
+
@router.post("/{insight_id}/apply/", response_model=KBArticleResponse)
|
| 62 |
async def apply_knowledge_insight(
|
| 63 |
insight_id: UUID,
|
| 64 |
current_user: User = Depends(get_current_user),
|
|
|
|
| 116 |
logger.info(f"Insight {insight_id} APPLIED by user {current_user.id}. Article: {new_article.id}")
|
| 117 |
return new_article
|
| 118 |
|
| 119 |
+
@router.post("/{insight_id}/dismiss/")
|
| 120 |
async def dismiss_insight(
|
| 121 |
insight_id: UUID,
|
| 122 |
current_user: User = Depends(get_current_user),
|
api/v1/messages.py
CHANGED
|
@@ -60,7 +60,7 @@ async def sanitize_message_response(message: Message, db: AsyncSession) -> Messa
|
|
| 60 |
return message
|
| 61 |
|
| 62 |
|
| 63 |
-
@router.post("/{ticket_id}/messages", response_model=MessageResponse, status_code=status.HTTP_201_CREATED)
|
| 64 |
async def send_message(
|
| 65 |
ticket_id: UUID,
|
| 66 |
payload: MessageCreate,
|
|
@@ -142,7 +142,7 @@ async def send_message(
|
|
| 142 |
return await sanitize_message_response(new_message, db)
|
| 143 |
|
| 144 |
|
| 145 |
-
@router.patch("/{ticket_id}/messages/{message_id}", response_model=MessageResponse)
|
| 146 |
async def edit_message(
|
| 147 |
ticket_id: UUID,
|
| 148 |
message_id: UUID,
|
|
@@ -186,7 +186,7 @@ async def edit_message(
|
|
| 186 |
return await sanitize_message_response(message, db)
|
| 187 |
|
| 188 |
|
| 189 |
-
@router.delete("/{ticket_id}/messages/{message_id}", status_code=status.HTTP_204_NO_CONTENT, response_model=None, response_class=Response)
|
| 190 |
async def delete_message(
|
| 191 |
ticket_id: UUID,
|
| 192 |
message_id: UUID,
|
|
@@ -224,7 +224,7 @@ async def delete_message(
|
|
| 224 |
return None
|
| 225 |
|
| 226 |
|
| 227 |
-
@router.get("/{ticket_id}/messages", response_model=List[MessageResponse])
|
| 228 |
async def list_messages(
|
| 229 |
ticket_id: UUID,
|
| 230 |
current_user: User = Depends(get_current_user),
|
|
|
|
| 60 |
return message
|
| 61 |
|
| 62 |
|
| 63 |
+
@router.post("/{ticket_id}/messages/", response_model=MessageResponse, status_code=status.HTTP_201_CREATED)
|
| 64 |
async def send_message(
|
| 65 |
ticket_id: UUID,
|
| 66 |
payload: MessageCreate,
|
|
|
|
| 142 |
return await sanitize_message_response(new_message, db)
|
| 143 |
|
| 144 |
|
| 145 |
+
@router.patch("/{ticket_id}/messages/{message_id}/", response_model=MessageResponse)
|
| 146 |
async def edit_message(
|
| 147 |
ticket_id: UUID,
|
| 148 |
message_id: UUID,
|
|
|
|
| 186 |
return await sanitize_message_response(message, db)
|
| 187 |
|
| 188 |
|
| 189 |
+
@router.delete("/{ticket_id}/messages/{message_id}/", status_code=status.HTTP_204_NO_CONTENT, response_model=None, response_class=Response)
|
| 190 |
async def delete_message(
|
| 191 |
ticket_id: UUID,
|
| 192 |
message_id: UUID,
|
|
|
|
| 224 |
return None
|
| 225 |
|
| 226 |
|
| 227 |
+
@router.get("/{ticket_id}/messages/", response_model=List[MessageResponse])
|
| 228 |
async def list_messages(
|
| 229 |
ticket_id: UUID,
|
| 230 |
current_user: User = Depends(get_current_user),
|
api/v1/nexus.py
CHANGED
|
@@ -28,7 +28,7 @@ class NexusResponse(BaseModel):
|
|
| 28 |
answer: str
|
| 29 |
sources: List[str] = []
|
| 30 |
|
| 31 |
-
@router.post("/query", response_model=NexusResponse)
|
| 32 |
async def query_nexus_master(
|
| 33 |
payload: NexusQueryRequest,
|
| 34 |
current_user: User = Depends(get_current_user),
|
|
@@ -143,7 +143,7 @@ async def query_nexus_master(
|
|
| 143 |
detail="Nexus Master encountered an unexpected internal error. Please contact 3SC Support."
|
| 144 |
)
|
| 145 |
|
| 146 |
-
@router.get("/history", response_model=NexusHistoryForensicResponse, dependencies=[Depends(require_roles(ALL_SC_ROLES))])
|
| 147 |
async def get_nexus_history(
|
| 148 |
db: AsyncSession = Depends(get_db),
|
| 149 |
current_user: User = Depends(get_current_user)
|
|
@@ -167,7 +167,7 @@ async def get_nexus_history(
|
|
| 167 |
"count": len(interactions)
|
| 168 |
}
|
| 169 |
|
| 170 |
-
@router.get("/thread/{thread_id}", response_model=List[NexusInteractionResponse], dependencies=[Depends(require_roles(ALL_SC_ROLES))])
|
| 171 |
async def get_nexus_thread_audit(
|
| 172 |
thread_id: UUID,
|
| 173 |
db: AsyncSession = Depends(get_db),
|
|
|
|
| 28 |
answer: str
|
| 29 |
sources: List[str] = []
|
| 30 |
|
| 31 |
+
@router.post("/query/", response_model=NexusResponse)
|
| 32 |
async def query_nexus_master(
|
| 33 |
payload: NexusQueryRequest,
|
| 34 |
current_user: User = Depends(get_current_user),
|
|
|
|
| 143 |
detail="Nexus Master encountered an unexpected internal error. Please contact 3SC Support."
|
| 144 |
)
|
| 145 |
|
| 146 |
+
@router.get("/history/", response_model=NexusHistoryForensicResponse, dependencies=[Depends(require_roles(ALL_SC_ROLES))])
|
| 147 |
async def get_nexus_history(
|
| 148 |
db: AsyncSession = Depends(get_db),
|
| 149 |
current_user: User = Depends(get_current_user)
|
|
|
|
| 167 |
"count": len(interactions)
|
| 168 |
}
|
| 169 |
|
| 170 |
+
@router.get("/thread/{thread_id}/", response_model=List[NexusInteractionResponse], dependencies=[Depends(require_roles(ALL_SC_ROLES))])
|
| 171 |
async def get_nexus_thread_audit(
|
| 172 |
thread_id: UUID,
|
| 173 |
db: AsyncSession = Depends(get_db),
|
api/v1/nexus_stream.py
CHANGED
|
@@ -72,7 +72,7 @@ async def nexus_event_generator(app, initial_state, config):
|
|
| 72 |
# Yield error to frontend before closing stream
|
| 73 |
yield f"data: {json.dumps({'type': 'error', 'message': str(e)})}\n\n"
|
| 74 |
|
| 75 |
-
@router.post("/stream")
|
| 76 |
async def stream_nexus_master(
|
| 77 |
payload: NexusQueryRequest,
|
| 78 |
current_user: User = Depends(get_current_user),
|
|
|
|
| 72 |
# Yield error to frontend before closing stream
|
| 73 |
yield f"data: {json.dumps({'type': 'error', 'message': str(e)})}\n\n"
|
| 74 |
|
| 75 |
+
@router.post("/stream/")
|
| 76 |
async def stream_nexus_master(
|
| 77 |
payload: NexusQueryRequest,
|
| 78 |
current_user: User = Depends(get_current_user),
|
api/v1/notifications.py
CHANGED
|
@@ -27,7 +27,7 @@ async def list_notifications(
|
|
| 27 |
result = await db.execute(stmt)
|
| 28 |
return result.scalars().all()
|
| 29 |
|
| 30 |
-
@router.patch("/mark-read", status_code=status.HTTP_200_OK)
|
| 31 |
async def mark_notifications_read(
|
| 32 |
current_user: User = Depends(get_current_user),
|
| 33 |
db: AsyncSession = Depends(get_db)
|
|
@@ -42,7 +42,7 @@ async def mark_notifications_read(
|
|
| 42 |
await db.commit()
|
| 43 |
return {"status": "success"}
|
| 44 |
|
| 45 |
-
@router.delete("/{notification_id}", status_code=status.HTTP_200_OK)
|
| 46 |
async def delete_notification(
|
| 47 |
notification_id: UUID,
|
| 48 |
current_user: User = Depends(get_current_user),
|
|
|
|
| 27 |
result = await db.execute(stmt)
|
| 28 |
return result.scalars().all()
|
| 29 |
|
| 30 |
+
@router.patch("/mark-read/", status_code=status.HTTP_200_OK)
|
| 31 |
async def mark_notifications_read(
|
| 32 |
current_user: User = Depends(get_current_user),
|
| 33 |
db: AsyncSession = Depends(get_db)
|
|
|
|
| 42 |
await db.commit()
|
| 43 |
return {"status": "success"}
|
| 44 |
|
| 45 |
+
@router.delete("/{notification_id}/", status_code=status.HTTP_200_OK)
|
| 46 |
async def delete_notification(
|
| 47 |
notification_id: UUID,
|
| 48 |
current_user: User = Depends(get_current_user),
|
api/v1/projects.py
CHANGED
|
@@ -55,7 +55,7 @@ async def list_projects(
|
|
| 55 |
result = await db.execute(stmt)
|
| 56 |
return result.scalars().all()
|
| 57 |
|
| 58 |
-
@projects_router.get("/{project_id}", response_model=ProjectResponse)
|
| 59 |
async def get_project(
|
| 60 |
project_id: str,
|
| 61 |
current_user: User = Depends(get_current_user),
|
|
@@ -73,7 +73,7 @@ async def get_project(
|
|
| 73 |
raise HTTPException(status_code=404, detail="Project not found")
|
| 74 |
return project
|
| 75 |
|
| 76 |
-
@projects_router.patch("/{project_id}", response_model=ProjectResponse, dependencies=[Depends(require_roles(WORKSPACE_ADMIN_ROLES))])
|
| 77 |
async def update_project(
|
| 78 |
project_id: UUID,
|
| 79 |
payload: ProjectUpdate,
|
|
@@ -99,7 +99,7 @@ async def update_project(
|
|
| 99 |
await db.refresh(project)
|
| 100 |
return project
|
| 101 |
|
| 102 |
-
@projects_router.delete("/{project_id}", status_code=status.HTTP_200_OK, dependencies=[Depends(require_roles(WORKSPACE_ADMIN_ROLES))])
|
| 103 |
async def delete_project(
|
| 104 |
project_id: UUID,
|
| 105 |
current_user: User = Depends(get_current_user),
|
|
|
|
| 55 |
result = await db.execute(stmt)
|
| 56 |
return result.scalars().all()
|
| 57 |
|
| 58 |
+
@projects_router.get("/{project_id}/", response_model=ProjectResponse)
|
| 59 |
async def get_project(
|
| 60 |
project_id: str,
|
| 61 |
current_user: User = Depends(get_current_user),
|
|
|
|
| 73 |
raise HTTPException(status_code=404, detail="Project not found")
|
| 74 |
return project
|
| 75 |
|
| 76 |
+
@projects_router.patch("/{project_id}/", response_model=ProjectResponse, dependencies=[Depends(require_roles(WORKSPACE_ADMIN_ROLES))])
|
| 77 |
async def update_project(
|
| 78 |
project_id: UUID,
|
| 79 |
payload: ProjectUpdate,
|
|
|
|
| 99 |
await db.refresh(project)
|
| 100 |
return project
|
| 101 |
|
| 102 |
+
@projects_router.delete("/{project_id}/", status_code=status.HTTP_200_OK, dependencies=[Depends(require_roles(WORKSPACE_ADMIN_ROLES))])
|
| 103 |
async def delete_project(
|
| 104 |
project_id: UUID,
|
| 105 |
current_user: User = Depends(get_current_user),
|
api/v1/system.py
CHANGED
|
@@ -18,7 +18,7 @@ from arq.connections import ArqRedis
|
|
| 18 |
router = APIRouter()
|
| 19 |
settings = get_settings()
|
| 20 |
|
| 21 |
-
@router.get("/status", dependencies=[Depends(get_current_staff_user)])
|
| 22 |
async def get_system_status(
|
| 23 |
db: AsyncSession = Depends(get_db),
|
| 24 |
arq_pool: ArqRedis = Depends(get_arq_pool)
|
|
@@ -72,7 +72,7 @@ from typing import Any, List, Dict, Optional
|
|
| 72 |
|
| 73 |
from core.deps import get_db, get_current_staff_user, get_arq_pool
|
| 74 |
...
|
| 75 |
-
@router.get("/workflows", response_model=List[AIWorkflowRead], dependencies=[Depends(get_current_staff_user)])
|
| 76 |
async def get_recent_workflows(
|
| 77 |
db: AsyncSession = Depends(get_db),
|
| 78 |
ticket_id: Optional[UUID] = None,
|
|
@@ -92,7 +92,7 @@ async def get_recent_workflows(
|
|
| 92 |
result = await db.execute(stmt)
|
| 93 |
return result.scalars().all()
|
| 94 |
|
| 95 |
-
@router.get("/interactions", response_model=List[AIInteractionRead], dependencies=[Depends(get_current_staff_user)])
|
| 96 |
async def get_recent_interactions(
|
| 97 |
db: AsyncSession = Depends(get_db),
|
| 98 |
ticket_id: Optional[UUID] = None,
|
|
@@ -112,7 +112,7 @@ async def get_recent_interactions(
|
|
| 112 |
result = await db.execute(stmt)
|
| 113 |
return result.scalars().all()
|
| 114 |
|
| 115 |
-
@router.get("/history", response_model=List[MetaInfraHealthRead], dependencies=[Depends(get_current_staff_user)])
|
| 116 |
async def get_performance_history(
|
| 117 |
db: AsyncSession = Depends(get_db)
|
| 118 |
) -> List[MetaInfraHealth]:
|
|
|
|
| 18 |
router = APIRouter()
|
| 19 |
settings = get_settings()
|
| 20 |
|
| 21 |
+
@router.get("/status/", dependencies=[Depends(get_current_staff_user)])
|
| 22 |
async def get_system_status(
|
| 23 |
db: AsyncSession = Depends(get_db),
|
| 24 |
arq_pool: ArqRedis = Depends(get_arq_pool)
|
|
|
|
| 72 |
|
| 73 |
from core.deps import get_db, get_current_staff_user, get_arq_pool
|
| 74 |
...
|
| 75 |
+
@router.get("/workflows/", response_model=List[AIWorkflowRead], dependencies=[Depends(get_current_staff_user)])
|
| 76 |
async def get_recent_workflows(
|
| 77 |
db: AsyncSession = Depends(get_db),
|
| 78 |
ticket_id: Optional[UUID] = None,
|
|
|
|
| 92 |
result = await db.execute(stmt)
|
| 93 |
return result.scalars().all()
|
| 94 |
|
| 95 |
+
@router.get("/interactions/", response_model=List[AIInteractionRead], dependencies=[Depends(get_current_staff_user)])
|
| 96 |
async def get_recent_interactions(
|
| 97 |
db: AsyncSession = Depends(get_db),
|
| 98 |
ticket_id: Optional[UUID] = None,
|
|
|
|
| 112 |
result = await db.execute(stmt)
|
| 113 |
return result.scalars().all()
|
| 114 |
|
| 115 |
+
@router.get("/history/", response_model=List[MetaInfraHealthRead], dependencies=[Depends(get_current_staff_user)])
|
| 116 |
async def get_performance_history(
|
| 117 |
db: AsyncSession = Depends(get_db)
|
| 118 |
) -> List[MetaInfraHealth]:
|
api/v1/tickets.py
CHANGED
|
@@ -94,7 +94,7 @@ async def sanitize_ticket_response(
|
|
| 94 |
|
| 95 |
# 5. Escalation Lead Lookup (Optimized)
|
| 96 |
setattr(ticket, "escalated_to_name", lead_name)
|
| 97 |
-
if ticket.is_escalated and
|
| 98 |
from models.user_workspace import UserWorkspace
|
| 99 |
stmt = select(User.full_name).join(UserWorkspace).where(
|
| 100 |
UserWorkspace.workspace_id == ticket.workspace_id,
|
|
@@ -268,7 +268,7 @@ async def create_ticket(
|
|
| 268 |
|
| 269 |
return await sanitize_ticket_response(new_ticket, current_user, db)
|
| 270 |
|
| 271 |
-
@router.get("/search", response_model=TicketSearchResponse, dependencies=[Depends(require_roles(ALL_SC_ROLES + ALL_CUSTOMER_ROLES))])
|
| 272 |
async def search_tickets(
|
| 273 |
q: str,
|
| 274 |
project_id: Optional[UUID] = None,
|
|
@@ -592,7 +592,7 @@ async def list_tickets(
|
|
| 592 |
for t in tickets
|
| 593 |
]
|
| 594 |
|
| 595 |
-
@router.get("/{ticket_id}", response_model=Union[TicketInternalResponse, TicketResponse])
|
| 596 |
async def get_ticket(
|
| 597 |
ticket_id: UUID,
|
| 598 |
current_user: User = Depends(get_current_user),
|
|
@@ -630,7 +630,7 @@ async def get_ticket(
|
|
| 630 |
raise HTTPException(status_code=404, detail="Ticket not found or access denied")
|
| 631 |
return await sanitize_ticket_response(ticket, current_user, db)
|
| 632 |
|
| 633 |
-
@router.patch("/{ticket_id}", response_model=Union[TicketInternalResponse, TicketResponse])
|
| 634 |
async def update_ticket(
|
| 635 |
ticket_id: UUID,
|
| 636 |
payload: TicketUpdate,
|
|
@@ -648,7 +648,8 @@ async def update_ticket(
|
|
| 648 |
.options(
|
| 649 |
joinedload(Ticket.creator),
|
| 650 |
joinedload(Ticket.assignee),
|
| 651 |
-
joinedload(Ticket.resolver)
|
|
|
|
| 652 |
)
|
| 653 |
.where(
|
| 654 |
Ticket.id == ticket_id,
|
|
@@ -776,7 +777,7 @@ async def update_ticket(
|
|
| 776 |
|
| 777 |
return await sanitize_ticket_response(ticket, current_user, db)
|
| 778 |
|
| 779 |
-
@router.delete("/{ticket_id}", status_code=status.HTTP_200_OK)
|
| 780 |
async def delete_ticket(
|
| 781 |
ticket_id: UUID,
|
| 782 |
current_user: User = Depends(get_current_user),
|
|
@@ -827,7 +828,7 @@ async def delete_ticket(
|
|
| 827 |
logger.info(f"Ticket soft-deleted: {ticket_id} by user {current_user.id}")
|
| 828 |
return {"status": "deleted"}
|
| 829 |
|
| 830 |
-
@router.post("/{ticket_id}/reprocess", status_code=status.HTTP_202_ACCEPTED)
|
| 831 |
async def reprocess_ticket_ai(
|
| 832 |
ticket_id: UUID,
|
| 833 |
force_reroute: bool = False,
|
|
@@ -897,7 +898,7 @@ async def reprocess_ticket_ai(
|
|
| 897 |
"ticket_id": str(ticket.id)
|
| 898 |
}
|
| 899 |
|
| 900 |
-
@router.post("/{ticket_id}/escalate", response_model=TicketResponse)
|
| 901 |
async def escalate_ticket(
|
| 902 |
ticket_id: UUID,
|
| 903 |
current_user: User = Depends(get_current_user),
|
|
@@ -910,7 +911,8 @@ async def escalate_ticket(
|
|
| 910 |
.options(
|
| 911 |
joinedload(Ticket.creator),
|
| 912 |
joinedload(Ticket.assignee),
|
| 913 |
-
joinedload(Ticket.resolver)
|
|
|
|
| 914 |
)
|
| 915 |
.where(
|
| 916 |
Ticket.id == ticket_id,
|
|
|
|
| 94 |
|
| 95 |
# 5. Escalation Lead Lookup (Optimized)
|
| 96 |
setattr(ticket, "escalated_to_name", lead_name)
|
| 97 |
+
if ticket.is_escalated and not lead_name:
|
| 98 |
from models.user_workspace import UserWorkspace
|
| 99 |
stmt = select(User.full_name).join(UserWorkspace).where(
|
| 100 |
UserWorkspace.workspace_id == ticket.workspace_id,
|
|
|
|
| 268 |
|
| 269 |
return await sanitize_ticket_response(new_ticket, current_user, db)
|
| 270 |
|
| 271 |
+
@router.get("/search/", response_model=TicketSearchResponse, dependencies=[Depends(require_roles(ALL_SC_ROLES + ALL_CUSTOMER_ROLES))])
|
| 272 |
async def search_tickets(
|
| 273 |
q: str,
|
| 274 |
project_id: Optional[UUID] = None,
|
|
|
|
| 592 |
for t in tickets
|
| 593 |
]
|
| 594 |
|
| 595 |
+
@router.get("/{ticket_id}/", response_model=Union[TicketInternalResponse, TicketResponse])
|
| 596 |
async def get_ticket(
|
| 597 |
ticket_id: UUID,
|
| 598 |
current_user: User = Depends(get_current_user),
|
|
|
|
| 630 |
raise HTTPException(status_code=404, detail="Ticket not found or access denied")
|
| 631 |
return await sanitize_ticket_response(ticket, current_user, db)
|
| 632 |
|
| 633 |
+
@router.patch("/{ticket_id}/", response_model=Union[TicketInternalResponse, TicketResponse])
|
| 634 |
async def update_ticket(
|
| 635 |
ticket_id: UUID,
|
| 636 |
payload: TicketUpdate,
|
|
|
|
| 648 |
.options(
|
| 649 |
joinedload(Ticket.creator),
|
| 650 |
joinedload(Ticket.assignee),
|
| 651 |
+
joinedload(Ticket.resolver),
|
| 652 |
+
joinedload(Ticket.feedback)
|
| 653 |
)
|
| 654 |
.where(
|
| 655 |
Ticket.id == ticket_id,
|
|
|
|
| 777 |
|
| 778 |
return await sanitize_ticket_response(ticket, current_user, db)
|
| 779 |
|
| 780 |
+
@router.delete("/{ticket_id}/", status_code=status.HTTP_200_OK)
|
| 781 |
async def delete_ticket(
|
| 782 |
ticket_id: UUID,
|
| 783 |
current_user: User = Depends(get_current_user),
|
|
|
|
| 828 |
logger.info(f"Ticket soft-deleted: {ticket_id} by user {current_user.id}")
|
| 829 |
return {"status": "deleted"}
|
| 830 |
|
| 831 |
+
@router.post("/{ticket_id}/reprocess/", status_code=status.HTTP_202_ACCEPTED)
|
| 832 |
async def reprocess_ticket_ai(
|
| 833 |
ticket_id: UUID,
|
| 834 |
force_reroute: bool = False,
|
|
|
|
| 898 |
"ticket_id": str(ticket.id)
|
| 899 |
}
|
| 900 |
|
| 901 |
+
@router.post("/{ticket_id}/escalate/", response_model=TicketResponse)
|
| 902 |
async def escalate_ticket(
|
| 903 |
ticket_id: UUID,
|
| 904 |
current_user: User = Depends(get_current_user),
|
|
|
|
| 911 |
.options(
|
| 912 |
joinedload(Ticket.creator),
|
| 913 |
joinedload(Ticket.assignee),
|
| 914 |
+
joinedload(Ticket.resolver),
|
| 915 |
+
joinedload(Ticket.feedback)
|
| 916 |
)
|
| 917 |
.where(
|
| 918 |
Ticket.id == ticket_id,
|
api/v1/users.py
CHANGED
|
@@ -79,11 +79,11 @@ async def create_workspace_user(
|
|
| 79 |
logger.info(f"User created: {new_user.email} (Role: {payload.role}) in workspace {current_user.workspace_id}")
|
| 80 |
return new_user
|
| 81 |
|
| 82 |
-
@router.get("/me", response_model=UserResponse)
|
| 83 |
async def read_user_me(current_user: User = Depends(get_current_user)) -> Any:
|
| 84 |
return current_user
|
| 85 |
|
| 86 |
-
@router.patch("/me", response_model=UserResponse)
|
| 87 |
async def update_user_me(
|
| 88 |
payload: UserUpdate,
|
| 89 |
current_user: User = Depends(get_current_user),
|
|
@@ -153,7 +153,7 @@ async def list_users(
|
|
| 153 |
|
| 154 |
return users
|
| 155 |
|
| 156 |
-
@router.delete("/{user_id}", status_code=status.HTTP_200_OK, dependencies=[Depends(require_roles(WORKSPACE_ADMIN_ROLES))])
|
| 157 |
async def deactivate_user_v3(
|
| 158 |
user_id: str,
|
| 159 |
current_user: User = Depends(get_current_user),
|
|
@@ -176,7 +176,7 @@ async def deactivate_user_v3(
|
|
| 176 |
await db.commit()
|
| 177 |
logger.info(f"User deactivated/soft-deleted: {user_id} by admin {current_user.id}")
|
| 178 |
return {"status": "deleted"}
|
| 179 |
-
@router.patch("/{user_id}", response_model=UserResponse, dependencies=[Depends(require_roles(WORKSPACE_ADMIN_ROLES))])
|
| 180 |
async def update_user_admin(
|
| 181 |
user_id: str,
|
| 182 |
payload: UserAdminUpdate,
|
|
|
|
| 79 |
logger.info(f"User created: {new_user.email} (Role: {payload.role}) in workspace {current_user.workspace_id}")
|
| 80 |
return new_user
|
| 81 |
|
| 82 |
+
@router.get("/me/", response_model=UserResponse)
|
| 83 |
async def read_user_me(current_user: User = Depends(get_current_user)) -> Any:
|
| 84 |
return current_user
|
| 85 |
|
| 86 |
+
@router.patch("/me/", response_model=UserResponse)
|
| 87 |
async def update_user_me(
|
| 88 |
payload: UserUpdate,
|
| 89 |
current_user: User = Depends(get_current_user),
|
|
|
|
| 153 |
|
| 154 |
return users
|
| 155 |
|
| 156 |
+
@router.delete("/{user_id}/", status_code=status.HTTP_200_OK, dependencies=[Depends(require_roles(WORKSPACE_ADMIN_ROLES))])
|
| 157 |
async def deactivate_user_v3(
|
| 158 |
user_id: str,
|
| 159 |
current_user: User = Depends(get_current_user),
|
|
|
|
| 176 |
await db.commit()
|
| 177 |
logger.info(f"User deactivated/soft-deleted: {user_id} by admin {current_user.id}")
|
| 178 |
return {"status": "deleted"}
|
| 179 |
+
@router.patch("/{user_id}/", response_model=UserResponse, dependencies=[Depends(require_roles(WORKSPACE_ADMIN_ROLES))])
|
| 180 |
async def update_user_admin(
|
| 181 |
user_id: str,
|
| 182 |
payload: UserAdminUpdate,
|
api/v1/workspace.py
CHANGED
|
@@ -11,7 +11,7 @@ from schemas.workspace import WorkspaceUpdate, WorkspaceResponse, WorkspaceWithR
|
|
| 11 |
|
| 12 |
router = APIRouter()
|
| 13 |
|
| 14 |
-
@router.get("/list", response_model=List[WorkspaceWithRole])
|
| 15 |
async def list_available_workspaces(
|
| 16 |
current_user: User = Depends(get_current_user),
|
| 17 |
db: AsyncSession = Depends(get_db)
|
|
@@ -95,7 +95,7 @@ async def update_workspace(
|
|
| 95 |
await db.refresh(workspace)
|
| 96 |
return workspace
|
| 97 |
|
| 98 |
-
@router.get("/branding")
|
| 99 |
async def get_workspace_branding(
|
| 100 |
current_user: User = Depends(get_current_user),
|
| 101 |
db: AsyncSession = Depends(get_db)
|
|
|
|
| 11 |
|
| 12 |
router = APIRouter()
|
| 13 |
|
| 14 |
+
@router.get("/list/", response_model=List[WorkspaceWithRole])
|
| 15 |
async def list_available_workspaces(
|
| 16 |
current_user: User = Depends(get_current_user),
|
| 17 |
db: AsyncSession = Depends(get_db)
|
|
|
|
| 95 |
await db.refresh(workspace)
|
| 96 |
return workspace
|
| 97 |
|
| 98 |
+
@router.get("/branding/")
|
| 99 |
async def get_workspace_branding(
|
| 100 |
current_user: User = Depends(get_current_user),
|
| 101 |
db: AsyncSession = Depends(get_db)
|
main.py
CHANGED
|
@@ -128,6 +128,6 @@ app.include_router(nexus_stream.router, prefix=f"{settings.API_V1_STR}/nexus", t
|
|
| 128 |
app.include_router(system.router, prefix=f"{settings.API_V1_STR}/system", tags=["System Diagnostics"])
|
| 129 |
app.include_router(websockets.router, tags=["websockets"])
|
| 130 |
|
| 131 |
-
@app.get("/health", tags=["System"])
|
| 132 |
def health_check():
|
| 133 |
return {"status": "ok"}
|
|
|
|
| 128 |
app.include_router(system.router, prefix=f"{settings.API_V1_STR}/system", tags=["System Diagnostics"])
|
| 129 |
app.include_router(websockets.router, tags=["websockets"])
|
| 130 |
|
| 131 |
+
@app.get("/health/", tags=["System"])
|
| 132 |
def health_check():
|
| 133 |
return {"status": "ok"}
|
schemas/ticket.py
CHANGED
|
@@ -53,6 +53,8 @@ class TicketResponse(TicketBase):
|
|
| 53 |
created_at: datetime
|
| 54 |
updated_at: datetime
|
| 55 |
is_mine: bool = False
|
|
|
|
|
|
|
| 56 |
|
| 57 |
model_config = ConfigDict(from_attributes=True)
|
| 58 |
|
|
@@ -64,11 +66,9 @@ class TicketInternalResponse(TicketResponse):
|
|
| 64 |
assigned_to: Optional[UUID] = None
|
| 65 |
resolved_by: Optional[UUID] = None
|
| 66 |
escalated_to_id: Optional[UUID] = None
|
| 67 |
-
escalated_to_name: Optional[str] = None
|
| 68 |
duplicate_of_id: Optional[UUID] = None
|
| 69 |
estimated_effort_hours: Optional[Union[Dict[str, Any], float, int]] = None
|
| 70 |
ai_metadata: Optional[Dict[str, Any]] = None
|
| 71 |
-
is_escalated: Optional[datetime] = None
|
| 72 |
|
| 73 |
|
| 74 |
class TicketSearchResult(BaseModel):
|
|
|
|
| 53 |
created_at: datetime
|
| 54 |
updated_at: datetime
|
| 55 |
is_mine: bool = False
|
| 56 |
+
is_escalated: Optional[datetime] = None
|
| 57 |
+
escalated_to_name: Optional[str] = None
|
| 58 |
|
| 59 |
model_config = ConfigDict(from_attributes=True)
|
| 60 |
|
|
|
|
| 66 |
assigned_to: Optional[UUID] = None
|
| 67 |
resolved_by: Optional[UUID] = None
|
| 68 |
escalated_to_id: Optional[UUID] = None
|
|
|
|
| 69 |
duplicate_of_id: Optional[UUID] = None
|
| 70 |
estimated_effort_hours: Optional[Union[Dict[str, Any], float, int]] = None
|
| 71 |
ai_metadata: Optional[Dict[str, Any]] = None
|
|
|
|
| 72 |
|
| 73 |
|
| 74 |
class TicketSearchResult(BaseModel):
|