# coding: utf-8

"""
    BulkService

    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.bulk.fault_source import FaultSource
from typing_extensions import Self

class AdCenterInternalErrorFault(BaseModel):
    """
    AdCenterInternalErrorFault
    """ # noqa: E501
    error_message: Optional[StrictStr] = Field(default=None, alias="ErrorMessage")
    mt_server_name: Optional[StrictStr] = Field(default=None, alias="MTServerName")
    faulting_layer: Optional[FaultSource] = Field(default=None, alias="FaultingLayer")
    error_source_system: Optional[StrictStr] = Field(default=None, alias="ErrorSourceSystem")
    tracking_id: Optional[StrictStr] = Field(default=None, alias="TrackingId")
    type: Optional[StrictStr] = Field(default='AdCenterInternalErrorFault', alias="Type")
    __properties: ClassVar[List[str]] = ["ErrorMessage", "MTServerName", "FaultingLayer", "ErrorSourceSystem", "TrackingId", "Type"]

    model_config = ConfigDict(
        populate_by_name=True,
        validate_assignment=True,
        protected_namespaces=(),
    )
	
    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 AdCenterInternalErrorFault 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,
        )
        # set to None if error_message (nullable) is None
        # and model_fields_set contains the field
        if self.error_message is None and "error_message" in self.model_fields_set:
            _dict['ErrorMessage'] = None

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

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

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

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

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

        return _dict

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

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

        _obj = cls.model_validate({
            "ErrorMessage": obj.get("ErrorMessage") if obj.get("ErrorMessage") is not None else None,
                        "MTServerName": obj.get("MTServerName") if obj.get("MTServerName") is not None else None,
                        "FaultingLayer": obj.get("FaultingLayer") if obj.get("FaultingLayer") is not None else None,
                        "ErrorSourceSystem": obj.get("ErrorSourceSystem") if obj.get("ErrorSourceSystem") is not None else None,
                        "TrackingId": obj.get("TrackingId") if obj.get("TrackingId") is not None else None,
                        "Type": obj.get("Type") if obj.get("Type") is not None else 'AdCenterInternalErrorFault'
        })
        return _obj
