diff --git a/EVENTS_API_V1/Ack/ack_incident.py b/EVENTS_API_V1/Ack/ack_incident.py new file mode 100755 index 0000000..68a7745 --- /dev/null +++ b/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() \ No newline at end of file diff --git a/EVENTS_API_V1/Resolve/resolve_incident.py b/EVENTS_API_V1/Resolve/resolve_incident.py new file mode 100755 index 0000000..b1fc45a --- /dev/null +++ b/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() \ No newline at end of file diff --git a/EVENTS_API_V1/Trigger/trigger_with_incident_key.py b/EVENTS_API_V1/Trigger/trigger_with_incident_key.py new file mode 100755 index 0000000..ddb9028 --- /dev/null +++ b/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() \ No newline at end of file diff --git a/EVENTS_API_V1/Trigger/trigger_without_incident_key.py b/EVENTS_API_V1/Trigger/trigger_without_incident_key.py new file mode 100755 index 0000000..53558a0 --- /dev/null +++ b/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() \ No newline at end of file diff --git a/EVENTS_API_v2/ack/ack_incident.py b/EVENTS_API_v2/ack/ack_incident.py old mode 100644 new mode 100755 index a31052c..d63255e --- a/EVENTS_API_v2/ack/ack_incident.py +++ b/EVENTS_API_v2/ack/ack_incident.py @@ -1,39 +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 -SUBDOMAIN = "" # Enter your subdomain here -API_ACCESS_KEY = "" # Enter your subdomain's API access 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 -def ack_incident(): - """Acknowledges a triggered incident using the customer's API access key and incident key.""" - - headers = { - 'Accept': 'application/vnd.pagerduty+json;version=2', - 'Authorization': 'Token token={0}'.format(API_ACCESS_KEY), - 'Content-type': 'application/json' + header = { + "Content-Type": "application/json" } - payload = json.dumps({ - "service_key": "", # Enter the service key here - "incident_key": "", # Enter the incident key here - "event_type": "acknowledge", - "description": "Andrew now working on the problem.", # Enter your own description - "details": { - "work started": "2010-06-10 05:43" - } - }) - - r = requests.post('https://events.pagerduty.com/generic/2010-04-15/create_event.json', - headers=headers, - data=payload, - ) - - print r.status_code - print r.text + 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__': - ack_incident() + trigger_incident() \ No newline at end of file diff --git a/EVENTS_API_v2/resolve/resolve_incident.py b/EVENTS_API_v2/resolve/resolve_incident.py old mode 100644 new mode 100755 index ba01bb0..4c66295 --- a/EVENTS_API_v2/resolve/resolve_incident.py +++ b/EVENTS_API_v2/resolve/resolve_incident.py @@ -1,39 +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 -SUBDOMAIN = "" # Enter your subdomain here -API_ACCESS_KEY = "" # Enter your subdomain's API access 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 -def resolve_incident(): - """Resolves a PagerDuty incident using customer's API access key and incident key.""" - - headers = { - 'Accept': 'application/vnd.pagerduty+json;version=2', - 'Authorization': 'Token token={0}'.format(API_ACCESS_KEY), - 'Content-type': 'application/json', + header = { + "Content-Type": "application/json" } - - payload = json.dumps({ - "service_key": "", # Enter service key here - "incident_key": "", # Enter incident key here - "event_type": "resolve", - "description": "Andrew fixed the problem.", # Enter personalized description - "details": { - "fixed at": "2010-06-10 06:00" - } - }) - - r = requests.post('https://events.pagerduty.com/generic/2010-04-15/create_event.json', - headers=headers, - data=payload, - ) - print r.status_code - print r.text + 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__': - resolve_incident() + trigger_incident() \ No newline at end of file diff --git a/EVENTS_API_v2/trigger/trigger_with_incident_key.py b/EVENTS_API_v2/trigger/trigger_with_incident_key.py index 650cf7d..0cde85e 100644 --- a/EVENTS_API_v2/trigger/trigger_with_incident_key.py +++ b/EVENTS_API_v2/trigger/trigger_with_incident_key.py @@ -1,42 +1,38 @@ #!/usr/bin/env python + import json import requests - -SUBDOMAIN = "" # Enter your subdomain here -API_ACCESS_KEY = "" # Enter your subdomain's API access key here - +ROUTING_KEY = "" # ENTER EVENTS V2 API INTEGRATION KEY HERE +INCIDENT_KEY = "" # ENTER INCIDENT KEY HERE def trigger_incident(): - """Triggers an incident with a previously generated incident key.""" + # 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 - headers = { - 'Accept': 'application/vnd.pagerduty+json;version=2', - 'Authorization': 'Token token={0}'.format(API_ACCESS_KEY), - 'Content-type': 'application/json', + header = { + "Content-Type": "application/json" } - payload = json.dumps({ - "service_key": "", # Enter service key here - "incident_key": "srv01/HTTP", - "event_type": "trigger", - "description": "FAILURE for production/HTTP on machine srv01.acme.com", - "client": "Sample Monitoring Service", - "client_url": "https://monitoring.service.com", - "details": { - "ping time": "1500ms", - "load avg": 0.75 + 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" } - }) - - r = requests.post('https://events.pagerduty.com/generic/2010-04-15/create_event.json', - headers=headers, - data=payload, - ) - - print r.status_code - print r.text + } + 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/EVENTS_API_v2/trigger/trigger_without_incident_key.py b/EVENTS_API_v2/trigger/trigger_without_incident_key.py index ef01c60..3c17967 100644 --- a/EVENTS_API_v2/trigger/trigger_without_incident_key.py +++ b/EVENTS_API_v2/trigger/trigger_without_incident_key.py @@ -1,41 +1,36 @@ #!/usr/bin/env python + import json import requests - -SUBDOMAIN = "" # Enter your subdomain here -API_ACCESS_KEY = "" # Enter your subdomain's API access key here - +ROUTING_KEY = "" # ENTER EVENTS V2 API INTEGRATION KEY HERE def trigger_incident(): - """Triggers a PagerDuty incident without a previously generated incident key.""" + # 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 - headers = { - 'Accept': 'application/vnd.pagerduty+json;version=2', - 'Authorization': 'Token token={0}'.format(API_ACCESS_KEY), - 'Content-type': 'application/json', + header = { + "Content-Type": "application/json" } - payload = json.dumps({ - "service_key": "", # Enter service key here - "event_type": "trigger", - "description": "FAILURE for production/HTTP on machine srv01.acme.com", - "client": "Sample Monitoring Service", - "client_url": "https://monitoring.service.com", - "details": { - "ping time": "1500ms", - "load avg": 0.75 + 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" } - }) - - r = requests.post('https://events.pagerduty.com/generic/2010-04-15/create_event.json', - headers=headers, - data=payload, - ) - - print r.status_code - print r.text + } + 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/INTEGRATION_API/Ack/ack_incident.py b/INTEGRATION_API/Ack/ack_incident.py deleted file mode 100755 index f6ddf61..0000000 --- a/INTEGRATION_API/Ack/ack_incident.py +++ /dev/null @@ -1,31 +0,0 @@ -#!/usr/bin/env python -import json -import requests - - -SUBDOMAIN='pdt-dank' -API_ACCESS_KEY='HjEs6A6KozribnKqm1tX' - - -def trigger_incident(): - headers = { - 'Authorization': 'Token token={0}'.format(API_ACCESS_KEY), - 'Content-type': 'application/json', - } - payload = json.dumps({ - "service_key": "e05fd2270e2c4c028f3ae2388bbc09eb", - "incident_key": "18d16696da65420c9f8d5cfa38b17a27", - "event_type": "acknowledge", - "description": "Andrew now working on the problem.", - "details": { - "work started": "2010-06-10 05:43" - } - }) - r = requests.post( - 'https://events.pagerduty.com/generic/2010-04-15/create_event.json', - headers=headers, - data=payload, - ) - print r.status_code - print r.text -trigger_incident() diff --git a/INTEGRATION_API/Resolve/resolve_incident.py b/INTEGRATION_API/Resolve/resolve_incident.py deleted file mode 100755 index cd91d29..0000000 --- a/INTEGRATION_API/Resolve/resolve_incident.py +++ /dev/null @@ -1,31 +0,0 @@ -#!/usr/bin/env python -import json -import requests - - -SUBDOMAIN='pdt-dank' -API_ACCESS_KEY='HjEs6A6KozribnKqm1tX' - - -def trigger_incident(): - headers = { - 'Authorization': 'Token token={0}'.format(API_ACCESS_KEY), - 'Content-type': 'application/json', - } - payload = json.dumps({ - "service_key": "e05fd2270e2c4c028f3ae2388bbc09eb", - "incident_key": "18d16696da65420c9f8d5cfa38b17a27", - "event_type": "resolve", - "description": "Andrew fixed the problem.", - "details": { - "fixed at": "2010-06-10 06:00" - } - }) - r = requests.post( - 'https://events.pagerduty.com/generic/2010-04-15/create_event.json', - headers=headers, - data=payload, - ) - print r.status_code - print r.text -trigger_incident() diff --git a/INTEGRATION_API/Trigger/trigger_with_incident_key.py b/INTEGRATION_API/Trigger/trigger_with_incident_key.py deleted file mode 100755 index 6f50fed..0000000 --- a/INTEGRATION_API/Trigger/trigger_with_incident_key.py +++ /dev/null @@ -1,34 +0,0 @@ -#!/usr/bin/env python -import json -import requests - - -SUBDOMAIN='pdt-dank' -API_ACCESS_KEY='HjEs6A6KozribnKqm1tX' - - -def trigger_incident(): - headers = { - 'Authorization': 'Token token={0}'.format(API_ACCESS_KEY), - 'Content-type': 'application/json', - } - payload = json.dumps({ - "service_key": "e05fd2270e2c4c028f3ae2388bbc09eb", - "incident_key": "srv01/HTTP", - "event_type": "trigger", - "description": "FAILURE for production/HTTP on machine srv01.acme.com", - "client": "Sample Monitoring Service", - "client_url": "https://monitoring.service.com", - "details": { - "ping time": "1500ms", - "load avg": 0.75 - } - }) - r = requests.post( - 'https://events.pagerduty.com/generic/2010-04-15/create_event.json', - headers=headers, - data=payload, - ) - print r.status_code - print r.text -trigger_incident() diff --git a/INTEGRATION_API/Trigger/trigger_without_incident_key.py b/INTEGRATION_API/Trigger/trigger_without_incident_key.py deleted file mode 100755 index 28e0099..0000000 --- a/INTEGRATION_API/Trigger/trigger_without_incident_key.py +++ /dev/null @@ -1,33 +0,0 @@ -#!/usr/bin/env python -import json -import requests - - -SUBDOMAIN='pdt-dank' -API_ACCESS_KEY='HjEs6A6KozribnKqm1tX' - - -def trigger_incident(): - headers = { - 'Authorization': 'Token token={0}'.format(API_ACCESS_KEY), - 'Content-type': 'application/json', - } - payload = json.dumps({ - "service_key": "e05fd2270e2c4c028f3ae2388bbc09eb", - "event_type": "trigger", - "description": "FAILURE for production/HTTP on machine srv01.acme.com", - "client": "Sample Monitoring Service", - "client_url": "https://monitoring.service.com", - "details": { - "ping time": "1500ms", - "load avg": 0.75 - } - }) - r = requests.post( - 'https://events.pagerduty.com/generic/2010-04-15/create_event.json', - headers=headers, - data=payload, - ) - print r.status_code - print r.text -trigger_incident() diff --git a/REST_API_v1/Alerts/get_alerts_no_filter.py b/REST_API_v1/Alerts/get_alerts_no_filter.py deleted file mode 100755 index cd5d905..0000000 --- a/REST_API_v1/Alerts/get_alerts_no_filter.py +++ /dev/null @@ -1,20 +0,0 @@ -#!/usr/bin/env python -import json -import requests - - -SUBDOMAIN='pdt-dank' -API_ACCESS_KEY='HjEs6A6KozribnKqm1tX' - - -def get_alerts(since_date, until_date): - url = 'https://{0}.pagerduty.com/api/v1/alerts'.format(SUBDOMAIN) - headers = { - 'Authorization': 'Token token={0}'.format(API_ACCESS_KEY), - 'Content-Type': 'application/json', - } - prms, prms['since'], prms['until'] = {}, since_date, until_date - r = requests.get(url, params=prms, headers=headers) - print r.status_code - print r.json() - diff --git a/REST_API_v1/Alerts/get_alerts_with_filter.py b/REST_API_v1/Alerts/get_alerts_with_filter.py deleted file mode 100644 index 2c56d7c..0000000 --- a/REST_API_v1/Alerts/get_alerts_with_filter.py +++ /dev/null @@ -1,19 +0,0 @@ -#!/usr/bin/env python -import json -import requests - - -SUBDOMAIN='pdt-dank' -API_ACCESS_KEY='HjEs6A6KozribnKqm1tX' - - -def get_alerts_and_filter(since_date, until_date, filter_type): - url = 'https://{0}.pagerduty.com/api/v1/alerts'.format(SUBDOMAIN) - headers = { - 'Authorization': 'Token token={0}'.format(API_ACCESS_KEY), - 'Content-Type': 'application/json', - } - prms, prms['since_date'], prms['until_date'], prms['filter[type]'] = {}, since_date, until_date, filter_type - r = requests.get(url, params=prms, headers=headers) - print r.status_code - print r.json() diff --git a/REST_API_v1/EscalationPolicies/DELETE_EscPol_by_ID/delete_escalation_policy_by_id.py b/REST_API_v1/EscalationPolicies/DELETE_EscPol_by_ID/delete_escalation_policy_by_id.py deleted file mode 100755 index 5e08269..0000000 --- a/REST_API_v1/EscalationPolicies/DELETE_EscPol_by_ID/delete_escalation_policy_by_id.py +++ /dev/null @@ -1,18 +0,0 @@ -#!/usr/bin/env python -import requests - - -SUBDOMAIN='pdt-dank' -API_ACCESS_KEY='HjEs6A6KozribnKqm1tX' -ESCALATION_POLICY_ID='PNJ1R1Y' - -def get_escalation_policies(): - url = 'https://{0}.pagerduty.com/api/v1/escalation_policies/{1}'.format(SUBDOMAIN, ESCALATION_POLICY_ID) - headers = { - 'Authorization': 'Token token={0}'.format(API_ACCESS_KEY), - 'Content-Type': 'application/json', - } - r = requests.delete(url, headers=headers) - print r.status_code - print r.text - diff --git a/REST_API_v1/EscalationPolicies/EscalationRules/DELETE_EscRule_by_ID/delete_escalation_rule.py b/REST_API_v1/EscalationPolicies/EscalationRules/DELETE_EscRule_by_ID/delete_escalation_rule.py deleted file mode 100755 index 4bbceb4..0000000 --- a/REST_API_v1/EscalationPolicies/EscalationRules/DELETE_EscRule_by_ID/delete_escalation_rule.py +++ /dev/null @@ -1,20 +0,0 @@ -#!/usr/bin/env python -import requests - - -SUBDOMAIN='pdt-dank' -API_ACCESS_KEY='HjEs6A6KozribnKqm1tX' -ESCALATION_POLICY_ID='P2LK6XG' -ESCALATION_POLICY_RULE_ID='PKEAKH3' - - -def get_escalation_rule(): - url = 'https://{0}.pagerduty.com/api/v1/escalation_policies/{1}/escalation_rules/{2}'.format(SUBDOMAIN, ESCALATION_POLICY_ID, ESCALATION_POLICY_RULE_ID) - headers = { - 'Authorization': 'Token token={0}'.format(API_ACCESS_KEY), - 'Content-Type': 'application/json', - } - r = requests.delete(url, headers=headers) - print r.status_code - print r.text - diff --git a/REST_API_v1/EscalationPolicies/EscalationRules/GET_EscRule_by_ID/get_escalation_rule.py b/REST_API_v1/EscalationPolicies/EscalationRules/GET_EscRule_by_ID/get_escalation_rule.py deleted file mode 100644 index a4e4439..0000000 --- a/REST_API_v1/EscalationPolicies/EscalationRules/GET_EscRule_by_ID/get_escalation_rule.py +++ /dev/null @@ -1,20 +0,0 @@ -#!/usr/bin/env python -import requests - - -SUBDOMAIN='pdt-dank' -API_ACCESS_KEY='HjEs6A6KozribnKqm1tX' -ESCALATION_POLICY_ID='PLYUUBF' -ESCALATION_POLICY_RULE_ID='P6QNT52' - - -def get_escalation_rule(): - url = 'https://{0}.pagerduty.com/api/v1/escalation_policies/{1}/escalation_rules/{2}'.format(SUBDOMAIN, ESCALATION_POLICY_ID, ESCALATION_POLICY_RULE_ID) - headers = { - 'Authorization': 'Token token={0}'.format(API_ACCESS_KEY), - 'Content-Type': 'application/json', - } - r = requests.get(url, headers=headers) - print r.status_code - print r.json() - diff --git a/REST_API_v1/EscalationPolicies/EscalationRules/GET_Escalation_Rules/get_escalation_rules.py b/REST_API_v1/EscalationPolicies/EscalationRules/GET_Escalation_Rules/get_escalation_rules.py deleted file mode 100644 index ed3fa29..0000000 --- a/REST_API_v1/EscalationPolicies/EscalationRules/GET_Escalation_Rules/get_escalation_rules.py +++ /dev/null @@ -1,18 +0,0 @@ -#!/usr/bin/env python -import requests - - -SUBDOMAIN='pdt-dank' -API_ACCESS_KEY='HjEs6A6KozribnKqm1tX' -ESCALATION_POLICY_ID='PLYUUBF' - -def get_escalation_rules(): - url = 'https://{0}.pagerduty.com/api/v1/escalation_policies/{1}/escalation_rules'.format(SUBDOMAIN, ESCALATION_POLICY_ID) - headers = { - 'Authorization': 'Token token={0}'.format(API_ACCESS_KEY), - 'Content-Type': 'application/json', - } - r = requests.get(url, headers=headers) - print r.status_code - print r.json() - diff --git a/REST_API_v1/EscalationPolicies/EscalationRules/POST_Escalation_Rules/create_escalation_rule.py b/REST_API_v1/EscalationPolicies/EscalationRules/POST_Escalation_Rules/create_escalation_rule.py deleted file mode 100755 index 6440071..0000000 --- a/REST_API_v1/EscalationPolicies/EscalationRules/POST_Escalation_Rules/create_escalation_rule.py +++ /dev/null @@ -1,24 +0,0 @@ -#!/usr/bin/env python -import json -import requests - - -SUBDOMAIN='pdt-dank' -API_ACCESS_KEY='HjEs6A6KozribnKqm1tX' -ESCALATION_POLICY_ID='P2LK6XG' - - -def create_escalation_rule(): - headers = { - 'Authorization': 'Token token={0}'.format(API_ACCESS_KEY), - 'Content-type': 'application/json', - } - params = {"escalation_rule":{"escalation_delay_in_minutes":10,"targets":[{"type":"user","id":"PJR28TQ"}]}} - r = requests.post( - 'https://{0}.pagerduty.com/api/v1/escalation_policies/{1}/escalation_rules'.format(SUBDOMAIN, ESCALATION_POLICY_ID), - headers=headers, - data=json.dumps(params) - ) - print r.status_code - print r.text - diff --git a/REST_API_v1/EscalationPolicies/EscalationRules/PUT_EscRule_by_ID/test.py b/REST_API_v1/EscalationPolicies/EscalationRules/PUT_EscRule_by_ID/test.py deleted file mode 100755 index fd288d9..0000000 --- a/REST_API_v1/EscalationPolicies/EscalationRules/PUT_EscRule_by_ID/test.py +++ /dev/null @@ -1,34 +0,0 @@ -#!/usr/bin/env python -import json -import requests - - -SUBDOMAIN='pdt-dank' -API_ACCESS_KEY='HjEs6A6KozribnKqm1tX' -ESCALATION_POLICY_ID='P2LK6XG' -ESCALATION_RULE_ID='PCPB3KW' - - -def update_escalation_rule(): - headers = { - 'Authorization': 'Token token={0}'.format(API_ACCESS_KEY), - 'Content-type': 'application/json', - } - params = { - "escalation_delay_in_minutes":140, - "targets":[ - { - "type":"schedule", - "id":"PBCHDG6" - } - ] - } - r = requests.put( - 'https://{0}.pagerduty.com/api/v1/escalation_policies/{1}/escalation_rules/{2}'.format(SUBDOMAIN, ESCALATION_POLICY_ID, ESCALATION_RULE_ID), - headers=headers, - data=json.dumps(params) - ) - print r.status_code - print r.text -update_escalation_rule() - diff --git a/REST_API_v1/EscalationPolicies/EscalationRules/PUT_EscRule_by_ID/update_escalation_rule.py b/REST_API_v1/EscalationPolicies/EscalationRules/PUT_EscRule_by_ID/update_escalation_rule.py deleted file mode 100755 index dc5138f..0000000 --- a/REST_API_v1/EscalationPolicies/EscalationRules/PUT_EscRule_by_ID/update_escalation_rule.py +++ /dev/null @@ -1,34 +0,0 @@ -#!/usr/bin/env python -import json -import requests - - -SUBDOMAIN='pdt-dank' -API_ACCESS_KEY='HjEs6A6KozribnKqm1tX' -ESCALATION_POLICY_ID='P2LK6XG' -ESCALATION_RULE_ID='PCPB3KW' - - -def update_escalation_rule(): - headers = { - 'Authorization': 'Token token={0}'.format(API_ACCESS_KEY), - 'Content-type': 'application/json', - } - params = { - "escalation_delay_in_minutes":14, - "targets":[ - { - "type":"user", - "id":"PJR28TQ" - } - ] - } - r = requests.put( - 'https://{0}.pagerduty.com/api/v1/escalation_policies/{1}/escalation_rules/{2}'.format(SUBDOMAIN, ESCALATION_POLICY_ID, ESCALATION_RULE_ID), - headers=headers, - data=json.dumps(params) - ) - print r.status_code - print r.text -update_escalation_rule() - diff --git a/REST_API_v1/EscalationPolicies/EscalationRules/PUT_Escalation_Rules/update_escalation_rules.py b/REST_API_v1/EscalationPolicies/EscalationRules/PUT_Escalation_Rules/update_escalation_rules.py deleted file mode 100755 index f61da9a..0000000 --- a/REST_API_v1/EscalationPolicies/EscalationRules/PUT_Escalation_Rules/update_escalation_rules.py +++ /dev/null @@ -1,49 +0,0 @@ -#!/usr/bin/env python -import json -import requests - - -SUBDOMAIN='pdt-dank' -API_ACCESS_KEY='HjEs6A6KozribnKqm1tX' -ESCALATION_POLICY_ID='P2LK6XG' - - -def update_escalation_rule(): - headers = { - 'Authorization': 'Token token={0}'.format(API_ACCESS_KEY), - 'Content-type': 'application/json', - } - { - "escalation_rules": [ - { - "escalation_delay_in_minutes": 12, - "targets": [ - { - "type": "schedule", - "id": "PWEVPB6" - } - ] - }, - { - "id": "PNTPYK0", - "escalation_delay_in_minutes": 24 - } - ] - } - params = { - "escalation_delay_in_minutes":44, - "targets":[ - { - "type":"user", - "id":"PJR28TQ" - } - ] - } - r = requests.put( - 'https://{0}.pagerduty.com/api/v1/escalation_policies/{1}/escalation_rules'.format(SUBDOMAIN, ESCALATION_POLICY_ID), - headers=headers, - data=json.dumps(params) - ) - print r.status_code - print r.text - diff --git a/REST_API_v1/EscalationPolicies/GET_EscPol_by_ID/get_escalation_policy_by_id.py b/REST_API_v1/EscalationPolicies/GET_EscPol_by_ID/get_escalation_policy_by_id.py deleted file mode 100755 index 17a0e85..0000000 --- a/REST_API_v1/EscalationPolicies/GET_EscPol_by_ID/get_escalation_policy_by_id.py +++ /dev/null @@ -1,18 +0,0 @@ -#!/usr/bin/env python -import requests - - -SUBDOMAIN='pdt-dank' -API_ACCESS_KEY='HjEs6A6KozribnKqm1tX' -ESCALATION_POLICY_ID='PNJ1R1Y' - -def get_escalation_policies(): - url = 'https://{0}.pagerduty.com/api/v1/escalation_policies/{1}'.format(SUBDOMAIN, ESCALATION_POLICY_ID) - headers = { - 'Authorization': 'Token token={0}'.format(API_ACCESS_KEY), - 'Content-Type': 'application/json', - } - r = requests.get(url, headers=headers) - print r.status_code - print r.json() - diff --git a/REST_API_v1/EscalationPolicies/GET_EscPols/get_escalation_policies.py b/REST_API_v1/EscalationPolicies/GET_EscPols/get_escalation_policies.py deleted file mode 100644 index c23e141..0000000 --- a/REST_API_v1/EscalationPolicies/GET_EscPols/get_escalation_policies.py +++ /dev/null @@ -1,17 +0,0 @@ -#!/usr/bin/env python -import requests - - -SUBDOMAIN='pdt-dank' -API_ACCESS_KEY='HjEs6A6KozribnKqm1tX' - - -def get_escalation_policies(): - url = 'https://{0}.pagerduty.com/api/v1/escalation_policies'.format(SUBDOMAIN) - headers = { - 'Authorization': 'Token token={0}'.format(API_ACCESS_KEY), - 'Content-Type': 'application/json', - } - r = requests.get(url, headers=headers) - print r.status_code - print r.json() diff --git a/REST_API_v1/EscalationPolicies/OnCall/get_escalation_policy_oncall.py b/REST_API_v1/EscalationPolicies/OnCall/get_escalation_policy_oncall.py deleted file mode 100644 index 5f39090..0000000 --- a/REST_API_v1/EscalationPolicies/OnCall/get_escalation_policy_oncall.py +++ /dev/null @@ -1,18 +0,0 @@ -#!/usr/bin/env python -import requests - - -SUBDOMAIN='pdt-dank' -API_ACCESS_KEY='HjEs6A6KozribnKqm1tX' - - -def get_escalation_policy_oncall(): - url = 'https://{0}.pagerduty.com/api/v1/escalation_policies/on_call'.format(SUBDOMAIN) - headers = { - 'Authorization': 'Token token={0}'.format(API_ACCESS_KEY), - 'Content-Type': 'application/json', - } - r = requests.get(url, headers=headers) - print r.status_code - print r.json() - diff --git a/REST_API_v1/EscalationPolicies/POST_EscPols/create_escalation_policy.py b/REST_API_v1/EscalationPolicies/POST_EscPols/create_escalation_policy.py deleted file mode 100755 index 5aebcf7..0000000 --- a/REST_API_v1/EscalationPolicies/POST_EscPols/create_escalation_policy.py +++ /dev/null @@ -1,37 +0,0 @@ -#!/usr/bin/env python -import json -import requests - - -SUBDOMAIN='pdt-dank' -API_ACCESS_KEY='HjEs6A6KozribnKqm1tX' - - -def create_escalation_policy(): - headers = { - 'Authorization': 'Token token={0}'.format(API_ACCESS_KEY), - 'Content-type': 'application/json', - } - params = { - "name": "Escalation Policy", - "escalation_rules": [ - { - "escalation_delay_in_minutes": 22, - "targets": [ - { - "type": "user", - "id": "PJR28TQ" - } - ] - } - ], - "num_loops": 2 - } - r = requests.post( - 'https://{0}.pagerduty.com/api/v1/escalation_policies'.format(SUBDOMAIN), - headers=headers, - data=json.dumps(params) - ) - print r.status_code - print r.text - diff --git a/REST_API_v1/EscalationPolicies/PUT_EscPol_by_ID/update_escalation_policy.py b/REST_API_v1/EscalationPolicies/PUT_EscPol_by_ID/update_escalation_policy.py deleted file mode 100755 index e549131..0000000 --- a/REST_API_v1/EscalationPolicies/PUT_EscPol_by_ID/update_escalation_policy.py +++ /dev/null @@ -1,26 +0,0 @@ -#!/usr/bin/env python -import json -import requests - - -SUBDOMAIN='pdt-dank' -API_ACCESS_KEY='HjEs6A6KozribnKqm1tX' -ESCALATION_POLICY_ID='P2LK6XG' - - -def update_escalation_policy(): - headers = { - 'Authorization': 'Token token={0}'.format(API_ACCESS_KEY), - 'Content-type': 'application/json', - } - params = { - "name": "Escalation Policy 222222" - } - r = requests.put( - 'https://{0}.pagerduty.com/api/v1/escalation_policies/{1}'.format(SUBDOMAIN, ESCALATION_POLICY_ID), - headers=headers, - data=json.dumps(params) - ) - print r.status_code - print r.text - diff --git a/REST_API_v1/GeneralInformation/Authentication/authenticate_with_token.py b/REST_API_v1/GeneralInformation/Authentication/authenticate_with_token.py deleted file mode 100755 index 01b6c15..0000000 --- a/REST_API_v1/GeneralInformation/Authentication/authenticate_with_token.py +++ /dev/null @@ -1,18 +0,0 @@ -#!/usr/bin/env python -import requests - - -SUBDOMAIN='pdt-dank' -API_ACCESS_KEY='HjEs6A6KozribnKqm1tX' -SCHEDULE_ID='PKROVQO' - -def schedule_entries(): - url = 'https://{0}.pagerduty.com/api/v1/schedules/{1}/entries'.format(SUBDOMAIN, SCHEDULE_ID) - headers = { - 'Authorization': 'Token token={0}'.format(API_ACCESS_KEY), - 'Content-Type': 'application/json', - } - r = requests.get(url, headers=headers) - print r.status_code - print r.json() - diff --git a/REST_API_v1/GeneralInformation/Authentication/authenticate_with_username_and_password.py b/REST_API_v1/GeneralInformation/Authentication/authenticate_with_username_and_password.py deleted file mode 100755 index fa1eeb4..0000000 --- a/REST_API_v1/GeneralInformation/Authentication/authenticate_with_username_and_password.py +++ /dev/null @@ -1,17 +0,0 @@ -#!/usr/bin/env python -import requests - - -LOGIN_EMAIL='myemail@example.com' -LOGIN_PASSWORD='secret' -SUBDOMAIN='pdt-dank' -SCHEDULE_ID='PKROVQO' - -def schedule_entries(): - url = 'https://{0}.pagerduty.com/api/v1/schedules/{1}/entries'.format(SUBDOMAIN, SCHEDULE_ID) - headers = { - 'Content-Type': 'application/json', - } - r = requests.get(url, auth=(LOGIN_EMAIL, LOGIN_PASSWORD), headers=headers) - print r.status_code - diff --git a/REST_API_v1/Incidents/Get_Incidents/get_incidents_1.py b/REST_API_v1/Incidents/Get_Incidents/get_incidents_1.py deleted file mode 100755 index 10372d5..0000000 --- a/REST_API_v1/Incidents/Get_Incidents/get_incidents_1.py +++ /dev/null @@ -1,24 +0,0 @@ -#!/usr/bin/env python -import requests - - -SUBDOMAIN='pdt-dank' -API_ACCESS_KEY='HjEs6A6KozribnKqm1tX' - - -def get_incidents(): - headers = { - 'Authorization': 'Token token={0}'.format(API_ACCESS_KEY), - 'Content-type': 'application/json', - } - payload = { - 'status':'triggered,acknowledged', - } - r = requests.get( - 'https://{0}.pagerduty.com/api/v1/incidents'.format(SUBDOMAIN), - headers=headers, - params=payload, - ) - print r.status_code - print r.text - diff --git a/REST_API_v1/Incidents/Get_Incidents/get_incidents_2.py b/REST_API_v1/Incidents/Get_Incidents/get_incidents_2.py deleted file mode 100755 index 59a5bcd..0000000 --- a/REST_API_v1/Incidents/Get_Incidents/get_incidents_2.py +++ /dev/null @@ -1,24 +0,0 @@ -#!/usr/bin/env python -import requests - - -SUBDOMAIN='pdt-dank' -API_ACCESS_KEY='HjEs6A6KozribnKqm1tX' - - -def get_incidents(): - headers = { - 'Authorization': 'Token token={0}'.format(API_ACCESS_KEY), - 'Content-type': 'application/json', - } - payload = { - 'fields':'incident_number,status', - } - r = requests.get( - 'https://{0}.pagerduty.com/api/v1/incidents'.format(SUBDOMAIN), - headers=headers, - params=payload, - ) - print r.status_code - print r.text - diff --git a/REST_API_v1/Incidents/Get_Incidents/get_incidents_3.py b/REST_API_v1/Incidents/Get_Incidents/get_incidents_3.py deleted file mode 100755 index 376465c..0000000 --- a/REST_API_v1/Incidents/Get_Incidents/get_incidents_3.py +++ /dev/null @@ -1,26 +0,0 @@ -#!/usr/bin/env python -import requests - - -SUBDOMAIN='pdt-dank' -API_ACCESS_KEY='HjEs6A6KozribnKqm1tX' - - -def get_incidents(): - headers = { - 'Authorization': 'Token token={0}'.format(API_ACCESS_KEY), - 'Content-type': 'application/json', - } - payload = { - 'since':'2014-02-01', - 'until':'2014-05-01', - 'sort_by':'created_on:desc', - } - r = requests.get( - 'https://{0}.pagerduty.com/api/v1/incidents'.format(SUBDOMAIN), - headers=headers, - params=payload, - ) - print r.status_code - print r.text - diff --git a/REST_API_v1/Incidents/Get_Incidents/get_incidents_4.py b/REST_API_v1/Incidents/Get_Incidents/get_incidents_4.py deleted file mode 100755 index 2e0b0e9..0000000 --- a/REST_API_v1/Incidents/Get_Incidents/get_incidents_4.py +++ /dev/null @@ -1,28 +0,0 @@ -#!/usr/bin/env python -import requests - - -SUBDOMAIN='pdt-dank' -API_ACCESS_KEY='HjEs6A6KozribnKqm1tX' - - -def get_incidents(): - headers = { - 'Authorization': 'Token token={0}'.format(API_ACCESS_KEY), - 'Content-type': 'application/json', - } - payload = { - 'since':'2014-02-01', - 'until':'2014-05-01', - 'sort_by':'created_on:desc', - 'limit':50, - 'offset':0, - } - r = requests.get( - 'https://{0}.pagerduty.com/api/v1/incidents'.format(SUBDOMAIN), - headers=headers, - params=payload, - ) - print r.status_code - print r.text - diff --git a/REST_API_v1/Incidents/Get_Incidents/get_incidents_5.py b/REST_API_v1/Incidents/Get_Incidents/get_incidents_5.py deleted file mode 100755 index fb5a4f6..0000000 --- a/REST_API_v1/Incidents/Get_Incidents/get_incidents_5.py +++ /dev/null @@ -1,26 +0,0 @@ -#!/usr/bin/env python -import requests - - -SUBDOMAIN='pdt-dank' -API_ACCESS_KEY='HjEs6A6KozribnKqm1tX' - - -def get_incidents(): - headers = { - 'Authorization': 'Token token={0}'.format(API_ACCESS_KEY), - 'Content-type': 'application/json', - } - payload = { - 'since':'2014-02-01', - 'until':'2014-05-01', - 'service':'P0K8ML4', - } - r = requests.get( - 'https://{0}.pagerduty.com/api/v1/incidents'.format(SUBDOMAIN), - headers=headers, - params=payload, - ) - print r.status_code - print r.text - diff --git a/REST_API_v1/Incidents/Get_Incidents/get_incidents_6.py b/REST_API_v1/Incidents/Get_Incidents/get_incidents_6.py deleted file mode 100755 index ae1da8c..0000000 --- a/REST_API_v1/Incidents/Get_Incidents/get_incidents_6.py +++ /dev/null @@ -1,27 +0,0 @@ -#!/usr/bin/env python -import requests - - -SUBDOMAIN='pdt-dank' -API_ACCESS_KEY='HjEs6A6KozribnKqm1tX' - - -def get_incidents(): - headers = { - 'Authorization': 'Token token={0}'.format(API_ACCESS_KEY), - 'Content-type': 'application/json', - } - payload = { - 'since':'2014-02-01', - 'until':'2014-05-01', - 'status':'resolved', - 'sort_by':'resolved_on:asc', - } - r = requests.get( - 'https://{0}.pagerduty.com/api/v1/incidents'.format(SUBDOMAIN), - headers=headers, - params=payload, - ) - print r.status_code - print r.text - diff --git a/REST_API_v1/Incidents/Get_Incidents/get_incidents_7.py b/REST_API_v1/Incidents/Get_Incidents/get_incidents_7.py deleted file mode 100755 index 617d069..0000000 --- a/REST_API_v1/Incidents/Get_Incidents/get_incidents_7.py +++ /dev/null @@ -1,27 +0,0 @@ -#!/usr/bin/env python -import requests - - -SUBDOMAIN='pdt-dank' -API_ACCESS_KEY='HjEs6A6KozribnKqm1tX' - - -def get_incidents(): - headers = { - 'Authorization': 'Token token={0}'.format(API_ACCESS_KEY), - 'Content-type': 'application/json', - } - payload = { - 'since':'2014-02-01', - 'until':'2014-05-01', - 'status':'triggered,acknowledged', - 'sort_by':'created_on:asc', - } - r = requests.get( - 'https://{0}.pagerduty.com/api/v1/incidents'.format(SUBDOMAIN), - headers=headers, - params=payload, - ) - print r.status_code - print r.text - diff --git a/REST_API_v1/Incidents/Get_Incidents/get_incidents_8.py b/REST_API_v1/Incidents/Get_Incidents/get_incidents_8.py deleted file mode 100755 index b3d60e7..0000000 --- a/REST_API_v1/Incidents/Get_Incidents/get_incidents_8.py +++ /dev/null @@ -1,28 +0,0 @@ -#!/usr/bin/env python -import requests - - -SUBDOMAIN='pdt-dank' -API_ACCESS_KEY='HjEs6A6KozribnKqm1tX' - - -def get_incidents(): - headers = { - 'Authorization': 'Token token={0}'.format(API_ACCESS_KEY), - 'Content-type': 'application/json', - } - payload = { - 'since':'2014-02-01', - 'until':'2014-05-01', - 'status':'triggered,acknowledged', - 'sort_by':'created_on:asc', - 'limit':20, - } - r = requests.get( - 'https://{0}.pagerduty.com/api/v1/incidents'.format(SUBDOMAIN), - headers=headers, - params=payload, - ) - print r.status_code - print r.text - diff --git a/REST_API_v1/Incidents/Get_Incidents_By_ID/get_incidents_by_id.py b/REST_API_v1/Incidents/Get_Incidents_By_ID/get_incidents_by_id.py deleted file mode 100755 index 10372d5..0000000 --- a/REST_API_v1/Incidents/Get_Incidents_By_ID/get_incidents_by_id.py +++ /dev/null @@ -1,24 +0,0 @@ -#!/usr/bin/env python -import requests - - -SUBDOMAIN='pdt-dank' -API_ACCESS_KEY='HjEs6A6KozribnKqm1tX' - - -def get_incidents(): - headers = { - 'Authorization': 'Token token={0}'.format(API_ACCESS_KEY), - 'Content-type': 'application/json', - } - payload = { - 'status':'triggered,acknowledged', - } - r = requests.get( - 'https://{0}.pagerduty.com/api/v1/incidents'.format(SUBDOMAIN), - headers=headers, - params=payload, - ) - print r.status_code - print r.text - diff --git a/REST_API_v1/Incidents/Get_Incidents_Count/get_incidents_count.py b/REST_API_v1/Incidents/Get_Incidents_Count/get_incidents_count.py deleted file mode 100755 index 5e5931e..0000000 --- a/REST_API_v1/Incidents/Get_Incidents_Count/get_incidents_count.py +++ /dev/null @@ -1,26 +0,0 @@ -#!/usr/bin/env python -import requests - - -SUBDOMAIN='pdt-dank' -API_ACCESS_KEY='HjEs6A6KozribnKqm1tX' - - -def get_incidents(): - headers = { - 'Authorization': 'Token token={0}'.format(API_ACCESS_KEY), - 'Content-type': 'application/json', - } - payload = { - 'since':'2014-04-01', - 'until':'2014-05-01', - 'status':'resolved', - } - r = requests.get( - 'https://{0}.pagerduty.com/api/v1/incidents/count'.format(SUBDOMAIN), - headers=headers, - params=payload, - ) - print r.status_code - print r.text -get_incidents() diff --git a/REST_API_v1/Incidents/Notes/GET_Incident_Notes/get_incident_notes_by_incident_id.py b/REST_API_v1/Incidents/Notes/GET_Incident_Notes/get_incident_notes_by_incident_id.py deleted file mode 100755 index 27197ca..0000000 --- a/REST_API_v1/Incidents/Notes/GET_Incident_Notes/get_incident_notes_by_incident_id.py +++ /dev/null @@ -1,18 +0,0 @@ -#!/usr/bin/env python -import requests - - -SUBDOMAIN='pdt-dank' -API_ACCESS_KEY='HjEs6A6KozribnKqm1tX' -INCIDENT_ID='PNJ1R1Y' - -def get_notes_by_incident_id(): - url = 'https://{0}.pagerduty.com/api/v1/incidents/{1}/notes'.format(SUBDOMAIN, INCIDENT_ID) - headers = { - 'Authorization': 'Token token={0}'.format(API_ACCESS_KEY), - 'Content-Type': 'application/json', - } - r = requests.get(url, headers=headers) - print r.status_code - print r.json() - diff --git a/REST_API_v1/Incidents/Notes/POST_Incident_Notes/create_incident_note.py b/REST_API_v1/Incidents/Notes/POST_Incident_Notes/create_incident_note.py deleted file mode 100755 index 4cacf9a..0000000 --- a/REST_API_v1/Incidents/Notes/POST_Incident_Notes/create_incident_note.py +++ /dev/null @@ -1,29 +0,0 @@ -#!/usr/bin/env python -import json -import requests - - -SUBDOMAIN='pdt-dank' -API_ACCESS_KEY='HjEs6A6KozribnKqm1tX' -INCIDENT_ID='PAHI1MA' -REQUESTER_ID='PJR28TQ' - -def create_incident_note(): - headers = { - 'Authorization': 'Token token={0}'.format(API_ACCESS_KEY), - 'Content-type': 'application/json', - } - params = { - "requester_id":"{0}".format(REQUESTER_ID), - "note":{ - "content":"New Note", - } - } - r = requests.post( - 'https://{0}.pagerduty.com/api/v1/incidents/{1}/notes'.format(SUBDOMAIN, INCIDENT_ID), - headers=headers, - data=json.dumps(params) - ) - print r.status_code - print r.text - diff --git a/REST_API_v1/Incidents/PUT_Incidents/update_incidents.py b/REST_API_v1/Incidents/PUT_Incidents/update_incidents.py deleted file mode 100755 index 7991b31..0000000 --- a/REST_API_v1/Incidents/PUT_Incidents/update_incidents.py +++ /dev/null @@ -1,32 +0,0 @@ -#!/usr/bin/env python -import json -import requests - - -SUBDOMAIN='pdt-dank' -API_ACCESS_KEY='HjEs6A6KozribnKqm1tX' -REQUESTER_ID='PJR28TQ' -INCIDENT_ID='PBI9MB9' - -def update_incidents(): - headers = { - 'Authorization': 'Token token={0}'.format(API_ACCESS_KEY), - 'Content-type': 'application/json', - } - params = { - "requester_id": "{0}".format(REQUESTER_ID), - "incidents": [ - { - "id": "{0}".format(INCIDENT_ID), - "status": "resolved", - } - ] - } - r = requests.put( - 'https://{0}.pagerduty.com/api/v1/incidents'.format(SUBDOMAIN), - headers=headers, - data=json.dumps(params) - ) - print r.status_code - print r.text -update_incidents() diff --git a/REST_API_v1/Incidents/PUT_Incidents_Ack/ack_incident.py b/REST_API_v1/Incidents/PUT_Incidents_Ack/ack_incident.py deleted file mode 100755 index a3af19c..0000000 --- a/REST_API_v1/Incidents/PUT_Incidents_Ack/ack_incident.py +++ /dev/null @@ -1,22 +0,0 @@ -#!/usr/bin/env python -import json -import requests - - -SUBDOMAIN='pdt-dank' -API_ACCESS_KEY='HjEs6A6KozribnKqm1tX' -REQUESTER_ID='PJR28TQ' -INCIDENT_ID='PBI9MB9' - -def ack_incident(): - headers = { - 'Authorization': 'Token token={0}'.format(API_ACCESS_KEY), - 'Content-type': 'application/json', - } - r = requests.put( - 'https://{0}.pagerduty.com/api/v1/incidents/{1}/acknowledge?requester_id={2}'.format(SUBDOMAIN, INCIDENT_ID, REQUESTER_ID), - headers=headers, - ) - print r.status_code - print r.text -ack_incident() diff --git a/REST_API_v1/Incidents/PUT_Incidents_Reassign/reassign_incident.py b/REST_API_v1/Incidents/PUT_Incidents_Reassign/reassign_incident.py deleted file mode 100755 index fcdf663..0000000 --- a/REST_API_v1/Incidents/PUT_Incidents_Reassign/reassign_incident.py +++ /dev/null @@ -1,22 +0,0 @@ -#!/usr/bin/env python -import json -import requests - - -SUBDOMAIN='pdt-dank' -API_ACCESS_KEY='HjEs6A6KozribnKqm1tX' -REQUESTER_ID='PJR28TQ' -INCIDENT_ID='PBI9MB9' - -def reassign_incident(): - headers = { - 'Authorization': 'Token token={0}'.format(API_ACCESS_KEY), - 'Content-type': 'application/json', - } - r = requests.put( - 'https://{0}.pagerduty.com/api/v1/incidents/{1}/reassign'.format(SUBDOMAIN, INCIDENT_ID), - headers=headers, - ) - print r.status_code - print r.text -reassign_incident() diff --git a/REST_API_v1/Incidents/PUT_Incidents_Resolve/update_incidents.py b/REST_API_v1/Incidents/PUT_Incidents_Resolve/update_incidents.py deleted file mode 100755 index 55c0d87..0000000 --- a/REST_API_v1/Incidents/PUT_Incidents_Resolve/update_incidents.py +++ /dev/null @@ -1,22 +0,0 @@ -#!/usr/bin/env python -import json -import requests - - -SUBDOMAIN='pdt-dank' -API_ACCESS_KEY='HjEs6A6KozribnKqm1tX' -REQUESTER_ID='PJR28TQ' -INCIDENT_ID='PBI9MB9' - -def resolve_incident(): - headers = { - 'Authorization': 'Token token={0}'.format(API_ACCESS_KEY), - 'Content-type': 'application/json', - } - r = requests.put( - 'https://{0}.pagerduty.com/api/v1/incidents/{0}/resolve'.format(SUBDOMAIN, INCIDENT_ID), - headers=headers, - ) - print r.status_code - print r.text -resolve_incident() diff --git a/REST_API_v1/LogEntries/GET_Incident_LogEntries/get_incident_log_entries.py b/REST_API_v1/LogEntries/GET_Incident_LogEntries/get_incident_log_entries.py deleted file mode 100755 index f5989f7..0000000 --- a/REST_API_v1/LogEntries/GET_Incident_LogEntries/get_incident_log_entries.py +++ /dev/null @@ -1,21 +0,0 @@ -#!/usr/bin/env python -import requests - - -SUBDOMAIN='pdt-dank' -API_ACCESS_KEY='HjEs6A6KozribnKqm1tX' -INCIDENT_ID='PAHI1MA' - - -def get_incidents_log_entries(): - headers = { - 'Authorization': 'Token token={0}'.format(API_ACCESS_KEY), - 'Content-type': 'application/json', - } - r = requests.get( - 'https://{0}.pagerduty.com/api/v1/incidents/{1}/log_entries'.format(SUBDOMAIN, INCIDENT_ID), - headers=headers, - ) - print r.status_code - print r.text - diff --git a/REST_API_v1/LogEntries/GET_LogEntries/get_log_entries.py b/REST_API_v1/LogEntries/GET_LogEntries/get_log_entries.py deleted file mode 100755 index cb85e6c..0000000 --- a/REST_API_v1/LogEntries/GET_LogEntries/get_log_entries.py +++ /dev/null @@ -1,19 +0,0 @@ -#!/usr/bin/env python -import requests - - -SUBDOMAIN='pdt-dank' -API_ACCESS_KEY='HjEs6A6KozribnKqm1tX' - - -def get_log_entries(): - headers = { - 'Authorization': 'Token token={0}'.format(API_ACCESS_KEY), - 'Content-type': 'application/json', - } - r = requests.get( - 'https://{0}.pagerduty.com/api/v1/log_entries'.format(SUBDOMAIN), - headers=headers, - ) - print r.status_code - print r.text diff --git a/REST_API_v1/LogEntries/GET_LogEntries_By_ID/get_log_entries_by_id.py b/REST_API_v1/LogEntries/GET_LogEntries_By_ID/get_log_entries_by_id.py deleted file mode 100755 index 3e9bbe8..0000000 --- a/REST_API_v1/LogEntries/GET_LogEntries_By_ID/get_log_entries_by_id.py +++ /dev/null @@ -1,20 +0,0 @@ -#!/usr/bin/env python -import requests - - -SUBDOMAIN='pdt-dank' -API_ACCESS_KEY='HjEs6A6KozribnKqm1tX' -LOG_ENTRY_ID='PDO55AJ' - -def get_log_entries(): - headers = { - 'Authorization': 'Token token={0}'.format(API_ACCESS_KEY), - 'Content-type': 'application/json', - } - r = requests.get( - 'https://{0}.pagerduty.com/api/v1/log_entries/{1}'.format(SUBDOMAIN, LOG_ENTRY_ID), - headers=headers, - ) - print r.status_code - print r.text - diff --git a/REST_API_v1/LogEntries/GET_LogEntries_By_ID/get_log_entries_by_id_include_channel.py b/REST_API_v1/LogEntries/GET_LogEntries_By_ID/get_log_entries_by_id_include_channel.py deleted file mode 100755 index 4434759..0000000 --- a/REST_API_v1/LogEntries/GET_LogEntries_By_ID/get_log_entries_by_id_include_channel.py +++ /dev/null @@ -1,24 +0,0 @@ -#!/usr/bin/env python -import requests - - -SUBDOMAIN='pdt-dank' -API_ACCESS_KEY='HjEs6A6KozribnKqm1tX' -LOG_ENTRY_ID='PDO55AJ' - -def get_log_entries(): - headers = { - 'Authorization': 'Token token={0}'.format(API_ACCESS_KEY), - 'Content-type': 'application/json', - } - payload = { - "include[]": "channel", - } - r = requests.get( - 'https://{0}.pagerduty.com/api/v1/log_entries/{1}'.format(SUBDOMAIN, LOG_ENTRY_ID), - headers=headers, - params=payload, - ) - print r.status_code - print r.text - diff --git a/REST_API_v1/LogEntries/GET_User_LogEntries/get_user_log_entries.py b/REST_API_v1/LogEntries/GET_User_LogEntries/get_user_log_entries.py deleted file mode 100755 index 23198e3..0000000 --- a/REST_API_v1/LogEntries/GET_User_LogEntries/get_user_log_entries.py +++ /dev/null @@ -1,20 +0,0 @@ -#!/usr/bin/env python -import requests - - -SUBDOMAIN='pdt-dank' -API_ACCESS_KEY='HjEs6A6KozribnKqm1tX' -USER_ID='PJR28TQ' - -def get_users_log_entries(): - headers = { - 'Authorization': 'Token token={0}'.format(API_ACCESS_KEY), - 'Content-type': 'application/json', - } - r = requests.get( - 'https://{0}.pagerduty.com/api/v1/users/{1}/log_entries'.format(SUBDOMAIN, USER_ID), - headers=headers, - ) - print r.status_code - print r.text - diff --git a/REST_API_v1/MaintenanceWindows/DELETE_MaintenanceWindow/delete_maintenance_window.py b/REST_API_v1/MaintenanceWindows/DELETE_MaintenanceWindow/delete_maintenance_window.py deleted file mode 100755 index ac3b586..0000000 --- a/REST_API_v1/MaintenanceWindows/DELETE_MaintenanceWindow/delete_maintenance_window.py +++ /dev/null @@ -1,20 +0,0 @@ -#!/usr/bin/env python -import requests - - -SUBDOMAIN='pdt-dank' -API_ACCESS_KEY='HjEs6A6KozribnKqm1tX' -MAINTENANCE_WINDOW_ID='PEP41A8' - -def delete_maintenance_window(): - headers = { - 'Authorization': 'Token token={0}'.format(API_ACCESS_KEY), - 'Content-type': 'application/json', - } - r = requests.delete( - 'https://{0}.pagerduty.com/api/v1/maintenance_windows/{1}'.format(SUBDOMAIN, MAINTENANCE_WINDOW_ID), - headers=headers, - ) - print r.status_code - print r.text - diff --git a/REST_API_v1/MaintenanceWindows/GET_MaintenanceWindow_By_ID/get_maintenance_window_by_id.py b/REST_API_v1/MaintenanceWindows/GET_MaintenanceWindow_By_ID/get_maintenance_window_by_id.py deleted file mode 100755 index f2623fb..0000000 --- a/REST_API_v1/MaintenanceWindows/GET_MaintenanceWindow_By_ID/get_maintenance_window_by_id.py +++ /dev/null @@ -1,20 +0,0 @@ -#!/usr/bin/env python -import requests - - -SUBDOMAIN='pdt-dank' -API_ACCESS_KEY='HjEs6A6KozribnKqm1tX' -MAINTENANCE_WINDOW_ID='PZCBANA' - -def get_maintenance_window_by_id(): - headers = { - 'Authorization': 'Token token={0}'.format(API_ACCESS_KEY), - 'Content-type': 'application/json', - } - r = requests.get( - 'https://{0}.pagerduty.com/api/v1/maintenance_windows/{1}'.format(SUBDOMAIN, MAINTENANCE_WINDOW_ID), - headers=headers, - ) - print r.status_code - print r.text - diff --git a/REST_API_v1/MaintenanceWindows/GET_MaintenanceWindows/get_maintenance_windows.py b/REST_API_v1/MaintenanceWindows/GET_MaintenanceWindows/get_maintenance_windows.py deleted file mode 100755 index f4a6bcf..0000000 --- a/REST_API_v1/MaintenanceWindows/GET_MaintenanceWindows/get_maintenance_windows.py +++ /dev/null @@ -1,26 +0,0 @@ -#!/usr/bin/env python -import requests - - -SUBDOMAIN='pdt-dank' -API_ACCESS_KEY='HjEs6A6KozribnKqm1tX' - - -def get_maintenance_windows(): - headers = { - 'Authorization': 'Token token={0}'.format(API_ACCESS_KEY), - 'Content-type': 'application/json', - } - payload = { - 'query':'ruby 1.9 migration', - 'service_ids[]':'PY4XIXJ', - 'filter':'ongoing', - } - r = requests.get( - 'https://{0}.pagerduty.com/api/v1/maintenance_windows'.format(SUBDOMAIN), - headers=headers, - params=payload, - ) - print r.status_code - print r.text - diff --git a/REST_API_v1/MaintenanceWindows/POST_MaintenanceWindow/create_maintenance_window.py b/REST_API_v1/MaintenanceWindows/POST_MaintenanceWindow/create_maintenance_window.py deleted file mode 100755 index 324d549..0000000 --- a/REST_API_v1/MaintenanceWindows/POST_MaintenanceWindow/create_maintenance_window.py +++ /dev/null @@ -1,32 +0,0 @@ -#!/usr/bin/env python -import requests -import datetime -import json - - -SUBDOMAIN='pdt-dank' -API_ACCESS_KEY='HjEs6A6KozribnKqm1tX' -SERVICE_IDS=['XYZ0ABC'] - -def create_maintenance_window(minutes=5): -"""Create a maintenance window starting now""" - headers = { - 'Authorization': 'Token token={0}'.format(API_ACCESS_KEY), - 'Content-type': 'application/json', - } - payload = { - "maintenance_window": { - 'start_time': datetime.datetime.utcnow().strftime("%Y-%m-%d %H:%M:%SZ"), - 'end_time': (datetime.datetime.utcnow() + datetime.timedelta(minutes=minutes)).strftime("%Y-%m-%d %H:%M:%SZ"), - "description": "Description goes here", - "service_ids": PD_SERVICE_IDS, - } - } - r = requests.post( - 'https://{0}.pagerduty.com/api/v1/maintenance_windows'.format(SUBDOMAIN), - headers=headers, - data=json.dumps(payload) - ) - print r.status_code - print r.text - diff --git a/REST_API_v1/MaintenanceWindows/PUT_MaintenanceWindow/update_maintenance_window.py b/REST_API_v1/MaintenanceWindows/PUT_MaintenanceWindow/update_maintenance_window.py deleted file mode 100755 index 029c70c..0000000 --- a/REST_API_v1/MaintenanceWindows/PUT_MaintenanceWindow/update_maintenance_window.py +++ /dev/null @@ -1,29 +0,0 @@ -#!/usr/bin/env python -import json -import requests - - -SUBDOMAIN='pdt-dank' -API_ACCESS_KEY='HjEs6A6KozribnKqm1tX' -MAINTENANCE_WINDOW_ID='PEP41A8' -SERVICE_ID='PJGPSVN' - -def update_maintenance_window(): - headers = { - 'Authorization': 'Token token={0}'.format(API_ACCESS_KEY), - 'Content-type': 'application/json', - } - payload = { - "start_time":"2014-06-13T13:00:00-04:00Z", - "end_time":"2014-06-16T14:00:00-04:00Z", - "description":"Description goes here", - "service_ids":["{0}".format(SERVICE_ID)], - } - r = requests.put( - 'https://{0}.pagerduty.com/api/v1/maintenance_windows/{1}'.format(SUBDOMAIN, MAINTENANCE_WINDOW_ID), - headers=headers, - data=json.dumps(payload), - ) - print r.status_code - print r.text - diff --git a/REST_API_v1/Reports/get_alerts_per_time.py b/REST_API_v1/Reports/get_alerts_per_time.py deleted file mode 100755 index 7a78697..0000000 --- a/REST_API_v1/Reports/get_alerts_per_time.py +++ /dev/null @@ -1,25 +0,0 @@ -#!/usr/bin/env python -import requests - - -SUBDOMAIN='pdt-dank' -API_ACCESS_KEY='HjEs6A6KozribnKqm1tX' - - -def get_alerts_per_time(): - headers = { - 'Authorization': 'Token token={0}'.format(API_ACCESS_KEY), - 'Content-type': 'application/json', - } - payload = { - 'since':'2014-06-01', - 'until':'2014-06-12', - } - r = requests.get( - 'https://{0}.pagerduty.com/api/v1/reports/alerts_per_time'.format(SUBDOMAIN), - headers=headers, - params=payload, - ) - print r.status_code - print r.text - diff --git a/REST_API_v1/Reports/get_incidents_per_time.py b/REST_API_v1/Reports/get_incidents_per_time.py deleted file mode 100755 index 08e7e42..0000000 --- a/REST_API_v1/Reports/get_incidents_per_time.py +++ /dev/null @@ -1,26 +0,0 @@ -#!/usr/bin/env python -import requests - - -SUBDOMAIN='pdt-dank' -API_ACCESS_KEY='HjEs6A6KozribnKqm1tX' - - -def get_incidents_per_time(): - headers = { - 'Authorization': 'Token token={0}'.format(API_ACCESS_KEY), - 'Content-type': 'application/json', - } - payload = { - 'since':'2014-06-01', - 'until':'2014-06-12', - 'rollup':'daily', - } - r = requests.get( - 'https://{0}.pagerduty.com/api/v1/reports/incidents_per_time'.format(SUBDOMAIN), - headers=headers, - params=payload, - ) - print r.status_code - print r.text - diff --git a/REST_API_v1/Schedules/GET_Schedule_Entries/get_schedule_entries_next_day.py b/REST_API_v1/Schedules/GET_Schedule_Entries/get_schedule_entries_next_day.py deleted file mode 100755 index dcc66ad..0000000 --- a/REST_API_v1/Schedules/GET_Schedule_Entries/get_schedule_entries_next_day.py +++ /dev/null @@ -1,23 +0,0 @@ -#!/usr/bin/env python -import json -import requests - - -SUBDOMAIN='pdt-dank' -API_ACCESS_KEY='HjEs6A6KozribnKqm1tX' -SCHEDULE_ID='P6QNT52' - -def get_schedule_entries(): - url = 'https://{0}.pagerduty.com/api/v1/schedules/{1}'.format(SUBDOMAIN, SCHEDULE_ID) - headers = { - 'Authorization': 'Token token={0}'.format(API_ACCESS_KEY), - 'Content-Type': 'application/json', - } - payload = { - "since": "2014-06-20", - "until": "2014-06-22", - } - r = requests.get(url, headers=headers, params=payload) - print r.status_code - print r.json() - diff --git a/REST_API_v1/Schedules/GET_Schedule_Entries/get_schedule_entries_today_2pm.py b/REST_API_v1/Schedules/GET_Schedule_Entries/get_schedule_entries_today_2pm.py deleted file mode 100755 index 34e46ab..0000000 --- a/REST_API_v1/Schedules/GET_Schedule_Entries/get_schedule_entries_today_2pm.py +++ /dev/null @@ -1,25 +0,0 @@ -#!/usr/bin/env python -import json -import requests - - -SUBDOMAIN='pdt-dank' -API_ACCESS_KEY='HjEs6A6KozribnKqm1tX' -SCHEDULE_ID='P6QNT52' - - -def get_schedule_entries(): - url = 'https://{0}.pagerduty.com/api/v1/schedules/{1}/entries'.format(SUBDOMAIN, SCHEDULE_ID) - headers = { - 'Authorization': 'Token token={0}'.format(API_ACCESS_KEY), - 'Content-Type': 'application/json', - } - payload = { - "since": "2014-06-20T14:00:00Z", - "until": "2014-06-20T14:00:00Z", - "overflow": "true", - } - r = requests.get(url, headers=headers, params=payload) - print r.status_code - print r.json() - diff --git a/REST_API_v1/Schedules/Overrides/create_schedule_override.py b/REST_API_v1/Schedules/Overrides/create_schedule_override.py deleted file mode 100755 index 5155f14..0000000 --- a/REST_API_v1/Schedules/Overrides/create_schedule_override.py +++ /dev/null @@ -1,26 +0,0 @@ -#!/usr/bin/env python -import json -import requests - - -SUBDOMAIN='pdt-dank' -API_ACCESS_KEY='HjEs6A6KozribnKqm1tX' -SCHEDULE_ID='P6QNT52' - -def create_schedule_override(): - url = 'https://{0}.pagerduty.com/api/v1/schedules/{1}/overrides'.format(SUBDOMAIN, SCHEDULE_ID) - headers = { - 'Authorization': 'Token token={0}'.format(API_ACCESS_KEY), - 'Content-Type': 'application/json', - } - payload = { - "override": { - "user_id": "PJR28TQ", - "start": "2014-07-20", - "end": "2014-07-22", - } - } - r = requests.post(url, headers=headers, data=json.dumps(payload)) - print r.status_code - print r.json() - diff --git a/REST_API_v1/Schedules/Overrides/get_schedule_overrides.py b/REST_API_v1/Schedules/Overrides/get_schedule_overrides.py deleted file mode 100755 index dd81b58..0000000 --- a/REST_API_v1/Schedules/Overrides/get_schedule_overrides.py +++ /dev/null @@ -1,23 +0,0 @@ -#!/usr/bin/env python -import json -import requests - - -SUBDOMAIN='pdt-dank' -API_ACCESS_KEY='HjEs6A6KozribnKqm1tX' -SCHEDULE_ID='P6QNT52' - -def get_schedule_overrides(): - url = 'https://{0}.pagerduty.com/api/v1/schedules/{1}/overrides'.format(SUBDOMAIN, SCHEDULE_ID) - headers = { - 'Authorization': 'Token token={0}'.format(API_ACCESS_KEY), - 'Content-Type': 'application/json', - } - payload = { - "since": "2014-06-20", - "until": "2014-06-22", - } - r = requests.get(url, headers=headers, params=payload) - print r.status_code - print r.json() - diff --git a/REST_API_v1/Schedules/create_schedule.py b/REST_API_v1/Schedules/create_schedule.py deleted file mode 100755 index 49be2fd..0000000 --- a/REST_API_v1/Schedules/create_schedule.py +++ /dev/null @@ -1,24 +0,0 @@ -#!/usr/bin/env python -import json -import requests - - -SUBDOMAIN='pdt-dank' -API_ACCESS_KEY='HjEs6A6KozribnKqm1tX' - - -def create_schedule(): - headers = { - 'Authorization': 'Token token={0}'.format(API_ACCESS_KEY), - 'Content-type': 'application/json', - } - payload = json.dumps({"schedule":{"id":"P5WPTAH","name":"TestJulianStuff","time_zone":"UTC","today":"2014-06-12","escalation_policies":[],"description":"","schedule_layers":[{"name":"Schedule Layer 1","rendered_schedule_entries":[],"id":"PSJCVEV","priority":0,"start":"2014-06-12T22:55:05Z","end":None,"restriction_type":None,"rotation_virtual_start":"2014-06-08T00:00:00Z","rotation_turn_length_seconds":86400,"users":[{"member_order":1,"user":{"id":"PJR28TQ","name":"Dan Khersonsky","email":"dkhersonsky@pagerduty.com","color":"purple"}}],"restrictions":[],"rendered_coverage_percentage":0.0}],"overrides_subschedule":{"name":"Overrides","rendered_schedule_entries":[]},"final_schedule":{"name":"Final Schedule","rendered_schedule_entries":[],"rendered_coverage_percentage":0.0}}}) - - r = requests.post( - 'https://{0}.pagerduty.com/api/v1/schedules'.format(SUBDOMAIN), - headers=headers, - data=payload, - ) - print r.status_code - print r.text - diff --git a/REST_API_v1/Schedules/delete_schedule.py b/REST_API_v1/Schedules/delete_schedule.py deleted file mode 100755 index ad11cc6..0000000 --- a/REST_API_v1/Schedules/delete_schedule.py +++ /dev/null @@ -1,21 +0,0 @@ -#!/usr/bin/env python -import json -import requests - - -SUBDOMAIN='pdt-dank' -API_ACCESS_KEY='HjEs6A6KozribnKqm1tX' -SCHEDULE_ID='P8R0I83' - -def delete_schedule(): - headers = { - 'Authorization': 'Token token={0}'.format(API_ACCESS_KEY), - 'Content-type': 'application/json', - } - r = requests.delete( - 'https://{0}.pagerduty.com/api/v1/schedules/{0}'.format(SUBDOMAIN, SCHEDULE_ID), - headers=headers, - ) - print r.status_code - print r.text - diff --git a/REST_API_v1/Schedules/get_schedule_by_id.py b/REST_API_v1/Schedules/get_schedule_by_id.py deleted file mode 100755 index 21334b5..0000000 --- a/REST_API_v1/Schedules/get_schedule_by_id.py +++ /dev/null @@ -1,19 +0,0 @@ -#!/usr/bin/env python -import json -import requests - - -SUBDOMAIN='pdt-dank' -API_ACCESS_KEY='HjEs6A6KozribnKqm1tX' -SCHEDULE_ID='P6QNT52' - -def get_schedule_by_id(): - url = 'https://{0}.pagerduty.com/api/v1/schedules/{1}'.format(SUBDOMAIN, SCHEDULE_ID) - headers = { - 'Authorization': 'Token token={0}'.format(API_ACCESS_KEY), - 'Content-Type': 'application/json', - } - r = requests.get(url, headers=headers) - print r.status_code - print r.json() - diff --git a/REST_API_v1/Schedules/get_schedule_users_by_id.py b/REST_API_v1/Schedules/get_schedule_users_by_id.py deleted file mode 100755 index 4b305c2..0000000 --- a/REST_API_v1/Schedules/get_schedule_users_by_id.py +++ /dev/null @@ -1,23 +0,0 @@ -#!/usr/bin/env python -import json -import requests - - -SUBDOMAIN='pdt-dank' -API_ACCESS_KEY='HjEs6A6KozribnKqm1tX' -SCHEDULE_ID='P6QNT52' - -def get_schedule_by_id(): - url = 'https://{0}.pagerduty.com/api/v1/schedules/{1}/users'.format(SUBDOMAIN, SCHEDULE_ID) - headers = { - 'Authorization': 'Token token={0}'.format(API_ACCESS_KEY), - 'Content-Type': 'application/json', - } - params = { - 'since':'2014-06-01', - 'until':'2014-06-12', - } - r = requests.get(url, headers=headers, params=params) - print r.status_code - print r.json() - diff --git a/REST_API_v1/Schedules/get_schedules.py b/REST_API_v1/Schedules/get_schedules.py deleted file mode 100755 index d0746bd..0000000 --- a/REST_API_v1/Schedules/get_schedules.py +++ /dev/null @@ -1,19 +0,0 @@ -#!/usr/bin/env python -import json -import requests - - -SUBDOMAIN='pdt-dank' -API_ACCESS_KEY='HjEs6A6KozribnKqm1tX' - - -def get_schedules(): - url = 'https://{0}.pagerduty.com/api/v1/schedules'.format(SUBDOMAIN) - headers = { - 'Authorization': 'Token token={0}'.format(API_ACCESS_KEY), - 'Content-Type': 'application/json', - } - r = requests.get(url, headers=headers) - print r.status_code - print r.json() - diff --git a/REST_API_v1/Schedules/preview_schedule.py b/REST_API_v1/Schedules/preview_schedule.py deleted file mode 100755 index cdba24d..0000000 --- a/REST_API_v1/Schedules/preview_schedule.py +++ /dev/null @@ -1,24 +0,0 @@ -#!/usr/bin/env python -import json -import requests - - -SUBDOMAIN='pdt-dank' -API_ACCESS_KEY='zma9XjUU8tAjuzqnts1k' - - -def create_schedule(): - headers = { - 'Authorization': 'Token token={0}'.format(API_ACCESS_KEY), - 'Content-type': 'application/json', - } - payload = json.dumps({"schedule":{"id":"P5WPTAH","name":"TestJulian222Stuff","time_zone":"UTC","today":"2014-06-12","escalation_policies":[],"description":"","schedule_layers":[{"name":"Schedule Layer 1","rendered_schedule_entries":[],"id":"PSJCVEV","priority":0,"start":"2014-06-12T22:55:05Z","end":None,"restriction_type":None,"rotation_virtual_start":"2014-06-08T00:00:00Z","rotation_turn_length_seconds":86400,"users":[{"member_order":1,"user":{"id":"PJR28TQ","name":"Dan Khersonsky","email":"dkhersonsky@pagerduty.com","color":"purple"}}],"restrictions":[],"rendered_coverage_percentage":0.0}],"overrides_subschedule":{"name":"Overrides","rendered_schedule_entries":[]},"final_schedule":{"name":"Final Schedule","rendered_schedule_entries":[],"rendered_coverage_percentage":0.0}}}) - - r = requests.post( - 'https://{0}.pagerduty.com/api/v1/schedules/preview'.format(SUBDOMAIN), - headers=headers, - data=payload, - ) - print r.status_code - print r.text - diff --git a/REST_API_v1/Services/DELETE_Service/delete_service.py b/REST_API_v1/Services/DELETE_Service/delete_service.py deleted file mode 100755 index 7926b2c..0000000 --- a/REST_API_v1/Services/DELETE_Service/delete_service.py +++ /dev/null @@ -1,23 +0,0 @@ -#!/usr/bin/env python -import json -import requests - - -SUBDOMAIN='pdt-dank' -API_ACCESS_KEY='HjEs6A6KozribnKqm1tX' -SERVICE_ID='PXV2VTJ' -ESCALATION_POLICY_ID='PLYUUBF' - - -def delete_service(): - headers = { - 'Authorization': 'Token token={0}'.format(API_ACCESS_KEY), - 'Content-type': 'application/json', - } - r = requests.delete( - 'https://{0}.pagerduty.com/api/v1/services/{1}'.format(SUBDOMAIN, SERVICE_ID), - headers=headers, - ) - print r.status_code - print r.text - diff --git a/REST_API_v1/Services/DISABLE_Service/disable_service.py b/REST_API_v1/Services/DISABLE_Service/disable_service.py deleted file mode 100755 index 676e210..0000000 --- a/REST_API_v1/Services/DISABLE_Service/disable_service.py +++ /dev/null @@ -1,28 +0,0 @@ -#!/usr/bin/env python -import json -import requests - - -SUBDOMAIN='pdt-dank' -API_ACCESS_KEY='HjEs6A6KozribnKqm1tX' -SERVICE_ID='PJGPSVN' -REQUESTER_ID='PJR28TQ' - - -def disable_service(): - headers = { - 'Authorization': 'Token token={0}'.format(API_ACCESS_KEY), - 'Content-type': 'application/json', - } - payload = json.dumps({ - "requester_id":"{0}".format(REQUESTER_ID) - } - ) - r = requests.put( - 'https://{0}.pagerduty.com/api/v1/services/{1}/disable'.format(SUBDOMAIN, SERVICE_ID), - headers=headers, - data=payload, - ) - print r.status_code - print r.text - diff --git a/REST_API_v1/Services/EMAIL_FILTERS/create_email_filter.py b/REST_API_v1/Services/EMAIL_FILTERS/create_email_filter.py deleted file mode 100755 index adae81e..0000000 --- a/REST_API_v1/Services/EMAIL_FILTERS/create_email_filter.py +++ /dev/null @@ -1,32 +0,0 @@ -#!/usr/bin/env python -import json -import requests - - -SUBDOMAIN='pdt-dank' -API_ACCESS_KEY='HjEs6A6KozribnKqm1tX' -SERVICE_ID='P295MFW' -EMAIL_FILTER_ID='PY88T3A' - - -def create_email_filter(): - headers = { - 'Authorization': 'Token token={0}'.format(API_ACCESS_KEY), - 'Content-type': 'application/json', - } - payload = json.dumps({ - "email_filter":{ - "body_mode":"no-match", - "body_regex":"sev 3", - } - } - ) - - r = requests.post( - 'https://{0}.pagerduty.com/api/v1/services/{1}/email_filters'.format(SUBDOMAIN, SERVICE_ID), - headers=headers, - data=payload, - ) - print r.status_code - print r.text - diff --git a/REST_API_v1/Services/EMAIL_FILTERS/delete_email_filter.py b/REST_API_v1/Services/EMAIL_FILTERS/delete_email_filter.py deleted file mode 100755 index 4b9ebe4..0000000 --- a/REST_API_v1/Services/EMAIL_FILTERS/delete_email_filter.py +++ /dev/null @@ -1,23 +0,0 @@ -#!/usr/bin/env python -import json -import requests - - -SUBDOMAIN='pdt-dank' -API_ACCESS_KEY='HjEs6A6KozribnKqm1tX' -SERVICE_ID='P295MFW' -EMAIL_FILTER_ID='PY88T3A' - - -def delete_email_filter(): - headers = { - 'Authorization': 'Token token={0}'.format(API_ACCESS_KEY), - 'Content-type': 'application/json', - } - r = requests.delete( - 'https://{0}.pagerduty.com/api/v1/services/{1}/email_filters/{2}'.format(SUBDOMAIN, SERVICE_ID, EMAIL_FILTER_ID, EMAIL_FILTER_ID), - headers=headers, - ) - print r.status_code - print r.text - diff --git a/REST_API_v1/Services/EMAIL_FILTERS/update_email_filter.py b/REST_API_v1/Services/EMAIL_FILTERS/update_email_filter.py deleted file mode 100755 index f932e46..0000000 --- a/REST_API_v1/Services/EMAIL_FILTERS/update_email_filter.py +++ /dev/null @@ -1,31 +0,0 @@ -#!/usr/bin/env python -import json -import requests - - -SUBDOMAIN='pdt-dank' -API_ACCESS_KEY='HjEs6A6KozribnKqm1tX' -SERVICE_ID='P295MFW' -EMAIL_FILTER_ID='P2T76VF' - - -def update_email_filter(): - headers = { - 'Authorization': 'Token token={0}'.format(API_ACCESS_KEY), - 'Content-type': 'application/json', - } - payload = json.dumps({"email_filter":{ - "from_email_mode":"match", - "from_email_regex":"[rR]yan", - } - } - ) - - r = requests.put( - 'https://{0}.pagerduty.com/api/v1/services/{1}/email_filters/{2}'.format(SUBDOMAIN, SERVICE_ID, EMAIL_FILTER_ID), - headers=headers, - data=payload, - ) - print r.status_code - print r.text - diff --git a/REST_API_v1/Services/ENABLE_Service/enable_service.py b/REST_API_v1/Services/ENABLE_Service/enable_service.py deleted file mode 100755 index be4499e..0000000 --- a/REST_API_v1/Services/ENABLE_Service/enable_service.py +++ /dev/null @@ -1,28 +0,0 @@ -#!/usr/bin/env python -import json -import requests - - -SUBDOMAIN='pdt-dank' -API_ACCESS_KEY='HjEs6A6KozribnKqm1tX' -SERVICE_ID='PJGPSVN' -REQUESTER_ID='PJR28TQ' - - -def enable_service(): - headers = { - 'Authorization': 'Token token={0}'.format(API_ACCESS_KEY), - 'Content-type': 'application/json', - } - payload = json.dumps({ - "requester_id":"{0}".format(REQUESTER_ID) - } - ) - r = requests.put( - 'https://{0}.pagerduty.com/api/v1/services/{1}/enable'.format(SUBDOMAIN, SERVICE_ID), - headers=headers, - data=payload, - ) - print r.status_code - print r.text - diff --git a/REST_API_v1/Services/GET_Service_By_ID/get_service_by_id.py b/REST_API_v1/Services/GET_Service_By_ID/get_service_by_id.py deleted file mode 100755 index 3a7d7e4..0000000 --- a/REST_API_v1/Services/GET_Service_By_ID/get_service_by_id.py +++ /dev/null @@ -1,21 +0,0 @@ -#!/usr/bin/env python -import requests - - -SUBDOMAIN='pdt-dank' -API_ACCESS_KEY='HjEs6A6KozribnKqm1tX' -SERVICE_ID='PZ80FQV' - - -def get_service_by_id(): - headers = { - 'Authorization': 'Token token={0}'.format(API_ACCESS_KEY), - 'Content-type': 'application/json', - } - r = requests.get( - 'https://{0}.pagerduty.com/api/v1/services/{1}'.format(SUBDOMAIN, SERVICE_ID), - headers=headers, - ) - print r.status_code - print r.text - diff --git a/REST_API_v1/Services/GET_Services/get_services_include_email_filters.py b/REST_API_v1/Services/GET_Services/get_services_include_email_filters.py deleted file mode 100755 index 8f2d8fa..0000000 --- a/REST_API_v1/Services/GET_Services/get_services_include_email_filters.py +++ /dev/null @@ -1,24 +0,0 @@ -#!/usr/bin/env python -import requests - - -SUBDOMAIN='pdt-dank' -API_ACCESS_KEY='HjEs6A6KozribnKqm1tX' - - -def get_services_include_esc_pols(): - headers = { - 'Authorization': 'Token token={0}'.format(API_ACCESS_KEY), - 'Content-type': 'application/json', - } - payload = { - 'include[]':'email_filters', - } - r = requests.get( - 'https://{0}.pagerduty.com/api/v1/services'.format(SUBDOMAIN), - headers=headers, - params=payload, - ) - print r.status_code - print r.text - diff --git a/REST_API_v1/Services/GET_Services/get_services_include_esc_pol.py b/REST_API_v1/Services/GET_Services/get_services_include_esc_pol.py deleted file mode 100755 index beae03c..0000000 --- a/REST_API_v1/Services/GET_Services/get_services_include_esc_pol.py +++ /dev/null @@ -1,24 +0,0 @@ -#!/usr/bin/env python -import requests - - -SUBDOMAIN='pdt-dank' -API_ACCESS_KEY='HjEs6A6KozribnKqm1tX' - - -def get_services_include_esc_pols(): - headers = { - 'Authorization': 'Token token={0}'.format(API_ACCESS_KEY), - 'Content-type': 'application/json', - } - payload = { - 'include[]':'escalation_policy', - } - r = requests.get( - 'https://{0}.pagerduty.com/api/v1/services'.format(SUBDOMAIN), - headers=headers, - params=payload, - ) - print r.status_code - print r.text - diff --git a/REST_API_v1/Services/POST_Service/create_api_based_service.py b/REST_API_v1/Services/POST_Service/create_api_based_service.py deleted file mode 100755 index 73b7a79..0000000 --- a/REST_API_v1/Services/POST_Service/create_api_based_service.py +++ /dev/null @@ -1,32 +0,0 @@ -#!/usr/bin/env python -import json -import requests - - -SUBDOMAIN='pdt-dank' -API_ACCESS_KEY='HjEs6A6KozribnKqm1tX' -ESCALATION_POLICY_ID='PLYUUBF' - - -def create_service(): - headers = { - 'Authorization': 'Token token={0}'.format(API_ACCESS_KEY), - 'Content-type': 'application/json', - } - payload = json.dumps({ - "service":{ - "name":"default", - "description":"service sevname10", - "escalation_policy_id":"{0}".format(ESCALATION_POLICY_ID), - "type":"generic_events_api", - } - } - ) - r = requests.post( - 'https://{0}.pagerduty.com/api/v1/services'.format(SUBDOMAIN), - headers=headers, - data=payload, - ) - print r.status_code - print r.text - diff --git a/REST_API_v1/Services/POST_Service/create_email_based_service.py b/REST_API_v1/Services/POST_Service/create_email_based_service.py deleted file mode 100755 index 3add491..0000000 --- a/REST_API_v1/Services/POST_Service/create_email_based_service.py +++ /dev/null @@ -1,35 +0,0 @@ -#!/usr/bin/env python -import json -import requests - - -SUBDOMAIN='pdt-dank' -API_ACCESS_KEY='HjEs6A6KozribnKqm1tX' -ESCALATION_POLICY_ID='PLYUUBF' - - -def create_service(): - headers = { - 'Authorization': 'Token token={0}'.format(API_ACCESS_KEY), - 'Content-type': 'application/json', - } - payload = json.dumps( - { - "service": { - "name": "default-email", - "description": "default email service", - "escalation_policy_id": "{0}".format(ESCALATION_POLICY_ID), - "type": "generic_email", - "service_key": "default-email" - } - } - ) - - r = requests.post( - 'https://{0}.pagerduty.com/api/v1/services'.format(SUBDOMAIN), - headers=headers, - data=payload, - ) - print r.status_code - print r.text - diff --git a/REST_API_v1/Services/PUT_Service/update_service.py b/REST_API_v1/Services/PUT_Service/update_service.py deleted file mode 100755 index a2356ee..0000000 --- a/REST_API_v1/Services/PUT_Service/update_service.py +++ /dev/null @@ -1,32 +0,0 @@ -#!/usr/bin/env python -import json -import requests - - -SUBDOMAIN='pdt-dank' -API_ACCESS_KEY='HjEs6A6KozribnKqm1tX' -SERVICE_ID='PXV2VTJ' -ESCALATION_POLICY_ID='PLYUUBF' - - -def update_service(): - headers = { - 'Authorization': 'Token token={0}'.format(API_ACCESS_KEY), - 'Content-type': 'application/json', - } - payload = json.dumps({ - "service":{ - "name":"My New Name", - "description":"Brand New Description", - "escalation_policy_id":"{0}".format(ESCALATION_POLICY_ID) - } - } - ) - r = requests.put( - 'https://{0}.pagerduty.com/api/v1/services/{1}'.format(SUBDOMAIN, SERVICE_ID), - headers=headers, - data=payload, - ) - print r.status_code - print r.text - diff --git a/REST_API_v1/Services/REGENERATE_KEY/regenerate_service_key.py b/REST_API_v1/Services/REGENERATE_KEY/regenerate_service_key.py deleted file mode 100755 index d29f56e..0000000 --- a/REST_API_v1/Services/REGENERATE_KEY/regenerate_service_key.py +++ /dev/null @@ -1,22 +0,0 @@ -#!/usr/bin/env python -import json -import requests - - -SUBDOMAIN='pdt-dank' -API_ACCESS_KEY='HjEs6A6KozribnKqm1tX' -SERVICE_ID='PZ80FQV' - - -def regenerate_service(): - headers = { - 'Authorization': 'Token token={0}'.format(API_ACCESS_KEY), - 'Content-type': 'application/json', - } - r = requests.post( - 'https://{0}.pagerduty.com/api/v1/services/{1}/regenerate_key'.format(SUBDOMAIN, SERVICE_ID), - headers=headers, - ) - print r.status_code - print r.text - diff --git a/REST_API_v1/Users/Contact_Methods/create_contact_method.py b/REST_API_v1/Users/Contact_Methods/create_contact_method.py deleted file mode 100755 index b82566d..0000000 --- a/REST_API_v1/Users/Contact_Methods/create_contact_method.py +++ /dev/null @@ -1,24 +0,0 @@ -#!/usr/bin/env python -import json -import requests - - -SUBDOMAIN='pdt-dank' -API_ACCESS_KEY='HjEs6A6KozribnKqm1tX' -USER_ID='PJR28TQ' -CONTACT_METHOD_ID='PSD17NZ' - - -def create_contact_method(): - headers = { - 'Authorization': 'Token token={0}'.format(API_ACCESS_KEY), - 'Content-type': 'application/json', - } - payload = json.dumps({"contact_method":{"type":"SMS","address":"5551112222","label":"Island Lair","country_code":"1"}}) - r = requests.post( - 'https://{0}.pagerduty.com/api/v1/users/{1}/contact_methods'.format(SUBDOMAIN, USER_ID), - headers=headers, - ) - print r.status_code - print r.text - diff --git a/REST_API_v1/Users/Contact_Methods/get_user_contact_method_by_id.py b/REST_API_v1/Users/Contact_Methods/get_user_contact_method_by_id.py deleted file mode 100755 index b059653..0000000 --- a/REST_API_v1/Users/Contact_Methods/get_user_contact_method_by_id.py +++ /dev/null @@ -1,22 +0,0 @@ -#!/usr/bin/env python -import requests - - -SUBDOMAIN='pdt-dank' -API_ACCESS_KEY='HjEs6A6KozribnKqm1tX' -USER_ID='PJR28TQ' -CONTACT_METHOD_ID='PSD17NZ' - - -def get_user_contact_method_by_id(): - headers = { - 'Authorization': 'Token token={0}'.format(API_ACCESS_KEY), - 'Content-type': 'application/json', - } - r = requests.get( - 'https://{0}.pagerduty.com/api/v1/users/{1}/contact_methods/{2}'.format(SUBDOMAIN, USER_ID, CONTACT_METHOD_ID), - headers=headers, - ) - print r.status_code - print r.text - diff --git a/REST_API_v1/Users/Contact_Methods/get_user_contact_methods.py b/REST_API_v1/Users/Contact_Methods/get_user_contact_methods.py deleted file mode 100755 index c8989b0..0000000 --- a/REST_API_v1/Users/Contact_Methods/get_user_contact_methods.py +++ /dev/null @@ -1,21 +0,0 @@ -#!/usr/bin/env python -import requests - - -SUBDOMAIN='pdt-dank' -API_ACCESS_KEY='HjEs6A6KozribnKqm1tX' -USER_ID='PJR28TQ' - -def get_user_contact_methods_by_id(): - headers = { - 'Authorization': 'Token token={0}'.format(API_ACCESS_KEY), - 'Content-type': 'application/json', - } - r = requests.get( - 'https://{0}.pagerduty.com/api/v1/users/{1}/contact_methods'.format(SUBDOMAIN, USER_ID), - headers=headers, - ) - print r.status_code - print r.text -get_user_contact_methods_by_id() - diff --git a/REST_API_v1/Users/DELETE_Users/delete_user_by_id.py b/REST_API_v1/Users/DELETE_Users/delete_user_by_id.py deleted file mode 100755 index 1abc155..0000000 --- a/REST_API_v1/Users/DELETE_Users/delete_user_by_id.py +++ /dev/null @@ -1,20 +0,0 @@ -#!/usr/bin/env python -import requests - - -SUBDOMAIN='pdt-dank' -API_ACCESS_KEY='HjEs6A6KozribnKqm1tX' -USER_ID='PYZPJZ9' - -def delete_user_by_id(): - headers = { - 'Authorization': 'Token token={0}'.format(API_ACCESS_KEY), - 'Content-type': 'application/json', - } - r = requests.delete( - 'https://{0}.pagerduty.com/api/v1/users/{1}'.format(SUBDOMAIN, USER_ID), - headers=headers, - ) - print r.status_code - print r.text - diff --git a/REST_API_v1/Users/GET_User_By_ID/get_users_with_query.py b/REST_API_v1/Users/GET_User_By_ID/get_users_with_query.py deleted file mode 100755 index 7aeecf1..0000000 --- a/REST_API_v1/Users/GET_User_By_ID/get_users_with_query.py +++ /dev/null @@ -1,20 +0,0 @@ -#!/usr/bin/env python -import requests - - -SUBDOMAIN='pdt-dank' -API_ACCESS_KEY='HjEs6A6KozribnKqm1tX' -USER_ID='PJR28TQ' - -def get_user_by_id(): - headers = { - 'Authorization': 'Token token={0}'.format(API_ACCESS_KEY), - 'Content-type': 'application/json', - } - r = requests.get( - 'https://{0}.pagerduty.com/api/v1/users/{1}'.format(SUBDOMAIN, USER_ID), - headers=headers, - ) - print r.status_code - print r.text - diff --git a/REST_API_v1/Users/GET_User_On_Call_By_ID/get_users_with_query.py b/REST_API_v1/Users/GET_User_On_Call_By_ID/get_users_with_query.py deleted file mode 100755 index e96b3fe..0000000 --- a/REST_API_v1/Users/GET_User_On_Call_By_ID/get_users_with_query.py +++ /dev/null @@ -1,20 +0,0 @@ -#!/usr/bin/env python -import requests - - -SUBDOMAIN='pdt-dank' -API_ACCESS_KEY='HjEs6A6KozribnKqm1tX' -USER_ID='PJR28TQ' - -def get_user_by_id(): - headers = { - 'Authorization': 'Token token={0}'.format(API_ACCESS_KEY), - 'Content-type': 'application/json', - } - r = requests.get( - 'https://{0}.pagerduty.com/api/v1/users/{1}/on_call'.format(SUBDOMAIN, USER_ID), - headers=headers, - ) - print r.status_code - print r.text - diff --git a/REST_API_v1/Users/GET_Users/get_users_with_contacts_and_notifications.py b/REST_API_v1/Users/GET_Users/get_users_with_contacts_and_notifications.py deleted file mode 100755 index 7468cce..0000000 --- a/REST_API_v1/Users/GET_Users/get_users_with_contacts_and_notifications.py +++ /dev/null @@ -1,25 +0,0 @@ -#!/usr/bin/env python -import requests - - -SUBDOMAIN='pdt-dank' -API_ACCESS_KEY='HjEs6A6KozribnKqm1tX' - - -def get_users(): - headers = { - 'Authorization': 'Token token={0}'.format(API_ACCESS_KEY), - 'Content-type': 'application/json', - } - payload = { - 'include[]':'contact_methods', - 'include[]':'notification_rules', - } - r = requests.get( - 'https://{0}.pagerduty.com/api/v1/users'.format(SUBDOMAIN), - headers=headers, - params=payload, - ) - print r.status_code - print r.text - diff --git a/REST_API_v1/Users/GET_Users/get_users_with_query.py b/REST_API_v1/Users/GET_Users/get_users_with_query.py deleted file mode 100755 index ceacbcf..0000000 --- a/REST_API_v1/Users/GET_Users/get_users_with_query.py +++ /dev/null @@ -1,24 +0,0 @@ -#!/usr/bin/env python -import requests - - -SUBDOMAIN='pdt-dank' -API_ACCESS_KEY='HjEs6A6KozribnKqm1tX' - - -def get_users(): - headers = { - 'Authorization': 'Token token={0}'.format(API_ACCESS_KEY), - 'Content-type': 'application/json', - } - payload = { - 'query':'dan', - } - r = requests.get( - 'https://{0}.pagerduty.com/api/v1/users'.format(SUBDOMAIN), - headers=headers, - params=payload, - ) - print r.status_code - print r.text - diff --git a/REST_API_v1/Users/NotificationRules/create_notification_rule.py b/REST_API_v1/Users/NotificationRules/create_notification_rule.py deleted file mode 100755 index 519f74f..0000000 --- a/REST_API_v1/Users/NotificationRules/create_notification_rule.py +++ /dev/null @@ -1,29 +0,0 @@ -#!/usr/bin/env python -import json -import requests - - -SUBDOMAIN='pdt-dank' -API_ACCESS_KEY='zma9XjUU8tAjuzqnts1k' -USER_ID='PG9E0O0' -CONTACT_METHOD_ID='PIEGIBK' - - -def create_notification_rule(): - headers = { - 'Authorization': 'Token token={0}'.format(API_ACCESS_KEY), - 'Content-type': 'application/json', - } - payload = {"notification_rule": { - "contact_method_id": "{0}".format(CONTACT_METHOD_ID), - "start_delay_in_minutes":12, - } - } - r = requests.post( - 'https://{0}.pagerduty.com/api/v1/users/{1}/notification_rules'.format(SUBDOMAIN, USER_ID), - headers=headers, - data=json.dumps(payload), - ) - print r.status_code - print r.text - diff --git a/REST_API_v1/Users/NotificationRules/delete_notification_rule.py b/REST_API_v1/Users/NotificationRules/delete_notification_rule.py deleted file mode 100755 index aa69866..0000000 --- a/REST_API_v1/Users/NotificationRules/delete_notification_rule.py +++ /dev/null @@ -1,23 +0,0 @@ -#!/usr/bin/env python -import json -import requests - - -SUBDOMAIN='pdt-dank' -API_ACCESS_KEY='zma9XjUU8tAjuzqnts1k' -USER_ID='PG9E0O0' -NOTIFICATION_RULE_ID='PKQMJN2' - - -def delete_notification_rule(): - headers = { - 'Authorization': 'Token token={0}'.format(API_ACCESS_KEY), - 'Content-type': 'application/json', - } - r = requests.delete( - 'https://{0}.pagerduty.com/api/v1/users/{1}/notification_rules/{2}'.format(SUBDOMAIN, USER_ID, NOTIFICATION_RULE_ID), - headers=headers, - ) - print r.status_code - print r.text - diff --git a/REST_API_v1/Users/NotificationRules/get_user_notification_rule_by_id.py b/REST_API_v1/Users/NotificationRules/get_user_notification_rule_by_id.py deleted file mode 100755 index 3b4aaeb..0000000 --- a/REST_API_v1/Users/NotificationRules/get_user_notification_rule_by_id.py +++ /dev/null @@ -1,21 +0,0 @@ -#!/usr/bin/env python -import requests - - -SUBDOMAIN='pdt-dank' -API_ACCESS_KEY='zma9XjUU8tAjuzqnts1k' -USER_ID='PG9E0O0' -NOTIFICATION_RULE_ID='PKQMJN2' - -def get_user_notification_rule_by_id(): - headers = { - 'Authorization': 'Token token={0}'.format(API_ACCESS_KEY), - 'Content-type': 'application/json', - } - r = requests.get( - 'https://{0}.pagerduty.com/api/v1/users/{1}/notification_rules/{2}'.format(SUBDOMAIN, USER_ID, NOTIFICATION_RULE_ID), - headers=headers, - ) - print r.status_code - print r.text - diff --git a/REST_API_v1/Users/NotificationRules/get_user_notification_rules.py b/REST_API_v1/Users/NotificationRules/get_user_notification_rules.py deleted file mode 100755 index 28f8ec0..0000000 --- a/REST_API_v1/Users/NotificationRules/get_user_notification_rules.py +++ /dev/null @@ -1,21 +0,0 @@ -#!/usr/bin/env python -import requests - - -SUBDOMAIN='pdt-dank' -API_ACCESS_KEY='zma9XjUU8tAjuzqnts1k' -USER_ID='PG9E0O0' - - -def get_user_notification_rules(): - headers = { - 'Authorization': 'Token token={0}'.format(API_ACCESS_KEY), - 'Content-type': 'application/json', - } - r = requests.get( - 'https://{0}.pagerduty.com/api/v1/users/{1}/notification_rules'.format(SUBDOMAIN, USER_ID), - headers=headers, - ) - print r.status_code - print r.text - diff --git a/REST_API_v1/Users/NotificationRules/update_notification_rule.py b/REST_API_v1/Users/NotificationRules/update_notification_rule.py deleted file mode 100755 index 4cc5d33..0000000 --- a/REST_API_v1/Users/NotificationRules/update_notification_rule.py +++ /dev/null @@ -1,30 +0,0 @@ -#!/usr/bin/env python -import json -import requests - - -SUBDOMAIN='pdt-dank' -API_ACCESS_KEY='zma9XjUU8tAjuzqnts1k' -USER_ID='PG9E0O0' -CONTACT_METHOD_ID='PIEGIBK' -NOTIFICATION_RULE_ID='PKQMJN2' - - -def update_notification_rule(): - headers = { - 'Authorization': 'Token token={0}'.format(API_ACCESS_KEY), - 'Content-type': 'application/json', - } - payload = {"notification_rule": { - "contact_method_id": "{0}".format(CONTACT_METHOD_ID), - "start_delay_in_minutes":120, - } - } - r = requests.put( - 'https://{0}.pagerduty.com/api/v1/users/{1}/notification_rules/{2}'.format(SUBDOMAIN, USER_ID, NOTIFICATION_RULE_ID), - headers=headers, - data=json.dumps(payload), - ) - print r.status_code - print r.text - diff --git a/REST_API_v1/Users/POST_Users/create_user.py b/REST_API_v1/Users/POST_Users/create_user.py deleted file mode 100755 index 152639e..0000000 --- a/REST_API_v1/Users/POST_Users/create_user.py +++ /dev/null @@ -1,27 +0,0 @@ -#!/usr/bin/env python -import json -import requests - - -SUBDOMAIN='pdt-dank' -API_ACCESS_KEY='zma9XjUU8tAjuzqnts1k' -USER_ID='PJR28TQ' - - -def create_user(): - headers = { - 'Authorization': 'Token token={0}'.format(API_ACCESS_KEY), - 'Content-type': 'application/json', - } - payload = json.dumps({"role":"admin", - "name":"Bart Sampsoniteus", - "email":"jfjfjfjfjfbart@eklejlejlk.com", - "requester_id":"{0}".format(USER_ID),}) - r = requests.post( - 'https://{0}.pagerduty.com/api/v1/users'.format(SUBDOMAIN), - headers=headers, - data=payload, - ) - print r.status_code - print r.text - diff --git a/REST_API_v1/Users/PUT_Users/update_user.py b/REST_API_v1/Users/PUT_Users/update_user.py deleted file mode 100755 index a7fcadd..0000000 --- a/REST_API_v1/Users/PUT_Users/update_user.py +++ /dev/null @@ -1,28 +0,0 @@ -#!/usr/bin/env python -import json -import requests - - -SUBDOMAIN='pdt-dank' -API_ACCESS_KEY='zma9XjUU8tAjuzqnts1k' -USER_ID='PG9E0O0' -#USER_ID='PJR28TQ' - - -def update_user(): - headers = { - 'Authorization': 'Token token={0}'.format(API_ACCESS_KEY), - 'Content-type': 'application/json', - } - payload = json.dumps({"role":"admin", - "name":"Bart Sampsoiteu", - "email":"jfjfjfjfjfbart@eklejlejlk.co", - }) - r = requests.put( - 'https://{0}.pagerduty.com/api/v1/users/{1}'.format(SUBDOMAIN, USER_ID), - headers=headers, - data=payload, - ) - print r.status_code - print r.text -