39 أسطر
901 B
Python
39 أسطر
901 B
Python
import os
|
|
from typing import List, Dict, Any, Optional
|
|
from helpers import get_headers, build_client
|
|
|
|
|
|
BASE_URL = os.getenv(
|
|
"GITPASHA_BASE_URL",
|
|
"https://app.gitpasha.com/api/v1"
|
|
).rstrip("/")
|
|
|
|
|
|
def api_list_issues(
|
|
repo: str,
|
|
state: Optional[str] = None
|
|
) -> List[Dict[str, Any]]:
|
|
username = os.getenv("GITPASHA__USERNAME", "")
|
|
|
|
if "/" not in repo:
|
|
if not username:
|
|
raise ValueError("GITPASHA__USERNAME not set in .env")
|
|
repo = f"{username}/{repo}"
|
|
|
|
params = {}
|
|
if state:
|
|
params["state"] = state
|
|
with build_client() as client:
|
|
url = f"{BASE_URL}/repos/{repo}/issues"
|
|
res = client.get(
|
|
url,
|
|
headers=get_headers(),
|
|
params=params
|
|
)
|
|
res.raise_for_status()
|
|
try:
|
|
data = res.json()
|
|
except Exception:
|
|
data = []
|
|
return data
|