Skip to content

Commit 77288bd

Browse files
authored
Merge pull request PagerDuty#6 from PagerDuty/manage-incidents
Fixed issues with manage incidents example
2 parents d827175 + 5cf52c0 commit 77288bd

File tree

1 file changed

+28
-28
lines changed

1 file changed

+28
-28
lines changed

REST_API_v2/Incidents/manage_incidents.py

Lines changed: 28 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -36,20 +36,14 @@
3636

3737
# Update to match your chosen parameters for each incident
3838
INCIDENT_ONE_ID = 'P1DIBFS'
39-
INCIDENT_ONE_TYPE = 'incident'
40-
INCIDENT_ONE_SUMMARY = 'Enter your incident one summary here'
4139
INCIDENT_ONE_STATUS = 'resolved'
42-
INCIDENT_ONE_ESCALATION_LEVEL = 1
43-
INCIDENT_ONE_ASSIGNED_TO_USER = ''
44-
INCIDENT_ONE_ESCALATION_POLICY = ''
40+
INCIDENT_ONE_ASSIGNEE_ID = ''
41+
INCIDENT_ONE_ASSIGNEE_TYPE = ''
4542

4643
INCIDENT_TWO_ID = 'PKSPVAW'
47-
INCIDENT_TWO_TYPE = 'incident'
48-
INCIDENT_TWO_SUMMARY = 'Enter your incident two summary here'
4944
INCIDENT_TWO_STATUS = 'resolved'
50-
INCIDENT_TWO_ESCALATION_LEVEL = 1
51-
INCIDENT_TWO_ASSIGNED_TO_USER = ''
52-
INCIDENT_TWO_ESCALATION_POLICY = ''
45+
INCIDENT_TWO_ASSIGNEE_ID = ''
46+
INCIDENT_TWO_ASSIGNEE_TYPE = ''
5347

5448
def manage_incidents():
5549
url = 'https://api.pagerduty.com/incidents'
@@ -60,24 +54,30 @@ def manage_incidents():
6054
'From': EMAIL
6155
}
6256
payload = {
63-
'incidents': [{
64-
'id': INCIDENT_ONE_ID,
65-
'type': INCIDENT_ONE_TYPE,
66-
'summary': INCIDENT_ONE_SUMMARY,
67-
'status': INCIDENT_ONE_STATUS,
68-
'escalation_level': INCIDENT_ONE_ESCALATION_LEVEL,
69-
'assigned_to_user': INCIDENT_ONE_ASSIGNED_TO_USER,
70-
'escalation_policy': INCIDENT_ONE_ESCALATION_POLICY
71-
},
72-
{
73-
'id': INCIDENT_TWO_ID,
74-
'type': INCIDENT_TWO_TYPE,
75-
'summary': INCIDENT_TWO_SUMMARY,
76-
'status': INCIDENT_TWO_STATUS,
77-
'escalation_level': INCIDENT_TWO_ESCALATION_LEVEL,
78-
'assigned_to_user': INCIDENT_TWO_ASSIGNED_TO_USER,
79-
'escalation_policy': INCIDENT_TWO_ESCALATION_POLICY
80-
}]
57+
'incidents': [
58+
{
59+
'id': INCIDENT_ONE_ID,
60+
'type': 'incident',
61+
'status': INCIDENT_ONE_STATUS,
62+
'assigments': [{
63+
'assignee': {
64+
'id': INCIDENT_ONE_ASSIGNEE_ID,
65+
'type': INCIDENT_ONE_ASSIGNEE_TYPE
66+
}
67+
}]
68+
},
69+
{
70+
'id': INCIDENT_TWO_ID,
71+
'type': 'incident',
72+
'status': INCIDENT_TWO_STATUS,
73+
'assignments': [{
74+
'assignee': {
75+
'id': INCIDENT_TWO_ASSIGNEE_ID,
76+
'type': INCIDENT_TWO_ASSIGNEE_TYPE
77+
}
78+
}]
79+
}
80+
]
8181
}
8282
r = requests.put(url, headers=headers, data=json.dumps(payload))
8383
print 'Status Code: ' + str(r.status_code)

0 commit comments

Comments
 (0)