Skip to content

Commit 2804e33

Browse files
api-clients-generation-pipeline[bot]ci.datadog-api-specamaskara-dd
authored
Add tag pipeline, custom allocation rule and get cloud account by id for AWS/Azure/GCP configs APIs (#912)
Co-authored-by: ci.datadog-api-spec <[email protected]> Co-authored-by: amaskara-dd <[email protected]> Co-authored-by: Anika Maskara <[email protected]>
1 parent b620cf2 commit 2804e33

File tree

179 files changed

+17566
-753
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

179 files changed

+17566
-753
lines changed

.generator/schemas/v2/openapi.yaml

Lines changed: 2506 additions & 196 deletions
Large diffs are not rendered by default.
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
// Create arbitrary cost rule returns "OK" response
2+
use datadog_api_client::datadog;
3+
use datadog_api_client::datadogV2::api_cloud_cost_management::CloudCostManagementAPI;
4+
use datadog_api_client::datadogV2::model::ArbitraryCostUpsertRequest;
5+
use datadog_api_client::datadogV2::model::ArbitraryCostUpsertRequestData;
6+
use datadog_api_client::datadogV2::model::ArbitraryCostUpsertRequestDataAttributes;
7+
use datadog_api_client::datadogV2::model::ArbitraryCostUpsertRequestDataAttributesCostsToAllocateItems;
8+
use datadog_api_client::datadogV2::model::ArbitraryCostUpsertRequestDataAttributesStrategy;
9+
use datadog_api_client::datadogV2::model::ArbitraryCostUpsertRequestDataAttributesStrategyBasedOnCostsItems;
10+
use datadog_api_client::datadogV2::model::ArbitraryCostUpsertRequestDataType;
11+
12+
#[tokio::main]
13+
async fn main() {
14+
let body = ArbitraryCostUpsertRequest::new().data(
15+
ArbitraryCostUpsertRequestData::new(
16+
ArbitraryCostUpsertRequestDataType::UPSERT_ARBITRARY_RULE,
17+
)
18+
.attributes(
19+
ArbitraryCostUpsertRequestDataAttributes::new(
20+
vec![
21+
ArbitraryCostUpsertRequestDataAttributesCostsToAllocateItems::new(
22+
"is".to_string(),
23+
"account_id".to_string(),
24+
)
25+
.value("123456789".to_string())
26+
.values(Some(vec![])),
27+
ArbitraryCostUpsertRequestDataAttributesCostsToAllocateItems::new(
28+
"in".to_string(),
29+
"environment".to_string(),
30+
)
31+
.value("".to_string())
32+
.values(Some(vec!["production".to_string(), "staging".to_string()])),
33+
],
34+
vec!["aws".to_string(), "gcp".to_string()],
35+
"example-arbitrary-cost-rule".to_string(),
36+
ArbitraryCostUpsertRequestDataAttributesStrategy::new("proportional".to_string())
37+
.allocated_by_tag_keys(vec!["team".to_string(), "environment".to_string()])
38+
.based_on_costs(vec![
39+
ArbitraryCostUpsertRequestDataAttributesStrategyBasedOnCostsItems::new(
40+
"is".to_string(),
41+
"service".to_string(),
42+
)
43+
.value("web-api".to_string())
44+
.values(Some(vec![])),
45+
ArbitraryCostUpsertRequestDataAttributesStrategyBasedOnCostsItems::new(
46+
"not in".to_string(),
47+
"team".to_string(),
48+
)
49+
.value("".to_string())
50+
.values(Some(vec!["legacy".to_string(), "deprecated".to_string()])),
51+
])
52+
.granularity("daily".to_string()),
53+
"shared".to_string(),
54+
)
55+
.enabled(true)
56+
.order_id(1),
57+
),
58+
);
59+
let configuration = datadog::Configuration::new();
60+
let api = CloudCostManagementAPI::with_config(configuration);
61+
let resp = api.create_arbitrary_cost_rule(body).await;
62+
if let Ok(value) = resp {
63+
println!("{:#?}", value);
64+
} else {
65+
println!("{:#?}", resp.unwrap_err());
66+
}
67+
}

examples/v2_cloud-cost-management_CreateCostAWSCURConfig.rs

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,18 @@ use datadog_api_client::datadogV2::model::AwsCURConfigPostRequestType;
88

99
#[tokio::main]
1010
async fn main() {
11-
let body = AwsCURConfigPostRequest::new(AwsCURConfigPostData::new(
12-
AwsCURConfigPostRequestAttributes::new(
13-
"123456789123".to_string(),
14-
"dd-cost-bucket".to_string(),
15-
"dd-report-name".to_string(),
16-
"dd-report-prefix".to_string(),
17-
)
18-
.bucket_region("us-east-1".to_string()),
19-
AwsCURConfigPostRequestType::AWS_CUR_CONFIG_POST_REQUEST,
20-
));
11+
let body = AwsCURConfigPostRequest::new(
12+
AwsCURConfigPostData::new(AwsCURConfigPostRequestType::AWS_CUR_CONFIG_POST_REQUEST)
13+
.attributes(
14+
AwsCURConfigPostRequestAttributes::new(
15+
"123456789123".to_string(),
16+
"dd-cost-bucket".to_string(),
17+
"dd-report-name".to_string(),
18+
"dd-report-prefix".to_string(),
19+
)
20+
.bucket_region("us-east-1".to_string()),
21+
),
22+
);
2123
let configuration = datadog::Configuration::new();
2224
let api = CloudCostManagementAPI::with_config(configuration);
2325
let resp = api.create_cost_awscur_config(body).await;

examples/v2_cloud-cost-management_CreateCostAzureUCConfigs.rs

Lines changed: 20 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -9,27 +9,26 @@ use datadog_api_client::datadogV2::model::BillConfig;
99

1010
#[tokio::main]
1111
async fn main() {
12-
let body = AzureUCConfigPostRequest::new(AzureUCConfigPostData::new(
13-
AzureUCConfigPostRequestAttributes::new(
14-
"1234abcd-1234-abcd-1234-1234abcd1234".to_string(),
15-
BillConfig::new(
16-
"dd-actual-export".to_string(),
17-
"dd-export-path".to_string(),
18-
"dd-storage-account".to_string(),
19-
"dd-storage-container".to_string(),
20-
),
21-
BillConfig::new(
22-
"dd-actual-export".to_string(),
23-
"dd-export-path".to_string(),
24-
"dd-storage-account".to_string(),
25-
"dd-storage-container".to_string(),
26-
),
27-
"1234abcd-1234-abcd-1234-1234abcd1234".to_string(),
28-
"subscriptions/1234abcd-1234-abcd-1234-1234abcd1234".to_string(),
29-
)
30-
.is_enabled(true),
31-
AzureUCConfigPostRequestType::AZURE_UC_CONFIG_POST_REQUEST,
32-
));
12+
let body = AzureUCConfigPostRequest::new(
13+
AzureUCConfigPostData::new(AzureUCConfigPostRequestType::AZURE_UC_CONFIG_POST_REQUEST)
14+
.attributes(AzureUCConfigPostRequestAttributes::new(
15+
"1234abcd-1234-abcd-1234-1234abcd1234".to_string(),
16+
BillConfig::new(
17+
"dd-actual-export".to_string(),
18+
"dd-export-path".to_string(),
19+
"dd-storage-account".to_string(),
20+
"dd-storage-container".to_string(),
21+
),
22+
BillConfig::new(
23+
"dd-actual-export".to_string(),
24+
"dd-export-path".to_string(),
25+
"dd-storage-account".to_string(),
26+
"dd-storage-container".to_string(),
27+
),
28+
"1234abcd-1234-abcd-1234-1234abcd1234".to_string(),
29+
"subscriptions/1234abcd-1234-abcd-1234-1234abcd1234".to_string(),
30+
)),
31+
);
3332
let configuration = datadog::Configuration::new();
3433
let api = CloudCostManagementAPI::with_config(configuration);
3534
let resp = api.create_cost_azure_uc_configs(body).await;

examples/v2_cloud-cost-management_CreateCostGCPUsageCostConfig.rs

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Create Cloud Cost Management GCP Usage Cost config returns "OK" response
1+
// Create Google Cloud Usage Cost config returns "OK" response
22
use datadog_api_client::datadog;
33
use datadog_api_client::datadogV2::api_cloud_cost_management::CloudCostManagementAPI;
44
use datadog_api_client::datadogV2::model::GCPUsageCostConfigPostData;
@@ -8,17 +8,21 @@ use datadog_api_client::datadogV2::model::GCPUsageCostConfigPostRequestType;
88

99
#[tokio::main]
1010
async fn main() {
11-
let body = GCPUsageCostConfigPostRequest::new(GCPUsageCostConfigPostData::new(
12-
GCPUsageCostConfigPostRequestAttributes::new(
13-
"123456_A123BC_12AB34".to_string(),
14-
"dd-cost-bucket".to_string(),
15-
"billing".to_string(),
16-
"dd-cloud-cost-report".to_string(),
17-
"[email protected]".to_string(),
11+
let body = GCPUsageCostConfigPostRequest::new(
12+
GCPUsageCostConfigPostData::new(
13+
GCPUsageCostConfigPostRequestType::GCP_USAGE_COST_CONFIG_POST_REQUEST,
1814
)
19-
.export_prefix("datadog_cloud_cost_usage_export".to_string()),
20-
GCPUsageCostConfigPostRequestType::GCP_USAGE_COST_CONFIG_POST_REQUEST,
21-
));
15+
.attributes(
16+
GCPUsageCostConfigPostRequestAttributes::new(
17+
"123456_A123BC_12AB34".to_string(),
18+
"dd-cost-bucket".to_string(),
19+
"billing".to_string(),
20+
"dd-cloud-cost-report".to_string(),
21+
"[email protected]".to_string(),
22+
)
23+
.export_prefix("datadog_cloud_cost_usage_export".to_string()),
24+
),
25+
);
2226
let configuration = datadog::Configuration::new();
2327
let api = CloudCostManagementAPI::with_config(configuration);
2428
let resp = api.create_cost_gcp_usage_cost_config(body).await;
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
// Create ruleset returns "OK" response
2+
use datadog_api_client::datadog;
3+
use datadog_api_client::datadogV2::api_cloud_cost_management::CloudCostManagementAPI;
4+
use datadog_api_client::datadogV2::model::CreateRulesetRequest;
5+
use datadog_api_client::datadogV2::model::CreateRulesetRequestData;
6+
use datadog_api_client::datadogV2::model::CreateRulesetRequestDataAttributes;
7+
use datadog_api_client::datadogV2::model::CreateRulesetRequestDataAttributesRulesItems;
8+
use datadog_api_client::datadogV2::model::CreateRulesetRequestDataAttributesRulesItemsQuery;
9+
use datadog_api_client::datadogV2::model::CreateRulesetRequestDataAttributesRulesItemsQueryAddition;
10+
use datadog_api_client::datadogV2::model::CreateRulesetRequestDataType;
11+
12+
#[tokio::main]
13+
async fn main() {
14+
let body = CreateRulesetRequest::new().data(
15+
CreateRulesetRequestData::new(CreateRulesetRequestDataType::CREATE_RULESET)
16+
.attributes(
17+
CreateRulesetRequestDataAttributes::new(vec![
18+
CreateRulesetRequestDataAttributesRulesItems::new(
19+
true,
20+
"Add Cost Center Tag".to_string(),
21+
)
22+
.mapping(None)
23+
.query(Some(
24+
CreateRulesetRequestDataAttributesRulesItemsQuery::new(
25+
Some(
26+
CreateRulesetRequestDataAttributesRulesItemsQueryAddition::new(
27+
"cost_center".to_string(),
28+
"engineering".to_string(),
29+
),
30+
),
31+
true,
32+
r#"account_id:"123456789" AND service:"web-api""#.to_string(),
33+
)
34+
.case_insensitivity(false),
35+
))
36+
.reference_table(None),
37+
])
38+
.enabled(true),
39+
)
40+
.id("New Ruleset".to_string()),
41+
);
42+
let configuration = datadog::Configuration::new();
43+
let api = CloudCostManagementAPI::with_config(configuration);
44+
let resp = api.create_ruleset(body).await;
45+
if let Ok(value) = resp {
46+
println!("{:#?}", value);
47+
} else {
48+
println!("{:#?}", resp.unwrap_err());
49+
}
50+
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
// Delete arbitrary cost rule returns "No Content" response
2+
use datadog_api_client::datadog;
3+
use datadog_api_client::datadogV2::api_cloud_cost_management::CloudCostManagementAPI;
4+
5+
#[tokio::main]
6+
async fn main() {
7+
let configuration = datadog::Configuration::new();
8+
let api = CloudCostManagementAPI::with_config(configuration);
9+
let resp = api.delete_arbitrary_cost_rule(123456).await;
10+
if let Ok(value) = resp {
11+
println!("{:#?}", value);
12+
} else {
13+
println!("{:#?}", resp.unwrap_err());
14+
}
15+
}

examples/v2_cloud-cost-management_DeleteCostGCPUsageCostConfig.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Delete Cloud Cost Management GCP Usage Cost config returns "No Content" response
1+
// Delete Google Cloud Usage Cost config returns "No Content" response
22
use datadog_api_client::datadog;
33
use datadog_api_client::datadogV2::api_cloud_cost_management::CloudCostManagementAPI;
44

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
// Delete ruleset returns "No Content" response
2+
use datadog_api_client::datadog;
3+
use datadog_api_client::datadogV2::api_cloud_cost_management::CloudCostManagementAPI;
4+
5+
#[tokio::main]
6+
async fn main() {
7+
let configuration = datadog::Configuration::new();
8+
let api = CloudCostManagementAPI::with_config(configuration);
9+
let resp = api
10+
.delete_ruleset("1c5dae14-237d-4b9a-a515-aa55b3939142".to_string())
11+
.await;
12+
if let Ok(value) = resp {
13+
println!("{:#?}", value);
14+
} else {
15+
println!("{:#?}", resp.unwrap_err());
16+
}
17+
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
// Get arbitrary cost rule returns "OK" response
2+
use datadog_api_client::datadog;
3+
use datadog_api_client::datadogV2::api_cloud_cost_management::CloudCostManagementAPI;
4+
5+
#[tokio::main]
6+
async fn main() {
7+
let configuration = datadog::Configuration::new();
8+
let api = CloudCostManagementAPI::with_config(configuration);
9+
let resp = api.get_arbitrary_cost_rule(123456).await;
10+
if let Ok(value) = resp {
11+
println!("{:#?}", value);
12+
} else {
13+
println!("{:#?}", resp.unwrap_err());
14+
}
15+
}

0 commit comments

Comments
 (0)