New enterprise feature

This commit is contained in:
Urtzi Alfaro
2025-11-30 09:12:40 +01:00
parent f9d0eec6ec
commit 972db02f6d
176 changed files with 19741 additions and 1361 deletions

View File

@@ -38,6 +38,11 @@ async def get_tenant_members(request: Request, tenant_id: str = Path(...)):
"""Get tenant members"""
return await _proxy_to_tenant_service(request, f"/api/v1/tenants/{tenant_id}/members")
@router.get("/{tenant_id}/hierarchy")
async def get_tenant_hierarchy(request: Request, tenant_id: str = Path(...)):
"""Get tenant hierarchy information"""
return await _proxy_to_tenant_service(request, f"/api/v1/tenants/{tenant_id}/hierarchy")
@router.get("/{tenant_id}/my-access")
async def get_tenant_my_access(request: Request, tenant_id: str = Path(...)):
"""Get current user's access level for a tenant"""
@@ -341,6 +346,12 @@ async def proxy_tenant_production(request: Request, tenant_id: str = Path(...),
# TENANT-SCOPED ORCHESTRATOR SERVICE ENDPOINTS
# ================================================================
@router.api_route("/{tenant_id}/enterprise/{path:path}", methods=["GET", "POST", "PUT", "DELETE", "OPTIONS"])
async def proxy_tenant_enterprise(request: Request, tenant_id: str = Path(...), path: str = ""):
"""Proxy tenant enterprise dashboard requests to orchestrator service"""
target_path = f"/api/v1/tenants/{tenant_id}/enterprise/{path}".rstrip("/")
return await _proxy_to_orchestrator_service(request, target_path, tenant_id=tenant_id)
@router.api_route("/{tenant_id}/orchestrator/{path:path}", methods=["GET", "POST", "PUT", "DELETE", "OPTIONS"])
async def proxy_tenant_orchestrator(request: Request, tenant_id: str = Path(...), path: str = ""):
"""Proxy tenant orchestrator requests to orchestrator service"""
@@ -403,6 +414,32 @@ async def proxy_tenant_deliveries(request: Request, tenant_id: str = Path(...),
target_path = f"/api/v1/tenants/{tenant_id}/deliveries{path}".rstrip("/")
return await _proxy_to_suppliers_service(request, target_path, tenant_id=tenant_id)
# ================================================================
# TENANT-SCOPED LOCATIONS ENDPOINTS
# ================================================================
@router.api_route("/{tenant_id}/locations", methods=["GET", "POST", "PUT", "DELETE", "OPTIONS"])
async def proxy_tenant_locations_base(request: Request, tenant_id: str = Path(...)):
"""Proxy tenant locations requests to tenant service (base path)"""
target_path = f"/api/v1/tenants/{tenant_id}/locations"
return await _proxy_to_tenant_service(request, target_path)
@router.api_route("/{tenant_id}/locations/{path:path}", methods=["GET", "POST", "PUT", "DELETE", "OPTIONS"])
async def proxy_tenant_locations_with_path(request: Request, tenant_id: str = Path(...), path: str = ""):
"""Proxy tenant locations requests to tenant service (with additional path)"""
target_path = f"/api/v1/tenants/{tenant_id}/locations/{path}".rstrip("/")
return await _proxy_to_tenant_service(request, target_path)
# ================================================================
# TENANT-SCOPED DISTRIBUTION SERVICE ENDPOINTS
# ================================================================
@router.api_route("/{tenant_id}/distribution/{path:path}", methods=["GET", "POST", "PUT", "DELETE", "OPTIONS"])
async def proxy_tenant_distribution(request: Request, tenant_id: str = Path(...), path: str = ""):
"""Proxy tenant distribution requests to distribution service"""
target_path = f"/api/v1/tenants/{tenant_id}/distribution/{path}".rstrip("/")
return await _proxy_to_distribution_service(request, target_path, tenant_id=tenant_id)
# ================================================================
# TENANT-SCOPED RECIPES SERVICE ENDPOINTS
# ================================================================
@@ -497,6 +534,10 @@ async def _proxy_to_ai_insights_service(request: Request, target_path: str, tena
"""Proxy request to AI insights service"""
return await _proxy_request(request, target_path, settings.AI_INSIGHTS_SERVICE_URL, tenant_id=tenant_id)
async def _proxy_to_distribution_service(request: Request, target_path: str, tenant_id: str = None):
"""Proxy request to distribution service"""
return await _proxy_request(request, target_path, settings.DISTRIBUTION_SERVICE_URL, tenant_id=tenant_id)
async def _proxy_request(request: Request, target_path: str, service_url: str, tenant_id: str = None):
"""Generic proxy function with enhanced error handling"""