Merge remote-tracking branch 'origin/dev' into feat/get-readings

This commit is contained in:
Dorian
2026-09-17 11:58:27 +02:00
40 changed files with 2069 additions and 13 deletions
+8
View File
@@ -33,6 +33,7 @@ from app.services.alert import AlertService
from app.services.auth import AuthService, LoginPolicy
from app.services.reading import ReadingService
from app.services.recommendation import RecommendationService
from app.services.sensor import SensorService
from app.services.site import SiteService
from app.services.stats import StatsService
from app.services.user import UserService
@@ -175,6 +176,13 @@ def get_reading_service(session: SessionDep) -> ReadingService:
ReadingServiceDep = Annotated[ReadingService, Depends(get_reading_service)]
def get_sensor_service(session: SessionDep) -> SensorService:
return SensorService(sites=SiteRepository(session), readings=ReadingRepository(session))
SensorServiceDep = Annotated[SensorService, Depends(get_sensor_service)]
async def get_current_principal(
credentials: CredentialsDep,
session: SessionDep,
+4
View File
@@ -79,6 +79,10 @@ TAGS: Final[list[dict[str, Any]]] = [
"rôle `lecteur`."
),
},
{
"name": "sensors",
"description": "État de santé des capteurs par site. Réservé au rôle `admin`.",
},
]
cookie_de_rafraichissement = APIKeyCookie(
@@ -0,0 +1,16 @@
from fastapi import APIRouter
from app.api.deps import AdminDep, SensorServiceDep
from app.schemas.sensor import SensorStatusResponse
router = APIRouter()
@router.get(
"/status",
response_model=SensorStatusResponse,
summary="État de santé des capteurs par site",
)
async def get_status(_: AdminDep, service: SensorServiceDep) -> SensorStatusResponse:
etat = await service.status()
return SensorStatusResponse.model_validate(etat)
+4
View File
@@ -7,6 +7,7 @@ from app.api.v1.endpoints import (
health,
readings,
recommendations,
sensors,
sites,
stats,
users,
@@ -30,3 +31,6 @@ api_router.include_router(stats.router, prefix="/stats", tags=["stats"], respons
api_router.include_router(
readings.router, prefix="/readings", tags=["readings"], responses=REPONSES_LECTEUR
)
api_router.include_router(
sensors.router, prefix="/sensors", tags=["sensors"], responses=REPONSES_ADMIN
)