in modules/testrail.py [0:0]
def _get_milestones(self, project_id, **filters):
"""
Retrieves milestones for a given project with optional filters.
Args:
project_id (int): The ID of the project.
**filters: Arbitrary keyword arguments representing API filters.
Available Filters:
is_completed (bool or int):
- Set to True or 1 to return completed milestones only.
- Set to False or 0 to return open (active/upcoming) milestones only.
is_started (bool or int):
- Set to True or 1 to return started milestones only.
- Set to False or 0 to return upcoming milestones only.
limit (int):
- The number of milestones the response should return.
- The default response size is 250 milestones.
offset (int):
- Where to start counting the milestones from (the offset).
- Used for pagination.
Returns:
dict: The API response containing milestones.
"""
if not project_id:
raise ValueError("Project ID must be provided.")
# Base endpoint
endpoint = f"get_milestones/{project_id}"
# Process filters
if filters:
# Convert boolean values to integers (API expects 1 or 0)
for key in ["is_completed", "is_started"]:
if key in filters and isinstance(filters[key], bool):
filters[key] = int(filters[key])
# Build query parameters
query_params = "&".join(f"{key}={value}" for key, value in filters.items())
endpoint = f"{endpoint}&{query_params}"
# Make API call
return self.client.send_get(endpoint)