# coding: utf-8

"""
    Snowstorm

    SNOMED CT Terminology Server REST API

    The version of the OpenAPI document: 10.8.2
    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, StrictStr
from typing import Any, ClassVar, Dict, List, Optional
from snowstorm_client.models.annotation_component import AnnotationComponent
from snowstorm_client.models.axiom_component import AxiomComponent
from snowstorm_client.models.description_component import DescriptionComponent
from snowstorm_client.models.identifier_component import IdentifierComponent
from snowstorm_client.models.invalid_content_component import InvalidContentComponent
from snowstorm_client.models.relationship_component import RelationshipComponent
from snowstorm_client.models.term_lang_pojo_component import TermLangPojoComponent
from typing import Optional, Set
from typing_extensions import Self

class ConceptViewComponent(BaseModel):
    """
    ConceptViewComponent
    """ # noqa: E501
    annotations: Optional[List[AnnotationComponent]] = None
    active: Optional[StrictBool] = None
    concept_id: Optional[StrictStr] = Field(default=None, alias="conceptId")
    effective_time: Optional[StrictStr] = Field(default=None, alias="effectiveTime")
    pt: Optional[TermLangPojoComponent] = None
    descriptions: Optional[List[DescriptionComponent]] = None
    fsn: Optional[TermLangPojoComponent] = None
    relationships: Optional[List[RelationshipComponent]] = None
    definition_status_id: Optional[StrictStr] = Field(default=None, alias="definitionStatusId")
    module_id: Optional[StrictStr] = Field(default=None, alias="moduleId")
    class_axioms: Optional[List[AxiomComponent]] = Field(default=None, alias="classAxioms")
    gci_axioms: Optional[List[AxiomComponent]] = Field(default=None, alias="gciAxioms")
    identifiers: Optional[List[IdentifierComponent]] = None
    validation_results: Optional[List[InvalidContentComponent]] = Field(default=None, alias="validationResults")
    __properties: ClassVar[List[str]] = ["annotations", "active", "conceptId", "effectiveTime", "pt", "descriptions", "fsn", "relationships", "definitionStatusId", "moduleId", "classAxioms", "gciAxioms", "identifiers", "validationResults"]

    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 ConceptViewComponent 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 annotations (list)
        _items = []
        if self.annotations:
            for _item_annotations in self.annotations:
                if _item_annotations:
                    _items.append(_item_annotations.to_dict())
            _dict['annotations'] = _items
        # override the default output from pydantic by calling `to_dict()` of pt
        if self.pt:
            _dict['pt'] = self.pt.to_dict()
        # override the default output from pydantic by calling `to_dict()` of each item in descriptions (list)
        _items = []
        if self.descriptions:
            for _item_descriptions in self.descriptions:
                if _item_descriptions:
                    _items.append(_item_descriptions.to_dict())
            _dict['descriptions'] = _items
        # override the default output from pydantic by calling `to_dict()` of fsn
        if self.fsn:
            _dict['fsn'] = self.fsn.to_dict()
        # override the default output from pydantic by calling `to_dict()` of each item in relationships (list)
        _items = []
        if self.relationships:
            for _item_relationships in self.relationships:
                if _item_relationships:
                    _items.append(_item_relationships.to_dict())
            _dict['relationships'] = _items
        # override the default output from pydantic by calling `to_dict()` of each item in class_axioms (list)
        _items = []
        if self.class_axioms:
            for _item_class_axioms in self.class_axioms:
                if _item_class_axioms:
                    _items.append(_item_class_axioms.to_dict())
            _dict['classAxioms'] = _items
        # override the default output from pydantic by calling `to_dict()` of each item in gci_axioms (list)
        _items = []
        if self.gci_axioms:
            for _item_gci_axioms in self.gci_axioms:
                if _item_gci_axioms:
                    _items.append(_item_gci_axioms.to_dict())
            _dict['gciAxioms'] = _items
        # override the default output from pydantic by calling `to_dict()` of each item in identifiers (list)
        _items = []
        if self.identifiers:
            for _item_identifiers in self.identifiers:
                if _item_identifiers:
                    _items.append(_item_identifiers.to_dict())
            _dict['identifiers'] = _items
        # override the default output from pydantic by calling `to_dict()` of each item in validation_results (list)
        _items = []
        if self.validation_results:
            for _item_validation_results in self.validation_results:
                if _item_validation_results:
                    _items.append(_item_validation_results.to_dict())
            _dict['validationResults'] = _items
        return _dict

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

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

        _obj = cls.model_validate({
            "annotations": [AnnotationComponent.from_dict(_item) for _item in obj["annotations"]] if obj.get("annotations") is not None else None,
            "active": obj.get("active"),
            "conceptId": obj.get("conceptId"),
            "effectiveTime": obj.get("effectiveTime"),
            "pt": TermLangPojoComponent.from_dict(obj["pt"]) if obj.get("pt") is not None else None,
            "descriptions": [DescriptionComponent.from_dict(_item) for _item in obj["descriptions"]] if obj.get("descriptions") is not None else None,
            "fsn": TermLangPojoComponent.from_dict(obj["fsn"]) if obj.get("fsn") is not None else None,
            "relationships": [RelationshipComponent.from_dict(_item) for _item in obj["relationships"]] if obj.get("relationships") is not None else None,
            "definitionStatusId": obj.get("definitionStatusId"),
            "moduleId": obj.get("moduleId"),
            "classAxioms": [AxiomComponent.from_dict(_item) for _item in obj["classAxioms"]] if obj.get("classAxioms") is not None else None,
            "gciAxioms": [AxiomComponent.from_dict(_item) for _item in obj["gciAxioms"]] if obj.get("gciAxioms") is not None else None,
            "identifiers": [IdentifierComponent.from_dict(_item) for _item in obj["identifiers"]] if obj.get("identifiers") is not None else None,
            "validationResults": [InvalidContentComponent.from_dict(_item) for _item in obj["validationResults"]] if obj.get("validationResults") is not None else None
        })
        return _obj


