# 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, StrictBool, StrictStr
from typing import Any, ClassVar, Dict, List, Optional
from typing_extensions import Annotated
from mixpeek.models.shared_collection_features_extractors_models_feature_extractor_config_input import SharedCollectionFeaturesExtractorsModelsFeatureExtractorConfigInput
from mixpeek.models.source_config_input import SourceConfigInput
from mixpeek.models.taxonomy_application_config_input import TaxonomyApplicationConfigInput
from typing import Optional, Set
from typing_extensions import Self

class CloneCollectionRequest(BaseModel):
    """
    Request to clone a collection with optional modifications.  **Purpose:** Cloning creates a NEW collection (with new ID) based on an existing one, allowing you to make changes that aren't allowed via PATCH (source, feature_extractor, field_passthrough). This is the recommended way to iterate on collection designs.  **Clone vs Template vs Version:** - **Clone**: Copy THIS collection and modify it (for iteration/fixes) - **Template**: Create collection from a reusable pattern (for new projects) - **Version**: (Not implemented) - Use clone instead  **Use Cases:** - Change feature extractor configuration without breaking production - Modify field_passthrough to include/exclude fields - Switch to different source (bucket or collection) - Test modifications before replacing production collection - Create variants (e.g., different embedding models)  **All fields are OPTIONAL:** - Omit a field to keep the original value - Provide a field to override the original value - collection_name is REQUIRED (clones must have unique names)
    """ # noqa: E501
    collection_name: Annotated[str, Field(min_length=1, strict=True)] = Field(description="REQUIRED. Name for the cloned collection. Must be unique and different from the source collection.")
    description: Optional[StrictStr] = Field(default=None, description="OPTIONAL. Description override. If omitted, copies from source collection.")
    source: Optional[SourceConfigInput] = Field(default=None, description="OPTIONAL. Override source configuration. If omitted, copies from source collection. Allows switching between buckets or collections.")
    feature_extractor: Optional[SharedCollectionFeaturesExtractorsModelsFeatureExtractorConfigInput] = Field(default=None, description="OPTIONAL. Override feature extractor configuration. If omitted, copies from source collection. This is where you'd change models, parameters, or field_passthrough.")
    enabled: Optional[StrictBool] = Field(default=None, description="OPTIONAL. Override enabled status. If omitted, copies from source collection.")
    metadata: Optional[Dict[str, Any]] = Field(default=None, description="OPTIONAL. Override metadata. If omitted, copies from source collection.")
    taxonomy_applications: Optional[List[TaxonomyApplicationConfigInput]] = Field(default=None, description="OPTIONAL. Override taxonomy applications. If omitted, copies from source collection.")
    __properties: ClassVar[List[str]] = ["collection_name", "description", "source", "feature_extractor", "enabled", "metadata", "taxonomy_applications"]

    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 CloneCollectionRequest 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 source
        if self.source:
            _dict['source'] = self.source.to_dict()
        # override the default output from pydantic by calling `to_dict()` of feature_extractor
        if self.feature_extractor:
            _dict['feature_extractor'] = self.feature_extractor.to_dict()
        # override the default output from pydantic by calling `to_dict()` of each item in taxonomy_applications (list)
        _items = []
        if self.taxonomy_applications:
            for _item_taxonomy_applications in self.taxonomy_applications:
                if _item_taxonomy_applications:
                    _items.append(_item_taxonomy_applications.to_dict())
            _dict['taxonomy_applications'] = _items
        return _dict

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

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

        _obj = cls.model_validate({
            "collection_name": obj.get("collection_name"),
            "description": obj.get("description"),
            "source": SourceConfigInput.from_dict(obj["source"]) if obj.get("source") is not None else None,
            "feature_extractor": SharedCollectionFeaturesExtractorsModelsFeatureExtractorConfigInput.from_dict(obj["feature_extractor"]) if obj.get("feature_extractor") is not None else None,
            "enabled": obj.get("enabled"),
            "metadata": obj.get("metadata"),
            "taxonomy_applications": [TaxonomyApplicationConfigInput.from_dict(_item) for _item in obj["taxonomy_applications"]] if obj.get("taxonomy_applications") is not None else None
        })
        return _obj


