# generated by fastapi-codegen:
#   filename:  /Users/ivasylen/Code/contracts/guardicore/connector
#   timestamp: 2026-01-26T10:59:30+00:00

from __future__ import annotations

from enum import Enum
from typing import Any, Dict, List, Optional, Union
from uuid import UUID

from pydantic import BaseModel, ConfigDict, Field

from centra_sdk.utils.gc_serializer import GcSerializer

from ..common.common import Connector


class OptType(Enum):
    OPT_INT = 'opt_int'
    OPT_STRING = 'opt_string'
    OPT_BOOL = 'opt_bool'
    OPT_FLOAT = 'opt_float'
    OPT_ENUM = 'opt_enum'
    OPT_MULTICHOICE_STRING = 'opt_multichoice_string'
    OPT_DYNAMIC_LIST = 'opt_dynamic_list'
    OPT_DYNAMIC_LABEL_TRANSLATION = 'opt_dynamic_label_translation'


class ConfigOpts(BaseModel, GcSerializer):
    model_config = ConfigDict(
        populate_by_name=True,
        from_attributes=True,
    )
    name: str
    opt_type: OptType
    default_value: Union[str, int, bool, float, List, Dict[str, Any]]
    description: str
    secret: Optional[bool] = None
    hidden: Optional[bool] = None
    restart: Optional[bool] = None
    rebuild: Optional[bool] = None
    multi_line_text: Optional[bool] = None
    readonly: Optional[bool] = None
    dynamic_format: Optional[str] = None
    custom_title: Optional[str] = None


class Configuration(BaseModel, GcSerializer):
    model_config = ConfigDict(
        populate_by_name=True,
        from_attributes=True,
    )
    name: str
    value: Union[str, int, bool, float, Dict[str, Any], List]


class DynamicConfigOptionValuesRequest(BaseModel, GcSerializer):
    model_config = ConfigDict(
        populate_by_name=True,
        from_attributes=True,
    )
    unique_classifier: str = Field(..., alias='unique-classifier')
    offset: Optional[int] = 0
    limit: Optional[int] = 10
    search: Optional[str] = None


class DynamicConfigOptionValuesResponse(BaseModel, GcSerializer):
    model_config = ConfigDict(
        populate_by_name=True,
        from_attributes=True,
    )
    total_count: int = Field(..., alias='total-count')
    data: List


class InternalConfigMetadata(BaseModel, GcSerializer):
    model_config = ConfigDict(
        populate_by_name=True,
        from_attributes=True,
    )
    component_id: UUID = Field(..., alias='component-id')
    component_type: Connector = Field(..., alias='component-type')
    opts: List[ConfigOpts]


class InternalConfig(BaseModel, GcSerializer):
    model_config = ConfigDict(
        populate_by_name=True,
        from_attributes=True,
    )
    configs: List[Configuration]
