Skip to content

Commit 177d72f

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

File tree

8 files changed

+28
-7
lines changed

8 files changed

+28
-7
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.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@
6363
),
6464
category=EventCategory.CHANGE,
6565
integration_id=EventPayloadIntegrationId.CUSTOM_EVENTS,
66+
host="test-host",
6667
message="payment_processed feature flag has been enabled",
6768
tags=[
6869
"env:api_client_test",

src/datadog_api_client/v2/model/event_payload.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,10 @@ class EventPayload(ModelNormal):
2727
"max_length": 100,
2828
"min_length": 1,
2929
},
30+
"host": {
31+
"max_length": 255,
32+
"min_length": 1,
33+
},
3034
"message": {
3135
"max_length": 4000,
3236
"min_length": 1,
@@ -55,6 +59,7 @@ def openapi_types(_):
5559
"aggregation_key": (str,),
5660
"attributes": (EventPayloadAttributes,),
5761
"category": (EventCategory,),
62+
"host": (str,),
5863
"integration_id": (EventPayloadIntegrationId,),
5964
"message": (str,),
6065
"tags": ([str],),
@@ -66,6 +71,7 @@ def openapi_types(_):
6671
"aggregation_key": "aggregation_key",
6772
"attributes": "attributes",
6873
"category": "category",
74+
"host": "host",
6975
"integration_id": "integration_id",
7076
"message": "message",
7177
"tags": "tags",
@@ -79,6 +85,7 @@ def __init__(
7985
category: EventCategory,
8086
title: str,
8187
aggregation_key: Union[str, UnsetType] = unset,
88+
host: Union[str, UnsetType] = unset,
8289
integration_id: Union[EventPayloadIntegrationId, UnsetType] = unset,
8390
message: Union[str, UnsetType] = unset,
8491
tags: Union[List[str], UnsetType] = unset,
@@ -97,6 +104,9 @@ def __init__(
97104
:param category: Event category identifying the type of event.
98105
:type category: EventCategory
99106
107+
:param host: Host name to associate with the event. Any tags associated with the host are also applied to this event. Limited to 255 characters.
108+
:type host: str, optional
109+
100110
:param integration_id: Integration ID sourced from integration manifests.
101111
:type integration_id: EventPayloadIntegrationId, optional
102112
@@ -117,6 +127,8 @@ def __init__(
117127
"""
118128
if aggregation_key is not unset:
119129
kwargs["aggregation_key"] = aggregation_key
130+
if host is not unset:
131+
kwargs["host"] = host
120132
if integration_id is not unset:
121133
kwargs["integration_id"] = integration_id
122134
if message is not unset:
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/v2/cassettes/test_scenarios/test_post_an_event_returns_bad_request_response.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
interactions:
22
- request:
3-
body: '{"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
3+
body: '{"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
44
feature flag has been enabled","tags":["env:api_client_test"],"title":"payment_processed
55
feature flag updated"},"type":"event"}}'
66
headers:
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/v2/cassettes/test_scenarios/test_post_an_event_returns_ok_response.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
interactions:
22
- request:
3-
body: '{"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
3+
body: '{"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
44
feature flag has been enabled","tags":["env:api_client_test"],"title":"payment_processed
55
feature flag updated"},"type":"event"}}'
66
headers:
@@ -12,7 +12,7 @@ interactions:
1212
uri: https://event-management-intake.datadoghq.com/api/v2/events
1313
response:
1414
body:
15-
string: '{"data":{"attributes":{"attributes":{"evt":{"uid":"AZdafqaTAACKG_iMQ82pmAAA"}}},"id":"_","type":"event"},"links":{"self":"https://app.datadoghq.com/event/event?uid=AZdafqaTAACKG_iMQ82pmAAA"}}'
15+
string: '{"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

tests/v2/features/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)