Skip to content

Commit

Permalink
refactor Endpoints class usage
Browse files Browse the repository at this point in the history
  • Loading branch information
PeyGis committed Aug 9, 2023
1 parent eb53515 commit acd23d2
Showing 1 changed file with 6 additions and 8 deletions.
14 changes: 6 additions & 8 deletions integrations/sonarqube/sonarqube_integration/sonarqube_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,9 +77,9 @@ async def send_api_request(
async def get_projects(self) -> list[Any]:
"""A function to make API request to SonarQube and retrieve projects within an organization"""
logger.info(f"Fetching all projects in organization: {self.organization_id}")
endpoint_url = Endpoints.PROJECTS
response = await self.send_api_request(
endpoint=endpoint_url, query_params={"organization": self.organization_id}
endpoint=Endpoints.PROJECTS,
query_params={"organization": self.organization_id},
)
return response.get("components", [])

Expand All @@ -91,9 +91,8 @@ async def get_branches(self, project_key: str) -> Optional[dict[str, Any]]:
:return: Dictionary containing branch information or None if no branches found
"""
logger.info(f"Fetching all branches in project: {project_key}")
endpoint_url = Endpoints.BRANCHES
response = await self.send_api_request(
endpoint=endpoint_url, query_params={"project": project_key}
endpoint=Endpoints.BRANCHES, query_params={"project": project_key}
)
branches = response.get("branches", [])
if branches:
Expand All @@ -112,9 +111,9 @@ async def get_quality_gate_status(
:return: Dictionary containing quality gate status or None if not available
"""
logger.info(f"Fetching quality gate data in project: {project_key}")
endpoint_url = Endpoints.QUALITY_GATE_STATUS
response = await self.send_api_request(
endpoint=endpoint_url, query_params={"projectKey": project_key}
endpoint=Endpoints.QUALITY_GATE_STATUS,
query_params={"projectKey": project_key},
)
project_status = response.get("projectStatus", {})
if project_status:
Expand All @@ -131,9 +130,8 @@ async def get_quality_gate_name(self, project_key: str) -> Optional[str]:
:return: Quality gate name or None if not available
"""
logger.info(f"Fetching quality gate name in project: {project_key}")
endpoint_url = Endpoints.QUALITY_GATE_NAME
response = await self.send_api_request(
endpoint=endpoint_url,
endpoint=Endpoints.QUALITY_GATE_NAME,
query_params={"project": project_key, "organization": self.organization_id},
)
quality_gate = response.get("qualityGate", {})
Expand Down

0 comments on commit acd23d2

Please sign in to comment.