Skip to content

Commit e91b615

Browse files
committed
Added list_notifications.py
1 parent e93d371 commit e91b615

6 files changed

Lines changed: 119 additions & 60 deletions

File tree

REST_API_v2/AddOns/list_installed_addons.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -34,22 +34,22 @@
3434
# Update to match your chosen parameters
3535
INCLUDE = []
3636
SERVICE_IDS = []
37-
FILTER = ""
37+
FILTER = ''
3838

3939
def list_installed_addons():
40-
url = "https://api.pagerduty.com/addons"
40+
url = 'https://api.pagerduty.com/addons'
4141
headers = {
4242
'Accept': 'application/vnd.pagerduty+json;version=2',
4343
'Authorization': 'Token token=' + API_KEY
4444
}
4545
payload = {
46-
"include": INCLUDE,
47-
"service_ids": SERVICE_IDS,
48-
"filter": FILTER
46+
'include': INCLUDE,
47+
'service_ids': SERVICE_IDS,
48+
'filter': FILTER
4949
}
5050
r = requests.get(url, headers=headers, params=payload)
51-
print "Status Code: " + str(r.status_code)
51+
print 'Status Code: ' + str(r.status_code)
5252
print r.json()
5353

54-
if __name__ == "__main__":
54+
if __name__ == '__main__':
5555
list_installed_addons()

REST_API_v2/EscalationPolicies/list_escalation_policies.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -32,28 +32,28 @@
3232
API_KEY = '3c3gRvzx7uGfMYEnWKvF'
3333

3434
# Update to match your chosen parameters
35-
QUERY = ""
35+
QUERY = ''
3636
USER_IDS = []
3737
TEAM_IDS = []
3838
INCLUDE = []
39-
SORT_BY = "name"
39+
SORT_BY = 'name'
4040

4141
def list_escalation_policies():
42-
url = "https://api.pagerduty.com/escalation_policies"
42+
url = 'https://api.pagerduty.com/escalation_policies'
4343
headers = {
4444
'Accept': 'application/vnd.pagerduty+json;version=2',
4545
'Authorization': 'Token token=' + API_KEY
4646
}
4747
payload = {
48-
"query": QUERY,
49-
"user_ids": USER_IDS,
50-
"team_ids": TEAM_IDS,
51-
"include": INCLUDE,
52-
"sort_by": SORT_BY
48+
'query': QUERY,
49+
'user_ids': USER_IDS,
50+
'team_ids': TEAM_IDS,
51+
'include': INCLUDE,
52+
'sort_by': SORT_BY
5353
}
5454
r = requests.get(url, headers=headers, params=payload)
55-
print "Status Code: " + str(r.status_code)
55+
print 'Status Code: ' + str(r.status_code)
5656
print r.json()
5757

58-
if __name__ == "__main__":
58+
if __name__ == '__main__':
5959
list_escalation_policies()

REST_API_v2/Incidents/list_incidents.py

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -32,42 +32,42 @@
3232
API_KEY = '3c3gRvzx7uGfMYEnWKvF'
3333

3434
# Update to match your chosen parameters
35-
SINCE = ""
36-
UNTIL = ""
37-
DATE_RANGE = ""
35+
SINCE = ''
36+
UNTIL = ''
37+
DATE_RANGE = ''
3838
STATUSES = []
39-
INCIDENT_KEY = ""
39+
INCIDENT_KEY = ''
4040
SERVICE_IDS = []
4141
TEAM_IDS = []
4242
USER_IDS = []
4343
URGENCIES = []
44-
TIME_ZONE = "UTC"
44+
TIME_ZONE = 'UTC'
4545
SORT_BY = []
4646
INCLUDE = []
4747

4848
def list_incidents():
49-
url = "https://api.pagerduty.com/incidents"
49+
url = 'https://api.pagerduty.com/incidents'
5050
headers = {
5151
'Accept': 'application/vnd.pagerduty+json;version=2',
5252
'Authorization': 'Token token=' + API_KEY
5353
}
5454
payload = {
55-
"since": SINCE,
56-
"until": UNTIL,
57-
"date_range": DATE_RANGE,
58-
"statuses": STATUSES,
59-
"incident_key": INCIDENT_KEY,
60-
"service_ids": SERVICE_IDS,
61-
"team_ids": TEAM_IDS,
62-
"user_ids": USER_IDS,
63-
"urgencies": URGENCIES,
64-
"time_zone": TIME_ZONE,
65-
"sort_by": SORT_BY,
66-
"include": INCLUDE
55+
'since': SINCE,
56+
'until': UNTIL,
57+
'date_range': DATE_RANGE,
58+
'statuses': STATUSES,
59+
'incident_key': INCIDENT_KEY,
60+
'service_ids': SERVICE_IDS,
61+
'team_ids': TEAM_IDS,
62+
'user_ids': USER_IDS,
63+
'urgencies': URGENCIES,
64+
'time_zone': TIME_ZONE,
65+
'sort_by': SORT_BY,
66+
'include': INCLUDE
6767
}
6868
r = requests.get(url, headers=headers, params=payload)
69-
print "Status Code: " + str(r.status_code)
69+
print 'Status Code: ' + str(r.status_code)
7070
print r.json()
7171

72-
if __name__ == "__main__":
72+
if __name__ == '__main__':
7373
list_incidents()

REST_API_v2/LogEntries/list_log_entries.py

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -32,30 +32,30 @@
3232
API_KEY = '3c3gRvzx7uGfMYEnWKvF'
3333

3434
# Update to match your chosen parameters
35-
TIME_ZONE = "UTC"
36-
SINCE = ""
37-
UNTIL = ""
35+
TIME_ZONE = 'UTC'
36+
SINCE = ''
37+
UNTIL = ''
3838
IS_OVERVIEW = False
3939
INCLUDE = []
4040

4141
def list_log_entries():
42-
url = "https://api.pagerduty.com/log_entries"
42+
url = 'https://api.pagerduty.com/log_entries'
4343
headers = {
4444
'Accept': 'application/vnd.pagerduty+json;version=2',
4545
'Authorization': 'Token token=' + API_KEY
4646
}
4747
payload = {
48-
"time_zone": TIME_ZONE,
49-
"is_overview": IS_OVERVIEW,
50-
"include": INCLUDE
48+
'time_zone': TIME_ZONE,
49+
'is_overview': IS_OVERVIEW,
50+
'include': INCLUDE
5151
}
52-
if SINCE != "":
53-
payload["since"] = SINCE
54-
if UNTIL != "":
55-
payload["until"] = UNTIL
52+
if SINCE != '':
53+
payload['since'] = SINCE
54+
if UNTIL != '':
55+
payload['until'] = UNTIL
5656
r = requests.get(url, headers=headers, params=payload)
57-
print "Status Code: " + str(r.status_code)
57+
print 'Status Code: ' + str(r.status_code)
5858
print r.json()
5959

60-
if __name__ == "__main__":
60+
if __name__ == '__main__':
6161
list_log_entries()

REST_API_v2/MaintenanceWindows/list_maintenance_windows.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -35,25 +35,25 @@
3535
TEAM_IDS = []
3636
SERVICE_IDS = []
3737
INCLUDE = []
38-
FILTER = "all"
39-
QUERY = ""
38+
FILTER = 'all'
39+
QUERY = ''
4040

4141
def list_maintenance_windows():
42-
url = "https://api.pagerduty.com/maintenance_windows"
42+
url = 'https://api.pagerduty.com/maintenance_windows'
4343
headers = {
4444
'Accept': 'application/vnd.pagerduty+json;version=2',
4545
'Authorization': 'Token token=' + API_KEY
4646
}
4747
payload = {
48-
"team_ids": TEAM_IDS,
49-
"service_ids": SERVICE_IDS,
50-
"include": INCLUDE,
51-
"filter": FILTER,
52-
"query": QUERY
48+
'team_ids': TEAM_IDS,
49+
'service_ids': SERVICE_IDS,
50+
'include': INCLUDE,
51+
'filter': FILTER,
52+
'query': QUERY
5353
}
5454
r = requests.get(url, headers=headers, params=payload)
55-
print "Status Code: " + str(r.status_code)
55+
print 'Status Code: ' + str(r.status_code)
5656
print r.json()
5757

58-
if __name__ == "__main__":
58+
if __name__ == '__main__':
5959
list_maintenance_windows()
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
#!/usr/bin/env python
2+
#
3+
# Copyright (c) 2016, PagerDuty, Inc. <info@pagerduty.com>
4+
# All rights reserved.
5+
#
6+
# Redistribution and use in source and binary forms, with or without
7+
# modification, are permitted provided that the following conditions are met:
8+
# * Redistributions of source code must retain the above copyright
9+
# notice, this list of conditions and the following disclaimer.
10+
# * Redistributions in binary form must reproduce the above copyright
11+
# notice, this list of conditions and the following disclaimer in the
12+
# documentation and/or other materials provided with the distribution.
13+
# * Neither the name of PagerDuty Inc nor the
14+
# names of its contributors may be used to endorse or promote products
15+
# derived from this software without specific prior written permission.
16+
#
17+
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
18+
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
19+
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
20+
# DISCLAIMED. IN NO EVENT SHALL PAGERDUTY INC BE LIABLE FOR ANY
21+
# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
22+
# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
23+
# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
24+
# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25+
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
26+
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27+
28+
import requests
29+
import json
30+
31+
# Update to match your API key
32+
API_KEY = '3c3gRvzx7uGfMYEnWKvF'
33+
34+
# Update to match your chosen parameters
35+
TIME_ZONE = 'UTC'
36+
SINCE = '2016-05-15'
37+
UNTIL = '2016-05-20'
38+
FILTER = 'sms_notification'
39+
INCLUDE = []
40+
41+
def list_notifications():
42+
url = 'https://api.pagerduty.com/notifications'
43+
headers = {
44+
'Accept': 'application/vnd.pagerduty+json;version=2',
45+
'Authorization': 'Token token=' + API_KEY
46+
}
47+
payload = {
48+
'time_zone': TIME_ZONE,
49+
'since': SINCE,
50+
'until': UNTIL,
51+
'filter': FILTER,
52+
'include': INCLUDE
53+
}
54+
r = requests.get(url, headers=headers, params=payload)
55+
print 'Status Code: ' + str(r.status_code)
56+
print r.json()
57+
58+
if __name__ == '__main__':
59+
list_notifications()

0 commit comments

Comments
 (0)