# 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 datetime import datetime
from pydantic import BaseModel, ConfigDict, Field, StrictStr, field_validator
from typing import Any, ClassVar, Dict, List, Optional
from typing import Optional, Set
from typing_extensions import Self

class UpdateSprintV3ResponseResult(BaseModel):
    """
    迭代更新结果
    """ # noqa: E501
    id: Optional[StrictStr] = Field(default=None, description="迭代 ID")
    name: Optional[StrictStr] = Field(default=None, description="迭代名称")
    executor_id: Optional[StrictStr] = Field(default=None, description="执行人 ID", alias="executorId")
    description: Optional[StrictStr] = Field(default=None, description="迭代描述")
    status: Optional[StrictStr] = Field(default=None, description="迭代状态")
    project_id: Optional[StrictStr] = Field(default=None, description="项目 ID", alias="projectId")
    creator_id: Optional[StrictStr] = Field(default=None, description="创建者用户 ID", alias="creatorId")
    start_date: Optional[datetime] = Field(default=None, description="开始时间", alias="startDate")
    due_date: Optional[datetime] = Field(default=None, description="结束时间", alias="dueDate")
    accomplished: Optional[datetime] = Field(default=None, description="完成时间")
    created: Optional[datetime] = None
    updated: Optional[datetime] = None
    payload: Optional[Dict[str, Any]] = Field(default=None, description="迭代补充字段，如迭代锁定等信息")
    __properties: ClassVar[List[str]] = ["id", "name", "executorId", "description", "status", "projectId", "creatorId", "startDate", "dueDate", "accomplished", "created", "updated", "payload"]

    @field_validator('status')
    def status_validate_enum(cls, value):
        """Validates the enum"""
        if value is None:
            return value

        if value not in set(['future', 'active', 'complete']):
            raise ValueError("must be one of enum values ('future', 'active', 'complete')")
        return value

    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 UpdateSprintV3ResponseResult 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,
        )
        return _dict

    @classmethod
    def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
        """Create an instance of UpdateSprintV3ResponseResult 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"),
            "executorId": obj.get("executorId"),
            "description": obj.get("description"),
            "status": obj.get("status"),
            "projectId": obj.get("projectId"),
            "creatorId": obj.get("creatorId"),
            "startDate": obj.get("startDate"),
            "dueDate": obj.get("dueDate"),
            "accomplished": obj.get("accomplished"),
            "created": obj.get("created"),
            "updated": obj.get("updated"),
            "payload": obj.get("payload")
        })
        return _obj


