# coding: utf-8

"""
    GoodMem API

    API for interacting with the GoodMem service, providing vector-based memory storage and retrieval with multiple embedder support. The service enables creation of memory spaces, storing memories with vector representations, and efficient similarity-based retrieval.

    The version of the OpenAPI document: v1
    Contact: support@goodmem.io
    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 goodmem_client.models.chunking_configuration import ChunkingConfiguration
from typing import Optional, Set
from typing_extensions import Self

class UpdateSpaceRequest(BaseModel):
    """
    Request parameters for updating a space.
    """ # noqa: E501
    validate_label_strategy: Optional[Dict[str, Any]] = Field(default=None, alias="validateLabelStrategy")
    name: Optional[StrictStr] = Field(default=None, description="The new name for the space.")
    public_read: Optional[StrictBool] = Field(default=None, description="Whether the space is publicly readable by all users.", alias="publicRead")
    replace_labels: Optional[Dict[str, StrictStr]] = Field(default=None, description="Labels to replace all existing labels. Mutually exclusive with mergeLabels.", alias="replaceLabels")
    merge_labels: Optional[Dict[str, StrictStr]] = Field(default=None, description="Labels to merge with existing labels. Mutually exclusive with replaceLabels.", alias="mergeLabels")
    default_chunking_config: Optional[ChunkingConfiguration] = Field(default=None, alias="defaultChunkingConfig")
    __properties: ClassVar[List[str]] = ["validateLabelStrategy", "name", "publicRead", "replaceLabels", "mergeLabels", "defaultChunkingConfig"]

    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 UpdateSpaceRequest 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 default_chunking_config
        if self.default_chunking_config:
            _dict['defaultChunkingConfig'] = self.default_chunking_config.to_dict()
        # set to None if name (nullable) is None
        # and model_fields_set contains the field
        if self.name is None and "name" in self.model_fields_set:
            _dict['name'] = None

        # set to None if public_read (nullable) is None
        # and model_fields_set contains the field
        if self.public_read is None and "public_read" in self.model_fields_set:
            _dict['publicRead'] = None

        # set to None if replace_labels (nullable) is None
        # and model_fields_set contains the field
        if self.replace_labels is None and "replace_labels" in self.model_fields_set:
            _dict['replaceLabels'] = None

        # set to None if merge_labels (nullable) is None
        # and model_fields_set contains the field
        if self.merge_labels is None and "merge_labels" in self.model_fields_set:
            _dict['mergeLabels'] = None

        return _dict

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

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

        _obj = cls.model_validate({
            "validateLabelStrategy": obj.get("validateLabelStrategy"),
            "name": obj.get("name"),
            "publicRead": obj.get("publicRead"),
            "replaceLabels": obj.get("replaceLabels"),
            "mergeLabels": obj.get("mergeLabels"),
            "defaultChunkingConfig": ChunkingConfiguration.from_dict(obj["defaultChunkingConfig"]) if obj.get("defaultChunkingConfig") is not None else None
        })
        return _obj


