Skip to content

Commit 14607a5

Browse files
api-clients-generation-pipeline[bot]ci.datadog-api-spec
andauthored
Add enum Dataset type to Dataset API spec (DataDog#3281)
Co-authored-by: ci.datadog-api-spec <packages@datadoghq.com>
1 parent 0f61819 commit 14607a5

7 files changed

Lines changed: 111 additions & 28 deletions

File tree

.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:55:16.469"
2+
"spec_repo_commit": "7851858",
3+
"generated": "2025-08-18 14:49:19.064"
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:

api/datadogV2/model_dataset_request.go

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@ import (
2424
type DatasetRequest struct {
2525
// Dataset metadata and configurations.
2626
Attributes DatasetAttributesRequest `json:"attributes"`
27-
// Resource type, always "dataset".
28-
Type string `json:"type"`
27+
// Resource type, always set to `dataset`.
28+
Type DatasetType `json:"type"`
2929
// UnparsedObject contains the raw value of the object if there was an error when deserializing into the struct
3030
UnparsedObject map[string]interface{} `json:"-"`
3131
AdditionalProperties map[string]interface{} `json:"-"`
@@ -35,7 +35,7 @@ type DatasetRequest struct {
3535
// This constructor will assign default values to properties that have it defined,
3636
// and makes sure properties required by API are set, but the set of arguments
3737
// will change when the set of required properties is changed.
38-
func NewDatasetRequest(attributes DatasetAttributesRequest, typeVar string) *DatasetRequest {
38+
func NewDatasetRequest(attributes DatasetAttributesRequest, typeVar DatasetType) *DatasetRequest {
3939
this := DatasetRequest{}
4040
this.Attributes = attributes
4141
this.Type = typeVar
@@ -47,6 +47,8 @@ func NewDatasetRequest(attributes DatasetAttributesRequest, typeVar string) *Dat
4747
// but it doesn't guarantee that properties required by API are set.
4848
func NewDatasetRequestWithDefaults() *DatasetRequest {
4949
this := DatasetRequest{}
50+
var typeVar DatasetType = DATASETTYPE_DATASET
51+
this.Type = typeVar
5052
return &this
5153
}
5254

@@ -74,25 +76,25 @@ func (o *DatasetRequest) SetAttributes(v DatasetAttributesRequest) {
7476
}
7577

7678
// GetType returns the Type field value.
77-
func (o *DatasetRequest) GetType() string {
79+
func (o *DatasetRequest) GetType() DatasetType {
7880
if o == nil {
79-
var ret string
81+
var ret DatasetType
8082
return ret
8183
}
8284
return o.Type
8385
}
8486

8587
// GetTypeOk returns a tuple with the Type field value
8688
// and a boolean to check if the value has been set.
87-
func (o *DatasetRequest) GetTypeOk() (*string, bool) {
89+
func (o *DatasetRequest) GetTypeOk() (*DatasetType, bool) {
8890
if o == nil {
8991
return nil, false
9092
}
9193
return &o.Type, true
9294
}
9395

9496
// SetType sets field value.
95-
func (o *DatasetRequest) SetType(v string) {
97+
func (o *DatasetRequest) SetType(v DatasetType) {
9698
o.Type = v
9799
}
98100

@@ -115,7 +117,7 @@ func (o DatasetRequest) MarshalJSON() ([]byte, error) {
115117
func (o *DatasetRequest) UnmarshalJSON(bytes []byte) (err error) {
116118
all := struct {
117119
Attributes *DatasetAttributesRequest `json:"attributes"`
118-
Type *string `json:"type"`
120+
Type *DatasetType `json:"type"`
119121
}{}
120122
if err = datadog.Unmarshal(bytes, &all); err != nil {
121123
return datadog.Unmarshal(bytes, &o.UnparsedObject)
@@ -138,7 +140,11 @@ func (o *DatasetRequest) UnmarshalJSON(bytes []byte) (err error) {
138140
hasInvalidField = true
139141
}
140142
o.Attributes = *all.Attributes
141-
o.Type = *all.Type
143+
if !all.Type.IsValid() {
144+
hasInvalidField = true
145+
} else {
146+
o.Type = *all.Type
147+
}
142148

143149
if len(additionalProperties) > 0 {
144150
o.AdditionalProperties = additionalProperties

api/datadogV2/model_dataset_response.go

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@ type DatasetResponse struct {
2424
Attributes *DatasetAttributesResponse `json:"attributes,omitempty"`
2525
// Unique identifier for the dataset.
2626
Id *string `json:"id,omitempty"`
27-
// Resource type, always "dataset".
28-
Type *string `json:"type,omitempty"`
27+
// Resource type, always set to `dataset`.
28+
Type *DatasetType `json:"type,omitempty"`
2929
// UnparsedObject contains the raw value of the object if there was an error when deserializing into the struct
3030
UnparsedObject map[string]interface{} `json:"-"`
3131
AdditionalProperties map[string]interface{} `json:"-"`
@@ -37,6 +37,8 @@ type DatasetResponse struct {
3737
// will change when the set of required properties is changed.
3838
func NewDatasetResponse() *DatasetResponse {
3939
this := DatasetResponse{}
40+
var typeVar DatasetType = DATASETTYPE_DATASET
41+
this.Type = &typeVar
4042
return &this
4143
}
4244

@@ -45,6 +47,8 @@ func NewDatasetResponse() *DatasetResponse {
4547
// but it doesn't guarantee that properties required by API are set.
4648
func NewDatasetResponseWithDefaults() *DatasetResponse {
4749
this := DatasetResponse{}
50+
var typeVar DatasetType = DATASETTYPE_DATASET
51+
this.Type = &typeVar
4852
return &this
4953
}
5054

@@ -105,17 +109,17 @@ func (o *DatasetResponse) SetId(v string) {
105109
}
106110

107111
// GetType returns the Type field value if set, zero value otherwise.
108-
func (o *DatasetResponse) GetType() string {
112+
func (o *DatasetResponse) GetType() DatasetType {
109113
if o == nil || o.Type == nil {
110-
var ret string
114+
var ret DatasetType
111115
return ret
112116
}
113117
return *o.Type
114118
}
115119

116120
// GetTypeOk returns a tuple with the Type field value if set, nil otherwise
117121
// and a boolean to check if the value has been set.
118-
func (o *DatasetResponse) GetTypeOk() (*string, bool) {
122+
func (o *DatasetResponse) GetTypeOk() (*DatasetType, bool) {
119123
if o == nil || o.Type == nil {
120124
return nil, false
121125
}
@@ -127,8 +131,8 @@ func (o *DatasetResponse) HasType() bool {
127131
return o != nil && o.Type != nil
128132
}
129133

130-
// SetType gets a reference to the given string and assigns it to the Type field.
131-
func (o *DatasetResponse) SetType(v string) {
134+
// SetType gets a reference to the given DatasetType and assigns it to the Type field.
135+
func (o *DatasetResponse) SetType(v DatasetType) {
132136
o.Type = &v
133137
}
134138

@@ -159,7 +163,7 @@ func (o *DatasetResponse) UnmarshalJSON(bytes []byte) (err error) {
159163
all := struct {
160164
Attributes *DatasetAttributesResponse `json:"attributes,omitempty"`
161165
Id *string `json:"id,omitempty"`
162-
Type *string `json:"type,omitempty"`
166+
Type *DatasetType `json:"type,omitempty"`
163167
}{}
164168
if err = datadog.Unmarshal(bytes, &all); err != nil {
165169
return datadog.Unmarshal(bytes, &o.UnparsedObject)
@@ -177,7 +181,11 @@ func (o *DatasetResponse) UnmarshalJSON(bytes []byte) (err error) {
177181
}
178182
o.Attributes = all.Attributes
179183
o.Id = all.Id
180-
o.Type = all.Type
184+
if all.Type != nil && !all.Type.IsValid() {
185+
hasInvalidField = true
186+
} else {
187+
o.Type = all.Type
188+
}
181189

182190
if len(additionalProperties) > 0 {
183191
o.AdditionalProperties = additionalProperties
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License.
2+
// This product includes software developed at Datadog (https://www.datadoghq.com/).
3+
// Copyright 2019-Present Datadog, Inc.
4+
5+
package datadogV2
6+
7+
import (
8+
"fmt"
9+
10+
"github.com/DataDog/datadog-api-client-go/v2/api/datadog"
11+
)
12+
13+
// DatasetType Resource type, always set to `dataset`.
14+
type DatasetType string
15+
16+
// List of DatasetType.
17+
const (
18+
DATASETTYPE_DATASET DatasetType = "dataset"
19+
)
20+
21+
var allowedDatasetTypeEnumValues = []DatasetType{
22+
DATASETTYPE_DATASET,
23+
}
24+
25+
// GetAllowedValues reeturns the list of possible values.
26+
func (v *DatasetType) GetAllowedValues() []DatasetType {
27+
return allowedDatasetTypeEnumValues
28+
}
29+
30+
// UnmarshalJSON deserializes the given payload.
31+
func (v *DatasetType) UnmarshalJSON(src []byte) error {
32+
var value string
33+
err := datadog.Unmarshal(src, &value)
34+
if err != nil {
35+
return err
36+
}
37+
*v = DatasetType(value)
38+
return nil
39+
}
40+
41+
// NewDatasetTypeFromValue returns a pointer to a valid DatasetType
42+
// for the value passed as argument, or an error if the value passed is not allowed by the enum.
43+
func NewDatasetTypeFromValue(v string) (*DatasetType, error) {
44+
ev := DatasetType(v)
45+
if ev.IsValid() {
46+
return &ev, nil
47+
}
48+
return nil, fmt.Errorf("invalid value '%v' for DatasetType: valid values are %v", v, allowedDatasetTypeEnumValues)
49+
}
50+
51+
// IsValid return true if the value is valid for the enum, false otherwise.
52+
func (v DatasetType) IsValid() bool {
53+
for _, existing := range allowedDatasetTypeEnumValues {
54+
if existing == v {
55+
return true
56+
}
57+
}
58+
return false
59+
}
60+
61+
// Ptr returns reference to DatasetType value.
62+
func (v DatasetType) Ptr() *DatasetType {
63+
return &v
64+
}

examples/v2/datasets/CreateDataset.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ func main() {
2929
},
3030
},
3131
},
32-
Type: "dataset",
32+
Type: datadogV2.DATASETTYPE_DATASET,
3333
},
3434
}
3535
ctx := datadog.NewDefaultContext(context.Background())

examples/v2/datasets/UpdateDataset.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ func main() {
3232
},
3333
},
3434
},
35-
Type: "dataset",
35+
Type: datadogV2.DATASETTYPE_DATASET,
3636
},
3737
}
3838
ctx := datadog.NewDefaultContext(context.Background())

0 commit comments

Comments
 (0)