# 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, StrictStr
from typing import Any, ClassVar, Dict, List, Optional
from teambition_oapi_sdk.model.get_plan_v3_response_result_approval_info import GetPlanV3ResponseResultApprovalInfo
from teambition_oapi_sdk.model.get_plan_v3_response_result_change_rule import GetPlanV3ResponseResultChangeRule
from teambition_oapi_sdk.model.get_plan_v3_response_result_latest_online_version import GetPlanV3ResponseResultLatestOnlineVersion
from teambition_oapi_sdk.model.get_plan_v3_response_result_latest_version import GetPlanV3ResponseResultLatestVersion
from typing import Optional, Set
from typing_extensions import Self

class GetPlanV3ResponseResult(BaseModel):
    """
    GetPlanV3ResponseResult
    """ # noqa: E501
    id: Optional[StrictStr] = Field(default=None, description="计划ID")
    organization_id: Optional[StrictStr] = Field(default=None, description="组织ID", alias="organizationId")
    project_id: Optional[StrictStr] = Field(default=None, description="项目ID", alias="projectId")
    virtual_project_id: Optional[StrictStr] = Field(default=None, description="虚拟项目ID", alias="virtualProjectId")
    subject: Optional[StrictStr] = Field(default=None, description="计划标题")
    start_date: Optional[StrictStr] = Field(default=None, description="计划开始时间(UTC)", alias="startDate")
    due_date: Optional[StrictStr] = Field(default=None, description="计划截止时间(UTC)", alias="dueDate")
    status: Optional[StrictStr] = Field(default=None, description="计划状态")
    creator_id: Optional[StrictStr] = Field(default=None, description="创建者ID", alias="creatorId")
    created: Optional[StrictStr] = Field(default=None, description="创建时间(UTC)")
    modifier_id: Optional[StrictStr] = Field(default=None, description="修改者ID", alias="modifierId")
    updated: Optional[StrictStr] = Field(default=None, description="更新时间(UTC)")
    visible: Optional[StrictStr] = Field(default=None, description="计划可见性")
    publish_time: Optional[StrictStr] = Field(default=None, description="发布时间(UTC)", alias="publishTime")
    publish_user_id: Optional[StrictStr] = Field(default=None, description="发布者ID", alias="publishUserId")
    change_rule: Optional[GetPlanV3ResponseResultChangeRule] = Field(default=None, alias="changeRule")
    approval_info: Optional[GetPlanV3ResponseResultApprovalInfo] = Field(default=None, alias="approvalInfo")
    latest_online_version: Optional[GetPlanV3ResponseResultLatestOnlineVersion] = Field(default=None, alias="latestOnlineVersion")
    latest_version: Optional[GetPlanV3ResponseResultLatestVersion] = Field(default=None, alias="latestVersion")
    __properties: ClassVar[List[str]] = ["id", "organizationId", "projectId", "virtualProjectId", "subject", "startDate", "dueDate", "status", "creatorId", "created", "modifierId", "updated", "visible", "publishTime", "publishUserId", "changeRule", "approvalInfo", "latestOnlineVersion", "latestVersion"]

    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 GetPlanV3ResponseResult 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 change_rule
        if self.change_rule:
            _dict['changeRule'] = self.change_rule.to_dict()
        # override the default output from pydantic by calling `to_dict()` of approval_info
        if self.approval_info:
            _dict['approvalInfo'] = self.approval_info.to_dict()
        # override the default output from pydantic by calling `to_dict()` of latest_online_version
        if self.latest_online_version:
            _dict['latestOnlineVersion'] = self.latest_online_version.to_dict()
        # override the default output from pydantic by calling `to_dict()` of latest_version
        if self.latest_version:
            _dict['latestVersion'] = self.latest_version.to_dict()
        return _dict

    @classmethod
    def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
        """Create an instance of GetPlanV3ResponseResult 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"),
            "organizationId": obj.get("organizationId"),
            "projectId": obj.get("projectId"),
            "virtualProjectId": obj.get("virtualProjectId"),
            "subject": obj.get("subject"),
            "startDate": obj.get("startDate"),
            "dueDate": obj.get("dueDate"),
            "status": obj.get("status"),
            "creatorId": obj.get("creatorId"),
            "created": obj.get("created"),
            "modifierId": obj.get("modifierId"),
            "updated": obj.get("updated"),
            "visible": obj.get("visible"),
            "publishTime": obj.get("publishTime"),
            "publishUserId": obj.get("publishUserId"),
            "changeRule": GetPlanV3ResponseResultChangeRule.from_dict(obj["changeRule"]) if obj.get("changeRule") is not None else None,
            "approvalInfo": GetPlanV3ResponseResultApprovalInfo.from_dict(obj["approvalInfo"]) if obj.get("approvalInfo") is not None else None,
            "latestOnlineVersion": GetPlanV3ResponseResultLatestOnlineVersion.from_dict(obj["latestOnlineVersion"]) if obj.get("latestOnlineVersion") is not None else None,
            "latestVersion": GetPlanV3ResponseResultLatestVersion.from_dict(obj["latestVersion"]) if obj.get("latestVersion") is not None else None
        })
        return _obj


