mirror of
https://framagit.org/framasoft/framaspace/argos.git
synced 2025-04-28 18:02:41 +02:00
📝 — Document how to add a new notification way (fix #48)
This commit is contained in:
parent
4d806e11aa
commit
4eb802a48b
2 changed files with 35 additions and 0 deletions
34
docs/developer/new-notification-way.md
Normal file
34
docs/developer/new-notification-way.md
Normal file
|
@ -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.
|
|
@ -61,6 +61,7 @@ developer/installation
|
||||||
developer/overview
|
developer/overview
|
||||||
developer/dependencies
|
developer/dependencies
|
||||||
developer/new-check
|
developer/new-check
|
||||||
|
developer/new-notification-way
|
||||||
developer/models
|
developer/models
|
||||||
developer/migrations
|
developer/migrations
|
||||||
developer/tests
|
developer/tests
|
||||||
|
|
Loading…
Reference in a new issue