From 4eb802a48b0d51aa2b86c63939b79daef912cb95 Mon Sep 17 00:00:00 2001 From: Luc Didry Date: Mon, 27 May 2024 09:54:08 +0200 Subject: [PATCH] =?UTF-8?q?=F0=9F=93=9D=20=E2=80=94=20Document=20how=20to?= =?UTF-8?q?=20add=20a=20new=20notification=20way=20(fix=20#48)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/developer/new-notification-way.md | 34 ++++++++++++++++++++++++++ docs/index.md | 1 + 2 files changed, 35 insertions(+) create mode 100644 docs/developer/new-notification-way.md diff --git a/docs/developer/new-notification-way.md b/docs/developer/new-notification-way.md new file mode 100644 index 0000000..3e193a8 --- /dev/null +++ b/docs/developer/new-notification-way.md @@ -0,0 +1,34 @@ +# Add a notification way + +Adding a new notification way is quite simple. + +First, you need to think about how you will configure it. +As example, here’s how gotify notifications are configured: +```yaml +gotify: + - url: https://example.org + tokens: + - foo + - bar +``` + +Feel free to open an issue to discuss about your notification way or its configuration before coding! +See [#50](https://framagit.org/framasoft/framaspace/argos/-/issues/50) for example. + +Then, you’ll need to add the pydantic schema matching your config in [`argos/schemas/config.py`](https://framagit.org/framasoft/framaspace/argos/-/blob/main/argos/schemas/config.py). + +For gotify, it’s: +```python +class GotifyUrl(BaseModel): + url: HttpUrl + tokens: List[str] +``` + +Add the schema to the `General` schema in the same file (don’t forget to make it optional). + +For gotify, we added this: +```python + gotify: Optional[List[GotifyUrl]] = None +``` + +Finally, write a function which use your new notification way in [`argos/server/alerting.py`](https://framagit.org/framasoft/framaspace/argos/-/blob/main/argos/server/alerting.py) and use it in the `handle_alert` function of the same file. diff --git a/docs/index.md b/docs/index.md index 6d09e90..ef25728 100644 --- a/docs/index.md +++ b/docs/index.md @@ -61,6 +61,7 @@ developer/installation developer/overview developer/dependencies developer/new-check +developer/new-notification-way developer/models developer/migrations developer/tests