Skip to content

Commit 588a11e

Browse files
author
ci.datadog-api-spec
committed
Regenerate client from commit a45a8aa9 of spec repo
1 parent 694e17d commit 588a11e

14 files changed

+1009
-4
lines changed

.apigentools-info

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,13 @@
44
"spec_versions": {
55
"v1": {
66
"apigentools_version": "1.6.6",
7-
"regenerated": "2024-09-10 15:40:02.487387",
8-
"spec_repo_commit": "80dc4248"
7+
"regenerated": "2024-09-10 17:48:14.301264",
8+
"spec_repo_commit": "a45a8aa9"
99
},
1010
"v2": {
1111
"apigentools_version": "1.6.6",
12-
"regenerated": "2024-09-10 15:40:02.506102",
13-
"spec_repo_commit": "80dc4248"
12+
"regenerated": "2024-09-10 17:48:14.319409",
13+
"spec_repo_commit": "a45a8aa9"
1414
}
1515
}
1616
}

.generator/schemas/v2/openapi.yaml

Lines changed: 129 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2117,6 +2117,73 @@ components:
21172117
- storage_account
21182118
- storage_container
21192119
type: object
2120+
BillingDimensionsMappingBody:
2121+
description: Billing dimensions mapping data.
2122+
items:
2123+
$ref: '#/components/schemas/BillingDimensionsMappingBodyItem'
2124+
type: array
2125+
BillingDimensionsMappingBodyItem:
2126+
description: The definition of `BillingDimensionsMappingBodyItem` object.
2127+
properties:
2128+
attributes:
2129+
$ref: '#/components/schemas/BillingDimensionsMappingBodyItemAttributes'
2130+
id:
2131+
description: ID of the billing dimension.
2132+
type: string
2133+
type:
2134+
$ref: '#/components/schemas/ActiveBillingDimensionsType'
2135+
type: object
2136+
BillingDimensionsMappingBodyItemAttributes:
2137+
description: Mapping of billing dimensions to endpoint keys.
2138+
properties:
2139+
endpoints:
2140+
description: List of supported endpoints with their keys mapped to the billing_dimension.
2141+
items:
2142+
$ref: '#/components/schemas/BillingDimensionsMappingBodyItemAttributesEndpointsItems'
2143+
type: array
2144+
in_app_label:
2145+
description: Label used for the billing dimension in the Plan & Usage charts.
2146+
example: APM Hosts
2147+
type: string
2148+
timestamp:
2149+
description: 'Month in ISO-8601 format, UTC, precise to second: `[YYYY-MM-DDThh:mm:ss]`.'
2150+
format: date-time
2151+
type: string
2152+
type: object
2153+
BillingDimensionsMappingBodyItemAttributesEndpointsItems:
2154+
description: An endpoint's keys mapped to the billing_dimension.
2155+
properties:
2156+
id:
2157+
description: The URL for the endpoint.
2158+
example: api/v1/usage/billable-summary
2159+
type: string
2160+
keys:
2161+
description: The billing dimension.
2162+
example:
2163+
- apm_host_top99p
2164+
- apm_host_sum
2165+
items:
2166+
example: apm_host_top99p
2167+
type: string
2168+
type: array
2169+
status:
2170+
$ref: '#/components/schemas/BillingDimensionsMappingBodyItemAttributesEndpointsItemsStatus'
2171+
type: object
2172+
BillingDimensionsMappingBodyItemAttributesEndpointsItemsStatus:
2173+
description: Denotes whether or not mapping keys were available for this endpoint.
2174+
enum:
2175+
- OK
2176+
- NOT_FOUND
2177+
type: string
2178+
x-enum-varnames:
2179+
- OK
2180+
- NOT_FOUND
2181+
BillingDimensionsMappingResponse:
2182+
description: Billing dimensions mapping response.
2183+
properties:
2184+
data:
2185+
$ref: '#/components/schemas/BillingDimensionsMappingBody'
2186+
type: object
21202187
BulkMuteFindingsRequest:
21212188
description: The new bulk mute finding request.
21222189
properties:
@@ -38362,6 +38429,68 @@ paths:
3836238429
summary: Get hourly usage for application security
3836338430
tags:
3836438431
- Usage Metering
38432+
/api/v2/usage/billing_dimension_mapping:
38433+
get:
38434+
description: 'Get a mapping of billing dimensions to the corresponding keys
38435+
for the supported usage metering public API endpoints.
38436+
38437+
38438+
This endpoint is only accessible for [parent-level organizations](https://docs.datadoghq.com/account_management/multi_organization/).'
38439+
operationId: GetBillingDimensionMapping
38440+
parameters:
38441+
- description: Datetime in ISO-8601 format, UTC, for mappings beginning this
38442+
month. Defaults to the current month.
38443+
in: query
38444+
name: filter[month]
38445+
required: false
38446+
schema:
38447+
format: date-time
38448+
type: string
38449+
- description: String to specify whether to retrieve active billing dimension
38450+
mappings or all available mappings. Available views are `active` and `all`.
38451+
Defaults to `active`.
38452+
in: query
38453+
name: filter[view]
38454+
required: false
38455+
schema:
38456+
default: active
38457+
type: string
38458+
responses:
38459+
'200':
38460+
content:
38461+
application/json;datetime-format=rfc3339:
38462+
schema:
38463+
$ref: '#/components/schemas/BillingDimensionsMappingResponse'
38464+
description: OK
38465+
'400':
38466+
content:
38467+
application/json;datetime-format=rfc3339:
38468+
schema:
38469+
$ref: '#/components/schemas/APIErrorResponse'
38470+
description: Bad Request
38471+
'403':
38472+
content:
38473+
application/json;datetime-format=rfc3339:
38474+
schema:
38475+
$ref: '#/components/schemas/APIErrorResponse'
38476+
description: Forbidden - User is not authorized
38477+
'429':
38478+
content:
38479+
application/json;datetime-format=rfc3339:
38480+
schema:
38481+
$ref: '#/components/schemas/APIErrorResponse'
38482+
description: Too many requests
38483+
security:
38484+
- apiKeyAuth: []
38485+
appKeyAuth: []
38486+
- AuthZ:
38487+
- usage_read
38488+
summary: Get billing dimensions mapping for usage endpoints
38489+
tags:
38490+
- Usage Metering
38491+
x-unstable: '**Note**: This endpoint is in public beta.
38492+
38493+
If you have any feedback, contact [Datadog support](https://docs.datadoghq.com/help/).'
3836538494
/api/v2/usage/cost_by_org:
3836638495
get:
3836738496
deprecated: true
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
// Get billing dimensions mapping for usage endpoints returns "OK" response
2+
use datadog_api_client::datadog;
3+
use datadog_api_client::datadogV2::api_usage_metering::GetBillingDimensionMappingOptionalParams;
4+
use datadog_api_client::datadogV2::api_usage_metering::UsageMeteringAPI;
5+
6+
#[tokio::main]
7+
async fn main() {
8+
let mut configuration = datadog::Configuration::new();
9+
configuration.set_unstable_operation_enabled("v2.GetBillingDimensionMapping", true);
10+
let api = UsageMeteringAPI::with_config(configuration);
11+
let resp = api
12+
.get_billing_dimension_mapping(GetBillingDimensionMappingOptionalParams::default())
13+
.await;
14+
if let Ok(value) = resp {
15+
println!("{:#?}", value);
16+
} else {
17+
println!("{:#?}", resp.unwrap_err());
18+
}
19+
}

src/datadog/configuration.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,7 @@ impl Default for Configuration {
135135
("v2.list_apis".to_owned(), false),
136136
("v2.update_open_api".to_owned(), false),
137137
("v2.get_active_billing_dimensions".to_owned(), false),
138+
("v2.get_billing_dimension_mapping".to_owned(), false),
138139
("v2.get_monthly_cost_attribution".to_owned(), false),
139140
("v2.create_dora_deployment".to_owned(), false),
140141
("v2.create_dora_incident".to_owned(), false),

src/datadogV2/api/api_usage_metering.rs

Lines changed: 172 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,29 @@ use log::warn;
66
use reqwest::header::{HeaderMap, HeaderValue};
77
use serde::{Deserialize, Serialize};
88

9+
/// GetBillingDimensionMappingOptionalParams is a struct for passing parameters to the method [`UsageMeteringAPI::get_billing_dimension_mapping`]
10+
#[non_exhaustive]
11+
#[derive(Clone, Default, Debug)]
12+
pub struct GetBillingDimensionMappingOptionalParams {
13+
/// Datetime in ISO-8601 format, UTC, for mappings beginning this month. Defaults to the current month.
14+
pub filter_month: Option<chrono::DateTime<chrono::Utc>>,
15+
/// String to specify whether to retrieve active billing dimension mappings or all available mappings. Available views are `active` and `all`. Defaults to `active`.
16+
pub filter_view: Option<String>,
17+
}
18+
19+
impl GetBillingDimensionMappingOptionalParams {
20+
/// Datetime in ISO-8601 format, UTC, for mappings beginning this month. Defaults to the current month.
21+
pub fn filter_month(mut self, value: chrono::DateTime<chrono::Utc>) -> Self {
22+
self.filter_month = Some(value);
23+
self
24+
}
25+
/// String to specify whether to retrieve active billing dimension mappings or all available mappings. Available views are `active` and `all`. Defaults to `active`.
26+
pub fn filter_view(mut self, value: String) -> Self {
27+
self.filter_view = Some(value);
28+
self
29+
}
30+
}
31+
932
/// GetCostByOrgOptionalParams is a struct for passing parameters to the method [`UsageMeteringAPI::get_cost_by_org`]
1033
#[non_exhaustive]
1134
#[derive(Clone, Default, Debug)]
@@ -296,6 +319,14 @@ pub enum GetActiveBillingDimensionsError {
296319
UnknownValue(serde_json::Value),
297320
}
298321

322+
/// GetBillingDimensionMappingError is a struct for typed errors of method [`UsageMeteringAPI::get_billing_dimension_mapping`]
323+
#[derive(Debug, Clone, Serialize, Deserialize)]
324+
#[serde(untagged)]
325+
pub enum GetBillingDimensionMappingError {
326+
APIErrorResponse(crate::datadogV2::model::APIErrorResponse),
327+
UnknownValue(serde_json::Value),
328+
}
329+
299330
/// GetCostByOrgError is a struct for typed errors of method [`UsageMeteringAPI::get_cost_by_org`]
300331
#[derive(Debug, Clone, Serialize, Deserialize)]
301332
#[serde(untagged)]
@@ -559,6 +590,147 @@ impl UsageMeteringAPI {
559590
}
560591
}
561592

593+
/// Get a mapping of billing dimensions to the corresponding keys for the supported usage metering public API endpoints.
594+
///
595+
/// This endpoint is only accessible for [parent-level organizations](<https://docs.datadoghq.com/account_management/multi_organization/>).
596+
pub async fn get_billing_dimension_mapping(
597+
&self,
598+
params: GetBillingDimensionMappingOptionalParams,
599+
) -> Result<
600+
crate::datadogV2::model::BillingDimensionsMappingResponse,
601+
datadog::Error<GetBillingDimensionMappingError>,
602+
> {
603+
match self
604+
.get_billing_dimension_mapping_with_http_info(params)
605+
.await
606+
{
607+
Ok(response_content) => {
608+
if let Some(e) = response_content.entity {
609+
Ok(e)
610+
} else {
611+
Err(datadog::Error::Serde(serde::de::Error::custom(
612+
"response content was None",
613+
)))
614+
}
615+
}
616+
Err(err) => Err(err),
617+
}
618+
}
619+
620+
/// Get a mapping of billing dimensions to the corresponding keys for the supported usage metering public API endpoints.
621+
///
622+
/// This endpoint is only accessible for [parent-level organizations](<https://docs.datadoghq.com/account_management/multi_organization/>).
623+
pub async fn get_billing_dimension_mapping_with_http_info(
624+
&self,
625+
params: GetBillingDimensionMappingOptionalParams,
626+
) -> Result<
627+
datadog::ResponseContent<crate::datadogV2::model::BillingDimensionsMappingResponse>,
628+
datadog::Error<GetBillingDimensionMappingError>,
629+
> {
630+
let local_configuration = &self.config;
631+
let operation_id = "v2.get_billing_dimension_mapping";
632+
if local_configuration.is_unstable_operation_enabled(operation_id) {
633+
warn!("Using unstable operation {operation_id}");
634+
} else {
635+
let local_error = datadog::UnstableOperationDisabledError {
636+
msg: "Operation 'v2.get_billing_dimension_mapping' is not enabled".to_string(),
637+
};
638+
return Err(datadog::Error::UnstableOperationDisabledError(local_error));
639+
}
640+
641+
// unbox and build optional parameters
642+
let filter_month = params.filter_month;
643+
let filter_view = params.filter_view;
644+
645+
let local_client = &self.client;
646+
647+
let local_uri_str = format!(
648+
"{}/api/v2/usage/billing_dimension_mapping",
649+
local_configuration.get_operation_host(operation_id)
650+
);
651+
let mut local_req_builder =
652+
local_client.request(reqwest::Method::GET, local_uri_str.as_str());
653+
654+
if let Some(ref local_query_param) = filter_month {
655+
local_req_builder = local_req_builder.query(&[(
656+
"filter[month]",
657+
&local_query_param.to_rfc3339_opts(chrono::SecondsFormat::Millis, true),
658+
)]);
659+
};
660+
if let Some(ref local_query_param) = filter_view {
661+
local_req_builder =
662+
local_req_builder.query(&[("filter[view]", &local_query_param.to_string())]);
663+
};
664+
665+
// build headers
666+
let mut headers = HeaderMap::new();
667+
headers.insert(
668+
"Accept",
669+
HeaderValue::from_static("application/json;datetime-format=rfc3339"),
670+
);
671+
672+
// build user agent
673+
match HeaderValue::from_str(local_configuration.user_agent.as_str()) {
674+
Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent),
675+
Err(e) => {
676+
log::warn!("Failed to parse user agent header: {e}, falling back to default");
677+
headers.insert(
678+
reqwest::header::USER_AGENT,
679+
HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()),
680+
)
681+
}
682+
};
683+
684+
// build auth
685+
if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") {
686+
headers.insert(
687+
"DD-API-KEY",
688+
HeaderValue::from_str(local_key.key.as_str())
689+
.expect("failed to parse DD-API-KEY header"),
690+
);
691+
};
692+
if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") {
693+
headers.insert(
694+
"DD-APPLICATION-KEY",
695+
HeaderValue::from_str(local_key.key.as_str())
696+
.expect("failed to parse DD-APPLICATION-KEY header"),
697+
);
698+
};
699+
700+
local_req_builder = local_req_builder.headers(headers);
701+
let local_req = local_req_builder.build()?;
702+
log::debug!("request content: {:?}", local_req.body());
703+
let local_resp = local_client.execute(local_req).await?;
704+
705+
let local_status = local_resp.status();
706+
let local_content = local_resp.text().await?;
707+
log::debug!("response content: {}", local_content);
708+
709+
if !local_status.is_client_error() && !local_status.is_server_error() {
710+
match serde_json::from_str::<crate::datadogV2::model::BillingDimensionsMappingResponse>(
711+
&local_content,
712+
) {
713+
Ok(e) => {
714+
return Ok(datadog::ResponseContent {
715+
status: local_status,
716+
content: local_content,
717+
entity: Some(e),
718+
})
719+
}
720+
Err(e) => return Err(datadog::Error::Serde(e)),
721+
};
722+
} else {
723+
let local_entity: Option<GetBillingDimensionMappingError> =
724+
serde_json::from_str(&local_content).ok();
725+
let local_error = datadog::ResponseContent {
726+
status: local_status,
727+
content: local_content,
728+
entity: local_entity,
729+
};
730+
Err(datadog::Error::ResponseError(local_error))
731+
}
732+
}
733+
562734
/// Get cost across multi-org account.
563735
/// Cost by org data for a given month becomes available no later than the 16th of the following month.
564736
/// **Note:** This endpoint has been deprecated. Please use the new endpoint

src/datadogV2/model/mod.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3102,6 +3102,16 @@ pub mod model_hourly_usage_type;
31023102
pub use self::model_hourly_usage_type::HourlyUsageType;
31033103
pub mod model_usage_time_series_type;
31043104
pub use self::model_usage_time_series_type::UsageTimeSeriesType;
3105+
pub mod model_billing_dimensions_mapping_response;
3106+
pub use self::model_billing_dimensions_mapping_response::BillingDimensionsMappingResponse;
3107+
pub mod model_billing_dimensions_mapping_body_item;
3108+
pub use self::model_billing_dimensions_mapping_body_item::BillingDimensionsMappingBodyItem;
3109+
pub mod model_billing_dimensions_mapping_body_item_attributes;
3110+
pub use self::model_billing_dimensions_mapping_body_item_attributes::BillingDimensionsMappingBodyItemAttributes;
3111+
pub mod model_billing_dimensions_mapping_body_item_attributes_endpoints_items;
3112+
pub use self::model_billing_dimensions_mapping_body_item_attributes_endpoints_items::BillingDimensionsMappingBodyItemAttributesEndpointsItems;
3113+
pub mod model_billing_dimensions_mapping_body_item_attributes_endpoints_items_status;
3114+
pub use self::model_billing_dimensions_mapping_body_item_attributes_endpoints_items_status::BillingDimensionsMappingBodyItemAttributesEndpointsItemsStatus;
31053115
pub mod model_cost_by_org_response;
31063116
pub use self::model_cost_by_org_response::CostByOrgResponse;
31073117
pub mod model_cost_by_org;

0 commit comments

Comments
 (0)