|
| 1 | +# Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. |
| 2 | +# This product includes software developed at Datadog (https://www.datadoghq.com/). |
| 3 | +# Copyright 2019-Present Datadog, Inc. |
| 4 | +from __future__ import annotations |
| 5 | + |
| 6 | +from typing import Union, TYPE_CHECKING |
| 7 | + |
| 8 | +from datadog_api_client.model_utils import ( |
| 9 | + ModelNormal, |
| 10 | + cached_property, |
| 11 | + unset, |
| 12 | + UnsetType, |
| 13 | +) |
| 14 | + |
| 15 | + |
| 16 | +if TYPE_CHECKING: |
| 17 | + from datadog_api_client.v1.model.monitor_formula_and_function_metric_aggregator import ( |
| 18 | + MonitorFormulaAndFunctionMetricAggregator, |
| 19 | + ) |
| 20 | + from datadog_api_client.v1.model.monitor_formula_and_function_metric_data_source import ( |
| 21 | + MonitorFormulaAndFunctionMetricDataSource, |
| 22 | + ) |
| 23 | + |
| 24 | + |
| 25 | +class MonitorFormulaAndFunctionMetricQueryDefinition(ModelNormal): |
| 26 | + @cached_property |
| 27 | + def openapi_types(_): |
| 28 | + from datadog_api_client.v1.model.monitor_formula_and_function_metric_aggregator import ( |
| 29 | + MonitorFormulaAndFunctionMetricAggregator, |
| 30 | + ) |
| 31 | + from datadog_api_client.v1.model.monitor_formula_and_function_metric_data_source import ( |
| 32 | + MonitorFormulaAndFunctionMetricDataSource, |
| 33 | + ) |
| 34 | + |
| 35 | + return { |
| 36 | + "aggregator": (MonitorFormulaAndFunctionMetricAggregator,), |
| 37 | + "data_source": (MonitorFormulaAndFunctionMetricDataSource,), |
| 38 | + "name": (str,), |
| 39 | + "query": (str,), |
| 40 | + } |
| 41 | + |
| 42 | + attribute_map = { |
| 43 | + "aggregator": "aggregator", |
| 44 | + "data_source": "data_source", |
| 45 | + "name": "name", |
| 46 | + "query": "query", |
| 47 | + } |
| 48 | + |
| 49 | + def __init__( |
| 50 | + self_, |
| 51 | + data_source: MonitorFormulaAndFunctionMetricDataSource, |
| 52 | + name: str, |
| 53 | + query: str, |
| 54 | + aggregator: Union[MonitorFormulaAndFunctionMetricAggregator, UnsetType] = unset, |
| 55 | + **kwargs, |
| 56 | + ): |
| 57 | + """ |
| 58 | + A formula and functions metric query. |
| 59 | +
|
| 60 | + :param aggregator: Aggregation methods for metric queries. |
| 61 | + :type aggregator: MonitorFormulaAndFunctionMetricAggregator, optional |
| 62 | +
|
| 63 | + :param data_source: Data source for metric-based queries. |
| 64 | + :type data_source: MonitorFormulaAndFunctionMetricDataSource |
| 65 | +
|
| 66 | + :param name: Name of the query for use in formulas. |
| 67 | + :type name: str |
| 68 | +
|
| 69 | + :param query: The monitor query. |
| 70 | + :type query: str |
| 71 | + """ |
| 72 | + if aggregator is not unset: |
| 73 | + kwargs["aggregator"] = aggregator |
| 74 | + super().__init__(kwargs) |
| 75 | + |
| 76 | + self_.data_source = data_source |
| 77 | + self_.name = name |
| 78 | + self_.query = query |
0 commit comments