# This file was auto-generated by Fern from our API Definition.

import typing

import pydantic
import typing_extensions
from ..core.pydantic_utilities import IS_PYDANTIC_V2, UniversalBaseModel
from ..core.serialization import FieldMetadata
from .vehicle_stats_fault_codes_value_j_1939_vendor_specific_fields import (
    VehicleStatsFaultCodesValueJ1939VendorSpecificFields,
)


class VehicleStatsFaultCodesValueJ1939DiagnosticTroubleCodes(UniversalBaseModel):
    """
    Diagnostic trouble code for J1939 vehicles.
    """

    fmi_description: typing_extensions.Annotated[
        typing.Optional[str],
        FieldMetadata(alias="fmiDescription"),
        pydantic.Field(alias="fmiDescription", description="A short description of the FMI identifier, if available."),
    ] = None
    fmi_id: typing_extensions.Annotated[
        int, FieldMetadata(alias="fmiId"), pydantic.Field(alias="fmiId", description="The FMI identifier.")
    ]
    mil_status: typing_extensions.Annotated[
        int,
        FieldMetadata(alias="milStatus"),
        pydantic.Field(alias="milStatus", description="The MIL status, indicating a check engine light."),
    ]
    occurrence_count: typing_extensions.Annotated[
        int,
        FieldMetadata(alias="occurrenceCount"),
        pydantic.Field(alias="occurrenceCount", description="The number of times this fault has triggered."),
    ]
    source_address_name: typing_extensions.Annotated[
        typing.Optional[str],
        FieldMetadata(alias="sourceAddressName"),
        pydantic.Field(alias="sourceAddressName", description="The source address name corresponding to the txId"),
    ] = None
    spn_description: typing_extensions.Annotated[
        typing.Optional[str],
        FieldMetadata(alias="spnDescription"),
        pydantic.Field(alias="spnDescription", description="A short description of the SPN identifier, if available."),
    ] = None
    spn_id: typing_extensions.Annotated[
        int, FieldMetadata(alias="spnId"), pydantic.Field(alias="spnId", description="The SPN identifier.")
    ]
    tx_id: typing_extensions.Annotated[
        int, FieldMetadata(alias="txId"), pydantic.Field(alias="txId", description="The TX identifier.")
    ]
    vendor_specific_fields: typing_extensions.Annotated[
        typing.Optional[VehicleStatsFaultCodesValueJ1939VendorSpecificFields],
        FieldMetadata(alias="vendorSpecificFields"),
        pydantic.Field(alias="vendorSpecificFields"),
    ] = None

    if IS_PYDANTIC_V2:
        model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict(extra="allow", frozen=True)  # type: ignore # Pydantic v2
    else:

        class Config:
            frozen = True
            smart_union = True
            extra = pydantic.Extra.allow
