diff --git a/.generator/schemas/v2/openapi.yaml b/.generator/schemas/v2/openapi.yaml index 7760d58c0..121f52ef3 100644 --- a/.generator/schemas/v2/openapi.yaml +++ b/.generator/schemas/v2/openapi.yaml @@ -20219,6 +20219,13 @@ components: $ref: '#/components/schemas/EventPayloadAttributes' category: $ref: '#/components/schemas/EventCategory' + host: + description: Host name to associate with the event. Any tags associated + with the host are also applied to this event. Limited to 255 characters. + example: hostname + maxLength: 255 + minLength: 1 + type: string integration_id: $ref: '#/components/schemas/EventPayloadIntegrationId' message: @@ -67608,6 +67615,7 @@ paths: rule: datacenter: devcycle.us1.prod category: change + host: hostname integration_id: custom-events message: payment_processed feature flag has been enabled tags: diff --git a/examples/v2_events_CreateEvent.rs b/examples/v2_events_CreateEvent.rs index 033ceb04b..b7a99475b 100644 --- a/examples/v2_events_CreateEvent.rs +++ b/examples/v2_events_CreateEvent.rs @@ -54,6 +54,7 @@ async fn main() { "payment_processed feature flag updated".to_string(), ) .aggregation_key("aggregation_key_123".to_string()) + .host("test-host".to_string()) .integration_id(EventPayloadIntegrationId::CUSTOM_EVENTS) .message("payment_processed feature flag has been enabled".to_string()) .tags(vec!["env:api_client_test".to_string()]), diff --git a/src/datadogV2/model/model_event_payload.rs b/src/datadogV2/model/model_event_payload.rs index 7c73d2495..852314d60 100644 --- a/src/datadogV2/model/model_event_payload.rs +++ b/src/datadogV2/model/model_event_payload.rs @@ -20,6 +20,9 @@ pub struct EventPayload { /// Event category identifying the type of event. #[serde(rename = "category")] pub category: crate::datadogV2::model::EventCategory, + /// Host name to associate with the event. Any tags associated with the host are also applied to this event. Limited to 255 characters. + #[serde(rename = "host")] + pub host: Option, /// Integration ID sourced from integration manifests. #[serde(rename = "integration_id")] pub integration_id: Option, @@ -53,6 +56,7 @@ impl EventPayload { aggregation_key: None, attributes, category, + host: None, integration_id: None, message: None, tags: None, @@ -67,6 +71,11 @@ impl EventPayload { self } + pub fn host(mut self, value: String) -> Self { + self.host = Some(value); + self + } + pub fn integration_id( mut self, value: crate::datadogV2::model::EventPayloadIntegrationId, @@ -111,6 +120,7 @@ impl<'de> Deserialize<'de> for EventPayload { let mut aggregation_key: Option = None; let mut attributes: Option = None; let mut category: Option = None; + let mut host: Option = None; let mut integration_id: Option = None; let mut message: Option = None; @@ -152,6 +162,12 @@ impl<'de> Deserialize<'de> for EventPayload { } } } + "host" => { + if v.is_null() { + continue; + } + host = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } "integration_id" => { if v.is_null() { continue; @@ -203,6 +219,7 @@ impl<'de> Deserialize<'de> for EventPayload { aggregation_key, attributes, category, + host, integration_id, message, tags, diff --git a/tests/scenarios/cassettes/v2/events/Post-an-event-returns-Bad-request-response.frozen b/tests/scenarios/cassettes/v2/events/Post-an-event-returns-Bad-request-response.frozen index a1cd4e8e4..a69ab2449 100644 --- a/tests/scenarios/cassettes/v2/events/Post-an-event-returns-Bad-request-response.frozen +++ b/tests/scenarios/cassettes/v2/events/Post-an-event-returns-Bad-request-response.frozen @@ -1 +1 @@ -2025-06-10T15:38:58.529Z \ No newline at end of file +2025-12-10T21:31:06.468Z \ No newline at end of file diff --git a/tests/scenarios/cassettes/v2/events/Post-an-event-returns-Bad-request-response.json b/tests/scenarios/cassettes/v2/events/Post-an-event-returns-Bad-request-response.json index 006c1d064..2c852c339 100644 --- a/tests/scenarios/cassettes/v2/events/Post-an-event-returns-Bad-request-response.json +++ b/tests/scenarios/cassettes/v2/events/Post-an-event-returns-Bad-request-response.json @@ -3,7 +3,7 @@ { "request": { "body": { - "string": "{\"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\"}}", + "string": "{\"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\"}}", "encoding": null }, "headers": { @@ -32,7 +32,7 @@ "message": "Bad Request" } }, - "recorded_at": "Tue, 10 Jun 2025 15:38:58 GMT" + "recorded_at": "Wed, 10 Dec 2025 21:31:06 GMT" } ], "recorded_with": "VCR 6.0.0" diff --git a/tests/scenarios/cassettes/v2/events/Post-an-event-returns-OK-response.frozen b/tests/scenarios/cassettes/v2/events/Post-an-event-returns-OK-response.frozen index 42309286e..36850703b 100644 --- a/tests/scenarios/cassettes/v2/events/Post-an-event-returns-OK-response.frozen +++ b/tests/scenarios/cassettes/v2/events/Post-an-event-returns-OK-response.frozen @@ -1 +1 @@ -2025-06-10T15:38:58.954Z \ No newline at end of file +2025-12-10T21:30:25.683Z \ No newline at end of file diff --git a/tests/scenarios/cassettes/v2/events/Post-an-event-returns-OK-response.json b/tests/scenarios/cassettes/v2/events/Post-an-event-returns-OK-response.json index 9e7d70dd6..27aeff165 100644 --- a/tests/scenarios/cassettes/v2/events/Post-an-event-returns-OK-response.json +++ b/tests/scenarios/cassettes/v2/events/Post-an-event-returns-OK-response.json @@ -3,7 +3,7 @@ { "request": { "body": { - "string": "{\"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\"}}", + "string": "{\"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\"}}", "encoding": null }, "headers": { @@ -19,7 +19,7 @@ }, "response": { "body": { - "string": "{\"data\":{\"attributes\":{\"attributes\":{\"evt\":{\"uid\":\"AZdafqaTAACKG_iMQ82pmAAA\"}}},\"id\":\"_\",\"type\":\"event\"},\"links\":{\"self\":\"https://app.datadoghq.com/event/event?uid=AZdafqaTAACKG_iMQ82pmAAA\"}}", + "string": "{\"data\":{\"attributes\":{\"attributes\":{\"evt\":{\"id\":\"8407723285051133019\",\"uid\":\"AZsKLCxvAACrUQTfNDwMWwAA\"}}},\"id\":\"_\",\"type\":\"event\"},\"links\":{\"self\":\"https://app.datadoghq.com/event/event?uid=AZsKLCxvAACrUQTfNDwMWwAA\"}}", "encoding": null }, "headers": { @@ -32,7 +32,7 @@ "message": "Accepted" } }, - "recorded_at": "Tue, 10 Jun 2025 15:38:58 GMT" + "recorded_at": "Wed, 10 Dec 2025 21:30:25 GMT" } ], "recorded_with": "VCR 6.0.0" diff --git a/tests/scenarios/features/v2/events.feature b/tests/scenarios/features/v2/events.feature index 61d824ce1..5beda13d5 100644 --- a/tests/scenarios/features/v2/events.feature +++ b/tests/scenarios/features/v2/events.feature @@ -74,14 +74,14 @@ Feature: Events @team:DataDog/event-management Scenario: Post an event returns "Bad request" response Given new "CreateEvent" request - 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"}} + 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"}} When the request is sent Then the response status is 400 Bad request @skip-validation @team:DataDog/event-management Scenario: Post an event returns "OK" response Given new "CreateEvent" request - 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"}} + 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"}} When the request is sent Then the response status is 202 OK And the response "data.type" is equal to "event"