"""임시 데모용 가짜 Pulp 클라이언트 — 성공 대시보드 미리보기.

PULP_DEMO=true 일 때만 사용된다. 실제 Pulp 서버 없이 화면을 확인하기 위한 것.
정식 기능과 무관하므로 단계 5(또는 실제 Pulp 연동 시) 제거 가능.
"""

from __future__ import annotations

from typing import Any

_REPOS: list[dict[str, Any]] = [
    {
        "pulp_href": "/pulp/api/v3/repositories/rpm/rpm/0001/",
        "name": "rocky9-baseos",
        "latest_version_href": "/pulp/api/v3/repositories/rpm/rpm/0001/versions/3/",
        "repo_config": {"gpgcheck": 1, "repo-gpgcheck": 1},
    },
    {
        "pulp_href": "/pulp/api/v3/repositories/rpm/rpm/0002/",
        "name": "rocky9-appstream",
        "latest_version_href": "/pulp/api/v3/repositories/rpm/rpm/0002/versions/2/",
        "repo_config": {"gpgcheck": 1, "repo-gpgcheck": 1},
    },
    {
        "pulp_href": "/pulp/api/v3/repositories/rpm/rpm/0003/",
        "name": "ubuntu2204-main",
        "latest_version_href": "/pulp/api/v3/repositories/rpm/rpm/0003/versions/5/",
        "repo_config": {"gpgcheck": 1, "repo-gpgcheck": 0},  # 부분 검증
    },
    {
        "pulp_href": "/pulp/api/v3/repositories/rpm/rpm/0004/",
        "name": "internal-tools",
        "latest_version_href": "/pulp/api/v3/repositories/rpm/rpm/0004/versions/1/",
        "repo_config": {},  # 미설정
    },
]

_VERSIONS: dict[str, dict[str, Any]] = {
    "/pulp/api/v3/repositories/rpm/rpm/0001/versions/3/": {
        "pulp_created": "2026-06-15T02:11:00Z",
        "content_summary": {"present": {"rpm.package": {"count": 4821}}},
    },
    "/pulp/api/v3/repositories/rpm/rpm/0002/versions/2/": {
        "pulp_created": "2026-06-14T23:40:00Z",
        "content_summary": {"present": {"rpm.package": {"count": 8934}}},
    },
    "/pulp/api/v3/repositories/rpm/rpm/0003/versions/5/": {
        "pulp_created": "2026-06-16T08:05:00Z",
        "content_summary": {"present": {"deb.package": {"count": 12500}}},
    },
    "/pulp/api/v3/repositories/rpm/rpm/0004/versions/1/": {
        "pulp_created": "2026-05-30T11:20:00Z",
        "content_summary": {"present": {"rpm.package": {"count": 87}}},
    },
}


class DemoPulpClient:
    def close(self) -> None:  # 인터페이스 호환
        pass

    def status(self) -> dict[str, Any]:
        return {"online": True, "demo": True}

    def list_repos(self) -> list[dict[str, Any]]:
        return _REPOS

    def get_version(self, version_href: str) -> dict[str, Any]:
        return _VERSIONS.get(version_href, {})
