Skip to content

Commit 7fdcc4e

Browse files
api-clients-generation-pipeline[bot]ci.datadog-api-spec
andauthored
Add host field to Post an event V2 API (#3307)
Co-authored-by: ci.datadog-api-spec <packages@datadoghq.com>
1 parent d617bba commit 7fdcc4e

File tree

8 files changed

+47
-10
lines changed

8 files changed

+47
-10
lines changed

.generator/schemas/v2/openapi.yaml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20306,6 +20306,13 @@ components:
2030620306
$ref: '#/components/schemas/EventPayloadAttributes'
2030720307
category:
2030820308
$ref: '#/components/schemas/EventCategory'
20309+
host:
20310+
description: Host name to associate with the event. Any tags associated
20311+
with the host are also applied to this event. Limited to 255 characters.
20312+
example: hostname
20313+
maxLength: 255
20314+
minLength: 1
20315+
type: string
2030920316
integration_id:
2031020317
$ref: '#/components/schemas/EventPayloadIntegrationId'
2031120318
message:
@@ -67866,6 +67873,7 @@ paths:
6786667873
rule:
6786767874
datacenter: devcycle.us1.prod
6786867875
category: change
67876+
host: hostname
6786967877
integration_id: custom-events
6787067878
message: payment_processed feature flag has been enabled
6787167879
tags:

examples/v2/events/CreateEvent.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ public static void main(String[] args) {
7979
"{'datacenter': 'devcycle.us1.prod'}")))))
8080
.category(EventCategory.CHANGE)
8181
.integrationId(EventPayloadIntegrationId.CUSTOM_EVENTS)
82+
.host("test-host")
8283
.message("payment_processed feature flag has been enabled")
8384
.tags(Collections.singletonList("env:api_client_test"))
8485
.title("payment_processed feature flag updated"))

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

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
EventPayload.JSON_PROPERTY_AGGREGATION_KEY,
2121
EventPayload.JSON_PROPERTY_ATTRIBUTES,
2222
EventPayload.JSON_PROPERTY_CATEGORY,
23+
EventPayload.JSON_PROPERTY_HOST,
2324
EventPayload.JSON_PROPERTY_INTEGRATION_ID,
2425
EventPayload.JSON_PROPERTY_MESSAGE,
2526
EventPayload.JSON_PROPERTY_TAGS,
@@ -39,6 +40,9 @@ public class EventPayload {
3940
public static final String JSON_PROPERTY_CATEGORY = "category";
4041
private EventCategory category;
4142

43+
public static final String JSON_PROPERTY_HOST = "host";
44+
private String host;
45+
4246
public static final String JSON_PROPERTY_INTEGRATION_ID = "integration_id";
4347
private EventPayloadIntegrationId integrationId;
4448

@@ -138,6 +142,28 @@ public void setCategory(EventCategory category) {
138142
this.category = category;
139143
}
140144

145+
public EventPayload host(String host) {
146+
this.host = host;
147+
return this;
148+
}
149+
150+
/**
151+
* Host name to associate with the event. Any tags associated with the host are also applied to
152+
* this event. Limited to 255 characters.
153+
*
154+
* @return host
155+
*/
156+
@jakarta.annotation.Nullable
157+
@JsonProperty(JSON_PROPERTY_HOST)
158+
@JsonInclude(value = JsonInclude.Include.USE_DEFAULTS)
159+
public String getHost() {
160+
return host;
161+
}
162+
163+
public void setHost(String host) {
164+
this.host = host;
165+
}
166+
141167
public EventPayload integrationId(EventPayloadIntegrationId integrationId) {
142168
this.integrationId = integrationId;
143169
this.unparsed |= !integrationId.isValid();
@@ -273,6 +299,7 @@ public boolean equals(Object o) {
273299
return Objects.equals(this.aggregationKey, eventPayload.aggregationKey)
274300
&& Objects.equals(this.attributes, eventPayload.attributes)
275301
&& Objects.equals(this.category, eventPayload.category)
302+
&& Objects.equals(this.host, eventPayload.host)
276303
&& Objects.equals(this.integrationId, eventPayload.integrationId)
277304
&& Objects.equals(this.message, eventPayload.message)
278305
&& Objects.equals(this.tags, eventPayload.tags)
@@ -283,7 +310,7 @@ public boolean equals(Object o) {
283310
@Override
284311
public int hashCode() {
285312
return Objects.hash(
286-
aggregationKey, attributes, category, integrationId, message, tags, timestamp, title);
313+
aggregationKey, attributes, category, host, integrationId, message, tags, timestamp, title);
287314
}
288315

289316
@Override
@@ -293,6 +320,7 @@ public String toString() {
293320
sb.append(" aggregationKey: ").append(toIndentedString(aggregationKey)).append("\n");
294321
sb.append(" attributes: ").append(toIndentedString(attributes)).append("\n");
295322
sb.append(" category: ").append(toIndentedString(category)).append("\n");
323+
sb.append(" host: ").append(toIndentedString(host)).append("\n");
296324
sb.append(" integrationId: ").append(toIndentedString(integrationId)).append("\n");
297325
sb.append(" message: ").append(toIndentedString(message)).append("\n");
298326
sb.append(" tags: ").append(toIndentedString(tags)).append("\n");
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
2025-06-10T15:38:58.529Z
1+
2025-12-10T21:31:06.468Z

src/test/resources/cassettes/features/v2/Post_an_event_returns_Bad_request_response.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"httpRequest": {
44
"body": {
55
"type": "JSON",
6-
"json": "{\"data\":{\"attributes\":{\"aggregation_key\":\"aggregation_key_123\",\"attributes\":{\"author\":{\"name\":\"example@datadog.com\",\"type\":\"user\"},\"change_metadata\":{\"dd\":{\"team\":\"datadog_team\",\"user_email\":\"datadog@datadog.com\",\"user_id\":\"datadog_user_id\",\"user_name\":\"datadog_username\"},\"resource_link\":\"datadog.com/feature/fallback_payments_test\"},\"changed_resource\":{\"name\":\"fallback_payments_test\",\"type\":\"feature_flag\"},\"impacted_resources\":[{\"name\":\"payments_api\",\"type\":\"service\"}],\"new_value\":{\"enabled\":true,\"percentage\":\"50%\",\"rule\":{\"datacenter\":\"devcycle.us1.prod\"}},\"prev_value\":{\"enabled\":true,\"percentage\":\"10%\",\"rule\":{\"datacenter\":\"devcycle.us1.prod\"}}},\"category\":\"invalid\",\"integration_id\":\"custom-events\",\"message\":\"payment_processed feature flag has been enabled\",\"tags\":[\"env:api_client_test\"],\"title\":\"payment_processed feature flag updated\"},\"type\":\"event\"}}"
6+
"json": "{\"data\":{\"attributes\":{\"aggregation_key\":\"aggregation_key_123\",\"attributes\":{\"author\":{\"name\":\"example@datadog.com\",\"type\":\"user\"},\"change_metadata\":{\"dd\":{\"team\":\"datadog_team\",\"user_email\":\"datadog@datadog.com\",\"user_id\":\"datadog_user_id\",\"user_name\":\"datadog_username\"},\"resource_link\":\"datadog.com/feature/fallback_payments_test\"},\"changed_resource\":{\"name\":\"fallback_payments_test\",\"type\":\"feature_flag\"},\"impacted_resources\":[{\"name\":\"payments_api\",\"type\":\"service\"}],\"new_value\":{\"enabled\":true,\"percentage\":\"50%\",\"rule\":{\"datacenter\":\"devcycle.us1.prod\"}},\"prev_value\":{\"enabled\":true,\"percentage\":\"10%\",\"rule\":{\"datacenter\":\"devcycle.us1.prod\"}}},\"category\":\"invalid\",\"host\":\"test-host\",\"integration_id\":\"custom-events\",\"message\":\"payment_processed feature flag has been enabled\",\"tags\":[\"env:api_client_test\"],\"title\":\"payment_processed feature flag updated\"},\"type\":\"event\"}}"
77
},
88
"headers": {},
99
"method": "POST",
@@ -27,6 +27,6 @@
2727
"timeToLive": {
2828
"unlimited": true
2929
},
30-
"id": "b35f8f84-50dc-70b8-3d76-61b05817ff7e"
30+
"id": "df202477-5328-5206-f854-ba0313ce3ab1"
3131
}
3232
]
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
2025-06-10T15:38:58.954Z
1+
2025-12-10T21:30:25.683Z

src/test/resources/cassettes/features/v2/Post_an_event_returns_OK_response.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"httpRequest": {
44
"body": {
55
"type": "JSON",
6-
"json": "{\"data\":{\"attributes\":{\"aggregation_key\":\"aggregation_key_123\",\"attributes\":{\"author\":{\"name\":\"example@datadog.com\",\"type\":\"user\"},\"change_metadata\":{\"dd\":{\"team\":\"datadog_team\",\"user_email\":\"datadog@datadog.com\",\"user_id\":\"datadog_user_id\",\"user_name\":\"datadog_username\"},\"resource_link\":\"datadog.com/feature/fallback_payments_test\"},\"changed_resource\":{\"name\":\"fallback_payments_test\",\"type\":\"feature_flag\"},\"impacted_resources\":[{\"name\":\"payments_api\",\"type\":\"service\"}],\"new_value\":{\"enabled\":true,\"percentage\":\"50%\",\"rule\":{\"datacenter\":\"devcycle.us1.prod\"}},\"prev_value\":{\"enabled\":true,\"percentage\":\"10%\",\"rule\":{\"datacenter\":\"devcycle.us1.prod\"}}},\"category\":\"change\",\"integration_id\":\"custom-events\",\"message\":\"payment_processed feature flag has been enabled\",\"tags\":[\"env:api_client_test\"],\"title\":\"payment_processed feature flag updated\"},\"type\":\"event\"}}"
6+
"json": "{\"data\":{\"attributes\":{\"aggregation_key\":\"aggregation_key_123\",\"attributes\":{\"author\":{\"name\":\"example@datadog.com\",\"type\":\"user\"},\"change_metadata\":{\"dd\":{\"team\":\"datadog_team\",\"user_email\":\"datadog@datadog.com\",\"user_id\":\"datadog_user_id\",\"user_name\":\"datadog_username\"},\"resource_link\":\"datadog.com/feature/fallback_payments_test\"},\"changed_resource\":{\"name\":\"fallback_payments_test\",\"type\":\"feature_flag\"},\"impacted_resources\":[{\"name\":\"payments_api\",\"type\":\"service\"}],\"new_value\":{\"enabled\":true,\"percentage\":\"50%\",\"rule\":{\"datacenter\":\"devcycle.us1.prod\"}},\"prev_value\":{\"enabled\":true,\"percentage\":\"10%\",\"rule\":{\"datacenter\":\"devcycle.us1.prod\"}}},\"category\":\"change\",\"host\":\"test-host\",\"integration_id\":\"custom-events\",\"message\":\"payment_processed feature flag has been enabled\",\"tags\":[\"env:api_client_test\"],\"title\":\"payment_processed feature flag updated\"},\"type\":\"event\"}}"
77
},
88
"headers": {},
99
"method": "POST",
@@ -12,7 +12,7 @@
1212
"secure": true
1313
},
1414
"httpResponse": {
15-
"body": "{\"data\":{\"attributes\":{\"attributes\":{\"evt\":{\"uid\":\"AZdafqaTAACKG_iMQ82pmAAA\"}}},\"id\":\"_\",\"type\":\"event\"},\"links\":{\"self\":\"https://app.datadoghq.com/event/event?uid=AZdafqaTAACKG_iMQ82pmAAA\"}}",
15+
"body": "{\"data\":{\"attributes\":{\"attributes\":{\"evt\":{\"id\":\"8407723285051133019\",\"uid\":\"AZsKLCxvAACrUQTfNDwMWwAA\"}}},\"id\":\"_\",\"type\":\"event\"},\"links\":{\"self\":\"https://app.datadoghq.com/event/event?uid=AZsKLCxvAACrUQTfNDwMWwAA\"}}",
1616
"headers": {
1717
"Content-Type": [
1818
"application/json"
@@ -27,6 +27,6 @@
2727
"timeToLive": {
2828
"unlimited": true
2929
},
30-
"id": "12f2ce8c-e9b9-19c0-6a47-1c2b7d261fb3"
30+
"id": "7b0f8268-4418-29ad-8e3e-52424c7477bd"
3131
}
3232
]

src/test/resources/com/datadog/api/client/v2/api/events.feature

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,14 +74,14 @@ Feature: Events
7474
@team:DataDog/event-management
7575
Scenario: Post an event returns "Bad request" response
7676
Given new "CreateEvent" request
77-
And body with value {"data": {"attributes": {"aggregation_key": "aggregation_key_123", "attributes": {"author": {"name": "example@datadog.com", "type": "user"}, "change_metadata": {"dd": {"team": "datadog_team", "user_email": "datadog@datadog.com", "user_id": "datadog_user_id", "user_name": "datadog_username"}, "resource_link": "datadog.com/feature/fallback_payments_test"}, "changed_resource": {"name": "fallback_payments_test", "type": "feature_flag"}, "impacted_resources": [{"name": "payments_api", "type": "service"}], "new_value": {"enabled": true, "percentage": "50%", "rule": {"datacenter": "devcycle.us1.prod"}}, "prev_value": {"enabled": true, "percentage": "10%", "rule": {"datacenter": "devcycle.us1.prod"}}}, "category": "invalid", "integration_id": "custom-events", "message": "payment_processed feature flag has been enabled", "tags": ["env:api_client_test"], "title": "payment_processed feature flag updated"}, "type": "event"}}
77+
And body with value {"data": {"attributes": {"aggregation_key": "aggregation_key_123", "attributes": {"author": {"name": "example@datadog.com", "type": "user"}, "change_metadata": {"dd": {"team": "datadog_team", "user_email": "datadog@datadog.com", "user_id": "datadog_user_id", "user_name": "datadog_username"}, "resource_link": "datadog.com/feature/fallback_payments_test"}, "changed_resource": {"name": "fallback_payments_test", "type": "feature_flag"}, "impacted_resources": [{"name": "payments_api", "type": "service"}], "new_value": {"enabled": true, "percentage": "50%", "rule": {"datacenter": "devcycle.us1.prod"}}, "prev_value": {"enabled": true, "percentage": "10%", "rule": {"datacenter": "devcycle.us1.prod"}}}, "category": "invalid", "integration_id": "custom-events", "host": "test-host", "message": "payment_processed feature flag has been enabled", "tags": ["env:api_client_test"], "title": "payment_processed feature flag updated"}, "type": "event"}}
7878
When the request is sent
7979
Then the response status is 400 Bad request
8080

8181
@skip-validation @team:DataDog/event-management
8282
Scenario: Post an event returns "OK" response
8383
Given new "CreateEvent" request
84-
And body with value {"data": {"attributes": {"aggregation_key": "aggregation_key_123", "attributes": {"author": {"name": "example@datadog.com", "type": "user"}, "change_metadata": {"dd": {"team": "datadog_team", "user_email": "datadog@datadog.com", "user_id": "datadog_user_id", "user_name": "datadog_username"}, "resource_link": "datadog.com/feature/fallback_payments_test"}, "changed_resource": {"name": "fallback_payments_test", "type": "feature_flag"}, "impacted_resources": [{"name": "payments_api", "type": "service"}], "new_value": {"enabled": true, "percentage": "50%", "rule": {"datacenter": "devcycle.us1.prod"}}, "prev_value": {"enabled": true, "percentage": "10%", "rule": {"datacenter": "devcycle.us1.prod"}}}, "category": "change", "integration_id": "custom-events", "message": "payment_processed feature flag has been enabled", "tags": ["env:api_client_test"], "title": "payment_processed feature flag updated"}, "type": "event"}}
84+
And body with value {"data": {"attributes": {"aggregation_key": "aggregation_key_123", "attributes": {"author": {"name": "example@datadog.com", "type": "user"}, "change_metadata": {"dd": {"team": "datadog_team", "user_email": "datadog@datadog.com", "user_id": "datadog_user_id", "user_name": "datadog_username"}, "resource_link": "datadog.com/feature/fallback_payments_test"}, "changed_resource": {"name": "fallback_payments_test", "type": "feature_flag"}, "impacted_resources": [{"name": "payments_api", "type": "service"}], "new_value": {"enabled": true, "percentage": "50%", "rule": {"datacenter": "devcycle.us1.prod"}}, "prev_value": {"enabled": true, "percentage": "10%", "rule": {"datacenter": "devcycle.us1.prod"}}}, "category": "change", "integration_id": "custom-events", "host": "test-host", "message": "payment_processed feature flag has been enabled", "tags": ["env:api_client_test"], "title": "payment_processed feature flag updated"}, "type": "event"}}
8585
When the request is sent
8686
Then the response status is 202 OK
8787
And the response "data.type" is equal to "event"

0 commit comments

Comments
 (0)