Skip to content

Commit df3e2a9

Browse files
committed
Initial commit
0 parents  commit df3e2a9

158 files changed

Lines changed: 6472 additions & 0 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
#!/usr/bin/env python
2+
import json
3+
import requests
4+
5+
6+
SUBDOMAIN='pdt-dank'
7+
API_ACCESS_KEY='HjEs6A6KozribnKqm1tX'
8+
9+
10+
def trigger_incident():
11+
headers = {
12+
'Authorization': 'Token token={0}'.format(API_ACCESS_KEY),
13+
'Content-type': 'application/json',
14+
}
15+
payload = json.dumps({
16+
"service_key": "e05fd2270e2c4c028f3ae2388bbc09eb",
17+
"incident_key": "18d16696da65420c9f8d5cfa38b17a27",
18+
"event_type": "acknowledge",
19+
"description": "Andrew now working on the problem.",
20+
"details": {
21+
"work started": "2010-06-10 05:43"
22+
}
23+
})
24+
r = requests.post(
25+
'https://events.pagerduty.com/generic/2010-04-15/create_event.json',
26+
headers=headers,
27+
data=payload,
28+
)
29+
print r.status_code
30+
print r.text
31+
trigger_incident()
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
#!/usr/bin/env python
2+
import json
3+
import requests
4+
5+
6+
SUBDOMAIN='pdt-dank'
7+
API_ACCESS_KEY='HjEs6A6KozribnKqm1tX'
8+
9+
10+
def trigger_incident():
11+
headers = {
12+
'Authorization': 'Token token={0}'.format(API_ACCESS_KEY),
13+
'Content-type': 'application/json',
14+
}
15+
payload = json.dumps({
16+
"service_key": "e05fd2270e2c4c028f3ae2388bbc09eb",
17+
"incident_key": "18d16696da65420c9f8d5cfa38b17a27",
18+
"event_type": "resolve",
19+
"description": "Andrew fixed the problem.",
20+
"details": {
21+
"fixed at": "2010-06-10 06:00"
22+
}
23+
})
24+
r = requests.post(
25+
'https://events.pagerduty.com/generic/2010-04-15/create_event.json',
26+
headers=headers,
27+
data=payload,
28+
)
29+
print r.status_code
30+
print r.text
31+
trigger_incident()
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
#!/usr/bin/env python
2+
import json
3+
import requests
4+
5+
6+
SUBDOMAIN='pdt-dank'
7+
API_ACCESS_KEY='HjEs6A6KozribnKqm1tX'
8+
9+
10+
def trigger_incident():
11+
headers = {
12+
'Authorization': 'Token token={0}'.format(API_ACCESS_KEY),
13+
'Content-type': 'application/json',
14+
}
15+
payload = json.dumps({
16+
"service_key": "e05fd2270e2c4c028f3ae2388bbc09eb",
17+
"incident_key": "srv01/HTTP",
18+
"event_type": "trigger",
19+
"description": "FAILURE for production/HTTP on machine srv01.acme.com",
20+
"client": "Sample Monitoring Service",
21+
"client_url": "https://monitoring.service.com",
22+
"details": {
23+
"ping time": "1500ms",
24+
"load avg": 0.75
25+
}
26+
})
27+
r = requests.post(
28+
'https://events.pagerduty.com/generic/2010-04-15/create_event.json',
29+
headers=headers,
30+
data=payload,
31+
)
32+
print r.status_code
33+
print r.text
34+
trigger_incident()
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
#!/usr/bin/env python
2+
import json
3+
import requests
4+
5+
6+
SUBDOMAIN='pdt-dank'
7+
API_ACCESS_KEY='HjEs6A6KozribnKqm1tX'
8+
9+
10+
def trigger_incident():
11+
headers = {
12+
'Authorization': 'Token token={0}'.format(API_ACCESS_KEY),
13+
'Content-type': 'application/json',
14+
}
15+
payload = json.dumps({
16+
"service_key": "e05fd2270e2c4c028f3ae2388bbc09eb",
17+
"event_type": "trigger",
18+
"description": "FAILURE for production/HTTP on machine srv01.acme.com",
19+
"client": "Sample Monitoring Service",
20+
"client_url": "https://monitoring.service.com",
21+
"details": {
22+
"ping time": "1500ms",
23+
"load avg": 0.75
24+
}
25+
})
26+
r = requests.post(
27+
'https://events.pagerduty.com/generic/2010-04-15/create_event.json',
28+
headers=headers,
29+
data=payload,
30+
)
31+
print r.status_code
32+
print r.text
33+
trigger_incident()
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
#!/usr/bin/env python
2+
import json
3+
import requests
4+
5+
6+
SUBDOMAIN='pdt-dank'
7+
API_ACCESS_KEY='HjEs6A6KozribnKqm1tX'
8+
9+
10+
def get_alerts(since_date, until_date):
11+
url = 'https://{0}.pagerduty.com/api/v1/alerts'.format(SUBDOMAIN)
12+
headers = {
13+
'Authorization': 'Token token={0}'.format(API_ACCESS_KEY),
14+
'Content-Type': 'application/json',
15+
}
16+
prms, prms['since'], prms['until'] = {}, since_date, until_date
17+
r = requests.get(url, params=prms, headers=headers)
18+
print r.status_code
19+
print r.json()
20+
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#!/usr/bin/env python
2+
import json
3+
import requests
4+
5+
6+
SUBDOMAIN='pdt-dank'
7+
API_ACCESS_KEY='HjEs6A6KozribnKqm1tX'
8+
9+
10+
def get_alerts_and_filter(since_date, until_date, filter_type):
11+
url = 'https://{0}.pagerduty.com/api/v1/alerts'.format(SUBDOMAIN)
12+
headers = {
13+
'Authorization': 'Token token={0}'.format(API_ACCESS_KEY),
14+
'Content-Type': 'application/json',
15+
}
16+
prms, prms['since_date'], prms['until_date'], prms['filter[type]'] = {}, since_date, until_date, filter_type
17+
r = requests.get(url, params=prms, headers=headers)
18+
print r.status_code
19+
print r.json()
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
#!/usr/bin/env python
2+
import requests
3+
4+
5+
SUBDOMAIN='pdt-dank'
6+
API_ACCESS_KEY='HjEs6A6KozribnKqm1tX'
7+
ESCALATION_POLICY_ID='PNJ1R1Y'
8+
9+
def get_escalation_policies():
10+
url = 'https://{0}.pagerduty.com/api/v1/escalation_policies/{1}'.format(SUBDOMAIN, ESCALATION_POLICY_ID)
11+
headers = {
12+
'Authorization': 'Token token={0}'.format(API_ACCESS_KEY),
13+
'Content-Type': 'application/json',
14+
}
15+
r = requests.delete(url, headers=headers)
16+
print r.status_code
17+
print r.text
18+
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
#!/usr/bin/env python
2+
import requests
3+
4+
5+
SUBDOMAIN='pdt-dank'
6+
API_ACCESS_KEY='HjEs6A6KozribnKqm1tX'
7+
ESCALATION_POLICY_ID='P2LK6XG'
8+
ESCALATION_POLICY_RULE_ID='PKEAKH3'
9+
10+
11+
def get_escalation_rule():
12+
url = 'https://{0}.pagerduty.com/api/v1/escalation_policies/{1}/escalation_rules/{2}'.format(SUBDOMAIN, ESCALATION_POLICY_ID, ESCALATION_POLICY_RULE_ID)
13+
headers = {
14+
'Authorization': 'Token token={0}'.format(API_ACCESS_KEY),
15+
'Content-Type': 'application/json',
16+
}
17+
r = requests.delete(url, headers=headers)
18+
print r.status_code
19+
print r.text
20+
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
#!/usr/bin/env python
2+
import requests
3+
4+
5+
SUBDOMAIN='pdt-dank'
6+
API_ACCESS_KEY='HjEs6A6KozribnKqm1tX'
7+
ESCALATION_POLICY_ID='PLYUUBF'
8+
ESCALATION_POLICY_RULE_ID='P6QNT52'
9+
10+
11+
def get_escalation_rule():
12+
url = 'https://{0}.pagerduty.com/api/v1/escalation_policies/{1}/escalation_rules/{2}'.format(SUBDOMAIN, ESCALATION_POLICY_ID, ESCALATION_POLICY_RULE_ID)
13+
headers = {
14+
'Authorization': 'Token token={0}'.format(API_ACCESS_KEY),
15+
'Content-Type': 'application/json',
16+
}
17+
r = requests.get(url, headers=headers)
18+
print r.status_code
19+
print r.json()
20+
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
#!/usr/bin/env python
2+
import requests
3+
4+
5+
SUBDOMAIN='pdt-dank'
6+
API_ACCESS_KEY='HjEs6A6KozribnKqm1tX'
7+
ESCALATION_POLICY_ID='PLYUUBF'
8+
9+
def get_escalation_rules():
10+
url = 'https://{0}.pagerduty.com/api/v1/escalation_policies/{1}/escalation_rules'.format(SUBDOMAIN, ESCALATION_POLICY_ID)
11+
headers = {
12+
'Authorization': 'Token token={0}'.format(API_ACCESS_KEY),
13+
'Content-Type': 'application/json',
14+
}
15+
r = requests.get(url, headers=headers)
16+
print r.status_code
17+
print r.json()
18+

0 commit comments

Comments
 (0)