# 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, StrictStr, field_validator
from typing import Any, ClassVar, Dict, List, Optional
from typing import Optional, Set
from typing_extensions import Self

class SearchResultItem(BaseModel):
    """
    Individual search result representing a matched resource.  Contains essential metadata about the matched resource including type, ID, name, description, and timestamps. Results are sorted by relevance (exact matches first) and creation time.  Use Cases:     - Display search results in UI     - Navigate to specific resources by ID     - Show resource metadata in search results     - Filter or sort results client-side  Fields:     - resource_type: Type of resource (bucket, collection, etc.)     - resource_id: Unique identifier for the resource     - resource_name: Human-readable name     - description: Optional description text     - created_at: When the resource was created     - updated_at: When the resource was last updated (if applicable)
    """ # noqa: E501
    resource_type: StrictStr = Field(description="Type of resource this result represents. REQUIRED. One of: 'bucket', 'collection', 'retriever', 'taxonomy', 'cluster', 'published_retriever', 'namespace'. Used to identify which resource type was matched and how to navigate to it. Example: 'bucket' indicates this is a bucket resource.")
    resource_id: StrictStr = Field(description="Unique identifier for the resource. REQUIRED. Format depends on resource_type: - bucket: 'bkt_XXXXXXXX' - collection: 'col_XXXXXXXXXX' - retriever: 'ret_XXXXXXXXXXXXXX' - taxonomy: 'tax_XXXXXXXXXXXX' - cluster: 'clust_XXXXXXXXXX' - published_retriever: 'pk_XXXXXXXXXX' - namespace: 'ns_XXXXXXXXXX'. Use this ID to fetch the full resource or perform operations on it.")
    resource_name: StrictStr = Field(description="Human-readable name of the resource. REQUIRED. This is the field that was matched in the search. Corresponds to: bucket_name, collection_name, retriever_name, taxonomy_name, cluster_name, or public_name. Example: 'Production Videos', 'Product Embeddings', 'Recommendation Engine', 'my-public-search'.")
    description: Optional[StrictStr] = Field(default=None, description="Description of the resource if provided. OPTIONAL - May be null if no description was set. Provides additional context about the resource's purpose or contents.")
    created_at: datetime = Field(description="Timestamp when the resource was created. REQUIRED. ISO 8601 format with UTC timezone. Used for sorting results by creation time.")
    updated_at: Optional[datetime] = Field(default=None, description="Timestamp when the resource was last updated. OPTIONAL - May be null if resource has never been updated. ISO 8601 format with UTC timezone.")
    __properties: ClassVar[List[str]] = ["resource_type", "resource_id", "resource_name", "description", "created_at", "updated_at"]

    @field_validator('resource_type')
    def resource_type_validate_enum(cls, value):
        """Validates the enum"""
        if value not in set(['bucket', 'collection', 'retriever', 'taxonomy', 'cluster', 'published_retriever', 'namespace']):
            raise ValueError("must be one of enum values ('bucket', 'collection', 'retriever', 'taxonomy', 'cluster', 'published_retriever', 'namespace')")
        return value

    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 SearchResultItem 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,
        )
        return _dict

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

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

        _obj = cls.model_validate({
            "resource_type": obj.get("resource_type"),
            "resource_id": obj.get("resource_id"),
            "resource_name": obj.get("resource_name"),
            "description": obj.get("description"),
            "created_at": obj.get("created_at"),
            "updated_at": obj.get("updated_at")
        })
        return _obj


