from typing import Optional

from .report_serializable import ReportSerializable


class CustomReportNamedResource(ReportSerializable):
    """A named resource reference used by renderers and preparers."""

    def __init__(self, name: Optional[str], type: str) -> None:
        """Creates a named resource reference.

        Args:
            name: Optional alias for the resource.
            type: Resource type identifier.
        """
        self.type = type
        self.name = name

    def build_content(self) -> dict:
        """Serializes the resource reference.

        Returns:
            Dict with ``name`` and ``type`` keys.
        """
        return {"name": self.name, "type": self.type}
