diff --git a/src/ionbeam/core/aviso.py b/src/ionbeam/core/aviso.py new file mode 100644 index 0000000..ed91211 --- /dev/null +++ b/src/ionbeam/core/aviso.py @@ -0,0 +1,19 @@ +import requests +from typing import Any +from datetime import datetime + + +def send_aviso_notification(request: dict[str, Any]): + notification = { + "type": "aviso", + "data": {"event": "iot-data", "request": request}, + "datacontenttype": "application/json", + "id": "0c02fdc5-148c-43b5-b2fa-cb1f590369ff", + "source": "/host/user", + "specversion": "1.0", + "time": datetime.utcnow().isoformat(timespec="milliseconds") + "Z", + } + + response = requests.post("https://iot-notifications.ecmwf.int/api/v1/notification", json=notification) + # response.raise_for_status() + return response diff --git a/src/ionbeam/writers/mars_client_writer.py b/src/ionbeam/writers/mars_client_writer.py index b40a6d9..63ad3fc 100644 --- a/src/ionbeam/writers/mars_client_writer.py +++ b/src/ionbeam/writers/mars_client_writer.py @@ -15,6 +15,7 @@ import dataclasses from ..core.bases import Writer, Message, FileMessage, FinishMessage +from ..core.aviso import send_aviso_notification import logging @@ -97,7 +98,7 @@ def process(self, message: FileMessage | FinishMessage) -> Iterable[Message]: logger.debug(mars_request) run_temp_mars_request(file=fp.name) - # send an aviso notification here + response = send_aviso_notification(request) # TODO: the explicit mars_keys should not be necessary here. metadata = self.generate_metadata(message, mars_keys=message.metadata.mars_keys)