Skip to content

Commit

Permalink
ns-api: notify, replace priority with level
Browse files Browse the repository at this point in the history
  • Loading branch information
gsanchietti committed Feb 22, 2024
1 parent 9a1560e commit 7eaf72a
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 7 deletions.
20 changes: 15 additions & 5 deletions packages/ns-api/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6057,15 +6057,15 @@ Response example:
"notifications": [
{
"id": 3,
"priority": "low",
"level": 2,
"title": "mytest",
"payload": {},
"timestamp": 1708523000,
"active": true
},
{
"id": 1,
"priority": "high",
"level": 3,
"title": "os_update",
"payload": {
"new_relase": "1.2.3"
Expand All @@ -6090,7 +6090,7 @@ Response example:
"notifications": [
{
"id": 2,
"priority": "low",
"level": 2,
"title": "new_host",
"payload": {
"host": "7.7.7.7"
Expand All @@ -6102,11 +6102,21 @@ Response example:
}
```
Valid values for level are are:
- `0`: DEBUG
- `1`: INFO
- `2`: NOTICE
- `3`: WARNING
- `4`: ERR
- `5`: CRIT
- `6`: ALERT
- `7`: EMERG
### add-notification
Add a new notification:
```
api-cli ns.notify add-notification --data '{"priority": "high", "title": "os_update", "payload": {"new_relase": "1.2.3"}}'
api-cli ns.notify add-notification --data '{"level": 2, "title": "os_update", "payload": {"new_relase": "1.2.3"}}'
```
Response example:
Expand Down Expand Up @@ -6137,7 +6147,7 @@ Response example:
```json
{
"id": 1,
"priority": "high",
"level": 2,
"title": "os_update",
"payload": {
"new_relase": "1.2.3"
Expand Down
4 changes: 2 additions & 2 deletions packages/ns-api/files/ns.notify
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ if cmd == 'list':
print(json.dumps({
"list-read-notifications": {},
"list-unread-notifications": {},
"add-notification": {"title": "string", "priority": "string", "payload": "object"},
"add-notification": {"title": "string", "level": 2, "payload": "object"},
"get-notification": {"id": "int"},
"mark-as-read": {"id": "int"},
"mark-as-unread": {"id": "int"},
Expand All @@ -34,7 +34,7 @@ else:
args = json.loads(sys.stdin.read())

if action == "add-notification":
ret = notify.add_notification(args.get("title"), args.get("priority"), args.get("payload"))
ret = notify.add_notification(args.get("title"), args.get("level"), args.get("payload"))
elif action == "get-notification":
ret = notify.get_notification(args.get("id"))
elif action == "mark-as-read":
Expand Down

0 comments on commit 7eaf72a

Please sign in to comment.