|
| 1 | +"""Issue tracker repository for issue tracker profile data access.""" |
| 2 | + |
| 3 | +import logging |
| 4 | +from typing import Dict, Any |
| 5 | + |
| 6 | +from .base_repository import BaseRepository |
| 7 | +from ..utils.error_handling import IriusRiskError |
| 8 | + |
| 9 | +logger = logging.getLogger(__name__) |
| 10 | + |
| 11 | + |
| 12 | +class IssueTrackerRepository(BaseRepository): |
| 13 | + """Repository for issue tracker profile data access operations.""" |
| 14 | + |
| 15 | + def get_by_id(self, profile_id: str, **kwargs) -> Dict[str, Any]: |
| 16 | + """Not supported — issue tracker profiles are accessed via get_issue_tracker_profiles.""" |
| 17 | + raise IriusRiskError( |
| 18 | + "Issue tracker profiles should be accessed through get_issue_tracker_profiles()" |
| 19 | + ) |
| 20 | + |
| 21 | + def list_all(self, **kwargs) -> Dict[str, Any]: |
| 22 | + """List all issue tracker profiles.""" |
| 23 | + return self.get_issue_tracker_profiles() |
| 24 | + |
| 25 | + def get_issue_tracker_profiles(self) -> Dict[str, Any]: |
| 26 | + """Get all available issue tracker profiles. |
| 27 | +
|
| 28 | + Returns: |
| 29 | + Dictionary with 'profiles' list and 'full_response' |
| 30 | +
|
| 31 | + Raises: |
| 32 | + IriusRiskError: If API request fails |
| 33 | + """ |
| 34 | + logger.debug("Retrieving issue tracker profiles") |
| 35 | + |
| 36 | + try: |
| 37 | + response = self.api_client.get_issue_tracker_profiles() |
| 38 | + profiles_data = self._extract_items_from_response(response) |
| 39 | + |
| 40 | + logger.debug(f"Retrieved {len(profiles_data)} issue tracker profiles") |
| 41 | + |
| 42 | + return { |
| 43 | + 'profiles': profiles_data, |
| 44 | + 'full_response': response |
| 45 | + } |
| 46 | + |
| 47 | + except Exception as e: |
| 48 | + self._handle_error(e, "retrieving issue tracker profiles") |
| 49 | + |
| 50 | + def get_project_issue_trackers(self, project_id: str) -> Dict[str, Any]: |
| 51 | + """Get issue trackers configured for a specific project. |
| 52 | +
|
| 53 | + Args: |
| 54 | + project_id: Project UUID |
| 55 | +
|
| 56 | + Returns: |
| 57 | + Dictionary with 'trackers' list and 'full_response' |
| 58 | +
|
| 59 | + Raises: |
| 60 | + IriusRiskError: If API request fails |
| 61 | + """ |
| 62 | + logger.debug(f"Retrieving issue trackers for project '{project_id}'") |
| 63 | + |
| 64 | + try: |
| 65 | + response = self.api_client.get_project_issue_trackers(project_id) |
| 66 | + trackers_data = self._extract_items_from_response(response) |
| 67 | + |
| 68 | + logger.debug(f"Retrieved {len(trackers_data)} issue trackers for project '{project_id}'") |
| 69 | + |
| 70 | + return { |
| 71 | + 'trackers': trackers_data, |
| 72 | + 'full_response': response |
| 73 | + } |
| 74 | + |
| 75 | + except Exception as e: |
| 76 | + self._handle_error(e, f"retrieving issue trackers for project '{project_id}'") |
0 commit comments