From c0f6811211074971b5695eb694dbfd31eb034a77 Mon Sep 17 00:00:00 2001 From: prupke2 <31414339+prupke2@users.noreply.github.com> Date: Thu, 16 Aug 2018 13:14:18 -0400 Subject: [PATCH 1/9] Adding create_maintenance_window_all_services Python 3 script that adds a maintenance window on all services --- .../create_maintenance_window_all_services | 157 ++++++++++++++++++ 1 file changed, 157 insertions(+) create mode 100644 REST_API_v2/MaintenanceWindows/create_maintenance_window_all_services diff --git a/REST_API_v2/MaintenanceWindows/create_maintenance_window_all_services b/REST_API_v2/MaintenanceWindows/create_maintenance_window_all_services new file mode 100644 index 0000000..e975c10 --- /dev/null +++ b/REST_API_v2/MaintenanceWindows/create_maintenance_window_all_services @@ -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) From 5c903b9b690d9e0d93866c35111cfe288fb3c1ed Mon Sep 17 00:00:00 2001 From: prupke2 <31414339+prupke2@users.noreply.github.com> Date: Thu, 16 Aug 2018 13:33:12 -0400 Subject: [PATCH 2/9] Added end_all_maintenance_windows.py Script to end all ongoing maintenance windows in your subdomain. --- .../end_all_maintenance_windows | 140 ++++++++++++++++++ 1 file changed, 140 insertions(+) create mode 100644 REST_API_v2/MaintenanceWindows/end_all_maintenance_windows diff --git a/REST_API_v2/MaintenanceWindows/end_all_maintenance_windows b/REST_API_v2/MaintenanceWindows/end_all_maintenance_windows new file mode 100644 index 0000000..9d5e8a1 --- /dev/null +++ b/REST_API_v2/MaintenanceWindows/end_all_maintenance_windows @@ -0,0 +1,140 @@ +#!/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 will search for all currently active maintenance windows on all +# services and end them. It does not support pagination, so it is limited to 100 +# maintenance windows (by default it will sort by name) +# +# REQUIRED: API_KEY, EMAIL +# +# OPTIONAL: You can set the END_TIME to a future date if required. +# +# # Date format: '2018-09-30T14:00:00' +# +# There are also other parameters for filtering maintenance windows. +# +# -------------------------------------------------------------------------------- + +import requests +import datetime + +current_time = datetime.datetime.now() + +# Update to match your v2 REST API key +API_KEY = '' + +# Update to match your login email +EMAIL = '' + +# Update to match your chosen parameters +# You can also specify a different end date here instead (Date format: '2018-09-30T14:00:00') +END_TIME = current_time +TEAM_IDS = [] +SERVICE_IDS = [] +INCLUDE = [] +FILTER = 'ongoing' +QUERY = '' + + +def get_maintenance_windows(): + url = 'https://api.pagerduty.com/maintenance_windows?total=true' + headers = { + 'Accept': 'application/vnd.pagerduty+json;version=2', + 'Authorization': 'Token token={token}'.format(token=API_KEY) + } + payload = { + 'team_ids[]': TEAM_IDS, + 'service_ids[]': SERVICE_IDS, + 'include[]': INCLUDE, + 'filter': FILTER, + 'query': QUERY + } + maintenance_windows_ids = [] + r = requests.get(url, headers=headers, params=payload) + print('Getting ongoing maintenance windows...') + 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 maintenance windows.") + print("\tPlease ensure that the login email and v2 REST API key in this script are correct.") + print(r.text) + return maintenance_windows_ids + maintenance_list = r.json() + ids = maintenance_list['maintenance_windows'] + total = int(maintenance_list['total']) + + if total > 0: + if total == 1: + print("\t1 ongoing maintenance window found:") + if total == 2: + print("\t", total, 'ongoing maintenance windows found') + for maintenance_window in range(total): + maintenance_windows_ids.append(ids[maintenance_window]['id']) + print("\t", maintenance_windows_ids) + else: + print("No ongoing maintenance windows found") + return maintenance_windows_ids + + +def end_maintenance_window(MAINTENANCE_WINDOWS): + if len(MAINTENANCE_WINDOWS) == 1: + print("Ending maintenance window...") + else: + print("Ending maintenance windows...") + headers = { + 'Accept': 'application/vnd.pagerduty+json;version=2', + 'Authorization': 'Token token={token}'.format(token=API_KEY) + } + for maintenance_window in range(len(MAINTENANCE_WINDOWS)): + url = 'https://api.pagerduty.com/maintenance_windows/{id}'.format(id=MAINTENANCE_WINDOWS[maintenance_window]) + print("\t", str(MAINTENANCE_WINDOWS[maintenance_window])) + r = requests.delete(url, headers=headers) + print('\tStatus Code: {code}'.format(code=r.status_code)) + if r.status_code == 204: + print('\tMaintenance window ended successfully!') + else: + print("\tThere was an error ending this maintenance window") + print("\tPlease ensure that the login email and v2 REST API key in this script have proper permissions") + return maintenance_windows_ids + print(r.text) + +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: + MAINTENANCE_WINDOWS = get_maintenance_windows() + if MAINTENANCE_WINDOWS != []: + end_maintenance_window(MAINTENANCE_WINDOWS) + + +# ----------------------------------------------------------------------- + From 3f31569b6f08f81c05bf2c073e6e2fa1341bf52c Mon Sep 17 00:00:00 2001 From: prupke2 <31414339+prupke2@users.noreply.github.com> Date: Thu, 16 Aug 2018 13:54:22 -0400 Subject: [PATCH 3/9] Rename end_all_maintenance_windows to end_all_maintenance_windows.py --- ...end_all_maintenance_windows => end_all_maintenance_windows.py} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename REST_API_v2/MaintenanceWindows/{end_all_maintenance_windows => end_all_maintenance_windows.py} (100%) diff --git a/REST_API_v2/MaintenanceWindows/end_all_maintenance_windows b/REST_API_v2/MaintenanceWindows/end_all_maintenance_windows.py similarity index 100% rename from REST_API_v2/MaintenanceWindows/end_all_maintenance_windows rename to REST_API_v2/MaintenanceWindows/end_all_maintenance_windows.py From c04c7126f715548451a238a18d443d65dcde7583 Mon Sep 17 00:00:00 2001 From: prupke2 <31414339+prupke2@users.noreply.github.com> Date: Thu, 16 Aug 2018 13:55:05 -0400 Subject: [PATCH 4/9] Rename create_maintenance_window_all_services to create_maintenance_window_all_services.py --- ...dow_all_services => create_maintenance_window_all_services.py} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename REST_API_v2/MaintenanceWindows/{create_maintenance_window_all_services => create_maintenance_window_all_services.py} (100%) diff --git a/REST_API_v2/MaintenanceWindows/create_maintenance_window_all_services b/REST_API_v2/MaintenanceWindows/create_maintenance_window_all_services.py similarity index 100% rename from REST_API_v2/MaintenanceWindows/create_maintenance_window_all_services rename to REST_API_v2/MaintenanceWindows/create_maintenance_window_all_services.py From 345ea3d86e4580a74f9e84f67b40d201cac34b0d Mon Sep 17 00:00:00 2001 From: RAHUL DIVGAN Date: Mon, 24 Sep 2018 12:19:47 -0700 Subject: [PATCH 5/9] Escalation policy schema corrected for Service update API --- REST_API_v2/Services/update_service.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/REST_API_v2/Services/update_service.py b/REST_API_v2/Services/update_service.py index d428eef..5a529eb 100755 --- a/REST_API_v2/Services/update_service.py +++ b/REST_API_v2/Services/update_service.py @@ -54,7 +54,10 @@ 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 From 307a0a17405086049c21bfb4d8da4a1e67cb9af9 Mon Sep 17 00:00:00 2001 From: alireza Date: Sat, 10 Nov 2018 19:17:31 -0800 Subject: [PATCH 6/9] created two sub folder two support python v2 and v3 --- .../EVENTS_API_V1}/Ack/ack_incident.py | 0 .../Resolve/resolve_incident.py | 0 .../Trigger/trigger_with_incident_key.py | 0 .../Trigger/trigger_without_incident_key.py | 0 .../EVENTS_API_v2}/ack/ack_incident.py | 0 .../resolve/resolve_incident.py | 0 .../trigger/trigger_with_incident_key.py | 0 .../trigger/trigger_without_incident_key.py | 0 .../REST_API_v2}/Abilities/list_abilities.py | 0 .../REST_API_v2}/Abilities/test_ability.py | 0 .../REST_API_v2}/AddOns/delete_addon.py | 0 .../REST_API_v2}/AddOns/get_addon.py | 0 .../REST_API_v2}/AddOns/install_addon.py | 0 .../AddOns/list_installed_addons.py | 0 .../REST_API_v2}/AddOns/update_addon.py | 0 .../create_escalation_policy.py | 0 .../delete_escalation_policy.py | 0 .../get_escalation_policy.py | 0 .../list_escalation_policies.py | 0 .../update_escalation_policy.py | 0 .../Incidents/create_incident_note.py | 0 .../REST_API_v2}/Incidents/get_incident.py | 0 .../Incidents/list_incident_log_entries.py | 0 .../Incidents/list_incident_notes.py | 0 .../REST_API_v2}/Incidents/list_incidents.py | 0 .../Incidents/manage_incidents.py | 0 .../REST_API_v2}/Incidents/snooze_incident.py | 0 .../Incidents/trigger_incident.py | 0 .../REST_API_v2}/Incidents/update_incident.py | 0 .../REST_API_v2}/LogEntries/get_log_entry.py | 0 .../LogEntries/list_log_entries.py | 0 .../create_maintenance_window.py | 0 .../delete_or_end_maintenance_window.py | 0 .../end_all_maintenance_windows.py | 140 +++++++++++++++++ .../get_maintenance_window.py | 0 .../list_maintenance_windows.py | 0 .../update_maintenance_window.py | 0 .../Notifications/list_notifications.py | 0 .../REST_API_v2}/OnCalls/list_oncalls.py | 0 .../REST_API_v2}/Schedules/create_override.py | 0 .../REST_API_v2}/Schedules/create_schedule.py | 0 .../REST_API_v2}/Schedules/delete_override.py | 0 .../REST_API_v2}/Schedules/delete_schedule.py | 0 .../REST_API_v2}/Schedules/get_schedule.py | 0 .../Schedules/list_oncall_users.py | 0 .../REST_API_v2}/Schedules/list_overrides.py | 0 .../REST_API_v2}/Schedules/list_schedules.py | 0 .../Schedules/preview_schedule.py | 0 .../REST_API_v2}/Schedules/update_schedule.py | 0 .../Services/create_integration.py | 0 .../REST_API_v2}/Services/create_service.py | 0 .../REST_API_v2}/Services/delete_service.py | 0 .../REST_API_v2}/Services/get_integration.py | 0 .../REST_API_v2}/Services/get_service.py | 0 .../REST_API_v2}/Services/list_services.py | 0 .../Services/update_integration.py | 0 .../REST_API_v2}/Services/update_service.py | 0 .../Teams/add_escalation_policy_to_team.py | 0 .../REST_API_v2}/Teams/add_user_to_team.py | 0 .../REST_API_v2}/Teams/create_team.py | 0 .../REST_API_v2}/Teams/delete_team.py | 0 .../REST_API_v2}/Teams/get_team.py | 0 .../REST_API_v2}/Teams/list_teams.py | 0 .../remove_escalation_policy_from_team.py | 0 .../Teams/remove_user_from_team.py | 0 .../REST_API_v2}/Teams/update_team.py | 0 .../REST_API_v2}/Users/create_user.py | 0 .../Users/create_user_contact_method.py | 0 .../Users/create_user_notification_rule.py | 0 .../REST_API_v2}/Users/delete_user.py | 0 .../Users/delete_user_contact_method.py | 0 .../Users/delete_user_notification_rule.py | 0 .../REST_API_v2}/Users/get_user.py | 0 .../Users/get_user_contact_method.py | 0 .../Users/get_user_notification_rule.py | 0 .../Users/list_user_contact_methods.py | 0 .../Users/list_user_notification_rules.py | 0 .../REST_API_v2}/Users/list_users.py | 0 .../REST_API_v2}/Users/update_user.py | 0 .../Users/update_user_contact_method.py | 0 .../Users/update_user_notification_rule.py | 0 .../REST_API_v2}/Vendors/get_vendor.py | 0 .../REST_API_v2}/Vendors/list_vendors.py | 0 python_v3/EVENTS_API_V1/Ack/ack_incident.py | 29 ++++ .../EVENTS_API_V1/Resolve/resolve_incident.py | 29 ++++ .../Trigger/trigger_with_incident_key.py | 29 ++++ .../Trigger/trigger_without_incident_key.py | 27 ++++ python_v3/EVENTS_API_v2/ack/ack_incident.py | 33 ++++ .../EVENTS_API_v2/resolve/resolve_incident.py | 33 ++++ .../trigger/trigger_with_incident_key.py | 38 +++++ .../trigger/trigger_without_incident_key.py | 36 +++++ .../REST_API_v2/Abilities/list_abilities.py | 45 ++++++ .../REST_API_v2/Abilities/test_ability.py | 48 ++++++ python_v3/REST_API_v2/AddOns/delete_addon.py | 48 ++++++ python_v3/REST_API_v2/AddOns/get_addon.py | 48 ++++++ python_v3/REST_API_v2/AddOns/install_addon.py | 61 ++++++++ .../AddOns/list_installed_addons.py | 55 +++++++ python_v3/REST_API_v2/AddOns/update_addon.py | 64 ++++++++ .../create_escalation_policy.py | 73 +++++++++ .../delete_escalation_policy.py | 48 ++++++ .../get_escalation_policy.py | 54 +++++++ .../list_escalation_policies.py | 59 +++++++ .../update_escalation_policy.py | 80 ++++++++++ .../Incidents/create_incident_note.py | 62 ++++++++ .../REST_API_v2/Incidents/get_incident.py | 48 ++++++ .../Incidents/list_incident_log_entries.py | 58 +++++++ .../Incidents/list_incident_notes.py | 50 ++++++ .../REST_API_v2/Incidents/list_incidents.py | 73 +++++++++ .../REST_API_v2/Incidents/manage_incidents.py | 88 +++++++++++ .../REST_API_v2/Incidents/snooze_incident.py | 61 ++++++++ .../REST_API_v2/Incidents/trigger_incident.py | 69 +++++++++ .../REST_API_v2/Incidents/update_incident.py | 70 +++++++++ .../REST_API_v2/LogEntries/get_log_entry.py | 54 +++++++ .../LogEntries/list_log_entries.py | 61 ++++++++ .../create_maintenance_window.py | 72 +++++++++ .../delete_or_end_maintenance_window.py | 48 ++++++ .../end_all_maintenance_windows.py | 0 .../get_maintenance_window.py | 54 +++++++ .../list_maintenance_windows.py | 59 +++++++ .../update_maintenance_window.py | 71 +++++++++ .../Notifications/list_notifications.py | 59 +++++++ python_v3/REST_API_v2/OnCalls/list_oncalls.py | 65 ++++++++ .../REST_API_v2/Schedules/create_override.py | 67 ++++++++ .../REST_API_v2/Schedules/create_schedule.py | 134 ++++++++++++++++ .../REST_API_v2/Schedules/delete_override.py | 52 +++++++ .../REST_API_v2/Schedules/delete_schedule.py | 48 ++++++ .../REST_API_v2/Schedules/get_schedule.py | 60 +++++++ .../Schedules/list_oncall_users.py | 59 +++++++ .../REST_API_v2/Schedules/list_overrides.py | 62 ++++++++ .../REST_API_v2/Schedules/list_schedules.py | 51 ++++++ .../REST_API_v2/Schedules/preview_schedule.py | 146 ++++++++++++++++++ .../REST_API_v2/Schedules/update_schedule.py | 145 +++++++++++++++++ .../Services/create_integration.py | 70 +++++++++ .../REST_API_v2/Services/create_service.py | 103 ++++++++++++ .../REST_API_v2/Services/delete_service.py | 48 ++++++ .../REST_API_v2/Services/get_integration.py | 58 +++++++ python_v3/REST_API_v2/Services/get_service.py | 54 +++++++ .../REST_API_v2/Services/list_services.py | 59 +++++++ .../Services/update_integration.py | 64 ++++++++ .../REST_API_v2/Services/update_service.py | 68 ++++++++ .../Teams/add_escalation_policy_to_team.py | 51 ++++++ .../REST_API_v2/Teams/add_user_to_team.py | 53 +++++++ python_v3/REST_API_v2/Teams/create_team.py | 59 +++++++ python_v3/REST_API_v2/Teams/delete_team.py | 48 ++++++ python_v3/REST_API_v2/Teams/get_team.py | 48 ++++++ python_v3/REST_API_v2/Teams/list_teams.py | 51 ++++++ .../remove_escalation_policy_from_team.py | 50 ++++++ .../Teams/remove_user_from_team.py | 52 +++++++ python_v3/REST_API_v2/Teams/update_team.py | 60 +++++++ python_v3/REST_API_v2/Users/create_user.py | 64 ++++++++ .../Users/create_user_contact_method.py | 62 ++++++++ .../Users/create_user_notification_rule.py | 69 +++++++++ python_v3/REST_API_v2/Users/delete_user.py | 48 ++++++ .../Users/delete_user_contact_method.py | 52 +++++++ .../Users/delete_user_notification_rule.py | 50 ++++++ python_v3/REST_API_v2/Users/get_user.py | 54 +++++++ .../Users/get_user_contact_method.py | 52 +++++++ .../Users/get_user_notification_rule.py | 56 +++++++ .../Users/list_user_contact_methods.py | 48 ++++++ .../Users/list_user_notification_rules.py | 56 +++++++ python_v3/REST_API_v2/Users/list_users.py | 55 +++++++ python_v3/REST_API_v2/Users/update_user.py | 62 ++++++++ .../Users/update_user_contact_method.py | 66 ++++++++ .../Users/update_user_notification_rule.py | 69 +++++++++ python_v3/REST_API_v2/Vendors/get_vendor.py | 48 ++++++ python_v3/REST_API_v2/Vendors/list_vendors.py | 45 ++++++ 166 files changed, 4975 insertions(+) rename {EVENTS_API_V1 => python_v2/EVENTS_API_V1}/Ack/ack_incident.py (100%) rename {EVENTS_API_V1 => python_v2/EVENTS_API_V1}/Resolve/resolve_incident.py (100%) rename {EVENTS_API_V1 => python_v2/EVENTS_API_V1}/Trigger/trigger_with_incident_key.py (100%) rename {EVENTS_API_V1 => python_v2/EVENTS_API_V1}/Trigger/trigger_without_incident_key.py (100%) rename {EVENTS_API_v2 => python_v2/EVENTS_API_v2}/ack/ack_incident.py (100%) rename {EVENTS_API_v2 => python_v2/EVENTS_API_v2}/resolve/resolve_incident.py (100%) rename {EVENTS_API_v2 => python_v2/EVENTS_API_v2}/trigger/trigger_with_incident_key.py (100%) rename {EVENTS_API_v2 => python_v2/EVENTS_API_v2}/trigger/trigger_without_incident_key.py (100%) rename {REST_API_v2 => python_v2/REST_API_v2}/Abilities/list_abilities.py (100%) rename {REST_API_v2 => python_v2/REST_API_v2}/Abilities/test_ability.py (100%) rename {REST_API_v2 => python_v2/REST_API_v2}/AddOns/delete_addon.py (100%) rename {REST_API_v2 => python_v2/REST_API_v2}/AddOns/get_addon.py (100%) rename {REST_API_v2 => python_v2/REST_API_v2}/AddOns/install_addon.py (100%) rename {REST_API_v2 => python_v2/REST_API_v2}/AddOns/list_installed_addons.py (100%) rename {REST_API_v2 => python_v2/REST_API_v2}/AddOns/update_addon.py (100%) rename {REST_API_v2 => python_v2/REST_API_v2}/EscalationPolicies/create_escalation_policy.py (100%) rename {REST_API_v2 => python_v2/REST_API_v2}/EscalationPolicies/delete_escalation_policy.py (100%) rename {REST_API_v2 => python_v2/REST_API_v2}/EscalationPolicies/get_escalation_policy.py (100%) rename {REST_API_v2 => python_v2/REST_API_v2}/EscalationPolicies/list_escalation_policies.py (100%) rename {REST_API_v2 => python_v2/REST_API_v2}/EscalationPolicies/update_escalation_policy.py (100%) rename {REST_API_v2 => python_v2/REST_API_v2}/Incidents/create_incident_note.py (100%) rename {REST_API_v2 => python_v2/REST_API_v2}/Incidents/get_incident.py (100%) rename {REST_API_v2 => python_v2/REST_API_v2}/Incidents/list_incident_log_entries.py (100%) rename {REST_API_v2 => python_v2/REST_API_v2}/Incidents/list_incident_notes.py (100%) rename {REST_API_v2 => python_v2/REST_API_v2}/Incidents/list_incidents.py (100%) rename {REST_API_v2 => python_v2/REST_API_v2}/Incidents/manage_incidents.py (100%) rename {REST_API_v2 => python_v2/REST_API_v2}/Incidents/snooze_incident.py (100%) rename {REST_API_v2 => python_v2/REST_API_v2}/Incidents/trigger_incident.py (100%) rename {REST_API_v2 => python_v2/REST_API_v2}/Incidents/update_incident.py (100%) rename {REST_API_v2 => python_v2/REST_API_v2}/LogEntries/get_log_entry.py (100%) rename {REST_API_v2 => python_v2/REST_API_v2}/LogEntries/list_log_entries.py (100%) rename {REST_API_v2 => python_v2/REST_API_v2}/MaintenanceWindows/create_maintenance_window.py (100%) rename {REST_API_v2 => python_v2/REST_API_v2}/MaintenanceWindows/delete_or_end_maintenance_window.py (100%) create mode 100644 python_v2/REST_API_v2/MaintenanceWindows/end_all_maintenance_windows.py rename {REST_API_v2 => python_v2/REST_API_v2}/MaintenanceWindows/get_maintenance_window.py (100%) rename {REST_API_v2 => python_v2/REST_API_v2}/MaintenanceWindows/list_maintenance_windows.py (100%) rename {REST_API_v2 => python_v2/REST_API_v2}/MaintenanceWindows/update_maintenance_window.py (100%) rename {REST_API_v2 => python_v2/REST_API_v2}/Notifications/list_notifications.py (100%) rename {REST_API_v2 => python_v2/REST_API_v2}/OnCalls/list_oncalls.py (100%) rename {REST_API_v2 => python_v2/REST_API_v2}/Schedules/create_override.py (100%) rename {REST_API_v2 => python_v2/REST_API_v2}/Schedules/create_schedule.py (100%) rename {REST_API_v2 => python_v2/REST_API_v2}/Schedules/delete_override.py (100%) rename {REST_API_v2 => python_v2/REST_API_v2}/Schedules/delete_schedule.py (100%) rename {REST_API_v2 => python_v2/REST_API_v2}/Schedules/get_schedule.py (100%) rename {REST_API_v2 => python_v2/REST_API_v2}/Schedules/list_oncall_users.py (100%) rename {REST_API_v2 => python_v2/REST_API_v2}/Schedules/list_overrides.py (100%) rename {REST_API_v2 => python_v2/REST_API_v2}/Schedules/list_schedules.py (100%) rename {REST_API_v2 => python_v2/REST_API_v2}/Schedules/preview_schedule.py (100%) rename {REST_API_v2 => python_v2/REST_API_v2}/Schedules/update_schedule.py (100%) rename {REST_API_v2 => python_v2/REST_API_v2}/Services/create_integration.py (100%) rename {REST_API_v2 => python_v2/REST_API_v2}/Services/create_service.py (100%) rename {REST_API_v2 => python_v2/REST_API_v2}/Services/delete_service.py (100%) rename {REST_API_v2 => python_v2/REST_API_v2}/Services/get_integration.py (100%) rename {REST_API_v2 => python_v2/REST_API_v2}/Services/get_service.py (100%) rename {REST_API_v2 => python_v2/REST_API_v2}/Services/list_services.py (100%) rename {REST_API_v2 => python_v2/REST_API_v2}/Services/update_integration.py (100%) rename {REST_API_v2 => python_v2/REST_API_v2}/Services/update_service.py (100%) rename {REST_API_v2 => python_v2/REST_API_v2}/Teams/add_escalation_policy_to_team.py (100%) rename {REST_API_v2 => python_v2/REST_API_v2}/Teams/add_user_to_team.py (100%) rename {REST_API_v2 => python_v2/REST_API_v2}/Teams/create_team.py (100%) rename {REST_API_v2 => python_v2/REST_API_v2}/Teams/delete_team.py (100%) rename {REST_API_v2 => python_v2/REST_API_v2}/Teams/get_team.py (100%) rename {REST_API_v2 => python_v2/REST_API_v2}/Teams/list_teams.py (100%) rename {REST_API_v2 => python_v2/REST_API_v2}/Teams/remove_escalation_policy_from_team.py (100%) rename {REST_API_v2 => python_v2/REST_API_v2}/Teams/remove_user_from_team.py (100%) rename {REST_API_v2 => python_v2/REST_API_v2}/Teams/update_team.py (100%) rename {REST_API_v2 => python_v2/REST_API_v2}/Users/create_user.py (100%) rename {REST_API_v2 => python_v2/REST_API_v2}/Users/create_user_contact_method.py (100%) rename {REST_API_v2 => python_v2/REST_API_v2}/Users/create_user_notification_rule.py (100%) rename {REST_API_v2 => python_v2/REST_API_v2}/Users/delete_user.py (100%) rename {REST_API_v2 => python_v2/REST_API_v2}/Users/delete_user_contact_method.py (100%) rename {REST_API_v2 => python_v2/REST_API_v2}/Users/delete_user_notification_rule.py (100%) rename {REST_API_v2 => python_v2/REST_API_v2}/Users/get_user.py (100%) rename {REST_API_v2 => python_v2/REST_API_v2}/Users/get_user_contact_method.py (100%) rename {REST_API_v2 => python_v2/REST_API_v2}/Users/get_user_notification_rule.py (100%) rename {REST_API_v2 => python_v2/REST_API_v2}/Users/list_user_contact_methods.py (100%) rename {REST_API_v2 => python_v2/REST_API_v2}/Users/list_user_notification_rules.py (100%) rename {REST_API_v2 => python_v2/REST_API_v2}/Users/list_users.py (100%) rename {REST_API_v2 => python_v2/REST_API_v2}/Users/update_user.py (100%) rename {REST_API_v2 => python_v2/REST_API_v2}/Users/update_user_contact_method.py (100%) rename {REST_API_v2 => python_v2/REST_API_v2}/Users/update_user_notification_rule.py (100%) rename {REST_API_v2 => python_v2/REST_API_v2}/Vendors/get_vendor.py (100%) rename {REST_API_v2 => python_v2/REST_API_v2}/Vendors/list_vendors.py (100%) create mode 100755 python_v3/EVENTS_API_V1/Ack/ack_incident.py create mode 100755 python_v3/EVENTS_API_V1/Resolve/resolve_incident.py create mode 100755 python_v3/EVENTS_API_V1/Trigger/trigger_with_incident_key.py create mode 100755 python_v3/EVENTS_API_V1/Trigger/trigger_without_incident_key.py create mode 100755 python_v3/EVENTS_API_v2/ack/ack_incident.py create mode 100755 python_v3/EVENTS_API_v2/resolve/resolve_incident.py create mode 100644 python_v3/EVENTS_API_v2/trigger/trigger_with_incident_key.py create mode 100644 python_v3/EVENTS_API_v2/trigger/trigger_without_incident_key.py create mode 100755 python_v3/REST_API_v2/Abilities/list_abilities.py create mode 100755 python_v3/REST_API_v2/Abilities/test_ability.py create mode 100755 python_v3/REST_API_v2/AddOns/delete_addon.py create mode 100755 python_v3/REST_API_v2/AddOns/get_addon.py create mode 100755 python_v3/REST_API_v2/AddOns/install_addon.py create mode 100755 python_v3/REST_API_v2/AddOns/list_installed_addons.py create mode 100755 python_v3/REST_API_v2/AddOns/update_addon.py create mode 100755 python_v3/REST_API_v2/EscalationPolicies/create_escalation_policy.py create mode 100755 python_v3/REST_API_v2/EscalationPolicies/delete_escalation_policy.py create mode 100755 python_v3/REST_API_v2/EscalationPolicies/get_escalation_policy.py create mode 100755 python_v3/REST_API_v2/EscalationPolicies/list_escalation_policies.py create mode 100755 python_v3/REST_API_v2/EscalationPolicies/update_escalation_policy.py create mode 100755 python_v3/REST_API_v2/Incidents/create_incident_note.py create mode 100755 python_v3/REST_API_v2/Incidents/get_incident.py create mode 100755 python_v3/REST_API_v2/Incidents/list_incident_log_entries.py create mode 100755 python_v3/REST_API_v2/Incidents/list_incident_notes.py create mode 100755 python_v3/REST_API_v2/Incidents/list_incidents.py create mode 100755 python_v3/REST_API_v2/Incidents/manage_incidents.py create mode 100755 python_v3/REST_API_v2/Incidents/snooze_incident.py create mode 100644 python_v3/REST_API_v2/Incidents/trigger_incident.py create mode 100755 python_v3/REST_API_v2/Incidents/update_incident.py create mode 100755 python_v3/REST_API_v2/LogEntries/get_log_entry.py create mode 100755 python_v3/REST_API_v2/LogEntries/list_log_entries.py create mode 100755 python_v3/REST_API_v2/MaintenanceWindows/create_maintenance_window.py create mode 100755 python_v3/REST_API_v2/MaintenanceWindows/delete_or_end_maintenance_window.py rename {REST_API_v2 => python_v3/REST_API_v2}/MaintenanceWindows/end_all_maintenance_windows.py (100%) create mode 100755 python_v3/REST_API_v2/MaintenanceWindows/get_maintenance_window.py create mode 100755 python_v3/REST_API_v2/MaintenanceWindows/list_maintenance_windows.py create mode 100755 python_v3/REST_API_v2/MaintenanceWindows/update_maintenance_window.py create mode 100755 python_v3/REST_API_v2/Notifications/list_notifications.py create mode 100755 python_v3/REST_API_v2/OnCalls/list_oncalls.py create mode 100755 python_v3/REST_API_v2/Schedules/create_override.py create mode 100755 python_v3/REST_API_v2/Schedules/create_schedule.py create mode 100755 python_v3/REST_API_v2/Schedules/delete_override.py create mode 100755 python_v3/REST_API_v2/Schedules/delete_schedule.py create mode 100755 python_v3/REST_API_v2/Schedules/get_schedule.py create mode 100755 python_v3/REST_API_v2/Schedules/list_oncall_users.py create mode 100755 python_v3/REST_API_v2/Schedules/list_overrides.py create mode 100755 python_v3/REST_API_v2/Schedules/list_schedules.py create mode 100755 python_v3/REST_API_v2/Schedules/preview_schedule.py create mode 100755 python_v3/REST_API_v2/Schedules/update_schedule.py create mode 100755 python_v3/REST_API_v2/Services/create_integration.py create mode 100755 python_v3/REST_API_v2/Services/create_service.py create mode 100755 python_v3/REST_API_v2/Services/delete_service.py create mode 100755 python_v3/REST_API_v2/Services/get_integration.py create mode 100755 python_v3/REST_API_v2/Services/get_service.py create mode 100755 python_v3/REST_API_v2/Services/list_services.py create mode 100755 python_v3/REST_API_v2/Services/update_integration.py create mode 100755 python_v3/REST_API_v2/Services/update_service.py create mode 100755 python_v3/REST_API_v2/Teams/add_escalation_policy_to_team.py create mode 100755 python_v3/REST_API_v2/Teams/add_user_to_team.py create mode 100755 python_v3/REST_API_v2/Teams/create_team.py create mode 100755 python_v3/REST_API_v2/Teams/delete_team.py create mode 100755 python_v3/REST_API_v2/Teams/get_team.py create mode 100755 python_v3/REST_API_v2/Teams/list_teams.py create mode 100755 python_v3/REST_API_v2/Teams/remove_escalation_policy_from_team.py create mode 100755 python_v3/REST_API_v2/Teams/remove_user_from_team.py create mode 100755 python_v3/REST_API_v2/Teams/update_team.py create mode 100755 python_v3/REST_API_v2/Users/create_user.py create mode 100755 python_v3/REST_API_v2/Users/create_user_contact_method.py create mode 100755 python_v3/REST_API_v2/Users/create_user_notification_rule.py create mode 100755 python_v3/REST_API_v2/Users/delete_user.py create mode 100755 python_v3/REST_API_v2/Users/delete_user_contact_method.py create mode 100755 python_v3/REST_API_v2/Users/delete_user_notification_rule.py create mode 100755 python_v3/REST_API_v2/Users/get_user.py create mode 100755 python_v3/REST_API_v2/Users/get_user_contact_method.py create mode 100755 python_v3/REST_API_v2/Users/get_user_notification_rule.py create mode 100755 python_v3/REST_API_v2/Users/list_user_contact_methods.py create mode 100755 python_v3/REST_API_v2/Users/list_user_notification_rules.py create mode 100755 python_v3/REST_API_v2/Users/list_users.py create mode 100755 python_v3/REST_API_v2/Users/update_user.py create mode 100755 python_v3/REST_API_v2/Users/update_user_contact_method.py create mode 100755 python_v3/REST_API_v2/Users/update_user_notification_rule.py create mode 100755 python_v3/REST_API_v2/Vendors/get_vendor.py create mode 100755 python_v3/REST_API_v2/Vendors/list_vendors.py diff --git a/EVENTS_API_V1/Ack/ack_incident.py b/python_v2/EVENTS_API_V1/Ack/ack_incident.py similarity index 100% rename from EVENTS_API_V1/Ack/ack_incident.py rename to python_v2/EVENTS_API_V1/Ack/ack_incident.py diff --git a/EVENTS_API_V1/Resolve/resolve_incident.py b/python_v2/EVENTS_API_V1/Resolve/resolve_incident.py similarity index 100% rename from EVENTS_API_V1/Resolve/resolve_incident.py rename to python_v2/EVENTS_API_V1/Resolve/resolve_incident.py diff --git a/EVENTS_API_V1/Trigger/trigger_with_incident_key.py b/python_v2/EVENTS_API_V1/Trigger/trigger_with_incident_key.py similarity index 100% rename from EVENTS_API_V1/Trigger/trigger_with_incident_key.py rename to python_v2/EVENTS_API_V1/Trigger/trigger_with_incident_key.py diff --git a/EVENTS_API_V1/Trigger/trigger_without_incident_key.py b/python_v2/EVENTS_API_V1/Trigger/trigger_without_incident_key.py similarity index 100% rename from EVENTS_API_V1/Trigger/trigger_without_incident_key.py rename to python_v2/EVENTS_API_V1/Trigger/trigger_without_incident_key.py diff --git a/EVENTS_API_v2/ack/ack_incident.py b/python_v2/EVENTS_API_v2/ack/ack_incident.py similarity index 100% rename from EVENTS_API_v2/ack/ack_incident.py rename to python_v2/EVENTS_API_v2/ack/ack_incident.py diff --git a/EVENTS_API_v2/resolve/resolve_incident.py b/python_v2/EVENTS_API_v2/resolve/resolve_incident.py similarity index 100% rename from EVENTS_API_v2/resolve/resolve_incident.py rename to python_v2/EVENTS_API_v2/resolve/resolve_incident.py diff --git a/EVENTS_API_v2/trigger/trigger_with_incident_key.py b/python_v2/EVENTS_API_v2/trigger/trigger_with_incident_key.py similarity index 100% rename from EVENTS_API_v2/trigger/trigger_with_incident_key.py rename to python_v2/EVENTS_API_v2/trigger/trigger_with_incident_key.py diff --git a/EVENTS_API_v2/trigger/trigger_without_incident_key.py b/python_v2/EVENTS_API_v2/trigger/trigger_without_incident_key.py similarity index 100% rename from EVENTS_API_v2/trigger/trigger_without_incident_key.py rename to python_v2/EVENTS_API_v2/trigger/trigger_without_incident_key.py diff --git a/REST_API_v2/Abilities/list_abilities.py b/python_v2/REST_API_v2/Abilities/list_abilities.py similarity index 100% rename from REST_API_v2/Abilities/list_abilities.py rename to python_v2/REST_API_v2/Abilities/list_abilities.py diff --git a/REST_API_v2/Abilities/test_ability.py b/python_v2/REST_API_v2/Abilities/test_ability.py similarity index 100% rename from REST_API_v2/Abilities/test_ability.py rename to python_v2/REST_API_v2/Abilities/test_ability.py diff --git a/REST_API_v2/AddOns/delete_addon.py b/python_v2/REST_API_v2/AddOns/delete_addon.py similarity index 100% rename from REST_API_v2/AddOns/delete_addon.py rename to python_v2/REST_API_v2/AddOns/delete_addon.py diff --git a/REST_API_v2/AddOns/get_addon.py b/python_v2/REST_API_v2/AddOns/get_addon.py similarity index 100% rename from REST_API_v2/AddOns/get_addon.py rename to python_v2/REST_API_v2/AddOns/get_addon.py diff --git a/REST_API_v2/AddOns/install_addon.py b/python_v2/REST_API_v2/AddOns/install_addon.py similarity index 100% rename from REST_API_v2/AddOns/install_addon.py rename to python_v2/REST_API_v2/AddOns/install_addon.py diff --git a/REST_API_v2/AddOns/list_installed_addons.py b/python_v2/REST_API_v2/AddOns/list_installed_addons.py similarity index 100% rename from REST_API_v2/AddOns/list_installed_addons.py rename to python_v2/REST_API_v2/AddOns/list_installed_addons.py diff --git a/REST_API_v2/AddOns/update_addon.py b/python_v2/REST_API_v2/AddOns/update_addon.py similarity index 100% rename from REST_API_v2/AddOns/update_addon.py rename to python_v2/REST_API_v2/AddOns/update_addon.py diff --git a/REST_API_v2/EscalationPolicies/create_escalation_policy.py b/python_v2/REST_API_v2/EscalationPolicies/create_escalation_policy.py similarity index 100% rename from REST_API_v2/EscalationPolicies/create_escalation_policy.py rename to python_v2/REST_API_v2/EscalationPolicies/create_escalation_policy.py diff --git a/REST_API_v2/EscalationPolicies/delete_escalation_policy.py b/python_v2/REST_API_v2/EscalationPolicies/delete_escalation_policy.py similarity index 100% rename from REST_API_v2/EscalationPolicies/delete_escalation_policy.py rename to python_v2/REST_API_v2/EscalationPolicies/delete_escalation_policy.py diff --git a/REST_API_v2/EscalationPolicies/get_escalation_policy.py b/python_v2/REST_API_v2/EscalationPolicies/get_escalation_policy.py similarity index 100% rename from REST_API_v2/EscalationPolicies/get_escalation_policy.py rename to python_v2/REST_API_v2/EscalationPolicies/get_escalation_policy.py diff --git a/REST_API_v2/EscalationPolicies/list_escalation_policies.py b/python_v2/REST_API_v2/EscalationPolicies/list_escalation_policies.py similarity index 100% rename from REST_API_v2/EscalationPolicies/list_escalation_policies.py rename to python_v2/REST_API_v2/EscalationPolicies/list_escalation_policies.py diff --git a/REST_API_v2/EscalationPolicies/update_escalation_policy.py b/python_v2/REST_API_v2/EscalationPolicies/update_escalation_policy.py similarity index 100% rename from REST_API_v2/EscalationPolicies/update_escalation_policy.py rename to python_v2/REST_API_v2/EscalationPolicies/update_escalation_policy.py diff --git a/REST_API_v2/Incidents/create_incident_note.py b/python_v2/REST_API_v2/Incidents/create_incident_note.py similarity index 100% rename from REST_API_v2/Incidents/create_incident_note.py rename to python_v2/REST_API_v2/Incidents/create_incident_note.py diff --git a/REST_API_v2/Incidents/get_incident.py b/python_v2/REST_API_v2/Incidents/get_incident.py similarity index 100% rename from REST_API_v2/Incidents/get_incident.py rename to python_v2/REST_API_v2/Incidents/get_incident.py diff --git a/REST_API_v2/Incidents/list_incident_log_entries.py b/python_v2/REST_API_v2/Incidents/list_incident_log_entries.py similarity index 100% rename from REST_API_v2/Incidents/list_incident_log_entries.py rename to python_v2/REST_API_v2/Incidents/list_incident_log_entries.py diff --git a/REST_API_v2/Incidents/list_incident_notes.py b/python_v2/REST_API_v2/Incidents/list_incident_notes.py similarity index 100% rename from REST_API_v2/Incidents/list_incident_notes.py rename to python_v2/REST_API_v2/Incidents/list_incident_notes.py diff --git a/REST_API_v2/Incidents/list_incidents.py b/python_v2/REST_API_v2/Incidents/list_incidents.py similarity index 100% rename from REST_API_v2/Incidents/list_incidents.py rename to python_v2/REST_API_v2/Incidents/list_incidents.py diff --git a/REST_API_v2/Incidents/manage_incidents.py b/python_v2/REST_API_v2/Incidents/manage_incidents.py similarity index 100% rename from REST_API_v2/Incidents/manage_incidents.py rename to python_v2/REST_API_v2/Incidents/manage_incidents.py diff --git a/REST_API_v2/Incidents/snooze_incident.py b/python_v2/REST_API_v2/Incidents/snooze_incident.py similarity index 100% rename from REST_API_v2/Incidents/snooze_incident.py rename to python_v2/REST_API_v2/Incidents/snooze_incident.py diff --git a/REST_API_v2/Incidents/trigger_incident.py b/python_v2/REST_API_v2/Incidents/trigger_incident.py similarity index 100% rename from REST_API_v2/Incidents/trigger_incident.py rename to python_v2/REST_API_v2/Incidents/trigger_incident.py diff --git a/REST_API_v2/Incidents/update_incident.py b/python_v2/REST_API_v2/Incidents/update_incident.py similarity index 100% rename from REST_API_v2/Incidents/update_incident.py rename to python_v2/REST_API_v2/Incidents/update_incident.py diff --git a/REST_API_v2/LogEntries/get_log_entry.py b/python_v2/REST_API_v2/LogEntries/get_log_entry.py similarity index 100% rename from REST_API_v2/LogEntries/get_log_entry.py rename to python_v2/REST_API_v2/LogEntries/get_log_entry.py diff --git a/REST_API_v2/LogEntries/list_log_entries.py b/python_v2/REST_API_v2/LogEntries/list_log_entries.py similarity index 100% rename from REST_API_v2/LogEntries/list_log_entries.py rename to python_v2/REST_API_v2/LogEntries/list_log_entries.py diff --git a/REST_API_v2/MaintenanceWindows/create_maintenance_window.py b/python_v2/REST_API_v2/MaintenanceWindows/create_maintenance_window.py similarity index 100% rename from REST_API_v2/MaintenanceWindows/create_maintenance_window.py rename to python_v2/REST_API_v2/MaintenanceWindows/create_maintenance_window.py diff --git a/REST_API_v2/MaintenanceWindows/delete_or_end_maintenance_window.py b/python_v2/REST_API_v2/MaintenanceWindows/delete_or_end_maintenance_window.py similarity index 100% rename from REST_API_v2/MaintenanceWindows/delete_or_end_maintenance_window.py rename to python_v2/REST_API_v2/MaintenanceWindows/delete_or_end_maintenance_window.py diff --git a/python_v2/REST_API_v2/MaintenanceWindows/end_all_maintenance_windows.py b/python_v2/REST_API_v2/MaintenanceWindows/end_all_maintenance_windows.py new file mode 100644 index 0000000..60a3907 --- /dev/null +++ b/python_v2/REST_API_v2/MaintenanceWindows/end_all_maintenance_windows.py @@ -0,0 +1,140 @@ +#!/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 will search for all currently active maintenance windows on all +# services and end them. It does not support pagination, so it is limited to 100 +# maintenance windows (by default it will sort by name) +# +# REQUIRED: API_KEY, EMAIL +# +# OPTIONAL: You can set the END_TIME to a future date if required. +# +# # Date format: '2018-09-30T14:00:00' +# +# There are also other parameters for filtering maintenance windows. +# +# -------------------------------------------------------------------------------- + +import requests +import datetime + +current_time = datetime.datetime.now() + +# Update to match your v2 REST API key +API_KEY = '' + +# Update to match your login email +EMAIL = '' + +# Update to match your chosen parameters +# You can also specify a different end date here instead (Date format: '2018-09-30T14:00:00') +END_TIME = current_time +TEAM_IDS = [] +SERVICE_IDS = [] +INCLUDE = [] +FILTER = 'ongoing' +QUERY = '' + + +def get_maintenance_windows(): + url = 'https://api.pagerduty.com/maintenance_windows?total=true' + headers = { + 'Accept': 'application/vnd.pagerduty+json;version=2', + 'Authorization': 'Token token={token}'.format(token=API_KEY) + } + payload = { + 'team_ids[]': TEAM_IDS, + 'service_ids[]': SERVICE_IDS, + 'include[]': INCLUDE, + 'filter': FILTER, + 'query': QUERY + } + maintenance_windows_ids = [] + r = requests.get(url, headers=headers, params=payload) + print'Getting ongoing maintenance windows...' + 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 maintenance windows." + print "\tPlease ensure that the login email and v2 REST API key in this script are correct." + print r.text + return maintenance_windows_ids + maintenance_list = r.json() + ids = maintenance_list['maintenance_windows'] + total = int(maintenance_list['total']) + + if total > 0: + if total == 1: + print "\t1 ongoing maintenance window found:" + if total == 2: + print "\t", total, 'ongoing maintenance windows found' + for maintenance_window in range(total): + maintenance_windows_ids.append(ids[maintenance_window]['id']) + print "\t", maintenance_windows_ids + else: + print "No ongoing maintenance windows found" + return maintenance_windows_ids + + +def end_maintenance_window(MAINTENANCE_WINDOWS): + if len(MAINTENANCE_WINDOWS) == 1: + print "Ending maintenance window..." + else: + print "Ending maintenance windows..." + headers = { + 'Accept': 'application/vnd.pagerduty+json;version=2', + 'Authorization': 'Token token={token}'.format(token=API_KEY) + } + for maintenance_window in range(len(MAINTENANCE_WINDOWS)): + url = 'https://api.pagerduty.com/maintenance_windows/{id}'.format(id=MAINTENANCE_WINDOWS[maintenance_window]) + print "\t", str(MAINTENANCE_WINDOWS[maintenance_window]) + r = requests.delete(url, headers=headers) + print '\tStatus Code: {code}'.format(code=r.status_code) + if r.status_code == 204: + print '\tMaintenance window ended successfully!' + else: + print "\tThere was an error ending this maintenance window" + print "\tPlease ensure that the login email and v2 REST API key in this script have proper permissions" + return maintenance_windows_ids + print r.text + +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: + MAINTENANCE_WINDOWS = get_maintenance_windows() + if MAINTENANCE_WINDOWS != []: + end_maintenance_window(MAINTENANCE_WINDOWS) + + +# ----------------------------------------------------------------------- + diff --git a/REST_API_v2/MaintenanceWindows/get_maintenance_window.py b/python_v2/REST_API_v2/MaintenanceWindows/get_maintenance_window.py similarity index 100% rename from REST_API_v2/MaintenanceWindows/get_maintenance_window.py rename to python_v2/REST_API_v2/MaintenanceWindows/get_maintenance_window.py diff --git a/REST_API_v2/MaintenanceWindows/list_maintenance_windows.py b/python_v2/REST_API_v2/MaintenanceWindows/list_maintenance_windows.py similarity index 100% rename from REST_API_v2/MaintenanceWindows/list_maintenance_windows.py rename to python_v2/REST_API_v2/MaintenanceWindows/list_maintenance_windows.py diff --git a/REST_API_v2/MaintenanceWindows/update_maintenance_window.py b/python_v2/REST_API_v2/MaintenanceWindows/update_maintenance_window.py similarity index 100% rename from REST_API_v2/MaintenanceWindows/update_maintenance_window.py rename to python_v2/REST_API_v2/MaintenanceWindows/update_maintenance_window.py diff --git a/REST_API_v2/Notifications/list_notifications.py b/python_v2/REST_API_v2/Notifications/list_notifications.py similarity index 100% rename from REST_API_v2/Notifications/list_notifications.py rename to python_v2/REST_API_v2/Notifications/list_notifications.py diff --git a/REST_API_v2/OnCalls/list_oncalls.py b/python_v2/REST_API_v2/OnCalls/list_oncalls.py similarity index 100% rename from REST_API_v2/OnCalls/list_oncalls.py rename to python_v2/REST_API_v2/OnCalls/list_oncalls.py diff --git a/REST_API_v2/Schedules/create_override.py b/python_v2/REST_API_v2/Schedules/create_override.py similarity index 100% rename from REST_API_v2/Schedules/create_override.py rename to python_v2/REST_API_v2/Schedules/create_override.py diff --git a/REST_API_v2/Schedules/create_schedule.py b/python_v2/REST_API_v2/Schedules/create_schedule.py similarity index 100% rename from REST_API_v2/Schedules/create_schedule.py rename to python_v2/REST_API_v2/Schedules/create_schedule.py diff --git a/REST_API_v2/Schedules/delete_override.py b/python_v2/REST_API_v2/Schedules/delete_override.py similarity index 100% rename from REST_API_v2/Schedules/delete_override.py rename to python_v2/REST_API_v2/Schedules/delete_override.py diff --git a/REST_API_v2/Schedules/delete_schedule.py b/python_v2/REST_API_v2/Schedules/delete_schedule.py similarity index 100% rename from REST_API_v2/Schedules/delete_schedule.py rename to python_v2/REST_API_v2/Schedules/delete_schedule.py diff --git a/REST_API_v2/Schedules/get_schedule.py b/python_v2/REST_API_v2/Schedules/get_schedule.py similarity index 100% rename from REST_API_v2/Schedules/get_schedule.py rename to python_v2/REST_API_v2/Schedules/get_schedule.py diff --git a/REST_API_v2/Schedules/list_oncall_users.py b/python_v2/REST_API_v2/Schedules/list_oncall_users.py similarity index 100% rename from REST_API_v2/Schedules/list_oncall_users.py rename to python_v2/REST_API_v2/Schedules/list_oncall_users.py diff --git a/REST_API_v2/Schedules/list_overrides.py b/python_v2/REST_API_v2/Schedules/list_overrides.py similarity index 100% rename from REST_API_v2/Schedules/list_overrides.py rename to python_v2/REST_API_v2/Schedules/list_overrides.py diff --git a/REST_API_v2/Schedules/list_schedules.py b/python_v2/REST_API_v2/Schedules/list_schedules.py similarity index 100% rename from REST_API_v2/Schedules/list_schedules.py rename to python_v2/REST_API_v2/Schedules/list_schedules.py diff --git a/REST_API_v2/Schedules/preview_schedule.py b/python_v2/REST_API_v2/Schedules/preview_schedule.py similarity index 100% rename from REST_API_v2/Schedules/preview_schedule.py rename to python_v2/REST_API_v2/Schedules/preview_schedule.py diff --git a/REST_API_v2/Schedules/update_schedule.py b/python_v2/REST_API_v2/Schedules/update_schedule.py similarity index 100% rename from REST_API_v2/Schedules/update_schedule.py rename to python_v2/REST_API_v2/Schedules/update_schedule.py diff --git a/REST_API_v2/Services/create_integration.py b/python_v2/REST_API_v2/Services/create_integration.py similarity index 100% rename from REST_API_v2/Services/create_integration.py rename to python_v2/REST_API_v2/Services/create_integration.py diff --git a/REST_API_v2/Services/create_service.py b/python_v2/REST_API_v2/Services/create_service.py similarity index 100% rename from REST_API_v2/Services/create_service.py rename to python_v2/REST_API_v2/Services/create_service.py diff --git a/REST_API_v2/Services/delete_service.py b/python_v2/REST_API_v2/Services/delete_service.py similarity index 100% rename from REST_API_v2/Services/delete_service.py rename to python_v2/REST_API_v2/Services/delete_service.py diff --git a/REST_API_v2/Services/get_integration.py b/python_v2/REST_API_v2/Services/get_integration.py similarity index 100% rename from REST_API_v2/Services/get_integration.py rename to python_v2/REST_API_v2/Services/get_integration.py diff --git a/REST_API_v2/Services/get_service.py b/python_v2/REST_API_v2/Services/get_service.py similarity index 100% rename from REST_API_v2/Services/get_service.py rename to python_v2/REST_API_v2/Services/get_service.py diff --git a/REST_API_v2/Services/list_services.py b/python_v2/REST_API_v2/Services/list_services.py similarity index 100% rename from REST_API_v2/Services/list_services.py rename to python_v2/REST_API_v2/Services/list_services.py diff --git a/REST_API_v2/Services/update_integration.py b/python_v2/REST_API_v2/Services/update_integration.py similarity index 100% rename from REST_API_v2/Services/update_integration.py rename to python_v2/REST_API_v2/Services/update_integration.py diff --git a/REST_API_v2/Services/update_service.py b/python_v2/REST_API_v2/Services/update_service.py similarity index 100% rename from REST_API_v2/Services/update_service.py rename to python_v2/REST_API_v2/Services/update_service.py diff --git a/REST_API_v2/Teams/add_escalation_policy_to_team.py b/python_v2/REST_API_v2/Teams/add_escalation_policy_to_team.py similarity index 100% rename from REST_API_v2/Teams/add_escalation_policy_to_team.py rename to python_v2/REST_API_v2/Teams/add_escalation_policy_to_team.py diff --git a/REST_API_v2/Teams/add_user_to_team.py b/python_v2/REST_API_v2/Teams/add_user_to_team.py similarity index 100% rename from REST_API_v2/Teams/add_user_to_team.py rename to python_v2/REST_API_v2/Teams/add_user_to_team.py diff --git a/REST_API_v2/Teams/create_team.py b/python_v2/REST_API_v2/Teams/create_team.py similarity index 100% rename from REST_API_v2/Teams/create_team.py rename to python_v2/REST_API_v2/Teams/create_team.py diff --git a/REST_API_v2/Teams/delete_team.py b/python_v2/REST_API_v2/Teams/delete_team.py similarity index 100% rename from REST_API_v2/Teams/delete_team.py rename to python_v2/REST_API_v2/Teams/delete_team.py diff --git a/REST_API_v2/Teams/get_team.py b/python_v2/REST_API_v2/Teams/get_team.py similarity index 100% rename from REST_API_v2/Teams/get_team.py rename to python_v2/REST_API_v2/Teams/get_team.py diff --git a/REST_API_v2/Teams/list_teams.py b/python_v2/REST_API_v2/Teams/list_teams.py similarity index 100% rename from REST_API_v2/Teams/list_teams.py rename to python_v2/REST_API_v2/Teams/list_teams.py diff --git a/REST_API_v2/Teams/remove_escalation_policy_from_team.py b/python_v2/REST_API_v2/Teams/remove_escalation_policy_from_team.py similarity index 100% rename from REST_API_v2/Teams/remove_escalation_policy_from_team.py rename to python_v2/REST_API_v2/Teams/remove_escalation_policy_from_team.py diff --git a/REST_API_v2/Teams/remove_user_from_team.py b/python_v2/REST_API_v2/Teams/remove_user_from_team.py similarity index 100% rename from REST_API_v2/Teams/remove_user_from_team.py rename to python_v2/REST_API_v2/Teams/remove_user_from_team.py diff --git a/REST_API_v2/Teams/update_team.py b/python_v2/REST_API_v2/Teams/update_team.py similarity index 100% rename from REST_API_v2/Teams/update_team.py rename to python_v2/REST_API_v2/Teams/update_team.py diff --git a/REST_API_v2/Users/create_user.py b/python_v2/REST_API_v2/Users/create_user.py similarity index 100% rename from REST_API_v2/Users/create_user.py rename to python_v2/REST_API_v2/Users/create_user.py diff --git a/REST_API_v2/Users/create_user_contact_method.py b/python_v2/REST_API_v2/Users/create_user_contact_method.py similarity index 100% rename from REST_API_v2/Users/create_user_contact_method.py rename to python_v2/REST_API_v2/Users/create_user_contact_method.py diff --git a/REST_API_v2/Users/create_user_notification_rule.py b/python_v2/REST_API_v2/Users/create_user_notification_rule.py similarity index 100% rename from REST_API_v2/Users/create_user_notification_rule.py rename to python_v2/REST_API_v2/Users/create_user_notification_rule.py diff --git a/REST_API_v2/Users/delete_user.py b/python_v2/REST_API_v2/Users/delete_user.py similarity index 100% rename from REST_API_v2/Users/delete_user.py rename to python_v2/REST_API_v2/Users/delete_user.py diff --git a/REST_API_v2/Users/delete_user_contact_method.py b/python_v2/REST_API_v2/Users/delete_user_contact_method.py similarity index 100% rename from REST_API_v2/Users/delete_user_contact_method.py rename to python_v2/REST_API_v2/Users/delete_user_contact_method.py diff --git a/REST_API_v2/Users/delete_user_notification_rule.py b/python_v2/REST_API_v2/Users/delete_user_notification_rule.py similarity index 100% rename from REST_API_v2/Users/delete_user_notification_rule.py rename to python_v2/REST_API_v2/Users/delete_user_notification_rule.py diff --git a/REST_API_v2/Users/get_user.py b/python_v2/REST_API_v2/Users/get_user.py similarity index 100% rename from REST_API_v2/Users/get_user.py rename to python_v2/REST_API_v2/Users/get_user.py diff --git a/REST_API_v2/Users/get_user_contact_method.py b/python_v2/REST_API_v2/Users/get_user_contact_method.py similarity index 100% rename from REST_API_v2/Users/get_user_contact_method.py rename to python_v2/REST_API_v2/Users/get_user_contact_method.py diff --git a/REST_API_v2/Users/get_user_notification_rule.py b/python_v2/REST_API_v2/Users/get_user_notification_rule.py similarity index 100% rename from REST_API_v2/Users/get_user_notification_rule.py rename to python_v2/REST_API_v2/Users/get_user_notification_rule.py diff --git a/REST_API_v2/Users/list_user_contact_methods.py b/python_v2/REST_API_v2/Users/list_user_contact_methods.py similarity index 100% rename from REST_API_v2/Users/list_user_contact_methods.py rename to python_v2/REST_API_v2/Users/list_user_contact_methods.py diff --git a/REST_API_v2/Users/list_user_notification_rules.py b/python_v2/REST_API_v2/Users/list_user_notification_rules.py similarity index 100% rename from REST_API_v2/Users/list_user_notification_rules.py rename to python_v2/REST_API_v2/Users/list_user_notification_rules.py diff --git a/REST_API_v2/Users/list_users.py b/python_v2/REST_API_v2/Users/list_users.py similarity index 100% rename from REST_API_v2/Users/list_users.py rename to python_v2/REST_API_v2/Users/list_users.py diff --git a/REST_API_v2/Users/update_user.py b/python_v2/REST_API_v2/Users/update_user.py similarity index 100% rename from REST_API_v2/Users/update_user.py rename to python_v2/REST_API_v2/Users/update_user.py diff --git a/REST_API_v2/Users/update_user_contact_method.py b/python_v2/REST_API_v2/Users/update_user_contact_method.py similarity index 100% rename from REST_API_v2/Users/update_user_contact_method.py rename to python_v2/REST_API_v2/Users/update_user_contact_method.py diff --git a/REST_API_v2/Users/update_user_notification_rule.py b/python_v2/REST_API_v2/Users/update_user_notification_rule.py similarity index 100% rename from REST_API_v2/Users/update_user_notification_rule.py rename to python_v2/REST_API_v2/Users/update_user_notification_rule.py diff --git a/REST_API_v2/Vendors/get_vendor.py b/python_v2/REST_API_v2/Vendors/get_vendor.py similarity index 100% rename from REST_API_v2/Vendors/get_vendor.py rename to python_v2/REST_API_v2/Vendors/get_vendor.py diff --git a/REST_API_v2/Vendors/list_vendors.py b/python_v2/REST_API_v2/Vendors/list_vendors.py similarity index 100% rename from REST_API_v2/Vendors/list_vendors.py rename to python_v2/REST_API_v2/Vendors/list_vendors.py diff --git a/python_v3/EVENTS_API_V1/Ack/ack_incident.py b/python_v3/EVENTS_API_V1/Ack/ack_incident.py new file mode 100755 index 0000000..079017f --- /dev/null +++ b/python_v3/EVENTS_API_V1/Ack/ack_incident.py @@ -0,0 +1,29 @@ +#!/usr/bin/env python + +import json +import requests + +SERVICE_KEY = "" # ENTER EVENTS V1 API INTEGRATION KEY HERE +INCIDENT_KEY = "" # ENTER INCIDENT KEY + +def trigger_incident(): + # Triggers a PagerDuty incident without a previously generated incident key + # Uses Events V1 API - documentation: https://v2.developer.pagerduty.com/docs/trigger-events + + payload = { # Payload is built with the least amount of fields required to trigger an incident + "service_key": SERVICE_KEY, + "event_type": "acknowledge", + "incident_key": INCIDENT_KEY, + "description": "Example alert on host1.example.com" + } + + response = requests.post('https://events.pagerduty.com/generic/2010-04-15/create_event.json', + data=json.dumps(payload)) + + if response.json()["status"] == "success": + print('Incident Acknowledged') + else: + print(response.text) # print error message if not successful + +if __name__ == '__main__': + trigger_incident() diff --git a/python_v3/EVENTS_API_V1/Resolve/resolve_incident.py b/python_v3/EVENTS_API_V1/Resolve/resolve_incident.py new file mode 100755 index 0000000..7e0f0aa --- /dev/null +++ b/python_v3/EVENTS_API_V1/Resolve/resolve_incident.py @@ -0,0 +1,29 @@ +#!/usr/bin/env python + +import json +import requests + +SERVICE_KEY = "" # ENTER EVENTS V1 API INTEGRATION KEY HERE +INCIDENT_KEY = "" # ENTER INCIDENT KEY + +def trigger_incident(): + # Triggers a PagerDuty incident without a previously generated incident key + # Uses Events V1 API - documentation: https://v2.developer.pagerduty.com/docs/trigger-events + + payload = { # Payload is built with the least amount of fields required to trigger an incident + "service_key": SERVICE_KEY, + "event_type": "resolve", + "incident_key": INCIDENT_KEY, + "description": "Example alert on host1.example.com" + } + + response = requests.post('https://events.pagerduty.com/generic/2010-04-15/create_event.json', + data=json.dumps(payload)) + + if response.json()["status"] == "success": + print ('Incident Resolved') + else: + print(response.text) # print error message if not successful + +if __name__ == '__main__': + trigger_incident() diff --git a/python_v3/EVENTS_API_V1/Trigger/trigger_with_incident_key.py b/python_v3/EVENTS_API_V1/Trigger/trigger_with_incident_key.py new file mode 100755 index 0000000..e7825f1 --- /dev/null +++ b/python_v3/EVENTS_API_V1/Trigger/trigger_with_incident_key.py @@ -0,0 +1,29 @@ +#!/usr/bin/env python + +import json +import requests + +SERVICE_KEY = "" # ENTER EVENTS V1 API INTEGRATION KEY HERE +INCIDENT_KEY = "" # ENTER INCIDENT KEY + +def trigger_incident(): + # Triggers a PagerDuty incident without a previously generated incident key + # Uses Events V1 API - documentation: https://v2.developer.pagerduty.com/docs/trigger-events + + payload = { # Payload is built with the least amount of fields required to trigger an incident + "service_key": SERVICE_KEY, + "event_type": "trigger", + "incident_key": INCIDENT_KEY, + "description": "Example alert on host1.example.com" + } + + response = requests.post('https://events.pagerduty.com/generic/2010-04-15/create_event.json', + data=json.dumps(payload)) + + if response.json()["status"] == "success": + print('Incident Triggered') + else: + print(response.text) # print error message if not successful + +if __name__ == '__main__': + trigger_incident() diff --git a/python_v3/EVENTS_API_V1/Trigger/trigger_without_incident_key.py b/python_v3/EVENTS_API_V1/Trigger/trigger_without_incident_key.py new file mode 100755 index 0000000..052ca5a --- /dev/null +++ b/python_v3/EVENTS_API_V1/Trigger/trigger_without_incident_key.py @@ -0,0 +1,27 @@ +#!/usr/bin/env python + +import json +import requests + +SERVICE_KEY = "" # ENTER EVENTS V1 API INTEGRATION KEY HERE + +def trigger_incident(): + # Triggers a PagerDuty incident without a previously generated incident key + # Uses Events V1 API - documentation: https://v2.developer.pagerduty.com/docs/trigger-events + + payload = { # Payload is built with the least amount of fields required to trigger an incident + "service_key": SERVICE_KEY, + "event_type": "trigger", + "description": "Example alert on host1.example.com" + } + + response = requests.post('https://events.pagerduty.com/generic/2010-04-15/create_event.json', + data=json.dumps(payload)) + + if response.json()["status"] == "success": + print('Incident created with with incident / alert key of ' + '"' + response.json()['incident_key'] + '"') + else: + print(response.text) # print error message if not successful + +if __name__ == '__main__': + trigger_incident() diff --git a/python_v3/EVENTS_API_v2/ack/ack_incident.py b/python_v3/EVENTS_API_v2/ack/ack_incident.py new file mode 100755 index 0000000..86a7378 --- /dev/null +++ b/python_v3/EVENTS_API_v2/ack/ack_incident.py @@ -0,0 +1,33 @@ +#!/usr/bin/env python + +import json +import requests + +ROUTING_KEY = "" # ENTER EVENTS V2 API INTEGRATION KEY HERE +INCIDENT_KEY = "" # ENTER INCIDENT KEY HERE + +def trigger_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 + + header = { + "Content-Type": "application/json" + } + + payload = { # Payload is built with the least amount of fields required to trigger an incident + "routing_key": ROUTING_KEY, + "event_action": "acknowledge", + "dedup_key": INCIDENT_KEY + } + + response = requests.post('https://events.pagerduty.com/v2/enqueue', + data=json.dumps(payload), + headers=header) + + if response.json()["status"] == "success": + print('Incident Acknowledged ') + else: + print(response.text) # print error message if not successful + +if __name__ == '__main__': + trigger_incident() diff --git a/python_v3/EVENTS_API_v2/resolve/resolve_incident.py b/python_v3/EVENTS_API_v2/resolve/resolve_incident.py new file mode 100755 index 0000000..610fa02 --- /dev/null +++ b/python_v3/EVENTS_API_v2/resolve/resolve_incident.py @@ -0,0 +1,33 @@ +#!/usr/bin/env python + +import json +import requests + +ROUTING_KEY = "" # ENTER EVENTS V2 API INTEGRATION KEY HERE +INCIDENT_KEY = "" # ENTER INCIDENT KEY HERE + +def trigger_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 + + header = { + "Content-Type": "application/json" + } + + payload = { # Payload is built with the least amount of fields required to trigger an incident + "routing_key": ROUTING_KEY, + "event_action": "resolve", + "dedup_key": INCIDENT_KEY + } + + response = requests.post('https://events.pagerduty.com/v2/enqueue', + data=json.dumps(payload), + headers=header) + + if response.json()["status"] == "success": + print('Incident Resolved ') + else: + print(response.text) # print error message if not successful + +if __name__ == '__main__': + trigger_incident() diff --git a/python_v3/EVENTS_API_v2/trigger/trigger_with_incident_key.py b/python_v3/EVENTS_API_v2/trigger/trigger_with_incident_key.py new file mode 100644 index 0000000..49e87f7 --- /dev/null +++ b/python_v3/EVENTS_API_v2/trigger/trigger_with_incident_key.py @@ -0,0 +1,38 @@ +#!/usr/bin/env python + +import json +import requests + +ROUTING_KEY = "" # ENTER EVENTS V2 API INTEGRATION KEY HERE +INCIDENT_KEY = "" # ENTER INCIDENT KEY HERE + +def trigger_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 + + header = { + "Content-Type": "application/json" + } + + payload = { # Payload is built with the least amount of fields required to trigger an incident + "routing_key": ROUTING_KEY, + "event_action": "trigger", + "dedup_key": INCIDENT_KEY, + "payload": { + "summary": "Example alert on host1.example.com", + "source": "monitoringtool:cloudvendor:central-region-dc-01:852559987:cluster/api-stats-prod-003", + "severity": "critical" + } + } + + response = requests.post('https://events.pagerduty.com/v2/enqueue', + data=json.dumps(payload), + headers=header) + + if response.json()["status"] == "success": + print('Incident Created') + else: + print(response.text) # print error message if not successful + +if __name__ == '__main__': + trigger_incident() diff --git a/python_v3/EVENTS_API_v2/trigger/trigger_without_incident_key.py b/python_v3/EVENTS_API_v2/trigger/trigger_without_incident_key.py new file mode 100644 index 0000000..f49c66c --- /dev/null +++ b/python_v3/EVENTS_API_v2/trigger/trigger_without_incident_key.py @@ -0,0 +1,36 @@ +#!/usr/bin/env python + +import json +import requests + +ROUTING_KEY = "" # ENTER EVENTS V2 API INTEGRATION KEY HERE + +def trigger_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 + + header = { + "Content-Type": "application/json" + } + + payload = { # Payload is built with the least amount of fields required to trigger an incident + "routing_key": ROUTING_KEY, + "event_action": "trigger", + "payload": { + "summary": "Example alert on host1.example.com", + "source": "monitoringtool:cloudvendor:central-region-dc-01:852559987:cluster/api-stats-prod-003", + "severity": "critical" + } + } + + response = requests.post('https://events.pagerduty.com/v2/enqueue', + data=json.dumps(payload), + 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'] + '"') + else: + print(response.text) # print error message if not successful + +if __name__ == '__main__': + trigger_incident() diff --git a/python_v3/REST_API_v2/Abilities/list_abilities.py b/python_v3/REST_API_v2/Abilities/list_abilities.py new file mode 100755 index 0000000..3a0a529 --- /dev/null +++ b/python_v3/REST_API_v2/Abilities/list_abilities.py @@ -0,0 +1,45 @@ +#!/usr/bin/env python +# +# Copyright (c) 2016, 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. + +import requests + +# Update to match your API key +API_KEY = '3c3gRvzx7uGfMYEnWKvF' + + +def list_abilities(): + url = 'https://api.pagerduty.com/abilities' + headers = { + 'Accept': 'application/vnd.pagerduty+json;version=2', + '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()) + +if __name__ == '__main__': + list_abilities() diff --git a/python_v3/REST_API_v2/Abilities/test_ability.py b/python_v3/REST_API_v2/Abilities/test_ability.py new file mode 100755 index 0000000..baedabf --- /dev/null +++ b/python_v3/REST_API_v2/Abilities/test_ability.py @@ -0,0 +1,48 @@ +#!/usr/bin/env python +# +# Copyright (c) 2016, 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. + +import requests + +# Update to match your API key +API_KEY = '3c3gRvzx7uGfMYEnWKvF' + +# Update to match your ability ID +ID = 'sso' + + +def test_ability(): + url = 'https://api.pagerduty.com/abilities/{id}'.format(id=ID) + headers = { + 'Accept': 'application/vnd.pagerduty+json;version=2', + '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) + +if __name__ == '__main__': + test_ability() diff --git a/python_v3/REST_API_v2/AddOns/delete_addon.py b/python_v3/REST_API_v2/AddOns/delete_addon.py new file mode 100755 index 0000000..c555754 --- /dev/null +++ b/python_v3/REST_API_v2/AddOns/delete_addon.py @@ -0,0 +1,48 @@ +#!/usr/bin/env python +# +# Copyright (c) 2016, 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. + +import requests + +# Update to match your API key +API_KEY = '3c3gRvzx7uGfMYEnWKvF' + +# Update to match ID of resource you want to delete +ID = 'PNIESDP' + + +def delete_addon(): + url = 'https://api.pagerduty.com/addons/{id}'.format(id=ID) + headers = { + 'Accept': 'application/vnd.pagerduty+json;version=2', + '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) + +if __name__ == '__main__': + delete_addon() diff --git a/python_v3/REST_API_v2/AddOns/get_addon.py b/python_v3/REST_API_v2/AddOns/get_addon.py new file mode 100755 index 0000000..04b4bed --- /dev/null +++ b/python_v3/REST_API_v2/AddOns/get_addon.py @@ -0,0 +1,48 @@ +#!/usr/bin/env python +# +# Copyright (c) 2016, 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. + +import requests + +# Update to match your API key +API_KEY = '3c3gRvzx7uGfMYEnWKvF' + +# Update to match ID of resource you want to GET +ID = 'PNIESDP' + + +def get_addon(): + url = 'https://api.pagerduty.com/addons/{id}'.format(id=ID) + headers = { + 'Accept': 'application/vnd.pagerduty+json;version=2', + '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()) + +if __name__ == '__main__': + get_addon() diff --git a/python_v3/REST_API_v2/AddOns/install_addon.py b/python_v3/REST_API_v2/AddOns/install_addon.py new file mode 100755 index 0000000..c36cefb --- /dev/null +++ b/python_v3/REST_API_v2/AddOns/install_addon.py @@ -0,0 +1,61 @@ +#!/usr/bin/env python +# +# Copyright (c) 2016, 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. + +import requests +import json + +# Update to match your API key +API_KEY = '3c3gRvzx7uGfMYEnWKvF' + +# Update to match your chosen parameters +SUMMARY = 'Insert addon summary here' +NAME = 'Insert addon name here' +SRC = 'https://intranet.example.com/status' +SERVICES = [] + + +def install_addon(): + url = 'https://api.pagerduty.com/addons' + headers = { + 'Accept': 'application/vnd.pagerduty+json;version=2', + 'Authorization': 'Token token={token}'.format(token=API_KEY), + 'Content-type': 'application/json' + } + payload = { + 'addon': { + 'summary': SUMMARY, + 'name': NAME, + 'src': SRC, + 'services': SERVICES + } + } + r = requests.post(url, headers=headers, data=json.dumps(payload)) + print('Status Code: {code}'.format(code=r.status_code)) + print(r.json()) + +if __name__ == '__main__': + install_addon() diff --git a/python_v3/REST_API_v2/AddOns/list_installed_addons.py b/python_v3/REST_API_v2/AddOns/list_installed_addons.py new file mode 100755 index 0000000..c21d7bd --- /dev/null +++ b/python_v3/REST_API_v2/AddOns/list_installed_addons.py @@ -0,0 +1,55 @@ +#!/usr/bin/env python +# +# Copyright (c) 2016, 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. + +import requests + +# Update to match your API key +API_KEY = '3c3gRvzx7uGfMYEnWKvF' + +# Update to match your chosen parameters +INCLUDE = [] +SERVICE_IDS = [] +FILTER = '' + + +def list_installed_addons(): + url = 'https://api.pagerduty.com/addons' + headers = { + 'Accept': 'application/vnd.pagerduty+json;version=2', + 'Authorization': 'Token token={token}'.format(token=API_KEY) + } + payload = { + 'include[]': INCLUDE, + 'service_ids[]': SERVICE_IDS, + 'filter': FILTER + } + r = requests.get(url, headers=headers, params=payload) + print('Status Code: {code}'.format(code=r.status_code)) + print(r.json()) + +if __name__ == '__main__': + list_installed_addons() diff --git a/python_v3/REST_API_v2/AddOns/update_addon.py b/python_v3/REST_API_v2/AddOns/update_addon.py new file mode 100755 index 0000000..3e61508 --- /dev/null +++ b/python_v3/REST_API_v2/AddOns/update_addon.py @@ -0,0 +1,64 @@ +#!/usr/bin/env python +# +# Copyright (c) 2016, 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. + +import requests +import json + +# Update to match your API key +API_KEY = '3c3gRvzx7uGfMYEnWKvF' + +# Update to match ID of resource you want to update +ID = 'P00HQZ9' + +# Update to match your chosen parameters +SUMMARY = 'Insert updated addon summary here' +NAME = 'Insert updated addon name here' +SRC = 'https://intranet.example.com/updated_status_page' +SERVICES = [] + + +def update_addon(): + url = 'https://api.pagerduty.com/addons/{id}'.format(id=ID) + headers = { + 'Accept': 'application/vnd.pagerduty+json;version=2', + 'Authorization': 'Token token={token}'.format(token=API_KEY), + 'Content-type': 'application/json' + } + payload = { + 'addon': { + 'summary': SUMMARY, + 'name': NAME, + 'src': SRC, + 'services': SERVICES + } + } + r = requests.put(url, headers=headers, data=json.dumps(payload)) + print('Status Code: ' + str(r.status_code)) + print(r.json()) + +if __name__ == '__main__': + update_addon() diff --git a/python_v3/REST_API_v2/EscalationPolicies/create_escalation_policy.py b/python_v3/REST_API_v2/EscalationPolicies/create_escalation_policy.py new file mode 100755 index 0000000..fa8883b --- /dev/null +++ b/python_v3/REST_API_v2/EscalationPolicies/create_escalation_policy.py @@ -0,0 +1,73 @@ +#!/usr/bin/env python +# +# Copyright (c) 2016, 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. + +import requests +import json + +# Update to match your API key +API_KEY = '3c3gRvzx7uGfMYEnWKvF' + +# Update to match your chosen parameters +TYPE = 'escalation_policy' +NAME = 'Insert resource name here' +SUMMARY = 'Insert resource description here' +REPEAT_ENABLED = True +NUM_LOOPS = 3 +ESCALATION_RULES = [{ + 'escalation_delay_in_minutes': 30, + 'targets': [{ + 'type': 'schedule', + 'id': 'PTC959G' + }] +}] +SERVICES = [] + + +def create_escalation_policy(): + url = 'https://api.pagerduty.com/escalation_policies' + headers = { + 'Accept': 'application/vnd.pagerduty+json;version=2', + 'Authorization': 'Token token={token}'.format(token=API_KEY), + 'Content-type': 'application/json' + } + payload = { + 'escalation_policy': { + 'name': NAME, + 'type': TYPE, + 'summary': SUMMARY, + 'repeat_enabled': REPEAT_ENABLED, + 'num_loops': NUM_LOOPS, + 'escalation_rules': ESCALATION_RULES, + 'services': SERVICES + } + } + r = requests.post(url, headers=headers, data=json.dumps(payload)) + print('Status Code: {code}'.format(code=r.status_code)) + print(r.json()) + +if __name__ == '__main__': + create_escalation_policy() diff --git a/python_v3/REST_API_v2/EscalationPolicies/delete_escalation_policy.py b/python_v3/REST_API_v2/EscalationPolicies/delete_escalation_policy.py new file mode 100755 index 0000000..4b77f58 --- /dev/null +++ b/python_v3/REST_API_v2/EscalationPolicies/delete_escalation_policy.py @@ -0,0 +1,48 @@ +#!/usr/bin/env python +# +# Copyright (c) 2016, 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. + +import requests + +# Update to match your API key +API_KEY = '3c3gRvzx7uGfMYEnWKvF' + +# Update to match ID of resource you want to delete +ID = 'P2ITA2T' + + +def delete_escalation_policy(): + url = 'https://api.pagerduty.com/escalation_policies/{id}'.format(id=ID) + headers = { + 'Accept': 'application/vnd.pagerduty+json;version=2', + '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) + +if __name__ == '__main__': + delete_escalation_policy() diff --git a/python_v3/REST_API_v2/EscalationPolicies/get_escalation_policy.py b/python_v3/REST_API_v2/EscalationPolicies/get_escalation_policy.py new file mode 100755 index 0000000..d0d8a56 --- /dev/null +++ b/python_v3/REST_API_v2/EscalationPolicies/get_escalation_policy.py @@ -0,0 +1,54 @@ +#!/usr/bin/env python +# +# Copyright (c) 2016, 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. + +import requests + +# Update to match your API key +API_KEY = '3c3gRvzx7uGfMYEnWKvF' + +# Update to match ID of resource you want to GET +ID = 'PIX2DN3' + +# Update to match your chosen parameters +INCLUDE = [] + + +def get_escalation_policy(): + url = 'https://api.pagerduty.com/escalation_policies/{id}'.format(id=ID) + headers = { + 'Accept': 'application/vnd.pagerduty+json;version=2', + 'Authorization': 'Token token={token}'.format(token=API_KEY) + } + payload = { + 'include[]': INCLUDE + } + r = requests.get(url, headers=headers, params=payload) + print('Status Code: {code}'.format(code=r.status_code)) + print(r.json()) + +if __name__ == '__main__': + get_escalation_policy() diff --git a/python_v3/REST_API_v2/EscalationPolicies/list_escalation_policies.py b/python_v3/REST_API_v2/EscalationPolicies/list_escalation_policies.py new file mode 100755 index 0000000..2de203e --- /dev/null +++ b/python_v3/REST_API_v2/EscalationPolicies/list_escalation_policies.py @@ -0,0 +1,59 @@ +#!/usr/bin/env python +# +# Copyright (c) 2016, 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. + +import requests + +# Update to match your API key +API_KEY = '3c3gRvzx7uGfMYEnWKvF' + +# Update to match your chosen parameters +QUERY = '' +USER_IDS = [] +TEAM_IDS = [] +INCLUDE = [] +SORT_BY = 'name' + + +def list_escalation_policies(): + url = 'https://api.pagerduty.com/escalation_policies' + headers = { + 'Accept': 'application/vnd.pagerduty+json;version=2', + 'Authorization': 'Token token={token}'.format(token=API_KEY) + } + payload = { + 'query': QUERY, + 'user_ids[]': USER_IDS, + 'team_ids[]': TEAM_IDS, + 'include[]': INCLUDE, + 'sort_by': SORT_BY + } + r = requests.get(url, headers=headers, params=payload) + print('Status Code: {code}'.format(code=r.status_code)) + print(r.json()) + +if __name__ == '__main__': + list_escalation_policies() diff --git a/python_v3/REST_API_v2/EscalationPolicies/update_escalation_policy.py b/python_v3/REST_API_v2/EscalationPolicies/update_escalation_policy.py new file mode 100755 index 0000000..5114f72 --- /dev/null +++ b/python_v3/REST_API_v2/EscalationPolicies/update_escalation_policy.py @@ -0,0 +1,80 @@ +#!/usr/bin/env python +# +# Copyright (c) 2016, 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. + +import requests +import json + +# Update to match your API key +API_KEY = '3c3gRvzx7uGfMYEnWKvF' + +# Update to match ID of resource you want to update +ID = 'PVHNG0S' + +# Update to match your chosen parameters +TYPE = 'escalation_policy' +NAME = 'Insert resource name here' +SUMMARY = 'Insert resource description here' +REPEAT_ENABLED = True +NUM_LOOPS = 3 +ESCALATION_RULES = [ + { + 'escalation_delay_in_minutes': 30, + 'targets': [ + { + 'type': 'schedule', + 'id': 'PTC959G' + } + ] + } +] +SERVICES = [] + + +def update_escalation_policy(): + url = 'https://api.pagerduty.com/escalation_policies/{id}'.format(id=ID) + headers = { + 'Accept': 'application/vnd.pagerduty+json;version=2', + 'Authorization': 'Token token={token}'.format(token=API_KEY), + 'Content-type': 'application/json' + } + payload = { + 'escalation_policy': { + 'name': NAME, + 'type': TYPE, + 'summary': SUMMARY, + 'repeat_enabled': REPEAT_ENABLED, + 'num_loops': NUM_LOOPS, + 'escalation_rules': ESCALATION_RULES, + 'services': SERVICES + } + } + r = requests.put(url, headers=headers, data=json.dumps(payload)) + print('Status Code: {code}'.format(code=r.status_code)) + print(r.json()) + +if __name__ == '__main__': + update_escalation_policy() diff --git a/python_v3/REST_API_v2/Incidents/create_incident_note.py b/python_v3/REST_API_v2/Incidents/create_incident_note.py new file mode 100755 index 0000000..409f740 --- /dev/null +++ b/python_v3/REST_API_v2/Incidents/create_incident_note.py @@ -0,0 +1,62 @@ +#!/usr/bin/env python +# +# Copyright (c) 2016, 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. + +import requests +import json + +# Update to match your API key +API_KEY = '3c3gRvzx7uGfMYEnWKvF' + +# Update to match your email address +EMAIL = 'lucas@pagerduty.com' + +# Update to match your chosen parameters +INCIDENT_ID = 'PI8BBP5' +CONTENT = 'Enter your note content here' + + +def create_incident_note(): + url = 'https://api.pagerduty.com/incidents/{id}/notes'.format( + id=INCIDENT_ID + ) + headers = { + 'Accept': 'application/vnd.pagerduty+json;version=2', + 'Authorization': 'Token token={token}'.format(token=API_KEY), + 'Content-type': 'application/json', + 'From': EMAIL + } + payload = { + 'note': { + 'content': CONTENT + } + } + r = requests.post(url, headers=headers, data=json.dumps(payload)) + print('Status Code: {code}'.format(code=r.status_code)) + print(r.json()) + +if __name__ == '__main__': + create_incident_note() diff --git a/python_v3/REST_API_v2/Incidents/get_incident.py b/python_v3/REST_API_v2/Incidents/get_incident.py new file mode 100755 index 0000000..9e3e91d --- /dev/null +++ b/python_v3/REST_API_v2/Incidents/get_incident.py @@ -0,0 +1,48 @@ +#!/usr/bin/env python +# +# Copyright (c) 2016, 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. + +import requests + +# Update to match your API key +API_KEY = '3c3gRvzx7uGfMYEnWKvF' + +# Update to match your incident ID +ID = 'P1DIBFS' + + +def get_incident(): + url = 'https://api.pagerduty.com/incidents/{id}'.format(id=ID) + headers = { + 'Accept': 'application/vnd.pagerduty+json;version=2', + '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()) + +if __name__ == '__main__': + get_incident() diff --git a/python_v3/REST_API_v2/Incidents/list_incident_log_entries.py b/python_v3/REST_API_v2/Incidents/list_incident_log_entries.py new file mode 100755 index 0000000..5dc2b9f --- /dev/null +++ b/python_v3/REST_API_v2/Incidents/list_incident_log_entries.py @@ -0,0 +1,58 @@ +#!/usr/bin/env python +# +# Copyright (c) 2016, 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. + +import requests + +# Update to match your API key +API_KEY = '3c3gRvzx7uGfMYEnWKvF' + +# Update to match your chosen parameters +INCIDENT_ID = 'P1DIBFS' +TIME_ZONE = 'UTC' +IS_OVERVIEW = False +INCLUDE = [] + + +def get_incident(): + url = 'https://api.pagerduty.com/incidents/{id}/log_entries'.format( + id=INCIDENT_ID + ) + headers = { + 'Accept': 'application/vnd.pagerduty+json;version=2', + 'Authorization': 'Token token={token}'.format(token=API_KEY) + } + payload = { + 'time_zone': TIME_ZONE, + 'is_overview': IS_OVERVIEW, + 'include[]': INCLUDE + } + r = requests.get(url, headers=headers, params=payload) + print('Status Code: {code}'.format(code=r.status_code)) + print(r.json()) + +if __name__ == '__main__': + get_incident() diff --git a/python_v3/REST_API_v2/Incidents/list_incident_notes.py b/python_v3/REST_API_v2/Incidents/list_incident_notes.py new file mode 100755 index 0000000..fa79177 --- /dev/null +++ b/python_v3/REST_API_v2/Incidents/list_incident_notes.py @@ -0,0 +1,50 @@ +#!/usr/bin/env python +# +# Copyright (c) 2016, 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. + +import requests + +# Update to match your API key +API_KEY = '3c3gRvzx7uGfMYEnWKvF' + +# Update to match your incident ID +INCIDENT_ID = 'P1DIBFS' + + +def get_incident(): + url = 'https://api.pagerduty.com/incidents/{id}/notes'.format( + id=INCIDENT_ID + ) + headers = { + 'Accept': 'application/vnd.pagerduty+json;version=2', + '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()) + +if __name__ == '__main__': + get_incident() diff --git a/python_v3/REST_API_v2/Incidents/list_incidents.py b/python_v3/REST_API_v2/Incidents/list_incidents.py new file mode 100755 index 0000000..8dacf85 --- /dev/null +++ b/python_v3/REST_API_v2/Incidents/list_incidents.py @@ -0,0 +1,73 @@ +#!/usr/bin/env python +# +# Copyright (c) 2016, 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. + +import requests + +# Update to match your API key +API_KEY = '3c3gRvzx7uGfMYEnWKvF' + +# Update to match your chosen parameters +SINCE = '' +UNTIL = '' +DATE_RANGE = '' +STATUSES = [] +INCIDENT_KEY = '' +SERVICE_IDS = [] +TEAM_IDS = [] +USER_IDS = [] +URGENCIES = [] +TIME_ZONE = 'UTC' +SORT_BY = [] +INCLUDE = [] + + +def list_incidents(): + url = 'https://api.pagerduty.com/incidents' + headers = { + 'Accept': 'application/vnd.pagerduty+json;version=2', + 'Authorization': 'Token token={token}'.format(token=API_KEY) + } + payload = { + 'since': SINCE, + 'until': UNTIL, + 'date_range': DATE_RANGE, + 'statuses[]': STATUSES, + 'incident_key': INCIDENT_KEY, + 'service_ids[]': SERVICE_IDS, + 'team_ids[]': TEAM_IDS, + 'user_ids[]': USER_IDS, + 'urgencies[]': URGENCIES, + 'time_zone': TIME_ZONE, + '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()) + +if __name__ == '__main__': + list_incidents() diff --git a/python_v3/REST_API_v2/Incidents/manage_incidents.py b/python_v3/REST_API_v2/Incidents/manage_incidents.py new file mode 100755 index 0000000..4d62b1a --- /dev/null +++ b/python_v3/REST_API_v2/Incidents/manage_incidents.py @@ -0,0 +1,88 @@ +#!/usr/bin/env python +# +# Copyright (c) 2016, 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. + +import requests +import json + +# Update to match your API key +API_KEY = '3c3gRvzx7uGfMYEnWKvF' + +# Update to match your email address +EMAIL = 'lucas@pagerduty.com' + +# Update to match your chosen parameters for each incident +INCIDENT_ONE_ID = 'P1DIBFS' +INCIDENT_ONE_STATUS = 'resolved' +INCIDENT_ONE_ASSIGNEE_ID = '' +INCIDENT_ONE_ASSIGNEE_TYPE = '' + +INCIDENT_TWO_ID = 'PKSPVAW' +INCIDENT_TWO_STATUS = 'resolved' +INCIDENT_TWO_ASSIGNEE_ID = '' +INCIDENT_TWO_ASSIGNEE_TYPE = '' + + +def manage_incidents(): + url = 'https://api.pagerduty.com/incidents' + headers = { + 'Accept': 'application/vnd.pagerduty+json;version=2', + 'Authorization': 'Token token={token}'.format(token=API_KEY), + 'Content-type': 'application/json', + 'From': EMAIL + } + payload = { + 'incidents': [ + { + 'id': INCIDENT_ONE_ID, + 'type': 'incident', + 'status': INCIDENT_ONE_STATUS, + 'assigments': [{ + 'assignee': { + 'id': INCIDENT_ONE_ASSIGNEE_ID, + 'type': INCIDENT_ONE_ASSIGNEE_TYPE + } + }] + }, + { + 'id': INCIDENT_TWO_ID, + 'type': 'incident', + 'status': INCIDENT_TWO_STATUS, + 'assignments': [{ + 'assignee': { + 'id': INCIDENT_TWO_ASSIGNEE_ID, + 'type': INCIDENT_TWO_ASSIGNEE_TYPE + } + }] + } + ] + } + r = requests.put(url, headers=headers, data=json.dumps(payload)) + print('Status Code: {code}'.format(code=r.status_code)) + print(r.json()) + +if __name__ == '__main__': + manage_incidents() diff --git a/python_v3/REST_API_v2/Incidents/snooze_incident.py b/python_v3/REST_API_v2/Incidents/snooze_incident.py new file mode 100755 index 0000000..5459aff --- /dev/null +++ b/python_v3/REST_API_v2/Incidents/snooze_incident.py @@ -0,0 +1,61 @@ +#!/usr/bin/env python +# +# Copyright (c) 2016, 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. + +import requests +import json + +# Update to match your API key +API_KEY = '3c3gRvzx7uGfMYEnWKvF' + +# Update to match your email address +EMAIL = 'lucas@pagerduty.com' + +# Update to match your chosen parameters +INCIDENT_ID = 'P7SP1VE' +CONTENT = 'Enter your note content here' + + +def snooze_incident(): + url = 'https://api.pagerduty.com/incidents/{id}/snooze'.format( + id=INCIDENT_ID + ) + headers = { + 'Accept': 'application/vnd.pagerduty+json;version=2', + 'Authorization': 'Token token={token}'.format(token=API_KEY), + 'Content-type': 'application/json', + 'From': EMAIL + } + payload = { + 'content': CONTENT, + '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()) + +if __name__ == '__main__': + snooze_incident() diff --git a/python_v3/REST_API_v2/Incidents/trigger_incident.py b/python_v3/REST_API_v2/Incidents/trigger_incident.py new file mode 100644 index 0000000..72576be --- /dev/null +++ b/python_v3/REST_API_v2/Incidents/trigger_incident.py @@ -0,0 +1,69 @@ +#!/usr/bin/env python +# +# Copyright (c) 2016, 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. + +import requests +import json + +# Update to match your API key +API_KEY = '' +SERVICE_ID = '' +FROM = '' + +def trigger_incident(): + """Triggers an incident via the V2 REST API using sample data.""" + + url = 'https://api.pagerduty.com/incidents' + headers = { + 'Content-Type': 'application/json', + 'Accept': 'application/vnd.pagerduty+json;version=2', + 'Authorization': 'Token token={token}'.format(token=API_KEY), + 'From': FROM + } + + payload = { + "incident": { + "type": "incident", + "title": "The server is on fire.", + "service": { + "id": SERVICE_ID, + "type": "service_reference" + }, + "incident_key": "baf7cf21b1da41b4b0221008339ff3571", + "body": { + "type": "incident_body", + "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." + } + } + } + + r = requests.post(url, headers=headers, data=json.dumps(payload)) + + print('Status Code: {code}'.format(code=r.status_code)) + print(r.json()) + +if __name__ == '__main__': + trigger_incident() diff --git a/python_v3/REST_API_v2/Incidents/update_incident.py b/python_v3/REST_API_v2/Incidents/update_incident.py new file mode 100755 index 0000000..7b8327b --- /dev/null +++ b/python_v3/REST_API_v2/Incidents/update_incident.py @@ -0,0 +1,70 @@ +#!/usr/bin/env python +# +# Copyright (c) 2016, 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. + +import requests +import json + +# Update to match your API key +API_KEY = '3c3gRvzx7uGfMYEnWKvF' + +# Update to match your email address +EMAIL = 'lucas@pagerduty.com' + +# Update to match your chosen parameters for the incident +INCIDENT_ID = 'PQQVDM1' +TYPE = 'incident' +SUMMARY = 'Enter your incident summary here' +STATUS = 'resolved' +ESCALATION_LEVEL = 1 +ASSIGNED_TO_USER = '' +ESCALATION_POLICY = '' + + +def update_incident(): + url = 'https://api.pagerduty.com/incidents/{id}'.format(id=INCIDENT_ID) + headers = { + 'Accept': 'application/vnd.pagerduty+json;version=2', + 'Authorization': 'Token token={token}'.format(token=API_KEY), + 'Content-type': 'application/json', + 'From': EMAIL + } + payload = { + 'incident': { + 'type': TYPE, + 'summary': SUMMARY, + 'status': STATUS, + 'escalation_level': ESCALATION_LEVEL, + 'assigned_to_user': ASSIGNED_TO_USER, + 'escalation_policy': ESCALATION_POLICY + } + } + r = requests.put(url, headers=headers, data=json.dumps(payload)) + print('Status Code: {code}'.format(code=r.status_code)) + print(r.json()) + +if __name__ == '__main__': + update_incident() diff --git a/python_v3/REST_API_v2/LogEntries/get_log_entry.py b/python_v3/REST_API_v2/LogEntries/get_log_entry.py new file mode 100755 index 0000000..b7d202f --- /dev/null +++ b/python_v3/REST_API_v2/LogEntries/get_log_entry.py @@ -0,0 +1,54 @@ +#!/usr/bin/env python +# +# Copyright (c) 2016, 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. + +import requests + +# Update to match your API key +API_KEY = '3c3gRvzx7uGfMYEnWKvF' + +# Update to match ID of resource you want to GET +ID = 'Q1LLSJN8TZGO3Q' + +# Update to match your chosen parameters +INCLUDE = [] + + +def get_log_entry(): + url = 'https://api.pagerduty.com/log_entries/{id}'.format(id=ID) + headers = { + 'Accept': 'application/vnd.pagerduty+json;version=2', + 'Authorization': 'Token token={token}'.format(token=API_KEY) + } + payload = { + 'include[]': INCLUDE + } + r = requests.get(url, headers=headers, params=payload) + print('Status Code: {code}'.format(code=r.status_code)) + print(r.json()) + +if __name__ == '__main__': + get_log_entry() diff --git a/python_v3/REST_API_v2/LogEntries/list_log_entries.py b/python_v3/REST_API_v2/LogEntries/list_log_entries.py new file mode 100755 index 0000000..04da706 --- /dev/null +++ b/python_v3/REST_API_v2/LogEntries/list_log_entries.py @@ -0,0 +1,61 @@ +#!/usr/bin/env python +# +# Copyright (c) 2016, 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. + +import requests + +# Update to match your API key +API_KEY = '3c3gRvzx7uGfMYEnWKvF' + +# Update to match your chosen parameters +TIME_ZONE = 'UTC' +SINCE = '' +UNTIL = '' +IS_OVERVIEW = False +INCLUDE = [] + + +def list_log_entries(): + url = 'https://api.pagerduty.com/log_entries' + headers = { + 'Accept': 'application/vnd.pagerduty+json;version=2', + 'Authorization': 'Token token={token}'.format(token=API_KEY) + } + payload = { + 'time_zone': TIME_ZONE, + 'is_overview': IS_OVERVIEW, + 'include[]': INCLUDE + } + if SINCE != '': + payload['since'] = SINCE + 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()) + +if __name__ == '__main__': + list_log_entries() diff --git a/python_v3/REST_API_v2/MaintenanceWindows/create_maintenance_window.py b/python_v3/REST_API_v2/MaintenanceWindows/create_maintenance_window.py new file mode 100755 index 0000000..164e29e --- /dev/null +++ b/python_v3/REST_API_v2/MaintenanceWindows/create_maintenance_window.py @@ -0,0 +1,72 @@ +#!/usr/bin/env python +# +# Copyright (c) 2016, 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. + +import requests +import json + +# Update to match your API key +API_KEY = '3c3gRvzx7uGfMYEnWKvF' + +# Update to match your email address +EMAIL = 'lucas@pagerduty.com' + +# Update to match your chosen parameters +START_TIME = '2016-05-23T14:00:00-07:00' +END_TIME = '2016-05-23T18:00:00-07:00' +DESCRIPTION = 'Enter your maintenance window description here' +SERVICES = [{ + 'id': 'PKWA90D', + 'type': 'service_reference' +}] +TEAMS = [] +TYPE = 'maintenance_window' + + +def create_maintenance_window(): + 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('Status Code: {code}'.format(code=r.status_code)) + print(r.json()) + +if __name__ == '__main__': + create_maintenance_window() diff --git a/python_v3/REST_API_v2/MaintenanceWindows/delete_or_end_maintenance_window.py b/python_v3/REST_API_v2/MaintenanceWindows/delete_or_end_maintenance_window.py new file mode 100755 index 0000000..02ea570 --- /dev/null +++ b/python_v3/REST_API_v2/MaintenanceWindows/delete_or_end_maintenance_window.py @@ -0,0 +1,48 @@ +#!/usr/bin/env python +# +# Copyright (c) 2016, 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. + +import requests + +# Update to match your API key +API_KEY = '3c3gRvzx7uGfMYEnWKvF' + +# Update to match ID of resource you want to delete +ID = 'PER23E0' + + +def delete_maintenance_window(): + url = 'https://api.pagerduty.com/maintenance_windows/{id}'.format(id=ID) + headers = { + 'Accept': 'application/vnd.pagerduty+json;version=2', + '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) + +if __name__ == '__main__': + delete_maintenance_window() diff --git a/REST_API_v2/MaintenanceWindows/end_all_maintenance_windows.py b/python_v3/REST_API_v2/MaintenanceWindows/end_all_maintenance_windows.py similarity index 100% rename from REST_API_v2/MaintenanceWindows/end_all_maintenance_windows.py rename to python_v3/REST_API_v2/MaintenanceWindows/end_all_maintenance_windows.py diff --git a/python_v3/REST_API_v2/MaintenanceWindows/get_maintenance_window.py b/python_v3/REST_API_v2/MaintenanceWindows/get_maintenance_window.py new file mode 100755 index 0000000..78b956b --- /dev/null +++ b/python_v3/REST_API_v2/MaintenanceWindows/get_maintenance_window.py @@ -0,0 +1,54 @@ +#!/usr/bin/env python +# +# Copyright (c) 2016, 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. + +import requests + +# Update to match your API key +API_KEY = '3c3gRvzx7uGfMYEnWKvF' + +# Update to match ID of resource you want to GET +ID = 'P5B7MVH' + +# Update to match your chosen parameters +INCLUDE = [] + + +def get_maintenance_window(): + url = 'https://api.pagerduty.com/maintenance_windows/{id}'.format(id=ID) + headers = { + 'Accept': 'application/vnd.pagerduty+json;version=2', + 'Authorization': 'Token token={token}'.format(token=API_KEY) + } + payload = { + 'include[]': INCLUDE + } + r = requests.get(url, headers=headers, params=payload) + print('Status Code: {code}'.format(code=r.status_code)) + print(r.json()) + +if __name__ == '__main__': + get_maintenance_window() diff --git a/python_v3/REST_API_v2/MaintenanceWindows/list_maintenance_windows.py b/python_v3/REST_API_v2/MaintenanceWindows/list_maintenance_windows.py new file mode 100755 index 0000000..72cc8c1 --- /dev/null +++ b/python_v3/REST_API_v2/MaintenanceWindows/list_maintenance_windows.py @@ -0,0 +1,59 @@ +#!/usr/bin/env python +# +# Copyright (c) 2016, 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. + +import requests + +# Update to match your API key +API_KEY = '3c3gRvzx7uGfMYEnWKvF' + +# Update to match your chosen parameters +TEAM_IDS = [] +SERVICE_IDS = [] +INCLUDE = [] +FILTER = 'all' +QUERY = '' + + +def list_maintenance_windows(): + url = 'https://api.pagerduty.com/maintenance_windows' + headers = { + 'Accept': 'application/vnd.pagerduty+json;version=2', + 'Authorization': 'Token token={token}'.format(token=API_KEY) + } + payload = { + 'team_ids[]': TEAM_IDS, + 'service_ids[]': SERVICE_IDS, + 'include[]': INCLUDE, + 'filter': FILTER, + 'query': QUERY + } + r = requests.get(url, headers=headers, params=payload) + print('Status Code: {code}'.format(code=r.status_code)) + print(r.json()) + +if __name__ == '__main__': + list_maintenance_windows() diff --git a/python_v3/REST_API_v2/MaintenanceWindows/update_maintenance_window.py b/python_v3/REST_API_v2/MaintenanceWindows/update_maintenance_window.py new file mode 100755 index 0000000..4709db7 --- /dev/null +++ b/python_v3/REST_API_v2/MaintenanceWindows/update_maintenance_window.py @@ -0,0 +1,71 @@ +#!/usr/bin/env python +# +# Copyright (c) 2016, 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. + +import requests +import json + +# Update to match your API key +API_KEY = '3c3gRvzx7uGfMYEnWKvF' + +# Update to match ID of resource you want to update +ID = 'PE54NW4' + +# Update to match your chosen parameters +START_TIME = '2016-05-23T14:00:00-07:00' +END_TIME = '2016-05-23T18:00:00-07:00' +DESCRIPTION = 'Enter your updated maintenance window description here' +SERVICES = [{ + 'id': 'PKWA90D', + 'type': 'service_reference' +}] +TEAMS = [] +TYPE = 'maintenance_window' + + +def update_maintenance_window(): + url = 'https://api.pagerduty.com/maintenance_windows/{id}'.format(id=ID) + headers = { + 'Accept': 'application/vnd.pagerduty+json;version=2', + 'Authorization': 'Token token={token}'.format(token=API_KEY), + 'Content-type': 'application/json' + } + payload = { + 'maintenance_window': { + 'start_time': START_TIME, + 'end_time': END_TIME, + 'description': DESCRIPTION, + 'services': SERVICES, + 'teams': TEAMS, + 'type': TYPE + } + } + r = requests.put(url, headers=headers, data=json.dumps(payload)) + print('Status Code: {code}'.format(code=r.status_code)) + print(r.json()) + +if __name__ == '__main__': + update_maintenance_window() diff --git a/python_v3/REST_API_v2/Notifications/list_notifications.py b/python_v3/REST_API_v2/Notifications/list_notifications.py new file mode 100755 index 0000000..b94a0c4 --- /dev/null +++ b/python_v3/REST_API_v2/Notifications/list_notifications.py @@ -0,0 +1,59 @@ +#!/usr/bin/env python +# +# Copyright (c) 2016, 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. + +import requests + +# Update to match your API key +API_KEY = '3c3gRvzx7uGfMYEnWKvF' + +# Update to match your chosen parameters +TIME_ZONE = 'UTC' +SINCE = '2016-05-15' +UNTIL = '2016-05-20' +FILTER = 'sms_notification' +INCLUDE = [] + + +def list_notifications(): + url = 'https://api.pagerduty.com/notifications' + headers = { + 'Accept': 'application/vnd.pagerduty+json;version=2', + 'Authorization': 'Token token={token}'.format(token=API_KEY) + } + payload = { + 'time_zone': TIME_ZONE, + 'since': SINCE, + 'until': UNTIL, + 'filter': FILTER, + 'include[]': INCLUDE + } + r = requests.get(url, headers=headers, params=payload) + print('Status Code: {code}'.format(code=r.status_code)) + print(r.json()) + +if __name__ == '__main__': + list_notifications() diff --git a/python_v3/REST_API_v2/OnCalls/list_oncalls.py b/python_v3/REST_API_v2/OnCalls/list_oncalls.py new file mode 100755 index 0000000..c2a12da --- /dev/null +++ b/python_v3/REST_API_v2/OnCalls/list_oncalls.py @@ -0,0 +1,65 @@ +#!/usr/bin/env python +# +# Copyright (c) 2016, 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. + +import requests + +# Update to match your API key +API_KEY = '3c3gRvzx7uGfMYEnWKvF' + +# Update to match your chosen parameters +TIME_ZONE = 'UTC' +INCLUDE = [] +USER_IDS = [] +ESCALATION_POLICY_IDS = [] +SCHEDULE_IDS = [] +SINCE = '' +UNTIL = '' +EARLIEST = False + + +def list_oncalls(): + url = 'https://api.pagerduty.com/oncalls' + headers = { + 'Accept': 'application/vnd.pagerduty+json;version=2', + 'Authorization': 'Token token={token}'.format(token=API_KEY) + } + payload = { + 'time_zone': TIME_ZONE, + 'include[]': INCLUDE, + 'user_ids[]': USER_IDS, + 'escalation_policy_ids[]': ESCALATION_POLICY_IDS, + 'schedule_ids[]': SCHEDULE_IDS, + 'since': SINCE, + 'until': UNTIL, + 'earliest': EARLIEST + } + r = requests.get(url, headers=headers, params=payload) + print('Status Code: {code}'.format(code=r.status_code)) + print(r.json()) + +if __name__ == '__main__': + list_oncalls() diff --git a/python_v3/REST_API_v2/Schedules/create_override.py b/python_v3/REST_API_v2/Schedules/create_override.py new file mode 100755 index 0000000..7e4cde5 --- /dev/null +++ b/python_v3/REST_API_v2/Schedules/create_override.py @@ -0,0 +1,67 @@ +#!/usr/bin/env python +# +# Copyright (c) 2016, 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. + +import requests +import json + +# Update to match your API key +API_KEY = '3c3gRvzx7uGfMYEnWKvF' + +# Update to match the schedule ID +SCHEDULE_ID = 'PJGJ9RZ' + +# Update to match your chosen parameters +USER_ID = 'PAZZ8LZ' +START = '2016-06-01' +END = '2016-07-01' + + +def create_override(): + url = 'https://api.pagerduty.com/schedules/{id}/overrides'.format( + id=SCHEDULE_ID + ) + headers = { + 'Accept': 'application/vnd.pagerduty+json;version=2', + 'Authorization': 'Token token={token}'.format(token=API_KEY), + 'Content-type': 'application/json' + } + payload = { + 'override': { + 'start': START, + 'end': END, + 'user': { + 'id': USER_ID, + 'type': 'user_reference' + } + } + } + r = requests.post(url, headers=headers, data=json.dumps(payload)) + print('Status Code: {code}'.format(code=r.status_code)) + print(r.json()) + +if __name__ == '__main__': + create_override() diff --git a/python_v3/REST_API_v2/Schedules/create_schedule.py b/python_v3/REST_API_v2/Schedules/create_schedule.py new file mode 100755 index 0000000..fbe1588 --- /dev/null +++ b/python_v3/REST_API_v2/Schedules/create_schedule.py @@ -0,0 +1,134 @@ +#!/usr/bin/env python +# +# Copyright (c) 2016, 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. + +import requests +import json + +# Update to match your API key +API_KEY = '3c3gRvzx7uGfMYEnWKvF' + +# Update to match your chosen parameters +OVERFLOW = False + +# Update to match your chosen parameters for the overall schedule +TYPE = 'schedule' +SUMMARY = 'Insert your schedule summary here' +NAME = 'Insert your schedule name here' +TIME_ZONE = 'UTC' +ESCALATION_POLICIES = [] +TEAMS = [] + +# Update to match your chosen parameters for each schedule layer +LAYER_ONE_START = '2016-05-23T18:00:00-07:00' +LAYER_ONE_END = '2016-06-23T18:00:00-07:00' +LAYER_ONE_USERS = [ + { + 'id': 'PAZZ8LZ', + 'type': 'user_reference' + }, + { + 'id': 'P1PJUIZ', + 'type': 'user_reference' + } +] +LAYER_ONE_RESTRICTION_TYPE = 'Daily' +LAYER_ONE_RESTRICTIONS = [] +LAYER_ONE_ROTATION_VIRTUAL_START = '2016-05-23T18:00:00-07:00' +LAYER_ONE_PRIORITY = 1 +LAYER_ONE_ROTATION_TURN_LENGTH_SECONDS = 60 * 60 * 24 # 24 hours +LAYER_ONE_NAME = 'Insert layer one name here' + +LAYER_TWO_START = '2016-05-23T18:00:00-07:00' +LAYER_TWO_END = '2016-06-23T18:00:00-07:00' +LAYER_TWO_USERS = [ + { + 'id': 'POC4AOM', + 'type': 'user_reference' + }, + { + 'id': 'PLUWO2C', + 'type': 'user_reference' + } +] +LAYER_TWO_RESTRICTION_TYPE = 'Weekly' +LAYER_TWO_RESTRICTIONS = [] +LAYER_TWO_ROTATION_VIRTUAL_START = '2016-05-23T18:00:00-07:00' +LAYER_TWO_PRIORITY = 1 +LAYER_TWO_ROTATION_TURN_LENGTH_SECONDS = 60 * 60 * 24 # 24 hours +LAYER_TWO_NAME = 'Insert layer two name here' + + +def create_schedule(): + url = 'https://api.pagerduty.com/schedules' + headers = { + 'Accept': 'application/vnd.pagerduty+json;version=2', + 'Authorization': 'Token token={token}'.format(token=API_KEY), + 'Content-type': 'application/json' + } + payload = { + 'overflow': OVERFLOW, + 'schedule': { + 'type': TYPE, + 'summary': SUMMARY, + 'name': NAME, + 'time_zone': TIME_ZONE, + 'escalation_policies': ESCALATION_POLICIES, + 'teams': TEAMS, + 'schedule_layers': [ + { + 'start': LAYER_ONE_START, + 'end': LAYER_ONE_END, + 'users': LAYER_ONE_USERS, + 'restriction_type': LAYER_ONE_RESTRICTION_TYPE, + 'restrictions': LAYER_ONE_RESTRICTIONS, + 'rotation_virtual_start': LAYER_ONE_ROTATION_VIRTUAL_START, + 'priority': LAYER_ONE_PRIORITY, + 'rotation_turn_length_seconds': + LAYER_ONE_ROTATION_TURN_LENGTH_SECONDS, + 'name': LAYER_ONE_NAME + }, + { + 'start': LAYER_TWO_START, + 'end': LAYER_TWO_END, + 'users': LAYER_TWO_USERS, + 'restriction_type': LAYER_TWO_RESTRICTION_TYPE, + 'restrictions': LAYER_TWO_RESTRICTIONS, + 'rotation_virtual_start': LAYER_TWO_ROTATION_VIRTUAL_START, + 'priority': LAYER_TWO_PRIORITY, + 'rotation_turn_length_seconds': + LAYER_TWO_ROTATION_TURN_LENGTH_SECONDS, + 'name': LAYER_TWO_NAME + } + ] + } + } + r = requests.post(url, headers=headers, data=json.dumps(payload)) + print('Status Code: {code}'.format(code=r.status_code)) + print(r.json()) + +if __name__ == '__main__': + create_schedule() diff --git a/python_v3/REST_API_v2/Schedules/delete_override.py b/python_v3/REST_API_v2/Schedules/delete_override.py new file mode 100755 index 0000000..19b762e --- /dev/null +++ b/python_v3/REST_API_v2/Schedules/delete_override.py @@ -0,0 +1,52 @@ +#!/usr/bin/env python +# +# Copyright (c) 2016, 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. + +import requests + +# Update to match your API key +API_KEY = '3c3gRvzx7uGfMYEnWKvF' + +# Update to match the IDs of the schedule and override you want to delete +SCHEDULE_ID = 'PJGJ9RZ' +OVERRIDE_ID = 'Q0PVCKPSTNQUGG' + + +def delete_override(): + url = 'https://api.pagerduty.com/schedules/{sid}/overrides/{oid}'.format( + sid=SCHEDULE_ID, + oid=OVERRIDE_ID + ) + headers = { + 'Accept': 'application/vnd.pagerduty+json;version=2', + '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) + +if __name__ == '__main__': + delete_override() diff --git a/python_v3/REST_API_v2/Schedules/delete_schedule.py b/python_v3/REST_API_v2/Schedules/delete_schedule.py new file mode 100755 index 0000000..ca31253 --- /dev/null +++ b/python_v3/REST_API_v2/Schedules/delete_schedule.py @@ -0,0 +1,48 @@ +#!/usr/bin/env python +# +# Copyright (c) 2016, 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. + +import requests + +# Update to match your API key +API_KEY = '3c3gRvzx7uGfMYEnWKvF' + +# Update to match ID of resource you want to delete +ID = 'PQX3A8C' + + +def delete_schedule(): + url = 'https://api.pagerduty.com/schedules/{id}'.format(id=ID) + headers = { + 'Accept': 'application/vnd.pagerduty+json;version=2', + '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) + +if __name__ == '__main__': + delete_schedule() diff --git a/python_v3/REST_API_v2/Schedules/get_schedule.py b/python_v3/REST_API_v2/Schedules/get_schedule.py new file mode 100755 index 0000000..084c18e --- /dev/null +++ b/python_v3/REST_API_v2/Schedules/get_schedule.py @@ -0,0 +1,60 @@ +#!/usr/bin/env python +# +# Copyright (c) 2016, 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. + +import requests + +# Update to match your API key +API_KEY = '3c3gRvzx7uGfMYEnWKvF' + +# Update to match your schedule ID +ID = 'PW73MZF' + +# Update to match your chosen parameters +TIME_ZONE = 'UTC' +SINCE = '' +UNTIL = '' + + +def get_schedule(): + url = 'https://api.pagerduty.com/schedules/{id}'.format(id=ID) + headers = { + 'Accept': 'application/vnd.pagerduty+json;version=2', + 'Authorization': 'Token token={token}'.format(token=API_KEY) + } + payload = { + 'time_zone': TIME_ZONE + } + if SINCE != '': + payload['since'] = SINCE + 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()) + +if __name__ == '__main__': + get_schedule() diff --git a/python_v3/REST_API_v2/Schedules/list_oncall_users.py b/python_v3/REST_API_v2/Schedules/list_oncall_users.py new file mode 100755 index 0000000..7fc4633 --- /dev/null +++ b/python_v3/REST_API_v2/Schedules/list_oncall_users.py @@ -0,0 +1,59 @@ +#!/usr/bin/env python +# +# Copyright (c) 2016, 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. + +import requests + +# Update to match your API key +API_KEY = '3c3gRvzx7uGfMYEnWKvF' + +# Update to match the schedule ID +SCHEDULE_ID = 'PJGJ9RZ' + +# Update to match your chosen parameters +SINCE = '' +UNTIL = '' + + +def list_overrides(): + url = 'https://api.pagerduty.com/schedules/{id}/users'.format( + id=SCHEDULE_ID + ) + headers = { + 'Accept': 'application/vnd.pagerduty+json;version=2', + 'Authorization': 'Token token={token}'.format(token=API_KEY) + } + payload = {} + if SINCE != '': + payload['since'] = SINCE + 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()) + +if __name__ == '__main__': + list_overrides() diff --git a/python_v3/REST_API_v2/Schedules/list_overrides.py b/python_v3/REST_API_v2/Schedules/list_overrides.py new file mode 100755 index 0000000..afa77a2 --- /dev/null +++ b/python_v3/REST_API_v2/Schedules/list_overrides.py @@ -0,0 +1,62 @@ +#!/usr/bin/env python +# +# Copyright (c) 2016, 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. + +import requests + +# Update to match your API key +API_KEY = '3c3gRvzx7uGfMYEnWKvF' + +# Update to match the schedule ID +SCHEDULE_ID = 'PJGJ9RZ' + +# Update to match your chosen parameters +SINCE = '2016-05-01' +UNTIL = '2016-06-01' +EDITABLE = False +OVERFLOW = False + + +def list_overrides(): + url = 'https://api.pagerduty.com/schedules/{id}/overrides'.format( + id=SCHEDULE_ID + ) + headers = { + 'Accept': 'application/vnd.pagerduty+json;version=2', + 'Authorization': 'Token token={token}'.format(token=API_KEY) + } + payload = { + 'since': SINCE, + 'until': UNTIL, + 'editable': EDITABLE, + 'overflow': OVERFLOW + } + r = requests.get(url, headers=headers, params=payload) + print('Status Code: {code}'.format(code=r.status_code)) + print(r.json()) + +if __name__ == '__main__': + list_overrides() diff --git a/python_v3/REST_API_v2/Schedules/list_schedules.py b/python_v3/REST_API_v2/Schedules/list_schedules.py new file mode 100755 index 0000000..de50bd2 --- /dev/null +++ b/python_v3/REST_API_v2/Schedules/list_schedules.py @@ -0,0 +1,51 @@ +#!/usr/bin/env python +# +# Copyright (c) 2016, 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. + +import requests + +# Update to match your API key +API_KEY = '3c3gRvzx7uGfMYEnWKvF' + +# Update to match your chosen parameters +QUERY = '' + + +def list_schedules(): + url = 'https://api.pagerduty.com/schedules' + headers = { + 'Accept': 'application/vnd.pagerduty+json;version=2', + 'Authorization': 'Token token={token}'.format(token=API_KEY) + } + payload = { + 'query': QUERY + } + r = requests.get(url, headers=headers, params=payload) + print('Status Code: {code}'.format(code=r.status_code)) + print(r.json()) + +if __name__ == '__main__': + list_schedules() diff --git a/python_v3/REST_API_v2/Schedules/preview_schedule.py b/python_v3/REST_API_v2/Schedules/preview_schedule.py new file mode 100755 index 0000000..6fb976b --- /dev/null +++ b/python_v3/REST_API_v2/Schedules/preview_schedule.py @@ -0,0 +1,146 @@ +#!/usr/bin/env python +# +# Copyright (c) 2016, 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. + +import requests +import json + +# Update to match your API key +API_KEY = '3c3gRvzx7uGfMYEnWKvF' + +# Update to match your chosen parameters +OVERFLOW = False +SINCE = '2016-05-25T00:00:00-07:00' +UNTIL = '2016-06-01T00:00:00-07:00' + +# Update to match your chosen parameters for the overall schedule +TYPE = 'schedule' +SUMMARY = 'Insert your schedule summary here' +NAME = 'Insert your schedule name here' +TIME_ZONE = 'UTC' +ESCALATION_POLICIES = [] +TEAMS = [] + +# Update to match your chosen parameters for each schedule layer +LAYER_ONE_START = '2016-05-23T18:00:00-07:00' +LAYER_ONE_END = '2016-06-23T18:00:00-07:00' +LAYER_ONE_USERS = [ + { + 'user': { + 'id': 'PAZZ8LZ', + 'type': 'user_reference' + } + }, + { + 'user': { + 'id': 'P1PJUIZ', + 'type': 'user_reference' + } + } +] +LAYER_ONE_RESTRICTION_TYPE = 'Daily' +LAYER_ONE_RESTRICTIONS = [] +LAYER_ONE_ROTATION_VIRTUAL_START = '2016-05-23T18:00:00-07:00' +LAYER_ONE_PRIORITY = 1 +LAYER_ONE_ROTATION_TURN_LENGTH_SECONDS = 60 * 60 * 24 # 24 hours +LAYER_ONE_NAME = 'Insert layer one name here' + +LAYER_TWO_START = '2016-05-23T18:00:00-07:00' +LAYER_TWO_END = '2016-06-23T18:00:00-07:00' +LAYER_TWO_USERS = [ + { + 'user': { + 'id': 'POC4AOM', + 'type': 'user_reference' + } + }, + { + 'user': { + 'id': 'PLUWO2C', + 'type': 'user_reference' + } + } +] +LAYER_TWO_RESTRICTION_TYPE = 'Weekly' +LAYER_TWO_RESTRICTIONS = [] +LAYER_TWO_ROTATION_VIRTUAL_START = '2016-05-23T18:00:00-07:00' +LAYER_TWO_PRIORITY = 1 +LAYER_TWO_ROTATION_TURN_LENGTH_SECONDS = 60 * 60 * 24 # 24 hours +LAYER_TWO_NAME = 'Insert layer two name here' + + +def preview_schedule(): + url = 'https://api.pagerduty.com/schedules/preview' + headers = { + 'Accept': 'application/vnd.pagerduty+json;version=2', + 'Authorization': 'Token token={token}'.format(token=API_KEY), + 'Content-type': 'application/json' + } + payload = { + 'since': SINCE, + 'until': UNTIL, + 'overflow': OVERFLOW, + 'schedule': { + 'type': TYPE, + 'summary': SUMMARY, + 'name': NAME, + 'time_zone': TIME_ZONE, + 'escalation_policies': ESCALATION_POLICIES, + 'teams': TEAMS, + 'schedule_layers': [ + { + 'start': LAYER_ONE_START, + 'end': LAYER_ONE_END, + 'users': LAYER_ONE_USERS, + 'restriction_type': LAYER_ONE_RESTRICTION_TYPE, + 'restrictions': LAYER_ONE_RESTRICTIONS, + 'rotation_virtual_start': LAYER_ONE_ROTATION_VIRTUAL_START, + 'priority': LAYER_ONE_PRIORITY, + 'rotation_turn_length_seconds': + LAYER_ONE_ROTATION_TURN_LENGTH_SECONDS, + 'name': LAYER_ONE_NAME + }, + { + 'start': LAYER_TWO_START, + 'end': LAYER_TWO_END, + 'users': LAYER_TWO_USERS, + 'restriction_type': LAYER_TWO_RESTRICTION_TYPE, + 'restrictions': LAYER_TWO_RESTRICTIONS, + 'rotation_virtual_start': LAYER_TWO_ROTATION_VIRTUAL_START, + 'priority': LAYER_TWO_PRIORITY, + 'rotation_turn_length_seconds': + LAYER_TWO_ROTATION_TURN_LENGTH_SECONDS, + 'name': LAYER_TWO_NAME + } + ] + } + } + r = requests.post(url, headers=headers, data=json.dumps(payload)) + print('Status Code: {code}'.format(code=r.status_code)) + print(r.json()) + +if __name__ == '__main__': + preview_schedule() diff --git a/python_v3/REST_API_v2/Schedules/update_schedule.py b/python_v3/REST_API_v2/Schedules/update_schedule.py new file mode 100755 index 0000000..e9724fe --- /dev/null +++ b/python_v3/REST_API_v2/Schedules/update_schedule.py @@ -0,0 +1,145 @@ +#!/usr/bin/env python +# +# Copyright (c) 2016, 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. + +import requests +import json + +# Update to match your API key +API_KEY = '3c3gRvzx7uGfMYEnWKvF' + +# Update to match ID of resource you want to update +ID = 'PM6GOQG' + +# Update to match your chosen parameters +OVERFLOW = False + +# Update to match your chosen parameters for the overall schedule +TYPE = 'schedule' +SUMMARY = 'Insert your schedule summary here' +NAME = 'Insert your schedule name here' +TIME_ZONE = 'UTC' +ESCALATION_POLICIES = [] +TEAMS = [] + +# Update to match your chosen parameters for each schedule layer +LAYER_ONE_START = '2016-05-23T18:00:00-07:00' +LAYER_ONE_END = '2016-06-23T18:00:00-07:00' +LAYER_ONE_USERS = [ + { + 'user': { + 'id': 'PIZFCCH', + 'type': 'user_reference' + } + }, + { + 'user': { + 'id': 'P1PJUIZ', + 'type': 'user_reference' + } + } +] +LAYER_ONE_RESTRICTION_TYPE = 'Daily' +LAYER_ONE_RESTRICTIONS = [] +LAYER_ONE_ROTATION_VIRTUAL_START = '2016-05-23T18:00:00-07:00' +LAYER_ONE_PRIORITY = 1 +LAYER_ONE_ROTATION_TURN_LENGTH_SECONDS = 60 * 60 * 24 # 24 hours +LAYER_ONE_NAME = 'Insert layer one name here' + +LAYER_TWO_START = '2016-05-23T18:00:00-07:00' +LAYER_TWO_END = '2016-06-23T18:00:00-07:00' +LAYER_TWO_USERS = [ + { + 'user': { + 'id': 'POC4AOM', + 'type': 'user_reference' + } + }, + { + 'user': { + 'id': 'PLUWO2C', + 'type': 'user_reference' + } + } +] +LAYER_TWO_RESTRICTION_TYPE = 'Weekly' +LAYER_TWO_RESTRICTIONS = [] +LAYER_TWO_ROTATION_VIRTUAL_START = '2016-05-23T18:00:00-07:00' +LAYER_TWO_PRIORITY = 1 +LAYER_TWO_ROTATION_TURN_LENGTH_SECONDS = 60 * 60 * 24 # 24 hours +LAYER_TWO_NAME = 'Insert layer two name here' + + +def update_schedule(): + url = 'https://api.pagerduty.com/schedules/{id}'.format(id=ID) + headers = { + 'Accept': 'application/vnd.pagerduty+json;version=2', + 'Authorization': 'Token token={token}'.format(token=API_KEY), + 'Content-type': 'application/json' + } + payload = { + 'overflow': OVERFLOW, + 'schedule': { + 'type': TYPE, + 'summary': SUMMARY, + 'name': NAME, + 'time_zone': TIME_ZONE, + 'escalation_policies': ESCALATION_POLICIES, + 'teams': TEAMS, + 'schedule_layers': [ + { + 'start': LAYER_ONE_START, + 'end': LAYER_ONE_END, + 'users': LAYER_ONE_USERS, + 'restriction_type': LAYER_ONE_RESTRICTION_TYPE, + 'restrictions': LAYER_ONE_RESTRICTIONS, + 'rotation_virtual_start': LAYER_ONE_ROTATION_VIRTUAL_START, + 'priority': LAYER_ONE_PRIORITY, + 'rotation_turn_length_seconds': + LAYER_ONE_ROTATION_TURN_LENGTH_SECONDS, + 'name': LAYER_ONE_NAME + }, + { + 'start': LAYER_TWO_START, + 'end': LAYER_TWO_END, + 'users': LAYER_TWO_USERS, + 'restriction_type': LAYER_TWO_RESTRICTION_TYPE, + 'restrictions': LAYER_TWO_RESTRICTIONS, + 'rotation_virtual_start': LAYER_TWO_ROTATION_VIRTUAL_START, + 'priority': LAYER_TWO_PRIORITY, + 'rotation_turn_length_seconds': + LAYER_TWO_ROTATION_TURN_LENGTH_SECONDS, + 'name': LAYER_TWO_NAME + } + ] + } + } + r = requests.put(url, headers=headers, data=json.dumps(payload)) + print('Status Code: {code}'.format(code=r.status_code)) + print(r.json()) + +if __name__ == '__main__': + update_schedule() diff --git a/python_v3/REST_API_v2/Services/create_integration.py b/python_v3/REST_API_v2/Services/create_integration.py new file mode 100755 index 0000000..6baba79 --- /dev/null +++ b/python_v3/REST_API_v2/Services/create_integration.py @@ -0,0 +1,70 @@ +#!/usr/bin/env python +# +# Copyright (c) 2016, 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. + +import requests +import json + +# Update to match your API key +API_KEY = '3c3gRvzx7uGfMYEnWKvF' + +# Update to match the service ID +SERVICE_ID = 'PK2X17C' + +# Update to match your chosen parameters +TYPE = 'generic_email_inbound_integration' +SUMMARY = 'Enter your integration summary here' +NAME = 'Enter your integration name here' +VENDOR = None +# Only required if creating email integration +INTEGRATION_EMAIL = 'insert_email@ENTER_YOUR_PD_SUBDOMAIN.pagerduty.com' + + +def create_integration(): + url = 'https://api.pagerduty.com/services/{id}/integrations'.format( + id=SERVICE_ID + ) + headers = { + 'Accept': 'application/vnd.pagerduty+json;version=2', + 'Authorization': 'Token token={token}'.format(token=API_KEY), + 'Content-type': 'application/json' + } + payload = { + 'integration': { + 'type': TYPE, + 'summary': SUMMARY, + 'name': NAME, + 'vendor': VENDOR + } + } + 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()) + +if __name__ == '__main__': + create_integration() diff --git a/python_v3/REST_API_v2/Services/create_service.py b/python_v3/REST_API_v2/Services/create_service.py new file mode 100755 index 0000000..cafd60b --- /dev/null +++ b/python_v3/REST_API_v2/Services/create_service.py @@ -0,0 +1,103 @@ +#!/usr/bin/env python +# +# Copyright (c) 2016, 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. + +import requests +import json + +# Update to match your API key +API_KEY = '3c3gRvzx7uGfMYEnWKvF' + +# Update to match your chosen parameters +NAME = 'Insert service name here' +DESCRIPTION = 'Insert service description here' +ESCALATION_POLICY_ID = 'PIX2DN3' +TYPE = 'service' +AUTO_RESOLVE_TIMEOUT = 14400 # 4 hours +ACKNOWLEDGEMENT_TIMEOUT = 1800 # 30 minutes +TEAMS = [] +INCIDENT_URGENCY = 'high' # used during support hours or as default urgency +OUTSIDE_SUPPORT_HOURS_URGENCY = 'low' +SCHEDULED_ACTIONS = [] +SUPPORT_HOURS = { + 'type': 'fixed_time_per_day', + 'time_zone': 'UTC', + 'days_of_week': [1, 2, 3, 4, 5], + 'start_time': '09:00:00', + 'end_time': '17:00:00' +} +INTEGRATIONS = [] +ADDONS = [] + + +def create_service(): + url = 'https://api.pagerduty.com/services' + headers = { + 'Accept': 'application/vnd.pagerduty+json;version=2', + 'Authorization': 'Token token={token}'.format(token=API_KEY), + 'Content-type': 'application/json' + } + payload = { + 'service': { + 'name': NAME, + 'description': DESCRIPTION, + 'escalation_policy': { + 'id': ESCALATION_POLICY_ID, + 'type': 'escalation_policy' + }, + 'type': TYPE, + 'auto_resolve_timeout': AUTO_RESOLVE_TIMEOUT, + 'acknowledgement_timeout': ACKNOWLEDGEMENT_TIMEOUT, + 'teams': TEAMS, + 'scheduled_actions': SCHEDULED_ACTIONS, + 'integrations': INTEGRATIONS, + 'addons': ADDONS, + 'support_hours': SUPPORT_HOURS + } + } + if not SUPPORT_HOURS: + payload['service']['incident_urgency_rule'] = { + 'type': 'constant', + 'urgency': INCIDENT_URGENCY + } + else: + payload['service']['incident_urgency_rule'] = { + 'type': 'use_support_hours', + 'during_support_hours': { + 'type': 'constant', + 'urgency': INCIDENT_URGENCY + }, + 'outside_support_hours': { + 'type': 'constant', + 'urgency': OUTSIDE_SUPPORT_HOURS_URGENCY + } + } + r = requests.post(url, headers=headers, data=json.dumps(payload)) + print('Status Code: {code}'.format(code=r.status_code)) + print(r.json()) + +if __name__ == '__main__': + create_service() diff --git a/python_v3/REST_API_v2/Services/delete_service.py b/python_v3/REST_API_v2/Services/delete_service.py new file mode 100755 index 0000000..945686d --- /dev/null +++ b/python_v3/REST_API_v2/Services/delete_service.py @@ -0,0 +1,48 @@ +#!/usr/bin/env python +# +# Copyright (c) 2016, 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. + +import requests + +# Update to match your API key +API_KEY = '3c3gRvzx7uGfMYEnWKvF' + +# Update to match ID of resource you want to delete +ID = 'PTRCGYM' + + +def delete_service(): + url = 'https://api.pagerduty.com/services/{id}'.format(id=ID) + headers = { + 'Accept': 'application/vnd.pagerduty+json;version=2', + '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) + +if __name__ == '__main__': + delete_service() diff --git a/python_v3/REST_API_v2/Services/get_integration.py b/python_v3/REST_API_v2/Services/get_integration.py new file mode 100755 index 0000000..b3ea2eb --- /dev/null +++ b/python_v3/REST_API_v2/Services/get_integration.py @@ -0,0 +1,58 @@ +#!/usr/bin/env python +# +# Copyright (c) 2016, 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. + +import requests + +# Update to match your API key +API_KEY = '3c3gRvzx7uGfMYEnWKvF' + +# Update to match your service and integration IDs +SERVICE_ID = 'PAU38PJ' +INTEGRATION_ID = 'PTT2FMS' + +# Update to match your chosen parameters +INCLUDE = [] + + +def get_integration(): + url = 'https://api.pagerduty.com/services/{sid}/integrations/{iid}'.format( + sid=SERVICE_ID, + iid=INTEGRATION_ID + ) + headers = { + 'Accept': 'application/vnd.pagerduty+json;version=2', + 'Authorization': 'Token token={token}'.format(token=API_KEY) + } + payload = { + 'include[]': INCLUDE + } + r = requests.get(url, headers=headers, params=payload) + print('Status Code: {code}'.format(code=r.status_code)) + print(r.json()) + +if __name__ == '__main__': + get_integration() diff --git a/python_v3/REST_API_v2/Services/get_service.py b/python_v3/REST_API_v2/Services/get_service.py new file mode 100755 index 0000000..95b64a6 --- /dev/null +++ b/python_v3/REST_API_v2/Services/get_service.py @@ -0,0 +1,54 @@ +#!/usr/bin/env python +# +# Copyright (c) 2016, 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. + +import requests + +# Update to match your API key +API_KEY = '3c3gRvzx7uGfMYEnWKvF' + +# Update to match your service ID +ID = 'PKWA90D' + +# Update to match your chosen parameters +INCLUDE = [] + + +def get_service(): + url = 'https://api.pagerduty.com/services/{id}'.format(id=ID) + headers = { + 'Accept': 'application/vnd.pagerduty+json;version=2', + 'Authorization': 'Token token={token}'.format(token=API_KEY) + } + payload = { + 'include[]': INCLUDE + } + r = requests.get(url, headers=headers, params=payload) + print('Status Code: {code}'.format(code=r.status_code)) + print(r.json()) + +if __name__ == '__main__': + get_service() diff --git a/python_v3/REST_API_v2/Services/list_services.py b/python_v3/REST_API_v2/Services/list_services.py new file mode 100755 index 0000000..04532e7 --- /dev/null +++ b/python_v3/REST_API_v2/Services/list_services.py @@ -0,0 +1,59 @@ +#!/usr/bin/env python +# +# Copyright (c) 2016, 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. + +import requests + +# Update to match your API key +API_KEY = '3c3gRvzx7uGfMYEnWKvF' + +# Update to match your chosen parameters +TEAM_IDS = [] +TIME_ZONE = 'UTC' +SORT_BY = 'name' +QUERY = '' +INCLUDE = [] + + +def list_services(): + url = 'https://api.pagerduty.com/services' + 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 + } + r = requests.get(url, headers=headers, params=payload) + print('Status Code: {code}'.format(code=r.status_code)) + print(r.json()) + +if __name__ == '__main__': + list_services() diff --git a/python_v3/REST_API_v2/Services/update_integration.py b/python_v3/REST_API_v2/Services/update_integration.py new file mode 100755 index 0000000..aaea2cb --- /dev/null +++ b/python_v3/REST_API_v2/Services/update_integration.py @@ -0,0 +1,64 @@ +#!/usr/bin/env python +# +# Copyright (c) 2016, 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. + +import requests +import json + +# Update to match your API key +API_KEY = '3c3gRvzx7uGfMYEnWKvF' + +# Update to match ID of resource you want to update +SERVICE_ID = 'PAU38PJ' +INTEGRATION_ID = 'PTT2FMS' + +# Update to match your chosen parameters +NAME = 'Insert your integration name here' +SUMMARY = 'Insert your integration summary here' + + +def update_integration(): + url = 'https://api.pagerduty.com/services/{sid}/integrations/{iid}'.format( + sid=SERVICE_ID, + iid=INTEGRATION_ID + ) + headers = { + 'Accept': 'application/vnd.pagerduty+json;version=2', + 'Authorization': 'Token token={token}'.format(token=API_KEY), + 'Content-type': 'application/json' + } + payload = { + 'integration': { + 'name': NAME, + 'summary': SUMMARY + } + } + r = requests.put(url, headers=headers, data=json.dumps(payload)) + print('Status Code: {code}'.format(code=r.status_code)) + print(r.json()) + +if __name__ == '__main__': + update_integration() diff --git a/python_v3/REST_API_v2/Services/update_service.py b/python_v3/REST_API_v2/Services/update_service.py new file mode 100755 index 0000000..1edddcd --- /dev/null +++ b/python_v3/REST_API_v2/Services/update_service.py @@ -0,0 +1,68 @@ +#!/usr/bin/env python +# +# Copyright (c) 2016, 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. + +import requests +import json + +# Update to match your API key +API_KEY = '3c3gRvzx7uGfMYEnWKvF' + +# Update to match ID of resource you want to update +ID = 'P8RK2P8' + +# Update to match your chosen parameters +NAME = 'Insert your service name here' +DESCRIPTION = 'Insert your service description here' +ESCALATION_POLICY_ID = 'PIX2DN3' +ACKNOWLEDGEMENT_TIMEOUT = 60 * 30 # 30 minutes +AUTO_RESOLVE_TIMEOUT = 60 * 60 * 4 # 4 hours +SEVERITY_FILTER = '' + + +def update_service(): + url = 'https://api.pagerduty.com/services/{id}'.format(id=ID) + headers = { + 'Accept': 'application/vnd.pagerduty+json;version=2', + 'Authorization': 'Token token={token}'.format(token=API_KEY), + 'Content-type': 'application/json' + } + payload = { + 'service': { + 'name': NAME, + 'description': DESCRIPTION, + 'escalation_policy_id': ESCALATION_POLICY_ID, + '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()) + +if __name__ == '__main__': + update_service() diff --git a/python_v3/REST_API_v2/Teams/add_escalation_policy_to_team.py b/python_v3/REST_API_v2/Teams/add_escalation_policy_to_team.py new file mode 100755 index 0000000..eb475da --- /dev/null +++ b/python_v3/REST_API_v2/Teams/add_escalation_policy_to_team.py @@ -0,0 +1,51 @@ +#!/usr/bin/env python +# +# Copyright (c) 2016, 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. + +import requests + +# Update to match your API key +API_KEY = '3c3gRvzx7uGfMYEnWKvF' + +# Update to match your IDs +TEAM_ID = 'PYYWGIO' +ESCALATION_POLICY_ID = 'PZPCKNC' + + +def add_escalation_policy_to_team(): + url = ('https://api.pagerduty.com/teams/{tid}/escalation_policies/{eid}' + .format(tid=TEAM_ID, eid=ESCALATION_POLICY_ID)) + headers = { + 'Accept': 'application/vnd.pagerduty+json;version=2', + 'Authorization': 'Token token={token}'.format(token=API_KEY), + 'Content-type': 'application/json' + } + r = requests.put(url, headers=headers) + print('Status Code: {code}'.format(code=r.status_code)) + print(r.text) + +if __name__ == '__main__': + add_escalation_policy_to_team() diff --git a/python_v3/REST_API_v2/Teams/add_user_to_team.py b/python_v3/REST_API_v2/Teams/add_user_to_team.py new file mode 100755 index 0000000..936e1d1 --- /dev/null +++ b/python_v3/REST_API_v2/Teams/add_user_to_team.py @@ -0,0 +1,53 @@ +#!/usr/bin/env python +# +# Copyright (c) 2016, 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. + +import requests + +# Update to match your API key +API_KEY = '' + +# Update to match your IDs +TEAM_ID = '' +USER_ID = '' + + +def add_user_to_team(): + url = 'https://api.pagerduty.com/teams/{tid}/users/{uid}'.format( + tid=TEAM_ID, + uid=USER_ID + ) + headers = { + 'Accept': 'application/vnd.pagerduty+json;version=2', + 'Authorization': 'Token token={token}'.format(token=API_KEY), + 'Content-type': 'application/json' + } + r = requests.put(url, headers=headers) + print('Status Code: {code}'.format(code=r.status_code)) + print(r.text) + +if __name__ == '__main__': + add_user_to_team() diff --git a/python_v3/REST_API_v2/Teams/create_team.py b/python_v3/REST_API_v2/Teams/create_team.py new file mode 100755 index 0000000..f8495f6 --- /dev/null +++ b/python_v3/REST_API_v2/Teams/create_team.py @@ -0,0 +1,59 @@ +#!/usr/bin/env python +# +# Copyright (c) 2016, 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. + +import requests +import json + +# Update to match your API key +API_KEY = '3c3gRvzx7uGfMYEnWKvF' + +# Update to match your chosen parameters +NAME = 'Insert team name here' +DESCRIPTION = 'Insert team description here' + + +def create_team(): + url = 'https://api.pagerduty.com/teams' + headers = { + 'Accept': 'application/vnd.pagerduty+json;version=2', + 'Authorization': 'Token token={token}'.format(token=API_KEY), + 'Content-type': 'application/json' + } + payload = { + 'team': { + 'type': 'team', + 'name': NAME, + 'description': DESCRIPTION, + 'summary': DESCRIPTION + } + } + r = requests.post(url, headers=headers, data=json.dumps(payload)) + print('Status Code: {code}'.format(code=r.status_code)) + print(r.json()) + +if __name__ == '__main__': + create_team() diff --git a/python_v3/REST_API_v2/Teams/delete_team.py b/python_v3/REST_API_v2/Teams/delete_team.py new file mode 100755 index 0000000..a4c0132 --- /dev/null +++ b/python_v3/REST_API_v2/Teams/delete_team.py @@ -0,0 +1,48 @@ +#!/usr/bin/env python +# +# Copyright (c) 2016, 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. + +import requests + +# Update to match your API key +API_KEY = '3c3gRvzx7uGfMYEnWKvF' + +# Update to match ID of resource you want to delete +ID = 'P53LIBV' + + +def delete_team(): + url = 'https://api.pagerduty.com/teams/{id}'.format(id=ID) + headers = { + 'Accept': 'application/vnd.pagerduty+json;version=2', + '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) + +if __name__ == '__main__': + delete_team() diff --git a/python_v3/REST_API_v2/Teams/get_team.py b/python_v3/REST_API_v2/Teams/get_team.py new file mode 100755 index 0000000..4e1d384 --- /dev/null +++ b/python_v3/REST_API_v2/Teams/get_team.py @@ -0,0 +1,48 @@ +#!/usr/bin/env python +# +# Copyright (c) 2016, 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. + +import requests + +# Update to match your API key +API_KEY = '3c3gRvzx7uGfMYEnWKvF' + +# Update to match your team ID +ID = 'PD28XX6' + + +def get_team(): + url = 'https://api.pagerduty.com/teams/{id}'.format(id=ID) + headers = { + 'Accept': 'application/vnd.pagerduty+json;version=2', + '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()) + +if __name__ == '__main__': + get_team() diff --git a/python_v3/REST_API_v2/Teams/list_teams.py b/python_v3/REST_API_v2/Teams/list_teams.py new file mode 100755 index 0000000..3a5fc89 --- /dev/null +++ b/python_v3/REST_API_v2/Teams/list_teams.py @@ -0,0 +1,51 @@ +#!/usr/bin/env python +# +# Copyright (c) 2016, 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. + +import requests + +# Update to match your API key +API_KEY = '3c3gRvzx7uGfMYEnWKvF' + +# Update to match your chosen parameters +QUERY = '' + + +def list_teams(): + url = 'https://api.pagerduty.com/teams' + headers = { + 'Accept': 'application/vnd.pagerduty+json;version=2', + 'Authorization': 'Token token={token}'.format(token=API_KEY) + } + payload = { + 'query': QUERY + } + r = requests.get(url, headers=headers, params=payload) + print('Status Code: {code}'.format(code=r.status_code)) + print(r.json()) + +if __name__ == '__main__': + list_teams() diff --git a/python_v3/REST_API_v2/Teams/remove_escalation_policy_from_team.py b/python_v3/REST_API_v2/Teams/remove_escalation_policy_from_team.py new file mode 100755 index 0000000..bc5cb74 --- /dev/null +++ b/python_v3/REST_API_v2/Teams/remove_escalation_policy_from_team.py @@ -0,0 +1,50 @@ +#!/usr/bin/env python +# +# Copyright (c) 2016, 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. + +import requests + +# Update to match your API key +API_KEY = '3c3gRvzx7uGfMYEnWKvF' + +# Update to match your IDs +TEAM_ID = 'PYYWGIO' +ESCALATION_POLICY_ID = 'PZPCKNC' + + +def remove_escalation_policy_from_team(): + url = ('https://api.pagerduty.com/teams/{tid}/escalation_policies/{eid}' + .format(tid=TEAM_ID, eid=ESCALATION_POLICY_ID)) + headers = { + 'Accept': 'application/vnd.pagerduty+json;version=2', + '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) + +if __name__ == '__main__': + remove_escalation_policy_from_team() diff --git a/python_v3/REST_API_v2/Teams/remove_user_from_team.py b/python_v3/REST_API_v2/Teams/remove_user_from_team.py new file mode 100755 index 0000000..4e658c2 --- /dev/null +++ b/python_v3/REST_API_v2/Teams/remove_user_from_team.py @@ -0,0 +1,52 @@ +#!/usr/bin/env python +# +# Copyright (c) 2016, 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. + +import requests + +# Update to match your API key +API_KEY = '3c3gRvzx7uGfMYEnWKvF' + +# Update to match your IDs +TEAM_ID = 'PYYWGIO' +USER_ID = 'P0H7Y7J' + + +def remove_user_from_team(): + url = 'https://api.pagerduty.com/teams/{tid}/users/{uid}'.format( + tid=TEAM_ID, + uid=USER_ID + ) + headers = { + 'Accept': 'application/vnd.pagerduty+json;version=2', + '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) + +if __name__ == '__main__': + remove_user_from_team() diff --git a/python_v3/REST_API_v2/Teams/update_team.py b/python_v3/REST_API_v2/Teams/update_team.py new file mode 100755 index 0000000..9657942 --- /dev/null +++ b/python_v3/REST_API_v2/Teams/update_team.py @@ -0,0 +1,60 @@ +#!/usr/bin/env python +# +# Copyright (c) 2016, 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. + +import requests +import json + +# Update to match your API key +API_KEY = '3c3gRvzx7uGfMYEnWKvF' + +# Update to match ID of resource you want to update +ID = 'PYYWGIO' + +# Update to match your chosen parameters +NAME = 'Insert your team name here' +DESCRIPTION = 'Insert your team description here' + + +def update_team(): + url = 'https://api.pagerduty.com/teams/{id}'.format(id=ID) + headers = { + 'Accept': 'application/vnd.pagerduty+json;version=2', + 'Authorization': 'Token token={token}'.format(token=API_KEY), + 'Content-type': 'application/json' + } + payload = { + 'team': { + 'name': NAME, + 'description': DESCRIPTION + } + } + r = requests.put(url, headers=headers, data=json.dumps(payload)) + print('Status Code: {code}'.format(code=r.status_code)) + print(r.json()) + +if __name__ == '__main__': + update_team() diff --git a/python_v3/REST_API_v2/Users/create_user.py b/python_v3/REST_API_v2/Users/create_user.py new file mode 100755 index 0000000..1688c94 --- /dev/null +++ b/python_v3/REST_API_v2/Users/create_user.py @@ -0,0 +1,64 @@ +#!/usr/bin/env python +# +# Copyright (c) 2016, 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. + +import requests +import json + +# Update to match your API key +API_KEY = '3c3gRvzx7uGfMYEnWKvF' + +# Update to match your PagerDuty email address +PD_EMAIL = 'lucas@pagerduty.com' + +# 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 + + +def create_user(): + url = 'https://api.pagerduty.com/users' + headers = { + 'Accept': 'application/vnd.pagerduty+json;version=2', + 'Authorization': 'Token token={token}'.format(token=API_KEY), + 'Content-type': 'application/json', + 'From': PD_EMAIL + } + payload = { + 'user': { + 'type': 'user', + 'name': NAME, + 'email': EMAIL, + 'role': ROLE + } + } + r = requests.post(url, headers=headers, data=json.dumps(payload)) + print('Status Code: {code}'.format(code=r.status_code)) + print(r.json()) + +if __name__ == '__main__': + create_user() diff --git a/python_v3/REST_API_v2/Users/create_user_contact_method.py b/python_v3/REST_API_v2/Users/create_user_contact_method.py new file mode 100755 index 0000000..1494bfe --- /dev/null +++ b/python_v3/REST_API_v2/Users/create_user_contact_method.py @@ -0,0 +1,62 @@ +#!/usr/bin/env python +# +# Copyright (c) 2016, 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. + +import requests +import json + +# Update to match your API key +API_KEY = '3c3gRvzx7uGfMYEnWKvF' + +# Update to match ID of user you want to update +ID = 'P0H7Y7J' + +# Update to match your chosen parameters +TYPE = 'email_contact_method' # Can be one of email_contact_method, sms_contact_method, phone_contact_method, or push_notification_contact_method # NOQA +ADDRESS = 'insert_email@here.com' +LABEL = 'Work' + + +def create_user_contact_method(): + url = 'https://api.pagerduty.com/users/{id}/contact_methods'.format(id=ID) + headers = { + 'Accept': 'application/vnd.pagerduty+json;version=2', + 'Authorization': 'Token token={token}'.format(token=API_KEY), + 'Content-type': 'application/json' + } + payload = { + 'contact_method': { + 'type': TYPE, + 'address': ADDRESS, + 'label': LABEL + } + } + r = requests.post(url, headers=headers, data=json.dumps(payload)) + print('Status Code: {code}'.format(code=r.status_code)) + print(r.json()) + +if __name__ == '__main__': + create_user_contact_method() diff --git a/python_v3/REST_API_v2/Users/create_user_notification_rule.py b/python_v3/REST_API_v2/Users/create_user_notification_rule.py new file mode 100755 index 0000000..01137b4 --- /dev/null +++ b/python_v3/REST_API_v2/Users/create_user_notification_rule.py @@ -0,0 +1,69 @@ +#!/usr/bin/env python +# +# Copyright (c) 2016, 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. + +import requests +import json + +# Update to match your API key +API_KEY = '3c3gRvzx7uGfMYEnWKvF' + +# Update to match ID of user you want to update +ID = 'P0TEZR0' + +# Update to match your chosen parameters +START_DELAY_IN_MINUTES = '5' +URGENCY = 'high' +CONTACT_METHOD_ID = 'P54SUEP' +CONTACT_METHOD_TYPE = 'email_contact_method' + + +def create_user_notification_rule(): + url = 'https://api.pagerduty.com/users/{id}/notification_rules'.format( + id=ID + ) + headers = { + 'Accept': 'application/vnd.pagerduty+json;version=2', + 'Authorization': 'Token token={token}'.format(token=API_KEY), + 'Content-type': 'application/json' + } + payload = { + 'notification_rule': { + 'start_delay_in_minutes': START_DELAY_IN_MINUTES, + 'contact_method': { + 'id': CONTACT_METHOD_ID, + 'type': CONTACT_METHOD_TYPE + }, + 'type': 'assignment_notification_rule', + 'urgency': URGENCY + } + } + r = requests.post(url, headers=headers, data=json.dumps(payload)) + print('Status Code: {code}'.format(code=r.status_code)) + print(r.json()) + +if __name__ == '__main__': + create_user_notification_rule() diff --git a/python_v3/REST_API_v2/Users/delete_user.py b/python_v3/REST_API_v2/Users/delete_user.py new file mode 100755 index 0000000..17a04b3 --- /dev/null +++ b/python_v3/REST_API_v2/Users/delete_user.py @@ -0,0 +1,48 @@ +#!/usr/bin/env python +# +# Copyright (c) 2016, 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. + +import requests + +# Update to match your API key +API_KEY = '3c3gRvzx7uGfMYEnWKvF' + +# Update to match ID of resource you want to delete +ID = 'PK1VFD9' + + +def delete_user(): + url = 'https://api.pagerduty.com/users/{id}'.format(id=ID) + headers = { + 'Accept': 'application/vnd.pagerduty+json;version=2', + '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) + +if __name__ == '__main__': + delete_user() diff --git a/python_v3/REST_API_v2/Users/delete_user_contact_method.py b/python_v3/REST_API_v2/Users/delete_user_contact_method.py new file mode 100755 index 0000000..83deb54 --- /dev/null +++ b/python_v3/REST_API_v2/Users/delete_user_contact_method.py @@ -0,0 +1,52 @@ +#!/usr/bin/env python +# +# Copyright (c) 2016, 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. + +import requests + +# Update to match your API key +API_KEY = '3c3gRvzx7uGfMYEnWKvF' + +# Update to match your IDs +USER_ID = 'P0TEZR0' +CONTACT_METHOD_ID = 'PRP8EDZ' + + +def delete_user_contact_method(): + url = 'https://api.pagerduty.com/users/{uid}/contact_methods/{cid}'.format( + uid=USER_ID, + cid=CONTACT_METHOD_ID + ) + headers = { + 'Accept': 'application/vnd.pagerduty+json;version=2', + '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) + +if __name__ == '__main__': + delete_user_contact_method() diff --git a/python_v3/REST_API_v2/Users/delete_user_notification_rule.py b/python_v3/REST_API_v2/Users/delete_user_notification_rule.py new file mode 100755 index 0000000..228cee0 --- /dev/null +++ b/python_v3/REST_API_v2/Users/delete_user_notification_rule.py @@ -0,0 +1,50 @@ +#!/usr/bin/env python +# +# Copyright (c) 2016, 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. + +import requests + +# Update to match your API key +API_KEY = '3c3gRvzx7uGfMYEnWKvF' + +# Update to match your IDs +USER_ID = 'P0TEZR0' +NOTIFICATION_RULE_ID = 'PM0NWL3' + + +def delete_user_notification_rule(): + url = ('https://api.pagerduty.com/users/{uid}/notification_rules/{nid}' + .format(uid=USER_ID, nid=NOTIFICATION_RULE_ID)) + headers = { + 'Accept': 'application/vnd.pagerduty+json;version=2', + '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) + +if __name__ == '__main__': + delete_user_notification_rule() diff --git a/python_v3/REST_API_v2/Users/get_user.py b/python_v3/REST_API_v2/Users/get_user.py new file mode 100755 index 0000000..7513929 --- /dev/null +++ b/python_v3/REST_API_v2/Users/get_user.py @@ -0,0 +1,54 @@ +#!/usr/bin/env python +# +# Copyright (c) 2016, 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. + +import requests + +# Update to match your API key +API_KEY = '3c3gRvzx7uGfMYEnWKvF' + +# Update to match your user ID +ID = 'P0TEZR0' + +# Update to match your chosen parameters +INCLUDE = [] + + +def get_user(): + url = 'https://api.pagerduty.com/users/{id}'.format(id=ID) + headers = { + 'Accept': 'application/vnd.pagerduty+json;version=2', + 'Authorization': 'Token token={token}'.format(token=API_KEY) + } + payload = { + 'include[]': INCLUDE + } + r = requests.get(url, headers=headers, params=payload) + print('Status Code: {code}'.format(code=r.status_code)) + print(r.json()) + +if __name__ == '__main__': + get_user() diff --git a/python_v3/REST_API_v2/Users/get_user_contact_method.py b/python_v3/REST_API_v2/Users/get_user_contact_method.py new file mode 100755 index 0000000..05c3a1e --- /dev/null +++ b/python_v3/REST_API_v2/Users/get_user_contact_method.py @@ -0,0 +1,52 @@ +#!/usr/bin/env python +# +# Copyright (c) 2016, 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. + +import requests + +# Update to match your API key +API_KEY = '3c3gRvzx7uGfMYEnWKvF' + +# Update to match your IDs +USER_ID = 'P0TEZR0' +CONTACT_METHOD_ID = 'P54SUEP' + + +def get_user_contact_method(): + url = 'https://api.pagerduty.com/users/{uid}/contact_methods/{cid}'.format( + uid=USER_ID, + cid=CONTACT_METHOD_ID + ) + headers = { + 'Accept': 'application/vnd.pagerduty+json;version=2', + '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()) + +if __name__ == '__main__': + get_user_contact_method() diff --git a/python_v3/REST_API_v2/Users/get_user_notification_rule.py b/python_v3/REST_API_v2/Users/get_user_notification_rule.py new file mode 100755 index 0000000..70ac0b8 --- /dev/null +++ b/python_v3/REST_API_v2/Users/get_user_notification_rule.py @@ -0,0 +1,56 @@ +#!/usr/bin/env python +# +# Copyright (c) 2016, 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. + +import requests + +# Update to match your API key +API_KEY = '3c3gRvzx7uGfMYEnWKvF' + +# Update to match your IDs +USER_ID = 'P0TEZR0' +NOTIFICATION_RULE_ID = 'PCR2WKT' + +# Update to match your chosen parameters +INCLUDE = [] + + +def get_user_notification_rule(): + url = ('https://api.pagerduty.com/users/{uid}/notification_rules/{nid}' + .format(uid=USER_ID, nid=NOTIFICATION_RULE_ID)) + headers = { + 'Accept': 'application/vnd.pagerduty+json;version=2', + 'Authorization': 'Token token={token}'.format(token=API_KEY) + } + payload = { + 'include[]': INCLUDE + } + r = requests.get(url, headers=headers, params=payload) + print('Status Code: {code}'.format(code=r.status_code)) + print(r.json()) + +if __name__ == '__main__': + get_user_notification_rule() diff --git a/python_v3/REST_API_v2/Users/list_user_contact_methods.py b/python_v3/REST_API_v2/Users/list_user_contact_methods.py new file mode 100755 index 0000000..fafd7bd --- /dev/null +++ b/python_v3/REST_API_v2/Users/list_user_contact_methods.py @@ -0,0 +1,48 @@ +#!/usr/bin/env python +# +# Copyright (c) 2016, 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. + +import requests + +# Update to match your API key +API_KEY = '3c3gRvzx7uGfMYEnWKvF' + +# Update to match your user ID +ID = 'P0TEZR0' + + +def list_user_contact_methods(): + url = 'https://api.pagerduty.com/users/{id}/contact_methods'.format(id=ID) + headers = { + 'Accept': 'application/vnd.pagerduty+json;version=2', + '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()) + +if __name__ == '__main__': + list_user_contact_methods() diff --git a/python_v3/REST_API_v2/Users/list_user_notification_rules.py b/python_v3/REST_API_v2/Users/list_user_notification_rules.py new file mode 100755 index 0000000..dc83f96 --- /dev/null +++ b/python_v3/REST_API_v2/Users/list_user_notification_rules.py @@ -0,0 +1,56 @@ +#!/usr/bin/env python +# +# Copyright (c) 2016, 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. + +import requests + +# Update to match your API key +API_KEY = '3c3gRvzx7uGfMYEnWKvF' + +# Update to match your user ID +ID = 'P0TEZR0' + +# Update to match your chosen parameters +INCLUDE = [] + + +def list_user_notification_rules(): + url = 'https://api.pagerduty.com/users/{id}/notification_rules'.format( + id=ID + ) + headers = { + 'Accept': 'application/vnd.pagerduty+json;version=2', + 'Authorization': 'Token token={token}'.format(token=API_KEY) + } + payload = { + 'include[]': INCLUDE + } + r = requests.get(url, headers=headers, params=payload) + print('Status Code: {code}'.format(code=r.status_code)) + print(r.json()) + +if __name__ == '__main__': + list_user_notification_rules() diff --git a/python_v3/REST_API_v2/Users/list_users.py b/python_v3/REST_API_v2/Users/list_users.py new file mode 100755 index 0000000..741b98a --- /dev/null +++ b/python_v3/REST_API_v2/Users/list_users.py @@ -0,0 +1,55 @@ +#!/usr/bin/env python +# +# Copyright (c) 2016, 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. + +import requests + +# Update to match your API key +API_KEY = '3c3gRvzx7uGfMYEnWKvF' + +# Update to match your chosen parameters +QUERY = '' +TEAM_IDS = [] +INCLUDE = [] + + +def list_users(): + url = 'https://api.pagerduty.com/users' + headers = { + 'Accept': 'application/vnd.pagerduty+json;version=2', + 'Authorization': 'Token token={token}'.format(token=API_KEY) + } + payload = { + 'query': QUERY, + 'team_ids[]': TEAM_IDS, + 'include[]': INCLUDE + } + r = requests.get(url, headers=headers, params=payload) + print('Status Code: {code}'.format(code=r.status_code)) + print(r.json()) + +if __name__ == '__main__': + list_users() diff --git a/python_v3/REST_API_v2/Users/update_user.py b/python_v3/REST_API_v2/Users/update_user.py new file mode 100755 index 0000000..eee465c --- /dev/null +++ b/python_v3/REST_API_v2/Users/update_user.py @@ -0,0 +1,62 @@ +#!/usr/bin/env python +# +# Copyright (c) 2016, 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. + +import requests +import json + +# Update to match your API key +API_KEY = '3c3gRvzx7uGfMYEnWKvF' + +# Update to match ID of resource you want to update +ID = 'P0TEZR0' + +# 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 + + +def update_user(): + url = 'https://api.pagerduty.com/users/{id}'.format(id=ID) + headers = { + 'Accept': 'application/vnd.pagerduty+json;version=2', + 'Authorization': 'Token token={token}'.format(token=API_KEY), + 'Content-type': 'application/json' + } + payload = { + 'user': { + 'name': NAME, + 'email': EMAIL, + 'role': ROLE + } + } + r = requests.put(url, headers=headers, data=json.dumps(payload)) + print('Status Code: {code}'.format(code=r.status_code)) + print(r.json()) + +if __name__ == '__main__': + update_user() diff --git a/python_v3/REST_API_v2/Users/update_user_contact_method.py b/python_v3/REST_API_v2/Users/update_user_contact_method.py new file mode 100755 index 0000000..03c75ad --- /dev/null +++ b/python_v3/REST_API_v2/Users/update_user_contact_method.py @@ -0,0 +1,66 @@ +#!/usr/bin/env python +# +# Copyright (c) 2016, 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. + +import requests +import json + +# Update to match your API key +API_KEY = '3c3gRvzx7uGfMYEnWKvF' + +# Update to match your IDs +USER_ID = 'P0TEZR0' +CONTACT_METHOD_ID = 'P54SUEP' + +# Update to match your chosen parameters +TYPE = 'email_contact_method' # Can be one of email_contact_method, sms_contact_method, phone_contact_method, or push_notification_contact_method # NOQA +ADDRESS = 'insert_email@here.com' +LABEL = 'Work' + + +def update_user_contact_method(): + url = 'https://api.pagerduty.com/users/{uid}/contact_methods/{cid}'.format( + uid=USER_ID, + cid=CONTACT_METHOD_ID + ) + headers = { + 'Accept': 'application/vnd.pagerduty+json;version=2', + 'Authorization': 'Token token={token}'.format(token=API_KEY), + 'Content-type': 'application/json' + } + payload = { + 'contact_method': { + 'type': TYPE, + 'address': ADDRESS, + 'label': LABEL + } + } + r = requests.put(url, headers=headers, data=json.dumps(payload)) + print('Status Code: {code}'.format(code=r.status_code)) + print(r.json()) + +if __name__ == '__main__': + update_user_contact_method() diff --git a/python_v3/REST_API_v2/Users/update_user_notification_rule.py b/python_v3/REST_API_v2/Users/update_user_notification_rule.py new file mode 100755 index 0000000..3370f94 --- /dev/null +++ b/python_v3/REST_API_v2/Users/update_user_notification_rule.py @@ -0,0 +1,69 @@ +#!/usr/bin/env python +# +# Copyright (c) 2016, 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. + +import requests +import json + +# Update to match your API key +API_KEY = '3c3gRvzx7uGfMYEnWKvF' + +# Update to match your IDs +USER_ID = 'P0TEZR0' +NOTIFICATION_RULE_ID = 'PHK9WYE' + +# Update to match your chosen parameters +START_DELAY_IN_MINUTES = '3' +URGENCY = 'high' +CONTACT_METHOD_ID = 'P54SUEP' +CONTACT_METHOD_TYPE = 'email_contact_method' + + +def update_user_notification_rule(): + url = ('https://api.pagerduty.com/users/{uid}/notification_rules/{nid}' + .format(uid=USER_ID, nid=NOTIFICATION_RULE_ID)) + headers = { + 'Accept': 'application/vnd.pagerduty+json;version=2', + 'Authorization': 'Token token={token}'.format(token=API_KEY), + 'Content-type': 'application/json' + } + payload = { + 'notification_rule': { + 'type': 'assignment_notification_rule', + 'start_delay_in_minutes': START_DELAY_IN_MINUTES, + 'urgency': URGENCY, + 'contact_method': { + 'id': CONTACT_METHOD_ID, + 'type': CONTACT_METHOD_TYPE + } + } + } + r = requests.put(url, headers=headers, data=json.dumps(payload)) + print('Status Code: {code}'.format(code=r.status_code)) + print(r.json()) + +if __name__ == '__main__': + update_user_notification_rule() diff --git a/python_v3/REST_API_v2/Vendors/get_vendor.py b/python_v3/REST_API_v2/Vendors/get_vendor.py new file mode 100755 index 0000000..27f1904 --- /dev/null +++ b/python_v3/REST_API_v2/Vendors/get_vendor.py @@ -0,0 +1,48 @@ +#!/usr/bin/env python +# +# Copyright (c) 2016, 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. + +import requests + +# Update to match your API key +API_KEY = '3c3gRvzx7uGfMYEnWKvF' + +# Update to match your vendor ID +ID = 'PYFMET1' + + +def get_vendor(): + url = 'https://api.pagerduty.com/vendors/{id}'.format(id=ID) + headers = { + 'Accept': 'application/vnd.pagerduty+json;version=2', + '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()) + +if __name__ == '__main__': + get_vendor() diff --git a/python_v3/REST_API_v2/Vendors/list_vendors.py b/python_v3/REST_API_v2/Vendors/list_vendors.py new file mode 100755 index 0000000..5e74323 --- /dev/null +++ b/python_v3/REST_API_v2/Vendors/list_vendors.py @@ -0,0 +1,45 @@ +#!/usr/bin/env python +# +# Copyright (c) 2016, 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. + +import requests + +# Update to match your API key +API_KEY = '3c3gRvzx7uGfMYEnWKvF' + + +def list_vendors(): + url = 'https://api.pagerduty.com/vendors' + headers = { + 'Accept': 'application/vnd.pagerduty+json;version=2', + '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()) + +if __name__ == '__main__': + list_vendors() From b5dae43f25d9020f95266198cfc9c46f36d781d8 Mon Sep 17 00:00:00 2001 From: Demitri Morgan Date: Wed, 12 Dec 2018 09:03:02 -0800 Subject: [PATCH 7/9] Merged Files / fixed typos Python v3/v2 samples are adequately represented by the v3 samples, because the only difference as yet is print statement syntax (and Python 3's is backwards compatible), and there's little chance we will run into significant differences between the Python files to warrant doubling the number of files that will need to be maintained. Additionally, this commit fixes some typos (i.e. functions named `trigger_incident` where `resolve_incident` would be more appropriate). --- .../Resolve/resolve_incident.py | 4 +- .../Trigger/trigger_with_incident_key.py | 0 .../Trigger/trigger_without_incident_key.py | 0 .../Ack => EVENTS_API_V1/ack}/ack_incident.py | 4 +- .../ack/ack_incident.py | 4 +- .../resolve/resolve_incident.py | 4 +- .../trigger/trigger_with_incident_key.py | 0 .../trigger/trigger_without_incident_key.py | 0 .../Abilities/list_abilities.py | 0 .../Abilities/test_ability.py | 0 .../AddOns/delete_addon.py | 0 .../AddOns/get_addon.py | 0 .../AddOns/install_addon.py | 0 .../AddOns/list_installed_addons.py | 0 .../AddOns/update_addon.py | 0 .../create_escalation_policy.py | 0 .../delete_escalation_policy.py | 0 .../get_escalation_policy.py | 0 .../list_escalation_policies.py | 0 .../update_escalation_policy.py | 0 .../Incidents/create_incident_note.py | 0 .../Incidents/get_incident.py | 0 .../Incidents/list_incident_log_entries.py | 0 .../Incidents/list_incident_notes.py | 0 .../Incidents/list_incidents.py | 0 .../Incidents/manage_incidents.py | 0 .../Incidents/snooze_incident.py | 0 .../Incidents/trigger_incident.py | 0 .../Incidents/update_incident.py | 0 .../LogEntries/get_log_entry.py | 0 .../LogEntries/list_log_entries.py | 0 .../create_maintenance_window.py | 0 .../delete_or_end_maintenance_window.py | 0 .../end_all_maintenance_windows.py | 0 .../get_maintenance_window.py | 0 .../list_maintenance_windows.py | 0 .../update_maintenance_window.py | 0 .../Notifications/list_notifications.py | 0 .../OnCalls/list_oncalls.py | 0 .../Schedules/create_override.py | 0 .../Schedules/create_schedule.py | 0 .../Schedules/delete_override.py | 0 .../Schedules/delete_schedule.py | 0 .../Schedules/get_schedule.py | 0 .../Schedules/list_oncall_users.py | 0 .../Schedules/list_overrides.py | 0 .../Schedules/list_schedules.py | 0 .../Schedules/preview_schedule.py | 0 .../Schedules/update_schedule.py | 0 .../Services/create_integration.py | 0 .../Services/create_service.py | 0 .../Services/delete_service.py | 0 .../Services/get_integration.py | 0 .../Services/get_service.py | 0 .../Services/list_services.py | 0 .../Services/update_integration.py | 0 .../Services/update_service.py | 0 .../Teams/add_escalation_policy_to_team.py | 0 .../Teams/add_user_to_team.py | 0 .../Teams/create_team.py | 0 .../Teams/delete_team.py | 0 .../Teams/get_team.py | 0 .../Teams/list_teams.py | 0 .../remove_escalation_policy_from_team.py | 0 .../Teams/remove_user_from_team.py | 0 .../Teams/update_team.py | 0 .../Users/create_user.py | 0 .../Users/create_user_contact_method.py | 0 .../Users/create_user_notification_rule.py | 0 .../Users/delete_user.py | 0 .../Users/delete_user_contact_method.py | 0 .../Users/delete_user_notification_rule.py | 0 .../Users/get_user.py | 0 .../Users/get_user_contact_method.py | 0 .../Users/get_user_notification_rule.py | 0 .../Users/list_user_contact_methods.py | 0 .../Users/list_user_notification_rules.py | 0 .../Users/list_users.py | 0 .../Users/update_user.py | 0 .../Users/update_user_contact_method.py | 0 .../Users/update_user_notification_rule.py | 0 .../Vendors/get_vendor.py | 0 .../Vendors/list_vendors.py | 0 python_v2/EVENTS_API_V1/Ack/ack_incident.py | 29 ---- .../EVENTS_API_V1/Resolve/resolve_incident.py | 29 ---- .../Trigger/trigger_with_incident_key.py | 29 ---- .../Trigger/trigger_without_incident_key.py | 27 ---- python_v2/EVENTS_API_v2/ack/ack_incident.py | 33 ---- .../EVENTS_API_v2/resolve/resolve_incident.py | 33 ---- .../trigger/trigger_with_incident_key.py | 38 ----- .../trigger/trigger_without_incident_key.py | 36 ----- .../REST_API_v2/Abilities/list_abilities.py | 45 ------ .../REST_API_v2/Abilities/test_ability.py | 48 ------ python_v2/REST_API_v2/AddOns/delete_addon.py | 48 ------ python_v2/REST_API_v2/AddOns/get_addon.py | 48 ------ python_v2/REST_API_v2/AddOns/install_addon.py | 61 -------- .../AddOns/list_installed_addons.py | 55 ------- python_v2/REST_API_v2/AddOns/update_addon.py | 64 -------- .../create_escalation_policy.py | 73 --------- .../delete_escalation_policy.py | 48 ------ .../get_escalation_policy.py | 54 ------- .../list_escalation_policies.py | 59 ------- .../update_escalation_policy.py | 80 ---------- .../Incidents/create_incident_note.py | 62 -------- .../REST_API_v2/Incidents/get_incident.py | 48 ------ .../Incidents/list_incident_log_entries.py | 58 ------- .../Incidents/list_incident_notes.py | 50 ------ .../REST_API_v2/Incidents/list_incidents.py | 73 --------- .../REST_API_v2/Incidents/manage_incidents.py | 88 ----------- .../REST_API_v2/Incidents/snooze_incident.py | 61 -------- .../REST_API_v2/Incidents/trigger_incident.py | 69 --------- .../REST_API_v2/Incidents/update_incident.py | 70 --------- .../REST_API_v2/LogEntries/get_log_entry.py | 54 ------- .../LogEntries/list_log_entries.py | 61 -------- .../create_maintenance_window.py | 72 --------- .../delete_or_end_maintenance_window.py | 48 ------ .../end_all_maintenance_windows.py | 140 ----------------- .../get_maintenance_window.py | 54 ------- .../list_maintenance_windows.py | 59 ------- .../update_maintenance_window.py | 71 --------- .../Notifications/list_notifications.py | 59 ------- python_v2/REST_API_v2/OnCalls/list_oncalls.py | 65 -------- .../REST_API_v2/Schedules/create_override.py | 67 -------- .../REST_API_v2/Schedules/create_schedule.py | 134 ---------------- .../REST_API_v2/Schedules/delete_override.py | 52 ------- .../REST_API_v2/Schedules/delete_schedule.py | 48 ------ .../REST_API_v2/Schedules/get_schedule.py | 60 ------- .../Schedules/list_oncall_users.py | 59 ------- .../REST_API_v2/Schedules/list_overrides.py | 62 -------- .../REST_API_v2/Schedules/list_schedules.py | 51 ------ .../REST_API_v2/Schedules/preview_schedule.py | 146 ------------------ .../REST_API_v2/Schedules/update_schedule.py | 145 ----------------- .../Services/create_integration.py | 70 --------- .../REST_API_v2/Services/create_service.py | 103 ------------ .../REST_API_v2/Services/delete_service.py | 48 ------ .../REST_API_v2/Services/get_integration.py | 58 ------- python_v2/REST_API_v2/Services/get_service.py | 54 ------- .../REST_API_v2/Services/list_services.py | 59 ------- .../Services/update_integration.py | 64 -------- .../REST_API_v2/Services/update_service.py | 68 -------- .../Teams/add_escalation_policy_to_team.py | 51 ------ .../REST_API_v2/Teams/add_user_to_team.py | 53 ------- python_v2/REST_API_v2/Teams/create_team.py | 59 ------- python_v2/REST_API_v2/Teams/delete_team.py | 48 ------ python_v2/REST_API_v2/Teams/get_team.py | 48 ------ python_v2/REST_API_v2/Teams/list_teams.py | 51 ------ .../remove_escalation_policy_from_team.py | 50 ------ .../Teams/remove_user_from_team.py | 52 ------- python_v2/REST_API_v2/Teams/update_team.py | 60 ------- python_v2/REST_API_v2/Users/create_user.py | 64 -------- .../Users/create_user_contact_method.py | 62 -------- .../Users/create_user_notification_rule.py | 69 --------- python_v2/REST_API_v2/Users/delete_user.py | 48 ------ .../Users/delete_user_contact_method.py | 52 ------- .../Users/delete_user_notification_rule.py | 50 ------ python_v2/REST_API_v2/Users/get_user.py | 54 ------- .../Users/get_user_contact_method.py | 52 ------- .../Users/get_user_notification_rule.py | 56 ------- .../Users/list_user_contact_methods.py | 48 ------ .../Users/list_user_notification_rules.py | 56 ------- python_v2/REST_API_v2/Users/list_users.py | 55 ------- python_v2/REST_API_v2/Users/update_user.py | 62 -------- .../Users/update_user_contact_method.py | 66 -------- .../Users/update_user_notification_rule.py | 69 --------- python_v2/REST_API_v2/Vendors/get_vendor.py | 48 ------ python_v2/REST_API_v2/Vendors/list_vendors.py | 45 ------ 166 files changed, 8 insertions(+), 4983 deletions(-) rename {python_v3/EVENTS_API_V1 => EVENTS_API_V1}/Resolve/resolve_incident.py (95%) rename {python_v3/EVENTS_API_V1 => EVENTS_API_V1}/Trigger/trigger_with_incident_key.py (100%) rename {python_v3/EVENTS_API_V1 => EVENTS_API_V1}/Trigger/trigger_without_incident_key.py (100%) rename {python_v3/EVENTS_API_V1/Ack => EVENTS_API_V1/ack}/ack_incident.py (95%) rename {python_v3/EVENTS_API_v2 => EVENTS_API_v2}/ack/ack_incident.py (95%) rename {python_v3/EVENTS_API_v2 => EVENTS_API_v2}/resolve/resolve_incident.py (95%) rename {python_v3/EVENTS_API_v2 => EVENTS_API_v2}/trigger/trigger_with_incident_key.py (100%) rename {python_v3/EVENTS_API_v2 => EVENTS_API_v2}/trigger/trigger_without_incident_key.py (100%) rename {python_v3/REST_API_v2 => REST_API_v2}/Abilities/list_abilities.py (100%) rename {python_v3/REST_API_v2 => REST_API_v2}/Abilities/test_ability.py (100%) rename {python_v3/REST_API_v2 => REST_API_v2}/AddOns/delete_addon.py (100%) rename {python_v3/REST_API_v2 => REST_API_v2}/AddOns/get_addon.py (100%) rename {python_v3/REST_API_v2 => REST_API_v2}/AddOns/install_addon.py (100%) rename {python_v3/REST_API_v2 => REST_API_v2}/AddOns/list_installed_addons.py (100%) rename {python_v3/REST_API_v2 => REST_API_v2}/AddOns/update_addon.py (100%) rename {python_v3/REST_API_v2 => REST_API_v2}/EscalationPolicies/create_escalation_policy.py (100%) rename {python_v3/REST_API_v2 => REST_API_v2}/EscalationPolicies/delete_escalation_policy.py (100%) rename {python_v3/REST_API_v2 => REST_API_v2}/EscalationPolicies/get_escalation_policy.py (100%) rename {python_v3/REST_API_v2 => REST_API_v2}/EscalationPolicies/list_escalation_policies.py (100%) rename {python_v3/REST_API_v2 => REST_API_v2}/EscalationPolicies/update_escalation_policy.py (100%) rename {python_v3/REST_API_v2 => REST_API_v2}/Incidents/create_incident_note.py (100%) rename {python_v3/REST_API_v2 => REST_API_v2}/Incidents/get_incident.py (100%) rename {python_v3/REST_API_v2 => REST_API_v2}/Incidents/list_incident_log_entries.py (100%) rename {python_v3/REST_API_v2 => REST_API_v2}/Incidents/list_incident_notes.py (100%) rename {python_v3/REST_API_v2 => REST_API_v2}/Incidents/list_incidents.py (100%) rename {python_v3/REST_API_v2 => REST_API_v2}/Incidents/manage_incidents.py (100%) rename {python_v3/REST_API_v2 => REST_API_v2}/Incidents/snooze_incident.py (100%) rename {python_v3/REST_API_v2 => REST_API_v2}/Incidents/trigger_incident.py (100%) rename {python_v3/REST_API_v2 => REST_API_v2}/Incidents/update_incident.py (100%) rename {python_v3/REST_API_v2 => REST_API_v2}/LogEntries/get_log_entry.py (100%) rename {python_v3/REST_API_v2 => REST_API_v2}/LogEntries/list_log_entries.py (100%) rename {python_v3/REST_API_v2 => REST_API_v2}/MaintenanceWindows/create_maintenance_window.py (100%) rename {python_v3/REST_API_v2 => REST_API_v2}/MaintenanceWindows/delete_or_end_maintenance_window.py (100%) rename {python_v3/REST_API_v2 => REST_API_v2}/MaintenanceWindows/end_all_maintenance_windows.py (100%) rename {python_v3/REST_API_v2 => REST_API_v2}/MaintenanceWindows/get_maintenance_window.py (100%) rename {python_v3/REST_API_v2 => REST_API_v2}/MaintenanceWindows/list_maintenance_windows.py (100%) rename {python_v3/REST_API_v2 => REST_API_v2}/MaintenanceWindows/update_maintenance_window.py (100%) rename {python_v3/REST_API_v2 => REST_API_v2}/Notifications/list_notifications.py (100%) rename {python_v3/REST_API_v2 => REST_API_v2}/OnCalls/list_oncalls.py (100%) rename {python_v3/REST_API_v2 => REST_API_v2}/Schedules/create_override.py (100%) rename {python_v3/REST_API_v2 => REST_API_v2}/Schedules/create_schedule.py (100%) rename {python_v3/REST_API_v2 => REST_API_v2}/Schedules/delete_override.py (100%) rename {python_v3/REST_API_v2 => REST_API_v2}/Schedules/delete_schedule.py (100%) rename {python_v3/REST_API_v2 => REST_API_v2}/Schedules/get_schedule.py (100%) rename {python_v3/REST_API_v2 => REST_API_v2}/Schedules/list_oncall_users.py (100%) rename {python_v3/REST_API_v2 => REST_API_v2}/Schedules/list_overrides.py (100%) rename {python_v3/REST_API_v2 => REST_API_v2}/Schedules/list_schedules.py (100%) rename {python_v3/REST_API_v2 => REST_API_v2}/Schedules/preview_schedule.py (100%) rename {python_v3/REST_API_v2 => REST_API_v2}/Schedules/update_schedule.py (100%) rename {python_v3/REST_API_v2 => REST_API_v2}/Services/create_integration.py (100%) rename {python_v3/REST_API_v2 => REST_API_v2}/Services/create_service.py (100%) rename {python_v3/REST_API_v2 => REST_API_v2}/Services/delete_service.py (100%) rename {python_v3/REST_API_v2 => REST_API_v2}/Services/get_integration.py (100%) rename {python_v3/REST_API_v2 => REST_API_v2}/Services/get_service.py (100%) rename {python_v3/REST_API_v2 => REST_API_v2}/Services/list_services.py (100%) rename {python_v3/REST_API_v2 => REST_API_v2}/Services/update_integration.py (100%) rename {python_v3/REST_API_v2 => REST_API_v2}/Services/update_service.py (100%) rename {python_v3/REST_API_v2 => REST_API_v2}/Teams/add_escalation_policy_to_team.py (100%) rename {python_v3/REST_API_v2 => REST_API_v2}/Teams/add_user_to_team.py (100%) rename {python_v3/REST_API_v2 => REST_API_v2}/Teams/create_team.py (100%) rename {python_v3/REST_API_v2 => REST_API_v2}/Teams/delete_team.py (100%) rename {python_v3/REST_API_v2 => REST_API_v2}/Teams/get_team.py (100%) rename {python_v3/REST_API_v2 => REST_API_v2}/Teams/list_teams.py (100%) rename {python_v3/REST_API_v2 => REST_API_v2}/Teams/remove_escalation_policy_from_team.py (100%) rename {python_v3/REST_API_v2 => REST_API_v2}/Teams/remove_user_from_team.py (100%) rename {python_v3/REST_API_v2 => REST_API_v2}/Teams/update_team.py (100%) rename {python_v3/REST_API_v2 => REST_API_v2}/Users/create_user.py (100%) rename {python_v3/REST_API_v2 => REST_API_v2}/Users/create_user_contact_method.py (100%) rename {python_v3/REST_API_v2 => REST_API_v2}/Users/create_user_notification_rule.py (100%) rename {python_v3/REST_API_v2 => REST_API_v2}/Users/delete_user.py (100%) rename {python_v3/REST_API_v2 => REST_API_v2}/Users/delete_user_contact_method.py (100%) rename {python_v3/REST_API_v2 => REST_API_v2}/Users/delete_user_notification_rule.py (100%) rename {python_v3/REST_API_v2 => REST_API_v2}/Users/get_user.py (100%) rename {python_v3/REST_API_v2 => REST_API_v2}/Users/get_user_contact_method.py (100%) rename {python_v3/REST_API_v2 => REST_API_v2}/Users/get_user_notification_rule.py (100%) rename {python_v3/REST_API_v2 => REST_API_v2}/Users/list_user_contact_methods.py (100%) rename {python_v3/REST_API_v2 => REST_API_v2}/Users/list_user_notification_rules.py (100%) rename {python_v3/REST_API_v2 => REST_API_v2}/Users/list_users.py (100%) rename {python_v3/REST_API_v2 => REST_API_v2}/Users/update_user.py (100%) rename {python_v3/REST_API_v2 => REST_API_v2}/Users/update_user_contact_method.py (100%) rename {python_v3/REST_API_v2 => REST_API_v2}/Users/update_user_notification_rule.py (100%) rename {python_v3/REST_API_v2 => REST_API_v2}/Vendors/get_vendor.py (100%) rename {python_v3/REST_API_v2 => REST_API_v2}/Vendors/list_vendors.py (100%) delete mode 100755 python_v2/EVENTS_API_V1/Ack/ack_incident.py delete mode 100755 python_v2/EVENTS_API_V1/Resolve/resolve_incident.py delete mode 100755 python_v2/EVENTS_API_V1/Trigger/trigger_with_incident_key.py delete mode 100755 python_v2/EVENTS_API_V1/Trigger/trigger_without_incident_key.py delete mode 100755 python_v2/EVENTS_API_v2/ack/ack_incident.py delete mode 100755 python_v2/EVENTS_API_v2/resolve/resolve_incident.py delete mode 100644 python_v2/EVENTS_API_v2/trigger/trigger_with_incident_key.py delete mode 100644 python_v2/EVENTS_API_v2/trigger/trigger_without_incident_key.py delete mode 100755 python_v2/REST_API_v2/Abilities/list_abilities.py delete mode 100755 python_v2/REST_API_v2/Abilities/test_ability.py delete mode 100755 python_v2/REST_API_v2/AddOns/delete_addon.py delete mode 100755 python_v2/REST_API_v2/AddOns/get_addon.py delete mode 100755 python_v2/REST_API_v2/AddOns/install_addon.py delete mode 100755 python_v2/REST_API_v2/AddOns/list_installed_addons.py delete mode 100755 python_v2/REST_API_v2/AddOns/update_addon.py delete mode 100755 python_v2/REST_API_v2/EscalationPolicies/create_escalation_policy.py delete mode 100755 python_v2/REST_API_v2/EscalationPolicies/delete_escalation_policy.py delete mode 100755 python_v2/REST_API_v2/EscalationPolicies/get_escalation_policy.py delete mode 100755 python_v2/REST_API_v2/EscalationPolicies/list_escalation_policies.py delete mode 100755 python_v2/REST_API_v2/EscalationPolicies/update_escalation_policy.py delete mode 100755 python_v2/REST_API_v2/Incidents/create_incident_note.py delete mode 100755 python_v2/REST_API_v2/Incidents/get_incident.py delete mode 100755 python_v2/REST_API_v2/Incidents/list_incident_log_entries.py delete mode 100755 python_v2/REST_API_v2/Incidents/list_incident_notes.py delete mode 100755 python_v2/REST_API_v2/Incidents/list_incidents.py delete mode 100755 python_v2/REST_API_v2/Incidents/manage_incidents.py delete mode 100755 python_v2/REST_API_v2/Incidents/snooze_incident.py delete mode 100644 python_v2/REST_API_v2/Incidents/trigger_incident.py delete mode 100755 python_v2/REST_API_v2/Incidents/update_incident.py delete mode 100755 python_v2/REST_API_v2/LogEntries/get_log_entry.py delete mode 100755 python_v2/REST_API_v2/LogEntries/list_log_entries.py delete mode 100755 python_v2/REST_API_v2/MaintenanceWindows/create_maintenance_window.py delete mode 100755 python_v2/REST_API_v2/MaintenanceWindows/delete_or_end_maintenance_window.py delete mode 100644 python_v2/REST_API_v2/MaintenanceWindows/end_all_maintenance_windows.py delete mode 100755 python_v2/REST_API_v2/MaintenanceWindows/get_maintenance_window.py delete mode 100755 python_v2/REST_API_v2/MaintenanceWindows/list_maintenance_windows.py delete mode 100755 python_v2/REST_API_v2/MaintenanceWindows/update_maintenance_window.py delete mode 100755 python_v2/REST_API_v2/Notifications/list_notifications.py delete mode 100755 python_v2/REST_API_v2/OnCalls/list_oncalls.py delete mode 100755 python_v2/REST_API_v2/Schedules/create_override.py delete mode 100755 python_v2/REST_API_v2/Schedules/create_schedule.py delete mode 100755 python_v2/REST_API_v2/Schedules/delete_override.py delete mode 100755 python_v2/REST_API_v2/Schedules/delete_schedule.py delete mode 100755 python_v2/REST_API_v2/Schedules/get_schedule.py delete mode 100755 python_v2/REST_API_v2/Schedules/list_oncall_users.py delete mode 100755 python_v2/REST_API_v2/Schedules/list_overrides.py delete mode 100755 python_v2/REST_API_v2/Schedules/list_schedules.py delete mode 100755 python_v2/REST_API_v2/Schedules/preview_schedule.py delete mode 100755 python_v2/REST_API_v2/Schedules/update_schedule.py delete mode 100755 python_v2/REST_API_v2/Services/create_integration.py delete mode 100755 python_v2/REST_API_v2/Services/create_service.py delete mode 100755 python_v2/REST_API_v2/Services/delete_service.py delete mode 100755 python_v2/REST_API_v2/Services/get_integration.py delete mode 100755 python_v2/REST_API_v2/Services/get_service.py delete mode 100755 python_v2/REST_API_v2/Services/list_services.py delete mode 100755 python_v2/REST_API_v2/Services/update_integration.py delete mode 100755 python_v2/REST_API_v2/Services/update_service.py delete mode 100755 python_v2/REST_API_v2/Teams/add_escalation_policy_to_team.py delete mode 100755 python_v2/REST_API_v2/Teams/add_user_to_team.py delete mode 100755 python_v2/REST_API_v2/Teams/create_team.py delete mode 100755 python_v2/REST_API_v2/Teams/delete_team.py delete mode 100755 python_v2/REST_API_v2/Teams/get_team.py delete mode 100755 python_v2/REST_API_v2/Teams/list_teams.py delete mode 100755 python_v2/REST_API_v2/Teams/remove_escalation_policy_from_team.py delete mode 100755 python_v2/REST_API_v2/Teams/remove_user_from_team.py delete mode 100755 python_v2/REST_API_v2/Teams/update_team.py delete mode 100755 python_v2/REST_API_v2/Users/create_user.py delete mode 100755 python_v2/REST_API_v2/Users/create_user_contact_method.py delete mode 100755 python_v2/REST_API_v2/Users/create_user_notification_rule.py delete mode 100755 python_v2/REST_API_v2/Users/delete_user.py delete mode 100755 python_v2/REST_API_v2/Users/delete_user_contact_method.py delete mode 100755 python_v2/REST_API_v2/Users/delete_user_notification_rule.py delete mode 100755 python_v2/REST_API_v2/Users/get_user.py delete mode 100755 python_v2/REST_API_v2/Users/get_user_contact_method.py delete mode 100755 python_v2/REST_API_v2/Users/get_user_notification_rule.py delete mode 100755 python_v2/REST_API_v2/Users/list_user_contact_methods.py delete mode 100755 python_v2/REST_API_v2/Users/list_user_notification_rules.py delete mode 100755 python_v2/REST_API_v2/Users/list_users.py delete mode 100755 python_v2/REST_API_v2/Users/update_user.py delete mode 100755 python_v2/REST_API_v2/Users/update_user_contact_method.py delete mode 100755 python_v2/REST_API_v2/Users/update_user_notification_rule.py delete mode 100755 python_v2/REST_API_v2/Vendors/get_vendor.py delete mode 100755 python_v2/REST_API_v2/Vendors/list_vendors.py diff --git a/python_v3/EVENTS_API_V1/Resolve/resolve_incident.py b/EVENTS_API_V1/Resolve/resolve_incident.py similarity index 95% rename from python_v3/EVENTS_API_V1/Resolve/resolve_incident.py rename to EVENTS_API_V1/Resolve/resolve_incident.py index 7e0f0aa..3ca5848 100755 --- a/python_v3/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 @@ -26,4 +26,4 @@ def trigger_incident(): print(response.text) # print error message if not successful if __name__ == '__main__': - trigger_incident() + resolve_incident() diff --git a/python_v3/EVENTS_API_V1/Trigger/trigger_with_incident_key.py b/EVENTS_API_V1/Trigger/trigger_with_incident_key.py similarity index 100% rename from python_v3/EVENTS_API_V1/Trigger/trigger_with_incident_key.py rename to EVENTS_API_V1/Trigger/trigger_with_incident_key.py diff --git a/python_v3/EVENTS_API_V1/Trigger/trigger_without_incident_key.py b/EVENTS_API_V1/Trigger/trigger_without_incident_key.py similarity index 100% rename from python_v3/EVENTS_API_V1/Trigger/trigger_without_incident_key.py rename to EVENTS_API_V1/Trigger/trigger_without_incident_key.py diff --git a/python_v3/EVENTS_API_V1/Ack/ack_incident.py b/EVENTS_API_V1/ack/ack_incident.py similarity index 95% rename from python_v3/EVENTS_API_V1/Ack/ack_incident.py rename to EVENTS_API_V1/ack/ack_incident.py index 079017f..d81285f 100755 --- a/python_v3/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 @@ -26,4 +26,4 @@ def trigger_incident(): print(response.text) # print error message if not successful if __name__ == '__main__': - trigger_incident() + ack_incident() diff --git a/python_v3/EVENTS_API_v2/ack/ack_incident.py b/EVENTS_API_v2/ack/ack_incident.py similarity index 95% rename from python_v3/EVENTS_API_v2/ack/ack_incident.py rename to EVENTS_API_v2/ack/ack_incident.py index 86a7378..feb5cf3 100755 --- a/python_v3/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 @@ -30,4 +30,4 @@ def trigger_incident(): print(response.text) # print error message if not successful if __name__ == '__main__': - trigger_incident() + ack_incident() diff --git a/python_v3/EVENTS_API_v2/resolve/resolve_incident.py b/EVENTS_API_v2/resolve/resolve_incident.py similarity index 95% rename from python_v3/EVENTS_API_v2/resolve/resolve_incident.py rename to EVENTS_API_v2/resolve/resolve_incident.py index 610fa02..80eddd7 100755 --- a/python_v3/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 @@ -30,4 +30,4 @@ def trigger_incident(): print(response.text) # print error message if not successful if __name__ == '__main__': - trigger_incident() + resolve_incident() diff --git a/python_v3/EVENTS_API_v2/trigger/trigger_with_incident_key.py b/EVENTS_API_v2/trigger/trigger_with_incident_key.py similarity index 100% rename from python_v3/EVENTS_API_v2/trigger/trigger_with_incident_key.py rename to EVENTS_API_v2/trigger/trigger_with_incident_key.py diff --git a/python_v3/EVENTS_API_v2/trigger/trigger_without_incident_key.py b/EVENTS_API_v2/trigger/trigger_without_incident_key.py similarity index 100% rename from python_v3/EVENTS_API_v2/trigger/trigger_without_incident_key.py rename to EVENTS_API_v2/trigger/trigger_without_incident_key.py diff --git a/python_v3/REST_API_v2/Abilities/list_abilities.py b/REST_API_v2/Abilities/list_abilities.py similarity index 100% rename from python_v3/REST_API_v2/Abilities/list_abilities.py rename to REST_API_v2/Abilities/list_abilities.py diff --git a/python_v3/REST_API_v2/Abilities/test_ability.py b/REST_API_v2/Abilities/test_ability.py similarity index 100% rename from python_v3/REST_API_v2/Abilities/test_ability.py rename to REST_API_v2/Abilities/test_ability.py diff --git a/python_v3/REST_API_v2/AddOns/delete_addon.py b/REST_API_v2/AddOns/delete_addon.py similarity index 100% rename from python_v3/REST_API_v2/AddOns/delete_addon.py rename to REST_API_v2/AddOns/delete_addon.py diff --git a/python_v3/REST_API_v2/AddOns/get_addon.py b/REST_API_v2/AddOns/get_addon.py similarity index 100% rename from python_v3/REST_API_v2/AddOns/get_addon.py rename to REST_API_v2/AddOns/get_addon.py diff --git a/python_v3/REST_API_v2/AddOns/install_addon.py b/REST_API_v2/AddOns/install_addon.py similarity index 100% rename from python_v3/REST_API_v2/AddOns/install_addon.py rename to REST_API_v2/AddOns/install_addon.py diff --git a/python_v3/REST_API_v2/AddOns/list_installed_addons.py b/REST_API_v2/AddOns/list_installed_addons.py similarity index 100% rename from python_v3/REST_API_v2/AddOns/list_installed_addons.py rename to REST_API_v2/AddOns/list_installed_addons.py diff --git a/python_v3/REST_API_v2/AddOns/update_addon.py b/REST_API_v2/AddOns/update_addon.py similarity index 100% rename from python_v3/REST_API_v2/AddOns/update_addon.py rename to REST_API_v2/AddOns/update_addon.py diff --git a/python_v3/REST_API_v2/EscalationPolicies/create_escalation_policy.py b/REST_API_v2/EscalationPolicies/create_escalation_policy.py similarity index 100% rename from python_v3/REST_API_v2/EscalationPolicies/create_escalation_policy.py rename to REST_API_v2/EscalationPolicies/create_escalation_policy.py diff --git a/python_v3/REST_API_v2/EscalationPolicies/delete_escalation_policy.py b/REST_API_v2/EscalationPolicies/delete_escalation_policy.py similarity index 100% rename from python_v3/REST_API_v2/EscalationPolicies/delete_escalation_policy.py rename to REST_API_v2/EscalationPolicies/delete_escalation_policy.py diff --git a/python_v3/REST_API_v2/EscalationPolicies/get_escalation_policy.py b/REST_API_v2/EscalationPolicies/get_escalation_policy.py similarity index 100% rename from python_v3/REST_API_v2/EscalationPolicies/get_escalation_policy.py rename to REST_API_v2/EscalationPolicies/get_escalation_policy.py diff --git a/python_v3/REST_API_v2/EscalationPolicies/list_escalation_policies.py b/REST_API_v2/EscalationPolicies/list_escalation_policies.py similarity index 100% rename from python_v3/REST_API_v2/EscalationPolicies/list_escalation_policies.py rename to REST_API_v2/EscalationPolicies/list_escalation_policies.py diff --git a/python_v3/REST_API_v2/EscalationPolicies/update_escalation_policy.py b/REST_API_v2/EscalationPolicies/update_escalation_policy.py similarity index 100% rename from python_v3/REST_API_v2/EscalationPolicies/update_escalation_policy.py rename to REST_API_v2/EscalationPolicies/update_escalation_policy.py diff --git a/python_v3/REST_API_v2/Incidents/create_incident_note.py b/REST_API_v2/Incidents/create_incident_note.py similarity index 100% rename from python_v3/REST_API_v2/Incidents/create_incident_note.py rename to REST_API_v2/Incidents/create_incident_note.py diff --git a/python_v3/REST_API_v2/Incidents/get_incident.py b/REST_API_v2/Incidents/get_incident.py similarity index 100% rename from python_v3/REST_API_v2/Incidents/get_incident.py rename to REST_API_v2/Incidents/get_incident.py diff --git a/python_v3/REST_API_v2/Incidents/list_incident_log_entries.py b/REST_API_v2/Incidents/list_incident_log_entries.py similarity index 100% rename from python_v3/REST_API_v2/Incidents/list_incident_log_entries.py rename to REST_API_v2/Incidents/list_incident_log_entries.py diff --git a/python_v3/REST_API_v2/Incidents/list_incident_notes.py b/REST_API_v2/Incidents/list_incident_notes.py similarity index 100% rename from python_v3/REST_API_v2/Incidents/list_incident_notes.py rename to REST_API_v2/Incidents/list_incident_notes.py diff --git a/python_v3/REST_API_v2/Incidents/list_incidents.py b/REST_API_v2/Incidents/list_incidents.py similarity index 100% rename from python_v3/REST_API_v2/Incidents/list_incidents.py rename to REST_API_v2/Incidents/list_incidents.py diff --git a/python_v3/REST_API_v2/Incidents/manage_incidents.py b/REST_API_v2/Incidents/manage_incidents.py similarity index 100% rename from python_v3/REST_API_v2/Incidents/manage_incidents.py rename to REST_API_v2/Incidents/manage_incidents.py diff --git a/python_v3/REST_API_v2/Incidents/snooze_incident.py b/REST_API_v2/Incidents/snooze_incident.py similarity index 100% rename from python_v3/REST_API_v2/Incidents/snooze_incident.py rename to REST_API_v2/Incidents/snooze_incident.py diff --git a/python_v3/REST_API_v2/Incidents/trigger_incident.py b/REST_API_v2/Incidents/trigger_incident.py similarity index 100% rename from python_v3/REST_API_v2/Incidents/trigger_incident.py rename to REST_API_v2/Incidents/trigger_incident.py diff --git a/python_v3/REST_API_v2/Incidents/update_incident.py b/REST_API_v2/Incidents/update_incident.py similarity index 100% rename from python_v3/REST_API_v2/Incidents/update_incident.py rename to REST_API_v2/Incidents/update_incident.py diff --git a/python_v3/REST_API_v2/LogEntries/get_log_entry.py b/REST_API_v2/LogEntries/get_log_entry.py similarity index 100% rename from python_v3/REST_API_v2/LogEntries/get_log_entry.py rename to REST_API_v2/LogEntries/get_log_entry.py diff --git a/python_v3/REST_API_v2/LogEntries/list_log_entries.py b/REST_API_v2/LogEntries/list_log_entries.py similarity index 100% rename from python_v3/REST_API_v2/LogEntries/list_log_entries.py rename to REST_API_v2/LogEntries/list_log_entries.py diff --git a/python_v3/REST_API_v2/MaintenanceWindows/create_maintenance_window.py b/REST_API_v2/MaintenanceWindows/create_maintenance_window.py similarity index 100% rename from python_v3/REST_API_v2/MaintenanceWindows/create_maintenance_window.py rename to REST_API_v2/MaintenanceWindows/create_maintenance_window.py diff --git a/python_v3/REST_API_v2/MaintenanceWindows/delete_or_end_maintenance_window.py b/REST_API_v2/MaintenanceWindows/delete_or_end_maintenance_window.py similarity index 100% rename from python_v3/REST_API_v2/MaintenanceWindows/delete_or_end_maintenance_window.py rename to REST_API_v2/MaintenanceWindows/delete_or_end_maintenance_window.py diff --git a/python_v3/REST_API_v2/MaintenanceWindows/end_all_maintenance_windows.py b/REST_API_v2/MaintenanceWindows/end_all_maintenance_windows.py similarity index 100% rename from python_v3/REST_API_v2/MaintenanceWindows/end_all_maintenance_windows.py rename to REST_API_v2/MaintenanceWindows/end_all_maintenance_windows.py diff --git a/python_v3/REST_API_v2/MaintenanceWindows/get_maintenance_window.py b/REST_API_v2/MaintenanceWindows/get_maintenance_window.py similarity index 100% rename from python_v3/REST_API_v2/MaintenanceWindows/get_maintenance_window.py rename to REST_API_v2/MaintenanceWindows/get_maintenance_window.py diff --git a/python_v3/REST_API_v2/MaintenanceWindows/list_maintenance_windows.py b/REST_API_v2/MaintenanceWindows/list_maintenance_windows.py similarity index 100% rename from python_v3/REST_API_v2/MaintenanceWindows/list_maintenance_windows.py rename to REST_API_v2/MaintenanceWindows/list_maintenance_windows.py diff --git a/python_v3/REST_API_v2/MaintenanceWindows/update_maintenance_window.py b/REST_API_v2/MaintenanceWindows/update_maintenance_window.py similarity index 100% rename from python_v3/REST_API_v2/MaintenanceWindows/update_maintenance_window.py rename to REST_API_v2/MaintenanceWindows/update_maintenance_window.py diff --git a/python_v3/REST_API_v2/Notifications/list_notifications.py b/REST_API_v2/Notifications/list_notifications.py similarity index 100% rename from python_v3/REST_API_v2/Notifications/list_notifications.py rename to REST_API_v2/Notifications/list_notifications.py diff --git a/python_v3/REST_API_v2/OnCalls/list_oncalls.py b/REST_API_v2/OnCalls/list_oncalls.py similarity index 100% rename from python_v3/REST_API_v2/OnCalls/list_oncalls.py rename to REST_API_v2/OnCalls/list_oncalls.py diff --git a/python_v3/REST_API_v2/Schedules/create_override.py b/REST_API_v2/Schedules/create_override.py similarity index 100% rename from python_v3/REST_API_v2/Schedules/create_override.py rename to REST_API_v2/Schedules/create_override.py diff --git a/python_v3/REST_API_v2/Schedules/create_schedule.py b/REST_API_v2/Schedules/create_schedule.py similarity index 100% rename from python_v3/REST_API_v2/Schedules/create_schedule.py rename to REST_API_v2/Schedules/create_schedule.py diff --git a/python_v3/REST_API_v2/Schedules/delete_override.py b/REST_API_v2/Schedules/delete_override.py similarity index 100% rename from python_v3/REST_API_v2/Schedules/delete_override.py rename to REST_API_v2/Schedules/delete_override.py diff --git a/python_v3/REST_API_v2/Schedules/delete_schedule.py b/REST_API_v2/Schedules/delete_schedule.py similarity index 100% rename from python_v3/REST_API_v2/Schedules/delete_schedule.py rename to REST_API_v2/Schedules/delete_schedule.py diff --git a/python_v3/REST_API_v2/Schedules/get_schedule.py b/REST_API_v2/Schedules/get_schedule.py similarity index 100% rename from python_v3/REST_API_v2/Schedules/get_schedule.py rename to REST_API_v2/Schedules/get_schedule.py diff --git a/python_v3/REST_API_v2/Schedules/list_oncall_users.py b/REST_API_v2/Schedules/list_oncall_users.py similarity index 100% rename from python_v3/REST_API_v2/Schedules/list_oncall_users.py rename to REST_API_v2/Schedules/list_oncall_users.py diff --git a/python_v3/REST_API_v2/Schedules/list_overrides.py b/REST_API_v2/Schedules/list_overrides.py similarity index 100% rename from python_v3/REST_API_v2/Schedules/list_overrides.py rename to REST_API_v2/Schedules/list_overrides.py diff --git a/python_v3/REST_API_v2/Schedules/list_schedules.py b/REST_API_v2/Schedules/list_schedules.py similarity index 100% rename from python_v3/REST_API_v2/Schedules/list_schedules.py rename to REST_API_v2/Schedules/list_schedules.py diff --git a/python_v3/REST_API_v2/Schedules/preview_schedule.py b/REST_API_v2/Schedules/preview_schedule.py similarity index 100% rename from python_v3/REST_API_v2/Schedules/preview_schedule.py rename to REST_API_v2/Schedules/preview_schedule.py diff --git a/python_v3/REST_API_v2/Schedules/update_schedule.py b/REST_API_v2/Schedules/update_schedule.py similarity index 100% rename from python_v3/REST_API_v2/Schedules/update_schedule.py rename to REST_API_v2/Schedules/update_schedule.py diff --git a/python_v3/REST_API_v2/Services/create_integration.py b/REST_API_v2/Services/create_integration.py similarity index 100% rename from python_v3/REST_API_v2/Services/create_integration.py rename to REST_API_v2/Services/create_integration.py diff --git a/python_v3/REST_API_v2/Services/create_service.py b/REST_API_v2/Services/create_service.py similarity index 100% rename from python_v3/REST_API_v2/Services/create_service.py rename to REST_API_v2/Services/create_service.py diff --git a/python_v3/REST_API_v2/Services/delete_service.py b/REST_API_v2/Services/delete_service.py similarity index 100% rename from python_v3/REST_API_v2/Services/delete_service.py rename to REST_API_v2/Services/delete_service.py diff --git a/python_v3/REST_API_v2/Services/get_integration.py b/REST_API_v2/Services/get_integration.py similarity index 100% rename from python_v3/REST_API_v2/Services/get_integration.py rename to REST_API_v2/Services/get_integration.py diff --git a/python_v3/REST_API_v2/Services/get_service.py b/REST_API_v2/Services/get_service.py similarity index 100% rename from python_v3/REST_API_v2/Services/get_service.py rename to REST_API_v2/Services/get_service.py diff --git a/python_v3/REST_API_v2/Services/list_services.py b/REST_API_v2/Services/list_services.py similarity index 100% rename from python_v3/REST_API_v2/Services/list_services.py rename to REST_API_v2/Services/list_services.py diff --git a/python_v3/REST_API_v2/Services/update_integration.py b/REST_API_v2/Services/update_integration.py similarity index 100% rename from python_v3/REST_API_v2/Services/update_integration.py rename to REST_API_v2/Services/update_integration.py diff --git a/python_v3/REST_API_v2/Services/update_service.py b/REST_API_v2/Services/update_service.py similarity index 100% rename from python_v3/REST_API_v2/Services/update_service.py rename to REST_API_v2/Services/update_service.py diff --git a/python_v3/REST_API_v2/Teams/add_escalation_policy_to_team.py b/REST_API_v2/Teams/add_escalation_policy_to_team.py similarity index 100% rename from python_v3/REST_API_v2/Teams/add_escalation_policy_to_team.py rename to REST_API_v2/Teams/add_escalation_policy_to_team.py diff --git a/python_v3/REST_API_v2/Teams/add_user_to_team.py b/REST_API_v2/Teams/add_user_to_team.py similarity index 100% rename from python_v3/REST_API_v2/Teams/add_user_to_team.py rename to REST_API_v2/Teams/add_user_to_team.py diff --git a/python_v3/REST_API_v2/Teams/create_team.py b/REST_API_v2/Teams/create_team.py similarity index 100% rename from python_v3/REST_API_v2/Teams/create_team.py rename to REST_API_v2/Teams/create_team.py diff --git a/python_v3/REST_API_v2/Teams/delete_team.py b/REST_API_v2/Teams/delete_team.py similarity index 100% rename from python_v3/REST_API_v2/Teams/delete_team.py rename to REST_API_v2/Teams/delete_team.py diff --git a/python_v3/REST_API_v2/Teams/get_team.py b/REST_API_v2/Teams/get_team.py similarity index 100% rename from python_v3/REST_API_v2/Teams/get_team.py rename to REST_API_v2/Teams/get_team.py diff --git a/python_v3/REST_API_v2/Teams/list_teams.py b/REST_API_v2/Teams/list_teams.py similarity index 100% rename from python_v3/REST_API_v2/Teams/list_teams.py rename to REST_API_v2/Teams/list_teams.py diff --git a/python_v3/REST_API_v2/Teams/remove_escalation_policy_from_team.py b/REST_API_v2/Teams/remove_escalation_policy_from_team.py similarity index 100% rename from python_v3/REST_API_v2/Teams/remove_escalation_policy_from_team.py rename to REST_API_v2/Teams/remove_escalation_policy_from_team.py diff --git a/python_v3/REST_API_v2/Teams/remove_user_from_team.py b/REST_API_v2/Teams/remove_user_from_team.py similarity index 100% rename from python_v3/REST_API_v2/Teams/remove_user_from_team.py rename to REST_API_v2/Teams/remove_user_from_team.py diff --git a/python_v3/REST_API_v2/Teams/update_team.py b/REST_API_v2/Teams/update_team.py similarity index 100% rename from python_v3/REST_API_v2/Teams/update_team.py rename to REST_API_v2/Teams/update_team.py diff --git a/python_v3/REST_API_v2/Users/create_user.py b/REST_API_v2/Users/create_user.py similarity index 100% rename from python_v3/REST_API_v2/Users/create_user.py rename to REST_API_v2/Users/create_user.py diff --git a/python_v3/REST_API_v2/Users/create_user_contact_method.py b/REST_API_v2/Users/create_user_contact_method.py similarity index 100% rename from python_v3/REST_API_v2/Users/create_user_contact_method.py rename to REST_API_v2/Users/create_user_contact_method.py diff --git a/python_v3/REST_API_v2/Users/create_user_notification_rule.py b/REST_API_v2/Users/create_user_notification_rule.py similarity index 100% rename from python_v3/REST_API_v2/Users/create_user_notification_rule.py rename to REST_API_v2/Users/create_user_notification_rule.py diff --git a/python_v3/REST_API_v2/Users/delete_user.py b/REST_API_v2/Users/delete_user.py similarity index 100% rename from python_v3/REST_API_v2/Users/delete_user.py rename to REST_API_v2/Users/delete_user.py diff --git a/python_v3/REST_API_v2/Users/delete_user_contact_method.py b/REST_API_v2/Users/delete_user_contact_method.py similarity index 100% rename from python_v3/REST_API_v2/Users/delete_user_contact_method.py rename to REST_API_v2/Users/delete_user_contact_method.py diff --git a/python_v3/REST_API_v2/Users/delete_user_notification_rule.py b/REST_API_v2/Users/delete_user_notification_rule.py similarity index 100% rename from python_v3/REST_API_v2/Users/delete_user_notification_rule.py rename to REST_API_v2/Users/delete_user_notification_rule.py diff --git a/python_v3/REST_API_v2/Users/get_user.py b/REST_API_v2/Users/get_user.py similarity index 100% rename from python_v3/REST_API_v2/Users/get_user.py rename to REST_API_v2/Users/get_user.py diff --git a/python_v3/REST_API_v2/Users/get_user_contact_method.py b/REST_API_v2/Users/get_user_contact_method.py similarity index 100% rename from python_v3/REST_API_v2/Users/get_user_contact_method.py rename to REST_API_v2/Users/get_user_contact_method.py diff --git a/python_v3/REST_API_v2/Users/get_user_notification_rule.py b/REST_API_v2/Users/get_user_notification_rule.py similarity index 100% rename from python_v3/REST_API_v2/Users/get_user_notification_rule.py rename to REST_API_v2/Users/get_user_notification_rule.py diff --git a/python_v3/REST_API_v2/Users/list_user_contact_methods.py b/REST_API_v2/Users/list_user_contact_methods.py similarity index 100% rename from python_v3/REST_API_v2/Users/list_user_contact_methods.py rename to REST_API_v2/Users/list_user_contact_methods.py diff --git a/python_v3/REST_API_v2/Users/list_user_notification_rules.py b/REST_API_v2/Users/list_user_notification_rules.py similarity index 100% rename from python_v3/REST_API_v2/Users/list_user_notification_rules.py rename to REST_API_v2/Users/list_user_notification_rules.py diff --git a/python_v3/REST_API_v2/Users/list_users.py b/REST_API_v2/Users/list_users.py similarity index 100% rename from python_v3/REST_API_v2/Users/list_users.py rename to REST_API_v2/Users/list_users.py diff --git a/python_v3/REST_API_v2/Users/update_user.py b/REST_API_v2/Users/update_user.py similarity index 100% rename from python_v3/REST_API_v2/Users/update_user.py rename to REST_API_v2/Users/update_user.py diff --git a/python_v3/REST_API_v2/Users/update_user_contact_method.py b/REST_API_v2/Users/update_user_contact_method.py similarity index 100% rename from python_v3/REST_API_v2/Users/update_user_contact_method.py rename to REST_API_v2/Users/update_user_contact_method.py diff --git a/python_v3/REST_API_v2/Users/update_user_notification_rule.py b/REST_API_v2/Users/update_user_notification_rule.py similarity index 100% rename from python_v3/REST_API_v2/Users/update_user_notification_rule.py rename to REST_API_v2/Users/update_user_notification_rule.py diff --git a/python_v3/REST_API_v2/Vendors/get_vendor.py b/REST_API_v2/Vendors/get_vendor.py similarity index 100% rename from python_v3/REST_API_v2/Vendors/get_vendor.py rename to REST_API_v2/Vendors/get_vendor.py diff --git a/python_v3/REST_API_v2/Vendors/list_vendors.py b/REST_API_v2/Vendors/list_vendors.py similarity index 100% rename from python_v3/REST_API_v2/Vendors/list_vendors.py rename to REST_API_v2/Vendors/list_vendors.py diff --git a/python_v2/EVENTS_API_V1/Ack/ack_incident.py b/python_v2/EVENTS_API_V1/Ack/ack_incident.py deleted file mode 100755 index 68a7745..0000000 --- a/python_v2/EVENTS_API_V1/Ack/ack_incident.py +++ /dev/null @@ -1,29 +0,0 @@ -#!/usr/bin/env python - -import json -import requests - -SERVICE_KEY = "" # ENTER EVENTS V1 API INTEGRATION KEY HERE -INCIDENT_KEY = "" # ENTER INCIDENT KEY - -def trigger_incident(): - # Triggers a PagerDuty incident without a previously generated incident key - # Uses Events V1 API - documentation: https://v2.developer.pagerduty.com/docs/trigger-events - - payload = { # Payload is built with the least amount of fields required to trigger an incident - "service_key": SERVICE_KEY, - "event_type": "acknowledge", - "incident_key": INCIDENT_KEY, - "description": "Example alert on host1.example.com" - } - - response = requests.post('https://events.pagerduty.com/generic/2010-04-15/create_event.json', - data=json.dumps(payload)) - - if response.json()["status"] == "success": - print ('Incident Acknowledged') - else: - print response.text # print error message if not successful - -if __name__ == '__main__': - trigger_incident() \ No newline at end of file diff --git a/python_v2/EVENTS_API_V1/Resolve/resolve_incident.py b/python_v2/EVENTS_API_V1/Resolve/resolve_incident.py deleted file mode 100755 index b1fc45a..0000000 --- a/python_v2/EVENTS_API_V1/Resolve/resolve_incident.py +++ /dev/null @@ -1,29 +0,0 @@ -#!/usr/bin/env python - -import json -import requests - -SERVICE_KEY = "" # ENTER EVENTS V1 API INTEGRATION KEY HERE -INCIDENT_KEY = "" # ENTER INCIDENT KEY - -def trigger_incident(): - # Triggers a PagerDuty incident without a previously generated incident key - # Uses Events V1 API - documentation: https://v2.developer.pagerduty.com/docs/trigger-events - - payload = { # Payload is built with the least amount of fields required to trigger an incident - "service_key": SERVICE_KEY, - "event_type": "resolve", - "incident_key": INCIDENT_KEY, - "description": "Example alert on host1.example.com" - } - - response = requests.post('https://events.pagerduty.com/generic/2010-04-15/create_event.json', - data=json.dumps(payload)) - - if response.json()["status"] == "success": - print ('Incident Resolved') - else: - print response.text # print error message if not successful - -if __name__ == '__main__': - trigger_incident() \ No newline at end of file diff --git a/python_v2/EVENTS_API_V1/Trigger/trigger_with_incident_key.py b/python_v2/EVENTS_API_V1/Trigger/trigger_with_incident_key.py deleted file mode 100755 index ddb9028..0000000 --- a/python_v2/EVENTS_API_V1/Trigger/trigger_with_incident_key.py +++ /dev/null @@ -1,29 +0,0 @@ -#!/usr/bin/env python - -import json -import requests - -SERVICE_KEY = "" # ENTER EVENTS V1 API INTEGRATION KEY HERE -INCIDENT_KEY = "" # ENTER INCIDENT KEY - -def trigger_incident(): - # Triggers a PagerDuty incident without a previously generated incident key - # Uses Events V1 API - documentation: https://v2.developer.pagerduty.com/docs/trigger-events - - payload = { # Payload is built with the least amount of fields required to trigger an incident - "service_key": SERVICE_KEY, - "event_type": "trigger", - "incident_key": INCIDENT_KEY, - "description": "Example alert on host1.example.com" - } - - response = requests.post('https://events.pagerduty.com/generic/2010-04-15/create_event.json', - data=json.dumps(payload)) - - if response.json()["status"] == "success": - print ('Incident Triggered') - else: - print response.text # print error message if not successful - -if __name__ == '__main__': - trigger_incident() \ No newline at end of file diff --git a/python_v2/EVENTS_API_V1/Trigger/trigger_without_incident_key.py b/python_v2/EVENTS_API_V1/Trigger/trigger_without_incident_key.py deleted file mode 100755 index 53558a0..0000000 --- a/python_v2/EVENTS_API_V1/Trigger/trigger_without_incident_key.py +++ /dev/null @@ -1,27 +0,0 @@ -#!/usr/bin/env python - -import json -import requests - -SERVICE_KEY = "" # ENTER EVENTS V1 API INTEGRATION KEY HERE - -def trigger_incident(): - # Triggers a PagerDuty incident without a previously generated incident key - # Uses Events V1 API - documentation: https://v2.developer.pagerduty.com/docs/trigger-events - - payload = { # Payload is built with the least amount of fields required to trigger an incident - "service_key": SERVICE_KEY, - "event_type": "trigger", - "description": "Example alert on host1.example.com" - } - - response = requests.post('https://events.pagerduty.com/generic/2010-04-15/create_event.json', - data=json.dumps(payload)) - - if response.json()["status"] == "success": - print ('Incident created with with incident / alert key of ' + '"' + response.json()['incident_key'] + '"') - else: - print response.text # print error message if not successful - -if __name__ == '__main__': - trigger_incident() \ No newline at end of file diff --git a/python_v2/EVENTS_API_v2/ack/ack_incident.py b/python_v2/EVENTS_API_v2/ack/ack_incident.py deleted file mode 100755 index d63255e..0000000 --- a/python_v2/EVENTS_API_v2/ack/ack_incident.py +++ /dev/null @@ -1,33 +0,0 @@ -#!/usr/bin/env python - -import json -import requests - -ROUTING_KEY = "" # ENTER EVENTS V2 API INTEGRATION KEY HERE -INCIDENT_KEY = "" # ENTER INCIDENT KEY HERE - -def trigger_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 - - header = { - "Content-Type": "application/json" - } - - payload = { # Payload is built with the least amount of fields required to trigger an incident - "routing_key": ROUTING_KEY, - "event_action": "acknowledge", - "dedup_key": INCIDENT_KEY - } - - response = requests.post('https://events.pagerduty.com/v2/enqueue', - data=json.dumps(payload), - headers=header) - - if response.json()["status"] == "success": - print ('Incident Acknowledged ') - else: - print response.text # print error message if not successful - -if __name__ == '__main__': - trigger_incident() \ No newline at end of file diff --git a/python_v2/EVENTS_API_v2/resolve/resolve_incident.py b/python_v2/EVENTS_API_v2/resolve/resolve_incident.py deleted file mode 100755 index 4c66295..0000000 --- a/python_v2/EVENTS_API_v2/resolve/resolve_incident.py +++ /dev/null @@ -1,33 +0,0 @@ -#!/usr/bin/env python - -import json -import requests - -ROUTING_KEY = "" # ENTER EVENTS V2 API INTEGRATION KEY HERE -INCIDENT_KEY = "" # ENTER INCIDENT KEY HERE - -def trigger_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 - - header = { - "Content-Type": "application/json" - } - - payload = { # Payload is built with the least amount of fields required to trigger an incident - "routing_key": ROUTING_KEY, - "event_action": "resolve", - "dedup_key": INCIDENT_KEY - } - - response = requests.post('https://events.pagerduty.com/v2/enqueue', - data=json.dumps(payload), - headers=header) - - if response.json()["status"] == "success": - print ('Incident Resolved ') - else: - print response.text # print error message if not successful - -if __name__ == '__main__': - trigger_incident() \ No newline at end of file diff --git a/python_v2/EVENTS_API_v2/trigger/trigger_with_incident_key.py b/python_v2/EVENTS_API_v2/trigger/trigger_with_incident_key.py deleted file mode 100644 index 0cde85e..0000000 --- a/python_v2/EVENTS_API_v2/trigger/trigger_with_incident_key.py +++ /dev/null @@ -1,38 +0,0 @@ -#!/usr/bin/env python - -import json -import requests - -ROUTING_KEY = "" # ENTER EVENTS V2 API INTEGRATION KEY HERE -INCIDENT_KEY = "" # ENTER INCIDENT KEY HERE - -def trigger_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 - - header = { - "Content-Type": "application/json" - } - - payload = { # Payload is built with the least amount of fields required to trigger an incident - "routing_key": ROUTING_KEY, - "event_action": "trigger", - "dedup_key": INCIDENT_KEY, - "payload": { - "summary": "Example alert on host1.example.com", - "source": "monitoringtool:cloudvendor:central-region-dc-01:852559987:cluster/api-stats-prod-003", - "severity": "critical" - } - } - - response = requests.post('https://events.pagerduty.com/v2/enqueue', - data=json.dumps(payload), - headers=header) - - if response.json()["status"] == "success": - print ('Incident Created') - else: - print response.text # print error message if not successful - -if __name__ == '__main__': - trigger_incident() \ No newline at end of file diff --git a/python_v2/EVENTS_API_v2/trigger/trigger_without_incident_key.py b/python_v2/EVENTS_API_v2/trigger/trigger_without_incident_key.py deleted file mode 100644 index 3c17967..0000000 --- a/python_v2/EVENTS_API_v2/trigger/trigger_without_incident_key.py +++ /dev/null @@ -1,36 +0,0 @@ -#!/usr/bin/env python - -import json -import requests - -ROUTING_KEY = "" # ENTER EVENTS V2 API INTEGRATION KEY HERE - -def trigger_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 - - header = { - "Content-Type": "application/json" - } - - payload = { # Payload is built with the least amount of fields required to trigger an incident - "routing_key": ROUTING_KEY, - "event_action": "trigger", - "payload": { - "summary": "Example alert on host1.example.com", - "source": "monitoringtool:cloudvendor:central-region-dc-01:852559987:cluster/api-stats-prod-003", - "severity": "critical" - } - } - - response = requests.post('https://events.pagerduty.com/v2/enqueue', - data=json.dumps(payload), - 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'] + '"') - else: - print response.text # print error message if not successful - -if __name__ == '__main__': - trigger_incident() \ No newline at end of file diff --git a/python_v2/REST_API_v2/Abilities/list_abilities.py b/python_v2/REST_API_v2/Abilities/list_abilities.py deleted file mode 100755 index dbe7f79..0000000 --- a/python_v2/REST_API_v2/Abilities/list_abilities.py +++ /dev/null @@ -1,45 +0,0 @@ -#!/usr/bin/env python -# -# Copyright (c) 2016, 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. - -import requests - -# Update to match your API key -API_KEY = '3c3gRvzx7uGfMYEnWKvF' - - -def list_abilities(): - url = 'https://api.pagerduty.com/abilities' - headers = { - 'Accept': 'application/vnd.pagerduty+json;version=2', - '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() - -if __name__ == '__main__': - list_abilities() diff --git a/python_v2/REST_API_v2/Abilities/test_ability.py b/python_v2/REST_API_v2/Abilities/test_ability.py deleted file mode 100755 index 7a1da01..0000000 --- a/python_v2/REST_API_v2/Abilities/test_ability.py +++ /dev/null @@ -1,48 +0,0 @@ -#!/usr/bin/env python -# -# Copyright (c) 2016, 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. - -import requests - -# Update to match your API key -API_KEY = '3c3gRvzx7uGfMYEnWKvF' - -# Update to match your ability ID -ID = 'sso' - - -def test_ability(): - url = 'https://api.pagerduty.com/abilities/{id}'.format(id=ID) - headers = { - 'Accept': 'application/vnd.pagerduty+json;version=2', - '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 - -if __name__ == '__main__': - test_ability() diff --git a/python_v2/REST_API_v2/AddOns/delete_addon.py b/python_v2/REST_API_v2/AddOns/delete_addon.py deleted file mode 100755 index f99deaa..0000000 --- a/python_v2/REST_API_v2/AddOns/delete_addon.py +++ /dev/null @@ -1,48 +0,0 @@ -#!/usr/bin/env python -# -# Copyright (c) 2016, 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. - -import requests - -# Update to match your API key -API_KEY = '3c3gRvzx7uGfMYEnWKvF' - -# Update to match ID of resource you want to delete -ID = 'PNIESDP' - - -def delete_addon(): - url = 'https://api.pagerduty.com/addons/{id}'.format(id=ID) - headers = { - 'Accept': 'application/vnd.pagerduty+json;version=2', - '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 - -if __name__ == '__main__': - delete_addon() diff --git a/python_v2/REST_API_v2/AddOns/get_addon.py b/python_v2/REST_API_v2/AddOns/get_addon.py deleted file mode 100755 index bf1c47c..0000000 --- a/python_v2/REST_API_v2/AddOns/get_addon.py +++ /dev/null @@ -1,48 +0,0 @@ -#!/usr/bin/env python -# -# Copyright (c) 2016, 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. - -import requests - -# Update to match your API key -API_KEY = '3c3gRvzx7uGfMYEnWKvF' - -# Update to match ID of resource you want to GET -ID = 'PNIESDP' - - -def get_addon(): - url = 'https://api.pagerduty.com/addons/{id}'.format(id=ID) - headers = { - 'Accept': 'application/vnd.pagerduty+json;version=2', - '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() - -if __name__ == '__main__': - get_addon() diff --git a/python_v2/REST_API_v2/AddOns/install_addon.py b/python_v2/REST_API_v2/AddOns/install_addon.py deleted file mode 100755 index 30511a1..0000000 --- a/python_v2/REST_API_v2/AddOns/install_addon.py +++ /dev/null @@ -1,61 +0,0 @@ -#!/usr/bin/env python -# -# Copyright (c) 2016, 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. - -import requests -import json - -# Update to match your API key -API_KEY = '3c3gRvzx7uGfMYEnWKvF' - -# Update to match your chosen parameters -SUMMARY = 'Insert addon summary here' -NAME = 'Insert addon name here' -SRC = 'https://intranet.example.com/status' -SERVICES = [] - - -def install_addon(): - url = 'https://api.pagerduty.com/addons' - headers = { - 'Accept': 'application/vnd.pagerduty+json;version=2', - 'Authorization': 'Token token={token}'.format(token=API_KEY), - 'Content-type': 'application/json' - } - payload = { - 'addon': { - 'summary': SUMMARY, - 'name': NAME, - 'src': SRC, - 'services': SERVICES - } - } - r = requests.post(url, headers=headers, data=json.dumps(payload)) - print 'Status Code: {code}'.format(code=r.status_code) - print r.json() - -if __name__ == '__main__': - install_addon() diff --git a/python_v2/REST_API_v2/AddOns/list_installed_addons.py b/python_v2/REST_API_v2/AddOns/list_installed_addons.py deleted file mode 100755 index e1a363a..0000000 --- a/python_v2/REST_API_v2/AddOns/list_installed_addons.py +++ /dev/null @@ -1,55 +0,0 @@ -#!/usr/bin/env python -# -# Copyright (c) 2016, 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. - -import requests - -# Update to match your API key -API_KEY = '3c3gRvzx7uGfMYEnWKvF' - -# Update to match your chosen parameters -INCLUDE = [] -SERVICE_IDS = [] -FILTER = '' - - -def list_installed_addons(): - url = 'https://api.pagerduty.com/addons' - headers = { - 'Accept': 'application/vnd.pagerduty+json;version=2', - 'Authorization': 'Token token={token}'.format(token=API_KEY) - } - payload = { - 'include[]': INCLUDE, - 'service_ids[]': SERVICE_IDS, - 'filter': FILTER - } - r = requests.get(url, headers=headers, params=payload) - print 'Status Code: {code}'.format(code=r.status_code) - print r.json() - -if __name__ == '__main__': - list_installed_addons() diff --git a/python_v2/REST_API_v2/AddOns/update_addon.py b/python_v2/REST_API_v2/AddOns/update_addon.py deleted file mode 100755 index 32d5019..0000000 --- a/python_v2/REST_API_v2/AddOns/update_addon.py +++ /dev/null @@ -1,64 +0,0 @@ -#!/usr/bin/env python -# -# Copyright (c) 2016, 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. - -import requests -import json - -# Update to match your API key -API_KEY = '3c3gRvzx7uGfMYEnWKvF' - -# Update to match ID of resource you want to update -ID = 'P00HQZ9' - -# Update to match your chosen parameters -SUMMARY = 'Insert updated addon summary here' -NAME = 'Insert updated addon name here' -SRC = 'https://intranet.example.com/updated_status_page' -SERVICES = [] - - -def update_addon(): - url = 'https://api.pagerduty.com/addons/{id}'.format(id=ID) - headers = { - 'Accept': 'application/vnd.pagerduty+json;version=2', - 'Authorization': 'Token token={token}'.format(token=API_KEY), - 'Content-type': 'application/json' - } - payload = { - 'addon': { - 'summary': SUMMARY, - 'name': NAME, - 'src': SRC, - 'services': SERVICES - } - } - r = requests.put(url, headers=headers, data=json.dumps(payload)) - print 'Status Code: ' + str(r.status_code) - print r.json() - -if __name__ == '__main__': - update_addon() diff --git a/python_v2/REST_API_v2/EscalationPolicies/create_escalation_policy.py b/python_v2/REST_API_v2/EscalationPolicies/create_escalation_policy.py deleted file mode 100755 index 33c12fb..0000000 --- a/python_v2/REST_API_v2/EscalationPolicies/create_escalation_policy.py +++ /dev/null @@ -1,73 +0,0 @@ -#!/usr/bin/env python -# -# Copyright (c) 2016, 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. - -import requests -import json - -# Update to match your API key -API_KEY = '3c3gRvzx7uGfMYEnWKvF' - -# Update to match your chosen parameters -TYPE = 'escalation_policy' -NAME = 'Insert resource name here' -SUMMARY = 'Insert resource description here' -REPEAT_ENABLED = True -NUM_LOOPS = 3 -ESCALATION_RULES = [{ - 'escalation_delay_in_minutes': 30, - 'targets': [{ - 'type': 'schedule', - 'id': 'PTC959G' - }] -}] -SERVICES = [] - - -def create_escalation_policy(): - url = 'https://api.pagerduty.com/escalation_policies' - headers = { - 'Accept': 'application/vnd.pagerduty+json;version=2', - 'Authorization': 'Token token={token}'.format(token=API_KEY), - 'Content-type': 'application/json' - } - payload = { - 'escalation_policy': { - 'name': NAME, - 'type': TYPE, - 'summary': SUMMARY, - 'repeat_enabled': REPEAT_ENABLED, - 'num_loops': NUM_LOOPS, - 'escalation_rules': ESCALATION_RULES, - 'services': SERVICES - } - } - r = requests.post(url, headers=headers, data=json.dumps(payload)) - print 'Status Code: {code}'.format(code=r.status_code) - print r.json() - -if __name__ == '__main__': - create_escalation_policy() diff --git a/python_v2/REST_API_v2/EscalationPolicies/delete_escalation_policy.py b/python_v2/REST_API_v2/EscalationPolicies/delete_escalation_policy.py deleted file mode 100755 index 11798b9..0000000 --- a/python_v2/REST_API_v2/EscalationPolicies/delete_escalation_policy.py +++ /dev/null @@ -1,48 +0,0 @@ -#!/usr/bin/env python -# -# Copyright (c) 2016, 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. - -import requests - -# Update to match your API key -API_KEY = '3c3gRvzx7uGfMYEnWKvF' - -# Update to match ID of resource you want to delete -ID = 'P2ITA2T' - - -def delete_escalation_policy(): - url = 'https://api.pagerduty.com/escalation_policies/{id}'.format(id=ID) - headers = { - 'Accept': 'application/vnd.pagerduty+json;version=2', - '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 - -if __name__ == '__main__': - delete_escalation_policy() diff --git a/python_v2/REST_API_v2/EscalationPolicies/get_escalation_policy.py b/python_v2/REST_API_v2/EscalationPolicies/get_escalation_policy.py deleted file mode 100755 index 1a66144..0000000 --- a/python_v2/REST_API_v2/EscalationPolicies/get_escalation_policy.py +++ /dev/null @@ -1,54 +0,0 @@ -#!/usr/bin/env python -# -# Copyright (c) 2016, 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. - -import requests - -# Update to match your API key -API_KEY = '3c3gRvzx7uGfMYEnWKvF' - -# Update to match ID of resource you want to GET -ID = 'PIX2DN3' - -# Update to match your chosen parameters -INCLUDE = [] - - -def get_escalation_policy(): - url = 'https://api.pagerduty.com/escalation_policies/{id}'.format(id=ID) - headers = { - 'Accept': 'application/vnd.pagerduty+json;version=2', - 'Authorization': 'Token token={token}'.format(token=API_KEY) - } - payload = { - 'include[]': INCLUDE - } - r = requests.get(url, headers=headers, params=payload) - print 'Status Code: {code}'.format(code=r.status_code) - print r.json() - -if __name__ == '__main__': - get_escalation_policy() diff --git a/python_v2/REST_API_v2/EscalationPolicies/list_escalation_policies.py b/python_v2/REST_API_v2/EscalationPolicies/list_escalation_policies.py deleted file mode 100755 index afe1e9b..0000000 --- a/python_v2/REST_API_v2/EscalationPolicies/list_escalation_policies.py +++ /dev/null @@ -1,59 +0,0 @@ -#!/usr/bin/env python -# -# Copyright (c) 2016, 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. - -import requests - -# Update to match your API key -API_KEY = '3c3gRvzx7uGfMYEnWKvF' - -# Update to match your chosen parameters -QUERY = '' -USER_IDS = [] -TEAM_IDS = [] -INCLUDE = [] -SORT_BY = 'name' - - -def list_escalation_policies(): - url = 'https://api.pagerduty.com/escalation_policies' - headers = { - 'Accept': 'application/vnd.pagerduty+json;version=2', - 'Authorization': 'Token token={token}'.format(token=API_KEY) - } - payload = { - 'query': QUERY, - 'user_ids[]': USER_IDS, - 'team_ids[]': TEAM_IDS, - 'include[]': INCLUDE, - 'sort_by': SORT_BY - } - r = requests.get(url, headers=headers, params=payload) - print 'Status Code: {code}'.format(code=r.status_code) - print r.json() - -if __name__ == '__main__': - list_escalation_policies() diff --git a/python_v2/REST_API_v2/EscalationPolicies/update_escalation_policy.py b/python_v2/REST_API_v2/EscalationPolicies/update_escalation_policy.py deleted file mode 100755 index 8582a46..0000000 --- a/python_v2/REST_API_v2/EscalationPolicies/update_escalation_policy.py +++ /dev/null @@ -1,80 +0,0 @@ -#!/usr/bin/env python -# -# Copyright (c) 2016, 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. - -import requests -import json - -# Update to match your API key -API_KEY = '3c3gRvzx7uGfMYEnWKvF' - -# Update to match ID of resource you want to update -ID = 'PVHNG0S' - -# Update to match your chosen parameters -TYPE = 'escalation_policy' -NAME = 'Insert resource name here' -SUMMARY = 'Insert resource description here' -REPEAT_ENABLED = True -NUM_LOOPS = 3 -ESCALATION_RULES = [ - { - 'escalation_delay_in_minutes': 30, - 'targets': [ - { - 'type': 'schedule', - 'id': 'PTC959G' - } - ] - } -] -SERVICES = [] - - -def update_escalation_policy(): - url = 'https://api.pagerduty.com/escalation_policies/{id}'.format(id=ID) - headers = { - 'Accept': 'application/vnd.pagerduty+json;version=2', - 'Authorization': 'Token token={token}'.format(token=API_KEY), - 'Content-type': 'application/json' - } - payload = { - 'escalation_policy': { - 'name': NAME, - 'type': TYPE, - 'summary': SUMMARY, - 'repeat_enabled': REPEAT_ENABLED, - 'num_loops': NUM_LOOPS, - 'escalation_rules': ESCALATION_RULES, - 'services': SERVICES - } - } - r = requests.put(url, headers=headers, data=json.dumps(payload)) - print 'Status Code: {code}'.format(code=r.status_code) - print r.json() - -if __name__ == '__main__': - update_escalation_policy() diff --git a/python_v2/REST_API_v2/Incidents/create_incident_note.py b/python_v2/REST_API_v2/Incidents/create_incident_note.py deleted file mode 100755 index 0d66dd4..0000000 --- a/python_v2/REST_API_v2/Incidents/create_incident_note.py +++ /dev/null @@ -1,62 +0,0 @@ -#!/usr/bin/env python -# -# Copyright (c) 2016, 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. - -import requests -import json - -# Update to match your API key -API_KEY = '3c3gRvzx7uGfMYEnWKvF' - -# Update to match your email address -EMAIL = 'lucas@pagerduty.com' - -# Update to match your chosen parameters -INCIDENT_ID = 'PI8BBP5' -CONTENT = 'Enter your note content here' - - -def create_incident_note(): - url = 'https://api.pagerduty.com/incidents/{id}/notes'.format( - id=INCIDENT_ID - ) - headers = { - 'Accept': 'application/vnd.pagerduty+json;version=2', - 'Authorization': 'Token token={token}'.format(token=API_KEY), - 'Content-type': 'application/json', - 'From': EMAIL - } - payload = { - 'note': { - 'content': CONTENT - } - } - r = requests.post(url, headers=headers, data=json.dumps(payload)) - print 'Status Code: {code}'.format(code=r.status_code) - print r.json() - -if __name__ == '__main__': - create_incident_note() diff --git a/python_v2/REST_API_v2/Incidents/get_incident.py b/python_v2/REST_API_v2/Incidents/get_incident.py deleted file mode 100755 index 1266418..0000000 --- a/python_v2/REST_API_v2/Incidents/get_incident.py +++ /dev/null @@ -1,48 +0,0 @@ -#!/usr/bin/env python -# -# Copyright (c) 2016, 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. - -import requests - -# Update to match your API key -API_KEY = '3c3gRvzx7uGfMYEnWKvF' - -# Update to match your incident ID -ID = 'P1DIBFS' - - -def get_incident(): - url = 'https://api.pagerduty.com/incidents/{id}'.format(id=ID) - headers = { - 'Accept': 'application/vnd.pagerduty+json;version=2', - '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() - -if __name__ == '__main__': - get_incident() diff --git a/python_v2/REST_API_v2/Incidents/list_incident_log_entries.py b/python_v2/REST_API_v2/Incidents/list_incident_log_entries.py deleted file mode 100755 index 3793ec8..0000000 --- a/python_v2/REST_API_v2/Incidents/list_incident_log_entries.py +++ /dev/null @@ -1,58 +0,0 @@ -#!/usr/bin/env python -# -# Copyright (c) 2016, 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. - -import requests - -# Update to match your API key -API_KEY = '3c3gRvzx7uGfMYEnWKvF' - -# Update to match your chosen parameters -INCIDENT_ID = 'P1DIBFS' -TIME_ZONE = 'UTC' -IS_OVERVIEW = False -INCLUDE = [] - - -def get_incident(): - url = 'https://api.pagerduty.com/incidents/{id}/log_entries'.format( - id=INCIDENT_ID - ) - headers = { - 'Accept': 'application/vnd.pagerduty+json;version=2', - 'Authorization': 'Token token={token}'.format(token=API_KEY) - } - payload = { - 'time_zone': TIME_ZONE, - 'is_overview': IS_OVERVIEW, - 'include[]': INCLUDE - } - r = requests.get(url, headers=headers, params=payload) - print 'Status Code: {code}'.format(code=r.status_code) - print r.json() - -if __name__ == '__main__': - get_incident() diff --git a/python_v2/REST_API_v2/Incidents/list_incident_notes.py b/python_v2/REST_API_v2/Incidents/list_incident_notes.py deleted file mode 100755 index 37fb83f..0000000 --- a/python_v2/REST_API_v2/Incidents/list_incident_notes.py +++ /dev/null @@ -1,50 +0,0 @@ -#!/usr/bin/env python -# -# Copyright (c) 2016, 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. - -import requests - -# Update to match your API key -API_KEY = '3c3gRvzx7uGfMYEnWKvF' - -# Update to match your incident ID -INCIDENT_ID = 'P1DIBFS' - - -def get_incident(): - url = 'https://api.pagerduty.com/incidents/{id}/notes'.format( - id=INCIDENT_ID - ) - headers = { - 'Accept': 'application/vnd.pagerduty+json;version=2', - '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() - -if __name__ == '__main__': - get_incident() diff --git a/python_v2/REST_API_v2/Incidents/list_incidents.py b/python_v2/REST_API_v2/Incidents/list_incidents.py deleted file mode 100755 index 95171c5..0000000 --- a/python_v2/REST_API_v2/Incidents/list_incidents.py +++ /dev/null @@ -1,73 +0,0 @@ -#!/usr/bin/env python -# -# Copyright (c) 2016, 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. - -import requests - -# Update to match your API key -API_KEY = '3c3gRvzx7uGfMYEnWKvF' - -# Update to match your chosen parameters -SINCE = '' -UNTIL = '' -DATE_RANGE = '' -STATUSES = [] -INCIDENT_KEY = '' -SERVICE_IDS = [] -TEAM_IDS = [] -USER_IDS = [] -URGENCIES = [] -TIME_ZONE = 'UTC' -SORT_BY = [] -INCLUDE = [] - - -def list_incidents(): - url = 'https://api.pagerduty.com/incidents' - headers = { - 'Accept': 'application/vnd.pagerduty+json;version=2', - 'Authorization': 'Token token={token}'.format(token=API_KEY) - } - payload = { - 'since': SINCE, - 'until': UNTIL, - 'date_range': DATE_RANGE, - 'statuses[]': STATUSES, - 'incident_key': INCIDENT_KEY, - 'service_ids[]': SERVICE_IDS, - 'team_ids[]': TEAM_IDS, - 'user_ids[]': USER_IDS, - 'urgencies[]': URGENCIES, - 'time_zone': TIME_ZONE, - '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() - -if __name__ == '__main__': - list_incidents() diff --git a/python_v2/REST_API_v2/Incidents/manage_incidents.py b/python_v2/REST_API_v2/Incidents/manage_incidents.py deleted file mode 100755 index 703a5e7..0000000 --- a/python_v2/REST_API_v2/Incidents/manage_incidents.py +++ /dev/null @@ -1,88 +0,0 @@ -#!/usr/bin/env python -# -# Copyright (c) 2016, 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. - -import requests -import json - -# Update to match your API key -API_KEY = '3c3gRvzx7uGfMYEnWKvF' - -# Update to match your email address -EMAIL = 'lucas@pagerduty.com' - -# Update to match your chosen parameters for each incident -INCIDENT_ONE_ID = 'P1DIBFS' -INCIDENT_ONE_STATUS = 'resolved' -INCIDENT_ONE_ASSIGNEE_ID = '' -INCIDENT_ONE_ASSIGNEE_TYPE = '' - -INCIDENT_TWO_ID = 'PKSPVAW' -INCIDENT_TWO_STATUS = 'resolved' -INCIDENT_TWO_ASSIGNEE_ID = '' -INCIDENT_TWO_ASSIGNEE_TYPE = '' - - -def manage_incidents(): - url = 'https://api.pagerduty.com/incidents' - headers = { - 'Accept': 'application/vnd.pagerduty+json;version=2', - 'Authorization': 'Token token={token}'.format(token=API_KEY), - 'Content-type': 'application/json', - 'From': EMAIL - } - payload = { - 'incidents': [ - { - 'id': INCIDENT_ONE_ID, - 'type': 'incident', - 'status': INCIDENT_ONE_STATUS, - 'assigments': [{ - 'assignee': { - 'id': INCIDENT_ONE_ASSIGNEE_ID, - 'type': INCIDENT_ONE_ASSIGNEE_TYPE - } - }] - }, - { - 'id': INCIDENT_TWO_ID, - 'type': 'incident', - 'status': INCIDENT_TWO_STATUS, - 'assignments': [{ - 'assignee': { - 'id': INCIDENT_TWO_ASSIGNEE_ID, - 'type': INCIDENT_TWO_ASSIGNEE_TYPE - } - }] - } - ] - } - r = requests.put(url, headers=headers, data=json.dumps(payload)) - print 'Status Code: {code}'.format(code=r.status_code) - print r.json() - -if __name__ == '__main__': - manage_incidents() diff --git a/python_v2/REST_API_v2/Incidents/snooze_incident.py b/python_v2/REST_API_v2/Incidents/snooze_incident.py deleted file mode 100755 index 24ea347..0000000 --- a/python_v2/REST_API_v2/Incidents/snooze_incident.py +++ /dev/null @@ -1,61 +0,0 @@ -#!/usr/bin/env python -# -# Copyright (c) 2016, 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. - -import requests -import json - -# Update to match your API key -API_KEY = '3c3gRvzx7uGfMYEnWKvF' - -# Update to match your email address -EMAIL = 'lucas@pagerduty.com' - -# Update to match your chosen parameters -INCIDENT_ID = 'P7SP1VE' -CONTENT = 'Enter your note content here' - - -def snooze_incident(): - url = 'https://api.pagerduty.com/incidents/{id}/snooze'.format( - id=INCIDENT_ID - ) - headers = { - 'Accept': 'application/vnd.pagerduty+json;version=2', - 'Authorization': 'Token token={token}'.format(token=API_KEY), - 'Content-type': 'application/json', - 'From': EMAIL - } - payload = { - 'content': CONTENT, - '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() - -if __name__ == '__main__': - snooze_incident() diff --git a/python_v2/REST_API_v2/Incidents/trigger_incident.py b/python_v2/REST_API_v2/Incidents/trigger_incident.py deleted file mode 100644 index 8ddcf77..0000000 --- a/python_v2/REST_API_v2/Incidents/trigger_incident.py +++ /dev/null @@ -1,69 +0,0 @@ -#!/usr/bin/env python -# -# Copyright (c) 2016, 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. - -import requests -import json - -# Update to match your API key -API_KEY = '' -SERVICE_ID = '' -FROM = '' - -def trigger_incident(): - """Triggers an incident via the V2 REST API using sample data.""" - - url = 'https://api.pagerduty.com/incidents' - headers = { - 'Content-Type': 'application/json', - 'Accept': 'application/vnd.pagerduty+json;version=2', - 'Authorization': 'Token token={token}'.format(token=API_KEY), - 'From': FROM - } - - payload = { - "incident": { - "type": "incident", - "title": "The server is on fire.", - "service": { - "id": SERVICE_ID, - "type": "service_reference" - }, - "incident_key": "baf7cf21b1da41b4b0221008339ff3571", - "body": { - "type": "incident_body", - "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." - } - } - } - - r = requests.post(url, headers=headers, data=json.dumps(payload)) - - print 'Status Code: {code}'.format(code=r.status_code) - print r.json() - -if __name__ == '__main__': - trigger_incident() diff --git a/python_v2/REST_API_v2/Incidents/update_incident.py b/python_v2/REST_API_v2/Incidents/update_incident.py deleted file mode 100755 index 6e2a3ec..0000000 --- a/python_v2/REST_API_v2/Incidents/update_incident.py +++ /dev/null @@ -1,70 +0,0 @@ -#!/usr/bin/env python -# -# Copyright (c) 2016, 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. - -import requests -import json - -# Update to match your API key -API_KEY = '3c3gRvzx7uGfMYEnWKvF' - -# Update to match your email address -EMAIL = 'lucas@pagerduty.com' - -# Update to match your chosen parameters for the incident -INCIDENT_ID = 'PQQVDM1' -TYPE = 'incident' -SUMMARY = 'Enter your incident summary here' -STATUS = 'resolved' -ESCALATION_LEVEL = 1 -ASSIGNED_TO_USER = '' -ESCALATION_POLICY = '' - - -def update_incident(): - url = 'https://api.pagerduty.com/incidents/{id}'.format(id=INCIDENT_ID) - headers = { - 'Accept': 'application/vnd.pagerduty+json;version=2', - 'Authorization': 'Token token={token}'.format(token=API_KEY), - 'Content-type': 'application/json', - 'From': EMAIL - } - payload = { - 'incident': { - 'type': TYPE, - 'summary': SUMMARY, - 'status': STATUS, - 'escalation_level': ESCALATION_LEVEL, - 'assigned_to_user': ASSIGNED_TO_USER, - 'escalation_policy': ESCALATION_POLICY - } - } - r = requests.put(url, headers=headers, data=json.dumps(payload)) - print 'Status Code: {code}'.format(code=r.status_code) - print r.json() - -if __name__ == '__main__': - update_incident() diff --git a/python_v2/REST_API_v2/LogEntries/get_log_entry.py b/python_v2/REST_API_v2/LogEntries/get_log_entry.py deleted file mode 100755 index 68be38e..0000000 --- a/python_v2/REST_API_v2/LogEntries/get_log_entry.py +++ /dev/null @@ -1,54 +0,0 @@ -#!/usr/bin/env python -# -# Copyright (c) 2016, 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. - -import requests - -# Update to match your API key -API_KEY = '3c3gRvzx7uGfMYEnWKvF' - -# Update to match ID of resource you want to GET -ID = 'Q1LLSJN8TZGO3Q' - -# Update to match your chosen parameters -INCLUDE = [] - - -def get_log_entry(): - url = 'https://api.pagerduty.com/log_entries/{id}'.format(id=ID) - headers = { - 'Accept': 'application/vnd.pagerduty+json;version=2', - 'Authorization': 'Token token={token}'.format(token=API_KEY) - } - payload = { - 'include[]': INCLUDE - } - r = requests.get(url, headers=headers, params=payload) - print 'Status Code: {code}'.format(code=r.status_code) - print r.json() - -if __name__ == '__main__': - get_log_entry() diff --git a/python_v2/REST_API_v2/LogEntries/list_log_entries.py b/python_v2/REST_API_v2/LogEntries/list_log_entries.py deleted file mode 100755 index ba5c3ec..0000000 --- a/python_v2/REST_API_v2/LogEntries/list_log_entries.py +++ /dev/null @@ -1,61 +0,0 @@ -#!/usr/bin/env python -# -# Copyright (c) 2016, 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. - -import requests - -# Update to match your API key -API_KEY = '3c3gRvzx7uGfMYEnWKvF' - -# Update to match your chosen parameters -TIME_ZONE = 'UTC' -SINCE = '' -UNTIL = '' -IS_OVERVIEW = False -INCLUDE = [] - - -def list_log_entries(): - url = 'https://api.pagerduty.com/log_entries' - headers = { - 'Accept': 'application/vnd.pagerduty+json;version=2', - 'Authorization': 'Token token={token}'.format(token=API_KEY) - } - payload = { - 'time_zone': TIME_ZONE, - 'is_overview': IS_OVERVIEW, - 'include[]': INCLUDE - } - if SINCE != '': - payload['since'] = SINCE - 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() - -if __name__ == '__main__': - list_log_entries() diff --git a/python_v2/REST_API_v2/MaintenanceWindows/create_maintenance_window.py b/python_v2/REST_API_v2/MaintenanceWindows/create_maintenance_window.py deleted file mode 100755 index fb81604..0000000 --- a/python_v2/REST_API_v2/MaintenanceWindows/create_maintenance_window.py +++ /dev/null @@ -1,72 +0,0 @@ -#!/usr/bin/env python -# -# Copyright (c) 2016, 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. - -import requests -import json - -# Update to match your API key -API_KEY = '3c3gRvzx7uGfMYEnWKvF' - -# Update to match your email address -EMAIL = 'lucas@pagerduty.com' - -# Update to match your chosen parameters -START_TIME = '2016-05-23T14:00:00-07:00' -END_TIME = '2016-05-23T18:00:00-07:00' -DESCRIPTION = 'Enter your maintenance window description here' -SERVICES = [{ - 'id': 'PKWA90D', - 'type': 'service_reference' -}] -TEAMS = [] -TYPE = 'maintenance_window' - - -def create_maintenance_window(): - 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 'Status Code: {code}'.format(code=r.status_code) - print r.json() - -if __name__ == '__main__': - create_maintenance_window() diff --git a/python_v2/REST_API_v2/MaintenanceWindows/delete_or_end_maintenance_window.py b/python_v2/REST_API_v2/MaintenanceWindows/delete_or_end_maintenance_window.py deleted file mode 100755 index b7efc51..0000000 --- a/python_v2/REST_API_v2/MaintenanceWindows/delete_or_end_maintenance_window.py +++ /dev/null @@ -1,48 +0,0 @@ -#!/usr/bin/env python -# -# Copyright (c) 2016, 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. - -import requests - -# Update to match your API key -API_KEY = '3c3gRvzx7uGfMYEnWKvF' - -# Update to match ID of resource you want to delete -ID = 'PER23E0' - - -def delete_maintenance_window(): - url = 'https://api.pagerduty.com/maintenance_windows/{id}'.format(id=ID) - headers = { - 'Accept': 'application/vnd.pagerduty+json;version=2', - '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 - -if __name__ == '__main__': - delete_maintenance_window() diff --git a/python_v2/REST_API_v2/MaintenanceWindows/end_all_maintenance_windows.py b/python_v2/REST_API_v2/MaintenanceWindows/end_all_maintenance_windows.py deleted file mode 100644 index 60a3907..0000000 --- a/python_v2/REST_API_v2/MaintenanceWindows/end_all_maintenance_windows.py +++ /dev/null @@ -1,140 +0,0 @@ -#!/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 will search for all currently active maintenance windows on all -# services and end them. It does not support pagination, so it is limited to 100 -# maintenance windows (by default it will sort by name) -# -# REQUIRED: API_KEY, EMAIL -# -# OPTIONAL: You can set the END_TIME to a future date if required. -# -# # Date format: '2018-09-30T14:00:00' -# -# There are also other parameters for filtering maintenance windows. -# -# -------------------------------------------------------------------------------- - -import requests -import datetime - -current_time = datetime.datetime.now() - -# Update to match your v2 REST API key -API_KEY = '' - -# Update to match your login email -EMAIL = '' - -# Update to match your chosen parameters -# You can also specify a different end date here instead (Date format: '2018-09-30T14:00:00') -END_TIME = current_time -TEAM_IDS = [] -SERVICE_IDS = [] -INCLUDE = [] -FILTER = 'ongoing' -QUERY = '' - - -def get_maintenance_windows(): - url = 'https://api.pagerduty.com/maintenance_windows?total=true' - headers = { - 'Accept': 'application/vnd.pagerduty+json;version=2', - 'Authorization': 'Token token={token}'.format(token=API_KEY) - } - payload = { - 'team_ids[]': TEAM_IDS, - 'service_ids[]': SERVICE_IDS, - 'include[]': INCLUDE, - 'filter': FILTER, - 'query': QUERY - } - maintenance_windows_ids = [] - r = requests.get(url, headers=headers, params=payload) - print'Getting ongoing maintenance windows...' - 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 maintenance windows." - print "\tPlease ensure that the login email and v2 REST API key in this script are correct." - print r.text - return maintenance_windows_ids - maintenance_list = r.json() - ids = maintenance_list['maintenance_windows'] - total = int(maintenance_list['total']) - - if total > 0: - if total == 1: - print "\t1 ongoing maintenance window found:" - if total == 2: - print "\t", total, 'ongoing maintenance windows found' - for maintenance_window in range(total): - maintenance_windows_ids.append(ids[maintenance_window]['id']) - print "\t", maintenance_windows_ids - else: - print "No ongoing maintenance windows found" - return maintenance_windows_ids - - -def end_maintenance_window(MAINTENANCE_WINDOWS): - if len(MAINTENANCE_WINDOWS) == 1: - print "Ending maintenance window..." - else: - print "Ending maintenance windows..." - headers = { - 'Accept': 'application/vnd.pagerduty+json;version=2', - 'Authorization': 'Token token={token}'.format(token=API_KEY) - } - for maintenance_window in range(len(MAINTENANCE_WINDOWS)): - url = 'https://api.pagerduty.com/maintenance_windows/{id}'.format(id=MAINTENANCE_WINDOWS[maintenance_window]) - print "\t", str(MAINTENANCE_WINDOWS[maintenance_window]) - r = requests.delete(url, headers=headers) - print '\tStatus Code: {code}'.format(code=r.status_code) - if r.status_code == 204: - print '\tMaintenance window ended successfully!' - else: - print "\tThere was an error ending this maintenance window" - print "\tPlease ensure that the login email and v2 REST API key in this script have proper permissions" - return maintenance_windows_ids - print r.text - -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: - MAINTENANCE_WINDOWS = get_maintenance_windows() - if MAINTENANCE_WINDOWS != []: - end_maintenance_window(MAINTENANCE_WINDOWS) - - -# ----------------------------------------------------------------------- - diff --git a/python_v2/REST_API_v2/MaintenanceWindows/get_maintenance_window.py b/python_v2/REST_API_v2/MaintenanceWindows/get_maintenance_window.py deleted file mode 100755 index 1cbf506..0000000 --- a/python_v2/REST_API_v2/MaintenanceWindows/get_maintenance_window.py +++ /dev/null @@ -1,54 +0,0 @@ -#!/usr/bin/env python -# -# Copyright (c) 2016, 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. - -import requests - -# Update to match your API key -API_KEY = '3c3gRvzx7uGfMYEnWKvF' - -# Update to match ID of resource you want to GET -ID = 'P5B7MVH' - -# Update to match your chosen parameters -INCLUDE = [] - - -def get_maintenance_window(): - url = 'https://api.pagerduty.com/maintenance_windows/{id}'.format(id=ID) - headers = { - 'Accept': 'application/vnd.pagerduty+json;version=2', - 'Authorization': 'Token token={token}'.format(token=API_KEY) - } - payload = { - 'include[]': INCLUDE - } - r = requests.get(url, headers=headers, params=payload) - print 'Status Code: {code}'.format(code=r.status_code) - print r.json() - -if __name__ == '__main__': - get_maintenance_window() diff --git a/python_v2/REST_API_v2/MaintenanceWindows/list_maintenance_windows.py b/python_v2/REST_API_v2/MaintenanceWindows/list_maintenance_windows.py deleted file mode 100755 index 2c7a100..0000000 --- a/python_v2/REST_API_v2/MaintenanceWindows/list_maintenance_windows.py +++ /dev/null @@ -1,59 +0,0 @@ -#!/usr/bin/env python -# -# Copyright (c) 2016, 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. - -import requests - -# Update to match your API key -API_KEY = '3c3gRvzx7uGfMYEnWKvF' - -# Update to match your chosen parameters -TEAM_IDS = [] -SERVICE_IDS = [] -INCLUDE = [] -FILTER = 'all' -QUERY = '' - - -def list_maintenance_windows(): - url = 'https://api.pagerduty.com/maintenance_windows' - headers = { - 'Accept': 'application/vnd.pagerduty+json;version=2', - 'Authorization': 'Token token={token}'.format(token=API_KEY) - } - payload = { - 'team_ids[]': TEAM_IDS, - 'service_ids[]': SERVICE_IDS, - 'include[]': INCLUDE, - 'filter': FILTER, - 'query': QUERY - } - r = requests.get(url, headers=headers, params=payload) - print 'Status Code: {code}'.format(code=r.status_code) - print r.json() - -if __name__ == '__main__': - list_maintenance_windows() diff --git a/python_v2/REST_API_v2/MaintenanceWindows/update_maintenance_window.py b/python_v2/REST_API_v2/MaintenanceWindows/update_maintenance_window.py deleted file mode 100755 index e0425c6..0000000 --- a/python_v2/REST_API_v2/MaintenanceWindows/update_maintenance_window.py +++ /dev/null @@ -1,71 +0,0 @@ -#!/usr/bin/env python -# -# Copyright (c) 2016, 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. - -import requests -import json - -# Update to match your API key -API_KEY = '3c3gRvzx7uGfMYEnWKvF' - -# Update to match ID of resource you want to update -ID = 'PE54NW4' - -# Update to match your chosen parameters -START_TIME = '2016-05-23T14:00:00-07:00' -END_TIME = '2016-05-23T18:00:00-07:00' -DESCRIPTION = 'Enter your updated maintenance window description here' -SERVICES = [{ - 'id': 'PKWA90D', - 'type': 'service_reference' -}] -TEAMS = [] -TYPE = 'maintenance_window' - - -def update_maintenance_window(): - url = 'https://api.pagerduty.com/maintenance_windows/{id}'.format(id=ID) - headers = { - 'Accept': 'application/vnd.pagerduty+json;version=2', - 'Authorization': 'Token token={token}'.format(token=API_KEY), - 'Content-type': 'application/json' - } - payload = { - 'maintenance_window': { - 'start_time': START_TIME, - 'end_time': END_TIME, - 'description': DESCRIPTION, - 'services': SERVICES, - 'teams': TEAMS, - 'type': TYPE - } - } - r = requests.put(url, headers=headers, data=json.dumps(payload)) - print 'Status Code: {code}'.format(code=r.status_code) - print r.json() - -if __name__ == '__main__': - update_maintenance_window() diff --git a/python_v2/REST_API_v2/Notifications/list_notifications.py b/python_v2/REST_API_v2/Notifications/list_notifications.py deleted file mode 100755 index 0599fdc..0000000 --- a/python_v2/REST_API_v2/Notifications/list_notifications.py +++ /dev/null @@ -1,59 +0,0 @@ -#!/usr/bin/env python -# -# Copyright (c) 2016, 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. - -import requests - -# Update to match your API key -API_KEY = '3c3gRvzx7uGfMYEnWKvF' - -# Update to match your chosen parameters -TIME_ZONE = 'UTC' -SINCE = '2016-05-15' -UNTIL = '2016-05-20' -FILTER = 'sms_notification' -INCLUDE = [] - - -def list_notifications(): - url = 'https://api.pagerduty.com/notifications' - headers = { - 'Accept': 'application/vnd.pagerduty+json;version=2', - 'Authorization': 'Token token={token}'.format(token=API_KEY) - } - payload = { - 'time_zone': TIME_ZONE, - 'since': SINCE, - 'until': UNTIL, - 'filter': FILTER, - 'include[]': INCLUDE - } - r = requests.get(url, headers=headers, params=payload) - print 'Status Code: {code}'.format(code=r.status_code) - print r.json() - -if __name__ == '__main__': - list_notifications() diff --git a/python_v2/REST_API_v2/OnCalls/list_oncalls.py b/python_v2/REST_API_v2/OnCalls/list_oncalls.py deleted file mode 100755 index 6f9bb09..0000000 --- a/python_v2/REST_API_v2/OnCalls/list_oncalls.py +++ /dev/null @@ -1,65 +0,0 @@ -#!/usr/bin/env python -# -# Copyright (c) 2016, 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. - -import requests - -# Update to match your API key -API_KEY = '3c3gRvzx7uGfMYEnWKvF' - -# Update to match your chosen parameters -TIME_ZONE = 'UTC' -INCLUDE = [] -USER_IDS = [] -ESCALATION_POLICY_IDS = [] -SCHEDULE_IDS = [] -SINCE = '' -UNTIL = '' -EARLIEST = False - - -def list_oncalls(): - url = 'https://api.pagerduty.com/oncalls' - headers = { - 'Accept': 'application/vnd.pagerduty+json;version=2', - 'Authorization': 'Token token={token}'.format(token=API_KEY) - } - payload = { - 'time_zone': TIME_ZONE, - 'include[]': INCLUDE, - 'user_ids[]': USER_IDS, - 'escalation_policy_ids[]': ESCALATION_POLICY_IDS, - 'schedule_ids[]': SCHEDULE_IDS, - 'since': SINCE, - 'until': UNTIL, - 'earliest': EARLIEST - } - r = requests.get(url, headers=headers, params=payload) - print 'Status Code: {code}'.format(code=r.status_code) - print r.json() - -if __name__ == '__main__': - list_oncalls() diff --git a/python_v2/REST_API_v2/Schedules/create_override.py b/python_v2/REST_API_v2/Schedules/create_override.py deleted file mode 100755 index 847e70d..0000000 --- a/python_v2/REST_API_v2/Schedules/create_override.py +++ /dev/null @@ -1,67 +0,0 @@ -#!/usr/bin/env python -# -# Copyright (c) 2016, 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. - -import requests -import json - -# Update to match your API key -API_KEY = '3c3gRvzx7uGfMYEnWKvF' - -# Update to match the schedule ID -SCHEDULE_ID = 'PJGJ9RZ' - -# Update to match your chosen parameters -USER_ID = 'PAZZ8LZ' -START = '2016-06-01' -END = '2016-07-01' - - -def create_override(): - url = 'https://api.pagerduty.com/schedules/{id}/overrides'.format( - id=SCHEDULE_ID - ) - headers = { - 'Accept': 'application/vnd.pagerduty+json;version=2', - 'Authorization': 'Token token={token}'.format(token=API_KEY), - 'Content-type': 'application/json' - } - payload = { - 'override': { - 'start': START, - 'end': END, - 'user': { - 'id': USER_ID, - 'type': 'user_reference' - } - } - } - r = requests.post(url, headers=headers, data=json.dumps(payload)) - print 'Status Code: {code}'.format(code=r.status_code) - print r.json() - -if __name__ == '__main__': - create_override() diff --git a/python_v2/REST_API_v2/Schedules/create_schedule.py b/python_v2/REST_API_v2/Schedules/create_schedule.py deleted file mode 100755 index 69ec8d2..0000000 --- a/python_v2/REST_API_v2/Schedules/create_schedule.py +++ /dev/null @@ -1,134 +0,0 @@ -#!/usr/bin/env python -# -# Copyright (c) 2016, 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. - -import requests -import json - -# Update to match your API key -API_KEY = '3c3gRvzx7uGfMYEnWKvF' - -# Update to match your chosen parameters -OVERFLOW = False - -# Update to match your chosen parameters for the overall schedule -TYPE = 'schedule' -SUMMARY = 'Insert your schedule summary here' -NAME = 'Insert your schedule name here' -TIME_ZONE = 'UTC' -ESCALATION_POLICIES = [] -TEAMS = [] - -# Update to match your chosen parameters for each schedule layer -LAYER_ONE_START = '2016-05-23T18:00:00-07:00' -LAYER_ONE_END = '2016-06-23T18:00:00-07:00' -LAYER_ONE_USERS = [ - { - 'id': 'PAZZ8LZ', - 'type': 'user_reference' - }, - { - 'id': 'P1PJUIZ', - 'type': 'user_reference' - } -] -LAYER_ONE_RESTRICTION_TYPE = 'Daily' -LAYER_ONE_RESTRICTIONS = [] -LAYER_ONE_ROTATION_VIRTUAL_START = '2016-05-23T18:00:00-07:00' -LAYER_ONE_PRIORITY = 1 -LAYER_ONE_ROTATION_TURN_LENGTH_SECONDS = 60 * 60 * 24 # 24 hours -LAYER_ONE_NAME = 'Insert layer one name here' - -LAYER_TWO_START = '2016-05-23T18:00:00-07:00' -LAYER_TWO_END = '2016-06-23T18:00:00-07:00' -LAYER_TWO_USERS = [ - { - 'id': 'POC4AOM', - 'type': 'user_reference' - }, - { - 'id': 'PLUWO2C', - 'type': 'user_reference' - } -] -LAYER_TWO_RESTRICTION_TYPE = 'Weekly' -LAYER_TWO_RESTRICTIONS = [] -LAYER_TWO_ROTATION_VIRTUAL_START = '2016-05-23T18:00:00-07:00' -LAYER_TWO_PRIORITY = 1 -LAYER_TWO_ROTATION_TURN_LENGTH_SECONDS = 60 * 60 * 24 # 24 hours -LAYER_TWO_NAME = 'Insert layer two name here' - - -def create_schedule(): - url = 'https://api.pagerduty.com/schedules' - headers = { - 'Accept': 'application/vnd.pagerduty+json;version=2', - 'Authorization': 'Token token={token}'.format(token=API_KEY), - 'Content-type': 'application/json' - } - payload = { - 'overflow': OVERFLOW, - 'schedule': { - 'type': TYPE, - 'summary': SUMMARY, - 'name': NAME, - 'time_zone': TIME_ZONE, - 'escalation_policies': ESCALATION_POLICIES, - 'teams': TEAMS, - 'schedule_layers': [ - { - 'start': LAYER_ONE_START, - 'end': LAYER_ONE_END, - 'users': LAYER_ONE_USERS, - 'restriction_type': LAYER_ONE_RESTRICTION_TYPE, - 'restrictions': LAYER_ONE_RESTRICTIONS, - 'rotation_virtual_start': LAYER_ONE_ROTATION_VIRTUAL_START, - 'priority': LAYER_ONE_PRIORITY, - 'rotation_turn_length_seconds': - LAYER_ONE_ROTATION_TURN_LENGTH_SECONDS, - 'name': LAYER_ONE_NAME - }, - { - 'start': LAYER_TWO_START, - 'end': LAYER_TWO_END, - 'users': LAYER_TWO_USERS, - 'restriction_type': LAYER_TWO_RESTRICTION_TYPE, - 'restrictions': LAYER_TWO_RESTRICTIONS, - 'rotation_virtual_start': LAYER_TWO_ROTATION_VIRTUAL_START, - 'priority': LAYER_TWO_PRIORITY, - 'rotation_turn_length_seconds': - LAYER_TWO_ROTATION_TURN_LENGTH_SECONDS, - 'name': LAYER_TWO_NAME - } - ] - } - } - r = requests.post(url, headers=headers, data=json.dumps(payload)) - print 'Status Code: {code}'.format(code=r.status_code) - print r.json() - -if __name__ == '__main__': - create_schedule() diff --git a/python_v2/REST_API_v2/Schedules/delete_override.py b/python_v2/REST_API_v2/Schedules/delete_override.py deleted file mode 100755 index f080c80..0000000 --- a/python_v2/REST_API_v2/Schedules/delete_override.py +++ /dev/null @@ -1,52 +0,0 @@ -#!/usr/bin/env python -# -# Copyright (c) 2016, 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. - -import requests - -# Update to match your API key -API_KEY = '3c3gRvzx7uGfMYEnWKvF' - -# Update to match the IDs of the schedule and override you want to delete -SCHEDULE_ID = 'PJGJ9RZ' -OVERRIDE_ID = 'Q0PVCKPSTNQUGG' - - -def delete_override(): - url = 'https://api.pagerduty.com/schedules/{sid}/overrides/{oid}'.format( - sid=SCHEDULE_ID, - oid=OVERRIDE_ID - ) - headers = { - 'Accept': 'application/vnd.pagerduty+json;version=2', - '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 - -if __name__ == '__main__': - delete_override() diff --git a/python_v2/REST_API_v2/Schedules/delete_schedule.py b/python_v2/REST_API_v2/Schedules/delete_schedule.py deleted file mode 100755 index 2565611..0000000 --- a/python_v2/REST_API_v2/Schedules/delete_schedule.py +++ /dev/null @@ -1,48 +0,0 @@ -#!/usr/bin/env python -# -# Copyright (c) 2016, 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. - -import requests - -# Update to match your API key -API_KEY = '3c3gRvzx7uGfMYEnWKvF' - -# Update to match ID of resource you want to delete -ID = 'PQX3A8C' - - -def delete_schedule(): - url = 'https://api.pagerduty.com/schedules/{id}'.format(id=ID) - headers = { - 'Accept': 'application/vnd.pagerduty+json;version=2', - '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 - -if __name__ == '__main__': - delete_schedule() diff --git a/python_v2/REST_API_v2/Schedules/get_schedule.py b/python_v2/REST_API_v2/Schedules/get_schedule.py deleted file mode 100755 index 9052f33..0000000 --- a/python_v2/REST_API_v2/Schedules/get_schedule.py +++ /dev/null @@ -1,60 +0,0 @@ -#!/usr/bin/env python -# -# Copyright (c) 2016, 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. - -import requests - -# Update to match your API key -API_KEY = '3c3gRvzx7uGfMYEnWKvF' - -# Update to match your schedule ID -ID = 'PW73MZF' - -# Update to match your chosen parameters -TIME_ZONE = 'UTC' -SINCE = '' -UNTIL = '' - - -def get_schedule(): - url = 'https://api.pagerduty.com/schedules/{id}'.format(id=ID) - headers = { - 'Accept': 'application/vnd.pagerduty+json;version=2', - 'Authorization': 'Token token={token}'.format(token=API_KEY) - } - payload = { - 'time_zone': TIME_ZONE - } - if SINCE != '': - payload['since'] = SINCE - 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() - -if __name__ == '__main__': - get_schedule() diff --git a/python_v2/REST_API_v2/Schedules/list_oncall_users.py b/python_v2/REST_API_v2/Schedules/list_oncall_users.py deleted file mode 100755 index 0053f2e..0000000 --- a/python_v2/REST_API_v2/Schedules/list_oncall_users.py +++ /dev/null @@ -1,59 +0,0 @@ -#!/usr/bin/env python -# -# Copyright (c) 2016, 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. - -import requests - -# Update to match your API key -API_KEY = '3c3gRvzx7uGfMYEnWKvF' - -# Update to match the schedule ID -SCHEDULE_ID = 'PJGJ9RZ' - -# Update to match your chosen parameters -SINCE = '' -UNTIL = '' - - -def list_overrides(): - url = 'https://api.pagerduty.com/schedules/{id}/users'.format( - id=SCHEDULE_ID - ) - headers = { - 'Accept': 'application/vnd.pagerduty+json;version=2', - 'Authorization': 'Token token={token}'.format(token=API_KEY) - } - payload = {} - if SINCE != '': - payload['since'] = SINCE - 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() - -if __name__ == '__main__': - list_overrides() diff --git a/python_v2/REST_API_v2/Schedules/list_overrides.py b/python_v2/REST_API_v2/Schedules/list_overrides.py deleted file mode 100755 index 99d4675..0000000 --- a/python_v2/REST_API_v2/Schedules/list_overrides.py +++ /dev/null @@ -1,62 +0,0 @@ -#!/usr/bin/env python -# -# Copyright (c) 2016, 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. - -import requests - -# Update to match your API key -API_KEY = '3c3gRvzx7uGfMYEnWKvF' - -# Update to match the schedule ID -SCHEDULE_ID = 'PJGJ9RZ' - -# Update to match your chosen parameters -SINCE = '2016-05-01' -UNTIL = '2016-06-01' -EDITABLE = False -OVERFLOW = False - - -def list_overrides(): - url = 'https://api.pagerduty.com/schedules/{id}/overrides'.format( - id=SCHEDULE_ID - ) - headers = { - 'Accept': 'application/vnd.pagerduty+json;version=2', - 'Authorization': 'Token token={token}'.format(token=API_KEY) - } - payload = { - 'since': SINCE, - 'until': UNTIL, - 'editable': EDITABLE, - 'overflow': OVERFLOW - } - r = requests.get(url, headers=headers, params=payload) - print 'Status Code: {code}'.format(code=r.status_code) - print r.json() - -if __name__ == '__main__': - list_overrides() diff --git a/python_v2/REST_API_v2/Schedules/list_schedules.py b/python_v2/REST_API_v2/Schedules/list_schedules.py deleted file mode 100755 index adc475f..0000000 --- a/python_v2/REST_API_v2/Schedules/list_schedules.py +++ /dev/null @@ -1,51 +0,0 @@ -#!/usr/bin/env python -# -# Copyright (c) 2016, 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. - -import requests - -# Update to match your API key -API_KEY = '3c3gRvzx7uGfMYEnWKvF' - -# Update to match your chosen parameters -QUERY = '' - - -def list_schedules(): - url = 'https://api.pagerduty.com/schedules' - headers = { - 'Accept': 'application/vnd.pagerduty+json;version=2', - 'Authorization': 'Token token={token}'.format(token=API_KEY) - } - payload = { - 'query': QUERY - } - r = requests.get(url, headers=headers, params=payload) - print 'Status Code: {code}'.format(code=r.status_code) - print r.json() - -if __name__ == '__main__': - list_schedules() diff --git a/python_v2/REST_API_v2/Schedules/preview_schedule.py b/python_v2/REST_API_v2/Schedules/preview_schedule.py deleted file mode 100755 index b4c3e52..0000000 --- a/python_v2/REST_API_v2/Schedules/preview_schedule.py +++ /dev/null @@ -1,146 +0,0 @@ -#!/usr/bin/env python -# -# Copyright (c) 2016, 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. - -import requests -import json - -# Update to match your API key -API_KEY = '3c3gRvzx7uGfMYEnWKvF' - -# Update to match your chosen parameters -OVERFLOW = False -SINCE = '2016-05-25T00:00:00-07:00' -UNTIL = '2016-06-01T00:00:00-07:00' - -# Update to match your chosen parameters for the overall schedule -TYPE = 'schedule' -SUMMARY = 'Insert your schedule summary here' -NAME = 'Insert your schedule name here' -TIME_ZONE = 'UTC' -ESCALATION_POLICIES = [] -TEAMS = [] - -# Update to match your chosen parameters for each schedule layer -LAYER_ONE_START = '2016-05-23T18:00:00-07:00' -LAYER_ONE_END = '2016-06-23T18:00:00-07:00' -LAYER_ONE_USERS = [ - { - 'user': { - 'id': 'PAZZ8LZ', - 'type': 'user_reference' - } - }, - { - 'user': { - 'id': 'P1PJUIZ', - 'type': 'user_reference' - } - } -] -LAYER_ONE_RESTRICTION_TYPE = 'Daily' -LAYER_ONE_RESTRICTIONS = [] -LAYER_ONE_ROTATION_VIRTUAL_START = '2016-05-23T18:00:00-07:00' -LAYER_ONE_PRIORITY = 1 -LAYER_ONE_ROTATION_TURN_LENGTH_SECONDS = 60 * 60 * 24 # 24 hours -LAYER_ONE_NAME = 'Insert layer one name here' - -LAYER_TWO_START = '2016-05-23T18:00:00-07:00' -LAYER_TWO_END = '2016-06-23T18:00:00-07:00' -LAYER_TWO_USERS = [ - { - 'user': { - 'id': 'POC4AOM', - 'type': 'user_reference' - } - }, - { - 'user': { - 'id': 'PLUWO2C', - 'type': 'user_reference' - } - } -] -LAYER_TWO_RESTRICTION_TYPE = 'Weekly' -LAYER_TWO_RESTRICTIONS = [] -LAYER_TWO_ROTATION_VIRTUAL_START = '2016-05-23T18:00:00-07:00' -LAYER_TWO_PRIORITY = 1 -LAYER_TWO_ROTATION_TURN_LENGTH_SECONDS = 60 * 60 * 24 # 24 hours -LAYER_TWO_NAME = 'Insert layer two name here' - - -def preview_schedule(): - url = 'https://api.pagerduty.com/schedules/preview' - headers = { - 'Accept': 'application/vnd.pagerduty+json;version=2', - 'Authorization': 'Token token={token}'.format(token=API_KEY), - 'Content-type': 'application/json' - } - payload = { - 'since': SINCE, - 'until': UNTIL, - 'overflow': OVERFLOW, - 'schedule': { - 'type': TYPE, - 'summary': SUMMARY, - 'name': NAME, - 'time_zone': TIME_ZONE, - 'escalation_policies': ESCALATION_POLICIES, - 'teams': TEAMS, - 'schedule_layers': [ - { - 'start': LAYER_ONE_START, - 'end': LAYER_ONE_END, - 'users': LAYER_ONE_USERS, - 'restriction_type': LAYER_ONE_RESTRICTION_TYPE, - 'restrictions': LAYER_ONE_RESTRICTIONS, - 'rotation_virtual_start': LAYER_ONE_ROTATION_VIRTUAL_START, - 'priority': LAYER_ONE_PRIORITY, - 'rotation_turn_length_seconds': - LAYER_ONE_ROTATION_TURN_LENGTH_SECONDS, - 'name': LAYER_ONE_NAME - }, - { - 'start': LAYER_TWO_START, - 'end': LAYER_TWO_END, - 'users': LAYER_TWO_USERS, - 'restriction_type': LAYER_TWO_RESTRICTION_TYPE, - 'restrictions': LAYER_TWO_RESTRICTIONS, - 'rotation_virtual_start': LAYER_TWO_ROTATION_VIRTUAL_START, - 'priority': LAYER_TWO_PRIORITY, - 'rotation_turn_length_seconds': - LAYER_TWO_ROTATION_TURN_LENGTH_SECONDS, - 'name': LAYER_TWO_NAME - } - ] - } - } - r = requests.post(url, headers=headers, data=json.dumps(payload)) - print 'Status Code: {code}'.format(code=r.status_code) - print r.json() - -if __name__ == '__main__': - preview_schedule() diff --git a/python_v2/REST_API_v2/Schedules/update_schedule.py b/python_v2/REST_API_v2/Schedules/update_schedule.py deleted file mode 100755 index 735cdaf..0000000 --- a/python_v2/REST_API_v2/Schedules/update_schedule.py +++ /dev/null @@ -1,145 +0,0 @@ -#!/usr/bin/env python -# -# Copyright (c) 2016, 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. - -import requests -import json - -# Update to match your API key -API_KEY = '3c3gRvzx7uGfMYEnWKvF' - -# Update to match ID of resource you want to update -ID = 'PM6GOQG' - -# Update to match your chosen parameters -OVERFLOW = False - -# Update to match your chosen parameters for the overall schedule -TYPE = 'schedule' -SUMMARY = 'Insert your schedule summary here' -NAME = 'Insert your schedule name here' -TIME_ZONE = 'UTC' -ESCALATION_POLICIES = [] -TEAMS = [] - -# Update to match your chosen parameters for each schedule layer -LAYER_ONE_START = '2016-05-23T18:00:00-07:00' -LAYER_ONE_END = '2016-06-23T18:00:00-07:00' -LAYER_ONE_USERS = [ - { - 'user': { - 'id': 'PIZFCCH', - 'type': 'user_reference' - } - }, - { - 'user': { - 'id': 'P1PJUIZ', - 'type': 'user_reference' - } - } -] -LAYER_ONE_RESTRICTION_TYPE = 'Daily' -LAYER_ONE_RESTRICTIONS = [] -LAYER_ONE_ROTATION_VIRTUAL_START = '2016-05-23T18:00:00-07:00' -LAYER_ONE_PRIORITY = 1 -LAYER_ONE_ROTATION_TURN_LENGTH_SECONDS = 60 * 60 * 24 # 24 hours -LAYER_ONE_NAME = 'Insert layer one name here' - -LAYER_TWO_START = '2016-05-23T18:00:00-07:00' -LAYER_TWO_END = '2016-06-23T18:00:00-07:00' -LAYER_TWO_USERS = [ - { - 'user': { - 'id': 'POC4AOM', - 'type': 'user_reference' - } - }, - { - 'user': { - 'id': 'PLUWO2C', - 'type': 'user_reference' - } - } -] -LAYER_TWO_RESTRICTION_TYPE = 'Weekly' -LAYER_TWO_RESTRICTIONS = [] -LAYER_TWO_ROTATION_VIRTUAL_START = '2016-05-23T18:00:00-07:00' -LAYER_TWO_PRIORITY = 1 -LAYER_TWO_ROTATION_TURN_LENGTH_SECONDS = 60 * 60 * 24 # 24 hours -LAYER_TWO_NAME = 'Insert layer two name here' - - -def update_schedule(): - url = 'https://api.pagerduty.com/schedules/{id}'.format(id=ID) - headers = { - 'Accept': 'application/vnd.pagerduty+json;version=2', - 'Authorization': 'Token token={token}'.format(token=API_KEY), - 'Content-type': 'application/json' - } - payload = { - 'overflow': OVERFLOW, - 'schedule': { - 'type': TYPE, - 'summary': SUMMARY, - 'name': NAME, - 'time_zone': TIME_ZONE, - 'escalation_policies': ESCALATION_POLICIES, - 'teams': TEAMS, - 'schedule_layers': [ - { - 'start': LAYER_ONE_START, - 'end': LAYER_ONE_END, - 'users': LAYER_ONE_USERS, - 'restriction_type': LAYER_ONE_RESTRICTION_TYPE, - 'restrictions': LAYER_ONE_RESTRICTIONS, - 'rotation_virtual_start': LAYER_ONE_ROTATION_VIRTUAL_START, - 'priority': LAYER_ONE_PRIORITY, - 'rotation_turn_length_seconds': - LAYER_ONE_ROTATION_TURN_LENGTH_SECONDS, - 'name': LAYER_ONE_NAME - }, - { - 'start': LAYER_TWO_START, - 'end': LAYER_TWO_END, - 'users': LAYER_TWO_USERS, - 'restriction_type': LAYER_TWO_RESTRICTION_TYPE, - 'restrictions': LAYER_TWO_RESTRICTIONS, - 'rotation_virtual_start': LAYER_TWO_ROTATION_VIRTUAL_START, - 'priority': LAYER_TWO_PRIORITY, - 'rotation_turn_length_seconds': - LAYER_TWO_ROTATION_TURN_LENGTH_SECONDS, - 'name': LAYER_TWO_NAME - } - ] - } - } - r = requests.put(url, headers=headers, data=json.dumps(payload)) - print 'Status Code: {code}'.format(code=r.status_code) - print r.json() - -if __name__ == '__main__': - update_schedule() diff --git a/python_v2/REST_API_v2/Services/create_integration.py b/python_v2/REST_API_v2/Services/create_integration.py deleted file mode 100755 index c1ee5fd..0000000 --- a/python_v2/REST_API_v2/Services/create_integration.py +++ /dev/null @@ -1,70 +0,0 @@ -#!/usr/bin/env python -# -# Copyright (c) 2016, 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. - -import requests -import json - -# Update to match your API key -API_KEY = '3c3gRvzx7uGfMYEnWKvF' - -# Update to match the service ID -SERVICE_ID = 'PK2X17C' - -# Update to match your chosen parameters -TYPE = 'generic_email_inbound_integration' -SUMMARY = 'Enter your integration summary here' -NAME = 'Enter your integration name here' -VENDOR = None -# Only required if creating email integration -INTEGRATION_EMAIL = 'insert_email@ENTER_YOUR_PD_SUBDOMAIN.pagerduty.com' - - -def create_integration(): - url = 'https://api.pagerduty.com/services/{id}/integrations'.format( - id=SERVICE_ID - ) - headers = { - 'Accept': 'application/vnd.pagerduty+json;version=2', - 'Authorization': 'Token token={token}'.format(token=API_KEY), - 'Content-type': 'application/json' - } - payload = { - 'integration': { - 'type': TYPE, - 'summary': SUMMARY, - 'name': NAME, - 'vendor': VENDOR - } - } - 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() - -if __name__ == '__main__': - create_integration() diff --git a/python_v2/REST_API_v2/Services/create_service.py b/python_v2/REST_API_v2/Services/create_service.py deleted file mode 100755 index a2d695a..0000000 --- a/python_v2/REST_API_v2/Services/create_service.py +++ /dev/null @@ -1,103 +0,0 @@ -#!/usr/bin/env python -# -# Copyright (c) 2016, 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. - -import requests -import json - -# Update to match your API key -API_KEY = '3c3gRvzx7uGfMYEnWKvF' - -# Update to match your chosen parameters -NAME = 'Insert service name here' -DESCRIPTION = 'Insert service description here' -ESCALATION_POLICY_ID = 'PIX2DN3' -TYPE = 'service' -AUTO_RESOLVE_TIMEOUT = 14400 # 4 hours -ACKNOWLEDGEMENT_TIMEOUT = 1800 # 30 minutes -TEAMS = [] -INCIDENT_URGENCY = 'high' # used during support hours or as default urgency -OUTSIDE_SUPPORT_HOURS_URGENCY = 'low' -SCHEDULED_ACTIONS = [] -SUPPORT_HOURS = { - 'type': 'fixed_time_per_day', - 'time_zone': 'UTC', - 'days_of_week': [1, 2, 3, 4, 5], - 'start_time': '09:00:00', - 'end_time': '17:00:00' -} -INTEGRATIONS = [] -ADDONS = [] - - -def create_service(): - url = 'https://api.pagerduty.com/services' - headers = { - 'Accept': 'application/vnd.pagerduty+json;version=2', - 'Authorization': 'Token token={token}'.format(token=API_KEY), - 'Content-type': 'application/json' - } - payload = { - 'service': { - 'name': NAME, - 'description': DESCRIPTION, - 'escalation_policy': { - 'id': ESCALATION_POLICY_ID, - 'type': 'escalation_policy' - }, - 'type': TYPE, - 'auto_resolve_timeout': AUTO_RESOLVE_TIMEOUT, - 'acknowledgement_timeout': ACKNOWLEDGEMENT_TIMEOUT, - 'teams': TEAMS, - 'scheduled_actions': SCHEDULED_ACTIONS, - 'integrations': INTEGRATIONS, - 'addons': ADDONS, - 'support_hours': SUPPORT_HOURS - } - } - if not SUPPORT_HOURS: - payload['service']['incident_urgency_rule'] = { - 'type': 'constant', - 'urgency': INCIDENT_URGENCY - } - else: - payload['service']['incident_urgency_rule'] = { - 'type': 'use_support_hours', - 'during_support_hours': { - 'type': 'constant', - 'urgency': INCIDENT_URGENCY - }, - 'outside_support_hours': { - 'type': 'constant', - 'urgency': OUTSIDE_SUPPORT_HOURS_URGENCY - } - } - r = requests.post(url, headers=headers, data=json.dumps(payload)) - print 'Status Code: {code}'.format(code=r.status_code) - print r.json() - -if __name__ == '__main__': - create_service() diff --git a/python_v2/REST_API_v2/Services/delete_service.py b/python_v2/REST_API_v2/Services/delete_service.py deleted file mode 100755 index bd0fe2a..0000000 --- a/python_v2/REST_API_v2/Services/delete_service.py +++ /dev/null @@ -1,48 +0,0 @@ -#!/usr/bin/env python -# -# Copyright (c) 2016, 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. - -import requests - -# Update to match your API key -API_KEY = '3c3gRvzx7uGfMYEnWKvF' - -# Update to match ID of resource you want to delete -ID = 'PTRCGYM' - - -def delete_service(): - url = 'https://api.pagerduty.com/services/{id}'.format(id=ID) - headers = { - 'Accept': 'application/vnd.pagerduty+json;version=2', - '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 - -if __name__ == '__main__': - delete_service() diff --git a/python_v2/REST_API_v2/Services/get_integration.py b/python_v2/REST_API_v2/Services/get_integration.py deleted file mode 100755 index 1f09b72..0000000 --- a/python_v2/REST_API_v2/Services/get_integration.py +++ /dev/null @@ -1,58 +0,0 @@ -#!/usr/bin/env python -# -# Copyright (c) 2016, 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. - -import requests - -# Update to match your API key -API_KEY = '3c3gRvzx7uGfMYEnWKvF' - -# Update to match your service and integration IDs -SERVICE_ID = 'PAU38PJ' -INTEGRATION_ID = 'PTT2FMS' - -# Update to match your chosen parameters -INCLUDE = [] - - -def get_integration(): - url = 'https://api.pagerduty.com/services/{sid}/integrations/{iid}'.format( - sid=SERVICE_ID, - iid=INTEGRATION_ID - ) - headers = { - 'Accept': 'application/vnd.pagerduty+json;version=2', - 'Authorization': 'Token token={token}'.format(token=API_KEY) - } - payload = { - 'include[]': INCLUDE - } - r = requests.get(url, headers=headers, params=payload) - print 'Status Code: {code}'.format(code=r.status_code) - print r.json() - -if __name__ == '__main__': - get_integration() diff --git a/python_v2/REST_API_v2/Services/get_service.py b/python_v2/REST_API_v2/Services/get_service.py deleted file mode 100755 index 41ae52e..0000000 --- a/python_v2/REST_API_v2/Services/get_service.py +++ /dev/null @@ -1,54 +0,0 @@ -#!/usr/bin/env python -# -# Copyright (c) 2016, 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. - -import requests - -# Update to match your API key -API_KEY = '3c3gRvzx7uGfMYEnWKvF' - -# Update to match your service ID -ID = 'PKWA90D' - -# Update to match your chosen parameters -INCLUDE = [] - - -def get_service(): - url = 'https://api.pagerduty.com/services/{id}'.format(id=ID) - headers = { - 'Accept': 'application/vnd.pagerduty+json;version=2', - 'Authorization': 'Token token={token}'.format(token=API_KEY) - } - payload = { - 'include[]': INCLUDE - } - r = requests.get(url, headers=headers, params=payload) - print 'Status Code: {code}'.format(code=r.status_code) - print r.json() - -if __name__ == '__main__': - get_service() diff --git a/python_v2/REST_API_v2/Services/list_services.py b/python_v2/REST_API_v2/Services/list_services.py deleted file mode 100755 index 34c5917..0000000 --- a/python_v2/REST_API_v2/Services/list_services.py +++ /dev/null @@ -1,59 +0,0 @@ -#!/usr/bin/env python -# -# Copyright (c) 2016, 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. - -import requests - -# Update to match your API key -API_KEY = '3c3gRvzx7uGfMYEnWKvF' - -# Update to match your chosen parameters -TEAM_IDS = [] -TIME_ZONE = 'UTC' -SORT_BY = 'name' -QUERY = '' -INCLUDE = [] - - -def list_services(): - url = 'https://api.pagerduty.com/services' - 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 - } - r = requests.get(url, headers=headers, params=payload) - print 'Status Code: {code}'.format(code=r.status_code) - print r.json() - -if __name__ == '__main__': - list_services() diff --git a/python_v2/REST_API_v2/Services/update_integration.py b/python_v2/REST_API_v2/Services/update_integration.py deleted file mode 100755 index b77720a..0000000 --- a/python_v2/REST_API_v2/Services/update_integration.py +++ /dev/null @@ -1,64 +0,0 @@ -#!/usr/bin/env python -# -# Copyright (c) 2016, 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. - -import requests -import json - -# Update to match your API key -API_KEY = '3c3gRvzx7uGfMYEnWKvF' - -# Update to match ID of resource you want to update -SERVICE_ID = 'PAU38PJ' -INTEGRATION_ID = 'PTT2FMS' - -# Update to match your chosen parameters -NAME = 'Insert your integration name here' -SUMMARY = 'Insert your integration summary here' - - -def update_integration(): - url = 'https://api.pagerduty.com/services/{sid}/integrations/{iid}'.format( - sid=SERVICE_ID, - iid=INTEGRATION_ID - ) - headers = { - 'Accept': 'application/vnd.pagerduty+json;version=2', - 'Authorization': 'Token token={token}'.format(token=API_KEY), - 'Content-type': 'application/json' - } - payload = { - 'integration': { - 'name': NAME, - 'summary': SUMMARY - } - } - r = requests.put(url, headers=headers, data=json.dumps(payload)) - print 'Status Code: {code}'.format(code=r.status_code) - print r.json() - -if __name__ == '__main__': - update_integration() diff --git a/python_v2/REST_API_v2/Services/update_service.py b/python_v2/REST_API_v2/Services/update_service.py deleted file mode 100755 index d428eef..0000000 --- a/python_v2/REST_API_v2/Services/update_service.py +++ /dev/null @@ -1,68 +0,0 @@ -#!/usr/bin/env python -# -# Copyright (c) 2016, 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. - -import requests -import json - -# Update to match your API key -API_KEY = '3c3gRvzx7uGfMYEnWKvF' - -# Update to match ID of resource you want to update -ID = 'P8RK2P8' - -# Update to match your chosen parameters -NAME = 'Insert your service name here' -DESCRIPTION = 'Insert your service description here' -ESCALATION_POLICY_ID = 'PIX2DN3' -ACKNOWLEDGEMENT_TIMEOUT = 60 * 30 # 30 minutes -AUTO_RESOLVE_TIMEOUT = 60 * 60 * 4 # 4 hours -SEVERITY_FILTER = '' - - -def update_service(): - url = 'https://api.pagerduty.com/services/{id}'.format(id=ID) - headers = { - 'Accept': 'application/vnd.pagerduty+json;version=2', - 'Authorization': 'Token token={token}'.format(token=API_KEY), - 'Content-type': 'application/json' - } - payload = { - 'service': { - 'name': NAME, - 'description': DESCRIPTION, - 'escalation_policy_id': ESCALATION_POLICY_ID, - '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() - -if __name__ == '__main__': - update_service() diff --git a/python_v2/REST_API_v2/Teams/add_escalation_policy_to_team.py b/python_v2/REST_API_v2/Teams/add_escalation_policy_to_team.py deleted file mode 100755 index 963a011..0000000 --- a/python_v2/REST_API_v2/Teams/add_escalation_policy_to_team.py +++ /dev/null @@ -1,51 +0,0 @@ -#!/usr/bin/env python -# -# Copyright (c) 2016, 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. - -import requests - -# Update to match your API key -API_KEY = '3c3gRvzx7uGfMYEnWKvF' - -# Update to match your IDs -TEAM_ID = 'PYYWGIO' -ESCALATION_POLICY_ID = 'PZPCKNC' - - -def add_escalation_policy_to_team(): - url = ('https://api.pagerduty.com/teams/{tid}/escalation_policies/{eid}' - .format(tid=TEAM_ID, eid=ESCALATION_POLICY_ID)) - headers = { - 'Accept': 'application/vnd.pagerduty+json;version=2', - 'Authorization': 'Token token={token}'.format(token=API_KEY), - 'Content-type': 'application/json' - } - r = requests.put(url, headers=headers) - print 'Status Code: {code}'.format(code=r.status_code) - print r.text - -if __name__ == '__main__': - add_escalation_policy_to_team() diff --git a/python_v2/REST_API_v2/Teams/add_user_to_team.py b/python_v2/REST_API_v2/Teams/add_user_to_team.py deleted file mode 100755 index 6fc2578..0000000 --- a/python_v2/REST_API_v2/Teams/add_user_to_team.py +++ /dev/null @@ -1,53 +0,0 @@ -#!/usr/bin/env python -# -# Copyright (c) 2016, 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. - -import requests - -# Update to match your API key -API_KEY = '' - -# Update to match your IDs -TEAM_ID = '' -USER_ID = '' - - -def add_user_to_team(): - url = 'https://api.pagerduty.com/teams/{tid}/users/{uid}'.format( - tid=TEAM_ID, - uid=USER_ID - ) - headers = { - 'Accept': 'application/vnd.pagerduty+json;version=2', - 'Authorization': 'Token token={token}'.format(token=API_KEY), - 'Content-type': 'application/json' - } - r = requests.put(url, headers=headers) - print 'Status Code: {code}'.format(code=r.status_code) - print r.text - -if __name__ == '__main__': - add_user_to_team() diff --git a/python_v2/REST_API_v2/Teams/create_team.py b/python_v2/REST_API_v2/Teams/create_team.py deleted file mode 100755 index 417bf09..0000000 --- a/python_v2/REST_API_v2/Teams/create_team.py +++ /dev/null @@ -1,59 +0,0 @@ -#!/usr/bin/env python -# -# Copyright (c) 2016, 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. - -import requests -import json - -# Update to match your API key -API_KEY = '3c3gRvzx7uGfMYEnWKvF' - -# Update to match your chosen parameters -NAME = 'Insert team name here' -DESCRIPTION = 'Insert team description here' - - -def create_team(): - url = 'https://api.pagerduty.com/teams' - headers = { - 'Accept': 'application/vnd.pagerduty+json;version=2', - 'Authorization': 'Token token={token}'.format(token=API_KEY), - 'Content-type': 'application/json' - } - payload = { - 'team': { - 'type': 'team', - 'name': NAME, - 'description': DESCRIPTION, - 'summary': DESCRIPTION - } - } - r = requests.post(url, headers=headers, data=json.dumps(payload)) - print 'Status Code: {code}'.format(code=r.status_code) - print r.json() - -if __name__ == '__main__': - create_team() diff --git a/python_v2/REST_API_v2/Teams/delete_team.py b/python_v2/REST_API_v2/Teams/delete_team.py deleted file mode 100755 index 8bf05a6..0000000 --- a/python_v2/REST_API_v2/Teams/delete_team.py +++ /dev/null @@ -1,48 +0,0 @@ -#!/usr/bin/env python -# -# Copyright (c) 2016, 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. - -import requests - -# Update to match your API key -API_KEY = '3c3gRvzx7uGfMYEnWKvF' - -# Update to match ID of resource you want to delete -ID = 'P53LIBV' - - -def delete_team(): - url = 'https://api.pagerduty.com/teams/{id}'.format(id=ID) - headers = { - 'Accept': 'application/vnd.pagerduty+json;version=2', - '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 - -if __name__ == '__main__': - delete_team() diff --git a/python_v2/REST_API_v2/Teams/get_team.py b/python_v2/REST_API_v2/Teams/get_team.py deleted file mode 100755 index 825b483..0000000 --- a/python_v2/REST_API_v2/Teams/get_team.py +++ /dev/null @@ -1,48 +0,0 @@ -#!/usr/bin/env python -# -# Copyright (c) 2016, 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. - -import requests - -# Update to match your API key -API_KEY = '3c3gRvzx7uGfMYEnWKvF' - -# Update to match your team ID -ID = 'PD28XX6' - - -def get_team(): - url = 'https://api.pagerduty.com/teams/{id}'.format(id=ID) - headers = { - 'Accept': 'application/vnd.pagerduty+json;version=2', - '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() - -if __name__ == '__main__': - get_team() diff --git a/python_v2/REST_API_v2/Teams/list_teams.py b/python_v2/REST_API_v2/Teams/list_teams.py deleted file mode 100755 index bb0666e..0000000 --- a/python_v2/REST_API_v2/Teams/list_teams.py +++ /dev/null @@ -1,51 +0,0 @@ -#!/usr/bin/env python -# -# Copyright (c) 2016, 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. - -import requests - -# Update to match your API key -API_KEY = '3c3gRvzx7uGfMYEnWKvF' - -# Update to match your chosen parameters -QUERY = '' - - -def list_teams(): - url = 'https://api.pagerduty.com/teams' - headers = { - 'Accept': 'application/vnd.pagerduty+json;version=2', - 'Authorization': 'Token token={token}'.format(token=API_KEY) - } - payload = { - 'query': QUERY - } - r = requests.get(url, headers=headers, params=payload) - print 'Status Code: {code}'.format(code=r.status_code) - print r.json() - -if __name__ == '__main__': - list_teams() diff --git a/python_v2/REST_API_v2/Teams/remove_escalation_policy_from_team.py b/python_v2/REST_API_v2/Teams/remove_escalation_policy_from_team.py deleted file mode 100755 index 9c47d67..0000000 --- a/python_v2/REST_API_v2/Teams/remove_escalation_policy_from_team.py +++ /dev/null @@ -1,50 +0,0 @@ -#!/usr/bin/env python -# -# Copyright (c) 2016, 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. - -import requests - -# Update to match your API key -API_KEY = '3c3gRvzx7uGfMYEnWKvF' - -# Update to match your IDs -TEAM_ID = 'PYYWGIO' -ESCALATION_POLICY_ID = 'PZPCKNC' - - -def remove_escalation_policy_from_team(): - url = ('https://api.pagerduty.com/teams/{tid}/escalation_policies/{eid}' - .format(tid=TEAM_ID, eid=ESCALATION_POLICY_ID)) - headers = { - 'Accept': 'application/vnd.pagerduty+json;version=2', - '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 - -if __name__ == '__main__': - remove_escalation_policy_from_team() diff --git a/python_v2/REST_API_v2/Teams/remove_user_from_team.py b/python_v2/REST_API_v2/Teams/remove_user_from_team.py deleted file mode 100755 index 11e4e2e..0000000 --- a/python_v2/REST_API_v2/Teams/remove_user_from_team.py +++ /dev/null @@ -1,52 +0,0 @@ -#!/usr/bin/env python -# -# Copyright (c) 2016, 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. - -import requests - -# Update to match your API key -API_KEY = '3c3gRvzx7uGfMYEnWKvF' - -# Update to match your IDs -TEAM_ID = 'PYYWGIO' -USER_ID = 'P0H7Y7J' - - -def remove_user_from_team(): - url = 'https://api.pagerduty.com/teams/{tid}/users/{uid}'.format( - tid=TEAM_ID, - uid=USER_ID - ) - headers = { - 'Accept': 'application/vnd.pagerduty+json;version=2', - '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 - -if __name__ == '__main__': - remove_user_from_team() diff --git a/python_v2/REST_API_v2/Teams/update_team.py b/python_v2/REST_API_v2/Teams/update_team.py deleted file mode 100755 index b84e10b..0000000 --- a/python_v2/REST_API_v2/Teams/update_team.py +++ /dev/null @@ -1,60 +0,0 @@ -#!/usr/bin/env python -# -# Copyright (c) 2016, 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. - -import requests -import json - -# Update to match your API key -API_KEY = '3c3gRvzx7uGfMYEnWKvF' - -# Update to match ID of resource you want to update -ID = 'PYYWGIO' - -# Update to match your chosen parameters -NAME = 'Insert your team name here' -DESCRIPTION = 'Insert your team description here' - - -def update_team(): - url = 'https://api.pagerduty.com/teams/{id}'.format(id=ID) - headers = { - 'Accept': 'application/vnd.pagerduty+json;version=2', - 'Authorization': 'Token token={token}'.format(token=API_KEY), - 'Content-type': 'application/json' - } - payload = { - 'team': { - 'name': NAME, - 'description': DESCRIPTION - } - } - r = requests.put(url, headers=headers, data=json.dumps(payload)) - print 'Status Code: {code}'.format(code=r.status_code) - print r.json() - -if __name__ == '__main__': - update_team() diff --git a/python_v2/REST_API_v2/Users/create_user.py b/python_v2/REST_API_v2/Users/create_user.py deleted file mode 100755 index 9514493..0000000 --- a/python_v2/REST_API_v2/Users/create_user.py +++ /dev/null @@ -1,64 +0,0 @@ -#!/usr/bin/env python -# -# Copyright (c) 2016, 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. - -import requests -import json - -# Update to match your API key -API_KEY = '3c3gRvzx7uGfMYEnWKvF' - -# Update to match your PagerDuty email address -PD_EMAIL = 'lucas@pagerduty.com' - -# 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 - - -def create_user(): - url = 'https://api.pagerduty.com/users' - headers = { - 'Accept': 'application/vnd.pagerduty+json;version=2', - 'Authorization': 'Token token={token}'.format(token=API_KEY), - 'Content-type': 'application/json', - 'From': PD_EMAIL - } - payload = { - 'user': { - 'type': 'user', - 'name': NAME, - 'email': EMAIL, - 'role': ROLE - } - } - r = requests.post(url, headers=headers, data=json.dumps(payload)) - print 'Status Code: {code}'.format(code=r.status_code) - print r.json() - -if __name__ == '__main__': - create_user() diff --git a/python_v2/REST_API_v2/Users/create_user_contact_method.py b/python_v2/REST_API_v2/Users/create_user_contact_method.py deleted file mode 100755 index 9f5acf2..0000000 --- a/python_v2/REST_API_v2/Users/create_user_contact_method.py +++ /dev/null @@ -1,62 +0,0 @@ -#!/usr/bin/env python -# -# Copyright (c) 2016, 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. - -import requests -import json - -# Update to match your API key -API_KEY = '3c3gRvzx7uGfMYEnWKvF' - -# Update to match ID of user you want to update -ID = 'P0H7Y7J' - -# Update to match your chosen parameters -TYPE = 'email_contact_method' # Can be one of email_contact_method, sms_contact_method, phone_contact_method, or push_notification_contact_method # NOQA -ADDRESS = 'insert_email@here.com' -LABEL = 'Work' - - -def create_user_contact_method(): - url = 'https://api.pagerduty.com/users/{id}/contact_methods'.format(id=ID) - headers = { - 'Accept': 'application/vnd.pagerduty+json;version=2', - 'Authorization': 'Token token={token}'.format(token=API_KEY), - 'Content-type': 'application/json' - } - payload = { - 'contact_method': { - 'type': TYPE, - 'address': ADDRESS, - 'label': LABEL - } - } - r = requests.post(url, headers=headers, data=json.dumps(payload)) - print 'Status Code: {code}'.format(code=r.status_code) - print r.json() - -if __name__ == '__main__': - create_user_contact_method() diff --git a/python_v2/REST_API_v2/Users/create_user_notification_rule.py b/python_v2/REST_API_v2/Users/create_user_notification_rule.py deleted file mode 100755 index 29a764c..0000000 --- a/python_v2/REST_API_v2/Users/create_user_notification_rule.py +++ /dev/null @@ -1,69 +0,0 @@ -#!/usr/bin/env python -# -# Copyright (c) 2016, 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. - -import requests -import json - -# Update to match your API key -API_KEY = '3c3gRvzx7uGfMYEnWKvF' - -# Update to match ID of user you want to update -ID = 'P0TEZR0' - -# Update to match your chosen parameters -START_DELAY_IN_MINUTES = '5' -URGENCY = 'high' -CONTACT_METHOD_ID = 'P54SUEP' -CONTACT_METHOD_TYPE = 'email_contact_method' - - -def create_user_notification_rule(): - url = 'https://api.pagerduty.com/users/{id}/notification_rules'.format( - id=ID - ) - headers = { - 'Accept': 'application/vnd.pagerduty+json;version=2', - 'Authorization': 'Token token={token}'.format(token=API_KEY), - 'Content-type': 'application/json' - } - payload = { - 'notification_rule': { - 'start_delay_in_minutes': START_DELAY_IN_MINUTES, - 'contact_method': { - 'id': CONTACT_METHOD_ID, - 'type': CONTACT_METHOD_TYPE - }, - 'type': 'assignment_notification_rule', - 'urgency': URGENCY - } - } - r = requests.post(url, headers=headers, data=json.dumps(payload)) - print 'Status Code: {code}'.format(code=r.status_code) - print r.json() - -if __name__ == '__main__': - create_user_notification_rule() diff --git a/python_v2/REST_API_v2/Users/delete_user.py b/python_v2/REST_API_v2/Users/delete_user.py deleted file mode 100755 index dadb099..0000000 --- a/python_v2/REST_API_v2/Users/delete_user.py +++ /dev/null @@ -1,48 +0,0 @@ -#!/usr/bin/env python -# -# Copyright (c) 2016, 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. - -import requests - -# Update to match your API key -API_KEY = '3c3gRvzx7uGfMYEnWKvF' - -# Update to match ID of resource you want to delete -ID = 'PK1VFD9' - - -def delete_user(): - url = 'https://api.pagerduty.com/users/{id}'.format(id=ID) - headers = { - 'Accept': 'application/vnd.pagerduty+json;version=2', - '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 - -if __name__ == '__main__': - delete_user() diff --git a/python_v2/REST_API_v2/Users/delete_user_contact_method.py b/python_v2/REST_API_v2/Users/delete_user_contact_method.py deleted file mode 100755 index d78d4be..0000000 --- a/python_v2/REST_API_v2/Users/delete_user_contact_method.py +++ /dev/null @@ -1,52 +0,0 @@ -#!/usr/bin/env python -# -# Copyright (c) 2016, 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. - -import requests - -# Update to match your API key -API_KEY = '3c3gRvzx7uGfMYEnWKvF' - -# Update to match your IDs -USER_ID = 'P0TEZR0' -CONTACT_METHOD_ID = 'PRP8EDZ' - - -def delete_user_contact_method(): - url = 'https://api.pagerduty.com/users/{uid}/contact_methods/{cid}'.format( - uid=USER_ID, - cid=CONTACT_METHOD_ID - ) - headers = { - 'Accept': 'application/vnd.pagerduty+json;version=2', - '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 - -if __name__ == '__main__': - delete_user_contact_method() diff --git a/python_v2/REST_API_v2/Users/delete_user_notification_rule.py b/python_v2/REST_API_v2/Users/delete_user_notification_rule.py deleted file mode 100755 index 93c5383..0000000 --- a/python_v2/REST_API_v2/Users/delete_user_notification_rule.py +++ /dev/null @@ -1,50 +0,0 @@ -#!/usr/bin/env python -# -# Copyright (c) 2016, 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. - -import requests - -# Update to match your API key -API_KEY = '3c3gRvzx7uGfMYEnWKvF' - -# Update to match your IDs -USER_ID = 'P0TEZR0' -NOTIFICATION_RULE_ID = 'PM0NWL3' - - -def delete_user_notification_rule(): - url = ('https://api.pagerduty.com/users/{uid}/notification_rules/{nid}' - .format(uid=USER_ID, nid=NOTIFICATION_RULE_ID)) - headers = { - 'Accept': 'application/vnd.pagerduty+json;version=2', - '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 - -if __name__ == '__main__': - delete_user_notification_rule() diff --git a/python_v2/REST_API_v2/Users/get_user.py b/python_v2/REST_API_v2/Users/get_user.py deleted file mode 100755 index 860fe49..0000000 --- a/python_v2/REST_API_v2/Users/get_user.py +++ /dev/null @@ -1,54 +0,0 @@ -#!/usr/bin/env python -# -# Copyright (c) 2016, 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. - -import requests - -# Update to match your API key -API_KEY = '3c3gRvzx7uGfMYEnWKvF' - -# Update to match your user ID -ID = 'P0TEZR0' - -# Update to match your chosen parameters -INCLUDE = [] - - -def get_user(): - url = 'https://api.pagerduty.com/users/{id}'.format(id=ID) - headers = { - 'Accept': 'application/vnd.pagerduty+json;version=2', - 'Authorization': 'Token token={token}'.format(token=API_KEY) - } - payload = { - 'include[]': INCLUDE - } - r = requests.get(url, headers=headers, params=payload) - print 'Status Code: {code}'.format(code=r.status_code) - print r.json() - -if __name__ == '__main__': - get_user() diff --git a/python_v2/REST_API_v2/Users/get_user_contact_method.py b/python_v2/REST_API_v2/Users/get_user_contact_method.py deleted file mode 100755 index 5ef95fe..0000000 --- a/python_v2/REST_API_v2/Users/get_user_contact_method.py +++ /dev/null @@ -1,52 +0,0 @@ -#!/usr/bin/env python -# -# Copyright (c) 2016, 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. - -import requests - -# Update to match your API key -API_KEY = '3c3gRvzx7uGfMYEnWKvF' - -# Update to match your IDs -USER_ID = 'P0TEZR0' -CONTACT_METHOD_ID = 'P54SUEP' - - -def get_user_contact_method(): - url = 'https://api.pagerduty.com/users/{uid}/contact_methods/{cid}'.format( - uid=USER_ID, - cid=CONTACT_METHOD_ID - ) - headers = { - 'Accept': 'application/vnd.pagerduty+json;version=2', - '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() - -if __name__ == '__main__': - get_user_contact_method() diff --git a/python_v2/REST_API_v2/Users/get_user_notification_rule.py b/python_v2/REST_API_v2/Users/get_user_notification_rule.py deleted file mode 100755 index ffac7f2..0000000 --- a/python_v2/REST_API_v2/Users/get_user_notification_rule.py +++ /dev/null @@ -1,56 +0,0 @@ -#!/usr/bin/env python -# -# Copyright (c) 2016, 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. - -import requests - -# Update to match your API key -API_KEY = '3c3gRvzx7uGfMYEnWKvF' - -# Update to match your IDs -USER_ID = 'P0TEZR0' -NOTIFICATION_RULE_ID = 'PCR2WKT' - -# Update to match your chosen parameters -INCLUDE = [] - - -def get_user_notification_rule(): - url = ('https://api.pagerduty.com/users/{uid}/notification_rules/{nid}' - .format(uid=USER_ID, nid=NOTIFICATION_RULE_ID)) - headers = { - 'Accept': 'application/vnd.pagerduty+json;version=2', - 'Authorization': 'Token token={token}'.format(token=API_KEY) - } - payload = { - 'include[]': INCLUDE - } - r = requests.get(url, headers=headers, params=payload) - print 'Status Code: {code}'.format(code=r.status_code) - print r.json() - -if __name__ == '__main__': - get_user_notification_rule() diff --git a/python_v2/REST_API_v2/Users/list_user_contact_methods.py b/python_v2/REST_API_v2/Users/list_user_contact_methods.py deleted file mode 100755 index 6e5190b..0000000 --- a/python_v2/REST_API_v2/Users/list_user_contact_methods.py +++ /dev/null @@ -1,48 +0,0 @@ -#!/usr/bin/env python -# -# Copyright (c) 2016, 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. - -import requests - -# Update to match your API key -API_KEY = '3c3gRvzx7uGfMYEnWKvF' - -# Update to match your user ID -ID = 'P0TEZR0' - - -def list_user_contact_methods(): - url = 'https://api.pagerduty.com/users/{id}/contact_methods'.format(id=ID) - headers = { - 'Accept': 'application/vnd.pagerduty+json;version=2', - '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() - -if __name__ == '__main__': - list_user_contact_methods() diff --git a/python_v2/REST_API_v2/Users/list_user_notification_rules.py b/python_v2/REST_API_v2/Users/list_user_notification_rules.py deleted file mode 100755 index 72dd2e7..0000000 --- a/python_v2/REST_API_v2/Users/list_user_notification_rules.py +++ /dev/null @@ -1,56 +0,0 @@ -#!/usr/bin/env python -# -# Copyright (c) 2016, 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. - -import requests - -# Update to match your API key -API_KEY = '3c3gRvzx7uGfMYEnWKvF' - -# Update to match your user ID -ID = 'P0TEZR0' - -# Update to match your chosen parameters -INCLUDE = [] - - -def list_user_notification_rules(): - url = 'https://api.pagerduty.com/users/{id}/notification_rules'.format( - id=ID - ) - headers = { - 'Accept': 'application/vnd.pagerduty+json;version=2', - 'Authorization': 'Token token={token}'.format(token=API_KEY) - } - payload = { - 'include[]': INCLUDE - } - r = requests.get(url, headers=headers, params=payload) - print 'Status Code: {code}'.format(code=r.status_code) - print r.json() - -if __name__ == '__main__': - list_user_notification_rules() diff --git a/python_v2/REST_API_v2/Users/list_users.py b/python_v2/REST_API_v2/Users/list_users.py deleted file mode 100755 index 7d53d52..0000000 --- a/python_v2/REST_API_v2/Users/list_users.py +++ /dev/null @@ -1,55 +0,0 @@ -#!/usr/bin/env python -# -# Copyright (c) 2016, 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. - -import requests - -# Update to match your API key -API_KEY = '3c3gRvzx7uGfMYEnWKvF' - -# Update to match your chosen parameters -QUERY = '' -TEAM_IDS = [] -INCLUDE = [] - - -def list_users(): - url = 'https://api.pagerduty.com/users' - headers = { - 'Accept': 'application/vnd.pagerduty+json;version=2', - 'Authorization': 'Token token={token}'.format(token=API_KEY) - } - payload = { - 'query': QUERY, - 'team_ids[]': TEAM_IDS, - 'include[]': INCLUDE - } - r = requests.get(url, headers=headers, params=payload) - print 'Status Code: {code}'.format(code=r.status_code) - print r.json() - -if __name__ == '__main__': - list_users() diff --git a/python_v2/REST_API_v2/Users/update_user.py b/python_v2/REST_API_v2/Users/update_user.py deleted file mode 100755 index 890c57b..0000000 --- a/python_v2/REST_API_v2/Users/update_user.py +++ /dev/null @@ -1,62 +0,0 @@ -#!/usr/bin/env python -# -# Copyright (c) 2016, 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. - -import requests -import json - -# Update to match your API key -API_KEY = '3c3gRvzx7uGfMYEnWKvF' - -# Update to match ID of resource you want to update -ID = 'P0TEZR0' - -# 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 - - -def update_user(): - url = 'https://api.pagerduty.com/users/{id}'.format(id=ID) - headers = { - 'Accept': 'application/vnd.pagerduty+json;version=2', - 'Authorization': 'Token token={token}'.format(token=API_KEY), - 'Content-type': 'application/json' - } - payload = { - 'user': { - 'name': NAME, - 'email': EMAIL, - 'role': ROLE - } - } - r = requests.put(url, headers=headers, data=json.dumps(payload)) - print 'Status Code: {code}'.format(code=r.status_code) - print r.json() - -if __name__ == '__main__': - update_user() diff --git a/python_v2/REST_API_v2/Users/update_user_contact_method.py b/python_v2/REST_API_v2/Users/update_user_contact_method.py deleted file mode 100755 index ad9fa9f..0000000 --- a/python_v2/REST_API_v2/Users/update_user_contact_method.py +++ /dev/null @@ -1,66 +0,0 @@ -#!/usr/bin/env python -# -# Copyright (c) 2016, 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. - -import requests -import json - -# Update to match your API key -API_KEY = '3c3gRvzx7uGfMYEnWKvF' - -# Update to match your IDs -USER_ID = 'P0TEZR0' -CONTACT_METHOD_ID = 'P54SUEP' - -# Update to match your chosen parameters -TYPE = 'email_contact_method' # Can be one of email_contact_method, sms_contact_method, phone_contact_method, or push_notification_contact_method # NOQA -ADDRESS = 'insert_email@here.com' -LABEL = 'Work' - - -def update_user_contact_method(): - url = 'https://api.pagerduty.com/users/{uid}/contact_methods/{cid}'.format( - uid=USER_ID, - cid=CONTACT_METHOD_ID - ) - headers = { - 'Accept': 'application/vnd.pagerduty+json;version=2', - 'Authorization': 'Token token={token}'.format(token=API_KEY), - 'Content-type': 'application/json' - } - payload = { - 'contact_method': { - 'type': TYPE, - 'address': ADDRESS, - 'label': LABEL - } - } - r = requests.put(url, headers=headers, data=json.dumps(payload)) - print 'Status Code: {code}'.format(code=r.status_code) - print r.json() - -if __name__ == '__main__': - update_user_contact_method() diff --git a/python_v2/REST_API_v2/Users/update_user_notification_rule.py b/python_v2/REST_API_v2/Users/update_user_notification_rule.py deleted file mode 100755 index 4c6c1c8..0000000 --- a/python_v2/REST_API_v2/Users/update_user_notification_rule.py +++ /dev/null @@ -1,69 +0,0 @@ -#!/usr/bin/env python -# -# Copyright (c) 2016, 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. - -import requests -import json - -# Update to match your API key -API_KEY = '3c3gRvzx7uGfMYEnWKvF' - -# Update to match your IDs -USER_ID = 'P0TEZR0' -NOTIFICATION_RULE_ID = 'PHK9WYE' - -# Update to match your chosen parameters -START_DELAY_IN_MINUTES = '3' -URGENCY = 'high' -CONTACT_METHOD_ID = 'P54SUEP' -CONTACT_METHOD_TYPE = 'email_contact_method' - - -def update_user_notification_rule(): - url = ('https://api.pagerduty.com/users/{uid}/notification_rules/{nid}' - .format(uid=USER_ID, nid=NOTIFICATION_RULE_ID)) - headers = { - 'Accept': 'application/vnd.pagerduty+json;version=2', - 'Authorization': 'Token token={token}'.format(token=API_KEY), - 'Content-type': 'application/json' - } - payload = { - 'notification_rule': { - 'type': 'assignment_notification_rule', - 'start_delay_in_minutes': START_DELAY_IN_MINUTES, - 'urgency': URGENCY, - 'contact_method': { - 'id': CONTACT_METHOD_ID, - 'type': CONTACT_METHOD_TYPE - } - } - } - r = requests.put(url, headers=headers, data=json.dumps(payload)) - print 'Status Code: {code}'.format(code=r.status_code) - print r.json() - -if __name__ == '__main__': - update_user_notification_rule() diff --git a/python_v2/REST_API_v2/Vendors/get_vendor.py b/python_v2/REST_API_v2/Vendors/get_vendor.py deleted file mode 100755 index c4afea9..0000000 --- a/python_v2/REST_API_v2/Vendors/get_vendor.py +++ /dev/null @@ -1,48 +0,0 @@ -#!/usr/bin/env python -# -# Copyright (c) 2016, 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. - -import requests - -# Update to match your API key -API_KEY = '3c3gRvzx7uGfMYEnWKvF' - -# Update to match your vendor ID -ID = 'PYFMET1' - - -def get_vendor(): - url = 'https://api.pagerduty.com/vendors/{id}'.format(id=ID) - headers = { - 'Accept': 'application/vnd.pagerduty+json;version=2', - '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() - -if __name__ == '__main__': - get_vendor() diff --git a/python_v2/REST_API_v2/Vendors/list_vendors.py b/python_v2/REST_API_v2/Vendors/list_vendors.py deleted file mode 100755 index a7b7900..0000000 --- a/python_v2/REST_API_v2/Vendors/list_vendors.py +++ /dev/null @@ -1,45 +0,0 @@ -#!/usr/bin/env python -# -# Copyright (c) 2016, 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. - -import requests - -# Update to match your API key -API_KEY = '3c3gRvzx7uGfMYEnWKvF' - - -def list_vendors(): - url = 'https://api.pagerduty.com/vendors' - headers = { - 'Accept': 'application/vnd.pagerduty+json;version=2', - '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() - -if __name__ == '__main__': - list_vendors() From 629ba2ecf3cfd3f0681285a999b93a945ebb0faa Mon Sep 17 00:00:00 2001 From: David John Coleman II Date: Wed, 3 Apr 2019 16:13:00 -0500 Subject: [PATCH 8/9] remove team_responder from API_Python_Examples --- REST_API_v2/Users/create_user.py | 2 +- REST_API_v2/Users/update_user.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/REST_API_v2/Users/create_user.py b/REST_API_v2/Users/create_user.py index 1688c94..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(): diff --git a/REST_API_v2/Users/update_user.py b/REST_API_v2/Users/update_user.py index eee465c..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(): From 990554fa484598ef71f08539fdfee94dcdfc7639 Mon Sep 17 00:00:00 2001 From: Demitri Morgan Date: Wed, 22 May 2019 15:18:40 -0700 Subject: [PATCH 9/9] Fix issue #18: wrong type for sort_by parameter --- REST_API_v2/Incidents/list_incidents.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/REST_API_v2/Incidents/list_incidents.py b/REST_API_v2/Incidents/list_incidents.py index 8dacf85..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,7 +62,7 @@ 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)