# coding: utf-8

"""
    ibl-data-manager

    API for iblai

    The version of the OpenAPI document: 4.202.1-ai-plus
    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 datetime import datetime
from pydantic import BaseModel, ConfigDict, Field, StrictInt, StrictStr
from typing import Any, ClassVar, Dict, List, Optional
from typing_extensions import Annotated
from uuid import UUID
from typing import Optional, Set
from typing_extensions import Self

class PatchedAgentConfig(BaseModel):
    """
    PatchedAgentConfig
    """ # noqa: E501
    id: Optional[StrictInt] = None
    mentor: Optional[UUID] = None
    identity: Optional[StrictStr] = Field(default=None, description="Agent persona — name, creature type, visual description, vibe (→ IDENTITY.md).")
    soul: Optional[StrictStr] = Field(default=None, description="Behavioral guidelines — personality, communication style, values, boundaries (→ SOUL.md).")
    user_context: Optional[StrictStr] = Field(default=None, description="User-specific preferences and environment details — SSH hosts, device names, TTS voices (→ USER.md).")
    tools: Optional[StrictStr] = Field(default=None, description="Environment-specific reference notes for tool usage — device names, API aliases (→ TOOLS.md). Does not control which skills load.")
    agents: Optional[StrictStr] = Field(default=None, description="Multi-agent routing — agent IDs, workspaces, model assignments, channel bindings (→ AGENTS.md).")
    bootstrap: Optional[StrictStr] = Field(default=None, description="One-time first-run ritual — consumed and deleted by instance after use. Stored here for re-push on redeploy (→ BOOTSTRAP.md).")
    heartbeat: Optional[StrictStr] = Field(default=None, description="Periodic awareness checklist content. Schedule settings (interval, activeHours) go in config field (→ HEARTBEAT.md).")
    memory: Optional[StrictStr] = Field(default=None, description="Seed memory — long-term curated facts. Instance may modify its own copy over time (→ MEMORY.md).")
    model: Optional[Annotated[str, Field(strict=True, max_length=200)]] = Field(default=None, description="LLM model identifier (e.g. anthropic/claude-sonnet-4-5-20250929).")
    config: Optional[Any] = Field(default=None, description="Instance config patch sent via config.patch RPC — heartbeat schedule, session isolation, skill toggles, model fallbacks, etc.")
    created_at: Optional[datetime] = None
    updated_at: Optional[datetime] = None
    __properties: ClassVar[List[str]] = ["id", "mentor", "identity", "soul", "user_context", "tools", "agents", "bootstrap", "heartbeat", "memory", "model", "config", "created_at", "updated_at"]

    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 PatchedAgentConfig 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.
        * OpenAPI `readOnly` fields are excluded.
        * OpenAPI `readOnly` fields are excluded.
        * OpenAPI `readOnly` fields are excluded.
        """
        excluded_fields: Set[str] = set([
            "id",
            "created_at",
            "updated_at",
        ])

        _dict = self.model_dump(
            by_alias=True,
            exclude=excluded_fields,
            exclude_none=True,
        )
        # set to None if config (nullable) is None
        # and model_fields_set contains the field
        if self.config is None and "config" in self.model_fields_set:
            _dict['config'] = None

        return _dict

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

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

        _obj = cls.model_validate({
            "id": obj.get("id"),
            "mentor": obj.get("mentor"),
            "identity": obj.get("identity"),
            "soul": obj.get("soul"),
            "user_context": obj.get("user_context"),
            "tools": obj.get("tools"),
            "agents": obj.get("agents"),
            "bootstrap": obj.get("bootstrap"),
            "heartbeat": obj.get("heartbeat"),
            "memory": obj.get("memory"),
            "model": obj.get("model"),
            "config": obj.get("config"),
            "created_at": obj.get("created_at"),
            "updated_at": obj.get("updated_at")
        })
        return _obj


