-
Notifications
You must be signed in to change notification settings - Fork 48
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for generic webhooks (#96)
This can be useful with push notification services such as Gotify.
- Loading branch information
Showing
7 changed files
with
141 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
from typing import Dict, Optional | ||
|
||
import requests | ||
|
||
|
||
class Webhook: | ||
url: str | ||
params: Dict[str, str] | ||
|
||
def __init__(self, url: str, params: Dict[str, str]): | ||
self.url = url | ||
self.params = params | ||
|
||
def push_incident(self, title: str, message: str): | ||
format_args = { | ||
"title": title, | ||
"message": message, | ||
} | ||
# Interpolate URL and params | ||
url = self.url.format(**format_args) | ||
params = { | ||
name: str(value).format(**format_args) | ||
for name, value in self.params.items() | ||
} | ||
|
||
return requests.post(url, params=params) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
|
||
endpoints: | ||
- name: foo | ||
url: http://localhost:8080/swagger | ||
method: GET | ||
header: | ||
SOME-HEADER: SOME-VALUE | ||
timeout: 0.01 | ||
expectation: | ||
- type: HTTP_STATUS | ||
status_range: 200-300 | ||
incident: MAJOR | ||
- type: LATENCY | ||
threshold: 1 | ||
- type: REGEX | ||
regex: '.*(<body).*' | ||
allowed_fails: 0 | ||
component_id: 1 | ||
action: | ||
- CREATE_INCIDENT | ||
- UPDATE_STATUS | ||
public_incidents: true | ||
latency_unit: ms | ||
frequency: 30 | ||
cachet: | ||
api_url: https://demo.cachethq.io/api/v1 | ||
token: my_token | ||
webhooks: | ||
- url: "https://push.example.com/{title}" | ||
- url: "https://push.example.com/message?token=<apptoken>" | ||
params: | ||
title: "{title}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters