Skip to content

Commit 57036aa

Browse files
refactor: update work item relations endpoints to use direct identifiers for removal
1 parent cea30b8 commit 57036aa

3 files changed

Lines changed: 15 additions & 21 deletions

File tree

plane/api/work_items/custom_relations.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44

55
from ...models.work_items import (
66
CreateWorkItemCustomRelation,
7-
RemoveWorkItemCustomRelation,
87
WorkItemWithRelationType,
98
)
109
from ..base_resource import BaseResource
@@ -68,17 +67,16 @@ def remove(
6867
workspace_slug: str,
6968
project_id: str,
7069
work_item_id: str,
71-
data: RemoveWorkItemCustomRelation,
70+
related_work_item_id: str,
7271
) -> None:
7372
"""Remove a custom relation between this work item and a target.
7473
7574
Args:
7675
workspace_slug: The workspace slug identifier
7776
project_id: UUID of the project
7877
work_item_id: UUID of the work item
79-
data: Removal payload containing the related work item UUID
78+
related_work_item_id: UUID of the related work item to remove the relation with
8079
"""
81-
return self._post(
82-
f"{workspace_slug}/projects/{project_id}/work-items/{work_item_id}/work-item-relations/remove/",
83-
data.model_dump(exclude_none=True),
80+
self._delete(
81+
f"{workspace_slug}/projects/{project_id}/work-items/{work_item_id}/work-item-relations/{related_work_item_id}/"
8482
)

plane/api/work_items/dependencies.py

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44

55
from ...models.work_items import (
66
CreateWorkItemDependency,
7-
RemoveWorkItemDependency,
87
WorkItemDependencyResponse,
98
WorkItemWithRelationType,
109
)
@@ -32,7 +31,7 @@ def list(
3231
work_item_id: UUID of the work item
3332
"""
3433
response = self._get(
35-
f"{workspace_slug}/projects/{project_id}/work-items/{work_item_id}/relation-dependencies/"
34+
f"{workspace_slug}/projects/{project_id}/work-items/{work_item_id}/dependencies/"
3635
)
3736
return WorkItemDependencyResponse.model_validate(response)
3837

@@ -52,7 +51,7 @@ def create(
5251
data: Dependency creation payload
5352
"""
5453
response = self._post(
55-
f"{workspace_slug}/projects/{project_id}/work-items/{work_item_id}/relation-dependencies/",
54+
f"{workspace_slug}/projects/{project_id}/work-items/{work_item_id}/dependencies/",
5655
data.model_dump(exclude_none=True),
5756
)
5857
return [WorkItemWithRelationType.model_validate(item) for item in response]
@@ -62,17 +61,16 @@ def remove(
6261
workspace_slug: str,
6362
project_id: str,
6463
work_item_id: str,
65-
data: RemoveWorkItemDependency,
64+
related_work_item_id: str,
6665
) -> None:
6766
"""Remove a dependency relation between this work item and a target.
6867
6968
Args:
7069
workspace_slug: The workspace slug identifier
7170
project_id: UUID of the project
7271
work_item_id: UUID of the work item
73-
data: Removal payload containing the related work item UUID
72+
related_work_item_id: UUID of the related work item to remove the dependency with
7473
"""
75-
return self._post(
76-
f"{workspace_slug}/projects/{project_id}/work-items/{work_item_id}/relation-dependencies/remove/",
77-
data.model_dump(exclude_none=True),
74+
self._delete(
75+
f"{workspace_slug}/projects/{project_id}/work-items/{work_item_id}/dependencies/{related_work_item_id}/"
7876
)

tests/unit/test_work_item_relations.py

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,6 @@
1515
CreateWorkItem,
1616
CreateWorkItemCustomRelation,
1717
CreateWorkItemDependency,
18-
RemoveWorkItemCustomRelation,
19-
RemoveWorkItemDependency,
2018
WorkItemDependencyResponse,
2119
WorkItemWithRelationType,
2220
)
@@ -74,7 +72,7 @@ def custom_definition(client: PlaneClient, workspace_slug: str):
7472

7573

7674
class TestWorkItemDependencies:
77-
"""Tests for the /relation-dependencies/ endpoint."""
75+
"""Tests for the /dependencies/ endpoint."""
7876

7977
def test_list_dependencies_empty(
8078
self, client: PlaneClient, workspace_slug: str, project: Project, work_item_a
@@ -154,7 +152,7 @@ def test_remove_dependency(
154152
workspace_slug,
155153
project.id,
156154
work_item_a.id,
157-
RemoveWorkItemDependency(work_item_id=work_item_b.id),
155+
work_item_b.id,
158156
)
159157
result = client.work_items.dependencies.list(workspace_slug, project.id, work_item_a.id)
160158
blocking_ids = [wi.id for wi in result.blocking]
@@ -195,7 +193,7 @@ def test_create_all_dependency_types(
195193
workspace_slug,
196194
project.id,
197195
work_item_a.id,
198-
RemoveWorkItemDependency(work_item_id=work_item_b.id),
196+
work_item_b.id,
199197
)
200198
assert created_any
201199

@@ -292,7 +290,7 @@ def test_remove_custom_relation(
292290
workspace_slug,
293291
project.id,
294292
work_item_a.id,
295-
RemoveWorkItemCustomRelation(work_item_id=work_item_b.id),
293+
work_item_b.id,
296294
)
297295
result = client.work_items.custom_relations.list(workspace_slug, project.id, work_item_a.id)
298296
outward_ids = [wi.id for wi in result.get(custom_definition.outward, [])]
@@ -327,7 +325,7 @@ def test_create_custom_relation_inward(
327325
workspace_slug,
328326
project.id,
329327
work_item_a.id,
330-
RemoveWorkItemCustomRelation(work_item_id=work_item_b.id),
328+
work_item_b.id,
331329
)
332330

333331
def test_create_relation_invalid_definition(

0 commit comments

Comments
 (0)