# 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, StrictInt, StrictStr
from typing import Any, ClassVar, Dict, List, Optional
from teambition_oapi_sdk.model.create_test_case_v3_request_steps_inner import CreateTestCaseV3RequestStepsInner
from teambition_oapi_sdk.model.query_test_cases_v3_response_result_inner_customfields_inner import QueryTestCasesV3ResponseResultInnerCustomfieldsInner
from typing import Optional, Set
from typing_extensions import Self

class QueryTestCasesV3ResponseResultInner(BaseModel):
    """
    QueryTestCasesV3ResponseResultInner
    """ # noqa: E501
    accomplished: Optional[StrictStr] = Field(default=None, description="完成时间")
    case_type: Optional[StrictStr] = Field(default=None, description="用例类型", alias="caseType")
    created: Optional[StrictStr] = Field(default=None, description="测试用例创建时间(UTC)")
    creator_id: Optional[StrictStr] = Field(default=None, description="创建者 ID", alias="creatorId")
    customfields: Optional[List[QueryTestCasesV3ResponseResultInnerCustomfieldsInner]] = Field(default=None, description="自定义字段值集合")
    executor_id: Optional[StrictStr] = Field(default=None, description="执行者ID", alias="executorId")
    flowstatus_id: Optional[StrictStr] = Field(default=None, description="工作流状态 ID", alias="flowstatusId")
    from_hub_testcase_id: Optional[StrictStr] = Field(default=None, description="关联的基础用例ID", alias="fromHubTestcaseId")
    id: Optional[StrictStr] = Field(default=None, description="测试用例 ID")
    involve_members: Optional[List[StrictStr]] = Field(default=None, description="参与者", alias="involveMembers")
    is_archived: Optional[StrictStr] = Field(default=None, description="是否归档", alias="isArchived")
    is_deleted: Optional[StrictBool] = Field(default=None, description="是否删除", alias="isDeleted")
    is_done: Optional[StrictBool] = Field(default=None, description="是否完成", alias="isDone")
    is_suspended: Optional[StrictBool] = Field(default=None, description="是否归档", alias="isSuspended")
    organization_id: Optional[StrictStr] = Field(default=None, description="企业 ID", alias="organizationId")
    pos: Optional[StrictInt] = Field(default=None, description="用例位置")
    precondition: Optional[StrictStr] = Field(default=None, description="前置条件")
    priority: Optional[StrictInt] = Field(default=None, description="用例等级")
    project_id: Optional[StrictStr] = Field(default=None, description="项目 ID", alias="projectId")
    sfc_id: Optional[StrictStr] = Field(default=None, description="任务类型 ID", alias="sfcId")
    commongroup: Optional[Dict[str, Any]] = Field(default=None, description="分组 ID")
    steps: Optional[List[CreateTestCaseV3RequestStepsInner]] = Field(default=None, description="步骤列表")
    tag_ids: Optional[List[StrictStr]] = Field(default=None, description="标签", alias="tagIds")
    testhub_id: Optional[StrictStr] = Field(default=None, description="用例库 ID", alias="testhubId")
    testplan_id: Optional[StrictStr] = Field(default=None, description="测试计划 ID", alias="testplanId")
    title: Optional[StrictStr] = Field(default=None, description="用例名称")
    unique_id: Optional[StrictInt] = Field(default=None, description="短ID", alias="uniqueId")
    updated: Optional[StrictStr] = Field(default=None, description="测试用例更新时间(UTC)")
    __properties: ClassVar[List[str]] = ["accomplished", "caseType", "created", "creatorId", "customfields", "executorId", "flowstatusId", "fromHubTestcaseId", "id", "involveMembers", "isArchived", "isDeleted", "isDone", "isSuspended", "organizationId", "pos", "precondition", "priority", "projectId", "sfcId", "commongroup", "steps", "tagIds", "testhubId", "testplanId", "title", "uniqueId", "updated"]

    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 QueryTestCasesV3ResponseResultInner 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
        # override the default output from pydantic by calling `to_dict()` of each item in steps (list)
        _items = []
        if self.steps:
            for _item_steps in self.steps:
                if _item_steps:
                    _items.append(_item_steps.to_dict())
            _dict['steps'] = _items
        return _dict

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

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

        _obj = cls.model_validate({
            "accomplished": obj.get("accomplished"),
            "caseType": obj.get("caseType"),
            "created": obj.get("created"),
            "creatorId": obj.get("creatorId"),
            "customfields": [QueryTestCasesV3ResponseResultInnerCustomfieldsInner.from_dict(_item) for _item in obj["customfields"]] if obj.get("customfields") is not None else None,
            "executorId": obj.get("executorId"),
            "flowstatusId": obj.get("flowstatusId"),
            "fromHubTestcaseId": obj.get("fromHubTestcaseId"),
            "id": obj.get("id"),
            "involveMembers": obj.get("involveMembers"),
            "isArchived": obj.get("isArchived"),
            "isDeleted": obj.get("isDeleted"),
            "isDone": obj.get("isDone"),
            "isSuspended": obj.get("isSuspended"),
            "organizationId": obj.get("organizationId"),
            "pos": obj.get("pos"),
            "precondition": obj.get("precondition"),
            "priority": obj.get("priority"),
            "projectId": obj.get("projectId"),
            "sfcId": obj.get("sfcId"),
            "commongroup": obj.get("commongroup"),
            "steps": [CreateTestCaseV3RequestStepsInner.from_dict(_item) for _item in obj["steps"]] if obj.get("steps") is not None else None,
            "tagIds": obj.get("tagIds"),
            "testhubId": obj.get("testhubId"),
            "testplanId": obj.get("testplanId"),
            "title": obj.get("title"),
            "uniqueId": obj.get("uniqueId"),
            "updated": obj.get("updated")
        })
        return _obj


