# 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, StrictStr
from typing import Any, ClassVar, Dict, List, Optional
from typing_extensions import Annotated
from mixpeek.models.display_config_input import DisplayConfigInput
from typing import Optional, Set
from typing_extensions import Self

class PatchRetrieverRequest(BaseModel):
    """
    Request to update a retriever's metadata.  **IMPORTANT: Partial Updates with Controlled Mutability**  This endpoint allows updating ONLY metadata fields. Core retriever logic is immutable to ensure consistency for dependent resources (taxonomies, cached results, etc.).  **✅ Fields You CAN Update (Metadata Only):** - `retriever_name`: Rename the retriever - `description`: Update documentation - `tags`: Update organization tags - `display_config`: Update display configuration for publishing  **❌ Fields You CANNOT Update (Immutable Core Logic):** - `input_schema`: Input field definitions (breaks dependent taxonomies) - `stages`: Retriever stages and configurations (changes matching behavior) - `collection_ids`: Target collections (changes data sources) - `budget_limits`: Budget constraints (affects execution behavior)  **Need to Modify Core Logic?** Use POST /retrievers/{retriever_id}/clone instead. Cloning creates a new retriever with a new ID, allowing you to: - Fix typos in stage names - Add or remove stages - Change target collections - Modify input schema or budget limits  **Behavior:** - All fields are OPTIONAL - provide only what you want to update - Version number automatically increments on each update - Empty updates (no fields provided) will be rejected with 400 error - Original retriever remains unchanged (no destructive operations)  **Why This Design?** - Taxonomies reference retrievers by ID and expect consistent behavior - Cached results remain valid after metadata-only changes - Version tracking enables auditing and rollback - Published retrievers maintain stable behavior for consumers
    """ # noqa: E501
    retriever_name: Optional[Annotated[str, Field(min_length=1, strict=True)]] = Field(default=None, description="Updated retriever name. OPTIONAL - only provide if you want to rename the retriever.")
    description: Optional[StrictStr] = Field(default=None, description="Updated human-readable description. OPTIONAL - only provide if you want to update the description.")
    tags: Optional[List[StrictStr]] = Field(default=None, description="Updated tags for organization and filtering. OPTIONAL - replaces existing tags if provided.")
    display_config: Optional[DisplayConfigInput] = Field(default=None, description="Updated display configuration for public retriever UI rendering. OPTIONAL - only provide if you want to update the display settings. Defines how the search interface should appear when published.")
    __properties: ClassVar[List[str]] = ["retriever_name", "description", "tags", "display_config"]

    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 PatchRetrieverRequest 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()
        return _dict

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

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

        _obj = cls.model_validate({
            "retriever_name": obj.get("retriever_name"),
            "description": obj.get("description"),
            "tags": obj.get("tags"),
            "display_config": DisplayConfigInput.from_dict(obj["display_config"]) if obj.get("display_config") is not None else None
        })
        return _obj


