"""Type definitions for {{ module_name }}.

This module contains all Pydantic models, settings, and type definitions
for the {{ module_name }} camera module.

Generated by: madsci new module --template module/camera
Template version: {{ template_version }}
"""

from typing import Literal, Optional

from madsci.node_module import RestNodeConfig
from pydantic import BaseModel, Field


class {{ module_name | pascal_case }}NodeConfig(RestNodeConfig):
    """Configuration for the {{ module_name | pascal_case }} node.

    This class defines all configuration options for the camera node.
    Values can be set via environment variables, config files, or programmatically.
    """

    # Server configuration
    node_url: str = Field(
        default="http://localhost:{{ port }}/",
        description="URL where the node REST API is served",
    )

    # Interface configuration
    interface_type: Literal["real", "fake"] = Field(
        default="real",
        description="Which interface to use (real or fake)",
    )

    # Device configuration
    device_number: int = Field(
        default=0,
        description="Device number for multi-camera setups",
    )

    wait_time: float = Field(
        default=2.0,
        description="Time to wait while running an action, in seconds (simulates hardware timing)",
    )

    # Camera-specific configuration
    default_exposure_ms: float = Field(
        default=100.0,
        description="Default exposure time in milliseconds",
    )

    default_resolution: str = Field(
        default="1920x1080",
        description="Default image resolution (WIDTHxHEIGHT)",
    )


class {{ module_name | pascal_case }}InterfaceConfig(BaseModel):
    """Configuration for the {{ module_name | pascal_case }} hardware interface.

    This class defines settings specific to the camera interface,
    such as connection parameters, retry behavior, and imaging defaults.
    """

    connection_timeout: float = Field(
        default=10.0,
        description="Timeout for establishing connection to the camera, in seconds",
    )

    retry_count: int = Field(
        default=3,
        description="Number of retries for failed operations",
    )

    resolution: str = Field(
        default="1920x1080",
        description="Image resolution (WIDTHxHEIGHT)",
    )

    exposure_ms: float = Field(
        default=100.0,
        description="Exposure time in milliseconds",
    )

    gain: float = Field(
        default=1.0,
        description="Camera gain multiplier",
    )


class {{ module_name | pascal_case }}CaptureResult(BaseModel):
    """Result from a {{ module_name }} image capture operation.

    Contains information about the captured image including its path,
    dimensions, timestamp, and any additional metadata.
    """

    image_path: Optional[str] = Field(
        default=None,
        description="Path to the captured image file",
    )

    width: int = Field(
        description="Image width in pixels",
    )

    height: int = Field(
        description="Image height in pixels",
    )

    timestamp: Optional[float] = Field(
        default=None,
        description="Timestamp when the image was captured (epoch seconds)",
    )

    metadata: dict = Field(
        default_factory=dict,
        description="Additional metadata about the capture (exposure, gain, etc.)",
    )


class {{ module_name | pascal_case }}Result(BaseModel):
    """Result from a {{ module_name }} camera operation.

    Use this model to define the structure of results from camera operations.
    """

    success: bool = Field(description="Whether the operation succeeded")
    data: Optional[dict] = Field(
        default=None,
        description="Result data from the operation",
    )
    error_message: Optional[str] = Field(
        default=None,
        description="Error message if operation failed",
    )
