الملفات
GitPasha-MCP-Server/api/issues/create.py

40 أسطر
1.0 KiB
Python

import os
from typing import Dict, Any, Optional, List
from helpers import get_headers, build_client
BASE_URL = os.getenv(
"GITPASHA_BASE_URL",
"https://app.gitpasha.com/api/v1"
).rstrip("/")
def api_create_issue(
repo: str,
title: str,
body: str = "",
labels: Optional[List[str]] = None,
assignees: Optional[List[str]] = None
) -> 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}"
payload: Dict[str, Any] = {"title": title, "body": body}
if labels:
payload["labels"] = labels
if assignees:
payload["assignees"] = assignees
with build_client() as client:
url = f"{BASE_URL}/repos/{repo}/issues"
res = client.post(
url,
headers=get_headers(),
json=payload
)
res.raise_for_status()
data = res.json()
return data