Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
101 changes: 101 additions & 0 deletions .generator/schemas/v2/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18525,6 +18525,45 @@ components:
x-enum-varnames:
- "TRUE"
- "FALSE"
CostTagMetadataMonth:
description: A month that has Cloud Cost Management tag metadata available for a given provider.
properties:
id:
description: The month, in `YYYY-MM` format.
example: "2026-04"
type: string
type:
$ref: "#/components/schemas/CostTagMetadataMonthType"
required:
- id
- type
type: object
CostTagMetadataMonthType:
default: cost_tag_metadata_month
description: Type of the Cloud Cost Management tag metadata month resource.
enum:
- cost_tag_metadata_month
example: cost_tag_metadata_month
type: string
x-enum-varnames:
- COST_TAG_METADATA_MONTH
CostTagMetadataMonthsResponse:
description: List of months that have Cloud Cost Management tag metadata for the requested provider, ordered most-recent first and capped at 36 months.
example:
data:
- id: "2026-04"
type: cost_tag_metadata_month
- id: "2026-03"
type: cost_tag_metadata_month
properties:
data:
description: List of months that have tag metadata available.
items:
$ref: "#/components/schemas/CostTagMetadataMonth"
type: array
required:
- data
type: object
CostTagType:
default: cost_tag
description: Type of the Cloud Cost Management tag resource.
Expand Down Expand Up @@ -109019,6 +109058,68 @@ paths:
x-unstable: |-
**Note**: This endpoint is in preview and is subject to change.
If you have any feedback, contact [Datadog support](https://docs.datadoghq.com/help/).
/api/v2/cost/tag_metadata/months:
get:
description: |-
List months that have Cloud Cost Management tag metadata for a given provider,
ordered most-recent first. The response is capped at 36 months.
operationId: ListCostTagMetadataMonths
parameters:
- description: |-
Provider to scope the query to. Use the value of the `providername` tag in CCM
(for example, `aws`, `azure`, `gcp`, `Oracle`, `Confluent Cloud`, `Snowflake`).
For costs uploaded through the Custom Costs API, use `custom`.
Values are case-sensitive.
example: aws
in: query
name: filter[provider]
required: true
schema:
type: string
responses:
"200":
content:
application/json:
examples:
default:
value:
data:
- id: "2026-04"
type: cost_tag_metadata_month
- id: "2026-03"
type: cost_tag_metadata_month
schema:
$ref: "#/components/schemas/CostTagMetadataMonthsResponse"
description: OK
"400":
content:
application/json:
schema:
$ref: "#/components/schemas/APIErrorResponse"
description: Bad Request
"403":
content:
application/json:
schema:
$ref: "#/components/schemas/APIErrorResponse"
description: Forbidden
"429":
$ref: "#/components/responses/TooManyRequestsResponse"
security:
- apiKeyAuth: []
appKeyAuth: []
- AuthZ:
- cloud_cost_management_read
summary: List Cloud Cost Management tag metadata months
tags:
- Cloud Cost Management
"x-permission":
operator: OR
permissions:
- cloud_cost_management_read
x-unstable: |-
**Note**: This endpoint is in preview and is subject to change.
If you have any feedback, contact [Datadog support](https://docs.datadoghq.com/help/).
/api/v2/cost/tag_metadata/orchestrators:
get:
description: List container orchestrators (for example, `kubernetes`, `ecs`) detected in Cloud Cost Management data for the requested period.
Expand Down
18 changes: 18 additions & 0 deletions examples/v2_cloud-cost-management_ListCostTagMetadataMonths.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
// List Cloud Cost Management tag metadata months returns "OK" response
use datadog_api_client::datadog;
use datadog_api_client::datadogV2::api_cloud_cost_management::CloudCostManagementAPI;

#[tokio::main]
async fn main() {
let mut configuration = datadog::Configuration::new();
configuration.set_unstable_operation_enabled("v2.ListCostTagMetadataMonths", true);
let api = CloudCostManagementAPI::with_config(configuration);
let resp = api
.list_cost_tag_metadata_months("filter[provider]".to_string())
.await;
if let Ok(value) = resp {
println!("{:#?}", value);
} else {
println!("{:#?}", resp.unwrap_err());
}
}
1 change: 1 addition & 0 deletions src/datadog/configuration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -374,6 +374,7 @@ impl Default for Configuration {
("v2.list_cost_tag_key_sources".to_owned(), false),
("v2.list_cost_tag_metadata".to_owned(), false),
("v2.list_cost_tag_metadata_metrics".to_owned(), false),
("v2.list_cost_tag_metadata_months".to_owned(), false),
("v2.list_cost_tag_metadata_orchestrators".to_owned(), false),
("v2.search_cost_recommendations".to_owned(), false),
("v2.create_dashboard_secure_embed".to_owned(), false),
Expand Down
132 changes: 132 additions & 0 deletions src/datadogV2/api/api_cloud_cost_management.rs
Original file line number Diff line number Diff line change
Expand Up @@ -875,6 +875,14 @@ pub enum ListCostTagMetadataMetricsError {
UnknownValue(serde_json::Value),
}

/// ListCostTagMetadataMonthsError is a struct for typed errors of method [`CloudCostManagementAPI::list_cost_tag_metadata_months`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum ListCostTagMetadataMonthsError {
APIErrorResponse(crate::datadogV2::model::APIErrorResponse),
UnknownValue(serde_json::Value),
}

/// ListCostTagMetadataOrchestratorsError is a struct for typed errors of method [`CloudCostManagementAPI::list_cost_tag_metadata_orchestrators`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
Expand Down Expand Up @@ -6163,6 +6171,130 @@ impl CloudCostManagementAPI {
}
}

/// List months that have Cloud Cost Management tag metadata for a given provider,
/// ordered most-recent first. The response is capped at 36 months.
pub async fn list_cost_tag_metadata_months(
&self,
filter_provider: String,
) -> Result<
crate::datadogV2::model::CostTagMetadataMonthsResponse,
datadog::Error<ListCostTagMetadataMonthsError>,
> {
match self
.list_cost_tag_metadata_months_with_http_info(filter_provider)
.await
{
Ok(response_content) => {
if let Some(e) = response_content.entity {
Ok(e)
} else {
Err(datadog::Error::Serde(serde::de::Error::custom(
"response content was None",
)))
}
}
Err(err) => Err(err),
}
}

/// List months that have Cloud Cost Management tag metadata for a given provider,
/// ordered most-recent first. The response is capped at 36 months.
pub async fn list_cost_tag_metadata_months_with_http_info(
&self,
filter_provider: String,
) -> Result<
datadog::ResponseContent<crate::datadogV2::model::CostTagMetadataMonthsResponse>,
datadog::Error<ListCostTagMetadataMonthsError>,
> {
let local_configuration = &self.config;
let operation_id = "v2.list_cost_tag_metadata_months";
if local_configuration.is_unstable_operation_enabled(operation_id) {
warn!("Using unstable operation {operation_id}");
} else {
let local_error = datadog::UnstableOperationDisabledError {
msg: "Operation 'v2.list_cost_tag_metadata_months' is not enabled".to_string(),
};
return Err(datadog::Error::UnstableOperationDisabledError(local_error));
}

let local_client = &self.client;

let local_uri_str = format!(
"{}/api/v2/cost/tag_metadata/months",
local_configuration.get_operation_host(operation_id)
);
let mut local_req_builder =
local_client.request(reqwest::Method::GET, local_uri_str.as_str());

local_req_builder =
local_req_builder.query(&[("filter[provider]", &filter_provider.to_string())]);

// build headers
let mut headers = HeaderMap::new();
headers.insert("Accept", HeaderValue::from_static("application/json"));

// build user agent
match HeaderValue::from_str(local_configuration.user_agent.as_str()) {
Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent),
Err(e) => {
log::warn!("Failed to parse user agent header: {e}, falling back to default");
headers.insert(
reqwest::header::USER_AGENT,
HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()),
)
}
};

// build auth
if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") {
headers.insert(
"DD-API-KEY",
HeaderValue::from_str(local_key.key.as_str())
.expect("failed to parse DD-API-KEY header"),
);
};
if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") {
headers.insert(
"DD-APPLICATION-KEY",
HeaderValue::from_str(local_key.key.as_str())
.expect("failed to parse DD-APPLICATION-KEY header"),
);
};

local_req_builder = local_req_builder.headers(headers);
let local_req = local_req_builder.build()?;
log::debug!("request content: {:?}", local_req.body());
let local_resp = local_client.execute(local_req).await?;

let local_status = local_resp.status();
let local_content = local_resp.text().await?;
log::debug!("response content: {}", local_content);

if !local_status.is_client_error() && !local_status.is_server_error() {
match serde_json::from_str::<crate::datadogV2::model::CostTagMetadataMonthsResponse>(
&local_content,
) {
Ok(e) => {
return Ok(datadog::ResponseContent {
status: local_status,
content: local_content,
entity: Some(e),
})
}
Err(e) => return Err(datadog::Error::Serde(e)),
};
} else {
let local_entity: Option<ListCostTagMetadataMonthsError> =
serde_json::from_str(&local_content).ok();
let local_error = datadog::ResponseContent {
status: local_status,
content: local_content,
entity: local_entity,
};
Err(datadog::Error::ResponseError(local_error))
}
}

/// List container orchestrators (for example, `kubernetes`, `ecs`) detected in Cloud Cost Management data for the requested period.
pub async fn list_cost_tag_metadata_orchestrators(
&self,
Expand Down
6 changes: 6 additions & 0 deletions src/datadogV2/model/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2992,6 +2992,12 @@ pub mod model_cost_metric;
pub use self::model_cost_metric::CostMetric;
pub mod model_cost_metric_type;
pub use self::model_cost_metric_type::CostMetricType;
pub mod model_cost_tag_metadata_months_response;
pub use self::model_cost_tag_metadata_months_response::CostTagMetadataMonthsResponse;
pub mod model_cost_tag_metadata_month;
pub use self::model_cost_tag_metadata_month::CostTagMetadataMonth;
pub mod model_cost_tag_metadata_month_type;
pub use self::model_cost_tag_metadata_month_type::CostTagMetadataMonthType;
pub mod model_cost_orchestrators_response;
pub use self::model_cost_orchestrators_response::CostOrchestratorsResponse;
pub mod model_cost_orchestrator;
Expand Down
Loading
Loading