feat(14-01): add site_id device filter, wireless data endpoints, and frontend API clients
- Add site_id and sector_id query parameters to devices list endpoint - Add get_device_registrations and get_device_rf_stats to link_service - Add RegistrationResponse, RFStatsResponse schemas to link.py - Add /registrations and /rf-stats endpoints to links router - Add sectorsApi frontend client (list, create, update, delete, assignDevice) - Add wirelessApi frontend client (links, registrations, RF stats, unknown clients) Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -87,6 +87,8 @@ async def list_devices(
|
||||
group_id: Optional[uuid.UUID] = Query(None),
|
||||
sort_by: str = Query("created_at", description="Field to sort by"),
|
||||
sort_order: str = Query("desc", description="asc or desc"),
|
||||
site_id: Optional[uuid.UUID] = Query(None, description="Filter by site"),
|
||||
sector_id: Optional[uuid.UUID] = Query(None, description="Filter by sector"),
|
||||
current_user: CurrentUser = Depends(get_current_user),
|
||||
db: AsyncSession = Depends(get_db),
|
||||
) -> DeviceListResponse:
|
||||
@@ -104,6 +106,8 @@ async def list_devices(
|
||||
group_id=group_id,
|
||||
sort_by=sort_by,
|
||||
sort_order=sort_order,
|
||||
site_id=site_id,
|
||||
sector_id=sector_id,
|
||||
)
|
||||
return DeviceListResponse(items=items, total=total, page=page, page_size=page_size)
|
||||
|
||||
|
||||
@@ -18,7 +18,12 @@ from sqlalchemy.ext.asyncio import AsyncSession
|
||||
from app.database import get_db
|
||||
from app.middleware.tenant_context import CurrentUser, get_current_user
|
||||
from app.routers.devices import _check_tenant_access
|
||||
from app.schemas.link import LinkListResponse, UnknownClientListResponse
|
||||
from app.schemas.link import (
|
||||
LinkListResponse,
|
||||
RegistrationListResponse,
|
||||
RFStatsListResponse,
|
||||
UnknownClientListResponse,
|
||||
)
|
||||
from app.services import link_service
|
||||
|
||||
router = APIRouter(tags=["links"])
|
||||
@@ -73,6 +78,38 @@ async def list_site_links(
|
||||
return await link_service.get_site_links(db=db, tenant_id=tenant_id, site_id=site_id)
|
||||
|
||||
|
||||
@router.get(
|
||||
"/tenants/{tenant_id}/devices/{device_id}/registrations",
|
||||
response_model=RegistrationListResponse,
|
||||
summary="List device wireless registrations",
|
||||
)
|
||||
async def list_device_registrations(
|
||||
tenant_id: uuid.UUID,
|
||||
device_id: uuid.UUID,
|
||||
current_user: CurrentUser = Depends(get_current_user),
|
||||
db: AsyncSession = Depends(get_db),
|
||||
) -> RegistrationListResponse:
|
||||
"""Get latest wireless registration data for a device (most recent per MAC)."""
|
||||
await _check_tenant_access(current_user, tenant_id, db)
|
||||
return await link_service.get_device_registrations(db=db, tenant_id=tenant_id, device_id=device_id)
|
||||
|
||||
|
||||
@router.get(
|
||||
"/tenants/{tenant_id}/devices/{device_id}/rf-stats",
|
||||
response_model=RFStatsListResponse,
|
||||
summary="List device RF monitor stats",
|
||||
)
|
||||
async def list_device_rf_stats(
|
||||
tenant_id: uuid.UUID,
|
||||
device_id: uuid.UUID,
|
||||
current_user: CurrentUser = Depends(get_current_user),
|
||||
db: AsyncSession = Depends(get_db),
|
||||
) -> RFStatsListResponse:
|
||||
"""Get latest RF monitor stats for a device (most recent per interface)."""
|
||||
await _check_tenant_access(current_user, tenant_id, db)
|
||||
return await link_service.get_device_rf_stats(db=db, tenant_id=tenant_id, device_id=device_id)
|
||||
|
||||
|
||||
@router.get(
|
||||
"/tenants/{tenant_id}/devices/{device_id}/unknown-clients",
|
||||
response_model=UnknownClientListResponse,
|
||||
|
||||
Reference in New Issue
Block a user