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

class PublishedRetrieverResponse(BaseModel):
    """
    Response model for GET published retriever.  Returns the full published retriever config including the public API key since the user already has access to it.
    """ # noqa: E501
    retriever_id: StrictStr = Field(description="ID of the underlying retriever")
    public_id: StrictStr = Field(description="Public identifier for this published retriever")
    public_name: StrictStr = Field(description="Public URL-safe name")
    description: Optional[StrictStr] = Field(default=None, description="Description of this public retriever")
    icon_base64: Optional[StrictStr] = Field(default=None, description="Base64 encoded icon/favicon for this retriever")
    public_api_key: StrictStr = Field(description="Public API key (safe to show to retriever owner)")
    display_config: DisplayConfigOutput = Field(description="Display configuration for UI rendering")
    rate_limit_config: RateLimitConfig = Field(description="Rate limiting configuration")
    password_protected: StrictBool = Field(description="Whether password protection is enabled")
    is_active: StrictBool = Field(description="Whether the published retriever is active")
    retriever_metadata: Optional[RetrieverMetadata] = Field(default=None, description="Optional technical metadata about the retriever")
    created_at: datetime = Field(description="Timestamp when published")
    updated_at: datetime = Field(description="Timestamp when last updated")
    __properties: ClassVar[List[str]] = ["retriever_id", "public_id", "public_name", "description", "icon_base64", "public_api_key", "display_config", "rate_limit_config", "password_protected", "is_active", "retriever_metadata", "created_at", "updated_at"]

    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 PublishedRetrieverResponse 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 rate_limit_config
        if self.rate_limit_config:
            _dict['rate_limit_config'] = self.rate_limit_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 PublishedRetrieverResponse from a dict"""
        if obj is None:
            return None

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

        _obj = cls.model_validate({
            "retriever_id": obj.get("retriever_id"),
            "public_id": obj.get("public_id"),
            "public_name": obj.get("public_name"),
            "description": obj.get("description"),
            "icon_base64": obj.get("icon_base64"),
            "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,
            "rate_limit_config": RateLimitConfig.from_dict(obj["rate_limit_config"]) if obj.get("rate_limit_config") is not None else None,
            "password_protected": obj.get("password_protected"),
            "is_active": obj.get("is_active"),
            "retriever_metadata": RetrieverMetadata.from_dict(obj["retriever_metadata"]) if obj.get("retriever_metadata") is not None else None,
            "created_at": obj.get("created_at"),
            "updated_at": obj.get("updated_at")
        })
        return _obj


