From b73a5a123fc9d2dfaeabdf400019bfefdee04383 Mon Sep 17 00:00:00 2001 From: austinmh12 <45670765+austinmh12@users.noreply.github.com> Date: Wed, 16 Oct 2019 09:47:06 -0400 Subject: [PATCH 1/2] Added create_custom_field Added a function to create a custom field --- atlassian/jira.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/atlassian/jira.py b/atlassian/jira.py index 8bf71d706..9294173cf 100644 --- a/atlassian/jira.py +++ b/atlassian/jira.py @@ -577,6 +577,15 @@ def get_custom_fields(self, search=None, start=1, limit=50): if limit: params['maxResults'] = limit return self.get(url, params=params) + + def create_custom_field(self, name, type, search_key=None, description=None): + url = 'rest/api/2/field' + data = {'name': name, 'type': type} + if search_key: + data['search_key'] = search_key + if description: + data['description'] = description + return self.post(url, data=data) def get_all_available_screen_fields(self, screen_id): """ From c5f558a3d35444549f0c5dfbfce9c583ba896702 Mon Sep 17 00:00:00 2001 From: austinmh12 <45670765+austinmh12@users.noreply.github.com> Date: Wed, 16 Oct 2019 09:56:20 -0400 Subject: [PATCH 2/2] Added doc string --- atlassian/jira.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/atlassian/jira.py b/atlassian/jira.py index 9294173cf..128b3b79c 100644 --- a/atlassian/jira.py +++ b/atlassian/jira.py @@ -579,6 +579,13 @@ def get_custom_fields(self, search=None, start=1, limit=50): return self.get(url, params=params) def create_custom_field(self, name, type, search_key=None, description=None): + """ + Creates a custom field with the given name and type + :param name: str + :param type: str, like 'com.atlassian.jira.plugin.system.customfieldtypes:textfield' + :param search_key: str, like above + :param description: str + """ url = 'rest/api/2/field' data = {'name': name, 'type': type} if search_key: