Skip to content

Commit 2f2fd03

Browse files
committed
feat(api): New iteration API
Add iteration API with the ability to get the list of related issues.
1 parent 265dbbd commit 2f2fd03

File tree

1 file changed

+80
-0
lines changed

1 file changed

+80
-0
lines changed

gitlab/v4/objects/__init__.py

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1084,6 +1084,7 @@ class GroupIssueManager(ListMixin, RESTManager):
10841084
"state",
10851085
"labels",
10861086
"milestone",
1087+
"iteration",
10871088
"order_by",
10881089
"sort",
10891090
"iids",
@@ -1296,6 +1297,40 @@ class GroupMilestoneManager(CRUDMixin, RESTManager):
12961297
_list_filters = ("iids", "state", "search")
12971298

12981299

1300+
class GroupIteration(SaveMixin, ObjectDeleteMixin, RESTObject):
1301+
_short_print_attr = "title"
1302+
1303+
@cli.register_custom_action("GroupIteration")
1304+
@exc.on_http_error(exc.GitlabListError)
1305+
def issues(self, **kwargs):
1306+
"""List issues related to this Iteration.
1307+
1308+
Args:
1309+
**kwargs: Extra options to send to the server (e.g. sudo)
1310+
1311+
Raises:
1312+
GitlabAuthenticationError: If authentication is not correct
1313+
GitlabListError: If the list could not be retrieved
1314+
1315+
Returns:
1316+
The list of issues
1317+
"""
1318+
manager = GroupIssueManager(self.manager.gitlab, parent=self.manager._parent)
1319+
return manager.list(iteration_id=self.get_id(), **kwargs)
1320+
1321+
1322+
class GroupIterationManager(CRUDMixin, RESTManager):
1323+
_path = "/groups/%(group_id)s/iterations"
1324+
_obj_cls = GroupIteration
1325+
_from_parent_attrs = {"group_id": "id"}
1326+
_create_attrs = (("title",), ("description", "due_date", "start_date"))
1327+
_update_attrs = (
1328+
tuple(),
1329+
("title", "description", "due_date", "start_date", "state"),
1330+
)
1331+
_list_filters = ("iids", "state", "search")
1332+
1333+
12991334
class GroupNotificationSettings(NotificationSettings):
13001335
pass
13011336

@@ -1396,6 +1431,7 @@ class Group(SaveMixin, ObjectDeleteMixin, RESTObject):
13961431
("members", "GroupMemberManager"),
13971432
("mergerequests", "GroupMergeRequestManager"),
13981433
("milestones", "GroupMilestoneManager"),
1434+
("iterations", "GroupIterationManager"),
13991435
("notificationsettings", "GroupNotificationSettingsManager"),
14001436
("packages", "GroupPackageManager"),
14011437
("projects", "GroupProjectManager"),
@@ -1648,6 +1684,7 @@ class IssueManager(ListMixin, RESTManager):
16481684
"state",
16491685
"labels",
16501686
"milestone",
1687+
"iteration",
16511688
"scope",
16521689
"author_id",
16531690
"assignee_id",
@@ -2781,6 +2818,7 @@ class ProjectIssueManager(CRUDMixin, RESTManager):
27812818
"state",
27822819
"labels",
27832820
"milestone",
2821+
"iteration",
27842822
"scope",
27852823
"author_id",
27862824
"assignee_id",
@@ -2801,6 +2839,7 @@ class ProjectIssueManager(CRUDMixin, RESTManager):
28012839
"assignee_ids",
28022840
"assignee_id",
28032841
"milestone_id",
2842+
"iteration_id",
28042843
"labels",
28052844
"created_at",
28062845
"due_date",
@@ -2817,6 +2856,7 @@ class ProjectIssueManager(CRUDMixin, RESTManager):
28172856
"assignee_ids",
28182857
"assignee_id",
28192858
"milestone_id",
2859+
"iteration_id",
28202860
"labels",
28212861
"state_event",
28222862
"updated_at",
@@ -3576,6 +3616,45 @@ class ProjectMilestoneManager(CRUDMixin, RESTManager):
35763616
_list_filters = ("iids", "state", "search")
35773617

35783618

3619+
class ProjectIteration(SaveMixin, ObjectDeleteMixin, RESTObject):
3620+
_short_print_attr = "title"
3621+
3622+
@cli.register_custom_action("ProjectIteration")
3623+
@exc.on_http_error(exc.GitlabListError)
3624+
def issues(self, **kwargs):
3625+
"""List issues related to this milestone.
3626+
3627+
Args:
3628+
**kwargs: Extra options to send to the server (e.g. sudo)
3629+
3630+
Raises:
3631+
GitlabAuthenticationError: If authentication is not correct
3632+
GitlabListError: If the list could not be retrieved
3633+
3634+
Returns:
3635+
The list of issues
3636+
"""
3637+
3638+
manager = ProjectIssueManager(self.manager.gitlab, parent=self.manager._parent)
3639+
3640+
return manager.list(iteration_id=self.get_id(), **kwargs)
3641+
3642+
3643+
class ProjectIterationManager(CRUDMixin, RESTManager):
3644+
_path = "/projects/%(project_id)s/iterations"
3645+
_obj_cls = ProjectIteration
3646+
_from_parent_attrs = {"project_id": "id"}
3647+
_create_attrs = (
3648+
("title",),
3649+
("description", "due_date", "start_date", "state"),
3650+
)
3651+
_update_attrs = (
3652+
tuple(),
3653+
("title", "description", "due_date", "start_date", "state"),
3654+
)
3655+
_list_filters = ("iids", "state", "search")
3656+
3657+
35793658
class ProjectLabel(SubscribableMixin, SaveMixin, ObjectDeleteMixin, RESTObject):
35803659
_id_attr = "name"
35813660

@@ -4690,6 +4769,7 @@ class Project(SaveMixin, ObjectDeleteMixin, RESTObject):
46904769
("members", "ProjectMemberManager"),
46914770
("mergerequests", "ProjectMergeRequestManager"),
46924771
("milestones", "ProjectMilestoneManager"),
4772+
("iterations", "ProjectIterationManager"),
46934773
("notes", "ProjectNoteManager"),
46944774
("notificationsettings", "ProjectNotificationSettingsManager"),
46954775
("packages", "ProjectPackageManager"),

0 commit comments

Comments
 (0)