# 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, StrictInt, StrictStr
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 FeatureExtractorResponseModel(BaseModel):
    """
    Feature extractor response model for API responses.
    """ # noqa: E501
    feature_extractor_name: StrictStr
    version: StrictStr
    feature_extractor_id: StrictStr
    description: StrictStr
    icon: StrictStr
    source: Optional[ExtractorSource] = Field(default=None, description="The origin/source of this extractor: 'builtin' (shipped with Mixpeek), 'custom' (user-created), or 'community' (marketplace).")
    input_schema: Dict[str, Any]
    output_schema: Dict[str, Any]
    parameter_schema: Dict[str, Any]
    supported_input_types: List[StrictStr]
    max_inputs: Dict[str, StrictInt]
    default_parameters: Dict[str, Any]
    costs: Optional[CostsInfo] = Field(default=None, description="Credit cost information for this extractor")
    required_vector_indexes: List[VectorIndexDefinition]
    required_payload_indexes: List[PayloadIndexConfigOutput]
    position_fields: Optional[List[StrictStr]] = Field(default=None, description="Output fields that uniquely identify each document within a source object. Enables idempotent reprocessing: rerunning a batch produces the same document IDs, so existing documents are updated instead of creating duplicates. Works with bucket `unique_key` to enable fully deterministic document IDs. Empty list means single-output extractor (one document per source). Read-only (set by extractor).")
    __properties: ClassVar[List[str]] = ["feature_extractor_name", "version", "feature_extractor_id", "description", "icon", "source", "input_schema", "output_schema", "parameter_schema", "supported_input_types", "max_inputs", "default_parameters", "costs", "required_vector_indexes", "required_payload_indexes", "position_fields"]

    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 FeatureExtractorResponseModel 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 FeatureExtractorResponseModel 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"),
            "description": obj.get("description"),
            "icon": obj.get("icon"),
            "source": obj.get("source"),
            "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")
        })
        return _obj


