Skip to content

Commit 714369a

Browse files
committed
Switch string concatenation to use format()
1 parent 794038c commit 714369a

71 files changed

Lines changed: 252 additions & 210 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.

REST_API_v2/AddOns/delete_addon.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,13 +35,13 @@
3535

3636

3737
def delete_addon():
38-
url = 'https://api.pagerduty.com/addons/' + ID
38+
url = 'https://api.pagerduty.com/addons/{id}'.format(id=ID)
3939
headers = {
4040
'Accept': 'application/vnd.pagerduty+json;version=2',
41-
'Authorization': 'Token token=' + API_KEY
41+
'Authorization': 'Token token={token}'.format(token=API_KEY)
4242
}
4343
r = requests.delete(url, headers=headers)
44-
print 'Status Code: ' + str(r.status_code)
44+
print 'Status Code: {code}'.format(code=r.status_code)
4545
print r.text
4646

4747
if __name__ == '__main__':

REST_API_v2/AddOns/get_addon.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,13 +35,13 @@
3535

3636

3737
def get_addon():
38-
url = 'https://api.pagerduty.com/addons/' + ID
38+
url = 'https://api.pagerduty.com/addons/{id}'.format(id=ID)
3939
headers = {
4040
'Accept': 'application/vnd.pagerduty+json;version=2',
41-
'Authorization': 'Token token=' + API_KEY
41+
'Authorization': 'Token token={token}'.format(token=API_KEY)
4242
}
4343
r = requests.get(url, headers=headers)
44-
print 'Status Code: ' + str(r.status_code)
44+
print 'Status Code: {code}'.format(code=r.status_code)
4545
print r.json()
4646

4747
if __name__ == '__main__':

REST_API_v2/AddOns/install_addon.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ def install_addon():
4242
url = 'https://api.pagerduty.com/addons'
4343
headers = {
4444
'Accept': 'application/vnd.pagerduty+json;version=2',
45-
'Authorization': 'Token token=' + API_KEY,
45+
'Authorization': 'Token token={token}'.format(token=API_KEY),
4646
'Content-type': 'application/json'
4747
}
4848
payload = {
@@ -54,7 +54,7 @@ def install_addon():
5454
}
5555
}
5656
r = requests.post(url, headers=headers, data=json.dumps(payload))
57-
print 'Status Code: ' + str(r.status_code)
57+
print 'Status Code: {code}'.format(code=r.status_code)
5858
print r.json()
5959

6060
if __name__ == '__main__':

REST_API_v2/AddOns/list_installed_addons.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,15 +40,15 @@ def list_installed_addons():
4040
url = 'https://api.pagerduty.com/addons'
4141
headers = {
4242
'Accept': 'application/vnd.pagerduty+json;version=2',
43-
'Authorization': 'Token token=' + API_KEY
43+
'Authorization': 'Token token={token}'.format(token=API_KEY)
4444
}
4545
payload = {
4646
'include[]': INCLUDE,
4747
'service_ids[]': SERVICE_IDS,
4848
'filter': FILTER
4949
}
5050
r = requests.get(url, headers=headers, params=payload)
51-
print 'Status Code: ' + str(r.status_code)
51+
print 'Status Code: {code}'.format(code=r.status_code)
5252
print r.json()
5353

5454
if __name__ == '__main__':

REST_API_v2/AddOns/update_addon.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,10 @@
4242

4343

4444
def update_addon():
45-
url = 'https://api.pagerduty.com/addons/' + ID
45+
url = 'https://api.pagerduty.com/addons/{id}'.format(id=ID)
4646
headers = {
4747
'Accept': 'application/vnd.pagerduty+json;version=2',
48-
'Authorization': 'Token token=' + API_KEY,
48+
'Authorization': 'Token token={token}'.format(token=API_KEY),
4949
'Content-type': 'application/json'
5050
}
5151
payload = {

REST_API_v2/EscalationPolicies/create_escalation_policy.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ def create_escalation_policy():
5151
url = 'https://api.pagerduty.com/escalation_policies'
5252
headers = {
5353
'Accept': 'application/vnd.pagerduty+json;version=2',
54-
'Authorization': 'Token token=' + API_KEY,
54+
'Authorization': 'Token token={token}'.format(token=API_KEY),
5555
'Content-type': 'application/json'
5656
}
5757
payload = {
@@ -66,7 +66,7 @@ def create_escalation_policy():
6666
}
6767
}
6868
r = requests.post(url, headers=headers, data=json.dumps(payload))
69-
print 'Status Code: ' + str(r.status_code)
69+
print 'Status Code: {code}'.format(code=r.status_code)
7070
print r.json()
7171

7272
if __name__ == '__main__':

REST_API_v2/EscalationPolicies/delete_escalation_policy.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,13 +35,13 @@
3535

3636

3737
def delete_escalation_policy():
38-
url = 'https://api.pagerduty.com/escalation_policies/' + ID
38+
url = 'https://api.pagerduty.com/escalation_policies/{id}'.format(id=ID)
3939
headers = {
4040
'Accept': 'application/vnd.pagerduty+json;version=2',
41-
'Authorization': 'Token token=' + API_KEY
41+
'Authorization': 'Token token={token}'.format(token=API_KEY)
4242
}
4343
r = requests.delete(url, headers=headers)
44-
print 'Status Code: ' + str(r.status_code)
44+
print 'Status Code: {code}'.format(code=r.status_code)
4545
print r.text
4646

4747
if __name__ == '__main__':

REST_API_v2/EscalationPolicies/get_escalation_policy.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,16 +38,16 @@
3838

3939

4040
def get_escalation_policy():
41-
url = 'https://api.pagerduty.com/escalation_policies/' + ID
41+
url = 'https://api.pagerduty.com/escalation_policies/{id}'.format(id=ID)
4242
headers = {
4343
'Accept': 'application/vnd.pagerduty+json;version=2',
44-
'Authorization': 'Token token=' + API_KEY
44+
'Authorization': 'Token token={token}'.format(token=API_KEY)
4545
}
4646
payload = {
4747
'include[]': INCLUDE
4848
}
4949
r = requests.get(url, headers=headers, params=payload)
50-
print 'Status Code: ' + str(r.status_code)
50+
print 'Status Code: {code}'.format(code=r.status_code)
5151
print r.json()
5252

5353
if __name__ == '__main__':

REST_API_v2/EscalationPolicies/list_escalation_policies.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ def list_escalation_policies():
4242
url = 'https://api.pagerduty.com/escalation_policies'
4343
headers = {
4444
'Accept': 'application/vnd.pagerduty+json;version=2',
45-
'Authorization': 'Token token=' + API_KEY
45+
'Authorization': 'Token token={token}'.format(token=API_KEY)
4646
}
4747
payload = {
4848
'query': QUERY,
@@ -52,7 +52,7 @@ def list_escalation_policies():
5252
'sort_by': SORT_BY
5353
}
5454
r = requests.get(url, headers=headers, params=payload)
55-
print 'Status Code: ' + str(r.status_code)
55+
print 'Status Code: {code}'.format(code=r.status_code)
5656
print r.json()
5757

5858
if __name__ == '__main__':

REST_API_v2/EscalationPolicies/update_escalation_policy.py

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -40,21 +40,25 @@
4040
SUMMARY = 'Insert resource description here'
4141
REPEAT_ENABLED = True
4242
NUM_LOOPS = 3
43-
ESCALATION_RULES = [{
44-
'escalation_delay_in_minutes': 30,
45-
'targets': [{
46-
'type': 'schedule',
47-
'id': 'PTC959G'
48-
}]
49-
}]
43+
ESCALATION_RULES = [
44+
{
45+
'escalation_delay_in_minutes': 30,
46+
'targets': [
47+
{
48+
'type': 'schedule',
49+
'id': 'PTC959G'
50+
}
51+
]
52+
}
53+
]
5054
SERVICES = []
5155

5256

5357
def update_escalation_policy():
54-
url = 'https://api.pagerduty.com/escalation_policies/' + ID
58+
url = 'https://api.pagerduty.com/escalation_policies/{id}'.format(id=ID)
5559
headers = {
5660
'Accept': 'application/vnd.pagerduty+json;version=2',
57-
'Authorization': 'Token token=' + API_KEY,
61+
'Authorization': 'Token token={token}'.format(token=API_KEY),
5862
'Content-type': 'application/json'
5963
}
6064
payload = {
@@ -69,7 +73,7 @@ def update_escalation_policy():
6973
}
7074
}
7175
r = requests.put(url, headers=headers, data=json.dumps(payload))
72-
print 'Status Code: ' + str(r.status_code)
76+
print 'Status Code: {code}'.format(code=r.status_code)
7377
print r.json()
7478

7579
if __name__ == '__main__':

0 commit comments

Comments
 (0)