Skip to content

Commit d0553d4

Browse files
authored
Jira: Adjust example notifications (#576)
1 parent 958f97d commit d0553d4

File tree

3 files changed

+68
-55
lines changed

3 files changed

+68
-55
lines changed

atlassian/jira.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1841,6 +1841,10 @@ def get_priority_by_id(self, priority_id):
18411841
url = 'rest/api/2/priority/{}'.format(priority_id)
18421842
return self.get(url)
18431843

1844+
#######################################################################################################
1845+
# Workflow
1846+
# Reference: https://docs.atlassian.com/software/jira/docs/api/REST/8.5.0/#api/2/workflow
1847+
#######################################################################################################
18441848
def get_all_workflows(self):
18451849
"""
18461850
Provide all workflows for application admin
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
from atlassian import Jira
2+
3+
jira = Jira(
4+
url='http://localhost:8090',
5+
username='admin',
6+
password='admin')
7+
8+
9+
def compare_dicts(dict1, dict2, print_diffs=False):
10+
count = 0
11+
hint = []
12+
if len(dict1) != len(dict2) and len(dict1) != len(dict2) + 1 and len(dict2) != len(dict1) + 1:
13+
return False
14+
15+
for key in dict1:
16+
if dict1[key] != dict2.get(key):
17+
count += 1
18+
hint.append(key)
19+
if count > 1:
20+
return False
21+
line = None
22+
if len(dict1) != len(dict2):
23+
line = 'Different size'
24+
if count == 1:
25+
line = 'Different: ' + hint[0]
26+
if line and print_diffs:
27+
print(line)
28+
return True
29+
30+
31+
def review():
32+
notification_scheme_dict = {}
33+
all_notification_schemes_dict = {}
34+
35+
notification_schemes_ids = jira.get_notification_schemes()
36+
names = []
37+
38+
for notification_schemes_id in notification_schemes_ids['values']:
39+
40+
notification_id = notification_schemes_id['id']
41+
notification_schemes = jira.get_notification_scheme(notification_id, 'all')
42+
names.append(notification_schemes['name'])
43+
notification_scheme_dict = {}
44+
45+
for scheme in notification_schemes['notificationSchemeEvents']:
46+
notification_types = []
47+
48+
for notificationType in scheme['notifications']:
49+
notification_types.append(notificationType['notificationType'])
50+
notification_scheme_dict[scheme['event']['name']] = notification_types
51+
all_notification_schemes_dict[notification_schemes['name']] = notification_scheme_dict
52+
53+
show_diffs = False
54+
for i in range(len(names)):
55+
for j in range(len(names)):
56+
if names and i < j:
57+
if compare_dicts(all_notification_schemes_dict[names[i]],
58+
all_notification_schemes_dict[names[j]],
59+
print_diffs=show_diffs):
60+
print('| same |', names[i], ' | ', names[j], '|')
61+
62+
63+
if __name__ == '__main__':
64+
review()

examples/jira/jira-notification_schemes_duplicates.py

Lines changed: 0 additions & 55 deletions
This file was deleted.

0 commit comments

Comments
 (0)