diff options
author | Nejc Habjan <nejc.habjan@siemens.com> | 2022-07-24 01:45:46 +0200 |
---|---|---|
committer | John Villalovos <john@sodarock.com> | 2022-07-24 14:19:39 -0700 |
commit | 8703324dc21a30757e15e504b7d20472f25d2ab9 (patch) | |
tree | ee7c3105edb9eacc9e507d5f9f7f68e987f92ec4 /gitlab/v4/objects | |
parent | 4882cb22f55c41d8495840110be2d338b5545a04 (diff) | |
download | gitlab-8703324dc21a30757e15e504b7d20472f25d2ab9.tar.gz |
feat(issues): add support for issue reorder API
Diffstat (limited to 'gitlab/v4/objects')
-rw-r--r-- | gitlab/v4/objects/issues.py | 34 |
1 files changed, 33 insertions, 1 deletions
diff --git a/gitlab/v4/objects/issues.py b/gitlab/v4/objects/issues.py index 736bb5c..b1888cb 100644 --- a/gitlab/v4/objects/issues.py +++ b/gitlab/v4/objects/issues.py @@ -1,4 +1,4 @@ -from typing import Any, cast, Dict, Tuple, TYPE_CHECKING, Union +from typing import Any, cast, Dict, Optional, Tuple, TYPE_CHECKING, Union from gitlab import cli from gitlab import exceptions as exc @@ -140,6 +140,38 @@ class ProjectIssue( assert isinstance(server_data, dict) self._update_attrs(server_data) + @cli.register_custom_action("ProjectIssue", ("move_after_id", "move_before_id")) + @exc.on_http_error(exc.GitlabUpdateError) + def reorder( + self, + move_after_id: Optional[int] = None, + move_before_id: Optional[int] = None, + **kwargs: Any, + ) -> None: + """Reorder an issue on a board. + + Args: + move_after_id: ID of an issue that should be placed after this issue + move_before_id: ID of an issue that should be placed before this issue + **kwargs: Extra options to send to the server (e.g. sudo) + + Raises: + GitlabAuthenticationError: If authentication is not correct + GitlabUpdateError: If the issue could not be reordered + """ + path = f"{self.manager.path}/{self.encoded_id}/reorder" + data: Dict[str, Any] = {} + + if move_after_id is not None: + data["move_after_id"] = move_after_id + if move_before_id is not None: + data["move_before_id"] = move_before_id + + server_data = self.manager.gitlab.http_put(path, post_data=data, **kwargs) + if TYPE_CHECKING: + assert isinstance(server_data, dict) + self._update_attrs(server_data) + @cli.register_custom_action("ProjectIssue") @exc.on_http_error(exc.GitlabGetError) def related_merge_requests(self, **kwargs: Any) -> Dict[str, Any]: |