diff --git a/papi/main.py b/papi/main.py index 58eaffa..3ced1bf 100644 --- a/papi/main.py +++ b/papi/main.py @@ -57,6 +57,15 @@ class Notifier: {"changes": changes, "status": [x for x in status]} ) + def error_sonde(idsonde, kind="perte_contact_api"): + notifications[idsonde].append( + { + "changes": ["perte contact api"], + "status": ["Le monitoring est inacessible"], + } + ) + breakpoint() + Notifier = Notifier() @@ -129,6 +138,17 @@ def list_notification_as_text(request: Request, idsonde: str): ) +@app.post("/sonde/{idsonde}/error") +def post_sonde_error( + idsonde: str, body: dict = Body(...), db: Session = Depends(get_db) +): + if not (sonde := crud.get_sonde(db, idsonde)): + return + + Notifier.error_sonde(idsonde) + return + + @app.post("/sonde/{idsonde}/") def post_sonde_data( idsonde: str, body: dict = Body(...), db: Session = Depends(get_db)