from __future__ import annotations

from enum import Enum


class InterfaceKind(str, Enum):
    PARTITIONED = "partitioned"
    NONPARTITIONED = "nonpartitioned"

    @classmethod
    def from_str(
        cls,
        value: str,
    ) -> InterfaceKind:
        for kind in InterfaceKind:
            if kind.value.lower() == value.lower():
                return kind
        raise ValueError(f"Unknown InterfaceKind: {value}")

    @classmethod
    def from_any(
        cls,
        value: InterfaceKind | str,
    ) -> InterfaceKind:
        if isinstance(value, InterfaceKind):
            return value
        return cls.from_str(value)

    @classmethod
    def list_all(cls) -> list[InterfaceKind]:
        return [kind for kind in cls]

    def __str__(self) -> str:
        return self.value

    def __repr__(self) -> str:
        return f"{self.__class__.__name__}.{self.name}"
