forked from PagerDuty/API_Python_Examples
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathack_incident.py
More file actions
executable file
·31 lines (27 loc) · 834 Bytes
/
Copy pathack_incident.py
File metadata and controls
executable file
·31 lines (27 loc) · 834 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#!/usr/bin/env python
import json
import requests
SUBDOMAIN='pdt-dank'
API_ACCESS_KEY='HjEs6A6KozribnKqm1tX'
def trigger_incident():
headers = {
'Authorization': 'Token token={0}'.format(API_ACCESS_KEY),
'Content-type': 'application/json',
}
payload = json.dumps({
"service_key": "e05fd2270e2c4c028f3ae2388bbc09eb",
"incident_key": "18d16696da65420c9f8d5cfa38b17a27",
"event_type": "acknowledge",
"description": "Andrew now working on the problem.",
"details": {
"work started": "2010-06-10 05:43"
}
})
r = requests.post(
'https://events.pagerduty.com/generic/2010-04-15/create_event.json',
headers=headers,
data=payload,
)
print r.status_code
print r.text
trigger_incident()