Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion REST_API_v1/Incidents/PUT_Incidents_Ack/ack_incident.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ def ack_incident():
'Content-type': 'application/json',
}
r = requests.put(
'https://{0}.pagerduty.com/api/v1/incidents/{0}/acknowledge'.format(SUBDOMAIN, INCIDENT_ID),
'https://{0}.pagerduty.com/api/v1/incidents/{1}/acknowledge?requester_id={2}'.format(SUBDOMAIN, INCIDENT_ID, REQUESTER_ID),
headers=headers,
)
print r.status_code
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ def reassign_incident():
'Content-type': 'application/json',
}
r = requests.put(
'https://{0}.pagerduty.com/api/v1/incidents/{0}/reassign'.format(SUBDOMAIN, INCIDENT_ID),
'https://{0}.pagerduty.com/api/v1/incidents/{1}/reassign'.format(SUBDOMAIN, INCIDENT_ID),
headers=headers,
)
print r.status_code
Expand Down
Original file line number Diff line number Diff line change
@@ -1,19 +1,31 @@
#!/usr/bin/env python
import requests
import datetime
import json


SUBDOMAIN='pdt-dank'
API_ACCESS_KEY='HjEs6A6KozribnKqm1tX'
SERVICE_IDS=['XYZ0ABC']


def get_maintenance_window_by_id():
def create_maintenance_window(minutes=5):
"""Create a maintenance window starting now"""
headers = {
'Authorization': 'Token token={0}'.format(API_ACCESS_KEY),
'Content-type': 'application/json',
}
r = requests.get(
'https://{0}.pagerduty.com/api/v1/maintenance_windows/{1}'.format(SUBDOMAIN, MAINTENANCE_WINDOW_ID),
payload = {
"maintenance_window": {
'start_time': datetime.datetime.utcnow().strftime("%Y-%m-%d %H:%M:%SZ"),
'end_time': (datetime.datetime.utcnow() + datetime.timedelta(minutes=minutes)).strftime("%Y-%m-%d %H:%M:%SZ"),
"description": "Description goes here",
"service_ids": PD_SERVICE_IDS,
}
}
r = requests.post(
'https://{0}.pagerduty.com/api/v1/maintenance_windows'.format(SUBDOMAIN),
headers=headers,
data=json.dumps(payload)
)
print r.status_code
print r.text
Expand Down