-
Notifications
You must be signed in to change notification settings - Fork 52
Expand file tree
/
Copy pathCreateArbitraryCostRule.py
More file actions
86 lines (82 loc) · 3.34 KB
/
CreateArbitraryCostRule.py
File metadata and controls
86 lines (82 loc) · 3.34 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
"""
Create arbitrary cost rule returns "OK" response
"""
from datadog_api_client import ApiClient, Configuration
from datadog_api_client.v2.api.cloud_cost_management_api import CloudCostManagementApi
from datadog_api_client.v2.model.arbitrary_cost_upsert_request import ArbitraryCostUpsertRequest
from datadog_api_client.v2.model.arbitrary_cost_upsert_request_data import ArbitraryCostUpsertRequestData
from datadog_api_client.v2.model.arbitrary_cost_upsert_request_data_attributes import (
ArbitraryCostUpsertRequestDataAttributes,
)
from datadog_api_client.v2.model.arbitrary_cost_upsert_request_data_attributes_costs_to_allocate_items import (
ArbitraryCostUpsertRequestDataAttributesCostsToAllocateItems,
)
from datadog_api_client.v2.model.arbitrary_cost_upsert_request_data_attributes_strategy import (
ArbitraryCostUpsertRequestDataAttributesStrategy,
)
from datadog_api_client.v2.model.arbitrary_cost_upsert_request_data_attributes_strategy_based_on_costs_items import (
ArbitraryCostUpsertRequestDataAttributesStrategyBasedOnCostsItems,
)
from datadog_api_client.v2.model.arbitrary_cost_upsert_request_data_type import ArbitraryCostUpsertRequestDataType
body = ArbitraryCostUpsertRequest(
data=ArbitraryCostUpsertRequestData(
attributes=ArbitraryCostUpsertRequestDataAttributes(
costs_to_allocate=[
ArbitraryCostUpsertRequestDataAttributesCostsToAllocateItems(
condition="is",
tag="account_id",
value="123456789",
values=[],
),
ArbitraryCostUpsertRequestDataAttributesCostsToAllocateItems(
condition="in",
tag="environment",
value="",
values=[
"production",
"staging",
],
),
],
enabled=True,
order_id=1,
provider=[
"aws",
"gcp",
],
rule_name="example-arbitrary-cost-rule",
strategy=ArbitraryCostUpsertRequestDataAttributesStrategy(
allocated_by_tag_keys=[
"team",
"environment",
],
based_on_costs=[
ArbitraryCostUpsertRequestDataAttributesStrategyBasedOnCostsItems(
condition="is",
tag="service",
value="web-api",
values=[],
),
ArbitraryCostUpsertRequestDataAttributesStrategyBasedOnCostsItems(
condition="not in",
tag="team",
value="",
values=[
"legacy",
"deprecated",
],
),
],
granularity="daily",
method="proportional",
),
type="shared",
),
type=ArbitraryCostUpsertRequestDataType.UPSERT_ARBITRARY_RULE,
),
)
configuration = Configuration()
with ApiClient(configuration) as api_client:
api_instance = CloudCostManagementApi(api_client)
response = api_instance.create_arbitrary_cost_rule(body=body)
print(response)