Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add API specification for events intake v2 #334

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions .apigentools-info
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@
"spec_versions": {
"v1": {
"apigentools_version": "1.6.6",
"regenerated": "2024-11-20 21:48:42.107867",
"spec_repo_commit": "34905ccb"
"regenerated": "2024-11-21 20:23:39.100315",
"spec_repo_commit": "ad36259c"
},
"v2": {
"apigentools_version": "1.6.6",
"regenerated": "2024-11-20 21:48:42.126846",
"spec_repo_commit": "34905ccb"
"regenerated": "2024-11-21 20:23:39.119286",
"spec_repo_commit": "ad36259c"
}
}
}
316 changes: 316 additions & 0 deletions .generator/schemas/v2/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4556,6 +4556,127 @@ components:
format: int64
type: integer
type: object
ChangeEventCustomAttributes:
description: Object representing custom change event attributes.
properties:
author:
$ref: '#/components/schemas/ChangeEventCustomAttributesAuthor'
change_metadata:
additionalProperties: {}
description: Free form object with information related to the `change` event.
Can be arbitrarily nested and contain any valid JSON.
example:
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
type: object
changed_resource:
$ref: '#/components/schemas/ChangeEventCustomAttributesChangedResource'
impacted_resources:
description: 'A list of resources impacted by this change. It is recommended
to provide an impacted resource to display

the change event at the right location. Only resources of type `service`
are supported.'
example:
- name: payments_api
type: service
items:
$ref: '#/components/schemas/ChangeEventCustomAttributesImpactedResourcesItems'
type: array
new_value:
additionalProperties: {}
description: Free form object to track new value of the changed resource.
example:
enabled: true
percentage: 50%
rule:
datacenter: devcycle.us1.prod
type: object
prev_value:
additionalProperties: {}
description: Free form object to track previous value of the changed resource.
example:
enabled: true
percentage: 10%
rule:
datacenter: devcycle.us1.prod
type: object
required:
- changed_resource
type: object
ChangeEventCustomAttributesAuthor:
description: Object representing the entity which made the change. Optional
field but if provided should include `type` and `name`.
properties:
name:
description: Author's name. Limited to 128 characters.
example: datadog@datadog.com
maxLength: 128
type: string
type:
$ref: '#/components/schemas/ChangeEventCustomAttributesAuthorType'
required:
- name
- type
type: object
ChangeEventCustomAttributesAuthorType:
description: Author's type.
enum:
- user
- system
example: user
type: string
x-enum-varnames:
- USER
- SYSTEM
ChangeEventCustomAttributesChangedResource:
description: Object representing a uniquely identified resource. Only the resource
type `feature_flag` is supported.
properties:
name:
description: Resource's name.
example: fallback_payments_test
type: string
type:
$ref: '#/components/schemas/ChangeEventCustomAttributesChangedResourceType'
required:
- type
- name
type: object
ChangeEventCustomAttributesChangedResourceType:
description: Resource's type.
enum:
- feature_flag
example: feature_flag
type: string
x-enum-varnames:
- FEATURE_FLAG
ChangeEventCustomAttributesImpactedResourcesItems:
description: Object representing a uniquely identified resource. Only the resource
type `service` is supported.
properties:
name:
description: Resource's name.
example: payments_api
type: string
type:
$ref: '#/components/schemas/ChangeEventCustomAttributesImpactedResourcesItemsType'
required:
- type
- name
type: object
ChangeEventCustomAttributesImpactedResourcesItemsType:
description: Resource's type.
enum:
- service
example: service
type: string
x-enum-varnames:
- SERVICE
ChargebackBreakdown:
description: Charges breakdown.
properties:
Expand Down Expand Up @@ -9335,6 +9456,125 @@ components:
example: Oh boy!
type: string
type: object
EventCategory:
description: Event category to identify the type of event. Only the value `change`
is supported. Support for other categories are coming. please reach out to
datadog support if you're interested.
enum:
- change
example: change
type: string
x-enum-varnames:
- CHANGE
EventCreateRequest:
description: Object representing an event creation request.
properties:
attributes:
$ref: '#/components/schemas/EventPayload'
type:
$ref: '#/components/schemas/EventCreateRequestType'
type: object
EventCreateRequestPayload:
description: Payload for creating an event.
properties:
data:
$ref: '#/components/schemas/EventCreateRequest'
type: object
EventCreateRequestType:
description: Entity type.
enum:
- event
example: event
type: string
x-enum-varnames:
- EVENT
EventCreateResponse:
description: Object containing an event response.
properties:
attributes:
$ref: '#/components/schemas/EventCreateResponseAttributes'
type:
description: Event type
example: event
type: string
type: object
EventCreateResponseAttributes:
description: JSON object containing all events attributes and their associated
values.
properties:
attributes:
$ref: '#/components/schemas/EventCreateResponseAttributesAttributes'
type: object
EventCreateResponseAttributesAttributes:
description: JSON object of attributes from your events.
properties:
evt:
$ref: '#/components/schemas/EventCreateResponseAttributesAttributesEvt'
type: object
EventCreateResponseAttributesAttributesEvt:
description: JSON object of event system attributes.
properties:
id:
description: Event id
type: string
type: object
EventCreateResponsePayload:
description: Response containing information about created event.
properties:
data:
$ref: '#/components/schemas/EventCreateResponse'
type: object
EventPayload:
description: Event attributes.
properties:
aggregation_key:
description: An arbitrary string to use for aggregation when correlating
events. Limited to 100 characters.
maxLength: 100
type: string
attributes:
$ref: '#/components/schemas/EventPayloadAttributes'
category:
$ref: '#/components/schemas/EventCategory'
message:
description: The body of the event. Limited to 4000 characters.
example: payment_processed feature flag has been enabled
maxLength: 4000
type: string
tags:
description: 'A list of tags to apply to the event.

Refer to [Tags docs](https://docs.datadoghq.com/getting_started/tagging/).'
example:
- environment:test
items:
description: A tag.
type: string
type: array
timestamp:
description: 'Timestamp when the event occurred. Must follow [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html)
format.

For example `"2017-01-15T01:30:15.010000Z"`.

Defaults to the timestamp of receipt. Limited to values no older than
18 hours.'
type: string
title:
description: The event title. Limited to 500 characters.
example: payment_processed feature flag updated
maxLength: 500
type: string
required:
- title
- category
- attributes
type: object
EventPayloadAttributes:
description: JSON object for custom attributes. Schema are different per each
event category.
oneOf:
- $ref: '#/components/schemas/ChangeEventCustomAttributes'
EventPriority:
description: The priority of the event's monitor. For example, `normal` or `low`.
enum:
Expand Down Expand Up @@ -31196,6 +31436,82 @@ paths:
operator: OR
permissions:
- events_read
post:
description: This endpoint allows you to post events. Only events with `change`
category are under General Availability.
operationId: CreateEvent
requestBody:
content:
application/json:
examples:
json-request-body:
value:
data:
attributes:
attributes:
author:
name: datadog@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
message: payment_processed feature flag has been enabled
tags:
- environment:test
title: payment_processed feature flag updated
type: event
schema:
$ref: '#/components/schemas/EventCreateRequestPayload'
description: Event request object
required: true
responses:
'200':
content:
application/json:
schema:
$ref: '#/components/schemas/EventCreateResponsePayload'
description: OK
'400':
content:
application/json:
schema:
$ref: '#/components/schemas/JSONAPIErrorResponse'
description: Bad request
'403':
content:
application/json:
schema:
$ref: '#/components/schemas/JSONAPIErrorResponse'
description: Forbidden
'429':
$ref: '#/components/responses/TooManyRequestsResponse'
security:
- apiKeyAuth: []
summary: Post an event
tags:
- Events
x-codegen-request-body-name: body
/api/v2/events/search:
post:
description: 'List endpoint returns events that match an events search query.
Expand Down
7 changes: 5 additions & 2 deletions .generator/src/generator/formatter.py
Original file line number Diff line number Diff line change
Expand Up @@ -624,10 +624,13 @@ def format_data_with_schema_dict(
imports.add("std::collections::BTreeMap")
if schema.get("additionalProperties") == {}:
for k, v in data.items():
if isinstance(v, (int, float)):
if isinstance(v, bool):
imports.add("serde_json::Value")
parameters += f'("{k}".to_string(), Value::from(\"{v}\")),'
elif isinstance(v, (int, float)):
imports.add("serde_json::Value")
parameters += f'("{k}".to_string(), Value::from({v})),'
if isinstance(v, str):
elif isinstance(v, str):
imports.add("serde_json::Value")
parameters += f'("{k}".to_string(), Value::from(\"{v}\")),'
return f"BTreeMap::from([{parameters}])", imports
Expand Down
Loading
Loading