# coding: utf-8

"""
    Teambition Open API

    Teambition Open API

    The version of the OpenAPI document: 1.0.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, Field, StrictBool, StrictStr
from typing import Any, ClassVar, Dict, List, Optional
from teambition_oapi_sdk.model.copy_project_v3_response_result_customfields_inner import CopyProjectV3ResponseResultCustomfieldsInner
from typing import Optional, Set
from typing_extensions import Self

class CreateProjectV3ResponseResult(BaseModel):
    """
    项目详情
    """ # noqa: E501
    id: Optional[StrictStr] = Field(default=None, description="项目ID")
    name: Optional[StrictStr] = Field(default=None, description="项目名称")
    creator_id: Optional[StrictStr] = Field(default=None, description="创建人ID", alias="creatorId")
    logo: Optional[StrictStr] = Field(default=None, description="项目封面")
    organization_id: Optional[StrictStr] = Field(default=None, description="企业ID", alias="organizationId")
    visibility: Optional[StrictStr] = Field(default=None, description="项目可见性")
    unique_id_prefix: Optional[StrictStr] = Field(default=None, description="任务ID前缀", alias="uniqueIdPrefix")
    created: Optional[StrictStr] = Field(default=None, description="创建时间")
    updated: Optional[StrictStr] = Field(default=None, description="更新时间")
    is_archived: Optional[StrictBool] = Field(default=None, description="是否在回收站", alias="isArchived")
    is_suspended: Optional[StrictBool] = Field(default=None, description="是否归档", alias="isSuspended")
    normal_type: Optional[StrictStr] = Field(default=None, description="项目类型", alias="normalType")
    root_collection_id: Optional[StrictStr] = Field(default=None, description="项目根文件夹ID", alias="rootCollectionId")
    source_id: Optional[StrictStr] = Field(default=None, description="来源项目ID", alias="sourceId")
    default_collection_id: Optional[StrictStr] = Field(default=None, description="项目默认文件夹ID", alias="defaultCollectionId")
    is_template: Optional[StrictBool] = Field(default=None, description="是否为模版项目", alias="isTemplate")
    customfields: Optional[List[CopyProjectV3ResponseResultCustomfieldsInner]] = Field(default=None, description="自定义字段值集合")
    __properties: ClassVar[List[str]] = ["id", "name", "creatorId", "logo", "organizationId", "visibility", "uniqueIdPrefix", "created", "updated", "isArchived", "isSuspended", "normalType", "rootCollectionId", "sourceId", "defaultCollectionId", "isTemplate", "customfields"]

    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 CreateProjectV3ResponseResult 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 customfields (list)
        _items = []
        if self.customfields:
            for _item_customfields in self.customfields:
                if _item_customfields:
                    _items.append(_item_customfields.to_dict())
            _dict['customfields'] = _items
        return _dict

    @classmethod
    def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
        """Create an instance of CreateProjectV3ResponseResult 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"),
            "name": obj.get("name"),
            "creatorId": obj.get("creatorId"),
            "logo": obj.get("logo"),
            "organizationId": obj.get("organizationId"),
            "visibility": obj.get("visibility"),
            "uniqueIdPrefix": obj.get("uniqueIdPrefix"),
            "created": obj.get("created"),
            "updated": obj.get("updated"),
            "isArchived": obj.get("isArchived"),
            "isSuspended": obj.get("isSuspended"),
            "normalType": obj.get("normalType"),
            "rootCollectionId": obj.get("rootCollectionId"),
            "sourceId": obj.get("sourceId"),
            "defaultCollectionId": obj.get("defaultCollectionId"),
            "isTemplate": obj.get("isTemplate"),
            "customfields": [CopyProjectV3ResponseResultCustomfieldsInner.from_dict(_item) for _item in obj["customfields"]] if obj.get("customfields") is not None else None
        })
        return _obj


