REFACTOR API gateway
This commit is contained in:
@@ -3,10 +3,11 @@
|
||||
Tenant API endpoints
|
||||
"""
|
||||
|
||||
from fastapi import APIRouter, Depends, HTTPException, status, Request
|
||||
from fastapi import APIRouter, Depends, HTTPException, status, Path
|
||||
from sqlalchemy.ext.asyncio import AsyncSession
|
||||
from typing import List, Dict, Any
|
||||
import structlog
|
||||
from uuid import UUID
|
||||
|
||||
from app.core.database import get_db
|
||||
from app.schemas.tenants import (
|
||||
@@ -45,8 +46,8 @@ async def register_bakery(
|
||||
|
||||
@router.get("/tenants/{tenant_id}/access/{user_id}", response_model=TenantAccessResponse)
|
||||
async def verify_tenant_access(
|
||||
tenant_id: str,
|
||||
user_id: str,
|
||||
tenant_id: UUID = Path(..., description="Tenant ID"),
|
||||
db: AsyncSession = Depends(get_db)
|
||||
):
|
||||
"""Verify if user has access to tenant - Called by Gateway"""
|
||||
@@ -62,7 +63,7 @@ async def verify_tenant_access(
|
||||
detail="Access verification failed"
|
||||
)
|
||||
|
||||
@router.get("/users/{user_id}/tenants", response_model=List[TenantResponse])
|
||||
@router.get("/tenants/users/{user_id}", response_model=List[TenantResponse])
|
||||
async def get_user_tenants(
|
||||
user_id: str,
|
||||
current_user: Dict[str, Any] = Depends(get_current_user_dep),
|
||||
@@ -89,7 +90,7 @@ async def get_user_tenants(
|
||||
|
||||
@router.get("/tenants/{tenant_id}", response_model=TenantResponse)
|
||||
async def get_tenant(
|
||||
tenant_id: str,
|
||||
tenant_id: UUID = Path(..., description="Tenant ID"),
|
||||
current_user: Dict[str, Any] = Depends(get_current_user_dep),
|
||||
db: AsyncSession = Depends(get_db)
|
||||
):
|
||||
@@ -113,8 +114,8 @@ async def get_tenant(
|
||||
|
||||
@router.put("/tenants/{tenant_id}", response_model=TenantResponse)
|
||||
async def update_tenant(
|
||||
tenant_id: str,
|
||||
update_data: TenantUpdate,
|
||||
tenant_id: UUID = Path(..., description="Tenant ID"),
|
||||
current_user: Dict[str, Any] = Depends(get_current_user_dep),
|
||||
db: AsyncSession = Depends(get_db)
|
||||
):
|
||||
@@ -134,9 +135,9 @@ async def update_tenant(
|
||||
|
||||
@router.post("/tenants/{tenant_id}/members", response_model=TenantMemberResponse)
|
||||
async def add_team_member(
|
||||
tenant_id: str,
|
||||
user_id: str,
|
||||
role: str,
|
||||
tenant_id: UUID = Path(..., description="Tenant ID"),
|
||||
current_user: Dict[str, Any] = Depends(get_current_user_dep),
|
||||
db: AsyncSession = Depends(get_db)
|
||||
):
|
||||
|
||||
Reference in New Issue
Block a user