# Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License.
# This product includes software developed at Datadog (https://www.datadoghq.com/).
# Copyright 2019-Present Datadog, Inc.


from datadog_api_client.v2.model_utils import (
    ModelNormal,
    cached_property,
)


def lazy_import():
    from datadog_api_client.v2.model.logs_aggregate_sort import LogsAggregateSort
    from datadog_api_client.v2.model.logs_group_by_histogram import LogsGroupByHistogram
    from datadog_api_client.v2.model.logs_group_by_missing import LogsGroupByMissing
    from datadog_api_client.v2.model.logs_group_by_total import LogsGroupByTotal

    globals()["LogsAggregateSort"] = LogsAggregateSort
    globals()["LogsGroupByHistogram"] = LogsGroupByHistogram
    globals()["LogsGroupByMissing"] = LogsGroupByMissing
    globals()["LogsGroupByTotal"] = LogsGroupByTotal


class LogsGroupBy(ModelNormal):
    """NOTE: This class is auto generated by OpenAPI Generator.
    Ref: https://openapi-generator.tech

    Do not edit the class manually.
    """

    validations = {}

    @cached_property
    def openapi_types():
        lazy_import()
        return {
            "facet": (str,),
            "histogram": (LogsGroupByHistogram,),
            "limit": (int,),
            "missing": (LogsGroupByMissing,),
            "sort": (LogsAggregateSort,),
            "total": (LogsGroupByTotal,),
        }

    attribute_map = {
        "facet": "facet",
        "histogram": "histogram",
        "limit": "limit",
        "missing": "missing",
        "sort": "sort",
        "total": "total",
    }

    read_only_vars = {}

    def __init__(self, facet, *args, **kwargs):
        """LogsGroupBy - a model defined in OpenAPI

        Args:
            facet (str): The name of the facet to use (required)

        Keyword Args:
            histogram (LogsGroupByHistogram): [optional]
            limit (int): [optional] The maximum buckets to return for this group by If omitted the server will use the default value of 10.
            missing (LogsGroupByMissing): [optional]
            sort (LogsAggregateSort): [optional]
            total (LogsGroupByTotal): [optional]
        """
        super().__init__(kwargs)

        self._check_pos_args(args)

        self.facet = facet

    @classmethod
    def _from_openapi_data(cls, facet, *args, **kwargs):
        """Helper creating a new instance from a response."""

        self = super(LogsGroupBy, cls)._from_openapi_data(kwargs)

        self._check_pos_args(args)

        self.facet = facet
        return self
