-
Notifications
You must be signed in to change notification settings - Fork 22
Expand file tree
/
Copy pathmilestones.py
More file actions
144 lines (124 loc) · 4.78 KB
/
Copy pathmilestones.py
File metadata and controls
144 lines (124 loc) · 4.78 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
from __future__ import annotations
from collections.abc import Mapping
from typing import Any
from ..models.milestones import (
CreateMilestone,
Milestone,
PaginatedMilestoneResponse,
PaginatedMilestoneWorkItemResponse,
UpdateMilestone,
)
from .base_resource import BaseResource
class Milestones(BaseResource):
def __init__(self, config: Any) -> None:
super().__init__(config, "/workspaces/")
def create(self, workspace_slug: str, project_id: str, data: CreateMilestone) -> Milestone:
"""Create a new milestone.
Args:
workspace_slug: The workspace slug identifier
project_id: UUID of the project
data: Milestone data
"""
response = self._post(
f"{workspace_slug}/projects/{project_id}/milestones",
data.model_dump(exclude_none=True),
)
return Milestone.model_validate(response)
def retrieve(self, workspace_slug: str, project_id: str, milestone_id: str) -> Milestone:
"""Retrieve a milestone by ID.
Args:
workspace_slug: The workspace slug identifier
project_id: UUID of the project
milestone_id: UUID of the milestone
"""
response = self._get(f"{workspace_slug}/projects/{project_id}/milestones/{milestone_id}")
return Milestone.model_validate(response)
def update(
self, workspace_slug: str, project_id: str, milestone_id: str, data: UpdateMilestone
) -> Milestone:
"""Update a milestone by ID.
Args:
workspace_slug: The workspace slug identifier
project_id: UUID of the project
milestone_id: UUID of the milestone
data: Updated milestone data
"""
response = self._patch(
f"{workspace_slug}/projects/{project_id}/milestones/{milestone_id}",
data.model_dump(exclude_none=True),
)
return Milestone.model_validate(response)
def delete(self, workspace_slug: str, project_id: str, milestone_id: str) -> None:
"""Delete a milestone by ID.
Args:
workspace_slug: The workspace slug identifier
project_id: UUID of the project
milestone_id: UUID of the milestone
"""
return self._delete(f"{workspace_slug}/projects/{project_id}/milestones/{milestone_id}")
def list(
self, workspace_slug: str, project_id: str, params: Mapping[str, Any] | None = None
) -> PaginatedMilestoneResponse:
"""List milestones with optional filtering parameters.
Args:
workspace_slug: The workspace slug identifier
project_id: UUID of the project
params: Optional query parameters
"""
response = self._get(f"{workspace_slug}/projects/{project_id}/milestones", params=params)
return PaginatedMilestoneResponse.model_validate(response)
def add_work_items(
self,
workspace_slug: str,
project_id: str,
milestone_id: str,
issue_ids: list[str],
) -> None:
"""Add work items to a milestone.
Args:
workspace_slug: The workspace slug identifier
project_id: UUID of the project
milestone_id: UUID of the milestone
issue_ids: List of issue IDs to add to the milestone
"""
return self._post(
f"{workspace_slug}/projects/{project_id}/milestones/{milestone_id}/work-items",
{"issues": issue_ids},
)
def remove_work_items(
self,
workspace_slug: str,
project_id: str,
milestone_id: str,
issue_ids: list[str],
) -> None:
"""Remove work items from a milestone.
Args:
workspace_slug: The workspace slug identifier
project_id: UUID of the project
milestone_id: UUID of the milestone
issue_ids: List of issue IDs to remove from the milestone
"""
return self._delete(
f"{workspace_slug}/projects/{project_id}/milestones/{milestone_id}/work-items",
{"issues": issue_ids},
)
def list_work_items(
self,
workspace_slug: str,
project_id: str,
milestone_id: str,
params: Mapping[str, Any] | None = None,
) -> PaginatedMilestoneWorkItemResponse:
"""List work items in a milestone.
Args:
workspace_slug: The workspace slug identifier
project_id: UUID of the project
milestone_id: UUID of the milestone
params: Optional query parameters
"""
response = self._get(
f"{workspace_slug}/projects/{project_id}/milestones/{milestone_id}/work-items",
params=params,
)
return PaginatedMilestoneWorkItemResponse.model_validate(response)