Skip to content

Fix bug in change resource enum value (configuration to metric_configuration) #2657

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .generated-info
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"spec_repo_commit": "8001cbb",
"generated": "2025-08-13 20:28:25.331"
"spec_repo_commit": "d394b63",
"generated": "2025-08-14 13:59:05.137"
}
8 changes: 4 additions & 4 deletions .generator/schemas/v2/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7649,12 +7649,12 @@ components:
description: The type of the changed resource.
enum:
- feature_flag
- configuration
- metric_configuration
example: feature_flag
type: string
x-enum-varnames:
- FEATURE_FLAG
- CONFIGURATION
- METRIC_CONFIGURATION
ChangeEventAttributesImpactedResourcesItem:
description: A uniquely identified resource.
properties:
Expand Down Expand Up @@ -7780,12 +7780,12 @@ components:
description: The type of the resource that was changed.
enum:
- feature_flag
- configuration
- metric_configuration
example: feature_flag
type: string
x-enum-varnames:
- FEATURE_FLAG
- CONFIGURATION
- METRIC_CONFIGURATION
ChangeEventCustomAttributesImpactedResourcesItems:
additionalProperties: false
description: Object representing a uniquely identified resource.
Expand Down
63 changes: 63 additions & 0 deletions examples/v2/events/CreateEvent_1017977945.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
/**
* Post an event with metric_configuration resource type returns "OK" response
*/

import { client, v2 } from "@datadog/datadog-api-client";

const configuration = client.createConfiguration();
const apiInstance = new v2.EventsApi(configuration);

const params: v2.EventsApiCreateEventRequest = {
body: {
data: {
attributes: {
aggregationKey: "aggregation_key_123",
attributes: {
author: {
name: "[email protected]",
type: "user",
},
changeMetadata: {
dd: "{'team': 'datadog_team', 'user_email': '[email protected]', 'user_id': 'datadog_user_id', 'user_name': 'datadog_username'}",
resource_link: "datadog.com/metric/config_test",
},
changedResource: {
name: "config_test",
type: "metric_configuration",
},
impactedResources: [
{
name: "system.cpu.usage",
type: "service",
},
],
newValue: {
aggregation: "avg",
tags: "['env:prod', 'service:web']",
unit: "percent",
},
prevValue: {
aggregation: "sum",
tags: "['env:prod']",
unit: "percent",
},
},
category: "change",
integrationId: "custom-events",
message: "metric configuration has been updated",
tags: ["env:api_client_test"],
title: "metric configuration updated",
},
type: "event",
},
},
};

apiInstance
.createEvent(params)
.then((data: v2.EventCreateResponsePayload) => {
console.log(
"API called successfully. Returned data: " + JSON.stringify(data)
);
})
.catch((error: any) => console.error(error));
9 changes: 9 additions & 0 deletions features/v2/events.feature
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,15 @@ Feature: Events
And the response "data.type" is equal to "event"
And the response "data.attributes.attributes.evt" has field "uid"

@skip-validation @team:DataDog/event-management
Scenario: Post an event with metric_configuration resource type returns "OK" response
Given new "CreateEvent" request
And body with value {"data": {"attributes": {"aggregation_key": "aggregation_key_123", "attributes": {"author": {"name": "[email protected]", "type": "user"}, "change_metadata": {"dd": {"team": "datadog_team", "user_email": "[email protected]", "user_id": "datadog_user_id", "user_name": "datadog_username"}, "resource_link": "datadog.com/metric/config_test"}, "changed_resource": {"name": "config_test", "type": "metric_configuration"}, "impacted_resources": [{"name": "system.cpu.usage", "type": "service"}], "new_value": {"aggregation": "avg", "tags": ["env:prod", "service:web"], "unit": "percent"}, "prev_value": {"aggregation": "sum", "tags": ["env:prod"], "unit": "percent"}}, "category": "change", "integration_id": "custom-events", "message": "metric configuration has been updated", "tags": ["env:api_client_test"], "title": "metric configuration updated"}, "type": "event"}}
When the request is sent
Then the response status is 202 OK
And the response "data.type" is equal to "event"
And the response "data.attributes.attributes.evt" has field "uid"

@team:DataDog/event-management
Scenario: Search events returns "Bad Request" response
Given new "SearchEvents" request
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import { UnparsedObject } from "../../datadog-api-client-common/util";

export type ChangeEventAttributesChangedResourceType =
| typeof FEATURE_FLAG
| typeof CONFIGURATION
| typeof METRIC_CONFIGURATION
| UnparsedObject;
export const FEATURE_FLAG = "feature_flag";
export const CONFIGURATION = "configuration";
export const METRIC_CONFIGURATION = "metric_configuration";
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import { UnparsedObject } from "../../datadog-api-client-common/util";

export type ChangeEventCustomAttributesChangedResourceType =
| typeof FEATURE_FLAG
| typeof CONFIGURATION
| typeof METRIC_CONFIGURATION
| UnparsedObject;
export const FEATURE_FLAG = "feature_flag";
export const CONFIGURATION = "configuration";
export const METRIC_CONFIGURATION = "metric_configuration";
7 changes: 5 additions & 2 deletions packages/datadog-api-client-v2/models/ObjectSerializer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2358,7 +2358,10 @@ const enumsMap: { [key: string]: any[] } = {
CaseStatus: ["OPEN", "IN_PROGRESS", "CLOSED"],
CaseType: ["STANDARD"],
ChangeEventAttributesAuthorType: ["user", "system", "api", "automation"],
ChangeEventAttributesChangedResourceType: ["feature_flag", "configuration"],
ChangeEventAttributesChangedResourceType: [
"feature_flag",
"metric_configuration",
],
ChangeEventAttributesImpactedResourcesItemType: ["service"],
ChangeEventCustomAttributesAuthorType: [
"user",
Expand All @@ -2368,7 +2371,7 @@ const enumsMap: { [key: string]: any[] } = {
],
ChangeEventCustomAttributesChangedResourceType: [
"feature_flag",
"configuration",
"metric_configuration",
],
ChangeEventCustomAttributesImpactedResourcesItemsType: ["service"],
CircleCIAPIKeyType: ["CircleCIAPIKey"],
Expand Down
Loading