# coding: utf-8

"""
    smritea SDK API

    Public SDK API for smritea AI memory system — programmatic memory operations via API key

    The version of the OpenAPI document: 1.0.0
    Contact: support@smritea.ai
    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, StrictFloat, StrictInt, StrictStr, field_validator
from typing import Any, ClassVar, Dict, List, Optional, Union
from smritea._internal.autogen.smritea_cloud_sdk.models.model_enums_search_method import ModelEnumsSearchMethod
from typing import Optional, Set
from typing_extensions import Self

class MemorySearchMemoryRequest(BaseModel):
    """
    MemorySearchMemoryRequest
    """ # noqa: E501
    actor_id: Optional[StrictStr] = None
    actor_type: Optional[StrictStr] = Field(default=None, description="ActorType filters search to messages from a specific actor type (optional). Values: \"user\", \"agent\", \"system\"")
    app_id: StrictStr
    conversation_id: Optional[StrictStr] = Field(default=None, description="ConversationID filters search to a specific conversation (optional). If omitted, searches across all actor's memories.")
    from_time: Optional[StrictStr] = Field(default=None, description="FromTime filters memories that overlap with time range [FromTime, ToTime] (ISO 8601 format). Must be used together with ToTime.")
    graph_depth: Optional[StrictInt] = Field(default=None, description="0=use app config, 1-5=override traversal depth")
    limit: Optional[StrictInt] = None
    method: Optional[ModelEnumsSearchMethod] = None
    query: StrictStr
    threshold: Optional[Union[StrictFloat, StrictInt]] = Field(default=None, description="0=no filtering (pipeline uses RRF scores, not cosine similarity)")
    to_time: Optional[StrictStr] = Field(default=None, description="ToTime is the end of the time range filter (ISO 8601 format). Must be used together with FromTime.")
    valid_at: Optional[StrictStr] = Field(default=None, description="ValidAt filters memories valid at a specific point in time (ISO 8601 format). A memory is valid if: active_from <= ValidAt AND (active_to is null OR active_to >= ValidAt) Mutually exclusive with FromTime/ToTime.")
    __properties: ClassVar[List[str]] = ["actor_id", "actor_type", "app_id", "conversation_id", "from_time", "graph_depth", "limit", "method", "query", "threshold", "to_time", "valid_at"]

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

        if value not in set(['user', 'agent', 'system']):
            raise ValueError("must be one of enum values ('user', 'agent', 'system')")
        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 MemorySearchMemoryRequest 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,
        )
        return _dict

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

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

        _obj = cls.model_validate({
            "actor_id": obj.get("actor_id"),
            "actor_type": obj.get("actor_type"),
            "app_id": obj.get("app_id"),
            "conversation_id": obj.get("conversation_id"),
            "from_time": obj.get("from_time"),
            "graph_depth": obj.get("graph_depth"),
            "limit": obj.get("limit"),
            "method": obj.get("method"),
            "query": obj.get("query"),
            "threshold": obj.get("threshold"),
            "to_time": obj.get("to_time"),
            "valid_at": obj.get("valid_at")
        })
        return _obj


