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

import datetime as dt
import typing

from ..core.datetime_utils import serialize_datetime
from ..core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1
from .entity_trait_definition_response_data import EntityTraitDefinitionResponseData
from .rule_condition_resource_response_data import RuleConditionResourceResponseData


class RuleConditionDetailResponseData(pydantic_v1.BaseModel):
    comparison_trait: typing.Optional[EntityTraitDefinitionResponseData] = None
    comparison_trait_id: typing.Optional[str] = None
    condition_group_id: typing.Optional[str] = None
    condition_type: str
    created_at: dt.datetime
    environment_id: str
    event_subtype: typing.Optional[str] = None
    flag_id: typing.Optional[str] = None
    id: str
    metric_period: typing.Optional[str] = None
    metric_value: int
    operator: str
    plan_id: typing.Optional[str] = None
    resource_ids: typing.List[str]
    resources: typing.List[RuleConditionResourceResponseData]
    rule_id: str
    trait: typing.Optional[EntityTraitDefinitionResponseData] = None
    trait_entity_type: typing.Optional[str] = None
    trait_id: typing.Optional[str] = None
    trait_value: str
    updated_at: dt.datetime

    def json(self, **kwargs: typing.Any) -> str:
        kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs}
        return super().json(**kwargs_with_defaults)

    def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]:
        kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs}
        kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs}

        return deep_union_pydantic_dicts(
            super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none)
        )

    class Config:
        frozen = True
        smart_union = True
        extra = pydantic_v1.Extra.allow
        json_encoders = {dt.datetime: serialize_datetime}
