From 680587be8388af9afc048a2436d51c8586d7711e Mon Sep 17 00:00:00 2001 From: "ci.datadog-api-spec" Date: Fri, 9 May 2025 01:02:15 +0000 Subject: [PATCH] Regenerate client from commit 9f916c56 of spec repo --- .apigentools-info | 8 +- .generator/schemas/v2/openapi.yaml | 173 +++++++++++++++++- docs/datadog_api_client.v2.model.rst | 56 ++++++ examples/v2/events/CreateEvent.py | 3 + src/datadog_api_client/v2/api/events_api.py | 51 +++++- .../v2/model/alert_event_custom_attributes.py | 93 ++++++++++ .../alert_event_custom_attributes_custom.py | 17 ++ ...ert_event_custom_attributes_links_items.py | 74 ++++++++ ..._custom_attributes_links_items_category.py | 35 ++++ .../alert_event_custom_attributes_priority.py | 47 +++++ .../alert_event_custom_attributes_status.py | 44 +++++ .../v2/model/event_category.py | 7 +- .../v2/model/event_create_request.py | 22 +-- .../v2/model/event_create_request_payload.py | 12 +- .../v2/model/event_create_response.py | 8 + ...eate_response_attributes_attributes_evt.py | 14 +- .../v2/model/event_create_response_payload.py | 16 +- .../event_create_response_payload_links.py | 36 ++++ .../v2/model/event_payload.py | 19 +- .../v2/model/event_payload_attributes.py | 14 ++ .../v2/model/event_payload_integration_id.py | 35 ++++ src/datadog_api_client/v2/models/__init__.py | 18 ++ tests/v2/features/events.feature | 6 +- 23 files changed, 759 insertions(+), 49 deletions(-) create mode 100644 src/datadog_api_client/v2/model/alert_event_custom_attributes.py create mode 100644 src/datadog_api_client/v2/model/alert_event_custom_attributes_custom.py create mode 100644 src/datadog_api_client/v2/model/alert_event_custom_attributes_links_items.py create mode 100644 src/datadog_api_client/v2/model/alert_event_custom_attributes_links_items_category.py create mode 100644 src/datadog_api_client/v2/model/alert_event_custom_attributes_priority.py create mode 100644 src/datadog_api_client/v2/model/alert_event_custom_attributes_status.py create mode 100644 src/datadog_api_client/v2/model/event_create_response_payload_links.py create mode 100644 src/datadog_api_client/v2/model/event_payload_integration_id.py diff --git a/.apigentools-info b/.apigentools-info index 06153259c8..fa7f10b56d 100644 --- a/.apigentools-info +++ b/.apigentools-info @@ -4,13 +4,13 @@ "spec_versions": { "v1": { "apigentools_version": "1.6.6", - "regenerated": "2025-05-08 14:34:53.291523", - "spec_repo_commit": "4b632dba" + "regenerated": "2025-05-09 01:01:36.764757", + "spec_repo_commit": "9f916c56" }, "v2": { "apigentools_version": "1.6.6", - "regenerated": "2025-05-08 14:34:53.311445", - "spec_repo_commit": "4b632dba" + "regenerated": "2025-05-09 01:01:36.781509", + "spec_repo_commit": "9f916c56" } } } \ No newline at end of file diff --git a/.generator/schemas/v2/openapi.yaml b/.generator/schemas/v2/openapi.yaml index 976fac306b..2f7184f5bc 100644 --- a/.generator/schemas/v2/openapi.yaml +++ b/.generator/schemas/v2/openapi.yaml @@ -2138,6 +2138,89 @@ components: - id - base_severity type: object + AlertEventCustomAttributes: + additionalProperties: false + description: Object representing custom alert event attributes. + properties: + custom: + $ref: '#/components/schemas/AlertEventCustomAttributesCustom' + links: + $ref: '#/components/schemas/AlertEventCustomAttributesLinks' + priority: + $ref: '#/components/schemas/AlertEventCustomAttributesPriority' + status: + $ref: '#/components/schemas/AlertEventCustomAttributesStatus' + type: object + AlertEventCustomAttributesCustom: + additionalProperties: {} + description: Custom attributes. Support up to 100 properties and a maximum nesting + depth of 10 levels. + example: {} + type: object + AlertEventCustomAttributesLinks: + description: The links related to the event. + items: + $ref: '#/components/schemas/AlertEventCustomAttributesLinksItems' + maxItems: 20 + minItems: 1 + type: array + AlertEventCustomAttributesLinksItems: + description: A link. + properties: + category: + $ref: '#/components/schemas/AlertEventCustomAttributesLinksItemsCategory' + title: + description: The title of the link. Limited to 300 characters. + example: Runbook Link + maxLength: 300 + type: string + url: + description: The URL of the link. Limited to 2048 characters. + example: https://app.datadoghq.com/runbook + maxLength: 2048 + type: string + required: + - url + - category + type: object + AlertEventCustomAttributesLinksItemsCategory: + description: The category of the link. + enum: + - runbook + example: runbook + type: string + x-enum-varnames: + - RUNBOOK + AlertEventCustomAttributesPriority: + description: The priority of the alert. + enum: + - '1' + - '2' + - '3' + - '4' + - '5' + example: '1' + type: string + x-enum-varnames: + - PRIORITY_ONE + - PRIORITY_TWO + - PRIORITY_THREE + - PRIORITY_FOUR + - PRIORITY_FIVE + AlertEventCustomAttributesStatus: + description: The status of the alert. + enum: + - info + - warn + - error + - ok + example: warn + type: string + x-enum-varnames: + - INFO + - WARN + - ERROR + - OK Annotation: description: A list of annotations used in the workflow. These are like sticky notes for your workflow! @@ -13904,15 +13987,16 @@ components: 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. + description: Event category to identify the type of event. For example, `change` + or `alert`. enum: - change + - alert example: change type: string x-enum-varnames: - CHANGE + - ALERT EventCreateRequest: description: Object representing an event creation request. properties: @@ -13920,12 +14004,17 @@ components: $ref: '#/components/schemas/EventPayload' type: $ref: '#/components/schemas/EventCreateRequestType' + required: + - type + - attributes type: object EventCreateRequestPayload: description: Payload for creating an event. properties: data: $ref: '#/components/schemas/EventCreateRequest' + required: + - data type: object EventCreateRequestType: description: Entity type. @@ -13940,6 +14029,12 @@ components: properties: attributes: $ref: '#/components/schemas/EventCreateResponseAttributes' + id: + description: A numerical ID compatible with the V1 endpoint. This field + is not populated in response from the V2 endpoint. To retrieve this ID, + refer to the event attributes in the Event Explorer. + example: _ + type: string type: description: Event type example: event @@ -13961,8 +14056,10 @@ components: EventCreateResponseAttributesAttributesEvt: description: JSON object of event system attributes. properties: - id: - description: Event id + uid: + description: A unique identifier for the event. You can use this ID to query + or reference the event in the V2 endpoint. + example: ABCDEFGHIJKLMNOPQRSTUVWX type: string type: object EventCreateResponsePayload: @@ -13970,6 +14067,17 @@ components: properties: data: $ref: '#/components/schemas/EventCreateResponse' + links: + $ref: '#/components/schemas/EventCreateResponsePayloadLinks' + type: object + EventCreateResponsePayloadLinks: + description: Links attributes. + properties: + self: + description: The URL of the event. This link is only functional when using + the `app` subdomain. + example: https://app.datadoghq.com/event/event?uid=ABCDEFGHIJKLMNOPQRSTUVWX + type: string type: object EventPayload: description: Event attributes. @@ -13977,12 +14085,15 @@ components: aggregation_key: description: An arbitrary string to use for aggregation when correlating events. Limited to 100 characters. + example: aggregation_key_123 maxLength: 100 type: string attributes: $ref: '#/components/schemas/EventPayloadAttributes' category: $ref: '#/components/schemas/EventCategory' + integration_id: + $ref: '#/components/schemas/EventPayloadIntegrationId' message: description: The body of the event. Limited to 4000 characters. example: payment_processed feature flag has been enabled @@ -13996,7 +14107,10 @@ components: - env:test items: description: A tag. + maxLength: 200 type: string + maxItems: 100 + minItems: 1 type: array timestamp: description: 'Timestamp when the event occurred. Must follow [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) @@ -14022,6 +14136,16 @@ components: event category. oneOf: - $ref: '#/components/schemas/ChangeEventCustomAttributes' + - $ref: '#/components/schemas/AlertEventCustomAttributes' + EventPayloadIntegrationId: + description: Integration IDs sourced from integration manifests. Currently, + only `custom-events` is supported. + enum: + - custom-events + example: custom-events + type: string + x-enum-varnames: + - CUSTOM_EVENTS EventPriority: description: The priority of the event's monitor. For example, `normal` or `low`. enum: @@ -45640,7 +45764,8 @@ paths: - events_read post: description: "This endpoint allows you to post events.\n\n\u2705 **Only events - with the `change` category** are in General Availability. See [Change Tracking](https://docs.datadoghq.com/change_tracking) + with the `change` or `alert` category** are in General Availability. For change + events, see [Change Tracking](https://docs.datadoghq.com/change_tracking) for more details.\n\n\u274C For use cases involving other event categories, please use the V1 endpoint." operationId: CreateEvent @@ -45652,6 +45777,7 @@ paths: value: data: attributes: + aggregation_key: aggregation_key_123 attributes: author: name: datadog@datadog.com @@ -45680,6 +45806,7 @@ paths: rule: datacenter: devcycle.us1.prod category: change + integration_id: custom-events message: payment_processed feature flag has been enabled tags: - env:test @@ -45690,7 +45817,7 @@ paths: description: Event request object required: true responses: - '200': + '202': content: application/json: schema: @@ -45713,6 +45840,38 @@ paths: security: - apiKeyAuth: [] appKeyAuth: [] + servers: + - url: https://{subdomain}.{site} + variables: + site: + default: datadoghq.com + description: The regional site for customers. + enum: + - datadoghq.com + - us3.datadoghq.com + - us5.datadoghq.com + - ap1.datadoghq.com + - datadoghq.eu + - ddog-gov.com + subdomain: + default: event-management-intake + description: The subdomain where the API is deployed. + - url: '{protocol}://{name}' + variables: + name: + default: event-management-intake.datadoghq.com + description: Full site DNS name. + protocol: + default: https + description: The protocol for accessing the API. + - url: https://{subdomain}.{site} + variables: + site: + default: datadoghq.com + description: Any Datadog deployment. + subdomain: + default: event-management-intake + description: The subdomain where the API is deployed. summary: Post an event tags: - Events diff --git a/docs/datadog_api_client.v2.model.rst b/docs/datadog_api_client.v2.model.rst index 92a46572b6..41ba1eff74 100644 --- a/docs/datadog_api_client.v2.model.rst +++ b/docs/datadog_api_client.v2.model.rst @@ -214,6 +214,48 @@ datadog\_api\_client.v2.model.advisory module :members: :show-inheritance: +datadog\_api\_client.v2.model.alert\_event\_custom\_attributes module +--------------------------------------------------------------------- + +.. automodule:: datadog_api_client.v2.model.alert_event_custom_attributes + :members: + :show-inheritance: + +datadog\_api\_client.v2.model.alert\_event\_custom\_attributes\_custom module +----------------------------------------------------------------------------- + +.. automodule:: datadog_api_client.v2.model.alert_event_custom_attributes_custom + :members: + :show-inheritance: + +datadog\_api\_client.v2.model.alert\_event\_custom\_attributes\_links\_items module +----------------------------------------------------------------------------------- + +.. automodule:: datadog_api_client.v2.model.alert_event_custom_attributes_links_items + :members: + :show-inheritance: + +datadog\_api\_client.v2.model.alert\_event\_custom\_attributes\_links\_items\_category module +--------------------------------------------------------------------------------------------- + +.. automodule:: datadog_api_client.v2.model.alert_event_custom_attributes_links_items_category + :members: + :show-inheritance: + +datadog\_api\_client.v2.model.alert\_event\_custom\_attributes\_priority module +------------------------------------------------------------------------------- + +.. automodule:: datadog_api_client.v2.model.alert_event_custom_attributes_priority + :members: + :show-inheritance: + +datadog\_api\_client.v2.model.alert\_event\_custom\_attributes\_status module +----------------------------------------------------------------------------- + +.. automodule:: datadog_api_client.v2.model.alert_event_custom_attributes_status + :members: + :show-inheritance: + datadog\_api\_client.v2.model.annotation module ----------------------------------------------- @@ -5723,6 +5765,13 @@ datadog\_api\_client.v2.model.event\_create\_response\_payload module :members: :show-inheritance: +datadog\_api\_client.v2.model.event\_create\_response\_payload\_links module +---------------------------------------------------------------------------- + +.. automodule:: datadog_api_client.v2.model.event_create_response_payload_links + :members: + :show-inheritance: + datadog\_api\_client.v2.model.event\_payload module --------------------------------------------------- @@ -5737,6 +5786,13 @@ datadog\_api\_client.v2.model.event\_payload\_attributes module :members: :show-inheritance: +datadog\_api\_client.v2.model.event\_payload\_integration\_id module +-------------------------------------------------------------------- + +.. automodule:: datadog_api_client.v2.model.event_payload_integration_id + :members: + :show-inheritance: + datadog\_api\_client.v2.model.event\_priority module ---------------------------------------------------- diff --git a/examples/v2/events/CreateEvent.py b/examples/v2/events/CreateEvent.py index 42bc837b0c..7588d2ff31 100644 --- a/examples/v2/events/CreateEvent.py +++ b/examples/v2/events/CreateEvent.py @@ -24,10 +24,12 @@ from datadog_api_client.v2.model.event_create_request_payload import EventCreateRequestPayload from datadog_api_client.v2.model.event_create_request_type import EventCreateRequestType from datadog_api_client.v2.model.event_payload import EventPayload +from datadog_api_client.v2.model.event_payload_integration_id import EventPayloadIntegrationId body = EventCreateRequestPayload( data=EventCreateRequest( attributes=EventPayload( + aggregation_key="aggregation_key_123", attributes=ChangeEventCustomAttributes( author=ChangeEventCustomAttributesAuthor( name="datadog@datadog.com", @@ -60,6 +62,7 @@ ), ), category=EventCategory.CHANGE, + integration_id=EventPayloadIntegrationId.CUSTOM_EVENTS, message="payment_processed feature flag has been enabled", tags=[ "env:test", diff --git a/src/datadog_api_client/v2/api/events_api.py b/src/datadog_api_client/v2/api/events_api.py index 1be946ba3c..5e160a11d9 100644 --- a/src/datadog_api_client/v2/api/events_api.py +++ b/src/datadog_api_client/v2/api/events_api.py @@ -42,6 +42,55 @@ def __init__(self, api_client=None): "operation_id": "create_event", "http_method": "POST", "version": "v2", + "servers": [ + { + "url": "https://{subdomain}.{site}", + "variables": { + "site": { + "description": "The regional site for customers.", + "default_value": "datadoghq.com", + "enum_values": [ + "datadoghq.com", + "us3.datadoghq.com", + "us5.datadoghq.com", + "ap1.datadoghq.com", + "datadoghq.eu", + "ddog-gov.com", + ], + }, + "subdomain": { + "description": "The subdomain where the API is deployed.", + "default_value": "event-management-intake", + }, + }, + }, + { + "url": "{protocol}://{name}", + "variables": { + "name": { + "description": "Full site DNS name.", + "default_value": "event-management-intake.datadoghq.com", + }, + "protocol": { + "description": "The protocol for accessing the API.", + "default_value": "https", + }, + }, + }, + { + "url": "https://{subdomain}.{site}", + "variables": { + "site": { + "description": "Any Datadog deployment.", + "default_value": "datadoghq.com", + }, + "subdomain": { + "description": "The subdomain where the API is deployed.", + "default_value": "event-management-intake", + }, + }, + }, + ], }, params_map={ "body": { @@ -131,7 +180,7 @@ def create_event( This endpoint allows you to post events. - ✅ **Only events with the change category** are in General Availability. See `Change Tracking `_ for more details. + ✅ **Only events with the change or alert category** are in General Availability. For change events, see `Change Tracking `_ for more details. ❌ For use cases involving other event categories, please use the V1 endpoint. diff --git a/src/datadog_api_client/v2/model/alert_event_custom_attributes.py b/src/datadog_api_client/v2/model/alert_event_custom_attributes.py new file mode 100644 index 0000000000..9ca2475950 --- /dev/null +++ b/src/datadog_api_client/v2/model/alert_event_custom_attributes.py @@ -0,0 +1,93 @@ +# Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +# This product includes software developed at Datadog (https://www.datadoghq.com/). +# Copyright 2019-Present Datadog, Inc. +from __future__ import annotations + +from typing import List, Union, TYPE_CHECKING + +from datadog_api_client.model_utils import ( + ModelNormal, + cached_property, + unset, + UnsetType, +) + + +if TYPE_CHECKING: + from datadog_api_client.v2.model.alert_event_custom_attributes_custom import AlertEventCustomAttributesCustom + from datadog_api_client.v2.model.alert_event_custom_attributes_links_items import ( + AlertEventCustomAttributesLinksItems, + ) + from datadog_api_client.v2.model.alert_event_custom_attributes_priority import AlertEventCustomAttributesPriority + from datadog_api_client.v2.model.alert_event_custom_attributes_status import AlertEventCustomAttributesStatus + + +class AlertEventCustomAttributes(ModelNormal): + validations = { + "links": { + "max_items": 20, + "min_items": 1, + }, + } + + @cached_property + def additional_properties_type(_): + return None + + @cached_property + def openapi_types(_): + from datadog_api_client.v2.model.alert_event_custom_attributes_custom import AlertEventCustomAttributesCustom + from datadog_api_client.v2.model.alert_event_custom_attributes_links_items import ( + AlertEventCustomAttributesLinksItems, + ) + from datadog_api_client.v2.model.alert_event_custom_attributes_priority import ( + AlertEventCustomAttributesPriority, + ) + from datadog_api_client.v2.model.alert_event_custom_attributes_status import AlertEventCustomAttributesStatus + + return { + "custom": (AlertEventCustomAttributesCustom,), + "links": ([AlertEventCustomAttributesLinksItems],), + "priority": (AlertEventCustomAttributesPriority,), + "status": (AlertEventCustomAttributesStatus,), + } + + attribute_map = { + "custom": "custom", + "links": "links", + "priority": "priority", + "status": "status", + } + + def __init__( + self_, + custom: Union[AlertEventCustomAttributesCustom, UnsetType] = unset, + links: Union[List[AlertEventCustomAttributesLinksItems], UnsetType] = unset, + priority: Union[AlertEventCustomAttributesPriority, UnsetType] = unset, + status: Union[AlertEventCustomAttributesStatus, UnsetType] = unset, + **kwargs, + ): + """ + Object representing custom alert event attributes. + + :param custom: Custom attributes. Support up to 100 properties and a maximum nesting depth of 10 levels. + :type custom: AlertEventCustomAttributesCustom, optional + + :param links: The links related to the event. + :type links: [AlertEventCustomAttributesLinksItems], optional + + :param priority: The priority of the alert. + :type priority: AlertEventCustomAttributesPriority, optional + + :param status: The status of the alert. + :type status: AlertEventCustomAttributesStatus, optional + """ + if custom is not unset: + kwargs["custom"] = custom + if links is not unset: + kwargs["links"] = links + if priority is not unset: + kwargs["priority"] = priority + if status is not unset: + kwargs["status"] = status + super().__init__(kwargs) diff --git a/src/datadog_api_client/v2/model/alert_event_custom_attributes_custom.py b/src/datadog_api_client/v2/model/alert_event_custom_attributes_custom.py new file mode 100644 index 0000000000..c21e2b7e02 --- /dev/null +++ b/src/datadog_api_client/v2/model/alert_event_custom_attributes_custom.py @@ -0,0 +1,17 @@ +# Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +# This product includes software developed at Datadog (https://www.datadoghq.com/). +# Copyright 2019-Present Datadog, Inc. +from __future__ import annotations + + +from datadog_api_client.model_utils import ( + ModelNormal, +) + + +class AlertEventCustomAttributesCustom(ModelNormal): + def __init__(self_, **kwargs): + """ + Custom attributes. Support up to 100 properties and a maximum nesting depth of 10 levels. + """ + super().__init__(kwargs) diff --git a/src/datadog_api_client/v2/model/alert_event_custom_attributes_links_items.py b/src/datadog_api_client/v2/model/alert_event_custom_attributes_links_items.py new file mode 100644 index 0000000000..f092376853 --- /dev/null +++ b/src/datadog_api_client/v2/model/alert_event_custom_attributes_links_items.py @@ -0,0 +1,74 @@ +# Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +# This product includes software developed at Datadog (https://www.datadoghq.com/). +# Copyright 2019-Present Datadog, Inc. +from __future__ import annotations + +from typing import Union, TYPE_CHECKING + +from datadog_api_client.model_utils import ( + ModelNormal, + cached_property, + unset, + UnsetType, +) + + +if TYPE_CHECKING: + from datadog_api_client.v2.model.alert_event_custom_attributes_links_items_category import ( + AlertEventCustomAttributesLinksItemsCategory, + ) + + +class AlertEventCustomAttributesLinksItems(ModelNormal): + validations = { + "title": { + "max_length": 300, + }, + "url": { + "max_length": 2048, + }, + } + + @cached_property + def openapi_types(_): + from datadog_api_client.v2.model.alert_event_custom_attributes_links_items_category import ( + AlertEventCustomAttributesLinksItemsCategory, + ) + + return { + "category": (AlertEventCustomAttributesLinksItemsCategory,), + "title": (str,), + "url": (str,), + } + + attribute_map = { + "category": "category", + "title": "title", + "url": "url", + } + + def __init__( + self_, + category: AlertEventCustomAttributesLinksItemsCategory, + url: str, + title: Union[str, UnsetType] = unset, + **kwargs, + ): + """ + A link. + + :param category: The category of the link. + :type category: AlertEventCustomAttributesLinksItemsCategory + + :param title: The title of the link. Limited to 300 characters. + :type title: str, optional + + :param url: The URL of the link. Limited to 2048 characters. + :type url: str + """ + if title is not unset: + kwargs["title"] = title + super().__init__(kwargs) + + self_.category = category + self_.url = url diff --git a/src/datadog_api_client/v2/model/alert_event_custom_attributes_links_items_category.py b/src/datadog_api_client/v2/model/alert_event_custom_attributes_links_items_category.py new file mode 100644 index 0000000000..5b86772c63 --- /dev/null +++ b/src/datadog_api_client/v2/model/alert_event_custom_attributes_links_items_category.py @@ -0,0 +1,35 @@ +# Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +# This product includes software developed at Datadog (https://www.datadoghq.com/). +# Copyright 2019-Present Datadog, Inc. +from __future__ import annotations + + +from datadog_api_client.model_utils import ( + ModelSimple, + cached_property, +) + +from typing import ClassVar + + +class AlertEventCustomAttributesLinksItemsCategory(ModelSimple): + """ + The category of the link. + + :param value: If omitted defaults to "runbook". Must be one of ["runbook"]. + :type value: str + """ + + allowed_values = { + "runbook", + } + RUNBOOK: ClassVar["AlertEventCustomAttributesLinksItemsCategory"] + + @cached_property + def openapi_types(_): + return { + "value": (str,), + } + + +AlertEventCustomAttributesLinksItemsCategory.RUNBOOK = AlertEventCustomAttributesLinksItemsCategory("runbook") diff --git a/src/datadog_api_client/v2/model/alert_event_custom_attributes_priority.py b/src/datadog_api_client/v2/model/alert_event_custom_attributes_priority.py new file mode 100644 index 0000000000..c23ac43cf0 --- /dev/null +++ b/src/datadog_api_client/v2/model/alert_event_custom_attributes_priority.py @@ -0,0 +1,47 @@ +# Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +# This product includes software developed at Datadog (https://www.datadoghq.com/). +# Copyright 2019-Present Datadog, Inc. +from __future__ import annotations + + +from datadog_api_client.model_utils import ( + ModelSimple, + cached_property, +) + +from typing import ClassVar + + +class AlertEventCustomAttributesPriority(ModelSimple): + """ + The priority of the alert. + + :param value: Must be one of ["1", "2", "3", "4", "5"]. + :type value: str + """ + + allowed_values = { + "1", + "2", + "3", + "4", + "5", + } + PRIORITY_ONE: ClassVar["AlertEventCustomAttributesPriority"] + PRIORITY_TWO: ClassVar["AlertEventCustomAttributesPriority"] + PRIORITY_THREE: ClassVar["AlertEventCustomAttributesPriority"] + PRIORITY_FOUR: ClassVar["AlertEventCustomAttributesPriority"] + PRIORITY_FIVE: ClassVar["AlertEventCustomAttributesPriority"] + + @cached_property + def openapi_types(_): + return { + "value": (str,), + } + + +AlertEventCustomAttributesPriority.PRIORITY_ONE = AlertEventCustomAttributesPriority("1") +AlertEventCustomAttributesPriority.PRIORITY_TWO = AlertEventCustomAttributesPriority("2") +AlertEventCustomAttributesPriority.PRIORITY_THREE = AlertEventCustomAttributesPriority("3") +AlertEventCustomAttributesPriority.PRIORITY_FOUR = AlertEventCustomAttributesPriority("4") +AlertEventCustomAttributesPriority.PRIORITY_FIVE = AlertEventCustomAttributesPriority("5") diff --git a/src/datadog_api_client/v2/model/alert_event_custom_attributes_status.py b/src/datadog_api_client/v2/model/alert_event_custom_attributes_status.py new file mode 100644 index 0000000000..ed73d2e932 --- /dev/null +++ b/src/datadog_api_client/v2/model/alert_event_custom_attributes_status.py @@ -0,0 +1,44 @@ +# Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +# This product includes software developed at Datadog (https://www.datadoghq.com/). +# Copyright 2019-Present Datadog, Inc. +from __future__ import annotations + + +from datadog_api_client.model_utils import ( + ModelSimple, + cached_property, +) + +from typing import ClassVar + + +class AlertEventCustomAttributesStatus(ModelSimple): + """ + The status of the alert. + + :param value: Must be one of ["info", "warn", "error", "ok"]. + :type value: str + """ + + allowed_values = { + "info", + "warn", + "error", + "ok", + } + INFO: ClassVar["AlertEventCustomAttributesStatus"] + WARN: ClassVar["AlertEventCustomAttributesStatus"] + ERROR: ClassVar["AlertEventCustomAttributesStatus"] + OK: ClassVar["AlertEventCustomAttributesStatus"] + + @cached_property + def openapi_types(_): + return { + "value": (str,), + } + + +AlertEventCustomAttributesStatus.INFO = AlertEventCustomAttributesStatus("info") +AlertEventCustomAttributesStatus.WARN = AlertEventCustomAttributesStatus("warn") +AlertEventCustomAttributesStatus.ERROR = AlertEventCustomAttributesStatus("error") +AlertEventCustomAttributesStatus.OK = AlertEventCustomAttributesStatus("ok") diff --git a/src/datadog_api_client/v2/model/event_category.py b/src/datadog_api_client/v2/model/event_category.py index 9dc88b7cbd..d078195c21 100644 --- a/src/datadog_api_client/v2/model/event_category.py +++ b/src/datadog_api_client/v2/model/event_category.py @@ -14,16 +14,18 @@ class EventCategory(ModelSimple): """ - 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. + Event category to identify the type of event. For example, `change` or `alert`. - :param value: If omitted defaults to "change". Must be one of ["change"]. + :param value: Must be one of ["change", "alert"]. :type value: str """ allowed_values = { "change", + "alert", } CHANGE: ClassVar["EventCategory"] + ALERT: ClassVar["EventCategory"] @cached_property def openapi_types(_): @@ -33,3 +35,4 @@ def openapi_types(_): EventCategory.CHANGE = EventCategory("change") +EventCategory.ALERT = EventCategory("alert") diff --git a/src/datadog_api_client/v2/model/event_create_request.py b/src/datadog_api_client/v2/model/event_create_request.py index 0c47ed1304..036d6ca3f5 100644 --- a/src/datadog_api_client/v2/model/event_create_request.py +++ b/src/datadog_api_client/v2/model/event_create_request.py @@ -3,13 +3,11 @@ # Copyright 2019-Present Datadog, Inc. from __future__ import annotations -from typing import Union, TYPE_CHECKING +from typing import TYPE_CHECKING from datadog_api_client.model_utils import ( ModelNormal, cached_property, - unset, - UnsetType, ) @@ -34,23 +32,17 @@ def openapi_types(_): "type": "type", } - def __init__( - self_, - attributes: Union[EventPayload, UnsetType] = unset, - type: Union[EventCreateRequestType, UnsetType] = unset, - **kwargs, - ): + def __init__(self_, attributes: EventPayload, type: EventCreateRequestType, **kwargs): """ Object representing an event creation request. :param attributes: Event attributes. - :type attributes: EventPayload, optional + :type attributes: EventPayload :param type: Entity type. - :type type: EventCreateRequestType, optional + :type type: EventCreateRequestType """ - if attributes is not unset: - kwargs["attributes"] = attributes - if type is not unset: - kwargs["type"] = type super().__init__(kwargs) + + self_.attributes = attributes + self_.type = type diff --git a/src/datadog_api_client/v2/model/event_create_request_payload.py b/src/datadog_api_client/v2/model/event_create_request_payload.py index 14b78c6a81..1c152e76f3 100644 --- a/src/datadog_api_client/v2/model/event_create_request_payload.py +++ b/src/datadog_api_client/v2/model/event_create_request_payload.py @@ -3,13 +3,11 @@ # Copyright 2019-Present Datadog, Inc. from __future__ import annotations -from typing import Union, TYPE_CHECKING +from typing import TYPE_CHECKING from datadog_api_client.model_utils import ( ModelNormal, cached_property, - unset, - UnsetType, ) @@ -30,13 +28,13 @@ def openapi_types(_): "data": "data", } - def __init__(self_, data: Union[EventCreateRequest, UnsetType] = unset, **kwargs): + def __init__(self_, data: EventCreateRequest, **kwargs): """ Payload for creating an event. :param data: Object representing an event creation request. - :type data: EventCreateRequest, optional + :type data: EventCreateRequest """ - if data is not unset: - kwargs["data"] = data super().__init__(kwargs) + + self_.data = data diff --git a/src/datadog_api_client/v2/model/event_create_response.py b/src/datadog_api_client/v2/model/event_create_response.py index 08443fcaf2..efe6fe911e 100644 --- a/src/datadog_api_client/v2/model/event_create_response.py +++ b/src/datadog_api_client/v2/model/event_create_response.py @@ -24,17 +24,20 @@ def openapi_types(_): return { "attributes": (EventCreateResponseAttributes,), + "id": (str,), "type": (str,), } attribute_map = { "attributes": "attributes", + "id": "id", "type": "type", } def __init__( self_, attributes: Union[EventCreateResponseAttributes, UnsetType] = unset, + id: Union[str, UnsetType] = unset, type: Union[str, UnsetType] = unset, **kwargs, ): @@ -44,11 +47,16 @@ def __init__( :param attributes: JSON object containing all events attributes and their associated values. :type attributes: EventCreateResponseAttributes, optional + :param id: A numerical ID compatible with the V1 endpoint. This field is not populated in response from the V2 endpoint. To retrieve this ID, refer to the event attributes in the Event Explorer. + :type id: str, optional + :param type: Event type :type type: str, optional """ if attributes is not unset: kwargs["attributes"] = attributes + if id is not unset: + kwargs["id"] = id if type is not unset: kwargs["type"] = type super().__init__(kwargs) diff --git a/src/datadog_api_client/v2/model/event_create_response_attributes_attributes_evt.py b/src/datadog_api_client/v2/model/event_create_response_attributes_attributes_evt.py index e61e67ddc0..17a6269275 100644 --- a/src/datadog_api_client/v2/model/event_create_response_attributes_attributes_evt.py +++ b/src/datadog_api_client/v2/model/event_create_response_attributes_attributes_evt.py @@ -17,20 +17,20 @@ class EventCreateResponseAttributesAttributesEvt(ModelNormal): @cached_property def openapi_types(_): return { - "id": (str,), + "uid": (str,), } attribute_map = { - "id": "id", + "uid": "uid", } - def __init__(self_, id: Union[str, UnsetType] = unset, **kwargs): + def __init__(self_, uid: Union[str, UnsetType] = unset, **kwargs): """ JSON object of event system attributes. - :param id: Event id - :type id: str, optional + :param uid: A unique identifier for the event. You can use this ID to query or reference the event in the V2 endpoint. + :type uid: str, optional """ - if id is not unset: - kwargs["id"] = id + if uid is not unset: + kwargs["uid"] = uid super().__init__(kwargs) diff --git a/src/datadog_api_client/v2/model/event_create_response_payload.py b/src/datadog_api_client/v2/model/event_create_response_payload.py index e79410032a..deacd5f5c0 100644 --- a/src/datadog_api_client/v2/model/event_create_response_payload.py +++ b/src/datadog_api_client/v2/model/event_create_response_payload.py @@ -15,28 +15,42 @@ if TYPE_CHECKING: from datadog_api_client.v2.model.event_create_response import EventCreateResponse + from datadog_api_client.v2.model.event_create_response_payload_links import EventCreateResponsePayloadLinks class EventCreateResponsePayload(ModelNormal): @cached_property def openapi_types(_): from datadog_api_client.v2.model.event_create_response import EventCreateResponse + from datadog_api_client.v2.model.event_create_response_payload_links import EventCreateResponsePayloadLinks return { "data": (EventCreateResponse,), + "links": (EventCreateResponsePayloadLinks,), } attribute_map = { "data": "data", + "links": "links", } - def __init__(self_, data: Union[EventCreateResponse, UnsetType] = unset, **kwargs): + def __init__( + self_, + data: Union[EventCreateResponse, UnsetType] = unset, + links: Union[EventCreateResponsePayloadLinks, UnsetType] = unset, + **kwargs, + ): """ Response containing information about created event. :param data: Object containing an event response. :type data: EventCreateResponse, optional + + :param links: Links attributes. + :type links: EventCreateResponsePayloadLinks, optional """ if data is not unset: kwargs["data"] = data + if links is not unset: + kwargs["links"] = links super().__init__(kwargs) diff --git a/src/datadog_api_client/v2/model/event_create_response_payload_links.py b/src/datadog_api_client/v2/model/event_create_response_payload_links.py new file mode 100644 index 0000000000..0e11b30983 --- /dev/null +++ b/src/datadog_api_client/v2/model/event_create_response_payload_links.py @@ -0,0 +1,36 @@ +# Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +# This product includes software developed at Datadog (https://www.datadoghq.com/). +# Copyright 2019-Present Datadog, Inc. +from __future__ import annotations + +from typing import Union + +from datadog_api_client.model_utils import ( + ModelNormal, + cached_property, + unset, + UnsetType, +) + + +class EventCreateResponsePayloadLinks(ModelNormal): + @cached_property + def openapi_types(_): + return { + "self": (str,), + } + + attribute_map = { + "self": "self", + } + + def __init__(self_, self: Union[str, UnsetType] = unset, **kwargs): + """ + Links attributes. + + :param self: The URL of the event. This link is only functional when using the ``app`` subdomain. + :type self: str, optional + """ + if self is not unset: + kwargs["self"] = self + super().__init__(kwargs) diff --git a/src/datadog_api_client/v2/model/event_payload.py b/src/datadog_api_client/v2/model/event_payload.py index 39c97b1e1a..cbcf4b81d3 100644 --- a/src/datadog_api_client/v2/model/event_payload.py +++ b/src/datadog_api_client/v2/model/event_payload.py @@ -16,7 +16,9 @@ if TYPE_CHECKING: from datadog_api_client.v2.model.event_payload_attributes import EventPayloadAttributes from datadog_api_client.v2.model.event_category import EventCategory + from datadog_api_client.v2.model.event_payload_integration_id import EventPayloadIntegrationId from datadog_api_client.v2.model.change_event_custom_attributes import ChangeEventCustomAttributes + from datadog_api_client.v2.model.alert_event_custom_attributes import AlertEventCustomAttributes class EventPayload(ModelNormal): @@ -27,6 +29,10 @@ class EventPayload(ModelNormal): "message": { "max_length": 4000, }, + "tags": { + "max_items": 100, + "min_items": 1, + }, "title": { "max_length": 500, }, @@ -36,11 +42,13 @@ class EventPayload(ModelNormal): def openapi_types(_): from datadog_api_client.v2.model.event_payload_attributes import EventPayloadAttributes from datadog_api_client.v2.model.event_category import EventCategory + from datadog_api_client.v2.model.event_payload_integration_id import EventPayloadIntegrationId return { "aggregation_key": (str,), "attributes": (EventPayloadAttributes,), "category": (EventCategory,), + "integration_id": (EventPayloadIntegrationId,), "message": (str,), "tags": ([str],), "timestamp": (str,), @@ -51,6 +59,7 @@ def openapi_types(_): "aggregation_key": "aggregation_key", "attributes": "attributes", "category": "category", + "integration_id": "integration_id", "message": "message", "tags": "tags", "timestamp": "timestamp", @@ -59,10 +68,11 @@ def openapi_types(_): def __init__( self_, - attributes: Union[EventPayloadAttributes, ChangeEventCustomAttributes], + attributes: Union[EventPayloadAttributes, ChangeEventCustomAttributes, AlertEventCustomAttributes], category: EventCategory, title: str, aggregation_key: Union[str, UnsetType] = unset, + integration_id: Union[EventPayloadIntegrationId, UnsetType] = unset, message: Union[str, UnsetType] = unset, tags: Union[List[str], UnsetType] = unset, timestamp: Union[str, UnsetType] = unset, @@ -77,9 +87,12 @@ def __init__( :param attributes: JSON object for custom attributes. Schema are different per each event category. :type attributes: EventPayloadAttributes - :param category: 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. + :param category: Event category to identify the type of event. For example, ``change`` or ``alert``. :type category: EventCategory + :param integration_id: Integration IDs sourced from integration manifests. Currently, only ``custom-events`` is supported. + :type integration_id: EventPayloadIntegrationId, optional + :param message: The body of the event. Limited to 4000 characters. :type message: str, optional @@ -97,6 +110,8 @@ def __init__( """ if aggregation_key is not unset: kwargs["aggregation_key"] = aggregation_key + if integration_id is not unset: + kwargs["integration_id"] = integration_id if message is not unset: kwargs["message"] = message if tags is not unset: diff --git a/src/datadog_api_client/v2/model/event_payload_attributes.py b/src/datadog_api_client/v2/model/event_payload_attributes.py index 18836e1630..d24c9734f6 100644 --- a/src/datadog_api_client/v2/model/event_payload_attributes.py +++ b/src/datadog_api_client/v2/model/event_payload_attributes.py @@ -33,6 +33,18 @@ def __init__(self, **kwargs): :param prev_value: Free form object to track previous value of the changed resource. :type prev_value: {str: (bool, date, datetime, dict, float, int, list, str, UUID, none_type,)}, optional + + :param custom: Custom attributes. Support up to 100 properties and a maximum nesting depth of 10 levels. + :type custom: AlertEventCustomAttributesCustom, optional + + :param links: The links related to the event. + :type links: [AlertEventCustomAttributesLinksItems], optional + + :param priority: The priority of the alert. + :type priority: AlertEventCustomAttributesPriority, optional + + :param status: The status of the alert. + :type status: AlertEventCustomAttributesStatus, optional """ super().__init__(kwargs) @@ -46,9 +58,11 @@ def _composed_schemas(_): # classes don't exist yet because their module has not finished # loading from datadog_api_client.v2.model.change_event_custom_attributes import ChangeEventCustomAttributes + from datadog_api_client.v2.model.alert_event_custom_attributes import AlertEventCustomAttributes return { "oneOf": [ ChangeEventCustomAttributes, + AlertEventCustomAttributes, ], } diff --git a/src/datadog_api_client/v2/model/event_payload_integration_id.py b/src/datadog_api_client/v2/model/event_payload_integration_id.py new file mode 100644 index 0000000000..669d51eafb --- /dev/null +++ b/src/datadog_api_client/v2/model/event_payload_integration_id.py @@ -0,0 +1,35 @@ +# Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +# This product includes software developed at Datadog (https://www.datadoghq.com/). +# Copyright 2019-Present Datadog, Inc. +from __future__ import annotations + + +from datadog_api_client.model_utils import ( + ModelSimple, + cached_property, +) + +from typing import ClassVar + + +class EventPayloadIntegrationId(ModelSimple): + """ + Integration IDs sourced from integration manifests. Currently, only `custom-events` is supported. + + :param value: If omitted defaults to "custom-events". Must be one of ["custom-events"]. + :type value: str + """ + + allowed_values = { + "custom-events", + } + CUSTOM_EVENTS: ClassVar["EventPayloadIntegrationId"] + + @cached_property + def openapi_types(_): + return { + "value": (str,), + } + + +EventPayloadIntegrationId.CUSTOM_EVENTS = EventPayloadIntegrationId("custom-events") diff --git a/src/datadog_api_client/v2/models/__init__.py b/src/datadog_api_client/v2/models/__init__.py index 734bdd615f..68bc659c34 100644 --- a/src/datadog_api_client/v2/models/__init__.py +++ b/src/datadog_api_client/v2/models/__init__.py @@ -92,6 +92,14 @@ from datadog_api_client.v2.model.active_billing_dimensions_response import ActiveBillingDimensionsResponse from datadog_api_client.v2.model.active_billing_dimensions_type import ActiveBillingDimensionsType from datadog_api_client.v2.model.advisory import Advisory +from datadog_api_client.v2.model.alert_event_custom_attributes import AlertEventCustomAttributes +from datadog_api_client.v2.model.alert_event_custom_attributes_custom import AlertEventCustomAttributesCustom +from datadog_api_client.v2.model.alert_event_custom_attributes_links_items import AlertEventCustomAttributesLinksItems +from datadog_api_client.v2.model.alert_event_custom_attributes_links_items_category import ( + AlertEventCustomAttributesLinksItemsCategory, +) +from datadog_api_client.v2.model.alert_event_custom_attributes_priority import AlertEventCustomAttributesPriority +from datadog_api_client.v2.model.alert_event_custom_attributes_status import AlertEventCustomAttributesStatus from datadog_api_client.v2.model.annotation import Annotation from datadog_api_client.v2.model.annotation_display import AnnotationDisplay from datadog_api_client.v2.model.annotation_display_bounds import AnnotationDisplayBounds @@ -1102,8 +1110,10 @@ EventCreateResponseAttributesAttributesEvt, ) from datadog_api_client.v2.model.event_create_response_payload import EventCreateResponsePayload +from datadog_api_client.v2.model.event_create_response_payload_links import EventCreateResponsePayloadLinks from datadog_api_client.v2.model.event_payload import EventPayload from datadog_api_client.v2.model.event_payload_attributes import EventPayloadAttributes +from datadog_api_client.v2.model.event_payload_integration_id import EventPayloadIntegrationId from datadog_api_client.v2.model.event_priority import EventPriority from datadog_api_client.v2.model.event_response import EventResponse from datadog_api_client.v2.model.event_response_attributes import EventResponseAttributes @@ -3535,6 +3545,12 @@ "ActiveBillingDimensionsResponse", "ActiveBillingDimensionsType", "Advisory", + "AlertEventCustomAttributes", + "AlertEventCustomAttributesCustom", + "AlertEventCustomAttributesLinksItems", + "AlertEventCustomAttributesLinksItemsCategory", + "AlertEventCustomAttributesPriority", + "AlertEventCustomAttributesStatus", "Annotation", "AnnotationDisplay", "AnnotationDisplayBounds", @@ -4261,8 +4277,10 @@ "EventCreateResponseAttributesAttributes", "EventCreateResponseAttributesAttributesEvt", "EventCreateResponsePayload", + "EventCreateResponsePayloadLinks", "EventPayload", "EventPayloadAttributes", + "EventPayloadIntegrationId", "EventPriority", "EventResponse", "EventResponseAttributes", diff --git a/tests/v2/features/events.feature b/tests/v2/features/events.feature index a8c1307ac6..b13848eb06 100644 --- a/tests/v2/features/events.feature +++ b/tests/v2/features/events.feature @@ -53,16 +53,16 @@ Feature: Events @generated @skip @team:DataDog/event-management Scenario: Post an event returns "Bad request" response Given new "CreateEvent" request - And body with 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": ["env:test"], "title": "payment_processed feature flag updated"}, "type": "event"}} + And body with value {"data": {"attributes": {"aggregation_key": "aggregation_key_123", "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", "integration_id": "custom-events", "message": "payment_processed feature flag has been enabled", "tags": ["env:test"], "title": "payment_processed feature flag updated"}, "type": "event"}} When the request is sent Then the response status is 400 Bad request @generated @skip @team:DataDog/event-management Scenario: Post an event returns "OK" response Given new "CreateEvent" request - And body with 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": ["env:test"], "title": "payment_processed feature flag updated"}, "type": "event"}} + And body with value {"data": {"attributes": {"aggregation_key": "aggregation_key_123", "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", "integration_id": "custom-events", "message": "payment_processed feature flag has been enabled", "tags": ["env:test"], "title": "payment_processed feature flag updated"}, "type": "event"}} When the request is sent - Then the response status is 200 OK + Then the response status is 202 OK @team:DataDog/event-management Scenario: Search events returns "Bad Request" response