# coding: utf-8

"""
    CampaignManagementService

    No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)

    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, StrictBool, StrictFloat, StrictInt, StrictStr
from typing import Any, ClassVar, Dict, List, Optional, Union, Set
from openapi_client.models.campaign.import_entity_statistics import ImportEntityStatistics
from openapi_client.models.campaign.import_job import ImportJob
from openapi_client.models.campaign.key_value_pair_ofstring_andstring import KeyValuePairOfstringAndstring
from typing_extensions import Self

class ImportResult(BaseModel):
    """
    ImportResult
    """ # noqa: E501
    id: Optional[StrictStr] = Field(default=None, alias="Id")
    start_time_in_utc: Optional[datetime] = Field(default=None, alias="StartTimeInUTC")
    status: Optional[StrictStr] = Field(default=None, alias="Status")
    import_job: Optional[ImportJob] = Field(default=None, alias="ImportJob")
    entity_statistics: Optional[List[Optional[ImportEntityStatistics]]] = Field(default=None, alias="EntityStatistics")
    error_log_url: Optional[StrictStr] = Field(default=None, alias="ErrorLogUrl")
    forward_compatibility_map: Optional[List[Optional[KeyValuePairOfstringAndstring]]] = Field(default=None, alias="ForwardCompatibilityMap")
    __properties: ClassVar[List[str]] = ["Id", "StartTimeInUTC", "Status", "ImportJob", "EntityStatistics", "ErrorLogUrl", "ForwardCompatibilityMap"]

    model_config = ConfigDict(
        populate_by_name=True,
        validate_assignment=True,
        protected_namespaces=(),
    )
	

    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 import_job
        if self.import_job:
            _dict['ImportJob'] = self.import_job.to_dict()
        # override the default output from pydantic by calling `to_dict()` of each item in entity_statistics (list)
        _items = []
        if self.entity_statistics:
            for _item_entity_statistics in self.entity_statistics:
                if _item_entity_statistics:
                    _items.append(_item_entity_statistics.to_dict())
            _dict['EntityStatistics'] = _items
        # override the default output from pydantic by calling `to_dict()` of each item in forward_compatibility_map (list)
        _items = []
        if self.forward_compatibility_map:
            for _item_forward_compatibility_map in self.forward_compatibility_map:
                if _item_forward_compatibility_map:
                    _items.append(_item_forward_compatibility_map.to_dict())
            _dict['ForwardCompatibilityMap'] = _items
        # set to None if id (nullable) is None
        # and model_fields_set contains the field
        if self.id is None and "id" in self.model_fields_set:
            _dict['Id'] = None

        # set to None if start_time_in_utc (nullable) is None
        # and model_fields_set contains the field
        if self.start_time_in_utc is None and "start_time_in_utc" in self.model_fields_set:
            _dict['StartTimeInUTC'] = None

        # set to None if status (nullable) is None
        # and model_fields_set contains the field
        if self.status is None and "status" in self.model_fields_set:
            _dict['Status'] = None

        # set to None if import_job (nullable) is None
        # and model_fields_set contains the field
        if self.import_job is None and "import_job" in self.model_fields_set:
            _dict['ImportJob'] = None

        # set to None if entity_statistics (nullable) is None
        # and model_fields_set contains the field
        if self.entity_statistics is None and "entity_statistics" in self.model_fields_set:
            _dict['EntityStatistics'] = None

        # set to None if error_log_url (nullable) is None
        # and model_fields_set contains the field
        if self.error_log_url is None and "error_log_url" in self.model_fields_set:
            _dict['ErrorLogUrl'] = None

        # set to None if forward_compatibility_map (nullable) is None
        # and model_fields_set contains the field
        if self.forward_compatibility_map is None and "forward_compatibility_map" in self.model_fields_set:
            _dict['ForwardCompatibilityMap'] = None

        return _dict

    @classmethod
    def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
        """Create an instance of ImportResult 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") if obj.get("Id") is not None else None,
                        "StartTimeInUTC": obj.get("StartTimeInUTC") if obj.get("StartTimeInUTC") is not None else None,
                        "Status": obj.get("Status") if obj.get("Status") is not None else None,
                        "ImportJob": ImportJob.from_dict(obj["ImportJob"]) if obj.get("ImportJob") is not None else None,
                        "EntityStatistics": [ImportEntityStatistics.from_dict(_item) for _item in obj["EntityStatistics"]] if obj.get("EntityStatistics") is not None else None,
                        "ErrorLogUrl": obj.get("ErrorLogUrl") if obj.get("ErrorLogUrl") is not None else None,
                        "ForwardCompatibilityMap": [KeyValuePairOfstringAndstring.from_dict(_item) for _item in obj["ForwardCompatibilityMap"]] if obj.get("ForwardCompatibilityMap") is not None else None
        })
        return _obj
