Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 24 additions & 4 deletions atlassian/jira.py
Original file line number Diff line number Diff line change
Expand Up @@ -530,13 +530,33 @@ def get_project_permission_scheme(self, project_id_or_key, expand=None):
:param expand: str
:return: data of project permission scheme
"""
if expand is None:
url = 'rest/api/2/project/{}/permissionscheme'.format(project_id_or_key)
else:
url = 'rest/api/2/project/{0}/permissionscheme?expand={1}'.format(project_id_or_key, expand)
url = 'rest/api/2/project/{}/permissionscheme'.format(project_id_or_key)
params={}
if expand:
params['expand'] = expand
return self.get(url, params=params)

def get_notification_schemes(self):
"""
Returns a paginated list of notification schemes
"""
url = 'rest/api/2/notificationscheme'
return self.get(url)

def get_notification_scheme(self, notification_scheme_id, expand=None):
"""
Returns a full representation of the notification scheme for the given id.
Use 'expand' to get details
:param notification_scheme_id: Id of scheme u wanna work with
:param expand: str
:return: full representation of the notification scheme for the given id
"""
url = 'rest/api/2/notificationscheme/{}'.format(notification_scheme_id)
params = {}
if expand:
params['expand'] = expand
return self.get(url, params=params)

def create_issue_type(self, name, description='', type='standard'):
"""
Create a new issue type
Expand Down
55 changes: 55 additions & 0 deletions examples/jira/jira-notification_schemes_duplicates.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
from atlassian import Jira
import requests

jira = Jira(
url='http://localhost:8090',
username='admin',
password='admin')


def compare_dicts(dict1, dict2):
count = 0
hint = []
if len(dict1) != len(dict2) and len(dict1) != len(dict2) + 1 and len(dict2) != len(dict1) + 1:
return False

for key in dict1:
if dict1[key] != dict2.get(key):
count += 1
hint.append(key)
if count > 1:
return False
if len(dict1) != len(dict2):
print('(Different size')
if count == 1:
print('(Different: ', hint[0])

return True

notificationscheme_dict = {}
all_notificationschemes_dict = {}

notificationschemes_ids = jira.get_notification_schemes()
names = []

for notificationschemes_id in notificationschemes_ids['values']:

id = notificationschemes_id['id']
notificationschemes = jira.get_notification_scheme(id, 'all')
names.append(notificationschemes['name'])
notificationscheme_dict = {}

for scheme in notificationschemes['notificationSchemeEvents']:
notificationTypes = []

for notificationType in scheme['notifications']:
notificationTypes.append(notificationType['notificationType'])
notificationscheme_dict[scheme['event']['name']] = notificationTypes
all_notificationschemes_dict[notificationschemes['name']] = notificationscheme_dict

for i in range(len(names)):
for j in range(len(names)):
if names and i < j:
if compare_dicts(all_notificationschemes_dict[names[i]], all_notificationschemes_dict[names[j]]):
print(names[i], '/', names[j])
print('same) \n -----------------------------------------------------------------')