# 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.external_link import ExternalLink
from typing import Optional, Set
from typing_extensions import Self

class PublicRetrieverListItem(BaseModel):
    """
    Simplified retriever information for public listing.  Provides essential details for browsing public retrievers without exposing sensitive configuration or credentials.
    """ # noqa: E501
    public_name: StrictStr = Field(description="Public URL-safe name used in the public URL")
    public_url: StrictStr = Field(description="Full public URL to the retriever page")
    title: StrictStr = Field(description="Display title from display_config")
    description: Optional[StrictStr] = Field(default=None, description="Display description from display_config")
    logo_url: Optional[StrictStr] = Field(default=None, description="Logo URL from display_config")
    icon_base64: Optional[StrictStr] = Field(default=None, description="Base64 encoded icon/favicon from display_config")
    og_image_url: Optional[StrictStr] = Field(default=None, description="Social preview/OG image URL from display_config")
    password_protected: StrictBool = Field(description="Whether password authentication is required")
    is_active: StrictBool = Field(description="Whether the retriever is active")
    external_links: Optional[List[ExternalLink]] = Field(default=None, description="External resource links (GitHub, blog posts, docs, etc.)")
    created_at: datetime = Field(description="When the retriever was published")
    updated_at: datetime = Field(description="When the retriever was last updated")
    __properties: ClassVar[List[str]] = ["public_name", "public_url", "title", "description", "logo_url", "icon_base64", "og_image_url", "password_protected", "is_active", "external_links", "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 PublicRetrieverListItem 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 each item in external_links (list)
        _items = []
        if self.external_links:
            for _item_external_links in self.external_links:
                if _item_external_links:
                    _items.append(_item_external_links.to_dict())
            _dict['external_links'] = _items
        return _dict

    @classmethod
    def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
        """Create an instance of PublicRetrieverListItem 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_url": obj.get("public_url"),
            "title": obj.get("title"),
            "description": obj.get("description"),
            "logo_url": obj.get("logo_url"),
            "icon_base64": obj.get("icon_base64"),
            "og_image_url": obj.get("og_image_url"),
            "password_protected": obj.get("password_protected"),
            "is_active": obj.get("is_active"),
            "external_links": [ExternalLink.from_dict(_item) for _item in obj["external_links"]] if obj.get("external_links") is not None else None,
            "created_at": obj.get("created_at"),
            "updated_at": obj.get("updated_at")
        })
        return _obj


