# coding: utf-8

"""
    allure-testops-service

    Branch **HEAD**  Commit **623f6ed302ba4b651cf9040faca4635af2d93b7c**

    The version of the OpenAPI document: 25.4.1
    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
from typing import Any, ClassVar, Dict, List, Optional
from src.client.generated.models.diff_value_change_boolean import DiffValueChangeBoolean
from src.client.generated.models.diff_value_change_long import DiffValueChangeLong
from src.client.generated.models.diff_value_change_string import DiffValueChangeString
from typing import Optional, Set
from typing_extensions import Self

class TestCaseDiff(BaseModel):
    """
    TestCaseDiff
    """ # noqa: E501
    automated: Optional[DiffValueChangeBoolean] = None
    deleted: Optional[DiffValueChangeBoolean] = None
    description: Optional[DiffValueChangeString] = None
    description_html: Optional[DiffValueChangeString] = Field(default=None, alias="descriptionHtml")
    expected_result: Optional[DiffValueChangeString] = Field(default=None, alias="expectedResult")
    expected_result_html: Optional[DiffValueChangeString] = Field(default=None, alias="expectedResultHtml")
    full_name: Optional[DiffValueChangeString] = Field(default=None, alias="fullName")
    name: Optional[DiffValueChangeString] = None
    precondition: Optional[DiffValueChangeString] = None
    precondition_html: Optional[DiffValueChangeString] = Field(default=None, alias="preconditionHtml")
    project_id: Optional[DiffValueChangeLong] = Field(default=None, alias="projectId")
    status_id: Optional[DiffValueChangeLong] = Field(default=None, alias="statusId")
    test_layer_id: Optional[DiffValueChangeLong] = Field(default=None, alias="testLayerId")
    workflow_id: Optional[DiffValueChangeLong] = Field(default=None, alias="workflowId")
    __properties: ClassVar[List[str]] = ["automated", "deleted", "description", "descriptionHtml", "expectedResult", "expectedResultHtml", "fullName", "name", "precondition", "preconditionHtml", "projectId", "statusId", "testLayerId", "workflowId"]

    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 TestCaseDiff 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 automated
        if self.automated:
            _dict['automated'] = self.automated.to_dict()
        # override the default output from pydantic by calling `to_dict()` of deleted
        if self.deleted:
            _dict['deleted'] = self.deleted.to_dict()
        # override the default output from pydantic by calling `to_dict()` of description
        if self.description:
            _dict['description'] = self.description.to_dict()
        # override the default output from pydantic by calling `to_dict()` of description_html
        if self.description_html:
            _dict['descriptionHtml'] = self.description_html.to_dict()
        # override the default output from pydantic by calling `to_dict()` of expected_result
        if self.expected_result:
            _dict['expectedResult'] = self.expected_result.to_dict()
        # override the default output from pydantic by calling `to_dict()` of expected_result_html
        if self.expected_result_html:
            _dict['expectedResultHtml'] = self.expected_result_html.to_dict()
        # override the default output from pydantic by calling `to_dict()` of full_name
        if self.full_name:
            _dict['fullName'] = self.full_name.to_dict()
        # override the default output from pydantic by calling `to_dict()` of name
        if self.name:
            _dict['name'] = self.name.to_dict()
        # override the default output from pydantic by calling `to_dict()` of precondition
        if self.precondition:
            _dict['precondition'] = self.precondition.to_dict()
        # override the default output from pydantic by calling `to_dict()` of precondition_html
        if self.precondition_html:
            _dict['preconditionHtml'] = self.precondition_html.to_dict()
        # override the default output from pydantic by calling `to_dict()` of project_id
        if self.project_id:
            _dict['projectId'] = self.project_id.to_dict()
        # override the default output from pydantic by calling `to_dict()` of status_id
        if self.status_id:
            _dict['statusId'] = self.status_id.to_dict()
        # override the default output from pydantic by calling `to_dict()` of test_layer_id
        if self.test_layer_id:
            _dict['testLayerId'] = self.test_layer_id.to_dict()
        # override the default output from pydantic by calling `to_dict()` of workflow_id
        if self.workflow_id:
            _dict['workflowId'] = self.workflow_id.to_dict()
        return _dict

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

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

        _obj = cls.model_validate({
            "automated": DiffValueChangeBoolean.from_dict(obj["automated"]) if obj.get("automated") is not None else None,
            "deleted": DiffValueChangeBoolean.from_dict(obj["deleted"]) if obj.get("deleted") is not None else None,
            "description": DiffValueChangeString.from_dict(obj["description"]) if obj.get("description") is not None else None,
            "descriptionHtml": DiffValueChangeString.from_dict(obj["descriptionHtml"]) if obj.get("descriptionHtml") is not None else None,
            "expectedResult": DiffValueChangeString.from_dict(obj["expectedResult"]) if obj.get("expectedResult") is not None else None,
            "expectedResultHtml": DiffValueChangeString.from_dict(obj["expectedResultHtml"]) if obj.get("expectedResultHtml") is not None else None,
            "fullName": DiffValueChangeString.from_dict(obj["fullName"]) if obj.get("fullName") is not None else None,
            "name": DiffValueChangeString.from_dict(obj["name"]) if obj.get("name") is not None else None,
            "precondition": DiffValueChangeString.from_dict(obj["precondition"]) if obj.get("precondition") is not None else None,
            "preconditionHtml": DiffValueChangeString.from_dict(obj["preconditionHtml"]) if obj.get("preconditionHtml") is not None else None,
            "projectId": DiffValueChangeLong.from_dict(obj["projectId"]) if obj.get("projectId") is not None else None,
            "statusId": DiffValueChangeLong.from_dict(obj["statusId"]) if obj.get("statusId") is not None else None,
            "testLayerId": DiffValueChangeLong.from_dict(obj["testLayerId"]) if obj.get("testLayerId") is not None else None,
            "workflowId": DiffValueChangeLong.from_dict(obj["workflowId"]) if obj.get("workflowId") is not None else None
        })
        return _obj


