diff --git a/EVENTS_API_V1/Resolve/resolve_incident.py b/EVENTS_API_V1/Resolve/resolve_incident.py index b1fc45a..3ca5848 100755 --- a/EVENTS_API_V1/Resolve/resolve_incident.py +++ b/EVENTS_API_V1/Resolve/resolve_incident.py @@ -6,7 +6,7 @@ SERVICE_KEY = "" # ENTER EVENTS V1 API INTEGRATION KEY HERE INCIDENT_KEY = "" # ENTER INCIDENT KEY -def trigger_incident(): +def resolve_incident(): # Triggers a PagerDuty incident without a previously generated incident key # Uses Events V1 API - documentation: https://v2.developer.pagerduty.com/docs/trigger-events @@ -23,7 +23,7 @@ def trigger_incident(): if response.json()["status"] == "success": print ('Incident Resolved') else: - print response.text # print error message if not successful + print(response.text) # print error message if not successful if __name__ == '__main__': - trigger_incident() \ No newline at end of file + resolve_incident() diff --git a/EVENTS_API_V1/Trigger/trigger_with_incident_key.py b/EVENTS_API_V1/Trigger/trigger_with_incident_key.py index ddb9028..e7825f1 100755 --- a/EVENTS_API_V1/Trigger/trigger_with_incident_key.py +++ b/EVENTS_API_V1/Trigger/trigger_with_incident_key.py @@ -21,9 +21,9 @@ def trigger_incident(): data=json.dumps(payload)) if response.json()["status"] == "success": - print ('Incident Triggered') + print('Incident Triggered') else: - print response.text # print error message if not successful + print(response.text) # print error message if not successful if __name__ == '__main__': - trigger_incident() \ No newline at end of file + trigger_incident() diff --git a/EVENTS_API_V1/Trigger/trigger_without_incident_key.py b/EVENTS_API_V1/Trigger/trigger_without_incident_key.py index 53558a0..052ca5a 100755 --- a/EVENTS_API_V1/Trigger/trigger_without_incident_key.py +++ b/EVENTS_API_V1/Trigger/trigger_without_incident_key.py @@ -19,9 +19,9 @@ def trigger_incident(): data=json.dumps(payload)) if response.json()["status"] == "success": - print ('Incident created with with incident / alert key of ' + '"' + response.json()['incident_key'] + '"') + print('Incident created with with incident / alert key of ' + '"' + response.json()['incident_key'] + '"') else: - print response.text # print error message if not successful + print(response.text) # print error message if not successful if __name__ == '__main__': - trigger_incident() \ No newline at end of file + trigger_incident() diff --git a/EVENTS_API_V1/Ack/ack_incident.py b/EVENTS_API_V1/ack/ack_incident.py similarity index 84% rename from EVENTS_API_V1/Ack/ack_incident.py rename to EVENTS_API_V1/ack/ack_incident.py index 68a7745..d81285f 100755 --- a/EVENTS_API_V1/Ack/ack_incident.py +++ b/EVENTS_API_V1/ack/ack_incident.py @@ -6,7 +6,7 @@ SERVICE_KEY = "" # ENTER EVENTS V1 API INTEGRATION KEY HERE INCIDENT_KEY = "" # ENTER INCIDENT KEY -def trigger_incident(): +def ack_incident(): # Triggers a PagerDuty incident without a previously generated incident key # Uses Events V1 API - documentation: https://v2.developer.pagerduty.com/docs/trigger-events @@ -21,9 +21,9 @@ def trigger_incident(): data=json.dumps(payload)) if response.json()["status"] == "success": - print ('Incident Acknowledged') + print('Incident Acknowledged') else: - print response.text # print error message if not successful + print(response.text) # print error message if not successful if __name__ == '__main__': - trigger_incident() \ No newline at end of file + ack_incident() diff --git a/EVENTS_API_v2/ack/ack_incident.py b/EVENTS_API_v2/ack/ack_incident.py index d63255e..feb5cf3 100755 --- a/EVENTS_API_v2/ack/ack_incident.py +++ b/EVENTS_API_v2/ack/ack_incident.py @@ -6,7 +6,7 @@ ROUTING_KEY = "" # ENTER EVENTS V2 API INTEGRATION KEY HERE INCIDENT_KEY = "" # ENTER INCIDENT KEY HERE -def trigger_incident(): +def ack_incident(): # Triggers a PagerDuty incident without a previously generated incident key # Uses Events V2 API - documentation: https://v2.developer.pagerduty.com/docs/send-an-event-events-api-v2 @@ -25,9 +25,9 @@ def trigger_incident(): headers=header) if response.json()["status"] == "success": - print ('Incident Acknowledged ') + print('Incident Acknowledged ') else: - print response.text # print error message if not successful + print(response.text) # print error message if not successful if __name__ == '__main__': - trigger_incident() \ No newline at end of file + ack_incident() diff --git a/EVENTS_API_v2/resolve/resolve_incident.py b/EVENTS_API_v2/resolve/resolve_incident.py index 4c66295..80eddd7 100755 --- a/EVENTS_API_v2/resolve/resolve_incident.py +++ b/EVENTS_API_v2/resolve/resolve_incident.py @@ -6,7 +6,7 @@ ROUTING_KEY = "" # ENTER EVENTS V2 API INTEGRATION KEY HERE INCIDENT_KEY = "" # ENTER INCIDENT KEY HERE -def trigger_incident(): +def resolve_incident(): # Triggers a PagerDuty incident without a previously generated incident key # Uses Events V2 API - documentation: https://v2.developer.pagerduty.com/docs/send-an-event-events-api-v2 @@ -25,9 +25,9 @@ def trigger_incident(): headers=header) if response.json()["status"] == "success": - print ('Incident Resolved ') + print('Incident Resolved ') else: - print response.text # print error message if not successful + print(response.text) # print error message if not successful if __name__ == '__main__': - trigger_incident() \ No newline at end of file + resolve_incident() diff --git a/EVENTS_API_v2/trigger/trigger_with_incident_key.py b/EVENTS_API_v2/trigger/trigger_with_incident_key.py index 0cde85e..49e87f7 100644 --- a/EVENTS_API_v2/trigger/trigger_with_incident_key.py +++ b/EVENTS_API_v2/trigger/trigger_with_incident_key.py @@ -30,9 +30,9 @@ def trigger_incident(): headers=header) if response.json()["status"] == "success": - print ('Incident Created') + print('Incident Created') else: - print response.text # print error message if not successful + print(response.text) # print error message if not successful if __name__ == '__main__': - trigger_incident() \ No newline at end of file + trigger_incident() diff --git a/EVENTS_API_v2/trigger/trigger_without_incident_key.py b/EVENTS_API_v2/trigger/trigger_without_incident_key.py index 3c17967..f49c66c 100644 --- a/EVENTS_API_v2/trigger/trigger_without_incident_key.py +++ b/EVENTS_API_v2/trigger/trigger_without_incident_key.py @@ -28,9 +28,9 @@ def trigger_incident(): headers=header) if response.json()["status"] == "success": - print ('Incident created with with dedup key (also known as incident / alert key) of ' + '"' + response.json()['dedup_key'] + '"') + print('Incident created with with dedup key (also known as incident / alert key) of ' + '"' + response.json()['dedup_key'] + '"') else: - print response.text # print error message if not successful + print(response.text) # print error message if not successful if __name__ == '__main__': - trigger_incident() \ No newline at end of file + trigger_incident() diff --git a/REST_API_v2/Abilities/list_abilities.py b/REST_API_v2/Abilities/list_abilities.py index dbe7f79..3a0a529 100755 --- a/REST_API_v2/Abilities/list_abilities.py +++ b/REST_API_v2/Abilities/list_abilities.py @@ -38,8 +38,8 @@ def list_abilities(): 'Authorization': 'Token token={token}'.format(token=API_KEY) } r = requests.get(url, headers=headers) - print 'Status Code: {code}'.format(code=r.status_code) - print r.json() + print('Status Code: {code}'.format(code=r.status_code)) + print(r.json()) if __name__ == '__main__': list_abilities() diff --git a/REST_API_v2/Abilities/test_ability.py b/REST_API_v2/Abilities/test_ability.py index 7a1da01..baedabf 100755 --- a/REST_API_v2/Abilities/test_ability.py +++ b/REST_API_v2/Abilities/test_ability.py @@ -41,8 +41,8 @@ def test_ability(): 'Authorization': 'Token token={token}'.format(token=API_KEY) } r = requests.get(url, headers=headers) - print 'Status Code: {code}'.format(code=r.status_code) - print r.text + print('Status Code: {code}'.format(code=r.status_code)) + print(r.text) if __name__ == '__main__': test_ability() diff --git a/REST_API_v2/AddOns/delete_addon.py b/REST_API_v2/AddOns/delete_addon.py index f99deaa..c555754 100755 --- a/REST_API_v2/AddOns/delete_addon.py +++ b/REST_API_v2/AddOns/delete_addon.py @@ -41,8 +41,8 @@ def delete_addon(): 'Authorization': 'Token token={token}'.format(token=API_KEY) } r = requests.delete(url, headers=headers) - print 'Status Code: {code}'.format(code=r.status_code) - print r.text + print('Status Code: {code}'.format(code=r.status_code)) + print(r.text) if __name__ == '__main__': delete_addon() diff --git a/REST_API_v2/AddOns/get_addon.py b/REST_API_v2/AddOns/get_addon.py index bf1c47c..04b4bed 100755 --- a/REST_API_v2/AddOns/get_addon.py +++ b/REST_API_v2/AddOns/get_addon.py @@ -41,8 +41,8 @@ def get_addon(): 'Authorization': 'Token token={token}'.format(token=API_KEY) } r = requests.get(url, headers=headers) - print 'Status Code: {code}'.format(code=r.status_code) - print r.json() + print('Status Code: {code}'.format(code=r.status_code)) + print(r.json()) if __name__ == '__main__': get_addon() diff --git a/REST_API_v2/AddOns/install_addon.py b/REST_API_v2/AddOns/install_addon.py index 30511a1..c36cefb 100755 --- a/REST_API_v2/AddOns/install_addon.py +++ b/REST_API_v2/AddOns/install_addon.py @@ -54,8 +54,8 @@ def install_addon(): } } r = requests.post(url, headers=headers, data=json.dumps(payload)) - print 'Status Code: {code}'.format(code=r.status_code) - print r.json() + print('Status Code: {code}'.format(code=r.status_code)) + print(r.json()) if __name__ == '__main__': install_addon() diff --git a/REST_API_v2/AddOns/list_installed_addons.py b/REST_API_v2/AddOns/list_installed_addons.py index e1a363a..c21d7bd 100755 --- a/REST_API_v2/AddOns/list_installed_addons.py +++ b/REST_API_v2/AddOns/list_installed_addons.py @@ -48,8 +48,8 @@ def list_installed_addons(): 'filter': FILTER } r = requests.get(url, headers=headers, params=payload) - print 'Status Code: {code}'.format(code=r.status_code) - print r.json() + print('Status Code: {code}'.format(code=r.status_code)) + print(r.json()) if __name__ == '__main__': list_installed_addons() diff --git a/REST_API_v2/AddOns/update_addon.py b/REST_API_v2/AddOns/update_addon.py index 32d5019..3e61508 100755 --- a/REST_API_v2/AddOns/update_addon.py +++ b/REST_API_v2/AddOns/update_addon.py @@ -57,8 +57,8 @@ def update_addon(): } } r = requests.put(url, headers=headers, data=json.dumps(payload)) - print 'Status Code: ' + str(r.status_code) - print r.json() + print('Status Code: ' + str(r.status_code)) + print(r.json()) if __name__ == '__main__': update_addon() diff --git a/REST_API_v2/EscalationPolicies/create_escalation_policy.py b/REST_API_v2/EscalationPolicies/create_escalation_policy.py index 33c12fb..fa8883b 100755 --- a/REST_API_v2/EscalationPolicies/create_escalation_policy.py +++ b/REST_API_v2/EscalationPolicies/create_escalation_policy.py @@ -66,8 +66,8 @@ def create_escalation_policy(): } } r = requests.post(url, headers=headers, data=json.dumps(payload)) - print 'Status Code: {code}'.format(code=r.status_code) - print r.json() + print('Status Code: {code}'.format(code=r.status_code)) + print(r.json()) if __name__ == '__main__': create_escalation_policy() diff --git a/REST_API_v2/EscalationPolicies/delete_escalation_policy.py b/REST_API_v2/EscalationPolicies/delete_escalation_policy.py index 11798b9..4b77f58 100755 --- a/REST_API_v2/EscalationPolicies/delete_escalation_policy.py +++ b/REST_API_v2/EscalationPolicies/delete_escalation_policy.py @@ -41,8 +41,8 @@ def delete_escalation_policy(): 'Authorization': 'Token token={token}'.format(token=API_KEY) } r = requests.delete(url, headers=headers) - print 'Status Code: {code}'.format(code=r.status_code) - print r.text + print('Status Code: {code}'.format(code=r.status_code)) + print(r.text) if __name__ == '__main__': delete_escalation_policy() diff --git a/REST_API_v2/EscalationPolicies/get_escalation_policy.py b/REST_API_v2/EscalationPolicies/get_escalation_policy.py index 1a66144..d0d8a56 100755 --- a/REST_API_v2/EscalationPolicies/get_escalation_policy.py +++ b/REST_API_v2/EscalationPolicies/get_escalation_policy.py @@ -47,8 +47,8 @@ def get_escalation_policy(): 'include[]': INCLUDE } r = requests.get(url, headers=headers, params=payload) - print 'Status Code: {code}'.format(code=r.status_code) - print r.json() + print('Status Code: {code}'.format(code=r.status_code)) + print(r.json()) if __name__ == '__main__': get_escalation_policy() diff --git a/REST_API_v2/EscalationPolicies/list_escalation_policies.py b/REST_API_v2/EscalationPolicies/list_escalation_policies.py index afe1e9b..2de203e 100755 --- a/REST_API_v2/EscalationPolicies/list_escalation_policies.py +++ b/REST_API_v2/EscalationPolicies/list_escalation_policies.py @@ -52,8 +52,8 @@ def list_escalation_policies(): 'sort_by': SORT_BY } r = requests.get(url, headers=headers, params=payload) - print 'Status Code: {code}'.format(code=r.status_code) - print r.json() + print('Status Code: {code}'.format(code=r.status_code)) + print(r.json()) if __name__ == '__main__': list_escalation_policies() diff --git a/REST_API_v2/EscalationPolicies/update_escalation_policy.py b/REST_API_v2/EscalationPolicies/update_escalation_policy.py index 8582a46..5114f72 100755 --- a/REST_API_v2/EscalationPolicies/update_escalation_policy.py +++ b/REST_API_v2/EscalationPolicies/update_escalation_policy.py @@ -73,8 +73,8 @@ def update_escalation_policy(): } } r = requests.put(url, headers=headers, data=json.dumps(payload)) - print 'Status Code: {code}'.format(code=r.status_code) - print r.json() + print('Status Code: {code}'.format(code=r.status_code)) + print(r.json()) if __name__ == '__main__': update_escalation_policy() diff --git a/REST_API_v2/Incidents/create_incident_note.py b/REST_API_v2/Incidents/create_incident_note.py index 0d66dd4..409f740 100755 --- a/REST_API_v2/Incidents/create_incident_note.py +++ b/REST_API_v2/Incidents/create_incident_note.py @@ -55,8 +55,8 @@ def create_incident_note(): } } r = requests.post(url, headers=headers, data=json.dumps(payload)) - print 'Status Code: {code}'.format(code=r.status_code) - print r.json() + print('Status Code: {code}'.format(code=r.status_code)) + print(r.json()) if __name__ == '__main__': create_incident_note() diff --git a/REST_API_v2/Incidents/get_incident.py b/REST_API_v2/Incidents/get_incident.py index 1266418..9e3e91d 100755 --- a/REST_API_v2/Incidents/get_incident.py +++ b/REST_API_v2/Incidents/get_incident.py @@ -41,8 +41,8 @@ def get_incident(): 'Authorization': 'Token token={token}'.format(token=API_KEY) } r = requests.get(url, headers=headers) - print 'Status Code: {code}'.format(code=r.status_code) - print r.json() + print('Status Code: {code}'.format(code=r.status_code)) + print(r.json()) if __name__ == '__main__': get_incident() diff --git a/REST_API_v2/Incidents/list_incident_log_entries.py b/REST_API_v2/Incidents/list_incident_log_entries.py index 3793ec8..5dc2b9f 100755 --- a/REST_API_v2/Incidents/list_incident_log_entries.py +++ b/REST_API_v2/Incidents/list_incident_log_entries.py @@ -51,8 +51,8 @@ def get_incident(): 'include[]': INCLUDE } r = requests.get(url, headers=headers, params=payload) - print 'Status Code: {code}'.format(code=r.status_code) - print r.json() + print('Status Code: {code}'.format(code=r.status_code)) + print(r.json()) if __name__ == '__main__': get_incident() diff --git a/REST_API_v2/Incidents/list_incident_notes.py b/REST_API_v2/Incidents/list_incident_notes.py index 37fb83f..fa79177 100755 --- a/REST_API_v2/Incidents/list_incident_notes.py +++ b/REST_API_v2/Incidents/list_incident_notes.py @@ -43,8 +43,8 @@ def get_incident(): 'Authorization': 'Token token={token}'.format(token=API_KEY) } r = requests.get(url, headers=headers) - print 'Status Code: {code}'.format(code=r.status_code) - print r.json() + print('Status Code: {code}'.format(code=r.status_code)) + print(r.json()) if __name__ == '__main__': get_incident() diff --git a/REST_API_v2/Incidents/list_incidents.py b/REST_API_v2/Incidents/list_incidents.py index 95171c5..bd2b8ec 100755 --- a/REST_API_v2/Incidents/list_incidents.py +++ b/REST_API_v2/Incidents/list_incidents.py @@ -41,7 +41,7 @@ USER_IDS = [] URGENCIES = [] TIME_ZONE = 'UTC' -SORT_BY = [] +SORT_BY = '' # comma-delineated list; see https://v2.developer.pagerduty.com/docs/sorting INCLUDE = [] @@ -62,12 +62,12 @@ def list_incidents(): 'user_ids[]': USER_IDS, 'urgencies[]': URGENCIES, 'time_zone': TIME_ZONE, - 'sort_by[]': SORT_BY, + 'sort_by': SORT_BY, 'include[]': INCLUDE } r = requests.get(url, headers=headers, params=payload) - print 'Status Code: {code}'.format(code=r.status_code) - print r.json() + print('Status Code: {code}'.format(code=r.status_code)) + print(r.json()) if __name__ == '__main__': list_incidents() diff --git a/REST_API_v2/Incidents/manage_incidents.py b/REST_API_v2/Incidents/manage_incidents.py index 703a5e7..4d62b1a 100755 --- a/REST_API_v2/Incidents/manage_incidents.py +++ b/REST_API_v2/Incidents/manage_incidents.py @@ -81,8 +81,8 @@ def manage_incidents(): ] } r = requests.put(url, headers=headers, data=json.dumps(payload)) - print 'Status Code: {code}'.format(code=r.status_code) - print r.json() + print('Status Code: {code}'.format(code=r.status_code)) + print(r.json()) if __name__ == '__main__': manage_incidents() diff --git a/REST_API_v2/Incidents/snooze_incident.py b/REST_API_v2/Incidents/snooze_incident.py index 24ea347..5459aff 100755 --- a/REST_API_v2/Incidents/snooze_incident.py +++ b/REST_API_v2/Incidents/snooze_incident.py @@ -54,8 +54,8 @@ def snooze_incident(): 'duration': 60 * 60 * 24 # 24 hours } r = requests.post(url, headers=headers, data=json.dumps(payload)) - print 'Status Code: {code}'.format(code=r.status_code) - print r.json() + print('Status Code: {code}'.format(code=r.status_code)) + print(r.json()) if __name__ == '__main__': snooze_incident() diff --git a/REST_API_v2/Incidents/trigger_incident.py b/REST_API_v2/Incidents/trigger_incident.py index 8ddcf77..72576be 100644 --- a/REST_API_v2/Incidents/trigger_incident.py +++ b/REST_API_v2/Incidents/trigger_incident.py @@ -62,8 +62,8 @@ def trigger_incident(): r = requests.post(url, headers=headers, data=json.dumps(payload)) - print 'Status Code: {code}'.format(code=r.status_code) - print r.json() + print('Status Code: {code}'.format(code=r.status_code)) + print(r.json()) if __name__ == '__main__': trigger_incident() diff --git a/REST_API_v2/Incidents/update_incident.py b/REST_API_v2/Incidents/update_incident.py index 6e2a3ec..7b8327b 100755 --- a/REST_API_v2/Incidents/update_incident.py +++ b/REST_API_v2/Incidents/update_incident.py @@ -63,8 +63,8 @@ def update_incident(): } } r = requests.put(url, headers=headers, data=json.dumps(payload)) - print 'Status Code: {code}'.format(code=r.status_code) - print r.json() + print('Status Code: {code}'.format(code=r.status_code)) + print(r.json()) if __name__ == '__main__': update_incident() diff --git a/REST_API_v2/LogEntries/get_log_entry.py b/REST_API_v2/LogEntries/get_log_entry.py index 68be38e..b7d202f 100755 --- a/REST_API_v2/LogEntries/get_log_entry.py +++ b/REST_API_v2/LogEntries/get_log_entry.py @@ -47,8 +47,8 @@ def get_log_entry(): 'include[]': INCLUDE } r = requests.get(url, headers=headers, params=payload) - print 'Status Code: {code}'.format(code=r.status_code) - print r.json() + print('Status Code: {code}'.format(code=r.status_code)) + print(r.json()) if __name__ == '__main__': get_log_entry() diff --git a/REST_API_v2/LogEntries/list_log_entries.py b/REST_API_v2/LogEntries/list_log_entries.py index ba5c3ec..04da706 100755 --- a/REST_API_v2/LogEntries/list_log_entries.py +++ b/REST_API_v2/LogEntries/list_log_entries.py @@ -54,8 +54,8 @@ def list_log_entries(): if UNTIL != '': payload['until'] = UNTIL r = requests.get(url, headers=headers, params=payload) - print 'Status Code: {code}'.format(code=r.status_code) - print r.json() + print('Status Code: {code}'.format(code=r.status_code)) + print(r.json()) if __name__ == '__main__': list_log_entries() diff --git a/REST_API_v2/MaintenanceWindows/create_maintenance_window.py b/REST_API_v2/MaintenanceWindows/create_maintenance_window.py index fb81604..164e29e 100755 --- a/REST_API_v2/MaintenanceWindows/create_maintenance_window.py +++ b/REST_API_v2/MaintenanceWindows/create_maintenance_window.py @@ -65,8 +65,8 @@ def create_maintenance_window(): } } r = requests.post(url, headers=headers, data=json.dumps(payload)) - print 'Status Code: {code}'.format(code=r.status_code) - print r.json() + print('Status Code: {code}'.format(code=r.status_code)) + print(r.json()) if __name__ == '__main__': create_maintenance_window() diff --git a/REST_API_v2/MaintenanceWindows/create_maintenance_window_all_services.py b/REST_API_v2/MaintenanceWindows/create_maintenance_window_all_services.py new file mode 100644 index 0000000..e975c10 --- /dev/null +++ b/REST_API_v2/MaintenanceWindows/create_maintenance_window_all_services.py @@ -0,0 +1,157 @@ +#!/usr/bin/env python +# +# Copyright (c) 2018, PagerDuty, Inc. +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are met: +# * Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# * Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# * Neither the name of PagerDuty Inc nor the +# names of its contributors may be used to endorse or promote products +# derived from this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +# ARE DISCLAIMED. IN NO EVENT SHALL PAGERDUTY INC BE LIABLE FOR ANY +# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +# -------------------------------------------------------------------------------- +# INSTRUCTIONS +# +# This script creates a maintenance window on all services. It does not support +# pagination, so it is limited to 100 services (by default it will sort by name) +# +# REQUIRED: API_KEY, EMAIL +# +# OPTIONAL: You can specify the delay before starting the maintenance window, as +# well as the duration. If you prefer, you can instead input the date in `start` +# and `end` below. +# +# # Date format: '2018-09-30T14:00:00' +# +# There are also optional parameters for filtering services or maintenance windows. +# +# -------------------------------------------------------------------------------- + +import requests +import json +import datetime + +# Update to match your API key +API_KEY = '' + +# Update to match your login email +EMAIL = '' + +# get_services parameters +TEAM_IDS = [] +TIME_ZONE = 'UTC' +SORT_BY = 'name' +QUERY = '' +INCLUDE = [] + +# set the delay and duration of maintenance windows +maintenance_start_delay_in_minutes = 0 +maintenance_duration_in_minutes = 10 + +# This gets the timezone of your local server - for UTC, use datetime.datetime.utcnow() +current_time = datetime.datetime.now() +start_time = str(current_time + datetime.timedelta(minutes = maintenance_start_delay_in_minutes)) +end_time = str(current_time + datetime.timedelta(minutes = maintenance_start_delay_in_minutes + maintenance_duration_in_minutes)) + +# You can also specify a start or end date here instead (Date format: '2018-09-30T14:00:00') +start = start_time +end = end_time +START_TIME = (start[0:10] + 'T' + start[11:19]) +END_TIME = (end[0:10] + 'T' + end[11:19]) +DESCRIPTION = 'This maintenance window was created from a python script' +TEAMS = [] +TYPE = 'maintenance_window' + +# ----------------------------------------------------------------------- + + +def get_services(): + print('Getting services...', flush=True) + url = 'https://api.pagerduty.com/services?total=true' + headers = { + 'Accept': 'application/vnd.pagerduty+json;version=2', + 'Authorization': 'Token token={token}'.format(token=API_KEY) + } + payload = { + 'team_ids[]': TEAM_IDS, + 'time_zone': TIME_ZONE, + 'sort_by': SORT_BY, + 'query': QUERY, + 'include[]': INCLUDE, + 'limit': 100 + } + r = requests.get(url, headers=headers, params=payload) + print('\tStatus code: {code}'.format(code=r.status_code)) + if r.status_code < 200 or r.status_code >= 204: + print("\tThere was an error getting your services.") + print("\tPlease ensure that the login email and v2 REST API key in this script are correct.") + print(r.text) + SERVICES = [] + return SERVICES + #print(r.json()) + data = json.loads(r.text) + total_services = data['total'] + print('Creating maintenance window on {total_services} services...'.format(total_services=total_services)) + SERVICES = data['services'] + return SERVICES + + +def create_maintenance_window(SERVICES): + url = 'https://api.pagerduty.com/maintenance_windows' + headers = { + 'Accept': 'application/vnd.pagerduty+json;version=2', + 'Authorization': 'Token token={token}'.format(token=API_KEY), + 'Content-type': 'application/json', + 'From': EMAIL + } + + payload = { + 'maintenance_window': { + 'start_time': START_TIME, + 'end_time': END_TIME, + 'description': DESCRIPTION, + 'services': SERVICES, + 'teams': TEAMS, + 'type': TYPE + } + } + r = requests.post(url, headers=headers, data=json.dumps(payload)) + print('\tStatus code: {code}'.format(code=str(r.status_code))) + if r.status_code >= 200 and r.status_code < 204: + print("Maintenance window successfully created:") + print("\tStart: ", START_TIME) + print("\tEnd: ", END_TIME) + print("\tServices: ") + for service in range(int(len(SERVICES))): + print("\t\t", SERVICES[service]['id']) + else: + print("\tThere was an error creating this maintenance window.") + print("\tPlease ensure that the login email and v2 REST API key in this script have proper permissions") + # print(r.json()) + + +if __name__ == '__main__': + if EMAIL == '': + print("Please add your login email to this script and run it again.") + elif API_KEY == '': + print("Please add your v2 REST API key to this script and run it again.") + else: + SERVICES = get_services() + if SERVICES != []: + create_maintenance_window(SERVICES) diff --git a/REST_API_v2/MaintenanceWindows/delete_or_end_maintenance_window.py b/REST_API_v2/MaintenanceWindows/delete_or_end_maintenance_window.py index b7efc51..02ea570 100755 --- a/REST_API_v2/MaintenanceWindows/delete_or_end_maintenance_window.py +++ b/REST_API_v2/MaintenanceWindows/delete_or_end_maintenance_window.py @@ -41,8 +41,8 @@ def delete_maintenance_window(): 'Authorization': 'Token token={token}'.format(token=API_KEY) } r = requests.delete(url, headers=headers) - print 'Status Code: {code}'.format(code=r.status_code) - print r.text + print('Status Code: {code}'.format(code=r.status_code)) + print(r.text) if __name__ == '__main__': delete_maintenance_window() diff --git a/REST_API_v2/MaintenanceWindows/get_maintenance_window.py b/REST_API_v2/MaintenanceWindows/get_maintenance_window.py index 1cbf506..78b956b 100755 --- a/REST_API_v2/MaintenanceWindows/get_maintenance_window.py +++ b/REST_API_v2/MaintenanceWindows/get_maintenance_window.py @@ -47,8 +47,8 @@ def get_maintenance_window(): 'include[]': INCLUDE } r = requests.get(url, headers=headers, params=payload) - print 'Status Code: {code}'.format(code=r.status_code) - print r.json() + print('Status Code: {code}'.format(code=r.status_code)) + print(r.json()) if __name__ == '__main__': get_maintenance_window() diff --git a/REST_API_v2/MaintenanceWindows/list_maintenance_windows.py b/REST_API_v2/MaintenanceWindows/list_maintenance_windows.py index 2c7a100..72cc8c1 100755 --- a/REST_API_v2/MaintenanceWindows/list_maintenance_windows.py +++ b/REST_API_v2/MaintenanceWindows/list_maintenance_windows.py @@ -52,8 +52,8 @@ def list_maintenance_windows(): 'query': QUERY } r = requests.get(url, headers=headers, params=payload) - print 'Status Code: {code}'.format(code=r.status_code) - print r.json() + print('Status Code: {code}'.format(code=r.status_code)) + print(r.json()) if __name__ == '__main__': list_maintenance_windows() diff --git a/REST_API_v2/MaintenanceWindows/update_maintenance_window.py b/REST_API_v2/MaintenanceWindows/update_maintenance_window.py index e0425c6..4709db7 100755 --- a/REST_API_v2/MaintenanceWindows/update_maintenance_window.py +++ b/REST_API_v2/MaintenanceWindows/update_maintenance_window.py @@ -64,8 +64,8 @@ def update_maintenance_window(): } } r = requests.put(url, headers=headers, data=json.dumps(payload)) - print 'Status Code: {code}'.format(code=r.status_code) - print r.json() + print('Status Code: {code}'.format(code=r.status_code)) + print(r.json()) if __name__ == '__main__': update_maintenance_window() diff --git a/REST_API_v2/Notifications/list_notifications.py b/REST_API_v2/Notifications/list_notifications.py index 0599fdc..b94a0c4 100755 --- a/REST_API_v2/Notifications/list_notifications.py +++ b/REST_API_v2/Notifications/list_notifications.py @@ -52,8 +52,8 @@ def list_notifications(): 'include[]': INCLUDE } r = requests.get(url, headers=headers, params=payload) - print 'Status Code: {code}'.format(code=r.status_code) - print r.json() + print('Status Code: {code}'.format(code=r.status_code)) + print(r.json()) if __name__ == '__main__': list_notifications() diff --git a/REST_API_v2/OnCalls/list_oncalls.py b/REST_API_v2/OnCalls/list_oncalls.py index 6f9bb09..c2a12da 100755 --- a/REST_API_v2/OnCalls/list_oncalls.py +++ b/REST_API_v2/OnCalls/list_oncalls.py @@ -58,8 +58,8 @@ def list_oncalls(): 'earliest': EARLIEST } r = requests.get(url, headers=headers, params=payload) - print 'Status Code: {code}'.format(code=r.status_code) - print r.json() + print('Status Code: {code}'.format(code=r.status_code)) + print(r.json()) if __name__ == '__main__': list_oncalls() diff --git a/REST_API_v2/Schedules/create_override.py b/REST_API_v2/Schedules/create_override.py index 847e70d..7e4cde5 100755 --- a/REST_API_v2/Schedules/create_override.py +++ b/REST_API_v2/Schedules/create_override.py @@ -60,8 +60,8 @@ def create_override(): } } r = requests.post(url, headers=headers, data=json.dumps(payload)) - print 'Status Code: {code}'.format(code=r.status_code) - print r.json() + print('Status Code: {code}'.format(code=r.status_code)) + print(r.json()) if __name__ == '__main__': create_override() diff --git a/REST_API_v2/Schedules/create_schedule.py b/REST_API_v2/Schedules/create_schedule.py index 69ec8d2..fbe1588 100755 --- a/REST_API_v2/Schedules/create_schedule.py +++ b/REST_API_v2/Schedules/create_schedule.py @@ -127,8 +127,8 @@ def create_schedule(): } } r = requests.post(url, headers=headers, data=json.dumps(payload)) - print 'Status Code: {code}'.format(code=r.status_code) - print r.json() + print('Status Code: {code}'.format(code=r.status_code)) + print(r.json()) if __name__ == '__main__': create_schedule() diff --git a/REST_API_v2/Schedules/delete_override.py b/REST_API_v2/Schedules/delete_override.py index f080c80..19b762e 100755 --- a/REST_API_v2/Schedules/delete_override.py +++ b/REST_API_v2/Schedules/delete_override.py @@ -45,8 +45,8 @@ def delete_override(): 'Authorization': 'Token token={token}'.format(token=API_KEY) } r = requests.delete(url, headers=headers) - print 'Status Code: {code}'.format(code=r.status_code) - print r.text + print('Status Code: {code}'.format(code=r.status_code)) + print(r.text) if __name__ == '__main__': delete_override() diff --git a/REST_API_v2/Schedules/delete_schedule.py b/REST_API_v2/Schedules/delete_schedule.py index 2565611..ca31253 100755 --- a/REST_API_v2/Schedules/delete_schedule.py +++ b/REST_API_v2/Schedules/delete_schedule.py @@ -41,8 +41,8 @@ def delete_schedule(): 'Authorization': 'Token token={token}'.format(token=API_KEY) } r = requests.delete(url, headers=headers) - print 'Status Code: {code}'.format(code=r.status_code) - print r.text + print('Status Code: {code}'.format(code=r.status_code)) + print(r.text) if __name__ == '__main__': delete_schedule() diff --git a/REST_API_v2/Schedules/get_schedule.py b/REST_API_v2/Schedules/get_schedule.py index 9052f33..084c18e 100755 --- a/REST_API_v2/Schedules/get_schedule.py +++ b/REST_API_v2/Schedules/get_schedule.py @@ -53,8 +53,8 @@ def get_schedule(): if UNTIL != '': payload['until'] = UNTIL r = requests.get(url, headers=headers, params=payload) - print 'Status Code: {code}'.format(code=r.status_code) - print r.json() + print('Status Code: {code}'.format(code=r.status_code)) + print(r.json()) if __name__ == '__main__': get_schedule() diff --git a/REST_API_v2/Schedules/list_oncall_users.py b/REST_API_v2/Schedules/list_oncall_users.py index 0053f2e..7fc4633 100755 --- a/REST_API_v2/Schedules/list_oncall_users.py +++ b/REST_API_v2/Schedules/list_oncall_users.py @@ -52,8 +52,8 @@ def list_overrides(): if UNTIL != '': payload['until'] = UNTIL r = requests.get(url, headers=headers, params=payload) - print 'Status Code: {code}'.format(code=r.status_code) - print r.json() + print('Status Code: {code}'.format(code=r.status_code)) + print(r.json()) if __name__ == '__main__': list_overrides() diff --git a/REST_API_v2/Schedules/list_overrides.py b/REST_API_v2/Schedules/list_overrides.py index 99d4675..afa77a2 100755 --- a/REST_API_v2/Schedules/list_overrides.py +++ b/REST_API_v2/Schedules/list_overrides.py @@ -55,8 +55,8 @@ def list_overrides(): 'overflow': OVERFLOW } r = requests.get(url, headers=headers, params=payload) - print 'Status Code: {code}'.format(code=r.status_code) - print r.json() + print('Status Code: {code}'.format(code=r.status_code)) + print(r.json()) if __name__ == '__main__': list_overrides() diff --git a/REST_API_v2/Schedules/list_schedules.py b/REST_API_v2/Schedules/list_schedules.py index adc475f..de50bd2 100755 --- a/REST_API_v2/Schedules/list_schedules.py +++ b/REST_API_v2/Schedules/list_schedules.py @@ -44,8 +44,8 @@ def list_schedules(): 'query': QUERY } r = requests.get(url, headers=headers, params=payload) - print 'Status Code: {code}'.format(code=r.status_code) - print r.json() + print('Status Code: {code}'.format(code=r.status_code)) + print(r.json()) if __name__ == '__main__': list_schedules() diff --git a/REST_API_v2/Schedules/preview_schedule.py b/REST_API_v2/Schedules/preview_schedule.py index b4c3e52..6fb976b 100755 --- a/REST_API_v2/Schedules/preview_schedule.py +++ b/REST_API_v2/Schedules/preview_schedule.py @@ -139,8 +139,8 @@ def preview_schedule(): } } r = requests.post(url, headers=headers, data=json.dumps(payload)) - print 'Status Code: {code}'.format(code=r.status_code) - print r.json() + print('Status Code: {code}'.format(code=r.status_code)) + print(r.json()) if __name__ == '__main__': preview_schedule() diff --git a/REST_API_v2/Schedules/update_schedule.py b/REST_API_v2/Schedules/update_schedule.py index 735cdaf..e9724fe 100755 --- a/REST_API_v2/Schedules/update_schedule.py +++ b/REST_API_v2/Schedules/update_schedule.py @@ -138,8 +138,8 @@ def update_schedule(): } } r = requests.put(url, headers=headers, data=json.dumps(payload)) - print 'Status Code: {code}'.format(code=r.status_code) - print r.json() + print('Status Code: {code}'.format(code=r.status_code)) + print(r.json()) if __name__ == '__main__': update_schedule() diff --git a/REST_API_v2/Services/create_integration.py b/REST_API_v2/Services/create_integration.py index c1ee5fd..6baba79 100755 --- a/REST_API_v2/Services/create_integration.py +++ b/REST_API_v2/Services/create_integration.py @@ -63,8 +63,8 @@ def create_integration(): if TYPE == 'generic_email_inbound_integration': payload['integration']['integration_email'] = INTEGRATION_EMAIL r = requests.post(url, headers=headers, data=json.dumps(payload)) - print 'Status Code: {code}'.format(code=r.status_code) - print r.json() + print('Status Code: {code}'.format(code=r.status_code)) + print(r.json()) if __name__ == '__main__': create_integration() diff --git a/REST_API_v2/Services/create_service.py b/REST_API_v2/Services/create_service.py index a2d695a..cafd60b 100755 --- a/REST_API_v2/Services/create_service.py +++ b/REST_API_v2/Services/create_service.py @@ -96,8 +96,8 @@ def create_service(): } } r = requests.post(url, headers=headers, data=json.dumps(payload)) - print 'Status Code: {code}'.format(code=r.status_code) - print r.json() + print('Status Code: {code}'.format(code=r.status_code)) + print(r.json()) if __name__ == '__main__': create_service() diff --git a/REST_API_v2/Services/delete_service.py b/REST_API_v2/Services/delete_service.py index bd0fe2a..945686d 100755 --- a/REST_API_v2/Services/delete_service.py +++ b/REST_API_v2/Services/delete_service.py @@ -41,8 +41,8 @@ def delete_service(): 'Authorization': 'Token token={token}'.format(token=API_KEY) } r = requests.delete(url, headers=headers) - print 'Status Code: {code}'.format(code=r.status_code) - print r.text + print('Status Code: {code}'.format(code=r.status_code)) + print(r.text) if __name__ == '__main__': delete_service() diff --git a/REST_API_v2/Services/get_integration.py b/REST_API_v2/Services/get_integration.py index 1f09b72..b3ea2eb 100755 --- a/REST_API_v2/Services/get_integration.py +++ b/REST_API_v2/Services/get_integration.py @@ -51,8 +51,8 @@ def get_integration(): 'include[]': INCLUDE } r = requests.get(url, headers=headers, params=payload) - print 'Status Code: {code}'.format(code=r.status_code) - print r.json() + print('Status Code: {code}'.format(code=r.status_code)) + print(r.json()) if __name__ == '__main__': get_integration() diff --git a/REST_API_v2/Services/get_service.py b/REST_API_v2/Services/get_service.py index 41ae52e..95b64a6 100755 --- a/REST_API_v2/Services/get_service.py +++ b/REST_API_v2/Services/get_service.py @@ -47,8 +47,8 @@ def get_service(): 'include[]': INCLUDE } r = requests.get(url, headers=headers, params=payload) - print 'Status Code: {code}'.format(code=r.status_code) - print r.json() + print('Status Code: {code}'.format(code=r.status_code)) + print(r.json()) if __name__ == '__main__': get_service() diff --git a/REST_API_v2/Services/list_services.py b/REST_API_v2/Services/list_services.py index 34c5917..04532e7 100755 --- a/REST_API_v2/Services/list_services.py +++ b/REST_API_v2/Services/list_services.py @@ -52,8 +52,8 @@ def list_services(): 'include[]': INCLUDE } r = requests.get(url, headers=headers, params=payload) - print 'Status Code: {code}'.format(code=r.status_code) - print r.json() + print('Status Code: {code}'.format(code=r.status_code)) + print(r.json()) if __name__ == '__main__': list_services() diff --git a/REST_API_v2/Services/update_integration.py b/REST_API_v2/Services/update_integration.py index b77720a..aaea2cb 100755 --- a/REST_API_v2/Services/update_integration.py +++ b/REST_API_v2/Services/update_integration.py @@ -57,8 +57,8 @@ def update_integration(): } } r = requests.put(url, headers=headers, data=json.dumps(payload)) - print 'Status Code: {code}'.format(code=r.status_code) - print r.json() + print('Status Code: {code}'.format(code=r.status_code)) + print(r.json()) if __name__ == '__main__': update_integration() diff --git a/REST_API_v2/Services/update_service.py b/REST_API_v2/Services/update_service.py index d428eef..d0bf571 100755 --- a/REST_API_v2/Services/update_service.py +++ b/REST_API_v2/Services/update_service.py @@ -54,15 +54,18 @@ def update_service(): 'service': { 'name': NAME, 'description': DESCRIPTION, - 'escalation_policy_id': ESCALATION_POLICY_ID, + 'escalation_policy': { + 'id': ESCALATION_POLICY_ID, + 'type': 'escalation_policy_reference' + }, 'acknowledgement_timeout': ACKNOWLEDGEMENT_TIMEOUT, 'auto_resolve_timeout': AUTO_RESOLVE_TIMEOUT, 'severity_filter': SEVERITY_FILTER } } r = requests.put(url, headers=headers, data=json.dumps(payload)) - print 'Status Code: {code}'.format(code=r.status_code) - print r.json() + print('Status Code: {code}'.format(code=r.status_code)) + print(r.json()) if __name__ == '__main__': update_service() diff --git a/REST_API_v2/Teams/add_escalation_policy_to_team.py b/REST_API_v2/Teams/add_escalation_policy_to_team.py index 963a011..eb475da 100755 --- a/REST_API_v2/Teams/add_escalation_policy_to_team.py +++ b/REST_API_v2/Teams/add_escalation_policy_to_team.py @@ -44,8 +44,8 @@ def add_escalation_policy_to_team(): 'Content-type': 'application/json' } r = requests.put(url, headers=headers) - print 'Status Code: {code}'.format(code=r.status_code) - print r.text + print('Status Code: {code}'.format(code=r.status_code)) + print(r.text) if __name__ == '__main__': add_escalation_policy_to_team() diff --git a/REST_API_v2/Teams/add_user_to_team.py b/REST_API_v2/Teams/add_user_to_team.py index 6fc2578..936e1d1 100755 --- a/REST_API_v2/Teams/add_user_to_team.py +++ b/REST_API_v2/Teams/add_user_to_team.py @@ -46,8 +46,8 @@ def add_user_to_team(): 'Content-type': 'application/json' } r = requests.put(url, headers=headers) - print 'Status Code: {code}'.format(code=r.status_code) - print r.text + print('Status Code: {code}'.format(code=r.status_code)) + print(r.text) if __name__ == '__main__': add_user_to_team() diff --git a/REST_API_v2/Teams/create_team.py b/REST_API_v2/Teams/create_team.py index 417bf09..f8495f6 100755 --- a/REST_API_v2/Teams/create_team.py +++ b/REST_API_v2/Teams/create_team.py @@ -52,8 +52,8 @@ def create_team(): } } r = requests.post(url, headers=headers, data=json.dumps(payload)) - print 'Status Code: {code}'.format(code=r.status_code) - print r.json() + print('Status Code: {code}'.format(code=r.status_code)) + print(r.json()) if __name__ == '__main__': create_team() diff --git a/REST_API_v2/Teams/delete_team.py b/REST_API_v2/Teams/delete_team.py index 8bf05a6..a4c0132 100755 --- a/REST_API_v2/Teams/delete_team.py +++ b/REST_API_v2/Teams/delete_team.py @@ -41,8 +41,8 @@ def delete_team(): 'Authorization': 'Token token={token}'.format(token=API_KEY) } r = requests.delete(url, headers=headers) - print 'Status Code: {code}'.format(code=r.status_code) - print r.text + print('Status Code: {code}'.format(code=r.status_code)) + print(r.text) if __name__ == '__main__': delete_team() diff --git a/REST_API_v2/Teams/get_team.py b/REST_API_v2/Teams/get_team.py index 825b483..4e1d384 100755 --- a/REST_API_v2/Teams/get_team.py +++ b/REST_API_v2/Teams/get_team.py @@ -41,8 +41,8 @@ def get_team(): 'Authorization': 'Token token={token}'.format(token=API_KEY) } r = requests.get(url, headers=headers) - print 'Status Code: {code}'.format(code=r.status_code) - print r.json() + print('Status Code: {code}'.format(code=r.status_code)) + print(r.json()) if __name__ == '__main__': get_team() diff --git a/REST_API_v2/Teams/list_teams.py b/REST_API_v2/Teams/list_teams.py index bb0666e..3a5fc89 100755 --- a/REST_API_v2/Teams/list_teams.py +++ b/REST_API_v2/Teams/list_teams.py @@ -44,8 +44,8 @@ def list_teams(): 'query': QUERY } r = requests.get(url, headers=headers, params=payload) - print 'Status Code: {code}'.format(code=r.status_code) - print r.json() + print('Status Code: {code}'.format(code=r.status_code)) + print(r.json()) if __name__ == '__main__': list_teams() diff --git a/REST_API_v2/Teams/remove_escalation_policy_from_team.py b/REST_API_v2/Teams/remove_escalation_policy_from_team.py index 9c47d67..bc5cb74 100755 --- a/REST_API_v2/Teams/remove_escalation_policy_from_team.py +++ b/REST_API_v2/Teams/remove_escalation_policy_from_team.py @@ -43,8 +43,8 @@ def remove_escalation_policy_from_team(): 'Authorization': 'Token token={token}'.format(token=API_KEY) } r = requests.delete(url, headers=headers) - print 'Status Code: {code}'.format(code=r.status_code) - print r.text + print('Status Code: {code}'.format(code=r.status_code)) + print(r.text) if __name__ == '__main__': remove_escalation_policy_from_team() diff --git a/REST_API_v2/Teams/remove_user_from_team.py b/REST_API_v2/Teams/remove_user_from_team.py index 11e4e2e..4e658c2 100755 --- a/REST_API_v2/Teams/remove_user_from_team.py +++ b/REST_API_v2/Teams/remove_user_from_team.py @@ -45,8 +45,8 @@ def remove_user_from_team(): 'Authorization': 'Token token={token}'.format(token=API_KEY) } r = requests.delete(url, headers=headers) - print 'Status Code: {code}'.format(code=r.status_code) - print r.text + print('Status Code: {code}'.format(code=r.status_code)) + print(r.text) if __name__ == '__main__': remove_user_from_team() diff --git a/REST_API_v2/Teams/update_team.py b/REST_API_v2/Teams/update_team.py index b84e10b..9657942 100755 --- a/REST_API_v2/Teams/update_team.py +++ b/REST_API_v2/Teams/update_team.py @@ -53,8 +53,8 @@ def update_team(): } } r = requests.put(url, headers=headers, data=json.dumps(payload)) - print 'Status Code: {code}'.format(code=r.status_code) - print r.json() + print('Status Code: {code}'.format(code=r.status_code)) + print(r.json()) if __name__ == '__main__': update_team() diff --git a/REST_API_v2/Users/create_user.py b/REST_API_v2/Users/create_user.py index 9514493..676c37e 100755 --- a/REST_API_v2/Users/create_user.py +++ b/REST_API_v2/Users/create_user.py @@ -37,7 +37,7 @@ # Update to match your chosen parameters for the new user NAME = 'Insert user name here' EMAIL = 'insert_email@here.com' -ROLE = 'user' # Can be one of admin, user, team_responder, limited_user, read_only_user # NOQA +ROLE = 'user' # Can be one of admin, user, limited_user, read_only_user # NOQA def create_user(): @@ -57,8 +57,8 @@ def create_user(): } } r = requests.post(url, headers=headers, data=json.dumps(payload)) - print 'Status Code: {code}'.format(code=r.status_code) - print r.json() + print('Status Code: {code}'.format(code=r.status_code)) + print(r.json()) if __name__ == '__main__': create_user() diff --git a/REST_API_v2/Users/create_user_contact_method.py b/REST_API_v2/Users/create_user_contact_method.py index 9f5acf2..1494bfe 100755 --- a/REST_API_v2/Users/create_user_contact_method.py +++ b/REST_API_v2/Users/create_user_contact_method.py @@ -55,8 +55,8 @@ def create_user_contact_method(): } } r = requests.post(url, headers=headers, data=json.dumps(payload)) - print 'Status Code: {code}'.format(code=r.status_code) - print r.json() + print('Status Code: {code}'.format(code=r.status_code)) + print(r.json()) if __name__ == '__main__': create_user_contact_method() diff --git a/REST_API_v2/Users/create_user_notification_rule.py b/REST_API_v2/Users/create_user_notification_rule.py index 29a764c..01137b4 100755 --- a/REST_API_v2/Users/create_user_notification_rule.py +++ b/REST_API_v2/Users/create_user_notification_rule.py @@ -62,8 +62,8 @@ def create_user_notification_rule(): } } r = requests.post(url, headers=headers, data=json.dumps(payload)) - print 'Status Code: {code}'.format(code=r.status_code) - print r.json() + print('Status Code: {code}'.format(code=r.status_code)) + print(r.json()) if __name__ == '__main__': create_user_notification_rule() diff --git a/REST_API_v2/Users/delete_user.py b/REST_API_v2/Users/delete_user.py index dadb099..17a04b3 100755 --- a/REST_API_v2/Users/delete_user.py +++ b/REST_API_v2/Users/delete_user.py @@ -41,8 +41,8 @@ def delete_user(): 'Authorization': 'Token token={token}'.format(token=API_KEY) } r = requests.delete(url, headers=headers) - print 'Status Code: {code}'.format(code=r.status_code) - print r.text + print('Status Code: {code}'.format(code=r.status_code)) + print(r.text) if __name__ == '__main__': delete_user() diff --git a/REST_API_v2/Users/delete_user_contact_method.py b/REST_API_v2/Users/delete_user_contact_method.py index d78d4be..83deb54 100755 --- a/REST_API_v2/Users/delete_user_contact_method.py +++ b/REST_API_v2/Users/delete_user_contact_method.py @@ -45,8 +45,8 @@ def delete_user_contact_method(): 'Authorization': 'Token token={token}'.format(token=API_KEY) } r = requests.delete(url, headers=headers) - print 'Status Code: {code}'.format(code=r.status_code) - print r.text + print('Status Code: {code}'.format(code=r.status_code)) + print(r.text) if __name__ == '__main__': delete_user_contact_method() diff --git a/REST_API_v2/Users/delete_user_notification_rule.py b/REST_API_v2/Users/delete_user_notification_rule.py index 93c5383..228cee0 100755 --- a/REST_API_v2/Users/delete_user_notification_rule.py +++ b/REST_API_v2/Users/delete_user_notification_rule.py @@ -43,8 +43,8 @@ def delete_user_notification_rule(): 'Authorization': 'Token token={token}'.format(token=API_KEY) } r = requests.delete(url, headers=headers) - print 'Status Code: {code}'.format(code=r.status_code) - print r.text + print('Status Code: {code}'.format(code=r.status_code)) + print(r.text) if __name__ == '__main__': delete_user_notification_rule() diff --git a/REST_API_v2/Users/get_user.py b/REST_API_v2/Users/get_user.py index 860fe49..7513929 100755 --- a/REST_API_v2/Users/get_user.py +++ b/REST_API_v2/Users/get_user.py @@ -47,8 +47,8 @@ def get_user(): 'include[]': INCLUDE } r = requests.get(url, headers=headers, params=payload) - print 'Status Code: {code}'.format(code=r.status_code) - print r.json() + print('Status Code: {code}'.format(code=r.status_code)) + print(r.json()) if __name__ == '__main__': get_user() diff --git a/REST_API_v2/Users/get_user_contact_method.py b/REST_API_v2/Users/get_user_contact_method.py index 5ef95fe..05c3a1e 100755 --- a/REST_API_v2/Users/get_user_contact_method.py +++ b/REST_API_v2/Users/get_user_contact_method.py @@ -45,8 +45,8 @@ def get_user_contact_method(): 'Authorization': 'Token token={token}'.format(token=API_KEY) } r = requests.get(url, headers=headers) - print 'Status Code: {code}'.format(code=r.status_code) - print r.json() + print('Status Code: {code}'.format(code=r.status_code)) + print(r.json()) if __name__ == '__main__': get_user_contact_method() diff --git a/REST_API_v2/Users/get_user_notification_rule.py b/REST_API_v2/Users/get_user_notification_rule.py index ffac7f2..70ac0b8 100755 --- a/REST_API_v2/Users/get_user_notification_rule.py +++ b/REST_API_v2/Users/get_user_notification_rule.py @@ -49,8 +49,8 @@ def get_user_notification_rule(): 'include[]': INCLUDE } r = requests.get(url, headers=headers, params=payload) - print 'Status Code: {code}'.format(code=r.status_code) - print r.json() + print('Status Code: {code}'.format(code=r.status_code)) + print(r.json()) if __name__ == '__main__': get_user_notification_rule() diff --git a/REST_API_v2/Users/list_user_contact_methods.py b/REST_API_v2/Users/list_user_contact_methods.py index 6e5190b..fafd7bd 100755 --- a/REST_API_v2/Users/list_user_contact_methods.py +++ b/REST_API_v2/Users/list_user_contact_methods.py @@ -41,8 +41,8 @@ def list_user_contact_methods(): 'Authorization': 'Token token={token}'.format(token=API_KEY) } r = requests.get(url, headers=headers) - print 'Status Code: {code}'.format(code=r.status_code) - print r.json() + print('Status Code: {code}'.format(code=r.status_code)) + print(r.json()) if __name__ == '__main__': list_user_contact_methods() diff --git a/REST_API_v2/Users/list_user_notification_rules.py b/REST_API_v2/Users/list_user_notification_rules.py index 72dd2e7..dc83f96 100755 --- a/REST_API_v2/Users/list_user_notification_rules.py +++ b/REST_API_v2/Users/list_user_notification_rules.py @@ -49,8 +49,8 @@ def list_user_notification_rules(): 'include[]': INCLUDE } r = requests.get(url, headers=headers, params=payload) - print 'Status Code: {code}'.format(code=r.status_code) - print r.json() + print('Status Code: {code}'.format(code=r.status_code)) + print(r.json()) if __name__ == '__main__': list_user_notification_rules() diff --git a/REST_API_v2/Users/list_users.py b/REST_API_v2/Users/list_users.py index 7d53d52..741b98a 100755 --- a/REST_API_v2/Users/list_users.py +++ b/REST_API_v2/Users/list_users.py @@ -48,8 +48,8 @@ def list_users(): 'include[]': INCLUDE } r = requests.get(url, headers=headers, params=payload) - print 'Status Code: {code}'.format(code=r.status_code) - print r.json() + print('Status Code: {code}'.format(code=r.status_code)) + print(r.json()) if __name__ == '__main__': list_users() diff --git a/REST_API_v2/Users/update_user.py b/REST_API_v2/Users/update_user.py index 890c57b..b6d9ef5 100755 --- a/REST_API_v2/Users/update_user.py +++ b/REST_API_v2/Users/update_user.py @@ -37,7 +37,7 @@ # Update to match your chosen parameters NAME = 'Insert user name here' EMAIL = 'insert_email@here.com' -ROLE = 'user' # Can be one of admin, user, team_responder, limited_user, read_only_user # NOQA +ROLE = 'user' # Can be one of admin, user, limited_user, read_only_user # NOQA def update_user(): @@ -55,8 +55,8 @@ def update_user(): } } r = requests.put(url, headers=headers, data=json.dumps(payload)) - print 'Status Code: {code}'.format(code=r.status_code) - print r.json() + print('Status Code: {code}'.format(code=r.status_code)) + print(r.json()) if __name__ == '__main__': update_user() diff --git a/REST_API_v2/Users/update_user_contact_method.py b/REST_API_v2/Users/update_user_contact_method.py index ad9fa9f..03c75ad 100755 --- a/REST_API_v2/Users/update_user_contact_method.py +++ b/REST_API_v2/Users/update_user_contact_method.py @@ -59,8 +59,8 @@ def update_user_contact_method(): } } r = requests.put(url, headers=headers, data=json.dumps(payload)) - print 'Status Code: {code}'.format(code=r.status_code) - print r.json() + print('Status Code: {code}'.format(code=r.status_code)) + print(r.json()) if __name__ == '__main__': update_user_contact_method() diff --git a/REST_API_v2/Users/update_user_notification_rule.py b/REST_API_v2/Users/update_user_notification_rule.py index 4c6c1c8..3370f94 100755 --- a/REST_API_v2/Users/update_user_notification_rule.py +++ b/REST_API_v2/Users/update_user_notification_rule.py @@ -62,8 +62,8 @@ def update_user_notification_rule(): } } r = requests.put(url, headers=headers, data=json.dumps(payload)) - print 'Status Code: {code}'.format(code=r.status_code) - print r.json() + print('Status Code: {code}'.format(code=r.status_code)) + print(r.json()) if __name__ == '__main__': update_user_notification_rule() diff --git a/REST_API_v2/Vendors/get_vendor.py b/REST_API_v2/Vendors/get_vendor.py index c4afea9..27f1904 100755 --- a/REST_API_v2/Vendors/get_vendor.py +++ b/REST_API_v2/Vendors/get_vendor.py @@ -41,8 +41,8 @@ def get_vendor(): 'Authorization': 'Token token={token}'.format(token=API_KEY) } r = requests.get(url, headers=headers) - print 'Status Code: {code}'.format(code=r.status_code) - print r.json() + print('Status Code: {code}'.format(code=r.status_code)) + print('r.json()) if __name__ == '__main__': get_vendor() diff --git a/REST_API_v2/Vendors/list_vendors.py b/REST_API_v2/Vendors/list_vendors.py index a7b7900..5e74323 100755 --- a/REST_API_v2/Vendors/list_vendors.py +++ b/REST_API_v2/Vendors/list_vendors.py @@ -38,8 +38,8 @@ def list_vendors(): 'Authorization': 'Token token={token}'.format(token=API_KEY) } r = requests.get(url, headers=headers) - print 'Status Code: {code}'.format(code=r.status_code) - print r.json() + print('Status Code: {code}'.format(code=r.status_code)) + print(r.json()) if __name__ == '__main__': list_vendors()