# coding: utf-8
"""Waylay Broker query parameters.

This code was generated from the OpenAPI documentation of 'Waylay Broker'

Generated by OpenAPI Generator (https://openapi-generator.tech)

Do not edit the class manually.
"""

from __future__ import annotations  # for Python 3.7–3.9

from typing import Any

from pydantic import (
    ConfigDict,
    Field,
    StrictStr,
)
from typing_extensions import (
    Annotated,  # >=3.11
)
from waylay.sdk.api._models import BaseModel as WaylayBaseModel

from ..models.aggregate import Aggregate
from ..models.order import Order


def _delete_series_query_alias_for(field_name: str) -> str:
    if field_name == "var_from":
        return "from"
    if field_name == "until":
        return "until"
    return field_name


class DeleteSeriesQuery(WaylayBaseModel):
    """Model for `delete_series` query parameters."""

    var_from: Annotated[
        Any | None, Field(description="Specifies the lower bound of the time period")
    ] = None
    until: Annotated[
        Any | None, Field(description="Specifies the upper bound of the time period")
    ] = None

    model_config = ConfigDict(
        validate_assignment=True,
        protected_namespaces=(),
        extra="allow",
        alias_generator=_delete_series_query_alias_for,
        populate_by_name=True,
    )


def _get_datapoints_for_metric_raw_query_alias_for(field_name: str) -> str:
    if field_name == "var_from":
        return "from"
    if field_name == "until":
        return "until"
    if field_name == "limit":
        return "limit"
    if field_name == "order":
        return "order"
    return field_name


class GetDatapointsForMetricRawQuery(WaylayBaseModel):
    """Model for `get_datapoints_for_metric_raw` query parameters."""

    var_from: Annotated[
        Any | None,
        Field(
            description="Specifies the lower bound of the time period. If not specified, a period of 7 days before `until` (or before the request was received) will be queried."
        ),
    ] = None
    until: Annotated[
        Any | None,
        Field(
            description="Specifies the upper bound of the time period. If not specified, a period of 7 days after `from` (or before the request was received) will be queried"
        ),
    ] = None
    limit: Annotated[
        Annotated[int, Field(strict=True, ge=1)] | None,
        Field(description="max number of values to retrieve"),
    ] = None
    order: Annotated[Order | None, Field(description="sort order")] = None

    model_config = ConfigDict(
        validate_assignment=True,
        protected_namespaces=(),
        extra="allow",
        alias_generator=_get_datapoints_for_metric_raw_query_alias_for,
        populate_by_name=True,
    )


def _get_last_datapoints_for_metric_query_alias_for(field_name: str) -> str:
    if field_name == "limit":
        return "limit"
    if field_name == "until":
        return "until"
    return field_name


class GetLastDatapointsForMetricQuery(WaylayBaseModel):
    """Model for `get_last_datapoints_for_metric` query parameters."""

    limit: Annotated[
        Annotated[int, Field(strict=True, ge=1)] | None,
        Field(description="max number of values to retrieve"),
    ] = None
    until: Annotated[
        Any | None,
        Field(
            description="Specifies the upper bound of the time period. If not specified, a period of 7 days after `from` (or before the request was received) will be queried"
        ),
    ] = None

    model_config = ConfigDict(
        validate_assignment=True,
        protected_namespaces=(),
        extra="allow",
        alias_generator=_get_last_datapoints_for_metric_query_alias_for,
        populate_by_name=True,
    )


def _get_last_metric_query_alias_for(field_name: str) -> str:
    return field_name


class GetLastMetricQuery(WaylayBaseModel):
    """Model for `get_last_metric` query parameters."""

    model_config = ConfigDict(
        validate_assignment=True,
        protected_namespaces=(),
        extra="allow",
        alias_generator=_get_last_metric_query_alias_for,
        populate_by_name=True,
    )


def _get_metric_series_query_alias_for(field_name: str) -> str:
    if field_name == "var_from":
        return "from"
    if field_name == "until":
        return "until"
    if field_name == "aggregate":
        return "aggregate"
    if field_name == "aggregates":
        return "aggregates"
    if field_name == "grouping":
        return "grouping"
    if field_name == "order":
        return "order"
    return field_name


class GetMetricSeriesQuery(WaylayBaseModel):
    """Model for `get_metric_series` query parameters."""

    var_from: Annotated[
        Any | None,
        Field(
            description="Specifies the lower bound of the time period. If not specified, a period of 7 days before `until` (or before the request was received) will be queried."
        ),
    ] = None
    until: Annotated[
        Any | None,
        Field(
            description="Specifies the upper bound of the time period. If not specified, a period of 7 days after `from` (or before the request was received) will be queried"
        ),
    ] = None
    aggregate: Annotated[
        Aggregate | None, Field(description="Specifies the aggregation function to use")
    ] = None
    aggregates: Annotated[
        StrictStr | None,
        Field(description="comma-separated list of aggregation functions"),
    ] = None
    grouping: Annotated[
        Any | None,
        Field(description="time period over which timeseries data must be aggregates"),
    ] = None
    order: Annotated[Order | None, Field(description="sort order")] = None

    model_config = ConfigDict(
        validate_assignment=True,
        protected_namespaces=(),
        extra="allow",
        alias_generator=_get_metric_series_query_alias_for,
        populate_by_name=True,
    )


def _get_series_query_alias_for(field_name: str) -> str:
    return field_name


class GetSeriesQuery(WaylayBaseModel):
    """Model for `get_series` query parameters."""

    model_config = ConfigDict(
        validate_assignment=True,
        protected_namespaces=(),
        extra="allow",
        alias_generator=_get_series_query_alias_for,
        populate_by_name=True,
    )


def _query_time_series_query_alias_for(field_name: str) -> str:
    return field_name


class QueryTimeSeriesQuery(WaylayBaseModel):
    """Model for `query_time_series` query parameters."""

    model_config = ConfigDict(
        validate_assignment=True,
        protected_namespaces=(),
        extra="allow",
        alias_generator=_query_time_series_query_alias_for,
        populate_by_name=True,
    )
