# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.

from __future__ import annotations

from typing import List, Union, Iterable
from typing_extensions import Literal, Required, Annotated, TypedDict

from ..._utils import PropertyInfo
from ..data_explorer_time_group_param import DataExplorerTimeGroupParam
from ..data_explorer_account_group_param import DataExplorerAccountGroupParam
from ..data_explorer_dimension_group_param import DataExplorerDimensionGroupParam

__all__ = [
    "UsageDataExportScheduleRequestParam",
    "Aggregation",
    "DimensionFilter",
    "GroupDataExportsDataExplorerAccountGroup",
    "GroupDataExportsDataExplorerDimensionGroup",
    "GroupDataExportsDataExplorerTimeGroup",
]


class Aggregation(TypedDict, total=False):
    field_code: Required[Annotated[str, PropertyInfo(alias="fieldCode")]]
    """Field code"""

    field_type: Required[Annotated[Literal["DIMENSION", "MEASURE"], PropertyInfo(alias="fieldType")]]
    """Type of field"""

    function: Required[Literal["SUM", "MIN", "MAX", "COUNT", "LATEST", "MEAN", "UNIQUE"]]
    """Aggregation function"""

    meter_id: Required[Annotated[str, PropertyInfo(alias="meterId")]]
    """Meter ID"""


class DimensionFilter(TypedDict, total=False):
    field_code: Required[Annotated[str, PropertyInfo(alias="fieldCode")]]
    """Field code"""

    meter_id: Required[Annotated[str, PropertyInfo(alias="meterId")]]
    """Meter ID"""

    values: Required[List[str]]
    """Values to filter by"""


class GroupDataExportsDataExplorerAccountGroup(DataExplorerAccountGroupParam, total=False):
    group_type: Annotated[Literal["ACCOUNT", "DIMENSION", "TIME"], PropertyInfo(alias="groupType")]  # type: ignore


class GroupDataExportsDataExplorerDimensionGroup(DataExplorerDimensionGroupParam, total=False):
    group_type: Annotated[Literal["ACCOUNT", "DIMENSION", "TIME"], PropertyInfo(alias="groupType")]  # type: ignore


class GroupDataExportsDataExplorerTimeGroup(DataExplorerTimeGroupParam, total=False):
    group_type: Annotated[Literal["ACCOUNT", "DIMENSION", "TIME"], PropertyInfo(alias="groupType")]  # type: ignore


class UsageDataExportScheduleRequestParam(TypedDict, total=False):
    source_type: Required[Annotated[Literal["USAGE"], PropertyInfo(alias="sourceType")]]
    """The type of data to export. Possible values are: USAGE"""

    time_period: Required[
        Annotated[
            Literal[
                "TODAY",
                "YESTERDAY",
                "WEEK_TO_DATE",
                "MONTH_TO_DATE",
                "YEAR_TO_DATE",
                "PREVIOUS_WEEK",
                "PREVIOUS_MONTH",
                "PREVIOUS_QUARTER",
                "PREVIOUS_YEAR",
                "LAST_12_HOURS",
                "LAST_7_DAYS",
                "LAST_30_DAYS",
                "LAST_35_DAYS",
                "LAST_90_DAYS",
                "LAST_120_DAYS",
                "LAST_YEAR",
            ],
            PropertyInfo(alias="timePeriod"),
        ]
    ]
    """
    Define a time period to control the range of usage data you want the data export
    to contain when it runs:

    - **TODAY**. Data collected for the current day up until the time the export
      runs.
    - **YESTERDAY**. Data collected for the day before the export runs - that is,
      the 24 hour period from midnight to midnight of the day before.
    - **WEEK_TO_DATE**. Data collected for the period covering the current week to
      the date and time the export runs, and weeks run Monday to Monday.
    - **CURRENT_MONTH**. Data collected for the current month in which the export is
      ran up to and including the date and time the export runs.
    - **LAST_30_DAYS**. Data collected for the 30 days prior to the date the export
      is ran.
    - **LAST_35_DAYS**. Data collected for the 35 days prior to the date the export
      is ran.
    - **PREVIOUS_WEEK**. Data collected for the previous full week period, and weeks
      run Monday to Monday.
    - **PREVIOUS_MONTH**. Data collected for the previous full month period.

    For more details and examples, see the
    [Time Period](https://www.m3ter.com/docs/guides/data-exports/creating-export-schedules#time-period)
    section in our main User Documentation.
    """

    account_ids: Annotated[List[str], PropertyInfo(alias="accountIds")]
    """List of account IDs to export"""

    aggregations: Iterable[Aggregation]
    """List of aggregations to apply"""

    dimension_filters: Annotated[Iterable[DimensionFilter], PropertyInfo(alias="dimensionFilters")]
    """List of dimension filters to apply"""

    groups: Iterable[
        Union[
            GroupDataExportsDataExplorerAccountGroup,
            GroupDataExportsDataExplorerDimensionGroup,
            GroupDataExportsDataExplorerTimeGroup,
        ]
    ]
    """List of groups to apply"""

    meter_ids: Annotated[List[str], PropertyInfo(alias="meterIds")]
    """List of meter IDs to export"""

    version: int
    """The version number of the entity:

    - **Create entity:** Not valid for initial insertion of new entity - _do not use
      for Create_. On initial Create, version is set at 1 and listed in the
      response.
    - **Update Entity:** On Update, version is required and must match the existing
      version because a check is performed to ensure sequential versioning is
      preserved. Version is incremented by 1 and listed in the response.
    """
