Skip to content

Commit ea3b5ba

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

File tree

8 files changed

+44
-10
lines changed

8 files changed

+44
-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:
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

cassettes/features/v2/events/Post-an-event-returns-Bad-request-response.yml

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
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

cassettes/features/v2/events/Post-an-event-returns-OK-response.yml

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

examples/v2/events/CreateEvent.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
}),
3535
category: DatadogAPIClient::V2::EventCategory::CHANGE,
3636
integration_id: DatadogAPIClient::V2::EventPayloadIntegrationId::CUSTOM_EVENTS,
37+
host: "test-host",
3738
message: "payment_processed feature flag has been enabled",
3839
tags: [
3940
"env:api_client_test",

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": "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"

lib/datadog_api_client/v2/models/event_payload.rb

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,9 @@ class EventPayload
3030
# Event category identifying the type of event.
3131
attr_reader :category
3232

33+
# Host name to associate with the event. Any tags associated with the host are also applied to this event. Limited to 255 characters.
34+
attr_reader :host
35+
3336
# Integration ID sourced from integration manifests.
3437
attr_accessor :integration_id
3538

@@ -55,6 +58,7 @@ def self.attribute_map
5558
:'aggregation_key' => :'aggregation_key',
5659
:'attributes' => :'attributes',
5760
:'category' => :'category',
61+
:'host' => :'host',
5862
:'integration_id' => :'integration_id',
5963
:'message' => :'message',
6064
:'tags' => :'tags',
@@ -70,6 +74,7 @@ def self.openapi_types
7074
:'aggregation_key' => :'String',
7175
:'attributes' => :'EventPayloadAttributes',
7276
:'category' => :'EventCategory',
77+
:'host' => :'String',
7378
:'integration_id' => :'EventPayloadIntegrationId',
7479
:'message' => :'String',
7580
:'tags' => :'Array<String>',
@@ -106,6 +111,10 @@ def initialize(attributes = {})
106111
self.category = attributes[:'category']
107112
end
108113

114+
if attributes.key?(:'host')
115+
self.host = attributes[:'host']
116+
end
117+
109118
if attributes.key?(:'integration_id')
110119
self.integration_id = attributes[:'integration_id']
111120
end
@@ -137,6 +146,8 @@ def valid?
137146
return false if !@aggregation_key.nil? && @aggregation_key.to_s.length < 1
138147
return false if @attributes.nil?
139148
return false if @category.nil?
149+
return false if !@host.nil? && @host.to_s.length > 255
150+
return false if !@host.nil? && @host.to_s.length < 1
140151
return false if !@message.nil? && @message.to_s.length > 4000
141152
return false if !@message.nil? && @message.to_s.length < 1
142153
return false if !@tags.nil? && @tags.length > 100
@@ -180,6 +191,19 @@ def category=(category)
180191
@category = category
181192
end
182193

194+
# Custom attribute writer method with validation
195+
# @param host [Object] Object to be assigned
196+
# @!visibility private
197+
def host=(host)
198+
if !host.nil? && host.to_s.length > 255
199+
fail ArgumentError, 'invalid value for "host", the character length must be smaller than or equal to 255.'
200+
end
201+
if !host.nil? && host.to_s.length < 1
202+
fail ArgumentError, 'invalid value for "host", the character length must be great than or equal to 1.'
203+
end
204+
@host = host
205+
end
206+
183207
# Custom attribute writer method with validation
184208
# @param message [Object] Object to be assigned
185209
# @!visibility private
@@ -231,6 +255,7 @@ def ==(o)
231255
aggregation_key == o.aggregation_key &&
232256
attributes == o.attributes &&
233257
category == o.category &&
258+
host == o.host &&
234259
integration_id == o.integration_id &&
235260
message == o.message &&
236261
tags == o.tags &&
@@ -242,7 +267,7 @@ def ==(o)
242267
# @return [Integer] Hash code
243268
# @!visibility private
244269
def hash
245-
[aggregation_key, attributes, category, integration_id, message, tags, timestamp, title].hash
270+
[aggregation_key, attributes, category, host, integration_id, message, tags, timestamp, title].hash
246271
end
247272
end
248273
end

0 commit comments

Comments
 (0)