diff --git a/atlassian/jira.py b/atlassian/jira.py index 944978886..5914c25bc 100644 --- a/atlassian/jira.py +++ b/atlassian/jira.py @@ -1841,6 +1841,10 @@ def get_priority_by_id(self, priority_id): url = 'rest/api/2/priority/{}'.format(priority_id) return self.get(url) + ####################################################################################################### + # Workflow + # Reference: https://docs.atlassian.com/software/jira/docs/api/REST/8.5.0/#api/2/workflow + ####################################################################################################### def get_all_workflows(self): """ Provide all workflows for application admin diff --git a/examples/jira/jira-notification-schemes-duplicates.py b/examples/jira/jira-notification-schemes-duplicates.py new file mode 100644 index 000000000..325817f7a --- /dev/null +++ b/examples/jira/jira-notification-schemes-duplicates.py @@ -0,0 +1,64 @@ +from atlassian import Jira + +jira = Jira( + url='http://localhost:8090', + username='admin', + password='admin') + + +def compare_dicts(dict1, dict2, print_diffs=False): + 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 + line = None + if len(dict1) != len(dict2): + line = 'Different size' + if count == 1: + line = 'Different: ' + hint[0] + if line and print_diffs: + print(line) + return True + + +def review(): + notification_scheme_dict = {} + all_notification_schemes_dict = {} + + notification_schemes_ids = jira.get_notification_schemes() + names = [] + + for notification_schemes_id in notification_schemes_ids['values']: + + notification_id = notification_schemes_id['id'] + notification_schemes = jira.get_notification_scheme(notification_id, 'all') + names.append(notification_schemes['name']) + notification_scheme_dict = {} + + for scheme in notification_schemes['notificationSchemeEvents']: + notification_types = [] + + for notificationType in scheme['notifications']: + notification_types.append(notificationType['notificationType']) + notification_scheme_dict[scheme['event']['name']] = notification_types + all_notification_schemes_dict[notification_schemes['name']] = notification_scheme_dict + + show_diffs = False + for i in range(len(names)): + for j in range(len(names)): + if names and i < j: + if compare_dicts(all_notification_schemes_dict[names[i]], + all_notification_schemes_dict[names[j]], + print_diffs=show_diffs): + print('| same |', names[i], ' | ', names[j], '|') + + +if __name__ == '__main__': + review() diff --git a/examples/jira/jira-notification_schemes_duplicates.py b/examples/jira/jira-notification_schemes_duplicates.py deleted file mode 100644 index a8a9f6834..000000000 --- a/examples/jira/jira-notification_schemes_duplicates.py +++ /dev/null @@ -1,55 +0,0 @@ -from atlassian import Jira - -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 -----------------------------------------------------------------')