-
Notifications
You must be signed in to change notification settings - Fork 43
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Co-authored-by: ci.datadog-api-spec <[email protected]>
- Loading branch information
1 parent
183cfc9
commit 44a302a
Showing
13 changed files
with
399 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
""" | ||
Create a Cost Monitor returns "OK" response | ||
""" | ||
|
||
from datadog_api_client import ApiClient, Configuration | ||
from datadog_api_client.v1.api.monitors_api import MonitorsApi | ||
from datadog_api_client.v1.model.monitor import Monitor | ||
from datadog_api_client.v1.model.monitor_formula_and_function_cost_aggregator import ( | ||
MonitorFormulaAndFunctionCostAggregator, | ||
) | ||
from datadog_api_client.v1.model.monitor_formula_and_function_cost_data_source import ( | ||
MonitorFormulaAndFunctionCostDataSource, | ||
) | ||
from datadog_api_client.v1.model.monitor_formula_and_function_cost_query_definition import ( | ||
MonitorFormulaAndFunctionCostQueryDefinition, | ||
) | ||
from datadog_api_client.v1.model.monitor_options import MonitorOptions | ||
from datadog_api_client.v1.model.monitor_thresholds import MonitorThresholds | ||
from datadog_api_client.v1.model.monitor_type import MonitorType | ||
|
||
body = Monitor( | ||
name="Example Monitor", | ||
type=MonitorType.COST_ALERT, | ||
query='formula("exclude_null(query1)").last("7d").anomaly(direction="above", threshold=10) >= 5', | ||
message="some message Notify: @hipchat-channel", | ||
tags=[ | ||
"test:examplemonitor", | ||
"env:ci", | ||
], | ||
priority=3, | ||
options=MonitorOptions( | ||
thresholds=MonitorThresholds( | ||
critical=5.0, | ||
warning=3.0, | ||
), | ||
variables=[ | ||
MonitorFormulaAndFunctionCostQueryDefinition( | ||
data_source=MonitorFormulaAndFunctionCostDataSource.CLOUD_COST, | ||
query="sum:aws.cost.net.amortized.shared.resources.allocated{aws_product IN (amplify ,athena, backup, bedrock ) } by {aws_product}.rollup(sum, 86400)", | ||
name="query1", | ||
aggregator=MonitorFormulaAndFunctionCostAggregator.SUM, | ||
), | ||
], | ||
include_tags=True, | ||
), | ||
) | ||
|
||
configuration = Configuration() | ||
with ApiClient(configuration) as api_client: | ||
api_instance = MonitorsApi(api_client) | ||
response = api_instance.create_monitor(body=body) | ||
|
||
print(response) |
59 changes: 59 additions & 0 deletions
59
src/datadog_api_client/v1/model/monitor_formula_and_function_cost_aggregator.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
# 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 __future__ import annotations | ||
|
||
|
||
from datadog_api_client.model_utils import ( | ||
ModelSimple, | ||
cached_property, | ||
) | ||
|
||
from typing import ClassVar | ||
|
||
|
||
class MonitorFormulaAndFunctionCostAggregator(ModelSimple): | ||
""" | ||
Aggregation methods for metric queries. | ||
:param value: Must be one of ["avg", "sum", "max", "min", "last", "area", "l2norm", "percentile", "stddev"]. | ||
:type value: str | ||
""" | ||
|
||
allowed_values = { | ||
"avg", | ||
"sum", | ||
"max", | ||
"min", | ||
"last", | ||
"area", | ||
"l2norm", | ||
"percentile", | ||
"stddev", | ||
} | ||
AVG: ClassVar["MonitorFormulaAndFunctionCostAggregator"] | ||
SUM: ClassVar["MonitorFormulaAndFunctionCostAggregator"] | ||
MAX: ClassVar["MonitorFormulaAndFunctionCostAggregator"] | ||
MIN: ClassVar["MonitorFormulaAndFunctionCostAggregator"] | ||
LAST: ClassVar["MonitorFormulaAndFunctionCostAggregator"] | ||
AREA: ClassVar["MonitorFormulaAndFunctionCostAggregator"] | ||
L2NORM: ClassVar["MonitorFormulaAndFunctionCostAggregator"] | ||
PERCENTILE: ClassVar["MonitorFormulaAndFunctionCostAggregator"] | ||
STDDEV: ClassVar["MonitorFormulaAndFunctionCostAggregator"] | ||
|
||
@cached_property | ||
def openapi_types(_): | ||
return { | ||
"value": (str,), | ||
} | ||
|
||
|
||
MonitorFormulaAndFunctionCostAggregator.AVG = MonitorFormulaAndFunctionCostAggregator("avg") | ||
MonitorFormulaAndFunctionCostAggregator.SUM = MonitorFormulaAndFunctionCostAggregator("sum") | ||
MonitorFormulaAndFunctionCostAggregator.MAX = MonitorFormulaAndFunctionCostAggregator("max") | ||
MonitorFormulaAndFunctionCostAggregator.MIN = MonitorFormulaAndFunctionCostAggregator("min") | ||
MonitorFormulaAndFunctionCostAggregator.LAST = MonitorFormulaAndFunctionCostAggregator("last") | ||
MonitorFormulaAndFunctionCostAggregator.AREA = MonitorFormulaAndFunctionCostAggregator("area") | ||
MonitorFormulaAndFunctionCostAggregator.L2NORM = MonitorFormulaAndFunctionCostAggregator("l2norm") | ||
MonitorFormulaAndFunctionCostAggregator.PERCENTILE = MonitorFormulaAndFunctionCostAggregator("percentile") | ||
MonitorFormulaAndFunctionCostAggregator.STDDEV = MonitorFormulaAndFunctionCostAggregator("stddev") |
41 changes: 41 additions & 0 deletions
41
src/datadog_api_client/v1/model/monitor_formula_and_function_cost_data_source.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
# 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 __future__ import annotations | ||
|
||
|
||
from datadog_api_client.model_utils import ( | ||
ModelSimple, | ||
cached_property, | ||
) | ||
|
||
from typing import ClassVar | ||
|
||
|
||
class MonitorFormulaAndFunctionCostDataSource(ModelSimple): | ||
""" | ||
Data source for cost queries. | ||
:param value: Must be one of ["metrics", "cloud_cost", "datadog_usage"]. | ||
:type value: str | ||
""" | ||
|
||
allowed_values = { | ||
"metrics", | ||
"cloud_cost", | ||
"datadog_usage", | ||
} | ||
METRICS: ClassVar["MonitorFormulaAndFunctionCostDataSource"] | ||
CLOUD_COST: ClassVar["MonitorFormulaAndFunctionCostDataSource"] | ||
DATADOG_USAGE: ClassVar["MonitorFormulaAndFunctionCostDataSource"] | ||
|
||
@cached_property | ||
def openapi_types(_): | ||
return { | ||
"value": (str,), | ||
} | ||
|
||
|
||
MonitorFormulaAndFunctionCostDataSource.METRICS = MonitorFormulaAndFunctionCostDataSource("metrics") | ||
MonitorFormulaAndFunctionCostDataSource.CLOUD_COST = MonitorFormulaAndFunctionCostDataSource("cloud_cost") | ||
MonitorFormulaAndFunctionCostDataSource.DATADOG_USAGE = MonitorFormulaAndFunctionCostDataSource("datadog_usage") |
78 changes: 78 additions & 0 deletions
78
src/datadog_api_client/v1/model/monitor_formula_and_function_cost_query_definition.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
# 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 __future__ import annotations | ||
|
||
from typing import Union, TYPE_CHECKING | ||
|
||
from datadog_api_client.model_utils import ( | ||
ModelNormal, | ||
cached_property, | ||
unset, | ||
UnsetType, | ||
) | ||
|
||
|
||
if TYPE_CHECKING: | ||
from datadog_api_client.v1.model.monitor_formula_and_function_cost_aggregator import ( | ||
MonitorFormulaAndFunctionCostAggregator, | ||
) | ||
from datadog_api_client.v1.model.monitor_formula_and_function_cost_data_source import ( | ||
MonitorFormulaAndFunctionCostDataSource, | ||
) | ||
|
||
|
||
class MonitorFormulaAndFunctionCostQueryDefinition(ModelNormal): | ||
@cached_property | ||
def openapi_types(_): | ||
from datadog_api_client.v1.model.monitor_formula_and_function_cost_aggregator import ( | ||
MonitorFormulaAndFunctionCostAggregator, | ||
) | ||
from datadog_api_client.v1.model.monitor_formula_and_function_cost_data_source import ( | ||
MonitorFormulaAndFunctionCostDataSource, | ||
) | ||
|
||
return { | ||
"aggregator": (MonitorFormulaAndFunctionCostAggregator,), | ||
"data_source": (MonitorFormulaAndFunctionCostDataSource,), | ||
"name": (str,), | ||
"query": (str,), | ||
} | ||
|
||
attribute_map = { | ||
"aggregator": "aggregator", | ||
"data_source": "data_source", | ||
"name": "name", | ||
"query": "query", | ||
} | ||
|
||
def __init__( | ||
self_, | ||
data_source: MonitorFormulaAndFunctionCostDataSource, | ||
name: str, | ||
query: str, | ||
aggregator: Union[MonitorFormulaAndFunctionCostAggregator, UnsetType] = unset, | ||
**kwargs, | ||
): | ||
""" | ||
A formula and functions cost query. | ||
:param aggregator: Aggregation methods for metric queries. | ||
:type aggregator: MonitorFormulaAndFunctionCostAggregator, optional | ||
:param data_source: Data source for cost queries. | ||
:type data_source: MonitorFormulaAndFunctionCostDataSource | ||
:param name: Name of the query for use in formulas. | ||
:type name: str | ||
:param query: The monitor query. | ||
:type query: str | ||
""" | ||
if aggregator is not unset: | ||
kwargs["aggregator"] = aggregator | ||
super().__init__(kwargs) | ||
|
||
self_.data_source = data_source | ||
self_.name = name | ||
self_.query = query |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.