|
34 | 34 | FROM = '' |
35 | 35 |
|
36 | 36 | def trigger_incident(): |
37 | | - """Triggers an incident using the V2 REST API.""" |
38 | | - |
| 37 | + """Triggers an incident using the V2 REST API.""" |
| 38 | + |
39 | 39 | url = 'https://api.pagerduty.com/incidents' |
40 | 40 | headers = { |
41 | | - 'Content-Type': 'application/json', |
| 41 | + 'Content-Type': 'application/json', |
42 | 42 | 'Accept': 'application/vnd.pagerduty+json;version=2', |
43 | 43 | 'Authorization': 'Token token={token}'.format(token=API_KEY), |
44 | 44 | 'From': FROM |
45 | 45 | } |
46 | 46 |
|
47 | 47 | payload = { |
48 | | - "incident": { |
49 | | - "type": "incident", |
50 | | - "title": "The server is on fire.", |
51 | | - "service": { |
52 | | - "id": SERVICE_ID, |
53 | | - "type": "service_reference" |
54 | | - }, |
55 | | - "incident_key": "baf7cf21b1da41b4b0221008339ff3571", |
56 | | - "body": { |
57 | | - "type": "incident_body", |
58 | | - "details": "A disk is getting full on this machine. You should investigate what is causing the disk to fill, and ensure that there is an automated process in place for ensuring data is rotated (eg. logs should have logrotate around them). If data is expected to stay on this disk forever, you should start planning to scale up to a larger disk." |
59 | | - } |
60 | | - } |
61 | | - } |
| 48 | + "incident": { |
| 49 | + "type": "incident", |
| 50 | + "title": "The server is on fire.", |
| 51 | + "service": { |
| 52 | + "id": SERVICE_ID, |
| 53 | + "type": "service_reference" |
| 54 | + }, |
| 55 | + "incident_key": "baf7cf21b1da41b4b0221008339ff3571", |
| 56 | + "body": { |
| 57 | + "type": "incident_body", |
| 58 | + "details": "A disk is getting full on this machine. You should investigate what is causing the disk to fill, and ensure that there is an automated process in place for ensuring data is rotated (eg. logs should have logrotate around them). If data is expected to stay on this disk forever, you should start planning to scale up to a larger disk." |
| 59 | + } |
| 60 | + } |
| 61 | + } |
62 | 62 |
|
63 | 63 | r = requests.post(url, headers=headers, data=json.dumps(payload)) |
64 | 64 |
|
|
0 commit comments