Skip to content

Commit 83b648b

Browse files
api-clients-generation-pipeline[bot]ci.datadog-api-spec
andauthored
Add Cloud Cost Management tag_metadata months endpoint (#1645)
Co-authored-by: ci.datadog-api-spec <packages@datadoghq.com>
1 parent 6fb7031 commit 83b648b

11 files changed

Lines changed: 569 additions & 0 deletions

.generator/schemas/v2/openapi.yaml

Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19897,6 +19897,45 @@ components:
1989719897
x-enum-varnames:
1989819898
- "TRUE"
1989919899
- "FALSE"
19900+
CostTagMetadataMonth:
19901+
description: A month that has Cloud Cost Management tag metadata available for a given provider.
19902+
properties:
19903+
id:
19904+
description: The month, in `YYYY-MM` format.
19905+
example: "2026-04"
19906+
type: string
19907+
type:
19908+
$ref: "#/components/schemas/CostTagMetadataMonthType"
19909+
required:
19910+
- id
19911+
- type
19912+
type: object
19913+
CostTagMetadataMonthType:
19914+
default: cost_tag_metadata_month
19915+
description: Type of the Cloud Cost Management tag metadata month resource.
19916+
enum:
19917+
- cost_tag_metadata_month
19918+
example: cost_tag_metadata_month
19919+
type: string
19920+
x-enum-varnames:
19921+
- COST_TAG_METADATA_MONTH
19922+
CostTagMetadataMonthsResponse:
19923+
description: List of months that have Cloud Cost Management tag metadata for the requested provider, ordered most-recent first and capped at 36 months.
19924+
example:
19925+
data:
19926+
- id: "2026-04"
19927+
type: cost_tag_metadata_month
19928+
- id: "2026-03"
19929+
type: cost_tag_metadata_month
19930+
properties:
19931+
data:
19932+
description: List of months that have tag metadata available.
19933+
items:
19934+
$ref: "#/components/schemas/CostTagMetadataMonth"
19935+
type: array
19936+
required:
19937+
- data
19938+
type: object
1990019939
CostTagType:
1990119940
default: cost_tag
1990219941
description: Type of the Cloud Cost Management tag resource.
@@ -111135,6 +111174,68 @@ paths:
111135111174
x-unstable: |-
111136111175
**Note**: This endpoint is in preview and is subject to change.
111137111176
If you have any feedback, contact [Datadog support](https://docs.datadoghq.com/help/).
111177+
/api/v2/cost/tag_metadata/months:
111178+
get:
111179+
description: |-
111180+
List months that have Cloud Cost Management tag metadata for a given provider,
111181+
ordered most-recent first. The response is capped at 36 months.
111182+
operationId: ListCostTagMetadataMonths
111183+
parameters:
111184+
- description: |-
111185+
Provider to scope the query to. Use the value of the `providername` tag in CCM
111186+
(for example, `aws`, `azure`, `gcp`, `Oracle`, `Confluent Cloud`, `Snowflake`).
111187+
For costs uploaded through the Custom Costs API, use `custom`.
111188+
Values are case-sensitive.
111189+
example: aws
111190+
in: query
111191+
name: filter[provider]
111192+
required: true
111193+
schema:
111194+
type: string
111195+
responses:
111196+
"200":
111197+
content:
111198+
application/json:
111199+
examples:
111200+
default:
111201+
value:
111202+
data:
111203+
- id: "2026-04"
111204+
type: cost_tag_metadata_month
111205+
- id: "2026-03"
111206+
type: cost_tag_metadata_month
111207+
schema:
111208+
$ref: "#/components/schemas/CostTagMetadataMonthsResponse"
111209+
description: OK
111210+
"400":
111211+
content:
111212+
application/json:
111213+
schema:
111214+
$ref: "#/components/schemas/APIErrorResponse"
111215+
description: Bad Request
111216+
"403":
111217+
content:
111218+
application/json:
111219+
schema:
111220+
$ref: "#/components/schemas/APIErrorResponse"
111221+
description: Forbidden
111222+
"429":
111223+
$ref: "#/components/responses/TooManyRequestsResponse"
111224+
security:
111225+
- apiKeyAuth: []
111226+
appKeyAuth: []
111227+
- AuthZ:
111228+
- cloud_cost_management_read
111229+
summary: List Cloud Cost Management tag metadata months
111230+
tags:
111231+
- Cloud Cost Management
111232+
"x-permission":
111233+
operator: OR
111234+
permissions:
111235+
- cloud_cost_management_read
111236+
x-unstable: |-
111237+
**Note**: This endpoint is in preview and is subject to change.
111238+
If you have any feedback, contact [Datadog support](https://docs.datadoghq.com/help/).
111138111239
/api/v2/cost/tag_metadata/orchestrators:
111139111240
get:
111140111241
description: List container orchestrators (for example, `kubernetes`, `ecs`) detected in Cloud Cost Management data for the requested period.
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
// List Cloud Cost Management tag metadata months 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 mut configuration = datadog::Configuration::new();
8+
configuration.set_unstable_operation_enabled("v2.ListCostTagMetadataMonths", true);
9+
let api = CloudCostManagementAPI::with_config(configuration);
10+
let resp = api
11+
.list_cost_tag_metadata_months("filter[provider]".to_string())
12+
.await;
13+
if let Ok(value) = resp {
14+
println!("{:#?}", value);
15+
} else {
16+
println!("{:#?}", resp.unwrap_err());
17+
}
18+
}

src/datadog/configuration.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -401,6 +401,7 @@ impl Default for Configuration {
401401
("v2.list_cost_tag_key_sources".to_owned(), false),
402402
("v2.list_cost_tag_metadata".to_owned(), false),
403403
("v2.list_cost_tag_metadata_metrics".to_owned(), false),
404+
("v2.list_cost_tag_metadata_months".to_owned(), false),
404405
("v2.list_cost_tag_metadata_orchestrators".to_owned(), false),
405406
("v2.search_cost_recommendations".to_owned(), false),
406407
("v2.create_dashboard_secure_embed".to_owned(), false),

src/datadogV2/api/api_cloud_cost_management.rs

Lines changed: 132 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -875,6 +875,14 @@ pub enum ListCostTagMetadataMetricsError {
875875
UnknownValue(serde_json::Value),
876876
}
877877

878+
/// ListCostTagMetadataMonthsError is a struct for typed errors of method [`CloudCostManagementAPI::list_cost_tag_metadata_months`]
879+
#[derive(Debug, Clone, Serialize, Deserialize)]
880+
#[serde(untagged)]
881+
pub enum ListCostTagMetadataMonthsError {
882+
APIErrorResponse(crate::datadogV2::model::APIErrorResponse),
883+
UnknownValue(serde_json::Value),
884+
}
885+
878886
/// ListCostTagMetadataOrchestratorsError is a struct for typed errors of method [`CloudCostManagementAPI::list_cost_tag_metadata_orchestrators`]
879887
#[derive(Debug, Clone, Serialize, Deserialize)]
880888
#[serde(untagged)]
@@ -6163,6 +6171,130 @@ impl CloudCostManagementAPI {
61636171
}
61646172
}
61656173

6174+
/// List months that have Cloud Cost Management tag metadata for a given provider,
6175+
/// ordered most-recent first. The response is capped at 36 months.
6176+
pub async fn list_cost_tag_metadata_months(
6177+
&self,
6178+
filter_provider: String,
6179+
) -> Result<
6180+
crate::datadogV2::model::CostTagMetadataMonthsResponse,
6181+
datadog::Error<ListCostTagMetadataMonthsError>,
6182+
> {
6183+
match self
6184+
.list_cost_tag_metadata_months_with_http_info(filter_provider)
6185+
.await
6186+
{
6187+
Ok(response_content) => {
6188+
if let Some(e) = response_content.entity {
6189+
Ok(e)
6190+
} else {
6191+
Err(datadog::Error::Serde(serde::de::Error::custom(
6192+
"response content was None",
6193+
)))
6194+
}
6195+
}
6196+
Err(err) => Err(err),
6197+
}
6198+
}
6199+
6200+
/// List months that have Cloud Cost Management tag metadata for a given provider,
6201+
/// ordered most-recent first. The response is capped at 36 months.
6202+
pub async fn list_cost_tag_metadata_months_with_http_info(
6203+
&self,
6204+
filter_provider: String,
6205+
) -> Result<
6206+
datadog::ResponseContent<crate::datadogV2::model::CostTagMetadataMonthsResponse>,
6207+
datadog::Error<ListCostTagMetadataMonthsError>,
6208+
> {
6209+
let local_configuration = &self.config;
6210+
let operation_id = "v2.list_cost_tag_metadata_months";
6211+
if local_configuration.is_unstable_operation_enabled(operation_id) {
6212+
warn!("Using unstable operation {operation_id}");
6213+
} else {
6214+
let local_error = datadog::UnstableOperationDisabledError {
6215+
msg: "Operation 'v2.list_cost_tag_metadata_months' is not enabled".to_string(),
6216+
};
6217+
return Err(datadog::Error::UnstableOperationDisabledError(local_error));
6218+
}
6219+
6220+
let local_client = &self.client;
6221+
6222+
let local_uri_str = format!(
6223+
"{}/api/v2/cost/tag_metadata/months",
6224+
local_configuration.get_operation_host(operation_id)
6225+
);
6226+
let mut local_req_builder =
6227+
local_client.request(reqwest::Method::GET, local_uri_str.as_str());
6228+
6229+
local_req_builder =
6230+
local_req_builder.query(&[("filter[provider]", &filter_provider.to_string())]);
6231+
6232+
// build headers
6233+
let mut headers = HeaderMap::new();
6234+
headers.insert("Accept", HeaderValue::from_static("application/json"));
6235+
6236+
// build user agent
6237+
match HeaderValue::from_str(local_configuration.user_agent.as_str()) {
6238+
Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent),
6239+
Err(e) => {
6240+
log::warn!("Failed to parse user agent header: {e}, falling back to default");
6241+
headers.insert(
6242+
reqwest::header::USER_AGENT,
6243+
HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()),
6244+
)
6245+
}
6246+
};
6247+
6248+
// build auth
6249+
if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") {
6250+
headers.insert(
6251+
"DD-API-KEY",
6252+
HeaderValue::from_str(local_key.key.as_str())
6253+
.expect("failed to parse DD-API-KEY header"),
6254+
);
6255+
};
6256+
if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") {
6257+
headers.insert(
6258+
"DD-APPLICATION-KEY",
6259+
HeaderValue::from_str(local_key.key.as_str())
6260+
.expect("failed to parse DD-APPLICATION-KEY header"),
6261+
);
6262+
};
6263+
6264+
local_req_builder = local_req_builder.headers(headers);
6265+
let local_req = local_req_builder.build()?;
6266+
log::debug!("request content: {:?}", local_req.body());
6267+
let local_resp = local_client.execute(local_req).await?;
6268+
6269+
let local_status = local_resp.status();
6270+
let local_content = local_resp.text().await?;
6271+
log::debug!("response content: {}", local_content);
6272+
6273+
if !local_status.is_client_error() && !local_status.is_server_error() {
6274+
match serde_json::from_str::<crate::datadogV2::model::CostTagMetadataMonthsResponse>(
6275+
&local_content,
6276+
) {
6277+
Ok(e) => {
6278+
return Ok(datadog::ResponseContent {
6279+
status: local_status,
6280+
content: local_content,
6281+
entity: Some(e),
6282+
})
6283+
}
6284+
Err(e) => return Err(datadog::Error::Serde(e)),
6285+
};
6286+
} else {
6287+
let local_entity: Option<ListCostTagMetadataMonthsError> =
6288+
serde_json::from_str(&local_content).ok();
6289+
let local_error = datadog::ResponseContent {
6290+
status: local_status,
6291+
content: local_content,
6292+
entity: local_entity,
6293+
};
6294+
Err(datadog::Error::ResponseError(local_error))
6295+
}
6296+
}
6297+
61666298
/// List container orchestrators (for example, `kubernetes`, `ecs`) detected in Cloud Cost Management data for the requested period.
61676299
pub async fn list_cost_tag_metadata_orchestrators(
61686300
&self,

src/datadogV2/model/mod.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2992,6 +2992,12 @@ pub mod model_cost_metric;
29922992
pub use self::model_cost_metric::CostMetric;
29932993
pub mod model_cost_metric_type;
29942994
pub use self::model_cost_metric_type::CostMetricType;
2995+
pub mod model_cost_tag_metadata_months_response;
2996+
pub use self::model_cost_tag_metadata_months_response::CostTagMetadataMonthsResponse;
2997+
pub mod model_cost_tag_metadata_month;
2998+
pub use self::model_cost_tag_metadata_month::CostTagMetadataMonth;
2999+
pub mod model_cost_tag_metadata_month_type;
3000+
pub use self::model_cost_tag_metadata_month_type::CostTagMetadataMonthType;
29953001
pub mod model_cost_orchestrators_response;
29963002
pub use self::model_cost_orchestrators_response::CostOrchestratorsResponse;
29973003
pub mod model_cost_orchestrator;

0 commit comments

Comments
 (0)