# 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 mixpeek.models.display_config_output import DisplayConfigOutput
from mixpeek.models.retriever_metadata import RetrieverMetadata
from typing import Optional, Set
from typing_extensions import Self

class PublicRetrieverConfigResponse(BaseModel):
    """
    Response for fetching public retriever configuration (for UI rendering).  This is what the public frontend (apps.mixpeek.com) fetches to render the search interface. It includes everything needed for UI rendering.
    """ # noqa: E501
    public_name: StrictStr = Field(description="Public name of the retriever")
    public_api_key: StrictStr = Field(description="Public API key for making authenticated requests. Frontend needs this to call the execute endpoint.")
    display_config: DisplayConfigOutput = Field(description="Display configuration for rendering the UI. Includes inputs, theme, layout, and exposed fields.")
    password_protected: StrictBool = Field(description="Whether this retriever requires password authentication")
    retriever_metadata: Optional[RetrieverMetadata] = Field(default=None, description="OPTIONAL. Technical metadata about how the retriever works. Only present if include_metadata=True was set during publishing.")
    __properties: ClassVar[List[str]] = ["public_name", "public_api_key", "display_config", "password_protected", "retriever_metadata"]

    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 PublicRetrieverConfigResponse 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 display_config
        if self.display_config:
            _dict['display_config'] = self.display_config.to_dict()
        # override the default output from pydantic by calling `to_dict()` of retriever_metadata
        if self.retriever_metadata:
            _dict['retriever_metadata'] = self.retriever_metadata.to_dict()
        return _dict

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

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

        _obj = cls.model_validate({
            "public_name": obj.get("public_name"),
            "public_api_key": obj.get("public_api_key"),
            "display_config": DisplayConfigOutput.from_dict(obj["display_config"]) if obj.get("display_config") is not None else None,
            "password_protected": obj.get("password_protected"),
            "retriever_metadata": RetrieverMetadata.from_dict(obj["retriever_metadata"]) if obj.get("retriever_metadata") is not None else None
        })
        return _obj


