# coding: utf-8

"""
    Mentortools Chat API

    Mentortools service for chatting

    The version of the OpenAPI document: 0.1.0
    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, StrictBool, StrictInt, StrictStr
from typing import Any, ClassVar, Dict, List, Optional
from chat_server_connector_v2.models.ai_assistant_goal_get import AiAssistantGoalGet
from chat_server_connector_v2.models.ai_assistant_lexicon_item import AiAssistantLexiconItem
from chat_server_connector_v2.models.assistant_function import AssistantFunction
from chat_server_connector_v2.models.assistant_type import AssistantType
from chat_server_connector_v2.models.conversation_style import ConversationStyle
from chat_server_connector_v2.models.knowledgebase_state import KnowledgebaseState
from typing import Optional, Set
from typing_extensions import Self
from pydantic_core import to_jsonable_python

class AiAssistantGet(BaseModel):
    """
    AiAssistantGet
    """ # noqa: E501
    allow_text: StrictBool
    allow_voice: StrictBool
    approved_urls: List[StrictStr]
    avatar_id: Optional[StrictStr] = None
    banned_keywords: List[StrictStr]
    conversation_starter: Optional[StrictStr] = None
    conversation_style: ConversationStyle
    created_at: StrictInt
    deleted_at: Optional[StrictInt] = None
    function: AssistantFunction
    goals: Optional[List[AiAssistantGoalGet]] = None
    id: StrictInt
    is_active: StrictBool
    is_available: Optional[StrictBool] = False
    is_live: StrictBool
    knowledgebase_state: Optional[KnowledgebaseState] = None
    last_updated_at: StrictInt
    lexicon_items: Optional[List[AiAssistantLexiconItem]] = None
    name: StrictStr
    prefer_voice: StrictBool
    system_prompt: Optional[StrictStr] = None
    system_prompt_support: Optional[StrictStr] = None
    system_prompt_tutor: Optional[StrictStr] = None
    type: AssistantType
    voice_id: StrictInt
    __properties: ClassVar[List[str]] = ["allow_text", "allow_voice", "approved_urls", "avatar_id", "banned_keywords", "conversation_starter", "conversation_style", "created_at", "deleted_at", "function", "goals", "id", "is_active", "is_available", "is_live", "knowledgebase_state", "last_updated_at", "lexicon_items", "name", "prefer_voice", "system_prompt", "system_prompt_support", "system_prompt_tutor", "type", "voice_id"]

    model_config = ConfigDict(
        validate_by_name=True,
        validate_by_alias=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"""
        return json.dumps(to_jsonable_python(self.to_dict()))

    @classmethod
    def from_json(cls, json_str: str) -> Optional[Self]:
        """Create an instance of AiAssistantGet 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 each item in goals (list)
        _items = []
        if self.goals:
            for _item_goals in self.goals:
                if _item_goals:
                    _items.append(_item_goals.to_dict())
            _dict['goals'] = _items
        # override the default output from pydantic by calling `to_dict()` of knowledgebase_state
        if self.knowledgebase_state:
            _dict['knowledgebase_state'] = self.knowledgebase_state.to_dict()
        # override the default output from pydantic by calling `to_dict()` of each item in lexicon_items (list)
        _items = []
        if self.lexicon_items:
            for _item_lexicon_items in self.lexicon_items:
                if _item_lexicon_items:
                    _items.append(_item_lexicon_items.to_dict())
            _dict['lexicon_items'] = _items
        return _dict

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

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

        _obj = cls.model_validate({
            "allow_text": obj.get("allow_text"),
            "allow_voice": obj.get("allow_voice"),
            "approved_urls": obj.get("approved_urls"),
            "avatar_id": obj.get("avatar_id"),
            "banned_keywords": obj.get("banned_keywords"),
            "conversation_starter": obj.get("conversation_starter"),
            "conversation_style": obj.get("conversation_style"),
            "created_at": obj.get("created_at"),
            "deleted_at": obj.get("deleted_at"),
            "function": obj.get("function"),
            "goals": [AiAssistantGoalGet.from_dict(_item) for _item in obj["goals"]] if obj.get("goals") is not None else None,
            "id": obj.get("id"),
            "is_active": obj.get("is_active"),
            "is_available": obj.get("is_available") if obj.get("is_available") is not None else False,
            "is_live": obj.get("is_live"),
            "knowledgebase_state": KnowledgebaseState.from_dict(obj["knowledgebase_state"]) if obj.get("knowledgebase_state") is not None else None,
            "last_updated_at": obj.get("last_updated_at"),
            "lexicon_items": [AiAssistantLexiconItem.from_dict(_item) for _item in obj["lexicon_items"]] if obj.get("lexicon_items") is not None else None,
            "name": obj.get("name"),
            "prefer_voice": obj.get("prefer_voice"),
            "system_prompt": obj.get("system_prompt"),
            "system_prompt_support": obj.get("system_prompt_support"),
            "system_prompt_tutor": obj.get("system_prompt_tutor"),
            "type": obj.get("type"),
            "voice_id": obj.get("voice_id")
        })
        return _obj


