# 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.normalized_scenario_dto_attachments_value import NormalizedScenarioDtoAttachmentsValue
from src.client.generated.models.normalized_scenario_step_dto import NormalizedScenarioStepDto
from typing import Optional, Set
from typing_extensions import Self

class NormalizedScenarioDto(BaseModel):
    """
    NormalizedScenarioDto
    """ # noqa: E501
    attachments: Optional[Dict[str, NormalizedScenarioDtoAttachmentsValue]] = None
    root: Optional[NormalizedScenarioStepDto] = None
    scenario_steps: Optional[Dict[str, NormalizedScenarioStepDto]] = Field(default=None, alias="scenarioSteps")
    shared_step_attachments: Optional[Dict[str, NormalizedScenarioDtoAttachmentsValue]] = Field(default=None, alias="sharedStepAttachments")
    shared_step_scenario_steps: Optional[Dict[str, NormalizedScenarioStepDto]] = Field(default=None, alias="sharedStepScenarioSteps")
    shared_steps: Optional[Dict[str, NormalizedScenarioStepDto]] = Field(default=None, alias="sharedSteps")
    __properties: ClassVar[List[str]] = ["attachments", "root", "scenarioSteps", "sharedStepAttachments", "sharedStepScenarioSteps", "sharedSteps"]

    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 NormalizedScenarioDto 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 value in attachments (dict)
        _field_dict = {}
        if self.attachments:
            for _key_attachments in self.attachments:
                if self.attachments[_key_attachments]:
                    _field_dict[_key_attachments] = self.attachments[_key_attachments].to_dict()
            _dict['attachments'] = _field_dict
        # override the default output from pydantic by calling `to_dict()` of root
        if self.root:
            _dict['root'] = self.root.to_dict()
        # override the default output from pydantic by calling `to_dict()` of each value in scenario_steps (dict)
        _field_dict = {}
        if self.scenario_steps:
            for _key_scenario_steps in self.scenario_steps:
                if self.scenario_steps[_key_scenario_steps]:
                    _field_dict[_key_scenario_steps] = self.scenario_steps[_key_scenario_steps].to_dict()
            _dict['scenarioSteps'] = _field_dict
        # override the default output from pydantic by calling `to_dict()` of each value in shared_step_attachments (dict)
        _field_dict = {}
        if self.shared_step_attachments:
            for _key_shared_step_attachments in self.shared_step_attachments:
                if self.shared_step_attachments[_key_shared_step_attachments]:
                    _field_dict[_key_shared_step_attachments] = self.shared_step_attachments[_key_shared_step_attachments].to_dict()
            _dict['sharedStepAttachments'] = _field_dict
        # override the default output from pydantic by calling `to_dict()` of each value in shared_step_scenario_steps (dict)
        _field_dict = {}
        if self.shared_step_scenario_steps:
            for _key_shared_step_scenario_steps in self.shared_step_scenario_steps:
                if self.shared_step_scenario_steps[_key_shared_step_scenario_steps]:
                    _field_dict[_key_shared_step_scenario_steps] = self.shared_step_scenario_steps[_key_shared_step_scenario_steps].to_dict()
            _dict['sharedStepScenarioSteps'] = _field_dict
        # override the default output from pydantic by calling `to_dict()` of each value in shared_steps (dict)
        _field_dict = {}
        if self.shared_steps:
            for _key_shared_steps in self.shared_steps:
                if self.shared_steps[_key_shared_steps]:
                    _field_dict[_key_shared_steps] = self.shared_steps[_key_shared_steps].to_dict()
            _dict['sharedSteps'] = _field_dict
        return _dict

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

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

        _obj = cls.model_validate({
            "attachments": dict(
                (_k, NormalizedScenarioDtoAttachmentsValue.from_dict(_v))
                for _k, _v in obj["attachments"].items()
            )
            if obj.get("attachments") is not None
            else None,
            "root": NormalizedScenarioStepDto.from_dict(obj["root"]) if obj.get("root") is not None else None,
            "scenarioSteps": dict(
                (_k, NormalizedScenarioStepDto.from_dict(_v))
                for _k, _v in obj["scenarioSteps"].items()
            )
            if obj.get("scenarioSteps") is not None
            else None,
            "sharedStepAttachments": dict(
                (_k, NormalizedScenarioDtoAttachmentsValue.from_dict(_v))
                for _k, _v in obj["sharedStepAttachments"].items()
            )
            if obj.get("sharedStepAttachments") is not None
            else None,
            "sharedStepScenarioSteps": dict(
                (_k, NormalizedScenarioStepDto.from_dict(_v))
                for _k, _v in obj["sharedStepScenarioSteps"].items()
            )
            if obj.get("sharedStepScenarioSteps") is not None
            else None,
            "sharedSteps": dict(
                (_k, NormalizedScenarioStepDto.from_dict(_v))
                for _k, _v in obj["sharedSteps"].items()
            )
            if obj.get("sharedSteps") is not None
            else None
        })
        return _obj


