"""Pydantic models for GA4GH TRS (Tool Registry Service) v2.0.1."""

from __future__ import annotations

from enum import Enum

from ai4gh.core.types import GA4GHBase


class DescriptorType(str, Enum):
    """Workflow descriptor type."""

    CWL = "CWL"
    WDL = "WDL"
    NFL = "NFL"
    GALAXY = "GALAXY"
    SMK = "SMK"
    JUPYTER = "JUPYTER"
    OTHER = "OTHER"


class ToolClass(GA4GHBase):
    """Tool class (workflow or tool)."""

    id: str | None = None
    name: str | None = None
    description: str | None = None


class FileWrapper(GA4GHBase):
    """A file (primary descriptor, test file, etc.)."""

    content: str | None = None
    url: str | None = None
    checksum: list[dict[str, str]] | None = None


class ImageData(GA4GHBase):
    """Container image information."""

    registry_host: str | None = None
    image_name: str | None = None
    size: int | None = None
    updated: str | None = None
    checksum: list[dict[str, str]] | None = None
    image_type: str | None = None


class ToolVersion(GA4GHBase):
    """A version of a tool or workflow."""

    id: str | None = None
    name: str | None = None
    url: str | None = None
    is_production: bool | None = None
    images: list[ImageData] | None = None
    descriptor_type: list[DescriptorType] | None = None
    author: list[str] | None = None
    meta_version: str | None = None
    signed: bool | None = None
    included_apps: list[str] | None = None
    verified_source: list[str] | None = None


class Tool(GA4GHBase):
    """A registered tool or workflow."""

    id: str | None = None
    url: str | None = None
    name: str | None = None
    organization: str | None = None
    toolclass: ToolClass | None = None
    description: str | None = None
    meta_version: str | None = None
    has_checker: bool | None = None
    checker_url: str | None = None
    versions: list[ToolVersion] | None = None
    aliases: list[str] | None = None


class ToolSearchResponse(GA4GHBase):
    """Search results for tools (wrapped list)."""

    tools: list[Tool] | None = None
    next_page_token: str | None = None
