Skip to content

Commit a2bed6c

Browse files
author
ci.datadog-api-spec
committed
Regenerate client from commit df23174c of spec repo
1 parent 8f158d1 commit a2bed6c

16 files changed

+1048
-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-10-28 23:07:48.999899",
8-
"spec_repo_commit": "4251a422"
7+
"regenerated": "2024-10-29 15:48:05.729945",
8+
"spec_repo_commit": "df23174c"
99
},
1010
"v2": {
1111
"apigentools_version": "1.6.6",
12-
"regenerated": "2024-10-28 23:07:49.018496",
13-
"spec_repo_commit": "4251a422"
12+
"regenerated": "2024-10-29 15:48:05.750192",
13+
"spec_repo_commit": "df23174c"
1414
}
1515
}
1616
}

.generator/schemas/v2/openapi.yaml

Lines changed: 132 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2179,6 +2179,74 @@ components:
21792179
- storage_account
21802180
- storage_container
21812181
type: object
2182+
BillingDimensionsMappingBody:
2183+
description: Billing dimensions mapping data.
2184+
items:
2185+
$ref: '#/components/schemas/BillingDimensionsMappingBodyItem'
2186+
type: array
2187+
BillingDimensionsMappingBodyItem:
2188+
description: The mapping data for each billing dimension.
2189+
properties:
2190+
attributes:
2191+
$ref: '#/components/schemas/BillingDimensionsMappingBodyItemAttributes'
2192+
id:
2193+
description: ID of the billing dimension.
2194+
type: string
2195+
type:
2196+
$ref: '#/components/schemas/ActiveBillingDimensionsType'
2197+
type: object
2198+
BillingDimensionsMappingBodyItemAttributes:
2199+
description: Mapping of billing dimensions to endpoint keys.
2200+
properties:
2201+
endpoints:
2202+
description: List of supported endpoints with their keys mapped to the billing_dimension.
2203+
items:
2204+
$ref: '#/components/schemas/BillingDimensionsMappingBodyItemAttributesEndpointsItems'
2205+
type: array
2206+
in_app_label:
2207+
description: Label used for the billing dimension in the Plan & Usage charts.
2208+
example: APM Hosts
2209+
type: string
2210+
timestamp:
2211+
description: 'Month in ISO-8601 format, UTC, and precise to the second:
2212+
`[YYYY-MM-DDThh:mm:ss]`.'
2213+
format: date-time
2214+
type: string
2215+
type: object
2216+
BillingDimensionsMappingBodyItemAttributesEndpointsItems:
2217+
description: An endpoint's keys mapped to the billing_dimension.
2218+
properties:
2219+
id:
2220+
description: The URL for the endpoint.
2221+
example: api/v1/usage/billable-summary
2222+
type: string
2223+
keys:
2224+
description: The billing dimension.
2225+
example:
2226+
- apm_host_top99p
2227+
- apm_host_sum
2228+
items:
2229+
example: apm_host_top99p
2230+
type: string
2231+
type: array
2232+
status:
2233+
$ref: '#/components/schemas/BillingDimensionsMappingBodyItemAttributesEndpointsItemsStatus'
2234+
type: object
2235+
BillingDimensionsMappingBodyItemAttributesEndpointsItemsStatus:
2236+
description: Denotes whether mapping keys were available for this endpoint.
2237+
enum:
2238+
- OK
2239+
- NOT_FOUND
2240+
type: string
2241+
x-enum-varnames:
2242+
- OK
2243+
- NOT_FOUND
2244+
BillingDimensionsMappingResponse:
2245+
description: Billing dimensions mapping response.
2246+
properties:
2247+
data:
2248+
$ref: '#/components/schemas/BillingDimensionsMappingBody'
2249+
type: object
21822250
BulkMuteFindingsRequest:
21832251
description: The new bulk mute finding request.
21842252
properties:
@@ -40478,6 +40546,70 @@ paths:
4047840546
operator: OR
4047940547
permissions:
4048040548
- usage_read
40549+
/api/v2/usage/billing_dimension_mapping:
40550+
get:
40551+
description: 'Get a mapping of billing dimensions to the corresponding keys
40552+
for the supported usage metering public API endpoints.
40553+
40554+
Mapping data is updated on a monthly cadence.
40555+
40556+
40557+
This endpoint is only accessible to [parent-level organizations](https://docs.datadoghq.com/account_management/multi_organization/).'
40558+
operationId: GetBillingDimensionMapping
40559+
parameters:
40560+
- description: Datetime in ISO-8601 format, UTC, and for mappings beginning
40561+
this month. Defaults to the current month.
40562+
in: query
40563+
name: filter[month]
40564+
required: false
40565+
schema:
40566+
format: date-time
40567+
type: string
40568+
- description: String to specify whether to retrieve active billing dimension
40569+
mappings for the contract or for all available mappings. Allowed views have
40570+
the string `active` or `all`. Defaults to `active`.
40571+
in: query
40572+
name: filter[view]
40573+
required: false
40574+
schema:
40575+
default: active
40576+
type: string
40577+
responses:
40578+
'200':
40579+
content:
40580+
application/json;datetime-format=rfc3339:
40581+
schema:
40582+
$ref: '#/components/schemas/BillingDimensionsMappingResponse'
40583+
description: OK
40584+
'400':
40585+
content:
40586+
application/json;datetime-format=rfc3339:
40587+
schema:
40588+
$ref: '#/components/schemas/APIErrorResponse'
40589+
description: Bad Request
40590+
'403':
40591+
content:
40592+
application/json;datetime-format=rfc3339:
40593+
schema:
40594+
$ref: '#/components/schemas/APIErrorResponse'
40595+
description: Forbidden - User is not authorized
40596+
'429':
40597+
content:
40598+
application/json;datetime-format=rfc3339:
40599+
schema:
40600+
$ref: '#/components/schemas/APIErrorResponse'
40601+
description: Too many requests
40602+
security:
40603+
- apiKeyAuth: []
40604+
appKeyAuth: []
40605+
- AuthZ:
40606+
- usage_read
40607+
summary: Get billing dimension mapping for usage endpoints
40608+
tags:
40609+
- Usage Metering
40610+
x-unstable: '**Note**: This endpoint is in Preview.
40611+
40612+
If you have any feedback, contact [Datadog support](https://docs.datadoghq.com/help/).'
4048140613
/api/v2/usage/cost_by_org:
4048240614
get:
4048340615
deprecated: true
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
// Get billing dimension 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: 174 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, and 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 for the contract or for all available mappings. Allowed views have the string `active` or `all`. Defaults to `active`.
16+
pub filter_view: Option<String>,
17+
}
18+
19+
impl GetBillingDimensionMappingOptionalParams {
20+
/// Datetime in ISO-8601 format, UTC, and 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 for the contract or for all available mappings. Allowed views have the string `active` or `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)]
@@ -303,6 +326,14 @@ pub enum GetActiveBillingDimensionsError {
303326
UnknownValue(serde_json::Value),
304327
}
305328

329+
/// GetBillingDimensionMappingError is a struct for typed errors of method [`UsageMeteringAPI::get_billing_dimension_mapping`]
330+
#[derive(Debug, Clone, Serialize, Deserialize)]
331+
#[serde(untagged)]
332+
pub enum GetBillingDimensionMappingError {
333+
APIErrorResponse(crate::datadogV2::model::APIErrorResponse),
334+
UnknownValue(serde_json::Value),
335+
}
336+
306337
/// GetCostByOrgError is a struct for typed errors of method [`UsageMeteringAPI::get_cost_by_org`]
307338
#[derive(Debug, Clone, Serialize, Deserialize)]
308339
#[serde(untagged)]
@@ -566,6 +597,149 @@ impl UsageMeteringAPI {
566597
}
567598
}
568599

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

0 commit comments

Comments
 (0)