# This file was auto-generated by Fern from our API Definition.

import typing

from ..core import enum

T_Result = typing.TypeVar("T_Result")


class NodeSelectorCapacityType(enum.StrEnum):
    """
    Configure what type of nodes to run the app. By default no placement logic is applied.
    "spot_fallback_on_demand" will try to place the application on spot nodes but will fallback to on-demand when spot nodes are not available.
    "spot" will strictly place the application on spot nodes.
    "on_demand" will strictly place the application on on-demand nodes.
    """

    SPOT_FALLBACK_ON_DEMAND = "spot_fallback_on_demand"
    SPOT = "spot"
    ON_DEMAND = "on_demand"
    _UNKNOWN = "__NODESELECTORCAPACITYTYPE_UNKNOWN__"
    """
    This member is used for forward compatibility. If the value is not recognized by the enum, it will be stored here, and the raw value is accessible through `.value`.
    """

    @classmethod
    def _missing_(cls, value: typing.Any) -> "NodeSelectorCapacityType":
        unknown = cls._UNKNOWN
        unknown._value_ = value
        return unknown

    def visit(
        self,
        spot_fallback_on_demand: typing.Callable[[], T_Result],
        spot: typing.Callable[[], T_Result],
        on_demand: typing.Callable[[], T_Result],
        _unknown_member: typing.Callable[[str], T_Result],
    ) -> T_Result:
        if self is NodeSelectorCapacityType.SPOT_FALLBACK_ON_DEMAND:
            return spot_fallback_on_demand()
        if self is NodeSelectorCapacityType.SPOT:
            return spot()
        if self is NodeSelectorCapacityType.ON_DEMAND:
            return on_demand()
        return _unknown_member(self._value_)
