# Automatically generated by generate_types.py. Do not edit manually.
import enum

from pydantic import field_validator

from .base import CommonEntityType, load_entity_supported_types

__all__ = ["ActorType", "ActorTypes"]


class ActorType(CommonEntityType):
    """
    ActorType represents metadata for actors in Colander. Check :ref:`the list of supported types <actor_types>`.

    Example:
        >>> actor_type = ActorTypes.INDIVIDUAL.value
        >>> print(actor_type.name)
        Individual
    """

    @field_validator("short_name", mode="before")
    @classmethod
    def is_supported_type(cls, short_name: str):
        if short_name not in {t["short_name"] for t in load_entity_supported_types("actor")}:
            raise ValueError(f"{short_name} is not supported")
        return short_name


class ActorTypes(enum.Enum):
    """
    ActorTypes provides access to all supported actor types.

    This class loads actor type definitions from the actor types JSON file and exposes them as an enum.
    It also provides a method to look up an actor type by its short name.

    Example:
        >>> actor_type = ActorTypes.INDIVIDUAL.value
        >>> print(actor_type.name)
        Individual
        >>> default_type = ActorTypes.by_short_name("nonexistent")
        >>> print(default_type.name)
        Generic
    """

    APT = ActorType(
        **{
            "short_name": "APT",
            "name": "APT",
            "description": "An advanced persistent threat group, typically well-resourced and highly skilled.",
            "icon": "",
            "nf_icon": "nf-fae-virus",
        }
    )
    """APT - An advanced persistent threat group, typically well-resourced and highly skilled."""

    COMPANY = ActorType(
        **{
            "short_name": "COMPANY",
            "name": "Private company",
            "description": "A privately owned business entity, often a target or participant in cyber activities.",
            "icon": "",
            "nf_icon": "nf-fa-dollar",
        }
    )
    """Private company - A privately owned business entity, often a target or participant in cyber activities."""

    CYBER_CRIMINAL = ActorType(
        **{
            "short_name": "CYBER_CRIMINAL",
            "name": "Cyber criminal",
            "description": "An individual or group engaging in illegal activities for financial gain.",
            "icon": "",
            "nf_icon": "nf-fa-user_secret",
        }
    )
    """Cyber criminal - An individual or group engaging in illegal activities for financial gain."""

    GENERIC = ActorType(
        **{
            "short_name": "GENERIC",
            "name": "Generic",
            "description": "A generic or unspecified actor type.",
            "icon": "",
            "nf_icon": "nf-cod-person",
        }
    )
    """Generic - A generic or unspecified actor type."""

    HACKTIVIST = ActorType(
        **{
            "short_name": "HACKTIVIST",
            "name": "Hacktivist",
            "description": "An individual or group using hacking to promote political or social agendas.",
            "icon": "",
            "nf_icon": "nf-cod-person",
        }
    )
    """Hacktivist - An individual or group using hacking to promote political or social agendas."""

    INDIVIDUAL = ActorType(
        **{
            "short_name": "INDIVIDUAL",
            "name": "Individual",
            "description": "A single person involved in threat activity or as a target.",
            "icon": "",
            "nf_icon": "nf-cod-person",
        }
    )
    """Individual - A single person involved in threat activity or as a target."""

    INSIDER = ActorType(
        **{
            "short_name": "INSIDER",
            "name": "Insider threat",
            "description": "An individual within an organization posing a security risk.",
            "icon": "",
            "nf_icon": "nf-fa-user",
        }
    )
    """Insider threat - An individual within an organization posing a security risk."""

    NATION_STATE = ActorType(
        **{
            "short_name": "NATION_STATE",
            "name": "Nation-state actor",
            "description": "A government-sponsored group conducting cyber operations.",
            "icon": "",
            "nf_icon": "nf-mdi-flag",
        }
    )
    """Nation-state actor - A government-sponsored group conducting cyber operations."""

    NGO = ActorType(
        **{
            "short_name": "NGO",
            "name": "NGO",
            "description": "A non-governmental organization.",
            "icon": "",
            "nf_icon": "nf-fae-cc_nc",
        }
    )
    """NGO - A non-governmental organization."""

    PUB_INST = ActorType(
        **{
            "short_name": "PUB_INST",
            "name": "Public institution",
            "description": "A government or public sector organization.",
            "icon": "",
            "nf_icon": "nf-fa-bank",
        }
    )
    """Public institution - A government or public sector organization."""

    THREAT_ACTOR = ActorType(
        **{
            "short_name": "THREAT_ACTOR",
            "name": "Threat actor",
            "description": "An individual or group responsible for malicious cyber activities.",
            "icon": "",
            "nf_icon": "nf-fae-virus",
        }
    )
    """Threat actor - An individual or group responsible for malicious cyber activities."""

    default = GENERIC  # type: ignore[attr-defined]

    @classmethod
    def by_short_name(cls, short_name: str):
        sn = short_name.replace(" ", "_").upper()
        if sn in cls._member_names_:
            return cls[sn].value
        return cls.default.value

    @classmethod
    def suggest(cls, value: str) -> ActorType:
        return cls.by_short_name(value)
