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

from __future__ import annotations

import typing

import pydantic
import typing_extensions
from ...commons.types.event_filter import EventFilter
from ...core.pydantic_utilities import IS_PYDANTIC_V2, UniversalBaseModel
from ...core.serialization import FieldMetadata
from .event_group_by import EventGroupBy
from .event_metric import EventMetric
from .time_interval import TimeInterval


class EventChartRequest_PieChart(UniversalBaseModel):
    """
    Examples
    --------
    from mavenagi.analytics import (
        EventChartRequest_PieChart,
        EventGroupBy,
        EventMetric_Count,
    )
    from mavenagi.commons import EventFilter

    EventChartRequest_PieChart(
        event_filter=EventFilter(
            event_types=["USER"],
        ),
        group_by=EventGroupBy(
            field="EVENT_NAME",
        ),
        metric=EventMetric_Count(),
    )
    """

    type: typing.Literal["pieChart"] = "pieChart"
    group_by: typing_extensions.Annotated[EventGroupBy, FieldMetadata(alias="groupBy")]
    metric: EventMetric
    event_filter: typing_extensions.Annotated[typing.Optional[EventFilter], FieldMetadata(alias="eventFilter")] = None
    timezone: typing.Optional[str] = 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


class EventChartRequest_DateHistogram(UniversalBaseModel):
    """
    Examples
    --------
    from mavenagi.analytics import (
        EventChartRequest_PieChart,
        EventGroupBy,
        EventMetric_Count,
    )
    from mavenagi.commons import EventFilter

    EventChartRequest_PieChart(
        event_filter=EventFilter(
            event_types=["USER"],
        ),
        group_by=EventGroupBy(
            field="EVENT_NAME",
        ),
        metric=EventMetric_Count(),
    )
    """

    type: typing.Literal["dateHistogram"] = "dateHistogram"
    time_interval: typing_extensions.Annotated[TimeInterval, FieldMetadata(alias="timeInterval")]
    group_by: typing_extensions.Annotated[typing.Optional[EventGroupBy], FieldMetadata(alias="groupBy")] = None
    metric: EventMetric
    event_filter: typing_extensions.Annotated[typing.Optional[EventFilter], FieldMetadata(alias="eventFilter")] = None
    timezone: typing.Optional[str] = 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


class EventChartRequest_BarChart(UniversalBaseModel):
    """
    Examples
    --------
    from mavenagi.analytics import (
        EventChartRequest_PieChart,
        EventGroupBy,
        EventMetric_Count,
    )
    from mavenagi.commons import EventFilter

    EventChartRequest_PieChart(
        event_filter=EventFilter(
            event_types=["USER"],
        ),
        group_by=EventGroupBy(
            field="EVENT_NAME",
        ),
        metric=EventMetric_Count(),
    )
    """

    type: typing.Literal["barChart"] = "barChart"
    bar_definition: typing_extensions.Annotated[EventGroupBy, FieldMetadata(alias="barDefinition")]
    metric: EventMetric
    vertical_grouping: typing_extensions.Annotated[
        typing.Optional[EventGroupBy], FieldMetadata(alias="verticalGrouping")
    ] = None
    event_filter: typing_extensions.Annotated[typing.Optional[EventFilter], FieldMetadata(alias="eventFilter")] = None
    timezone: typing.Optional[str] = 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


"""
from mavenagi.analytics import (
    EventChartRequest_PieChart,
    EventGroupBy,
    EventMetric_Count,
)
from mavenagi.commons import EventFilter

EventChartRequest_PieChart(
    event_filter=EventFilter(
        event_types=["USER"],
    ),
    group_by=EventGroupBy(
        field="EVENT_NAME",
    ),
    metric=EventMetric_Count(),
)
"""
EventChartRequest = typing.Union[
    EventChartRequest_PieChart, EventChartRequest_DateHistogram, EventChartRequest_BarChart
]
