1
0
mirror of https://github.com/checktheroads/hyperglass synced 2024-05-11 05:55:08 +00:00

general cleanup

This commit is contained in:
checktheroads
2020-04-16 00:27:00 -07:00
parent 3e53f0b313
commit ea21414634
3 changed files with 55 additions and 3 deletions

View File

@@ -66,6 +66,33 @@ Basic and API key authentication are supported.
If `api_key` is used, the header `X-API-Key: {key}` is added to the request, where `{key}` is the password.
:::
### Webhook Data Structure
The webhook will POST JSON data in the following format:
```json
{
"query_location": "router01",
"query_type": "bgp_route",
"query_vrf": "default",
"query_target": "1.1.1.0/24",
"headers": {
"content-length": "103",
"accept": "application/json, text/plain, */*",
"user-agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.163 Safari/537.36",
"content-type": "application/json;charset=UTF-8",
"referer": "http://lg.example.com/",
"accept-encoding": "gzip, deflate, br",
"accept-language": "en-US,en;q=0.9,fr;q=0.8,lb;q=0.7,la;q=0.6"
},
"source": "192.0.2.1",
"network": {
"prefix": "192.0.2.0/24",
"asns": ["64496"]
}
}
```
## Full example
```yaml

View File

@@ -1,4 +1,29 @@
"""API Events."""
on_startup = []
on_shutdown = []
# Project
from hyperglass.log import log
from hyperglass.util import check_redis
from hyperglass.exceptions import HyperglassError
from hyperglass.configuration import REDIS_CONFIG, params
async def _check_redis():
"""Ensure Redis is running before starting server.
Raises:
HyperglassError: Raised if Redis is not running.
Returns:
{bool} -- True if Redis is running.
"""
try:
await check_redis(db=params.cache.database, config=REDIS_CONFIG)
except RuntimeError as e:
raise HyperglassError(str(e), level="danger") from None
log.debug(f"Redis is running at: {REDIS_CONFIG['host']}:{REDIS_CONFIG['port']}")
return True
on_startup = (_check_redis,)
on_shutdown = ()

View File

@@ -11,7 +11,7 @@ import {
Tag,
useDisclosure,
useColorMode,
useTheme
useTheme,
} from "@chakra-ui/core";
import useConfig from "~/components/HyperglassProvider";
import useMedia from "~/components/MediaProvider";