Skip to content

Commit 07a02ed

Browse files
committed
Add sample for Orion.AlertActive.AppendNote
1 parent 236be43 commit 07a02ed

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

samples/add_alert_note.py

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
import requests
2+
from orionsdk import SwisClient
3+
4+
def main():
5+
npm_server = 'localhost'
6+
username = 'admin'
7+
password = ''
8+
9+
swis = SwisClient(npm_server, username, password)
10+
11+
r = swis.query('SELECT TOP 1 AlertObjectID FROM Orion.AlertActive ORDER BY TriggeredDateTime DESC')['results']
12+
13+
if len(r) == 0:
14+
print('No active alerts found.')
15+
return
16+
17+
alertObjectId = r[0]['AlertObjectID']
18+
alerts = [alertObjectId] # AppendNode expects a list of AlertObjectID values
19+
note = 'Python was here'
20+
21+
success = swis.invoke('Orion.AlertActive', 'AppendNote', alerts, note)
22+
23+
if success:
24+
print('It worked.')
25+
else:
26+
print('Something went wrong.')
27+
28+
if __name__ == '__main__':
29+
requests.packages.urllib3.disable_warnings()
30+
main()

0 commit comments

Comments
 (0)