Skip to content

Commit ef5feb4

Browse files
Oliver Blasiusnejch
authored andcommitted
feat: add resource iteration events (see https://docs.gitlab.com/ee/api/resource_iteration_events.html)
1 parent e88d34e commit ef5feb4

File tree

4 files changed

+80
-0
lines changed

4 files changed

+80
-0
lines changed

docs/gl_objects/issues.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,10 @@ Get the list of participants::
203203

204204
users = issue.participants()
205205

206+
Get the list of iteration events::
207+
208+
iteration_events = issue.resource_iteration_events.list()
209+
206210
Issue links
207211
===========
208212

gitlab/v4/objects/events.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515
"ProjectIssueResourceMilestoneEvent",
1616
"ProjectIssueResourceMilestoneEventManager",
1717
"ProjectIssueResourceStateEvent",
18+
"ProjectIssueResourceIterationEventManager",
19+
"ProjectIssueResourceIterationEvent",
1820
"ProjectIssueResourceStateEventManager",
1921
"ProjectMergeRequestResourceLabelEvent",
2022
"ProjectMergeRequestResourceLabelEventManager",
@@ -116,6 +118,23 @@ def get(
116118
)
117119

118120

121+
class ProjectIssueResourceIterationEvent(RESTObject):
122+
pass
123+
124+
125+
class ProjectIssueResourceIterationEventManager(RetrieveMixin, RESTManager):
126+
_path = "/projects/{project_id}/issues/{issue_iid}/resource_iteration_events"
127+
_obj_cls = ProjectIssueResourceIterationEvent
128+
_from_parent_attrs = {"project_id": "project_id", "issue_iid": "iid"}
129+
130+
def get(
131+
self, id: Union[str, int], lazy: bool = False, **kwargs: Any
132+
) -> ProjectIssueResourceIterationEvent:
133+
return cast(
134+
ProjectIssueResourceIterationEvent, super().get(id=id, lazy=lazy, **kwargs)
135+
)
136+
137+
119138
class ProjectMergeRequestResourceLabelEvent(RESTObject):
120139
pass
121140

gitlab/v4/objects/issues.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
from .award_emojis import ProjectIssueAwardEmojiManager # noqa: F401
2424
from .discussions import ProjectIssueDiscussionManager # noqa: F401
2525
from .events import ( # noqa: F401
26+
ProjectIssueResourceIterationEventManager,
2627
ProjectIssueResourceLabelEventManager,
2728
ProjectIssueResourceMilestoneEventManager,
2829
ProjectIssueResourceStateEventManager,
@@ -119,6 +120,7 @@ class ProjectIssue(
119120
resourcelabelevents: ProjectIssueResourceLabelEventManager
120121
resourcemilestoneevents: ProjectIssueResourceMilestoneEventManager
121122
resourcestateevents: ProjectIssueResourceStateEventManager
123+
resource_iteration_events: ProjectIssueResourceIterationEventManager
122124

123125
@cli.register_custom_action("ProjectIssue", ("to_project_id",))
124126
@exc.on_http_error(exc.GitlabUpdateError)
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
"""
2+
GitLab API: https://docs.gitlab.com/ee/api/resource_iteration_events.html
3+
"""
4+
5+
import pytest
6+
import responses
7+
8+
from gitlab.v4.objects import ProjectIssueResourceIterationEvent
9+
10+
issue_event_content = {"id": 1, "resource_type": "Issue"}
11+
12+
13+
@pytest.fixture()
14+
def resp_list_project_issue_iteration_events():
15+
with responses.RequestsMock() as rsps:
16+
rsps.add(
17+
method=responses.GET,
18+
url="http://localhost/api/v4/projects/1/issues/1/resource_iteration_events",
19+
json=[issue_event_content],
20+
content_type="application/json",
21+
status=200,
22+
)
23+
yield rsps
24+
25+
26+
@pytest.fixture()
27+
def resp_get_project_issue_iteration_event():
28+
with responses.RequestsMock() as rsps:
29+
rsps.add(
30+
method=responses.GET,
31+
url="http://localhost/api/v4/projects/1/issues/1/resource_iteration_events/1",
32+
json=issue_event_content,
33+
content_type="application/json",
34+
status=200,
35+
)
36+
yield rsps
37+
38+
39+
def test_list_project_issue_iteration_events(
40+
project_issue, resp_list_project_issue_iteration_events
41+
):
42+
iteration_events = project_issue.resource_iteration_events.list()
43+
assert isinstance(iteration_events, list)
44+
45+
iteration_event = iteration_events[0]
46+
assert isinstance(iteration_event, ProjectIssueResourceIterationEvent)
47+
assert iteration_event.resource_type == "Issue"
48+
49+
50+
def test_get_project_issue_iteration_event(
51+
project_issue, resp_get_project_issue_iteration_event
52+
):
53+
iteration_event = project_issue.resource_iteration_events.get(1)
54+
assert isinstance(iteration_event, ProjectIssueResourceIterationEvent)
55+
assert iteration_event.resource_type == "Issue"

0 commit comments

Comments
 (0)