diff --git a/jira/client.py b/jira/client.py index 9b41605fe..4f5aac7d7 100644 --- a/jira/client.py +++ b/jira/client.py @@ -1735,6 +1735,8 @@ def create_customer_request( def createmeta_issuetypes( self, projectIdOrKey: str | int, + startAt: int = 0, + maxResults: int = 50, ) -> dict[str, Any]: """Get the issue types metadata for a given project, required to create issues. @@ -1743,6 +1745,10 @@ def createmeta_issuetypes( Args: projectIdOrKey (Union[str, int]): id or key of the project for which to get the metadata. + startAt (int): Index of the first issue to return. (Default: ``0``) + maxResults (int): Maximum number of issues to return. + Total number of results is available in the ``total`` attribute of the returned :class:`ResultList`. + If maxResults evaluates to False, it will try to get all issues in batches. (Default: ``50``) Returns: Dict[str, Any] @@ -1753,12 +1759,20 @@ def createmeta_issuetypes( "Use 'createmeta' instead." ) - return self._get_json(f"issue/createmeta/{projectIdOrKey}/issuetypes") + return self._get_json( + f"issue/createmeta/{projectIdOrKey}/issuetypes", + params={ + "startAt": startAt, + "maxResults": maxResults, + }, + ) def createmeta_fieldtypes( self, projectIdOrKey: str | int, issueTypeId: str | int, + startAt: int = 0, + maxResults: int = 50, ) -> dict[str, Any]: """Get the field metadata for a given project and issue type, required to create issues. @@ -1768,6 +1782,10 @@ def createmeta_fieldtypes( Args: projectIdOrKey (Union[str, int]): id or key of the project for which to get the metadata. issueTypeId (Union[str, int]): id of the issue type for which to get the metadata. + startAt (int): Index of the first issue to return. (Default: ``0``) + maxResults (int): Maximum number of issues to return. + Total number of results is available in the ``total`` attribute of the returned :class:`ResultList`. + If maxResults evaluates to False, it will try to get all issues in batches. (Default: ``50``) Returns: Dict[str, Any] @@ -1779,7 +1797,11 @@ def createmeta_fieldtypes( ) return self._get_json( - f"issue/createmeta/{projectIdOrKey}/issuetypes/{issueTypeId}" + f"issue/createmeta/{projectIdOrKey}/issuetypes/{issueTypeId}", + params={ + "startAt": startAt, + "maxResults": maxResults, + }, ) def createmeta( diff --git a/tests/test_client.py b/tests/test_client.py index 5dfa1f401..8edb0bef7 100644 --- a/tests/test_client.py +++ b/tests/test_client.py @@ -250,3 +250,22 @@ def test_cookie_auth_retry(): ) # THEN: We don't get a RecursionError and only call the reset_function once mock_reset_func.assert_called_once() + + +def test_createmeta_issuetypes_pagination(cl_normal, slug): + """Test createmeta_issuetypes pagination kwargs""" + issue_types_resp = cl_normal.createmeta_issuetypes(slug, startAt=50, maxResults=100) + assert issue_types_resp["startAt"] == 50 + assert issue_types_resp["maxResults"] == 100 + + +def test_createmeta_fieldtypes_pagination(cl_normal, slug): + """Test createmeta_fieldtypes pagination kwargs""" + issue_types = cl_normal.createmeta_issuetypes(slug) + assert issue_types["total"] + issue_type_id = issue_types["values"][-1]["id"] + field_types_resp = cl_normal.createmeta_fieldtypes( + projectIdOrKey=slug, issueTypeId=issue_type_id, startAt=50, maxResults=100 + ) + assert field_types_resp["startAt"] == 50 + assert field_types_resp["maxResults"] == 100