# coding: utf-8

"""
    Mixpeek API

    This is the Mixpeek API, providing access to various endpoints for data processing and retrieval.

    The version of the OpenAPI document: 1.3.0
    Contact: info@mixpeek.com
    Generated by OpenAPI Generator (https://openapi-generator.tech)

    Do not edit the class manually.
"""  # noqa: E501


from __future__ import annotations
import pprint
import re  # noqa: F401
import json

from pydantic import BaseModel, ConfigDict, Field, StrictBool, StrictStr
from typing import Any, ClassVar, Dict, List, Optional
from typing_extensions import Annotated
from mixpeek.models.retriever_input_schema_field_output import RetrieverInputSchemaFieldOutput
from typing import Optional, Set
from typing_extensions import Self

class InputRenderingConfigOutput(BaseModel):
    """
    Configuration for how to render an input field in the public UI.  Maps to BucketSchemaField structure for consistency with how we define input types across the system.
    """ # noqa: E501
    field_name: StrictStr = Field(description="Name of the input field (matches retriever input_schema key)")
    field_schema: RetrieverInputSchemaFieldOutput = Field(description="Schema definition for this input field. Defines type, description, examples, and validation rules. Supports all bucket types (string, number, image, etc.) plus document_reference. Frontend uses this to render the appropriate input component (text input, image upload, dropdown, etc.)")
    input_type: Optional[StrictStr] = Field(default='text', description="UI input component type. Determines how the input is rendered: text (single line), select (dropdown), file (upload), multiselect (multiple choice)")
    label: StrictStr = Field(description="Human-readable label for the input")
    placeholder: Optional[StrictStr] = Field(default=None, description="Placeholder text for the input")
    helper_text: Optional[StrictStr] = Field(default=None, description="Helper text displayed below the input to guide users")
    suggestions: Optional[List[StrictStr]] = Field(default=None, description="Pre-filled suggestion chips that users can click to populate the input")
    required: Optional[StrictBool] = Field(default=True, description="Whether this input is required")
    order: Optional[Annotated[int, Field(strict=True, ge=0)]] = Field(default=0, description="Display order (lower numbers appear first)")
    __properties: ClassVar[List[str]] = ["field_name", "field_schema", "input_type", "label", "placeholder", "helper_text", "suggestions", "required", "order"]

    model_config = ConfigDict(
        populate_by_name=True,
        validate_assignment=True,
        protected_namespaces=(),
    )


    def to_str(self) -> str:
        """Returns the string representation of the model using alias"""
        return pprint.pformat(self.model_dump(by_alias=True))

    def to_json(self) -> str:
        """Returns the JSON representation of the model using alias"""
        # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead
        return json.dumps(self.to_dict())

    @classmethod
    def from_json(cls, json_str: str) -> Optional[Self]:
        """Create an instance of InputRenderingConfigOutput from a JSON string"""
        return cls.from_dict(json.loads(json_str))

    def to_dict(self) -> Dict[str, Any]:
        """Return the dictionary representation of the model using alias.

        This has the following differences from calling pydantic's
        `self.model_dump(by_alias=True)`:

        * `None` is only added to the output dict for nullable fields that
          were set at model initialization. Other fields with value `None`
          are ignored.
        """
        excluded_fields: Set[str] = set([
        ])

        _dict = self.model_dump(
            by_alias=True,
            exclude=excluded_fields,
            exclude_none=True,
        )
        # override the default output from pydantic by calling `to_dict()` of field_schema
        if self.field_schema:
            _dict['field_schema'] = self.field_schema.to_dict()
        return _dict

    @classmethod
    def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
        """Create an instance of InputRenderingConfigOutput from a dict"""
        if obj is None:
            return None

        if not isinstance(obj, dict):
            return cls.model_validate(obj)

        _obj = cls.model_validate({
            "field_name": obj.get("field_name"),
            "field_schema": RetrieverInputSchemaFieldOutput.from_dict(obj["field_schema"]) if obj.get("field_schema") is not None else None,
            "input_type": obj.get("input_type") if obj.get("input_type") is not None else 'text',
            "label": obj.get("label"),
            "placeholder": obj.get("placeholder"),
            "helper_text": obj.get("helper_text"),
            "suggestions": obj.get("suggestions"),
            "required": obj.get("required") if obj.get("required") is not None else True,
            "order": obj.get("order") if obj.get("order") is not None else 0
        })
        return _obj


