diff --git a/src/api/gitlab.py b/src/api/gitlab.py new file mode 100644 index 0000000..9ae25e5 --- /dev/null +++ b/src/api/gitlab.py @@ -0,0 +1,29 @@ +from typing import Any, Dict, List +import httpx +from src.api.base import APIClient + + +class GitLabClient(APIClient): + def __init__(self, token: str = None, base_url: str = "https://gitlab.com/api/v4"): + super().__init__(base_url, token or "") + + async def get_pull_requests(self, owner: str, repo: str) -> List[Dict[str, Any]]: + url = f"{self.base_url}/projects/{owner}%2F{repo}/merge_requests?state=opened&per_page=10" + async with httpx.AsyncClient() as client: + response = await client.get(url, headers=self.headers) + response.raise_for_status() + return response.json() + + async def get_issues(self, owner: str, repo: str) -> List[Dict[str, Any]]: + url = f"{self.base_url}/projects/{owner}%2F{repo}/issues?state=opened&per_page=10" + async with httpx.AsyncClient() as client: + response = await client.get(url, headers=self.headers) + response.raise_for_status() + return response.json() + + async def get_workflows(self, owner: str, repo: str) -> List[Dict[str, Any]]: + url = f"{self.base_url}/projects/{owner}%2F{repo}/pipelines?per_page=5" + async with httpx.AsyncClient() as client: + response = await client.get(url, headers=self.headers) + response.raise_for_status() + return response.json()