From f5a857d5d7093b8afa3c4ea242ac9923a64ea759 Mon Sep 17 00:00:00 2001 From: Gonchik Tsymzhitov Date: Mon, 22 Jan 2024 01:49:38 +0300 Subject: [PATCH] extend jira meta functions (#1308) --- atlassian/VERSION | 2 +- .../bitbucket/server/projects/__init__.py | 4 +- atlassian/jira.py | 38 +++++++++++++++++-- docs/jira.rst | 9 +++++ 4 files changed, 46 insertions(+), 7 deletions(-) diff --git a/atlassian/VERSION b/atlassian/VERSION index 16e598bbc..1b36d3211 100644 --- a/atlassian/VERSION +++ b/atlassian/VERSION @@ -1 +1 @@ -3.41.8 +3.41.9 diff --git a/atlassian/bitbucket/server/projects/__init__.py b/atlassian/bitbucket/server/projects/__init__.py index 1fae7cb78..1e3d64f09 100644 --- a/atlassian/bitbucket/server/projects/__init__.py +++ b/atlassian/bitbucket/server/projects/__init__.py @@ -20,11 +20,11 @@ def create(self, name, key, description, avatar=None): Note that the avatar has to be embedded as either a data-url or a URL to an external image as shown in the examples below: - w.projects.create( "Mars Project", "MARS", "Software for colonizing mars.", + w.projects.create( "Mars Project", "MARS", "Software for colonizing Mars.", avatar="data:image/gif;base64,R0lGODlhEAAQAMQAAORHHOVSKudfOulrSOp3WOyDZu6QdvCchPGolfO0o/..." ) - w.projects.create( "Mars Project", "MARS", "Software for colonizing mars.", + w.projects.create( "Mars Project", "MARS", "Software for colonizing Mars.", avatar="http://i.imgur.com/72tRx4w.gif" ) diff --git a/atlassian/jira.py b/atlassian/jira.py index 87323a4ec..96362606a 100644 --- a/atlassian/jira.py +++ b/atlassian/jira.py @@ -1064,13 +1064,43 @@ def issue_createmeta(self, project, expand="projects.issuetypes.fields"): url = self.resource_url("issue/createmeta?projectKeys={}".format(project)) return self.get(url, params=params) - def issue_createmeta_issuetypes(self, project): + def issue_createmeta_issuetypes(self, project, start=None, limit=None): + """ + Get create metadata issue types for a project + Returns a page of issue type metadata for a specified project. + Use the information to populate the requests in Create issue and Create issues. + :param project: + :param start: default: 0 + :param limit: default: 50 + :return: + """ url = self.resource_url("issue/createmeta/{}/issuetypes".format(project)) - return self.get(url) + params = {} + if start: + params["startAt"] = start + if limit: + params["maxResults"] = limit + return self.get(url, params=params) - def issue_createmeta_fieldtypes(self, project, issue_type_id): + def issue_createmeta_fieldtypes(self, project, issue_type_id, start=None, limit=None): + """ + Get create field metadata for a project and issue type id + Returns a page of field metadata for a specified project and issuetype id. + Use the information to populate the requests in Create issue and Create issues. + This operation can be accessed anonymously. + :param project: + :param issue_type_id: + :param start: default: 0 + :param limit: default: 50 + :return: + """ url = self.resource_url("issue/createmeta/{}/issuetypes/{}".format(project, issue_type_id)) - return self.get(url) + params = {} + if start: + params["startAt"] = start + if limit: + params["maxResults"] = limit + return self.get(url, params=params) def issue_editmeta(self, key): base_url = self.resource_url("issue") diff --git a/docs/jira.rst b/docs/jira.rst index 105b3e945..831bd371c 100644 --- a/docs/jira.rst +++ b/docs/jira.rst @@ -272,6 +272,15 @@ Manage issues # Get Issue Edit Meta jira.issue_editmeta(issue_key) + # Get issue create meta, deprecated on Cloud and from Jira 9.0 + jira.issue_createmeta(project, expand="projects.issuetypes.fields") + + # Get create metadata issue types for a project + jira.issue_createmeta_issuetypes(project, start=None, limit=None) + + # Get create field metadata for a project and issue type id + jira.issue_createmeta_fieldtypes(self, project, issue_type_id, start=None, limit=None) + # Create Issue Link data = { "type": {"name": "Duplicate" },