Skip to content

Commit 4960d8f

Browse files
authored
add backward compatibility for createmeta_issuetypes & createmeta_fieldtypes (#1838)
1 parent e8104ea commit 4960d8f

File tree

2 files changed

+99
-0
lines changed

2 files changed

+99
-0
lines changed

jira/client.py

+80
Original file line numberDiff line numberDiff line change
@@ -2076,6 +2076,86 @@ def _check_createmeta_issuetypes(self) -> None:
20762076
"Use 'createmeta' instead."
20772077
)
20782078

2079+
def createmeta_issuetypes(
2080+
self,
2081+
projectIdOrKey: str | int,
2082+
startAt: int = 0,
2083+
maxResults: int = 50,
2084+
) -> dict[str, Any]:
2085+
"""Get the issue types metadata for a given project, required to create issues.
2086+
2087+
.. deprecated:: 3.6.0
2088+
Use :func:`project_issue_types` instead.
2089+
2090+
This API was introduced in JIRA Server / DC 8.4 as a replacement for the more general purpose API 'createmeta'.
2091+
For details see: https://confluence.atlassian.com/jiracore/createmeta-rest-endpoint-to-be-removed-975040986.html
2092+
2093+
Args:
2094+
projectIdOrKey (Union[str, int]): id or key of the project for which to get the metadata.
2095+
startAt (int): Index of the first issue to return. (Default: ``0``)
2096+
maxResults (int): Maximum number of issues to return.
2097+
Total number of results is available in the ``total`` attribute of the returned :class:`ResultList`.
2098+
If maxResults evaluates to False, it will try to get all issues in batches. (Default: ``50``)
2099+
2100+
Returns:
2101+
Dict[str, Any]
2102+
"""
2103+
warnings.warn(
2104+
"'createmeta_issuetypes' is deprecated and will be removed in future releases."
2105+
"Use 'project_issue_types' instead.",
2106+
DeprecationWarning,
2107+
stacklevel=2,
2108+
)
2109+
self._check_createmeta_issuetypes()
2110+
return self._get_json(
2111+
f"issue/createmeta/{projectIdOrKey}/issuetypes",
2112+
params={
2113+
"startAt": startAt,
2114+
"maxResults": maxResults,
2115+
},
2116+
)
2117+
2118+
def createmeta_fieldtypes(
2119+
self,
2120+
projectIdOrKey: str | int,
2121+
issueTypeId: str | int,
2122+
startAt: int = 0,
2123+
maxResults: int = 50,
2124+
) -> dict[str, Any]:
2125+
"""Get the field metadata for a given project and issue type, required to create issues.
2126+
2127+
.. deprecated:: 3.6.0
2128+
Use :func:`project_issue_fields` instead.
2129+
2130+
This API was introduced in JIRA Server / DC 8.4 as a replacement for the more general purpose API 'createmeta'.
2131+
For details see: https://confluence.atlassian.com/jiracore/createmeta-rest-endpoint-to-be-removed-975040986.html
2132+
2133+
Args:
2134+
projectIdOrKey (Union[str, int]): id or key of the project for which to get the metadata.
2135+
issueTypeId (Union[str, int]): id of the issue type for which to get the metadata.
2136+
startAt (int): Index of the first issue to return. (Default: ``0``)
2137+
maxResults (int): Maximum number of issues to return.
2138+
Total number of results is available in the ``total`` attribute of the returned :class:`ResultList`.
2139+
If maxResults evaluates to False, it will try to get all issues in batches. (Default: ``50``)
2140+
2141+
Returns:
2142+
Dict[str, Any]
2143+
"""
2144+
warnings.warn(
2145+
"'createmeta_fieldtypes' is deprecated and will be removed in future releases."
2146+
"Use 'project_issue_fields' instead.",
2147+
DeprecationWarning,
2148+
stacklevel=2,
2149+
)
2150+
self._check_createmeta_issuetypes()
2151+
return self._get_json(
2152+
f"issue/createmeta/{projectIdOrKey}/issuetypes/{issueTypeId}",
2153+
params={
2154+
"startAt": startAt,
2155+
"maxResults": maxResults,
2156+
},
2157+
)
2158+
20792159
def createmeta(
20802160
self,
20812161
projectKeys: tuple[str, str] | str | None = None,

tests/test_client.py

+19
Original file line numberDiff line numberDiff line change
@@ -318,6 +318,25 @@ def test_cookie_auth_retry():
318318
mock_reset_func.assert_called_once()
319319

320320

321+
def test_createmeta_issuetypes_pagination(cl_normal, slug):
322+
"""Test createmeta_issuetypes pagination kwargs"""
323+
issue_types_resp = cl_normal.createmeta_issuetypes(slug, startAt=50, maxResults=100)
324+
assert issue_types_resp["startAt"] == 50
325+
assert issue_types_resp["maxResults"] == 100
326+
327+
328+
def test_createmeta_fieldtypes_pagination(cl_normal, slug):
329+
"""Test createmeta_fieldtypes pagination kwargs"""
330+
issue_types = cl_normal.createmeta_issuetypes(slug)
331+
assert issue_types["total"]
332+
issue_type_id = issue_types["values"][-1]["id"]
333+
field_types_resp = cl_normal.createmeta_fieldtypes(
334+
projectIdOrKey=slug, issueTypeId=issue_type_id, startAt=50, maxResults=100
335+
)
336+
assert field_types_resp["startAt"] == 50
337+
assert field_types_resp["maxResults"] == 100
338+
339+
321340
@pytest.mark.parametrize(
322341
"mock_client_method", ["mock_cloud_only_method", "mock_experimental_method"]
323342
)

0 commit comments

Comments
 (0)