Skip to content

Commit df98c3d

Browse files
api-clients-generation-pipeline[bot]ci.datadog-api-spec
andauthored
Uncomment edit dataset block, add dataset limitations into endpoint descriptions (#807)
Co-authored-by: ci.datadog-api-spec <[email protected]>
1 parent 332cce0 commit df98c3d

13 files changed

+459
-8
lines changed

.generated-info

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
{
2-
"spec_repo_commit": "d51e9a8",
3-
"generated": "2025-07-25 13:28:36.413"
2+
"spec_repo_commit": "e4f653f",
3+
"generated": "2025-07-25 14:12:09.627"
44
}

.generator/schemas/v2/openapi.yaml

Lines changed: 56 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12478,7 +12478,14 @@ components:
1247812478
- type
1247912479
type: object
1248012480
Dataset:
12481-
description: Dataset object.
12481+
description: "Dataset object.\n\n### Datasets Constraints\n- **Tag Limit per
12482+
Dataset**:\n - Each restricted dataset supports a maximum of 10 key:value
12483+
pairs per product.\n\n- **Tag Key Rules per Telemetry Type**:\n - Only one
12484+
tag key or attribute may be used to define access within a single telemetry
12485+
type.\n - The same or different tag key may be used across different telemetry
12486+
types.\n\n- **Tag Value Uniqueness**:\n - Tag values must be unique within
12487+
a single dataset.\n - A tag value used in one dataset cannot be reused in
12488+
another dataset of the same telemetry type."
1248212489
properties:
1248312490
attributes:
1248412491
$ref: '#/components/schemas/DatasetAttributes'
@@ -12556,6 +12563,14 @@ components:
1255612563
required:
1255712564
- data
1255812565
type: object
12566+
DatasetUpdateRequest:
12567+
description: Edit request for a dataset.
12568+
properties:
12569+
data:
12570+
$ref: '#/components/schemas/Dataset'
12571+
required:
12572+
- data
12573+
type: object
1255912574
Date:
1256012575
description: Date as Unix timestamp in milliseconds.
1256112576
example: 1722439510282
@@ -16083,10 +16098,9 @@ components:
1608316098
type: array
1608416099
product:
1608516100
description: 'Name of the product the dataset is for. Possible values are
16086-
''apm'', ''rum'', ''synthetics'',
16101+
''apm'', ''rum'',
1608716102

16088-
''metrics'', ''logs'', ''sd_repoinfo'', ''error_tracking'', ''cloud_cost'',
16089-
and ''ml_obs''.'
16103+
''metrics'', ''logs'', ''error_tracking'', and ''cloud_cost''.'
1609016104
example: logs
1609116105
type: string
1609216106
required:
@@ -48282,6 +48296,44 @@ paths:
4828248296
x-permission:
4828348297
operator: OPEN
4828448298
permissions: []
48299+
put:
48300+
description: Edits the dataset associated with the ID.
48301+
operationId: UpdateDataset
48302+
parameters:
48303+
- $ref: '#/components/parameters/DatasetID'
48304+
requestBody:
48305+
content:
48306+
application/json:
48307+
schema:
48308+
$ref: '#/components/schemas/DatasetUpdateRequest'
48309+
description: Dataset payload
48310+
required: true
48311+
responses:
48312+
'200':
48313+
content:
48314+
application/json:
48315+
schema:
48316+
$ref: '#/components/schemas/DatasetResponseSingle'
48317+
description: OK
48318+
'400':
48319+
$ref: '#/components/responses/BadRequestResponse'
48320+
'403':
48321+
$ref: '#/components/responses/NotAuthorizedResponse'
48322+
'404':
48323+
$ref: '#/components/responses/NotFoundResponse'
48324+
'429':
48325+
$ref: '#/components/responses/TooManyRequestsResponse'
48326+
security:
48327+
- apiKeyAuth: []
48328+
appKeyAuth: []
48329+
- AuthZ: []
48330+
summary: Edit a dataset
48331+
tags:
48332+
- Datasets
48333+
x-codegen-request-body-name: body
48334+
x-permission:
48335+
operator: OPEN
48336+
permissions: []
4828548337
/api/v2/deletion/data/{product}:
4828648338
post:
4828748339
description: Creates a data deletion request by providing a query and a timeframe

examples/v2_datasets_UpdateDataset.rs

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
// Edit a dataset returns "OK" response
2+
use datadog_api_client::datadog;
3+
use datadog_api_client::datadogV2::api_datasets::DatasetsAPI;
4+
use datadog_api_client::datadogV2::model::Dataset;
5+
use datadog_api_client::datadogV2::model::DatasetAttributes;
6+
use datadog_api_client::datadogV2::model::DatasetUpdateRequest;
7+
use datadog_api_client::datadogV2::model::FiltersPerProduct;
8+
9+
#[tokio::main]
10+
async fn main() {
11+
let body = DatasetUpdateRequest::new(
12+
Dataset::new(
13+
DatasetAttributes::new(
14+
"Security Audit Dataset".to_string(),
15+
vec!["role:86245fce-0a4e-11f0-92bd-da7ad0900002".to_string()],
16+
vec![FiltersPerProduct::new(
17+
vec!["@application.id:ABCD".to_string()],
18+
"logs".to_string(),
19+
)],
20+
)
21+
.created_at(None),
22+
"dataset".to_string(),
23+
)
24+
.id("123e4567-e89b-12d3-a456-426614174000".to_string()),
25+
);
26+
let configuration = datadog::Configuration::new();
27+
let api = DatasetsAPI::with_config(configuration);
28+
let resp = api.update_dataset("dataset_id".to_string(), body).await;
29+
if let Ok(value) = resp {
30+
println!("{:#?}", value);
31+
} else {
32+
println!("{:#?}", resp.unwrap_err());
33+
}
34+
}

src/datadogV2/api/api_datasets.rs

Lines changed: 163 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,14 @@ pub enum GetDatasetError {
4242
UnknownValue(serde_json::Value),
4343
}
4444

45+
/// UpdateDatasetError is a struct for typed errors of method [`DatasetsAPI::update_dataset`]
46+
#[derive(Debug, Clone, Serialize, Deserialize)]
47+
#[serde(untagged)]
48+
pub enum UpdateDatasetError {
49+
APIErrorResponse(crate::datadogV2::model::APIErrorResponse),
50+
UnknownValue(serde_json::Value),
51+
}
52+
4553
/// Data Access Controls in Datadog is a feature that allows administrators and access managers to regulate
4654
/// access to sensitive data. By defining Restricted Datasets, you can ensure that only specific teams or roles can
4755
/// view certain types of telemetry (for example, logs, traces, metrics, and RUM data).
@@ -558,4 +566,159 @@ impl DatasetsAPI {
558566
Err(datadog::Error::ResponseError(local_error))
559567
}
560568
}
569+
570+
/// Edits the dataset associated with the ID.
571+
pub async fn update_dataset(
572+
&self,
573+
dataset_id: String,
574+
body: crate::datadogV2::model::DatasetUpdateRequest,
575+
) -> Result<crate::datadogV2::model::DatasetResponseSingle, datadog::Error<UpdateDatasetError>>
576+
{
577+
match self.update_dataset_with_http_info(dataset_id, body).await {
578+
Ok(response_content) => {
579+
if let Some(e) = response_content.entity {
580+
Ok(e)
581+
} else {
582+
Err(datadog::Error::Serde(serde::de::Error::custom(
583+
"response content was None",
584+
)))
585+
}
586+
}
587+
Err(err) => Err(err),
588+
}
589+
}
590+
591+
/// Edits the dataset associated with the ID.
592+
pub async fn update_dataset_with_http_info(
593+
&self,
594+
dataset_id: String,
595+
body: crate::datadogV2::model::DatasetUpdateRequest,
596+
) -> Result<
597+
datadog::ResponseContent<crate::datadogV2::model::DatasetResponseSingle>,
598+
datadog::Error<UpdateDatasetError>,
599+
> {
600+
let local_configuration = &self.config;
601+
let operation_id = "v2.update_dataset";
602+
603+
let local_client = &self.client;
604+
605+
let local_uri_str = format!(
606+
"{}/api/v2/datasets/{dataset_id}",
607+
local_configuration.get_operation_host(operation_id),
608+
dataset_id = datadog::urlencode(dataset_id)
609+
);
610+
let mut local_req_builder =
611+
local_client.request(reqwest::Method::PUT, local_uri_str.as_str());
612+
613+
// build headers
614+
let mut headers = HeaderMap::new();
615+
headers.insert("Content-Type", HeaderValue::from_static("application/json"));
616+
headers.insert("Accept", HeaderValue::from_static("application/json"));
617+
618+
// build user agent
619+
match HeaderValue::from_str(local_configuration.user_agent.as_str()) {
620+
Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent),
621+
Err(e) => {
622+
log::warn!("Failed to parse user agent header: {e}, falling back to default");
623+
headers.insert(
624+
reqwest::header::USER_AGENT,
625+
HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()),
626+
)
627+
}
628+
};
629+
630+
// build auth
631+
if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") {
632+
headers.insert(
633+
"DD-API-KEY",
634+
HeaderValue::from_str(local_key.key.as_str())
635+
.expect("failed to parse DD-API-KEY header"),
636+
);
637+
};
638+
if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") {
639+
headers.insert(
640+
"DD-APPLICATION-KEY",
641+
HeaderValue::from_str(local_key.key.as_str())
642+
.expect("failed to parse DD-APPLICATION-KEY header"),
643+
);
644+
};
645+
646+
// build body parameters
647+
let output = Vec::new();
648+
let mut ser = serde_json::Serializer::with_formatter(output, datadog::DDFormatter);
649+
if body.serialize(&mut ser).is_ok() {
650+
if let Some(content_encoding) = headers.get("Content-Encoding") {
651+
match content_encoding.to_str().unwrap_or_default() {
652+
"gzip" => {
653+
let mut enc = GzEncoder::new(Vec::new(), Compression::default());
654+
let _ = enc.write_all(ser.into_inner().as_slice());
655+
match enc.finish() {
656+
Ok(buf) => {
657+
local_req_builder = local_req_builder.body(buf);
658+
}
659+
Err(e) => return Err(datadog::Error::Io(e)),
660+
}
661+
}
662+
"deflate" => {
663+
let mut enc = ZlibEncoder::new(Vec::new(), Compression::default());
664+
let _ = enc.write_all(ser.into_inner().as_slice());
665+
match enc.finish() {
666+
Ok(buf) => {
667+
local_req_builder = local_req_builder.body(buf);
668+
}
669+
Err(e) => return Err(datadog::Error::Io(e)),
670+
}
671+
}
672+
"zstd1" => {
673+
let mut enc = zstd::stream::Encoder::new(Vec::new(), 0).unwrap();
674+
let _ = enc.write_all(ser.into_inner().as_slice());
675+
match enc.finish() {
676+
Ok(buf) => {
677+
local_req_builder = local_req_builder.body(buf);
678+
}
679+
Err(e) => return Err(datadog::Error::Io(e)),
680+
}
681+
}
682+
_ => {
683+
local_req_builder = local_req_builder.body(ser.into_inner());
684+
}
685+
}
686+
} else {
687+
local_req_builder = local_req_builder.body(ser.into_inner());
688+
}
689+
}
690+
691+
local_req_builder = local_req_builder.headers(headers);
692+
let local_req = local_req_builder.build()?;
693+
log::debug!("request content: {:?}", local_req.body());
694+
let local_resp = local_client.execute(local_req).await?;
695+
696+
let local_status = local_resp.status();
697+
let local_content = local_resp.text().await?;
698+
log::debug!("response content: {}", local_content);
699+
700+
if !local_status.is_client_error() && !local_status.is_server_error() {
701+
match serde_json::from_str::<crate::datadogV2::model::DatasetResponseSingle>(
702+
&local_content,
703+
) {
704+
Ok(e) => {
705+
return Ok(datadog::ResponseContent {
706+
status: local_status,
707+
content: local_content,
708+
entity: Some(e),
709+
})
710+
}
711+
Err(e) => return Err(datadog::Error::Serde(e)),
712+
};
713+
} else {
714+
let local_entity: Option<UpdateDatasetError> =
715+
serde_json::from_str(&local_content).ok();
716+
let local_error = datadog::ResponseContent {
717+
status: local_status,
718+
content: local_content,
719+
entity: local_entity,
720+
};
721+
Err(datadog::Error::ResponseError(local_error))
722+
}
723+
}
561724
}

src/datadogV2/model/mod.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1380,6 +1380,8 @@ pub mod model_dataset_create_request;
13801380
pub use self::model_dataset_create_request::DatasetCreateRequest;
13811381
pub mod model_dataset_response_single;
13821382
pub use self::model_dataset_response_single::DatasetResponseSingle;
1383+
pub mod model_dataset_update_request;
1384+
pub use self::model_dataset_update_request::DatasetUpdateRequest;
13831385
pub mod model_create_data_deletion_request_body;
13841386
pub use self::model_create_data_deletion_request_body::CreateDataDeletionRequestBody;
13851387
pub mod model_create_data_deletion_request_body_data;

src/datadogV2/model/model_dataset.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,18 @@ use serde_with::skip_serializing_none;
77
use std::fmt::{self, Formatter};
88

99
/// Dataset object.
10+
///
11+
/// ### Datasets Constraints
12+
/// - **Tag Limit per Dataset**:
13+
/// - Each restricted dataset supports a maximum of 10 key:value pairs per product.
14+
///
15+
/// - **Tag Key Rules per Telemetry Type**:
16+
/// - Only one tag key or attribute may be used to define access within a single telemetry type.
17+
/// - The same or different tag key may be used across different telemetry types.
18+
///
19+
/// - **Tag Value Uniqueness**:
20+
/// - Tag values must be unique within a single dataset.
21+
/// - A tag value used in one dataset cannot be reused in another dataset of the same telemetry type.
1022
#[non_exhaustive]
1123
#[skip_serializing_none]
1224
#[derive(Clone, Debug, PartialEq, Serialize)]

src/datadogV2/model/model_dataset_create_request.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,18 @@ use std::fmt::{self, Formatter};
1212
#[derive(Clone, Debug, PartialEq, Serialize)]
1313
pub struct DatasetCreateRequest {
1414
/// Dataset object.
15+
///
16+
/// ### Datasets Constraints
17+
/// - **Tag Limit per Dataset**:
18+
/// - Each restricted dataset supports a maximum of 10 key:value pairs per product.
19+
///
20+
/// - **Tag Key Rules per Telemetry Type**:
21+
/// - Only one tag key or attribute may be used to define access within a single telemetry type.
22+
/// - The same or different tag key may be used across different telemetry types.
23+
///
24+
/// - **Tag Value Uniqueness**:
25+
/// - Tag values must be unique within a single dataset.
26+
/// - A tag value used in one dataset cannot be reused in another dataset of the same telemetry type.
1527
#[serde(rename = "data")]
1628
pub data: crate::datadogV2::model::Dataset,
1729
#[serde(flatten)]

src/datadogV2/model/model_dataset_response_single.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,18 @@ use std::fmt::{self, Formatter};
1212
#[derive(Clone, Debug, PartialEq, Serialize)]
1313
pub struct DatasetResponseSingle {
1414
/// Dataset object.
15+
///
16+
/// ### Datasets Constraints
17+
/// - **Tag Limit per Dataset**:
18+
/// - Each restricted dataset supports a maximum of 10 key:value pairs per product.
19+
///
20+
/// - **Tag Key Rules per Telemetry Type**:
21+
/// - Only one tag key or attribute may be used to define access within a single telemetry type.
22+
/// - The same or different tag key may be used across different telemetry types.
23+
///
24+
/// - **Tag Value Uniqueness**:
25+
/// - Tag values must be unique within a single dataset.
26+
/// - A tag value used in one dataset cannot be reused in another dataset of the same telemetry type.
1527
#[serde(rename = "data")]
1628
pub data: crate::datadogV2::model::Dataset,
1729
#[serde(flatten)]

0 commit comments

Comments
 (0)