Skip to content

Commit 6c28128

Browse files
api-clients-generation-pipeline[bot]ci.datadog-api-spec
andauthored
Add enum Dataset type to Dataset API spec (#3065)
Co-authored-by: ci.datadog-api-spec <packages@datadoghq.com>
1 parent edf6156 commit 6c28128

File tree

7 files changed

+90
-21
lines changed

7 files changed

+90
-21
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": "c38287b",
3-
"generated": "2025-08-15 18:54:57.072"
2+
"spec_repo_commit": "7851858",
3+
"generated": "2025-08-18 14:49:09.895"
44
}

.generator/schemas/v2/openapi.yaml

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13258,9 +13258,7 @@ components:
1325813258
attributes:
1325913259
$ref: '#/components/schemas/DatasetAttributesRequest'
1326013260
type:
13261-
description: Resource type, always "dataset".
13262-
example: dataset
13263-
type: string
13261+
$ref: '#/components/schemas/DatasetType'
1326413262
required:
1326513263
- type
1326613264
- attributes
@@ -13282,9 +13280,7 @@ components:
1328213280
example: 123e4567-e89b-12d3-a456-426614174000
1328313281
type: string
1328413282
type:
13285-
description: Resource type, always "dataset".
13286-
example: dataset
13287-
type: string
13283+
$ref: '#/components/schemas/DatasetType'
1328813284
type: object
1328913285
DatasetResponseMulti:
1329013286
description: Response containing a list of datasets.
@@ -13301,6 +13297,15 @@ components:
1330113297
data:
1330213298
$ref: '#/components/schemas/DatasetResponse'
1330313299
type: object
13300+
DatasetType:
13301+
default: dataset
13302+
description: Resource type, always set to `dataset`.
13303+
enum:
13304+
- dataset
13305+
example: dataset
13306+
type: string
13307+
x-enum-varnames:
13308+
- DATASET
1330413309
DatasetUpdateRequest:
1330513310
description: Edit request for a dataset.
1330613311
properties:

examples/v2/datasets/CreateDataset.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
import com.datadog.api.client.v2.model.DatasetCreateRequest;
88
import com.datadog.api.client.v2.model.DatasetRequest;
99
import com.datadog.api.client.v2.model.DatasetResponseSingle;
10+
import com.datadog.api.client.v2.model.DatasetType;
1011
import com.datadog.api.client.v2.model.FiltersPerProduct;
1112
import java.util.Collections;
1213

@@ -31,7 +32,7 @@ public static void main(String[] args) {
3132
new FiltersPerProduct()
3233
.filters(Collections.singletonList("@application.id:ABCD"))
3334
.product("metrics"))))
34-
.type("dataset"));
35+
.type(DatasetType.DATASET));
3536

3637
try {
3738
DatasetResponseSingle result = apiInstance.createDataset(body);

examples/v2/datasets/UpdateDataset.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import com.datadog.api.client.v2.model.DatasetAttributesRequest;
77
import com.datadog.api.client.v2.model.DatasetRequest;
88
import com.datadog.api.client.v2.model.DatasetResponseSingle;
9+
import com.datadog.api.client.v2.model.DatasetType;
910
import com.datadog.api.client.v2.model.DatasetUpdateRequest;
1011
import com.datadog.api.client.v2.model.FiltersPerProduct;
1112
import java.util.Collections;
@@ -34,7 +35,7 @@ public static void main(String[] args) {
3435
new FiltersPerProduct()
3536
.filters(Collections.singletonList("@application.id:1234"))
3637
.product("metrics"))))
37-
.type("dataset"));
38+
.type(DatasetType.DATASET));
3839

3940
try {
4041
DatasetResponseSingle result = apiInstance.updateDataset(DATASET_DATA_ID, body);

src/main/java/com/datadog/api/client/v2/model/DatasetRequest.java

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -42,18 +42,19 @@ public class DatasetRequest {
4242
private DatasetAttributesRequest attributes;
4343

4444
public static final String JSON_PROPERTY_TYPE = "type";
45-
private String type;
45+
private DatasetType type = DatasetType.DATASET;
4646

4747
public DatasetRequest() {}
4848

4949
@JsonCreator
5050
public DatasetRequest(
5151
@JsonProperty(required = true, value = JSON_PROPERTY_ATTRIBUTES)
5252
DatasetAttributesRequest attributes,
53-
@JsonProperty(required = true, value = JSON_PROPERTY_TYPE) String type) {
53+
@JsonProperty(required = true, value = JSON_PROPERTY_TYPE) DatasetType type) {
5454
this.attributes = attributes;
5555
this.unparsed |= attributes.unparsed;
5656
this.type = type;
57+
this.unparsed |= !type.isValid();
5758
}
5859

5960
public DatasetRequest attributes(DatasetAttributesRequest attributes) {
@@ -77,23 +78,27 @@ public void setAttributes(DatasetAttributesRequest attributes) {
7778
this.attributes = attributes;
7879
}
7980

80-
public DatasetRequest type(String type) {
81+
public DatasetRequest type(DatasetType type) {
8182
this.type = type;
83+
this.unparsed |= !type.isValid();
8284
return this;
8385
}
8486

8587
/**
86-
* Resource type, always "dataset".
88+
* Resource type, always set to <code>dataset</code>.
8789
*
8890
* @return type
8991
*/
9092
@JsonProperty(JSON_PROPERTY_TYPE)
9193
@JsonInclude(value = JsonInclude.Include.ALWAYS)
92-
public String getType() {
94+
public DatasetType getType() {
9395
return type;
9496
}
9597

96-
public void setType(String type) {
98+
public void setType(DatasetType type) {
99+
if (!type.isValid()) {
100+
this.unparsed = true;
101+
}
97102
this.type = type;
98103
}
99104

src/main/java/com/datadog/api/client/v2/model/DatasetResponse.java

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ public class DatasetResponse {
4848
private String id;
4949

5050
public static final String JSON_PROPERTY_TYPE = "type";
51-
private String type;
51+
private DatasetType type = DatasetType.DATASET;
5252

5353
public DatasetResponse attributes(DatasetAttributesResponse attributes) {
5454
this.attributes = attributes;
@@ -93,24 +93,28 @@ public void setId(String id) {
9393
this.id = id;
9494
}
9595

96-
public DatasetResponse type(String type) {
96+
public DatasetResponse type(DatasetType type) {
9797
this.type = type;
98+
this.unparsed |= !type.isValid();
9899
return this;
99100
}
100101

101102
/**
102-
* Resource type, always "dataset".
103+
* Resource type, always set to <code>dataset</code>.
103104
*
104105
* @return type
105106
*/
106107
@jakarta.annotation.Nullable
107108
@JsonProperty(JSON_PROPERTY_TYPE)
108109
@JsonInclude(value = JsonInclude.Include.USE_DEFAULTS)
109-
public String getType() {
110+
public DatasetType getType() {
110111
return type;
111112
}
112113

113-
public void setType(String type) {
114+
public void setType(DatasetType type) {
115+
if (!type.isValid()) {
116+
this.unparsed = true;
117+
}
114118
this.type = type;
115119
}
116120

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
/*
2+
* Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License.
3+
* This product includes software developed at Datadog (https://www.datadoghq.com/).
4+
* Copyright 2019-Present Datadog, Inc.
5+
*/
6+
7+
package com.datadog.api.client.v2.model;
8+
9+
import com.datadog.api.client.ModelEnum;
10+
import com.fasterxml.jackson.annotation.JsonCreator;
11+
import com.fasterxml.jackson.core.JsonGenerator;
12+
import com.fasterxml.jackson.core.JsonProcessingException;
13+
import com.fasterxml.jackson.databind.SerializerProvider;
14+
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
15+
import com.fasterxml.jackson.databind.ser.std.StdSerializer;
16+
import java.io.IOException;
17+
import java.util.Arrays;
18+
import java.util.HashSet;
19+
import java.util.Set;
20+
21+
/** Resource type, always set to <code>dataset</code>. */
22+
@JsonSerialize(using = DatasetType.DatasetTypeSerializer.class)
23+
public class DatasetType extends ModelEnum<String> {
24+
25+
private static final Set<String> allowedValues = new HashSet<String>(Arrays.asList("dataset"));
26+
27+
public static final DatasetType DATASET = new DatasetType("dataset");
28+
29+
DatasetType(String value) {
30+
super(value, allowedValues);
31+
}
32+
33+
public static class DatasetTypeSerializer extends StdSerializer<DatasetType> {
34+
public DatasetTypeSerializer(Class<DatasetType> t) {
35+
super(t);
36+
}
37+
38+
public DatasetTypeSerializer() {
39+
this(null);
40+
}
41+
42+
@Override
43+
public void serialize(DatasetType value, JsonGenerator jgen, SerializerProvider provider)
44+
throws IOException, JsonProcessingException {
45+
jgen.writeObject(value.value);
46+
}
47+
}
48+
49+
@JsonCreator
50+
public static DatasetType fromValue(String value) {
51+
return new DatasetType(value);
52+
}
53+
}

0 commit comments

Comments
 (0)