Skip to content

Commit 9602fc9

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

File tree

14 files changed

+395
-8
lines changed

14 files changed

+395
-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:24:15.646"
2+
"spec_repo_commit": "e4f653f",
3+
"generated": "2025-07-25 14:08:22.342"
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.ts

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
/**
2+
* Edit a dataset returns "OK" response
3+
*/
4+
5+
import { client, v2 } from "@datadog/datadog-api-client";
6+
7+
const configuration = client.createConfiguration();
8+
const apiInstance = new v2.DatasetsApi(configuration);
9+
10+
const params: v2.DatasetsApiUpdateDatasetRequest = {
11+
body: {
12+
data: {
13+
attributes: {
14+
createdAt: undefined,
15+
name: "Security Audit Dataset",
16+
principals: ["role:86245fce-0a4e-11f0-92bd-da7ad0900002"],
17+
productFilters: [
18+
{
19+
filters: ["@application.id:ABCD"],
20+
product: "logs",
21+
},
22+
],
23+
},
24+
id: "123e4567-e89b-12d3-a456-426614174000",
25+
type: "dataset",
26+
},
27+
},
28+
datasetId: "dataset_id",
29+
};
30+
31+
apiInstance
32+
.updateDataset(params)
33+
.then((data: v2.DatasetResponseSingle) => {
34+
console.log(
35+
"API called successfully. Returned data: " + JSON.stringify(data)
36+
);
37+
})
38+
.catch((error: any) => console.error(error));

features/support/scenarios_model_mapping.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4587,6 +4587,17 @@ export const ScenariosModelMappings: {[key: string]: {[key: string]: any}} = {
45874587
},
45884588
"operationResponseType": "DatasetResponseSingle",
45894589
},
4590+
"v2.UpdateDataset": {
4591+
"datasetId": {
4592+
"type": "string",
4593+
"format": "",
4594+
},
4595+
"body": {
4596+
"type": "DatasetUpdateRequest",
4597+
"format": "",
4598+
},
4599+
"operationResponseType": "DatasetResponseSingle",
4600+
},
45904601
"v2.CreateDataDeletionRequest": {
45914602
"product": {
45924603
"type": "string",

features/v2/datasets.feature

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,30 @@ Feature: Datasets
5353
When the request is sent
5454
Then the response status is 404 Not Found
5555

56+
@generated @skip @team:DataDog/aaa-granular-access
57+
Scenario: Edit a dataset returns "Bad Request" response
58+
Given new "UpdateDataset" request
59+
And request contains "dataset_id" parameter from "REPLACE.ME"
60+
And body with value {"data": {"attributes": {"created_at": null, "name": "Security Audit Dataset", "principals": ["role:86245fce-0a4e-11f0-92bd-da7ad0900002"], "product_filters": [{"filters": ["@application.id:ABCD"], "product": "logs"}]}, "id": "123e4567-e89b-12d3-a456-426614174000", "type": "dataset"}}
61+
When the request is sent
62+
Then the response status is 400 Bad Request
63+
64+
@generated @skip @team:DataDog/aaa-granular-access
65+
Scenario: Edit a dataset returns "Not Found" response
66+
Given new "UpdateDataset" request
67+
And request contains "dataset_id" parameter from "REPLACE.ME"
68+
And body with value {"data": {"attributes": {"created_at": null, "name": "Security Audit Dataset", "principals": ["role:86245fce-0a4e-11f0-92bd-da7ad0900002"], "product_filters": [{"filters": ["@application.id:ABCD"], "product": "logs"}]}, "id": "123e4567-e89b-12d3-a456-426614174000", "type": "dataset"}}
69+
When the request is sent
70+
Then the response status is 404 Not Found
71+
72+
@generated @skip @team:DataDog/aaa-granular-access
73+
Scenario: Edit a dataset returns "OK" response
74+
Given new "UpdateDataset" request
75+
And request contains "dataset_id" parameter from "REPLACE.ME"
76+
And body with value {"data": {"attributes": {"created_at": null, "name": "Security Audit Dataset", "principals": ["role:86245fce-0a4e-11f0-92bd-da7ad0900002"], "product_filters": [{"filters": ["@application.id:ABCD"], "product": "logs"}]}, "id": "123e4567-e89b-12d3-a456-426614174000", "type": "dataset"}}
77+
When the request is sent
78+
Then the response status is 200 OK
79+
5680
@generated @skip @team:DataDog/aaa-granular-access
5781
Scenario: Get a single dataset by ID returns "Bad Request" response
5882
Given new "GetDataset" request

features/v2/undo.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -888,6 +888,12 @@
888888
"type": "safe"
889889
}
890890
},
891+
"UpdateDataset": {
892+
"tag": "Datasets",
893+
"undo": {
894+
"type": "idempotent"
895+
}
896+
},
891897
"CreateDataDeletionRequest": {
892898
"tag": "Data Deletion",
893899
"undo": {

packages/datadog-api-client-v2/apis/DatasetsApi.ts

Lines changed: 150 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import { APIErrorResponse } from "../models/APIErrorResponse";
2020
import { DatasetCreateRequest } from "../models/DatasetCreateRequest";
2121
import { DatasetResponseMulti } from "../models/DatasetResponseMulti";
2222
import { DatasetResponseSingle } from "../models/DatasetResponseSingle";
23+
import { DatasetUpdateRequest } from "../models/DatasetUpdateRequest";
2324

2425
export class DatasetsApiRequestFactory extends BaseAPIRequestFactory {
2526
public async createDataset(
@@ -156,6 +157,57 @@ export class DatasetsApiRequestFactory extends BaseAPIRequestFactory {
156157

157158
return requestContext;
158159
}
160+
161+
public async updateDataset(
162+
datasetId: string,
163+
body: DatasetUpdateRequest,
164+
_options?: Configuration
165+
): Promise<RequestContext> {
166+
const _config = _options || this.configuration;
167+
168+
// verify required parameter 'datasetId' is not null or undefined
169+
if (datasetId === null || datasetId === undefined) {
170+
throw new RequiredError("datasetId", "updateDataset");
171+
}
172+
173+
// verify required parameter 'body' is not null or undefined
174+
if (body === null || body === undefined) {
175+
throw new RequiredError("body", "updateDataset");
176+
}
177+
178+
// Path Params
179+
const localVarPath = "/api/v2/datasets/{dataset_id}".replace(
180+
"{dataset_id}",
181+
encodeURIComponent(String(datasetId))
182+
);
183+
184+
// Make Request Context
185+
const requestContext = _config
186+
.getServer("v2.DatasetsApi.updateDataset")
187+
.makeRequestContext(localVarPath, HttpMethod.PUT);
188+
requestContext.setHeaderParam("Accept", "application/json");
189+
requestContext.setHttpConfig(_config.httpConfig);
190+
191+
// Body Params
192+
const contentType = ObjectSerializer.getPreferredMediaType([
193+
"application/json",
194+
]);
195+
requestContext.setHeaderParam("Content-Type", contentType);
196+
const serializedBody = ObjectSerializer.stringify(
197+
ObjectSerializer.serialize(body, "DatasetUpdateRequest", ""),
198+
contentType
199+
);
200+
requestContext.setBody(serializedBody);
201+
202+
// Apply auth methods
203+
applySecurityAuthentication(_config, requestContext, [
204+
"apiKeyAuth",
205+
"appKeyAuth",
206+
"AuthZ",
207+
]);
208+
209+
return requestContext;
210+
}
159211
}
160212

161213
export class DatasetsApiResponseProcessor {
@@ -399,6 +451,69 @@ export class DatasetsApiResponseProcessor {
399451
'Unknown API Status Code!\nBody: "' + body + '"'
400452
);
401453
}
454+
455+
/**
456+
* Unwraps the actual response sent by the server from the response context and deserializes the response content
457+
* to the expected objects
458+
*
459+
* @params response Response returned by the server for a request to updateDataset
460+
* @throws ApiException if the response code was not in [200, 299]
461+
*/
462+
public async updateDataset(
463+
response: ResponseContext
464+
): Promise<DatasetResponseSingle> {
465+
const contentType = ObjectSerializer.normalizeMediaType(
466+
response.headers["content-type"]
467+
);
468+
if (response.httpStatusCode === 200) {
469+
const body: DatasetResponseSingle = ObjectSerializer.deserialize(
470+
ObjectSerializer.parse(await response.body.text(), contentType),
471+
"DatasetResponseSingle"
472+
) as DatasetResponseSingle;
473+
return body;
474+
}
475+
if (
476+
response.httpStatusCode === 400 ||
477+
response.httpStatusCode === 403 ||
478+
response.httpStatusCode === 404 ||
479+
response.httpStatusCode === 429
480+
) {
481+
const bodyText = ObjectSerializer.parse(
482+
await response.body.text(),
483+
contentType
484+
);
485+
let body: APIErrorResponse;
486+
try {
487+
body = ObjectSerializer.deserialize(
488+
bodyText,
489+
"APIErrorResponse"
490+
) as APIErrorResponse;
491+
} catch (error) {
492+
logger.debug(`Got error deserializing error: ${error}`);
493+
throw new ApiException<APIErrorResponse>(
494+
response.httpStatusCode,
495+
bodyText
496+
);
497+
}
498+
throw new ApiException<APIErrorResponse>(response.httpStatusCode, body);
499+
}
500+
501+
// Work around for missing responses in specification, e.g. for petstore.yaml
502+
if (response.httpStatusCode >= 200 && response.httpStatusCode <= 299) {
503+
const body: DatasetResponseSingle = ObjectSerializer.deserialize(
504+
ObjectSerializer.parse(await response.body.text(), contentType),
505+
"DatasetResponseSingle",
506+
""
507+
) as DatasetResponseSingle;
508+
return body;
509+
}
510+
511+
const body = (await response.body.text()) || "";
512+
throw new ApiException<string>(
513+
response.httpStatusCode,
514+
'Unknown API Status Code!\nBody: "' + body + '"'
515+
);
516+
}
402517
}
403518

404519
export interface DatasetsApiCreateDatasetRequest {
@@ -425,6 +540,19 @@ export interface DatasetsApiGetDatasetRequest {
425540
datasetId: string;
426541
}
427542

543+
export interface DatasetsApiUpdateDatasetRequest {
544+
/**
545+
* The ID of a defined dataset.
546+
* @type string
547+
*/
548+
datasetId: string;
549+
/**
550+
* Dataset payload
551+
* @type DatasetUpdateRequest
552+
*/
553+
body: DatasetUpdateRequest;
554+
}
555+
428556
export class DatasetsApi {
429557
private requestFactory: DatasetsApiRequestFactory;
430558
private responseProcessor: DatasetsApiResponseProcessor;
@@ -521,4 +649,26 @@ export class DatasetsApi {
521649
});
522650
});
523651
}
652+
653+
/**
654+
* Edits the dataset associated with the ID.
655+
* @param param The request object
656+
*/
657+
public updateDataset(
658+
param: DatasetsApiUpdateDatasetRequest,
659+
options?: Configuration
660+
): Promise<DatasetResponseSingle> {
661+
const requestContextPromise = this.requestFactory.updateDataset(
662+
param.datasetId,
663+
param.body,
664+
options
665+
);
666+
return requestContextPromise.then((requestContext) => {
667+
return this.configuration.httpApi
668+
.send(requestContext)
669+
.then((responseContext) => {
670+
return this.responseProcessor.updateDataset(responseContext);
671+
});
672+
});
673+
}
524674
}

packages/datadog-api-client-v2/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -228,6 +228,7 @@ export {
228228
DatasetsApiCreateDatasetRequest,
229229
DatasetsApiDeleteDatasetRequest,
230230
DatasetsApiGetDatasetRequest,
231+
DatasetsApiUpdateDatasetRequest,
231232
DatasetsApi,
232233
} from "./apis/DatasetsApi";
233234

@@ -1443,6 +1444,7 @@ export { DatasetAttributes } from "./models/DatasetAttributes";
14431444
export { DatasetCreateRequest } from "./models/DatasetCreateRequest";
14441445
export { DatasetResponseMulti } from "./models/DatasetResponseMulti";
14451446
export { DatasetResponseSingle } from "./models/DatasetResponseSingle";
1447+
export { DatasetUpdateRequest } from "./models/DatasetUpdateRequest";
14461448
export { DataTransform } from "./models/DataTransform";
14471449
export { DataTransformProperties } from "./models/DataTransformProperties";
14481450
export { DataTransformType } from "./models/DataTransformType";

0 commit comments

Comments
 (0)