Skip to content

Commit ecf5ba0

Browse files
chore: implement pagination for work item relation definitions endpoint
1 parent 57036aa commit ecf5ba0

2 files changed

Lines changed: 22 additions & 3 deletions

File tree

plane/api/work_item_relation_definitions.py

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
from ..models.work_item_relation_definitions import (
44
CreateWorkItemRelationDefinition,
5+
PaginatedWorkItemRelationDefinitionResponse,
56
UpdateWorkItemRelationDefinition,
67
WorkItemRelationDefinition,
78
)
@@ -19,25 +20,33 @@ def list(
1920
workspace_slug: str,
2021
is_default: bool | None = None,
2122
is_active: bool | None = None,
22-
) -> list[WorkItemRelationDefinition]:
23-
"""List all work item relation definitions in the workspace.
23+
per_page: int | None = None,
24+
cursor: str | None = None,
25+
) -> PaginatedWorkItemRelationDefinitionResponse:
26+
"""List work item relation definitions in the workspace.
2427
2528
Args:
2629
workspace_slug: The workspace slug identifier
2730
is_default: Optional filter by default status
2831
is_active: Optional filter by active status
32+
per_page: Number of results per page (default 100)
33+
cursor: Pagination cursor from a previous response's next_cursor
2934
"""
3035
params: dict[str, Any] = {}
3136
if is_default is not None:
3237
params["is_default"] = str(is_default).lower()
3338
if is_active is not None:
3439
params["is_active"] = str(is_active).lower()
40+
if per_page is not None:
41+
params["per_page"] = per_page
42+
if cursor is not None:
43+
params["cursor"] = cursor
3544

3645
response = self._get(
3746
f"{workspace_slug}/work-item-relation-definitions/",
3847
params=params if params else None,
3948
)
40-
return [WorkItemRelationDefinition.model_validate(item) for item in response]
49+
return PaginatedWorkItemRelationDefinitionResponse.model_validate(response)
4150

4251
def create(
4352
self, workspace_slug: str, data: CreateWorkItemRelationDefinition

plane/models/work_item_relation_definitions.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
from pydantic import BaseModel, ConfigDict
44

5+
from .pagination import PaginatedResponse
6+
57

68
class WorkItemRelationDefinition(BaseModel):
79
"""Work item relation definition response model."""
@@ -47,3 +49,11 @@ class UpdateWorkItemRelationDefinition(BaseModel):
4749
is_active: bool | None = None
4850
color: str | None = None
4951
sort_order: float | None = None
52+
53+
54+
class PaginatedWorkItemRelationDefinitionResponse(PaginatedResponse):
55+
"""Paginated response for work item relation definitions."""
56+
57+
model_config = ConfigDict(extra="allow", populate_by_name=True)
58+
59+
results: list[WorkItemRelationDefinition]

0 commit comments

Comments
 (0)