from typing import Dict, Any
from ..http_client import HTTPClient


class ProjectsResource:
    def __init__(self, http: HTTPClient):
        self._http = http

    def list(self, organization_id: str = None, page: int = 1, page_size: int = 20) -> Dict[str, Any]:
        params = {"page": page, "pageSize": page_size}
        if organization_id:
            params["organizationId"] = organization_id
        return self._http.get("/projects", params=params)

    def get(self, project_id: str) -> Dict[str, Any]:
        return self._http.get(f"/projects/{project_id}")

    def create(self, data: Dict[str, Any]) -> Dict[str, Any]:
        return self._http.post("/projects", json=data)

    def update(self, project_id: str, data: Dict[str, Any]) -> Dict[str, Any]:
        return self._http.patch(f"/projects/{project_id}", json=data)

    def delete(self, project_id: str) -> None:
        return self._http.delete(f"/projects/{project_id}")
