Skip to content
Merged
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
111 changes: 86 additions & 25 deletions .generator/schemas/v2/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -70492,6 +70492,8 @@ components:
$ref: "#/components/schemas/ObservabilityPipelineTagCardinalityLimitProcessorPerMetricLimit"
maxItems: 100
type: array
tracking_mode:
$ref: "#/components/schemas/ObservabilityPipelineTagCardinalityLimitProcessorTrackingMode"
type:
$ref: "#/components/schemas/ObservabilityPipelineTagCardinalityLimitProcessorType"
value_limit:
Expand All @@ -70506,6 +70508,7 @@ components:
- type
- include
- limit_exceeded_action
- tracking_mode
- value_limit
- enabled
type: object
Expand All @@ -70520,6 +70523,16 @@ components:
x-enum-varnames:
- DROP_TAG
- DROP_EVENT
ObservabilityPipelineTagCardinalityLimitProcessorOverrideType:
description: How the override is applied. `limit_override` enforces a custom limit; `excluded` omits the metric or tag from cardinality tracking.
enum:
- limit_override
- excluded
example: limit_override
type: string
x-enum-varnames:
- LIMIT_OVERRIDE
- EXCLUDED
ObservabilityPipelineTagCardinalityLimitProcessorPerMetricLimit:
description: A cardinality override applied to a specific metric.
properties:
Expand All @@ -70529,65 +70542,63 @@ components:
description: The name of the metric this override applies to.
example: "system.cpu.user"
type: string
mode:
$ref: "#/components/schemas/ObservabilityPipelineTagCardinalityLimitProcessorPerMetricMode"
override_type:
$ref: "#/components/schemas/ObservabilityPipelineTagCardinalityLimitProcessorOverrideType"
per_tag_limits:
description: A list of per-tag cardinality overrides that apply within this metric. Must be omitted when `mode` is `excluded`.
description: A list of per-tag cardinality overrides that apply within this metric. Must be omitted when `override_type` is `excluded`.
items:
$ref: "#/components/schemas/ObservabilityPipelineTagCardinalityLimitProcessorPerTagLimit"
maxItems: 50
type: array
value_limit:
description: The maximum number of distinct tag value combinations allowed for this metric. Required when `mode` is `tracked`. Must be omitted when `mode` is `excluded`.
description: The maximum number of distinct tag value combinations allowed for this metric. Required when `override_type` is `limit_override`. Must be omitted when `override_type` is `excluded`.
example: 10000
format: int64
maximum: 1000000
minimum: 0
type: integer
required:
- metric_name
- mode
- override_type
type: object
ObservabilityPipelineTagCardinalityLimitProcessorPerMetricMode:
description: How the per-metric override is applied. `tracked` enforces a custom limit; `excluded` skips the metric entirely.
enum:
- tracked
- excluded
example: tracked
type: string
x-enum-varnames:
- TRACKED
- EXCLUDED
ObservabilityPipelineTagCardinalityLimitProcessorPerTagLimit:
description: A cardinality override for a specific tag key within a per-metric limit.
properties:
mode:
$ref: "#/components/schemas/ObservabilityPipelineTagCardinalityLimitProcessorPerTagMode"
override_type:
$ref: "#/components/schemas/ObservabilityPipelineTagCardinalityLimitProcessorOverrideType"
tag_key:
description: The tag key this override applies to.
example: "host"
type: string
value_limit:
description: The maximum number of distinct values allowed for this tag. Required when `mode` is `limit_override`. Must be omitted when `mode` is `excluded`.
description: The maximum number of distinct values allowed for this tag. Required when `override_type` is `limit_override`. Must be omitted when `override_type` is `excluded`.
example: 5000
format: int64
maximum: 1000000
minimum: 0
type: integer
required:
- tag_key
- override_type
type: object
ObservabilityPipelineTagCardinalityLimitProcessorTrackingMode:
description: Controls whether the processor uses exact or probabilistic tag tracking.
properties:
mode:
$ref: "#/components/schemas/ObservabilityPipelineTagCardinalityLimitProcessorTrackingModeMode"
required:
- mode
type: object
ObservabilityPipelineTagCardinalityLimitProcessorPerTagMode:
description: How the per-tag override is applied. `limit_override` enforces a custom limit on the tag; `excluded` skips the tag from cardinality tracking.
ObservabilityPipelineTagCardinalityLimitProcessorTrackingModeMode:
description: The cardinality tracking algorithm to use.
enum:
- limit_override
- excluded
example: limit_override
- exact_fingerprint
- probabilistic
example: exact_fingerprint
type: string
x-enum-varnames:
- LIMIT_OVERRIDE
- EXCLUDED
- EXACT_FINGERPRINT
- PROBABILISTIC
ObservabilityPipelineTagCardinalityLimitProcessorType:
default: tag_cardinality_limit
description: The processor type. The value must be `tag_cardinality_limit`.
Expand Down Expand Up @@ -127284,6 +127295,56 @@ 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/).
get:
description: Get the custom forecast for a budget.
operationId: GetCustomForecast
parameters:
- $ref: "#/components/parameters/BudgetID"
responses:
"200":
content:
application/json:
examples:
default:
value:
data:
attributes:
budget_uid: 00000000-0000-0000-0000-000000000001
created_at: 1738258683590
created_by: 00000000-0a0a-0a0a-aaa0-00000000000a
entries:
- amount: 400
month: 202501
tag_filters:
- tag_key: service
tag_value: ec2
- amount: 450
month: 202502
tag_filters:
- tag_key: service
tag_value: ec2
updated_at: 1738258683590
updated_by: 00000000-0a0a-0a0a-aaa0-00000000000a
id: 11111111-1111-1111-1111-111111111111
type: custom_forecast
schema:
$ref: "#/components/schemas/CustomForecastResponse"
description: OK
"400":
$ref: "#/components/responses/BadRequestResponse"
"404":
$ref: "#/components/responses/NotFoundResponse"
"429":
$ref: "#/components/responses/TooManyRequestsResponse"
security:
- apiKeyAuth: []
appKeyAuth: []
summary: Get a budget's custom forecast
tags:
- Cloud Cost Management
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/budgets:
get:
description: List budgets.
Expand Down
16 changes: 16 additions & 0 deletions examples/v2_cloud-cost-management_GetCustomForecast.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
// Get a budget's custom forecast 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.GetCustomForecast", true);
let api = CloudCostManagementAPI::with_config(configuration);
let resp = api.get_custom_forecast("budget_id".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 @@ -506,6 +506,7 @@ impl Default for Configuration {
),
("v2.get_cost_anomaly".to_owned(), false),
("v2.get_cost_tag_metadata_currency".to_owned(), false),
("v2.get_custom_forecast".to_owned(), false),
("v2.list_cost_anomalies".to_owned(), false),
("v2.list_cost_tag_key_sources".to_owned(), false),
("v2.list_cost_tag_metadata".to_owned(), false),
Expand Down
125 changes: 125 additions & 0 deletions src/datadogV2/api/api_cloud_cost_management.rs
Original file line number Diff line number Diff line change
Expand Up @@ -887,6 +887,14 @@ pub enum GetCustomCostsFileError {
UnknownValue(serde_json::Value),
}

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

/// GetTagPipelinesRulesetError is a struct for typed errors of method [`CloudCostManagementAPI::get_tag_pipelines_ruleset`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
Expand Down Expand Up @@ -5301,6 +5309,123 @@ impl CloudCostManagementAPI {
}
}

/// Get the custom forecast for a budget.
pub async fn get_custom_forecast(
&self,
budget_id: String,
) -> Result<
crate::datadogV2::model::CustomForecastResponse,
datadog::Error<GetCustomForecastError>,
> {
match self.get_custom_forecast_with_http_info(budget_id).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),
}
}

/// Get the custom forecast for a budget.
pub async fn get_custom_forecast_with_http_info(
&self,
budget_id: String,
) -> Result<
datadog::ResponseContent<crate::datadogV2::model::CustomForecastResponse>,
datadog::Error<GetCustomForecastError>,
> {
let local_configuration = &self.config;
let operation_id = "v2.get_custom_forecast";
if local_configuration.is_unstable_operation_enabled(operation_id) {
warn!("Using unstable operation {operation_id}");
} else {
let local_error = datadog::UnstableOperationDisabledError {
msg: "Operation 'v2.get_custom_forecast' 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/budget/{budget_id}/custom-forecast",
local_configuration.get_operation_host(operation_id),
budget_id = datadog::urlencode(budget_id)
);
let mut local_req_builder =
local_client.request(reqwest::Method::GET, local_uri_str.as_str());

// 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::CustomForecastResponse>(
&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<GetCustomForecastError> =
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))
}
}

/// Get a specific tag pipeline ruleset - Retrieve a specific tag pipeline ruleset by its ID
pub async fn get_tag_pipelines_ruleset(
&self,
Expand Down
10 changes: 6 additions & 4 deletions src/datadogV2/model/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7658,12 +7658,14 @@ pub mod model_observability_pipeline_tag_cardinality_limit_processor_action;
pub use self::model_observability_pipeline_tag_cardinality_limit_processor_action::ObservabilityPipelineTagCardinalityLimitProcessorAction;
pub mod model_observability_pipeline_tag_cardinality_limit_processor_per_metric_limit;
pub use self::model_observability_pipeline_tag_cardinality_limit_processor_per_metric_limit::ObservabilityPipelineTagCardinalityLimitProcessorPerMetricLimit;
pub mod model_observability_pipeline_tag_cardinality_limit_processor_per_metric_mode;
pub use self::model_observability_pipeline_tag_cardinality_limit_processor_per_metric_mode::ObservabilityPipelineTagCardinalityLimitProcessorPerMetricMode;
pub mod model_observability_pipeline_tag_cardinality_limit_processor_override_type;
pub use self::model_observability_pipeline_tag_cardinality_limit_processor_override_type::ObservabilityPipelineTagCardinalityLimitProcessorOverrideType;
pub mod model_observability_pipeline_tag_cardinality_limit_processor_per_tag_limit;
pub use self::model_observability_pipeline_tag_cardinality_limit_processor_per_tag_limit::ObservabilityPipelineTagCardinalityLimitProcessorPerTagLimit;
pub mod model_observability_pipeline_tag_cardinality_limit_processor_per_tag_mode;
pub use self::model_observability_pipeline_tag_cardinality_limit_processor_per_tag_mode::ObservabilityPipelineTagCardinalityLimitProcessorPerTagMode;
pub mod model_observability_pipeline_tag_cardinality_limit_processor_tracking_mode;
pub use self::model_observability_pipeline_tag_cardinality_limit_processor_tracking_mode::ObservabilityPipelineTagCardinalityLimitProcessorTrackingMode;
pub mod model_observability_pipeline_tag_cardinality_limit_processor_tracking_mode_mode;
pub use self::model_observability_pipeline_tag_cardinality_limit_processor_tracking_mode_mode::ObservabilityPipelineTagCardinalityLimitProcessorTrackingModeMode;
pub mod model_observability_pipeline_tag_cardinality_limit_processor_type;
pub use self::model_observability_pipeline_tag_cardinality_limit_processor_type::ObservabilityPipelineTagCardinalityLimitProcessorType;
pub mod model_observability_pipeline_config_processor_item;
Expand Down
Loading
Loading