Initial upload: DevDash CLI with TUI dashboard
Some checks failed
CI / test (push) Has been cancelled
Some checks failed
CI / test (push) Has been cancelled
This commit is contained in:
32
src/api/base.py
Normal file
32
src/api/base.py
Normal file
@@ -0,0 +1,32 @@
|
|||||||
|
import httpx
|
||||||
|
from abc import ABC, abstractmethod
|
||||||
|
from typing import Any, Dict, List, Optional
|
||||||
|
|
||||||
|
|
||||||
|
class APIClient(ABC):
|
||||||
|
def __init__(self, base_url: str, token: str):
|
||||||
|
self.base_url = base_url
|
||||||
|
self.token = token
|
||||||
|
self.headers = {
|
||||||
|
"Authorization": f"Bearer {token}",
|
||||||
|
"Accept": "application/json",
|
||||||
|
}
|
||||||
|
|
||||||
|
@abstractmethod
|
||||||
|
async def get_pull_requests(self, owner: str, repo: str) -> List[Dict[str, Any]]:
|
||||||
|
pass
|
||||||
|
|
||||||
|
@abstractmethod
|
||||||
|
async def get_issues(self, owner: str, repo: str) -> List[Dict[str, Any]]:
|
||||||
|
pass
|
||||||
|
|
||||||
|
@abstractmethod
|
||||||
|
async def get_workflows(self, owner: str, repo: str) -> List[Dict[str, Any]]:
|
||||||
|
pass
|
||||||
|
|
||||||
|
async def _request(
|
||||||
|
self, client: httpx.AsyncClient, method: str, url: str, **kwargs
|
||||||
|
) -> httpx.Response:
|
||||||
|
response = await client.request(method, url, **kwargs)
|
||||||
|
response.raise_for_status()
|
||||||
|
return response
|
||||||
Reference in New Issue
Block a user