# 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, StrictInt, StrictStr, field_validator
from typing import Any, ClassVar, Dict, List, Optional
from mixpeek.models.costs_info import CostsInfo
from mixpeek.models.extractor_source import ExtractorSource
from mixpeek.models.payload_index_config_output import PayloadIndexConfigOutput
from mixpeek.models.vector_index_definition import VectorIndexDefinition
from typing import Optional, Set
from typing_extensions import Self

class UnifiedExtractorResponse(BaseModel):
    """
    Unified extractor response combining builtin and custom plugins.  This model provides a consistent view of all extractors available to a namespace, regardless of whether they are builtin or custom.
    """ # noqa: E501
    feature_extractor_name: StrictStr = Field(description="Name of the feature extractor")
    version: StrictStr = Field(description="Version of the feature extractor")
    feature_extractor_id: StrictStr = Field(description="Unique identifier (name_version)")
    source: ExtractorSource = Field(description="Origin of this extractor: 'builtin' (shipped with Mixpeek), 'custom' (user-uploaded plugin), or 'community' (marketplace)")
    description: StrictStr = Field(description="Human-readable description")
    icon: Optional[StrictStr] = Field(default='box', description="Lucide-react icon name for frontend rendering")
    input_schema: Dict[str, Any] = Field(description="JSON schema for input data")
    output_schema: Dict[str, Any] = Field(description="JSON schema for output data")
    parameter_schema: Optional[Dict[str, Any]] = Field(default=None, description="JSON schema for parameters")
    supported_input_types: Optional[List[StrictStr]] = Field(default=None, description="Supported input types (video, image, text, etc.)")
    max_inputs: Optional[Dict[str, StrictInt]] = Field(default=None, description="Maximum number of inputs per type")
    default_parameters: Optional[Dict[str, Any]] = Field(default=None, description="Default parameter values")
    costs: Optional[CostsInfo] = Field(default=None, description="Credit cost information (builtin extractors only)")
    required_vector_indexes: Optional[List[VectorIndexDefinition]] = Field(default=None, description="Vector indexes this extractor produces")
    required_payload_indexes: Optional[List[PayloadIndexConfigOutput]] = Field(default=None, description="Payload indexes required by this extractor")
    position_fields: Optional[List[StrictStr]] = Field(default=None, description="Fields that identify unique positions within output documents. Used for deterministic document ID generation.")
    feature_uri: Optional[StrictStr] = Field(default=None, description="Primary feature URI (e.g., mixpeek://text_extractor@v1/embedding)")
    plugin_id: Optional[StrictStr] = Field(default=None, description="Plugin ID (custom plugins only)")
    deployed: Optional[StrictBool] = Field(default=None, description="Whether the plugin is deployed (custom plugins only)")
    validation_status: Optional[StrictStr] = Field(default=None, description="Validation status (custom plugins only)")
    created_at: Optional[datetime] = Field(default=None, description="Creation timestamp (custom plugins only)")
    updated_at: Optional[datetime] = Field(default=None, description="Last update timestamp (custom plugins only)")
    __properties: ClassVar[List[str]] = ["feature_extractor_name", "version", "feature_extractor_id", "source", "description", "icon", "input_schema", "output_schema", "parameter_schema", "supported_input_types", "max_inputs", "default_parameters", "costs", "required_vector_indexes", "required_payload_indexes", "position_fields", "feature_uri", "plugin_id", "deployed", "validation_status", "created_at", "updated_at"]

    @field_validator('validation_status')
    def validation_status_validate_enum(cls, value):
        """Validates the enum"""
        if value is None:
            return value

        if value not in set(['pending', 'passed', 'failed']):
            raise ValueError("must be one of enum values ('pending', 'passed', 'failed')")
        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 UnifiedExtractorResponse 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 costs
        if self.costs:
            _dict['costs'] = self.costs.to_dict()
        # override the default output from pydantic by calling `to_dict()` of each item in required_vector_indexes (list)
        _items = []
        if self.required_vector_indexes:
            for _item_required_vector_indexes in self.required_vector_indexes:
                if _item_required_vector_indexes:
                    _items.append(_item_required_vector_indexes.to_dict())
            _dict['required_vector_indexes'] = _items
        # override the default output from pydantic by calling `to_dict()` of each item in required_payload_indexes (list)
        _items = []
        if self.required_payload_indexes:
            for _item_required_payload_indexes in self.required_payload_indexes:
                if _item_required_payload_indexes:
                    _items.append(_item_required_payload_indexes.to_dict())
            _dict['required_payload_indexes'] = _items
        return _dict

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

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

        _obj = cls.model_validate({
            "feature_extractor_name": obj.get("feature_extractor_name"),
            "version": obj.get("version"),
            "feature_extractor_id": obj.get("feature_extractor_id"),
            "source": obj.get("source"),
            "description": obj.get("description"),
            "icon": obj.get("icon") if obj.get("icon") is not None else 'box',
            "input_schema": obj.get("input_schema"),
            "output_schema": obj.get("output_schema"),
            "parameter_schema": obj.get("parameter_schema"),
            "supported_input_types": obj.get("supported_input_types"),
            "max_inputs": obj.get("max_inputs"),
            "default_parameters": obj.get("default_parameters"),
            "costs": CostsInfo.from_dict(obj["costs"]) if obj.get("costs") is not None else None,
            "required_vector_indexes": [VectorIndexDefinition.from_dict(_item) for _item in obj["required_vector_indexes"]] if obj.get("required_vector_indexes") is not None else None,
            "required_payload_indexes": [PayloadIndexConfigOutput.from_dict(_item) for _item in obj["required_payload_indexes"]] if obj.get("required_payload_indexes") is not None else None,
            "position_fields": obj.get("position_fields"),
            "feature_uri": obj.get("feature_uri"),
            "plugin_id": obj.get("plugin_id"),
            "deployed": obj.get("deployed"),
            "validation_status": obj.get("validation_status"),
            "created_at": obj.get("created_at"),
            "updated_at": obj.get("updated_at")
        })
        return _obj


