Skip to content

Commit 76a67ab

Browse files
api-clients-generation-pipeline[bot]ci.datadog-api-spec
andauthored
Update GetBudget API spec with cost query parameters and custom forecast fields (#1722)
Co-authored-by: ci.datadog-api-spec <packages@datadoghq.com>
1 parent 3e472d1 commit 76a67ab

12 files changed

Lines changed: 909 additions & 9 deletions

.generator/schemas/v2/openapi.yaml

Lines changed: 145 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13185,6 +13185,20 @@ components:
1318513185
BudgetAttributes:
1318613186
description: The attributes of a budget.
1318713187
properties:
13188+
costs:
13189+
$ref: "#/components/schemas/BudgetAttributesCosts"
13190+
description: Aggregated cost data for the budget. Present only when `actual=true` or `forecast=true` is requested.
13191+
costs_period_end:
13192+
description: The end of the period used to compute cost data, in milliseconds since epoch.
13193+
format: int64
13194+
type: integer
13195+
costs_period_start:
13196+
description: The start of the period used to compute cost data, in milliseconds since epoch.
13197+
format: int64
13198+
type: integer
13199+
costs_unit:
13200+
$ref: "#/components/schemas/BudgetAttributesCostsUnit"
13201+
description: The unit used for all cost values in the response.
1318813202
created_at:
1318913203
description: The timestamp when the budget was created.
1319013204
example: 1738258683590
@@ -13237,6 +13251,53 @@ components:
1323713251
example: 00000000-0a0a-0a0a-aaa0-00000000000a
1323813252
type: string
1323913253
type: object
13254+
BudgetAttributesCosts:
13255+
description: Aggregated cost data for the budget over the requested period.
13256+
properties:
13257+
actual:
13258+
description: The total actual cost. Present only when `actual=true` is requested.
13259+
format: double
13260+
nullable: true
13261+
type: number
13262+
amount:
13263+
description: The total budgeted amount over the requested period.
13264+
format: double
13265+
nullable: true
13266+
type: number
13267+
forecast:
13268+
description: The total forecast cost, with any custom forecast overrides applied. Present only when `forecast=true` is requested.
13269+
format: double
13270+
nullable: true
13271+
type: number
13272+
ootb_forecast:
13273+
description: The out-of-the-box ML forecast before custom overrides. Present only when `forecast=true` is requested.
13274+
format: double
13275+
nullable: true
13276+
type: number
13277+
type: object
13278+
BudgetAttributesCostsUnit:
13279+
description: The unit used for all cost values in the response.
13280+
properties:
13281+
family:
13282+
description: The unit family (for example, `currency`).
13283+
type: string
13284+
id:
13285+
description: The unique identifier for the unit.
13286+
type: string
13287+
name:
13288+
description: The full name of the unit.
13289+
type: string
13290+
plural:
13291+
description: The plural form of the unit name.
13292+
type: string
13293+
scale_factor:
13294+
description: The scale factor applied to raw cost values.
13295+
format: double
13296+
type: number
13297+
short_name:
13298+
description: The abbreviated unit name.
13299+
type: string
13300+
type: object
1324013301
BudgetValidationRequest:
1324113302
description: The request object for validating a budget configuration before creating or updating it.
1324213303
example:
@@ -13402,6 +13463,9 @@ components:
1340213463
description: The budgeted amount for this entry.
1340313464
format: double
1340413465
type: number
13466+
costs:
13467+
$ref: "#/components/schemas/BudgetWithEntriesDataAttributesEntriesItemsCosts"
13468+
description: Cost data for this entry. Present only when `actual=true` or `forecast=true` is requested.
1340513469
month:
1340613470
description: The month this budget entry applies to, in YYYYMM format.
1340713471
format: int64
@@ -13412,6 +13476,36 @@ components:
1341213476
$ref: "#/components/schemas/BudgetWithEntriesDataAttributesEntriesItemsTagFiltersItems"
1341313477
type: array
1341413478
type: object
13479+
BudgetWithEntriesDataAttributesEntriesItemsCosts:
13480+
description: Cost data for a single budget entry.
13481+
properties:
13482+
actual:
13483+
description: The actual cost for this entry. Present only when `actual=true` is requested.
13484+
format: double
13485+
nullable: true
13486+
type: number
13487+
amount:
13488+
description: The budgeted amount for this entry.
13489+
format: double
13490+
nullable: true
13491+
type: number
13492+
custom_forecast:
13493+
description: |-
13494+
The custom forecast override for this entry. `null` when `forecast=true` is requested but no custom forecast has been set for this entry's month. A numeric value, including `0`, indicates an explicit custom forecast override. Omitted when `forecast=false` or the feature is not available for the organization.
13495+
format: double
13496+
nullable: true
13497+
type: number
13498+
forecast:
13499+
description: The final forecast for this entry, with any custom forecast override applied. Present only when `forecast=true` is requested.
13500+
format: double
13501+
nullable: true
13502+
type: number
13503+
ootb_forecast:
13504+
description: The out-of-the-box ML forecast for this entry, before custom overrides. Present only when `forecast=true` is requested.
13505+
format: double
13506+
nullable: true
13507+
type: number
13508+
type: object
1341513509
BudgetWithEntriesDataAttributesEntriesItemsTagFiltersItems:
1341613510
description: A tag filter used to scope a budget entry to specific resource tags.
1341713511
properties:
@@ -124497,10 +124591,36 @@ paths:
124497124591
tags:
124498124592
- Cloud Cost Management
124499124593
get:
124500-
description: Get a budget
124594+
description: Get a budget by ID. Pass `actual=true` or `forecast=true` to include cost data in the response. Use `start` and `end` (millisecond epochs, both required) to set the cost window. When `forecast=true`, each entry also includes `ootb_forecast` (the ML forecast before overrides) and `custom_forecast` (`null` if no override is set, a number if one is).
124501124595
operationId: GetBudget
124502124596
parameters:
124503124597
- $ref: "#/components/parameters/BudgetID"
124598+
- description: When `true`, includes actual cost data in the response.
124599+
in: query
124600+
name: actual
124601+
required: false
124602+
schema:
124603+
type: boolean
124604+
- description: When `true`, includes forecast cost data in the response, including `ootb_forecast` and `custom_forecast` per entry.
124605+
in: query
124606+
name: forecast
124607+
required: false
124608+
schema:
124609+
type: boolean
124610+
- description: Start of the cost window in milliseconds since epoch. Must be used together with `end`.
124611+
in: query
124612+
name: start
124613+
required: false
124614+
schema:
124615+
format: int64
124616+
type: integer
124617+
- description: End of the cost window in milliseconds since epoch. Must be used together with `start`.
124618+
in: query
124619+
name: end
124620+
required: false
124621+
schema:
124622+
format: int64
124623+
type: integer
124504124624
responses:
124505124625
"200":
124506124626
content:
@@ -124510,11 +124630,31 @@ paths:
124510124630
value:
124511124631
data:
124512124632
attributes:
124633+
costs:
124634+
actual: 850.25
124635+
amount: 1000.0
124636+
forecast: 1100.5
124637+
ootb_forecast: 1100.5
124638+
costs_period_end: 1740873600000
124639+
costs_period_start: 1738281600000
124640+
costs_unit:
124641+
family: currency
124642+
id: "1"
124643+
name: dollar
124644+
plural: dollars
124645+
scale_factor: 1.0
124646+
short_name: $
124513124647
created_at: 1738258683590
124514124648
created_by: 00000000-0a0a-0a0a-aaa0-00000000000a
124515124649
end_month: 202502
124516124650
entries:
124517124651
- amount: 500
124652+
costs:
124653+
actual: 425.5
124654+
amount: 500.0
124655+
custom_forecast:
124656+
forecast: 550.25
124657+
ootb_forecast: 550.25
124518124658
month: 202501
124519124659
tag_filters:
124520124660
- tag_key: service
@@ -124531,6 +124671,10 @@ paths:
124531124671
schema:
124532124672
$ref: "#/components/schemas/BudgetWithEntries"
124533124673
description: OK
124674+
"400":
124675+
$ref: "#/components/responses/BadRequestResponse"
124676+
"404":
124677+
$ref: "#/components/responses/NotFoundResponse"
124534124678
"429":
124535124679
$ref: "#/components/responses/TooManyRequestsResponse"
124536124680
security:

examples/v2_cloud-cost-management_GetBudget.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,15 @@
11
// Get budget returns "OK" response
22
use datadog_api_client::datadog;
33
use datadog_api_client::datadogV2::api_cloud_cost_management::CloudCostManagementAPI;
4+
use datadog_api_client::datadogV2::api_cloud_cost_management::GetBudgetOptionalParams;
45

56
#[tokio::main]
67
async fn main() {
78
let configuration = datadog::Configuration::new();
89
let api = CloudCostManagementAPI::with_config(configuration);
9-
let resp = api.get_budget("budget_id".to_string()).await;
10+
let resp = api
11+
.get_budget("budget_id".to_string(), GetBudgetOptionalParams::default())
12+
.await;
1013
if let Ok(value) = resp {
1114
println!("{:#?}", value);
1215
} else {

examples/v2_cloud-cost-management_UpsertBudget.rs

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,12 @@
22
use datadog_api_client::datadog;
33
use datadog_api_client::datadogV2::api_cloud_cost_management::CloudCostManagementAPI;
44
use datadog_api_client::datadogV2::model::BudgetAttributes;
5+
use datadog_api_client::datadogV2::model::BudgetAttributesCosts;
6+
use datadog_api_client::datadogV2::model::BudgetAttributesCostsUnit;
57
use datadog_api_client::datadogV2::model::BudgetWithEntries;
68
use datadog_api_client::datadogV2::model::BudgetWithEntriesData;
79
use datadog_api_client::datadogV2::model::BudgetWithEntriesDataAttributesEntriesItems;
10+
use datadog_api_client::datadogV2::model::BudgetWithEntriesDataAttributesEntriesItemsCosts;
811
use datadog_api_client::datadogV2::model::BudgetWithEntriesDataAttributesEntriesItemsTagFiltersItems;
912

1013
#[tokio::main]
@@ -13,10 +16,26 @@ async fn main() {
1316
BudgetWithEntriesData::new()
1417
.attributes(
1518
BudgetAttributes::new()
19+
.costs(
20+
BudgetAttributesCosts::new()
21+
.actual(None)
22+
.amount(None)
23+
.forecast(None)
24+
.ootb_forecast(None),
25+
)
26+
.costs_unit(BudgetAttributesCostsUnit::new())
1627
.created_at(1738258683590)
1728
.created_by("00000000-0a0a-0a0a-aaa0-00000000000a".to_string())
1829
.end_month(202502)
1930
.entries(vec![BudgetWithEntriesDataAttributesEntriesItems::new()
31+
.costs(
32+
BudgetWithEntriesDataAttributesEntriesItemsCosts::new()
33+
.actual(None)
34+
.amount(None)
35+
.custom_forecast(None)
36+
.forecast(None)
37+
.ootb_forecast(None),
38+
)
2039
.tag_filters(vec![
2140
BudgetWithEntriesDataAttributesEntriesItemsTagFiltersItems::new(),
2241
])])

src/datadogV2/api/api_cloud_cost_management.rs

Lines changed: 64 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,43 @@ impl DeleteCostTagDescriptionByKeyOptionalParams {
2727
}
2828
}
2929

30+
/// GetBudgetOptionalParams is a struct for passing parameters to the method [`CloudCostManagementAPI::get_budget`]
31+
#[non_exhaustive]
32+
#[derive(Clone, Default, Debug)]
33+
pub struct GetBudgetOptionalParams {
34+
/// When `true`, includes actual cost data in the response.
35+
pub actual: Option<bool>,
36+
/// When `true`, includes forecast cost data in the response, including `ootb_forecast` and `custom_forecast` per entry.
37+
pub forecast: Option<bool>,
38+
/// Start of the cost window in milliseconds since epoch. Must be used together with `end`.
39+
pub start: Option<i64>,
40+
/// End of the cost window in milliseconds since epoch. Must be used together with `start`.
41+
pub end: Option<i64>,
42+
}
43+
44+
impl GetBudgetOptionalParams {
45+
/// When `true`, includes actual cost data in the response.
46+
pub fn actual(mut self, value: bool) -> Self {
47+
self.actual = Some(value);
48+
self
49+
}
50+
/// When `true`, includes forecast cost data in the response, including `ootb_forecast` and `custom_forecast` per entry.
51+
pub fn forecast(mut self, value: bool) -> Self {
52+
self.forecast = Some(value);
53+
self
54+
}
55+
/// Start of the cost window in milliseconds since epoch. Must be used together with `end`.
56+
pub fn start(mut self, value: i64) -> Self {
57+
self.start = Some(value);
58+
self
59+
}
60+
/// End of the cost window in milliseconds since epoch. Must be used together with `start`.
61+
pub fn end(mut self, value: i64) -> Self {
62+
self.end = Some(value);
63+
self
64+
}
65+
}
66+
3067
/// GetCommitmentsCommitmentListOptionalParams is a struct for passing parameters to the method [`CloudCostManagementAPI::get_commitments_commitment_list`]
3168
#[non_exhaustive]
3269
#[derive(Clone, Default, Debug)]
@@ -2946,12 +2983,13 @@ impl CloudCostManagementAPI {
29462983
}
29472984
}
29482985

2949-
/// Get a budget
2986+
/// Get a budget by ID. Pass `actual=true` or `forecast=true` to include cost data in the response. Use `start` and `end` (millisecond epochs, both required) to set the cost window. When `forecast=true`, each entry also includes `ootb_forecast` (the ML forecast before overrides) and `custom_forecast` (`null` if no override is set, a number if one is).
29502987
pub async fn get_budget(
29512988
&self,
29522989
budget_id: String,
2990+
params: GetBudgetOptionalParams,
29532991
) -> Result<crate::datadogV2::model::BudgetWithEntries, datadog::Error<GetBudgetError>> {
2954-
match self.get_budget_with_http_info(budget_id).await {
2992+
match self.get_budget_with_http_info(budget_id, params).await {
29552993
Ok(response_content) => {
29562994
if let Some(e) = response_content.entity {
29572995
Ok(e)
@@ -2965,17 +3003,24 @@ impl CloudCostManagementAPI {
29653003
}
29663004
}
29673005

2968-
/// Get a budget
3006+
/// Get a budget by ID. Pass `actual=true` or `forecast=true` to include cost data in the response. Use `start` and `end` (millisecond epochs, both required) to set the cost window. When `forecast=true`, each entry also includes `ootb_forecast` (the ML forecast before overrides) and `custom_forecast` (`null` if no override is set, a number if one is).
29693007
pub async fn get_budget_with_http_info(
29703008
&self,
29713009
budget_id: String,
3010+
params: GetBudgetOptionalParams,
29723011
) -> Result<
29733012
datadog::ResponseContent<crate::datadogV2::model::BudgetWithEntries>,
29743013
datadog::Error<GetBudgetError>,
29753014
> {
29763015
let local_configuration = &self.config;
29773016
let operation_id = "v2.get_budget";
29783017

3018+
// unbox and build optional parameters
3019+
let actual = params.actual;
3020+
let forecast = params.forecast;
3021+
let start = params.start;
3022+
let end = params.end;
3023+
29793024
let local_client = &self.client;
29803025

29813026
let local_uri_str = format!(
@@ -2986,6 +3031,22 @@ impl CloudCostManagementAPI {
29863031
let mut local_req_builder =
29873032
local_client.request(reqwest::Method::GET, local_uri_str.as_str());
29883033

3034+
if let Some(ref local_query_param) = actual {
3035+
local_req_builder =
3036+
local_req_builder.query(&[("actual", &local_query_param.to_string())]);
3037+
};
3038+
if let Some(ref local_query_param) = forecast {
3039+
local_req_builder =
3040+
local_req_builder.query(&[("forecast", &local_query_param.to_string())]);
3041+
};
3042+
if let Some(ref local_query_param) = start {
3043+
local_req_builder =
3044+
local_req_builder.query(&[("start", &local_query_param.to_string())]);
3045+
};
3046+
if let Some(ref local_query_param) = end {
3047+
local_req_builder = local_req_builder.query(&[("end", &local_query_param.to_string())]);
3048+
};
3049+
29893050
// build headers
29903051
let mut headers = HeaderMap::new();
29913052
headers.insert("Accept", HeaderValue::from_static("application/json"));

src/datadogV2/model/mod.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2794,8 +2794,14 @@ pub mod model_budget_with_entries_data;
27942794
pub use self::model_budget_with_entries_data::BudgetWithEntriesData;
27952795
pub mod model_budget_attributes;
27962796
pub use self::model_budget_attributes::BudgetAttributes;
2797+
pub mod model_budget_attributes_costs;
2798+
pub use self::model_budget_attributes_costs::BudgetAttributesCosts;
2799+
pub mod model_budget_attributes_costs_unit;
2800+
pub use self::model_budget_attributes_costs_unit::BudgetAttributesCostsUnit;
27972801
pub mod model_budget_with_entries_data_attributes_entries_items;
27982802
pub use self::model_budget_with_entries_data_attributes_entries_items::BudgetWithEntriesDataAttributesEntriesItems;
2803+
pub mod model_budget_with_entries_data_attributes_entries_items_costs;
2804+
pub use self::model_budget_with_entries_data_attributes_entries_items_costs::BudgetWithEntriesDataAttributesEntriesItemsCosts;
27992805
pub mod model_budget_with_entries_data_attributes_entries_items_tag_filters_items;
28002806
pub use self::model_budget_with_entries_data_attributes_entries_items_tag_filters_items::BudgetWithEntriesDataAttributesEntriesItemsTagFiltersItems;
28012807
pub mod model_validation_response;

0 commit comments

Comments
 (0)