# coding: utf-8

"""
    XingChen 开放接口定义

    No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)

    The version of the OpenAPI document: v2
    Generated by OpenAPI Generator (https://openapi-generator.tech)

    Do not edit the class manually.
"""  # noqa: E501

from __future__ import annotations

import json
import pprint
import re  # noqa: F401
from typing import Optional

from pydantic import BaseModel, Field, StrictInt, StrictStr, constr, conlist

from xingchen.models.character_advanced_config import CharacterAdvancedConfig
from xingchen.models.file_info_vo import FileInfoVO


class CharacterVersionCreateOrUpdateDTO(BaseModel):
    """
    角色版本创建或更新对象  # noqa: E501
    """
    name: constr(strict=True, max_length=20, min_length=1) = Field(..., description="角色名称(最多20个字符)")
    avatar: Optional[FileInfoVO] = None
    introduction: Optional[StrictStr] = Field(None, description="角色描述")
    basic_information: StrictStr = Field(..., alias="basicInformation", description="基本信息")
    opening_line: Optional[StrictStr] = Field(None, alias="openingLine", description="开场白")
    traits: Optional[StrictStr] = Field(None, description="角色特点")
    chat_example: Optional[StrictStr] = Field(None, alias="chatExample", description="聊天示例")
    type: Optional[StrictStr] = Field(None, description="角色类型，virtual:虚拟角色，reproduction:已知角色复刻")
    chat_objective: Optional[StrictStr] = Field(None, alias="chatObjective", description="对话目标")
    advanced_config: Optional[CharacterAdvancedConfig] = Field(None, alias="advancedConfig")
    character_id: StrictStr = Field(..., alias="characterId", description="角色标识")
    version: Optional[StrictInt] = Field(None, description="角色版本，相同角色版本号唯一")
    role_types: Optional[conlist(StrictStr)] = Field(None, alias="roleTypes", description="角色类型")
    __properties = ["name", "avatar", "introduction", "basicInformation", "openingLine", "traits", "chatExample",
                    "type", "chatObjective", "advancedConfig", "characterId", "version", "roleTypes"]

    class Config:
        """Pydantic configuration"""
        allow_population_by_field_name = True
        validate_assignment = True

    def to_str(self) -> str:
        """Returns the string representation of the model using alias"""
        return pprint.pformat(self.dict(by_alias=True))

    def to_json(self) -> str:
        """Returns the JSON representation of the model using alias"""
        return json.dumps(self.to_dict())

    @classmethod
    def from_json(cls, json_str: str) -> CharacterVersionCreateOrUpdateDTO:
        """Create an instance of CharacterVersionCreateOrUpdateDTO from a JSON string"""
        return cls.from_dict(json.loads(json_str))

    def to_dict(self):
        """Returns the dictionary representation of the model using alias"""
        _dict = self.dict(by_alias=True,
                          exclude={
                          },
                          exclude_none=True)
        # override the default output from pydantic by calling `to_dict()` of avatar
        if self.avatar:
            _dict['avatar'] = self.avatar.to_dict()
        # override the default output from pydantic by calling `to_dict()` of advanced_config
        if self.advanced_config:
            _dict['advancedConfig'] = self.advanced_config.to_dict()
        return _dict

    @classmethod
    def from_dict(cls, obj: dict) -> CharacterVersionCreateOrUpdateDTO:
        """Create an instance of CharacterVersionCreateOrUpdateDTO from a dict"""
        if obj is None:
            return None

        if not isinstance(obj, dict):
            return CharacterVersionCreateOrUpdateDTO.parse_obj(obj)

        _obj = CharacterVersionCreateOrUpdateDTO.parse_obj({
            "name": obj.get("name"),
            "avatar": FileInfoVO.from_dict(obj.get("avatar")) if obj.get("avatar") is not None else None,
            "introduction": obj.get("introduction"),
            "basic_information": obj.get("basicInformation"),
            "opening_line": obj.get("openingLine"),
            "traits": obj.get("traits"),
            "chat_example": obj.get("chatExample"),
            "type": obj.get("type"),
            "chat_objective": obj.get("chatObjective"),
            "advanced_config": CharacterAdvancedConfig.from_dict(obj.get("advancedConfig")) if obj.get(
                "advancedConfig") is not None else None,
            "character_id": obj.get("characterId"),
            "version": obj.get("version"),
            "role_types": obj.get("roleTypes"),
        })
        return _obj
