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

import typing

import pydantic
from ..core.pydantic_utilities import IS_PYDANTIC_V2, UniversalBaseModel
from .create_or_update_condition_request_body_condition_type import CreateOrUpdateConditionRequestBodyConditionType
from .create_or_update_condition_request_body_metric_period import CreateOrUpdateConditionRequestBodyMetricPeriod
from .create_or_update_condition_request_body_metric_period_month_reset import (
    CreateOrUpdateConditionRequestBodyMetricPeriodMonthReset,
)
from .create_or_update_condition_request_body_operator import CreateOrUpdateConditionRequestBodyOperator


class CreateOrUpdateConditionRequestBody(UniversalBaseModel):
    comparison_trait_id: typing.Optional[str] = pydantic.Field(default=None)
    """
    Optionally provide a trait ID to compare a metric or trait value against instead of a value
    """

    condition_type: CreateOrUpdateConditionRequestBodyConditionType
    event_subtype: typing.Optional[str] = pydantic.Field(default=None)
    """
    Name of track event type used to measure this condition
    """

    id: typing.Optional[str] = None
    metric_period: typing.Optional[CreateOrUpdateConditionRequestBodyMetricPeriod] = pydantic.Field(default=None)
    """
    Period of time over which to measure the track event metric
    """

    metric_period_month_reset: typing.Optional[CreateOrUpdateConditionRequestBodyMetricPeriodMonthReset] = (
        pydantic.Field(default=None)
    )
    """
    When metric_period=current_month, specify whether the month restarts based on the calendar month or the billing period
    """

    metric_value: typing.Optional[int] = pydantic.Field(default=None)
    """
    Value to compare the track event metric against
    """

    operator: CreateOrUpdateConditionRequestBodyOperator
    resource_ids: typing.List[str] = pydantic.Field()
    """
    List of resource IDs (companies, users, or plans) targeted by this condition
    """

    trait_id: typing.Optional[str] = pydantic.Field(default=None)
    """
    ID of trait to use to measure this condition
    """

    trait_value: typing.Optional[str] = pydantic.Field(default=None)
    """
    Value to compare the trait value against
    """

    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
