Skip to content

Commit 8346e99

Browse files
author
ci.datadog-api-spec
committed
Regenerate client from commit c4c9bbbf of spec repo
1 parent 49969ba commit 8346e99

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-18 14:45:11.870692",
8-
"spec_repo_commit": "bae57ce1"
7+
"regenerated": "2024-09-18 15:50:07.441369",
8+
"spec_repo_commit": "c4c9bbbf"
99
},
1010
"v2": {
1111
"apigentools_version": "1.6.6",
12-
"regenerated": "2024-09-18 14:45:11.890523",
13-
"spec_repo_commit": "bae57ce1"
12+
"regenerated": "2024-09-18 15:50:07.455602",
13+
"spec_repo_commit": "c4c9bbbf"
1414
}
1515
}
1616
}

.generator/schemas/v2/openapi.yaml

Lines changed: 129 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2175,6 +2175,73 @@ components:
21752175
- storage_account
21762176
- storage_container
21772177
type: object
2178+
BillingDimensionsMappingBody:
2179+
description: Billing dimensions mapping data.
2180+
items:
2181+
$ref: '#/components/schemas/BillingDimensionsMappingBodyItem'
2182+
type: array
2183+
BillingDimensionsMappingBodyItem:
2184+
description: The definition of `BillingDimensionsMappingBodyItem` object.
2185+
properties:
2186+
attributes:
2187+
$ref: '#/components/schemas/BillingDimensionsMappingBodyItemAttributes'
2188+
id:
2189+
description: ID of the billing dimension.
2190+
type: string
2191+
type:
2192+
$ref: '#/components/schemas/ActiveBillingDimensionsType'
2193+
type: object
2194+
BillingDimensionsMappingBodyItemAttributes:
2195+
description: Mapping of billing dimensions to endpoint keys.
2196+
properties:
2197+
endpoints:
2198+
description: List of supported endpoints with their keys mapped to the billing_dimension.
2199+
items:
2200+
$ref: '#/components/schemas/BillingDimensionsMappingBodyItemAttributesEndpointsItems'
2201+
type: array
2202+
in_app_label:
2203+
description: Label used for the billing dimension in the Plan & Usage charts.
2204+
example: APM Hosts
2205+
type: string
2206+
timestamp:
2207+
description: 'Month in ISO-8601 format, UTC, precise to second: `[YYYY-MM-DDThh:mm:ss]`.'
2208+
format: date-time
2209+
type: string
2210+
type: object
2211+
BillingDimensionsMappingBodyItemAttributesEndpointsItems:
2212+
description: An endpoint's keys mapped to the billing_dimension.
2213+
properties:
2214+
id:
2215+
description: The URL for the endpoint.
2216+
example: api/v1/usage/billable-summary
2217+
type: string
2218+
keys:
2219+
description: The billing dimension.
2220+
example:
2221+
- apm_host_top99p
2222+
- apm_host_sum
2223+
items:
2224+
example: apm_host_top99p
2225+
type: string
2226+
type: array
2227+
status:
2228+
$ref: '#/components/schemas/BillingDimensionsMappingBodyItemAttributesEndpointsItemsStatus'
2229+
type: object
2230+
BillingDimensionsMappingBodyItemAttributesEndpointsItemsStatus:
2231+
description: Denotes whether or not mapping keys were available for this endpoint.
2232+
enum:
2233+
- OK
2234+
- NOT_FOUND
2235+
type: string
2236+
x-enum-varnames:
2237+
- OK
2238+
- NOT_FOUND
2239+
BillingDimensionsMappingResponse:
2240+
description: Billing dimensions mapping response.
2241+
properties:
2242+
data:
2243+
$ref: '#/components/schemas/BillingDimensionsMappingBody'
2244+
type: object
21782245
BulkMuteFindingsRequest:
21792246
description: The new bulk mute finding request.
21802247
properties:
@@ -38471,6 +38538,68 @@ paths:
3847138538
summary: Get hourly usage for application security
3847238539
tags:
3847338540
- Usage Metering
38541+
/api/v2/usage/billing_dimension_mapping:
38542+
get:
38543+
description: 'Get a mapping of billing dimensions to the corresponding keys
38544+
for the supported usage metering public API endpoints.
38545+
38546+
38547+
This endpoint is only accessible for [parent-level organizations](https://docs.datadoghq.com/account_management/multi_organization/).'
38548+
operationId: GetBillingDimensionMapping
38549+
parameters:
38550+
- description: Datetime in ISO-8601 format, UTC, for mappings beginning this
38551+
month. Defaults to the current month.
38552+
in: query
38553+
name: filter[month]
38554+
required: false
38555+
schema:
38556+
format: date-time
38557+
type: string
38558+
- description: String to specify whether to retrieve active billing dimension
38559+
mappings for the contract or all available mappings. Allowed views are `active`
38560+
and `all`. Defaults to `active`.
38561+
in: query
38562+
name: filter[view]
38563+
required: false
38564+
schema:
38565+
default: active
38566+
type: string
38567+
responses:
38568+
'200':
38569+
content:
38570+
application/json;datetime-format=rfc3339:
38571+
schema:
38572+
$ref: '#/components/schemas/BillingDimensionsMappingResponse'
38573+
description: OK
38574+
'400':
38575+
content:
38576+
application/json;datetime-format=rfc3339:
38577+
schema:
38578+
$ref: '#/components/schemas/APIErrorResponse'
38579+
description: Bad Request
38580+
'403':
38581+
content:
38582+
application/json;datetime-format=rfc3339:
38583+
schema:
38584+
$ref: '#/components/schemas/APIErrorResponse'
38585+
description: Forbidden - User is not authorized
38586+
'429':
38587+
content:
38588+
application/json;datetime-format=rfc3339:
38589+
schema:
38590+
$ref: '#/components/schemas/APIErrorResponse'
38591+
description: Too many requests
38592+
security:
38593+
- apiKeyAuth: []
38594+
appKeyAuth: []
38595+
- AuthZ:
38596+
- usage_read
38597+
summary: Get billing dimension mapping for usage endpoints
38598+
tags:
38599+
- Usage Metering
38600+
x-unstable: '**Note**: This endpoint is in public beta.
38601+
38602+
If you have any feedback, contact [Datadog support](https://docs.datadoghq.com/help/).'
3847438603
/api/v2/usage/cost_by_org:
3847538604
get:
3847638605
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: 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 for the contract or all available mappings. Allowed 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 for the contract or all available mappings. Allowed 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
@@ -3112,6 +3112,16 @@ pub mod model_hourly_usage_type;
31123112
pub use self::model_hourly_usage_type::HourlyUsageType;
31133113
pub mod model_usage_time_series_type;
31143114
pub use self::model_usage_time_series_type::UsageTimeSeriesType;
3115+
pub mod model_billing_dimensions_mapping_response;
3116+
pub use self::model_billing_dimensions_mapping_response::BillingDimensionsMappingResponse;
3117+
pub mod model_billing_dimensions_mapping_body_item;
3118+
pub use self::model_billing_dimensions_mapping_body_item::BillingDimensionsMappingBodyItem;
3119+
pub mod model_billing_dimensions_mapping_body_item_attributes;
3120+
pub use self::model_billing_dimensions_mapping_body_item_attributes::BillingDimensionsMappingBodyItemAttributes;
3121+
pub mod model_billing_dimensions_mapping_body_item_attributes_endpoints_items;
3122+
pub use self::model_billing_dimensions_mapping_body_item_attributes_endpoints_items::BillingDimensionsMappingBodyItemAttributesEndpointsItems;
3123+
pub mod model_billing_dimensions_mapping_body_item_attributes_endpoints_items_status;
3124+
pub use self::model_billing_dimensions_mapping_body_item_attributes_endpoints_items_status::BillingDimensionsMappingBodyItemAttributesEndpointsItemsStatus;
31153125
pub mod model_cost_by_org_response;
31163126
pub use self::model_cost_by_org_response::CostByOrgResponse;
31173127
pub mod model_cost_by_org;

0 commit comments

Comments
 (0)