Skip to content

Commit e72bde0

Browse files
api-clients-generation-pipeline[bot]ci.datadog-api-spec
andauthored
Add host field to Post an event V2 API (#1076)
Co-authored-by: ci.datadog-api-spec <[email protected]>
1 parent 5b467e3 commit e72bde0

File tree

8 files changed

+35
-9
lines changed

8 files changed

+35
-9
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.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ async fn main() {
5454
"payment_processed feature flag updated".to_string(),
5555
)
5656
.aggregation_key("aggregation_key_123".to_string())
57+
.host("test-host".to_string())
5758
.integration_id(EventPayloadIntegrationId::CUSTOM_EVENTS)
5859
.message("payment_processed feature flag has been enabled".to_string())
5960
.tags(vec!["env:api_client_test".to_string()]),

src/datadogV2/model/model_event_payload.rs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@ pub struct EventPayload {
2020
/// Event category identifying the type of event.
2121
#[serde(rename = "category")]
2222
pub category: crate::datadogV2::model::EventCategory,
23+
/// Host name to associate with the event. Any tags associated with the host are also applied to this event. Limited to 255 characters.
24+
#[serde(rename = "host")]
25+
pub host: Option<String>,
2326
/// Integration ID sourced from integration manifests.
2427
#[serde(rename = "integration_id")]
2528
pub integration_id: Option<crate::datadogV2::model::EventPayloadIntegrationId>,
@@ -53,6 +56,7 @@ impl EventPayload {
5356
aggregation_key: None,
5457
attributes,
5558
category,
59+
host: None,
5660
integration_id: None,
5761
message: None,
5862
tags: None,
@@ -67,6 +71,11 @@ impl EventPayload {
6771
self
6872
}
6973

74+
pub fn host(mut self, value: String) -> Self {
75+
self.host = Some(value);
76+
self
77+
}
78+
7079
pub fn integration_id(
7180
mut self,
7281
value: crate::datadogV2::model::EventPayloadIntegrationId,
@@ -111,6 +120,7 @@ impl<'de> Deserialize<'de> for EventPayload {
111120
let mut aggregation_key: Option<String> = None;
112121
let mut attributes: Option<crate::datadogV2::model::EventPayloadAttributes> = None;
113122
let mut category: Option<crate::datadogV2::model::EventCategory> = None;
123+
let mut host: Option<String> = None;
114124
let mut integration_id: Option<crate::datadogV2::model::EventPayloadIntegrationId> =
115125
None;
116126
let mut message: Option<String> = None;
@@ -152,6 +162,12 @@ impl<'de> Deserialize<'de> for EventPayload {
152162
}
153163
}
154164
}
165+
"host" => {
166+
if v.is_null() {
167+
continue;
168+
}
169+
host = Some(serde_json::from_value(v).map_err(M::Error::custom)?);
170+
}
155171
"integration_id" => {
156172
if v.is_null() {
157173
continue;
@@ -203,6 +219,7 @@ impl<'de> Deserialize<'de> for EventPayload {
203219
aggregation_key,
204220
attributes,
205221
category,
222+
host,
206223
integration_id,
207224
message,
208225
tags,
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

tests/scenarios/cassettes/v2/events/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
{
44
"request": {
55
"body": {
6-
"string": "{\"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/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+
"string": "{\"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/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
"encoding": null
88
},
99
"headers": {
@@ -32,7 +32,7 @@
3232
"message": "Bad Request"
3333
}
3434
},
35-
"recorded_at": "Tue, 10 Jun 2025 15:38:58 GMT"
35+
"recorded_at": "Wed, 10 Dec 2025 21:31:06 GMT"
3636
}
3737
],
3838
"recorded_with": "VCR 6.0.0"
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

tests/scenarios/cassettes/v2/events/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
{
44
"request": {
55
"body": {
6-
"string": "{\"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/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+
"string": "{\"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/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
"encoding": null
88
},
99
"headers": {
@@ -19,7 +19,7 @@
1919
},
2020
"response": {
2121
"body": {
22-
"string": "{\"data\":{\"attributes\":{\"attributes\":{\"evt\":{\"uid\":\"AZdafqaTAACKG_iMQ82pmAAA\"}}},\"id\":\"_\",\"type\":\"event\"},\"links\":{\"self\":\"https://app.datadoghq.com/event/event?uid=AZdafqaTAACKG_iMQ82pmAAA\"}}",
22+
"string": "{\"data\":{\"attributes\":{\"attributes\":{\"evt\":{\"id\":\"8407723285051133019\",\"uid\":\"AZsKLCxvAACrUQTfNDwMWwAA\"}}},\"id\":\"_\",\"type\":\"event\"},\"links\":{\"self\":\"https://app.datadoghq.com/event/event?uid=AZsKLCxvAACrUQTfNDwMWwAA\"}}",
2323
"encoding": null
2424
},
2525
"headers": {
@@ -32,7 +32,7 @@
3232
"message": "Accepted"
3333
}
3434
},
35-
"recorded_at": "Tue, 10 Jun 2025 15:38:58 GMT"
35+
"recorded_at": "Wed, 10 Dec 2025 21:30:25 GMT"
3636
}
3737
],
3838
"recorded_with": "VCR 6.0.0"

tests/scenarios/features/v2/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": "[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/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": "[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/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": "[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/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": "[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/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)