Skip to content

Commit 4b2a9e1

Browse files
api-clients-generation-pipeline[bot]ci.datadog-api-spec
andauthored
Add OpenAPI for Cloud Cost Management anomalies endpoints (#3514)
Co-authored-by: ci.datadog-api-spec <packages@datadoghq.com>
1 parent 475987d commit 4b2a9e1

19 files changed

Lines changed: 1297 additions & 0 deletions

.generator/schemas/v2/openapi.yaml

Lines changed: 403 additions & 0 deletions
Large diffs are not rendered by default.

docs/datadog_api_client.v2.model.rst

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6171,6 +6171,76 @@ datadog\_api\_client.v2.model.cost\_aggregation\_type module
61716171
:members:
61726172
:show-inheritance:
61736173

6174+
datadog\_api\_client.v2.model.cost\_anomalies\_response module
6175+
--------------------------------------------------------------
6176+
6177+
.. automodule:: datadog_api_client.v2.model.cost_anomalies_response
6178+
:members:
6179+
:show-inheritance:
6180+
6181+
datadog\_api\_client.v2.model.cost\_anomalies\_response\_data module
6182+
--------------------------------------------------------------------
6183+
6184+
.. automodule:: datadog_api_client.v2.model.cost_anomalies_response_data
6185+
:members:
6186+
:show-inheritance:
6187+
6188+
datadog\_api\_client.v2.model.cost\_anomalies\_response\_data\_attributes module
6189+
--------------------------------------------------------------------------------
6190+
6191+
.. automodule:: datadog_api_client.v2.model.cost_anomalies_response_data_attributes
6192+
:members:
6193+
:show-inheritance:
6194+
6195+
datadog\_api\_client.v2.model.cost\_anomalies\_response\_data\_type module
6196+
--------------------------------------------------------------------------
6197+
6198+
.. automodule:: datadog_api_client.v2.model.cost_anomalies_response_data_type
6199+
:members:
6200+
:show-inheritance:
6201+
6202+
datadog\_api\_client.v2.model.cost\_anomaly module
6203+
--------------------------------------------------
6204+
6205+
.. automodule:: datadog_api_client.v2.model.cost_anomaly
6206+
:members:
6207+
:show-inheritance:
6208+
6209+
datadog\_api\_client.v2.model.cost\_anomaly\_correlated\_tags module
6210+
--------------------------------------------------------------------
6211+
6212+
.. automodule:: datadog_api_client.v2.model.cost_anomaly_correlated_tags
6213+
:members:
6214+
:show-inheritance:
6215+
6216+
datadog\_api\_client.v2.model.cost\_anomaly\_dimensions module
6217+
--------------------------------------------------------------
6218+
6219+
.. automodule:: datadog_api_client.v2.model.cost_anomaly_dimensions
6220+
:members:
6221+
:show-inheritance:
6222+
6223+
datadog\_api\_client.v2.model.cost\_anomaly\_dismissal module
6224+
-------------------------------------------------------------
6225+
6226+
.. automodule:: datadog_api_client.v2.model.cost_anomaly_dismissal
6227+
:members:
6228+
:show-inheritance:
6229+
6230+
datadog\_api\_client.v2.model.cost\_anomaly\_response module
6231+
------------------------------------------------------------
6232+
6233+
.. automodule:: datadog_api_client.v2.model.cost_anomaly_response
6234+
:members:
6235+
:show-inheritance:
6236+
6237+
datadog\_api\_client.v2.model.cost\_anomaly\_response\_data module
6238+
------------------------------------------------------------------
6239+
6240+
.. automodule:: datadog_api_client.v2.model.cost_anomaly_response_data
6241+
:members:
6242+
:show-inheritance:
6243+
61746244
datadog\_api\_client.v2.model.cost\_attribution\_aggregates\_body module
61756245
------------------------------------------------------------------------
61766246

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
"""
2+
Get cost anomaly returns "OK" response
3+
"""
4+
5+
from datadog_api_client import ApiClient, Configuration
6+
from datadog_api_client.v2.api.cloud_cost_management_api import CloudCostManagementApi
7+
8+
configuration = Configuration()
9+
configuration.unstable_operations["get_cost_anomaly"] = True
10+
with ApiClient(configuration) as api_client:
11+
api_instance = CloudCostManagementApi(api_client)
12+
response = api_instance.get_cost_anomaly(
13+
anomaly_id="anomaly_id",
14+
)
15+
16+
print(response)
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
"""
2+
List cost anomalies returns "OK" response
3+
"""
4+
5+
from datadog_api_client import ApiClient, Configuration
6+
from datadog_api_client.v2.api.cloud_cost_management_api import CloudCostManagementApi
7+
8+
configuration = Configuration()
9+
configuration.unstable_operations["list_cost_anomalies"] = True
10+
with ApiClient(configuration) as api_client:
11+
api_instance = CloudCostManagementApi(api_client)
12+
response = api_instance.list_cost_anomalies()
13+
14+
print(response)

src/datadog_api_client/configuration.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -351,6 +351,8 @@ def __init__(
351351
"v2.search_security_monitoring_histsignals": False,
352352
"v2.get_code_coverage_branch_summary": False,
353353
"v2.get_code_coverage_commit_summary": False,
354+
"v2.get_cost_anomaly": False,
355+
"v2.list_cost_anomalies": False,
354356
"v2.create_dashboard_secure_embed": False,
355357
"v2.delete_dashboard_secure_embed": False,
356358
"v2.get_dashboard_secure_embed": False,

src/datadog_api_client/v2/api/cloud_cost_management_api.py

Lines changed: 194 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111
UnsetType,
1212
unset,
1313
)
14+
from datadog_api_client.v2.model.cost_anomalies_response import CostAnomaliesResponse
15+
from datadog_api_client.v2.model.cost_anomaly_response import CostAnomalyResponse
1416
from datadog_api_client.v2.model.arbitrary_rule_response_array import ArbitraryRuleResponseArray
1517
from datadog_api_client.v2.model.arbitrary_rule_response import ArbitraryRuleResponse
1618
from datadog_api_client.v2.model.arbitrary_cost_upsert_request import ArbitraryCostUpsertRequest
@@ -345,6 +347,29 @@ def __init__(self, api_client=None):
345347
api_client=api_client,
346348
)
347349

350+
self._get_cost_anomaly_endpoint = _Endpoint(
351+
settings={
352+
"response_type": (CostAnomalyResponse,),
353+
"auth": ["apiKeyAuth", "appKeyAuth", "AuthZ"],
354+
"endpoint_path": "/api/v2/cost/anomalies/{anomaly_id}",
355+
"operation_id": "get_cost_anomaly",
356+
"http_method": "GET",
357+
"version": "v2",
358+
},
359+
params_map={
360+
"anomaly_id": {
361+
"required": True,
362+
"openapi_types": (str,),
363+
"attribute": "anomaly_id",
364+
"location": "path",
365+
},
366+
},
367+
headers_map={
368+
"accept": ["application/json"],
369+
},
370+
api_client=api_client,
371+
)
372+
348373
self._get_cost_awscur_config_endpoint = _Endpoint(
349374
settings={
350375
"response_type": (AwsCurConfigResponse,),
@@ -499,6 +524,79 @@ def __init__(self, api_client=None):
499524
api_client=api_client,
500525
)
501526

527+
self._list_cost_anomalies_endpoint = _Endpoint(
528+
settings={
529+
"response_type": (CostAnomaliesResponse,),
530+
"auth": ["apiKeyAuth", "appKeyAuth", "AuthZ"],
531+
"endpoint_path": "/api/v2/cost/anomalies",
532+
"operation_id": "list_cost_anomalies",
533+
"http_method": "GET",
534+
"version": "v2",
535+
},
536+
params_map={
537+
"start": {
538+
"openapi_types": (int,),
539+
"attribute": "start",
540+
"location": "query",
541+
},
542+
"end": {
543+
"openapi_types": (int,),
544+
"attribute": "end",
545+
"location": "query",
546+
},
547+
"filter": {
548+
"openapi_types": (str,),
549+
"attribute": "filter",
550+
"location": "query",
551+
},
552+
"min_anomalous_threshold": {
553+
"openapi_types": (str,),
554+
"attribute": "min_anomalous_threshold",
555+
"location": "query",
556+
},
557+
"min_cost_threshold": {
558+
"openapi_types": (str,),
559+
"attribute": "min_cost_threshold",
560+
"location": "query",
561+
},
562+
"dismissal_cause": {
563+
"openapi_types": (str,),
564+
"attribute": "dismissal_cause",
565+
"location": "query",
566+
},
567+
"order_by": {
568+
"openapi_types": (str,),
569+
"attribute": "order_by",
570+
"location": "query",
571+
},
572+
"order": {
573+
"openapi_types": (str,),
574+
"attribute": "order",
575+
"location": "query",
576+
},
577+
"limit": {
578+
"openapi_types": (int,),
579+
"attribute": "limit",
580+
"location": "query",
581+
},
582+
"offset": {
583+
"openapi_types": (int,),
584+
"attribute": "offset",
585+
"location": "query",
586+
},
587+
"provider_ids": {
588+
"openapi_types": ([str],),
589+
"attribute": "provider_ids",
590+
"location": "query",
591+
"collection_format": "multi",
592+
},
593+
},
594+
headers_map={
595+
"accept": ["application/json"],
596+
},
597+
api_client=api_client,
598+
)
599+
502600
self._list_cost_awscur_configs_endpoint = _Endpoint(
503601
settings={
504602
"response_type": (AwsCURConfigsResponse,),
@@ -1194,6 +1292,23 @@ def get_budget(
11941292

11951293
return self._get_budget_endpoint.call_with_http_info(**kwargs)
11961294

1295+
def get_cost_anomaly(
1296+
self,
1297+
anomaly_id: str,
1298+
) -> CostAnomalyResponse:
1299+
"""Get cost anomaly.
1300+
1301+
Get a detected Cloud Cost Management anomaly by UUID.
1302+
1303+
:param anomaly_id: The UUID of the cost anomaly.
1304+
:type anomaly_id: str
1305+
:rtype: CostAnomalyResponse
1306+
"""
1307+
kwargs: Dict[str, Any] = {}
1308+
kwargs["anomaly_id"] = anomaly_id
1309+
1310+
return self._get_cost_anomaly_endpoint.call_with_http_info(**kwargs)
1311+
11971312
def get_cost_awscur_config(
11981313
self,
11991314
cloud_account_id: int,
@@ -1308,6 +1423,85 @@ def list_budgets(
13081423
kwargs: Dict[str, Any] = {}
13091424
return self._list_budgets_endpoint.call_with_http_info(**kwargs)
13101425

1426+
def list_cost_anomalies(
1427+
self,
1428+
*,
1429+
start: Union[int, UnsetType] = unset,
1430+
end: Union[int, UnsetType] = unset,
1431+
filter: Union[str, UnsetType] = unset,
1432+
min_anomalous_threshold: Union[str, UnsetType] = unset,
1433+
min_cost_threshold: Union[str, UnsetType] = unset,
1434+
dismissal_cause: Union[str, UnsetType] = unset,
1435+
order_by: Union[str, UnsetType] = unset,
1436+
order: Union[str, UnsetType] = unset,
1437+
limit: Union[int, UnsetType] = unset,
1438+
offset: Union[int, UnsetType] = unset,
1439+
provider_ids: Union[List[str], UnsetType] = unset,
1440+
) -> CostAnomaliesResponse:
1441+
"""List cost anomalies.
1442+
1443+
List detected Cloud Cost Management anomalies for the organization.
1444+
1445+
:param start: Start time as Unix milliseconds. Defaults to the start of the latest stable seven-day window.
1446+
:type start: int, optional
1447+
:param end: End time as Unix milliseconds. Defaults to the end of the latest stable seven-day window.
1448+
:type end: int, optional
1449+
:param filter: Optional JSON object mapping cost tag keys to allowed values, for example ``{"team":["payments"],"env":["prod"]}``. Filters match anomaly dimensions or correlated tags.
1450+
:type filter: str, optional
1451+
:param min_anomalous_threshold: Minimum absolute anomalous cost change to include. Numeric value; defaults to ``1``.
1452+
:type min_anomalous_threshold: str, optional
1453+
:param min_cost_threshold: Minimum absolute actual cost to include. Numeric value; defaults to ``0``.
1454+
:type min_cost_threshold: str, optional
1455+
:param dismissal_cause: Filter by resolution state. Use ``none`` for unresolved anomalies, ``all`` or ``*`` for resolved anomalies, or a comma-separated list of causes.
1456+
:type dismissal_cause: str, optional
1457+
:param order_by: Sort field. One of ``start_date`` , ``end_date`` , ``duration`` , ``max_cost`` , ``anomalous_cost`` , or ``dismissal_date``. Defaults to ``anomalous_cost``.
1458+
:type order_by: str, optional
1459+
:param order: Sort direction. One of ``asc`` or ``desc``. Defaults to ``desc``.
1460+
:type order: str, optional
1461+
:param limit: Maximum number of anomalies to return. Defaults to ``200``.
1462+
:type limit: int, optional
1463+
:param offset: Pagination offset. Defaults to ``0``.
1464+
:type offset: int, optional
1465+
:param provider_ids: Optional repeated cloud or SaaS provider filters, such as ``aws`` , ``gcp`` , ``azure`` , ``Oracle`` , ``datadog`` , ``OpenAI`` , or ``Anthropic``.
1466+
:type provider_ids: [str], optional
1467+
:rtype: CostAnomaliesResponse
1468+
"""
1469+
kwargs: Dict[str, Any] = {}
1470+
if start is not unset:
1471+
kwargs["start"] = start
1472+
1473+
if end is not unset:
1474+
kwargs["end"] = end
1475+
1476+
if filter is not unset:
1477+
kwargs["filter"] = filter
1478+
1479+
if min_anomalous_threshold is not unset:
1480+
kwargs["min_anomalous_threshold"] = min_anomalous_threshold
1481+
1482+
if min_cost_threshold is not unset:
1483+
kwargs["min_cost_threshold"] = min_cost_threshold
1484+
1485+
if dismissal_cause is not unset:
1486+
kwargs["dismissal_cause"] = dismissal_cause
1487+
1488+
if order_by is not unset:
1489+
kwargs["order_by"] = order_by
1490+
1491+
if order is not unset:
1492+
kwargs["order"] = order
1493+
1494+
if limit is not unset:
1495+
kwargs["limit"] = limit
1496+
1497+
if offset is not unset:
1498+
kwargs["offset"] = offset
1499+
1500+
if provider_ids is not unset:
1501+
kwargs["provider_ids"] = provider_ids
1502+
1503+
return self._list_cost_anomalies_endpoint.call_with_http_info(**kwargs)
1504+
13111505
def list_cost_awscur_configs(
13121506
self,
13131507
) -> AwsCURConfigsResponse:
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
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.v2.model.cost_anomalies_response_data import CostAnomaliesResponseData
18+
19+
20+
class CostAnomaliesResponse(ModelNormal):
21+
@cached_property
22+
def openapi_types(_):
23+
from datadog_api_client.v2.model.cost_anomalies_response_data import CostAnomaliesResponseData
24+
25+
return {
26+
"data": (CostAnomaliesResponseData,),
27+
}
28+
29+
attribute_map = {
30+
"data": "data",
31+
}
32+
33+
def __init__(self_, data: Union[CostAnomaliesResponseData, UnsetType] = unset, **kwargs):
34+
"""
35+
Response object containing a list of detected Cloud Cost Management anomalies and aggregated totals.
36+
37+
:param data: Resource wrapper for the list of cost anomalies and aggregated totals.
38+
:type data: CostAnomaliesResponseData, optional
39+
"""
40+
if data is not unset:
41+
kwargs["data"] = data
42+
super().__init__(kwargs)

0 commit comments

Comments
 (0)