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

import typing

import pydantic
from ..core.pydantic_utilities import IS_PYDANTIC_V2, UniversalBaseModel
from .config_field_descriptor_maximum import ConfigFieldDescriptorMaximum
from .config_field_descriptor_minimum import ConfigFieldDescriptorMinimum
from .config_field_type import ConfigFieldType
from .config_select_option import ConfigSelectOption


class ConfigFieldDescriptor(UniversalBaseModel):
    """
    Describes a single configuration field for the UI.
    """

    key: str = pydantic.Field()
    """
    Property key in the configuration object
    """

    label: str = pydantic.Field()
    """
    Human-readable label
    """

    field_type: ConfigFieldType = pydantic.Field()
    """
    UI input type
    """

    required: typing.Optional[bool] = pydantic.Field(default=None)
    """
    Whether the field is required
    """

    advanced: typing.Optional[bool] = pydantic.Field(default=None)
    """
    True for advanced/expert settings the UI should hide behind a toggle
    """

    order: typing.Optional[int] = pydantic.Field(default=None)
    """
    Display order (lower first)
    """

    description: typing.Optional[str] = pydantic.Field(default=None)
    """
    Help text for the field
    """

    placeholder: typing.Optional[str] = pydantic.Field(default=None)
    """
    Input placeholder text
    """

    default: typing.Optional[typing.Any] = pydantic.Field(default=None)
    """
    Default value
    """

    options: typing.Optional[typing.List[ConfigSelectOption]] = pydantic.Field(default=None)
    """
    Available options for dropdown / multi_select
    """

    pattern: typing.Optional[str] = pydantic.Field(default=None)
    """
    Validation regex pattern
    """

    minimum: typing.Optional[ConfigFieldDescriptorMinimum] = pydantic.Field(default=None)
    """
    Minimum value for numeric fields
    """

    maximum: typing.Optional[ConfigFieldDescriptorMaximum] = pydantic.Field(default=None)
    """
    Maximum value for numeric fields
    """

    examples: typing.Optional[typing.List[typing.Any]] = pydantic.Field(default=None)
    """
    Example values
    """

    oauth_provided: typing.Optional[bool] = pydantic.Field(default=None)
    """
    True if this field is automatically filled by OAuth credentials
    """

    supports_select_all: typing.Optional[bool] = pydantic.Field(default=None)
    """
    Whether a 'select all' shortcut is available
    """

    select_all_value: typing.Optional[str] = pydantic.Field(default=None)
    """
    The wildcard value for select-all (e.g. 'org/*')
    """

    group_options: typing.Optional[typing.List[typing.Dict[str, typing.Any]]] = pydantic.Field(default=None)
    """
    For group_select: list of oneOf option descriptors
    """

    if IS_PYDANTIC_V2:
        model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict(extra="allow", frozen=True)  # type: ignore # Pydantic v2
    else:

        class Config:
            frozen = True
            smart_union = True
            extra = pydantic.Extra.allow
