-
Notifications
You must be signed in to change notification settings - Fork 20
Expand file tree
/
Copy pathCreateEvent.rb
More file actions
47 lines (45 loc) · 2.08 KB
/
Copy pathCreateEvent.rb
File metadata and controls
47 lines (45 loc) · 2.08 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# Post an event returns "OK" response
require "datadog_api_client"
api_instance = DatadogAPIClient::V2::EventsAPI.new
body = DatadogAPIClient::V2::EventCreateRequestPayload.new({
data: DatadogAPIClient::V2::EventCreateRequest.new({
attributes: DatadogAPIClient::V2::EventPayload.new({
aggregation_key: "aggregation_key_123",
attributes: DatadogAPIClient::V2::ChangeEventCustomAttributes.new({
author: DatadogAPIClient::V2::ChangeEventCustomAttributesAuthor.new({
name: "example@datadog.com",
type: DatadogAPIClient::V2::ChangeEventCustomAttributesAuthorType::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: DatadogAPIClient::V2::ChangeEventCustomAttributesChangedResource.new({
name: "fallback_payments_test",
type: DatadogAPIClient::V2::ChangeEventCustomAttributesChangedResourceType::FEATURE_FLAG,
}),
impacted_resources: [
DatadogAPIClient::V2::ChangeEventCustomAttributesImpactedResourcesItems.new({
name: "payments_api",
type: DatadogAPIClient::V2::ChangeEventCustomAttributesImpactedResourcesItemsType::SERVICE,
}),
],
new_value: {
"enabled": "True", "percentage": "50%", "rule": "{'datacenter': 'devcycle.us1.prod'}",
},
prev_value: {
"enabled": "True", "percentage": "10%", "rule": "{'datacenter': 'devcycle.us1.prod'}",
},
}),
category: DatadogAPIClient::V2::EventCategory::CHANGE,
integration_id: DatadogAPIClient::V2::EventPayloadIntegrationId::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: DatadogAPIClient::V2::EventCreateRequestType::EVENT,
}),
})
p api_instance.create_event(body)