"""Data models for resource and workunit operations."""

from dataclasses import dataclass


@dataclass
class ResourceDef:
    """Definition for registering a new resource in B-Fabric.

    Used with register_resources_batch() for efficient batch registration.
    """

    name: str
    relativepath: str
    size: int
    storage_id: int
    md5: str = ""
    status: str = "AVAILABLE"


@dataclass
class CloneDef:
    """Definition for cloning an existing resource (no file copy).

    Used with clone_resources_batch() to register a new resource
    that points to an existing file on storage.
    """

    name: str  # New resource name
    source_relativepath: str  # Existing file path (reuse)
    source_storage_id: int  # Existing storage ID
    size: int
    md5: str


@dataclass
class DuplicateMatch:
    """Match info for an existing resource found during duplicate detection.

    Used by get_container_resources() to return resource info indexed by MD5.
    To check for duplicates, simply use: `if md5 in resources_by_md5`
    """

    resource_id: int
    filename: str
    relativepath: str
    workunit_id: int
    workunit_name: str
    storage_id: int
    md5: str