diff --git a/.apigentools-info b/.apigentools-info index 8e514ce342..c3e1e7fbd5 100644 --- a/.apigentools-info +++ b/.apigentools-info @@ -4,13 +4,13 @@ "spec_versions": { "v1": { "apigentools_version": "1.6.6", - "regenerated": "2025-06-18 13:32:33.091008", - "spec_repo_commit": "5e49afe1" + "regenerated": "2025-06-18 14:53:52.416901", + "spec_repo_commit": "5f7cad1f" }, "v2": { "apigentools_version": "1.6.6", - "regenerated": "2025-06-18 13:32:33.105798", - "spec_repo_commit": "5e49afe1" + "regenerated": "2025-06-18 14:53:52.465865", + "spec_repo_commit": "5f7cad1f" } } } \ No newline at end of file diff --git a/.generator/schemas/v2/openapi.yaml b/.generator/schemas/v2/openapi.yaml index c24700d9c6..cdbca1909d 100644 --- a/.generator/schemas/v2/openapi.yaml +++ b/.generator/schemas/v2/openapi.yaml @@ -2227,6 +2227,97 @@ components: - id - base_severity type: object + AlertEventCustomAttributes: + additionalProperties: false + description: Alert event attributes. + properties: + custom: + $ref: '#/components/schemas/AlertEventCustomAttributesCustom' + links: + $ref: '#/components/schemas/AlertEventCustomAttributesLinks' + priority: + $ref: '#/components/schemas/AlertEventCustomAttributesPriority' + status: + $ref: '#/components/schemas/AlertEventCustomAttributesStatus' + required: + - status + type: object + AlertEventCustomAttributesCustom: + additionalProperties: {} + description: Free form JSON object for arbitrary data. Supports up to 100 properties + per object and a maximum nesting depth of 10 levels. + example: {} + type: object + AlertEventCustomAttributesLinks: + description: The links related to the event. Maximum of 20 links allowed. + items: + $ref: '#/components/schemas/AlertEventCustomAttributesLinksItems' + maxItems: 20 + minItems: 1 + type: array + AlertEventCustomAttributesLinksItems: + additionalProperties: false + description: A link. + properties: + category: + $ref: '#/components/schemas/AlertEventCustomAttributesLinksItemsCategory' + title: + description: The display text of the link. Limited to 300 characters. + example: Runbook Link + maxLength: 300 + minLength: 1 + type: string + url: + description: The URL of the link. Limited to 2048 characters. + example: https://app.datadoghq.com/runbook + maxLength: 2048 + minLength: 1 + type: string + required: + - url + - category + type: object + AlertEventCustomAttributesLinksItemsCategory: + description: The category of the link. + enum: + - runbook + - documentation + - dashboard + example: runbook + type: string + x-enum-varnames: + - RUNBOOK + - DOCUMENTATION + - DASHBOARD + AlertEventCustomAttributesPriority: + default: '5' + description: The priority of the alert. + enum: + - '1' + - '2' + - '3' + - '4' + - '5' + example: '5' + type: string + x-enum-varnames: + - PRIORITY_ONE + - PRIORITY_TWO + - PRIORITY_THREE + - PRIORITY_FOUR + - PRIORITY_FIVE + AlertEventCustomAttributesStatus: + description: The status of the alert. + enum: + - warn + - error + - ok + example: warn + type: string + x-enum-varnames: + - WARN + - ERROR + - OK Annotation: description: A list of annotations used in the workflow. These are like sticky notes for your workflow! @@ -6919,14 +7010,16 @@ components: type: integer type: object ChangeEventCustomAttributes: - description: Object representing custom change event attributes. + additionalProperties: false + description: 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. + description: Free form JSON object with information related to the `change` + event. Supports up to 100 properties per object and a maximum nesting + depth of 10 levels. example: dd: team: datadog_team @@ -6941,17 +7034,19 @@ components: 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.' + the change event at the correct location. Only resources of type `service` + are supported. Maximum of 100 impacted resources allowed.' example: - name: payments_api type: service items: $ref: '#/components/schemas/ChangeEventCustomAttributesImpactedResourcesItems' + maxItems: 100 type: array new_value: additionalProperties: {} - description: Free form object to track new value of the changed resource. + description: Free form JSON object representing the new state of the changed + resource. example: enabled: true percentage: 50% @@ -6960,7 +7055,8 @@ components: type: object prev_value: additionalProperties: {} - description: Free form object to track previous value of the changed resource. + description: Free form JSON object representing the previous state of the + changed resource. example: enabled: true percentage: 10% @@ -6971,13 +7067,16 @@ components: - changed_resource type: object ChangeEventCustomAttributesAuthor: - description: Object representing the entity which made the change. Optional - field but if provided should include `type` and `name`. + additionalProperties: false + description: The entity that made the change. Optional, if provided it must + include `type` and `name`. properties: name: - description: Author's name. Limited to 128 characters. - example: datadog@datadog.com + description: The name of the user or system that made the change. Limited + to 128 characters. + example: example@datadog.com maxLength: 128 + minLength: 1 type: string type: $ref: '#/components/schemas/ChangeEventCustomAttributesAuthorType' @@ -6996,11 +7095,14 @@ components: - USER - SYSTEM ChangeEventCustomAttributesChangedResource: - description: Object representing a uniquely identified resource. + additionalProperties: false + description: A uniquely identified resource. properties: name: - description: Resource's name. + description: The name of the resource that was changed. Limited to 128 characters. example: fallback_payments_test + maxLength: 128 + minLength: 1 type: string type: $ref: '#/components/schemas/ChangeEventCustomAttributesChangedResourceType' @@ -7009,7 +7111,7 @@ components: - name type: object ChangeEventCustomAttributesChangedResourceType: - description: Resource's type. + description: The type of the resource that was changed. enum: - feature_flag - configuration @@ -7019,12 +7121,14 @@ components: - FEATURE_FLAG - CONFIGURATION ChangeEventCustomAttributesImpactedResourcesItems: - description: Object representing a uniquely identified resource. Only the resource - type `service` is supported. + additionalProperties: false + description: Object representing a uniquely identified resource. properties: name: - description: Resource's name. + description: The name of the impacted resource. Limited to 128 characters. example: payments_api + maxLength: 128 + minLength: 1 type: string type: $ref: '#/components/schemas/ChangeEventCustomAttributesImpactedResourcesItemsType' @@ -7033,7 +7137,7 @@ components: - name type: object ChangeEventCustomAttributesImpactedResourcesItemsType: - description: Resource's type. + description: The type of the impacted resource. enum: - service example: service @@ -14587,28 +14691,33 @@ 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 identifying the type of event. enum: - change + - alert example: change type: string x-enum-varnames: - CHANGE + - ALERT EventCreateRequest: - description: Object representing an event creation request. + description: An event object. properties: attributes: $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. @@ -14619,24 +14728,23 @@ components: x-enum-varnames: - EVENT EventCreateResponse: - description: Object containing an event response. + description: Event object. properties: attributes: $ref: '#/components/schemas/EventCreateResponseAttributes' type: - description: Event type + description: Entity type. example: event type: string type: object EventCreateResponseAttributes: - description: JSON object containing all events attributes and their associated - values. + description: Event attributes. properties: attributes: $ref: '#/components/schemas/EventCreateResponseAttributesAttributes' type: object EventCreateResponseAttributesAttributes: - description: JSON object of attributes from your events. + description: JSON object for category-specific attributes. properties: evt: $ref: '#/components/schemas/EventCreateResponseAttributesAttributesEvt' @@ -14645,41 +14753,71 @@ components: description: JSON object of event system attributes. properties: id: - description: Event id + deprecated: true + description: Event identifier. This field is deprecated and will be removed + in a future version. Use the `uid` field instead. + type: string + uid: + description: A unique identifier for the event. You can use this identifier + to query or reference the event. type: string type: object EventCreateResponsePayload: - description: Response containing information about created event. + description: Event creation response. properties: data: $ref: '#/components/schemas/EventCreateResponse' + links: + $ref: '#/components/schemas/EventCreateResponsePayloadLinks' + type: object + EventCreateResponsePayloadLinks: + description: Links to the event. + properties: + self: + description: The URL of the event. This link is only functional when using + the default subdomain. + type: string type: object EventPayload: + additionalProperties: false description: Event attributes. properties: aggregation_key: - description: An arbitrary string to use for aggregation when correlating - events. Limited to 100 characters. + description: A string used for aggregation when [correlating](https://docs.datadoghq.com/service_management/events/correlation/) + events. If you specify a key, events are deduplicated to alerts based + on this key. Limited to 100 characters. + example: aggregation_key_123 maxLength: 100 + minLength: 1 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. + description: Free formed text associated with the event. It's suggested + to use `data.attributes.attributes.custom` for well-structured attributes. + Limited to 4000 characters. example: payment_processed feature flag has been enabled maxLength: 4000 + minLength: 1 type: string tags: - description: 'A list of tags to apply to the event. + description: 'A list of tags associated with the event. Maximum of 100 tags + allowed. Refer to [Tags docs](https://docs.datadoghq.com/getting_started/tagging/).' example: - - env:test + - env:api_client_test items: description: A tag. + maxLength: 200 + minLength: 1 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) @@ -14691,9 +14829,10 @@ components: 18 hours.' type: string title: - description: The event title. Limited to 500 characters. + description: The title of the event. Limited to 500 characters. example: payment_processed feature flag updated maxLength: 500 + minLength: 1 type: string required: - title @@ -14701,10 +14840,19 @@ components: - attributes type: object EventPayloadAttributes: - description: JSON object for custom attributes. Schema are different per each - event category. + description: JSON object for category-specific attributes. Schema is different + per event category. oneOf: - $ref: '#/components/schemas/ChangeEventCustomAttributes' + - $ref: '#/components/schemas/AlertEventCustomAttributes' + EventPayloadIntegrationId: + description: Integration ID sourced from integration manifests. + 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: @@ -47063,10 +47211,15 @@ paths: permissions: - 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) + description: "This endpoint allows you to publish events.\n\n\u2705 **Only events + 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." + use the V1 endpoint or reach out to [support](https://www.datadoghq.com/support/).\n\n\u274C + Notifications are not yet supported for events sent to this endpoint. Use + the V1 endpoint for notification functionality.\n\n\u274C This endpoint is + not available for the Government (US1-FED) site. Contact your account representative + for more information." operationId: CreateEvent requestBody: content: @@ -47076,9 +47229,10 @@ paths: value: data: attributes: + aggregation_key: aggregation_key_123 attributes: author: - name: datadog@datadog.com + name: example@datadog.com type: user change_metadata: dd: @@ -47104,17 +47258,19 @@ paths: rule: datacenter: devcycle.us1.prod category: change + integration_id: custom-events message: payment_processed feature flag has been enabled tags: - - env:test + - env:api_client_test + timestamp: '2020-01-01T01:30:15.010000Z' title: payment_processed feature flag updated type: event schema: $ref: '#/components/schemas/EventCreateRequestPayload' - description: Event request object + description: Event creation request payload. required: true responses: - '200': + '202': content: application/json: schema: @@ -47137,6 +47293,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 dc67406f4d..32fedc94f9 100644 --- a/docs/datadog_api_client.v2.model.rst +++ b/docs/datadog_api_client.v2.model.rst @@ -221,6 +221,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 ----------------------------------------------- @@ -5975,6 +6017,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 --------------------------------------------------- @@ -5989,6 +6038,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..1c6a76c5ca 100644 --- a/examples/v2/events/CreateEvent.py +++ b/examples/v2/events/CreateEvent.py @@ -24,13 +24,15 @@ 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", + name="example@datadog.com", type=ChangeEventCustomAttributesAuthorType.USER, ), change_metadata=dict( @@ -60,9 +62,10 @@ ), ), category=EventCategory.CHANGE, + integration_id=EventPayloadIntegrationId.CUSTOM_EVENTS, message="payment_processed feature flag has been enabled", tags=[ - "env:test", + "env:api_client_test", ], title="payment_processed feature flag updated", ), diff --git a/src/datadog_api_client/v2/api/events_api.py b/src/datadog_api_client/v2/api/events_api.py index 1be946ba3c..0285d24c3a 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": { @@ -129,13 +178,17 @@ def create_event( ) -> EventCreateResponsePayload: """Post an event. - This endpoint allows you to post events. + This endpoint allows you to publish events. + + ✅ **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, use the V1 endpoint or reach out to `support `_. - ✅ **Only events with the change category** are in General Availability. See `Change Tracking `_ for more details. + ❌ Notifications are not yet supported for events sent to this endpoint. Use the V1 endpoint for notification functionality. - ❌ For use cases involving other event categories, please use the V1 endpoint. + ❌ This endpoint is not available for the Government (US1-FED) site. Contact your account representative for more information. - :param body: Event request object + :param body: Event creation request payload. :type body: EventCreateRequestPayload :rtype: EventCreateResponsePayload """ 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..cfe4b4aacf --- /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_, + status: AlertEventCustomAttributesStatus, + custom: Union[AlertEventCustomAttributesCustom, UnsetType] = unset, + links: Union[List[AlertEventCustomAttributesLinksItems], UnsetType] = unset, + priority: Union[AlertEventCustomAttributesPriority, UnsetType] = unset, + **kwargs, + ): + """ + Alert event attributes. + + :param custom: Free form JSON object for arbitrary data. Supports up to 100 properties per object and a maximum nesting depth of 10 levels. + :type custom: AlertEventCustomAttributesCustom, optional + + :param links: The links related to the event. Maximum of 20 links allowed. + :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 + """ + if custom is not unset: + kwargs["custom"] = custom + if links is not unset: + kwargs["links"] = links + if priority is not unset: + kwargs["priority"] = priority + super().__init__(kwargs) + + self_.status = status 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..119ac030ac --- /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): + """ + Free form JSON object for arbitrary data. Supports up to 100 properties per object 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..dcd250d167 --- /dev/null +++ b/src/datadog_api_client/v2/model/alert_event_custom_attributes_links_items.py @@ -0,0 +1,80 @@ +# 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, + "min_length": 1, + }, + "url": { + "max_length": 2048, + "min_length": 1, + }, + } + + @cached_property + def additional_properties_type(_): + return None + + @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 display text 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..ac15f26622 --- /dev/null +++ b/src/datadog_api_client/v2/model/alert_event_custom_attributes_links_items_category.py @@ -0,0 +1,43 @@ +# 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: Must be one of ["runbook", "documentation", "dashboard"]. + :type value: str + """ + + allowed_values = { + "runbook", + "documentation", + "dashboard", + } + RUNBOOK: ClassVar["AlertEventCustomAttributesLinksItemsCategory"] + DOCUMENTATION: ClassVar["AlertEventCustomAttributesLinksItemsCategory"] + DASHBOARD: ClassVar["AlertEventCustomAttributesLinksItemsCategory"] + + @cached_property + def openapi_types(_): + return { + "value": (str,), + } + + +AlertEventCustomAttributesLinksItemsCategory.RUNBOOK = AlertEventCustomAttributesLinksItemsCategory("runbook") +AlertEventCustomAttributesLinksItemsCategory.DOCUMENTATION = AlertEventCustomAttributesLinksItemsCategory( + "documentation" +) +AlertEventCustomAttributesLinksItemsCategory.DASHBOARD = AlertEventCustomAttributesLinksItemsCategory("dashboard") 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..7d50dd7f44 --- /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: If omitted defaults to "5". 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..2883bddb51 --- /dev/null +++ b/src/datadog_api_client/v2/model/alert_event_custom_attributes_status.py @@ -0,0 +1,41 @@ +# 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 ["warn", "error", "ok"]. + :type value: str + """ + + allowed_values = { + "warn", + "error", + "ok", + } + WARN: ClassVar["AlertEventCustomAttributesStatus"] + ERROR: ClassVar["AlertEventCustomAttributesStatus"] + OK: ClassVar["AlertEventCustomAttributesStatus"] + + @cached_property + def openapi_types(_): + return { + "value": (str,), + } + + +AlertEventCustomAttributesStatus.WARN = AlertEventCustomAttributesStatus("warn") +AlertEventCustomAttributesStatus.ERROR = AlertEventCustomAttributesStatus("error") +AlertEventCustomAttributesStatus.OK = AlertEventCustomAttributesStatus("ok") diff --git a/src/datadog_api_client/v2/model/change_event_custom_attributes.py b/src/datadog_api_client/v2/model/change_event_custom_attributes.py index 757e9c641f..9a9984c9e3 100644 --- a/src/datadog_api_client/v2/model/change_event_custom_attributes.py +++ b/src/datadog_api_client/v2/model/change_event_custom_attributes.py @@ -28,6 +28,16 @@ class ChangeEventCustomAttributes(ModelNormal): + validations = { + "impacted_resources": { + "max_items": 100, + }, + } + + @cached_property + def additional_properties_type(_): + return None + @cached_property def openapi_types(_): from datadog_api_client.v2.model.change_event_custom_attributes_author import ChangeEventCustomAttributesAuthor @@ -112,25 +122,25 @@ def __init__( **kwargs, ): """ - Object representing custom change event attributes. + Change event attributes. - :param author: Object representing the entity which made the change. Optional field but if provided should include ``type`` and ``name``. + :param author: The entity that made the change. Optional, if provided it must include ``type`` and ``name``. :type author: ChangeEventCustomAttributesAuthor, optional - :param change_metadata: Free form object with information related to the ``change`` event. Can be arbitrarily nested and contain any valid JSON. + :param change_metadata: Free form JSON object with information related to the ``change`` event. Supports up to 100 properties per object and a maximum nesting depth of 10 levels. :type change_metadata: {str: (bool, date, datetime, dict, float, int, list, str, UUID, none_type,)}, optional - :param changed_resource: Object representing a uniquely identified resource. + :param changed_resource: A uniquely identified resource. :type changed_resource: ChangeEventCustomAttributesChangedResource :param impacted_resources: 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. + the change event at the correct location. Only resources of type ``service`` are supported. Maximum of 100 impacted resources allowed. :type impacted_resources: [ChangeEventCustomAttributesImpactedResourcesItems], optional - :param new_value: Free form object to track new value of the changed resource. + :param new_value: Free form JSON object representing the new state of the changed resource. :type new_value: {str: (bool, date, datetime, dict, float, int, list, str, UUID, none_type,)}, optional - :param prev_value: Free form object to track previous value of the changed resource. + :param prev_value: Free form JSON object representing the previous state of the changed resource. :type prev_value: {str: (bool, date, datetime, dict, float, int, list, str, UUID, none_type,)}, optional """ if author is not unset: diff --git a/src/datadog_api_client/v2/model/change_event_custom_attributes_author.py b/src/datadog_api_client/v2/model/change_event_custom_attributes_author.py index 5bb1f4e8bc..ab5e7ddd9f 100644 --- a/src/datadog_api_client/v2/model/change_event_custom_attributes_author.py +++ b/src/datadog_api_client/v2/model/change_event_custom_attributes_author.py @@ -21,9 +21,14 @@ class ChangeEventCustomAttributesAuthor(ModelNormal): validations = { "name": { "max_length": 128, + "min_length": 1, }, } + @cached_property + def additional_properties_type(_): + return None + @cached_property def openapi_types(_): from datadog_api_client.v2.model.change_event_custom_attributes_author_type import ( @@ -42,9 +47,9 @@ def openapi_types(_): def __init__(self_, name: str, type: ChangeEventCustomAttributesAuthorType, **kwargs): """ - Object representing the entity which made the change. Optional field but if provided should include ``type`` and ``name``. + The entity that made the change. Optional, if provided it must include ``type`` and ``name``. - :param name: Author's name. Limited to 128 characters. + :param name: The name of the user or system that made the change. Limited to 128 characters. :type name: str :param type: Author's type. diff --git a/src/datadog_api_client/v2/model/change_event_custom_attributes_changed_resource.py b/src/datadog_api_client/v2/model/change_event_custom_attributes_changed_resource.py index f0d39cb4f9..57dae98aec 100644 --- a/src/datadog_api_client/v2/model/change_event_custom_attributes_changed_resource.py +++ b/src/datadog_api_client/v2/model/change_event_custom_attributes_changed_resource.py @@ -18,6 +18,17 @@ class ChangeEventCustomAttributesChangedResource(ModelNormal): + validations = { + "name": { + "max_length": 128, + "min_length": 1, + }, + } + + @cached_property + def additional_properties_type(_): + return None + @cached_property def openapi_types(_): from datadog_api_client.v2.model.change_event_custom_attributes_changed_resource_type import ( @@ -36,12 +47,12 @@ def openapi_types(_): def __init__(self_, name: str, type: ChangeEventCustomAttributesChangedResourceType, **kwargs): """ - Object representing a uniquely identified resource. + A uniquely identified resource. - :param name: Resource's name. + :param name: The name of the resource that was changed. Limited to 128 characters. :type name: str - :param type: Resource's type. + :param type: The type of the resource that was changed. :type type: ChangeEventCustomAttributesChangedResourceType """ super().__init__(kwargs) diff --git a/src/datadog_api_client/v2/model/change_event_custom_attributes_changed_resource_type.py b/src/datadog_api_client/v2/model/change_event_custom_attributes_changed_resource_type.py index 06de45b414..6556569be9 100644 --- a/src/datadog_api_client/v2/model/change_event_custom_attributes_changed_resource_type.py +++ b/src/datadog_api_client/v2/model/change_event_custom_attributes_changed_resource_type.py @@ -14,7 +14,7 @@ class ChangeEventCustomAttributesChangedResourceType(ModelSimple): """ - Resource's type. + The type of the resource that was changed. :param value: Must be one of ["feature_flag", "configuration"]. :type value: str diff --git a/src/datadog_api_client/v2/model/change_event_custom_attributes_impacted_resources_items.py b/src/datadog_api_client/v2/model/change_event_custom_attributes_impacted_resources_items.py index 129b7c01a9..f3e79fd840 100644 --- a/src/datadog_api_client/v2/model/change_event_custom_attributes_impacted_resources_items.py +++ b/src/datadog_api_client/v2/model/change_event_custom_attributes_impacted_resources_items.py @@ -18,6 +18,17 @@ class ChangeEventCustomAttributesImpactedResourcesItems(ModelNormal): + validations = { + "name": { + "max_length": 128, + "min_length": 1, + }, + } + + @cached_property + def additional_properties_type(_): + return None + @cached_property def openapi_types(_): from datadog_api_client.v2.model.change_event_custom_attributes_impacted_resources_items_type import ( @@ -36,12 +47,12 @@ def openapi_types(_): def __init__(self_, name: str, type: ChangeEventCustomAttributesImpactedResourcesItemsType, **kwargs): """ - Object representing a uniquely identified resource. Only the resource type ``service`` is supported. + Object representing a uniquely identified resource. - :param name: Resource's name. + :param name: The name of the impacted resource. Limited to 128 characters. :type name: str - :param type: Resource's type. + :param type: The type of the impacted resource. :type type: ChangeEventCustomAttributesImpactedResourcesItemsType """ super().__init__(kwargs) diff --git a/src/datadog_api_client/v2/model/change_event_custom_attributes_impacted_resources_items_type.py b/src/datadog_api_client/v2/model/change_event_custom_attributes_impacted_resources_items_type.py index b020054bcb..6d01bec098 100644 --- a/src/datadog_api_client/v2/model/change_event_custom_attributes_impacted_resources_items_type.py +++ b/src/datadog_api_client/v2/model/change_event_custom_attributes_impacted_resources_items_type.py @@ -14,7 +14,7 @@ class ChangeEventCustomAttributesImpactedResourcesItemsType(ModelSimple): """ - Resource's type. + The type of the impacted resource. :param value: If omitted defaults to "service". Must be one of ["service"]. :type value: str diff --git a/src/datadog_api_client/v2/model/event_category.py b/src/datadog_api_client/v2/model/event_category.py index 9dc88b7cbd..8d824eb024 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 identifying the type of event. - :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..33784ce8bc 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. + An event object. :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..d771f9a35e 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 + :param data: An event object. + :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..c3a58c4d26 100644 --- a/src/datadog_api_client/v2/model/event_create_response.py +++ b/src/datadog_api_client/v2/model/event_create_response.py @@ -39,12 +39,12 @@ def __init__( **kwargs, ): """ - Object containing an event response. + Event object. - :param attributes: JSON object containing all events attributes and their associated values. + :param attributes: Event attributes. :type attributes: EventCreateResponseAttributes, optional - :param type: Event type + :param type: Entity type. :type type: str, optional """ if attributes is not unset: diff --git a/src/datadog_api_client/v2/model/event_create_response_attributes.py b/src/datadog_api_client/v2/model/event_create_response_attributes.py index ec3a68a9fe..6d7c16fc1e 100644 --- a/src/datadog_api_client/v2/model/event_create_response_attributes.py +++ b/src/datadog_api_client/v2/model/event_create_response_attributes.py @@ -36,9 +36,9 @@ def openapi_types(_): def __init__(self_, attributes: Union[EventCreateResponseAttributesAttributes, UnsetType] = unset, **kwargs): """ - JSON object containing all events attributes and their associated values. + Event attributes. - :param attributes: JSON object of attributes from your events. + :param attributes: JSON object for category-specific attributes. :type attributes: EventCreateResponseAttributesAttributes, optional """ if attributes is not unset: diff --git a/src/datadog_api_client/v2/model/event_create_response_attributes_attributes.py b/src/datadog_api_client/v2/model/event_create_response_attributes_attributes.py index 84adda5368..7b4e492b00 100644 --- a/src/datadog_api_client/v2/model/event_create_response_attributes_attributes.py +++ b/src/datadog_api_client/v2/model/event_create_response_attributes_attributes.py @@ -36,7 +36,7 @@ def openapi_types(_): def __init__(self_, evt: Union[EventCreateResponseAttributesAttributesEvt, UnsetType] = unset, **kwargs): """ - JSON object of attributes from your events. + JSON object for category-specific attributes. :param evt: JSON object of event system attributes. :type evt: EventCreateResponseAttributesAttributesEvt, optional 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..538ecbc439 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 @@ -18,19 +18,26 @@ class EventCreateResponseAttributesAttributesEvt(ModelNormal): 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_, id: Union[str, UnsetType] = unset, uid: Union[str, UnsetType] = unset, **kwargs): """ JSON object of event system attributes. - :param id: Event id + :param id: Event identifier. This field is deprecated and will be removed in a future version. Use the ``uid`` field instead. **Deprecated**. :type id: str, optional + + :param uid: A unique identifier for the event. You can use this identifier to query or reference the event. + :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..064ca39ff0 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. + Event creation response. - :param data: Object containing an event response. + :param data: Event object. :type data: EventCreateResponse, optional + + :param links: Links to the event. + :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..da6b83e967 --- /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 to the event. + + :param self: The URL of the event. This link is only functional when using the default 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..6e310de013 100644 --- a/src/datadog_api_client/v2/model/event_payload.py +++ b/src/datadog_api_client/v2/model/event_payload.py @@ -16,31 +16,46 @@ 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): validations = { "aggregation_key": { "max_length": 100, + "min_length": 1, }, "message": { "max_length": 4000, + "min_length": 1, + }, + "tags": { + "max_items": 100, + "min_items": 1, }, "title": { "max_length": 500, + "min_length": 1, }, } + @cached_property + def additional_properties_type(_): + return None + @cached_property 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 +66,7 @@ def openapi_types(_): "aggregation_key": "aggregation_key", "attributes": "attributes", "category": "category", + "integration_id": "integration_id", "message": "message", "tags": "tags", "timestamp": "timestamp", @@ -59,10 +75,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, @@ -71,19 +88,22 @@ def __init__( """ Event attributes. - :param aggregation_key: An arbitrary string to use for aggregation when correlating events. Limited to 100 characters. + :param aggregation_key: A string used for aggregation when `correlating `_ events. If you specify a key, events are deduplicated to alerts based on this key. Limited to 100 characters. :type aggregation_key: str, optional - :param attributes: JSON object for custom attributes. Schema are different per each event category. + :param attributes: JSON object for category-specific attributes. Schema is different per 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 identifying the type of event. :type category: EventCategory - :param message: The body of the event. Limited to 4000 characters. + :param integration_id: Integration ID sourced from integration manifests. + :type integration_id: EventPayloadIntegrationId, optional + + :param message: Free formed text associated with the event. It's suggested to use ``data.attributes.attributes.custom`` for well-structured attributes. Limited to 4000 characters. :type message: str, optional - :param tags: A list of tags to apply to the event. + :param tags: A list of tags associated with the event. Maximum of 100 tags allowed. Refer to `Tags docs `_. :type tags: [str], optional @@ -92,11 +112,13 @@ def __init__( Defaults to the timestamp of receipt. Limited to values no older than 18 hours. :type timestamp: str, optional - :param title: The event title. Limited to 500 characters. + :param title: The title of the event. Limited to 500 characters. :type title: str """ 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..d19863ce35 100644 --- a/src/datadog_api_client/v2/model/event_payload_attributes.py +++ b/src/datadog_api_client/v2/model/event_payload_attributes.py @@ -13,26 +13,38 @@ class EventPayloadAttributes(ModelComposed): def __init__(self, **kwargs): """ - JSON object for custom attributes. Schema are different per each event category. + JSON object for category-specific attributes. Schema is different per event category. - :param author: Object representing the entity which made the change. Optional field but if provided should include `type` and `name`. + :param author: The entity that made the change. Optional, if provided it must include `type` and `name`. :type author: ChangeEventCustomAttributesAuthor, optional - :param change_metadata: Free form object with information related to the `change` event. Can be arbitrarily nested and contain any valid JSON. + :param change_metadata: Free form JSON object with information related to the `change` event. Supports up to 100 properties per object and a maximum nesting depth of 10 levels. :type change_metadata: {str: (bool, date, datetime, dict, float, int, list, str, UUID, none_type,)}, optional - :param changed_resource: Object representing a uniquely identified resource. + :param changed_resource: A uniquely identified resource. :type changed_resource: ChangeEventCustomAttributesChangedResource :param impacted_resources: 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. + the change event at the correct location. Only resources of type `service` are supported. Maximum of 100 impacted resources allowed. :type impacted_resources: [ChangeEventCustomAttributesImpactedResourcesItems], optional - :param new_value: Free form object to track new value of the changed resource. + :param new_value: Free form JSON object representing the new state of the changed resource. :type new_value: {str: (bool, date, datetime, dict, float, int, list, str, UUID, none_type,)}, optional - :param prev_value: Free form object to track previous value of the changed resource. + :param prev_value: Free form JSON object representing the previous state of the changed resource. :type prev_value: {str: (bool, date, datetime, dict, float, int, list, str, UUID, none_type,)}, optional + + :param custom: Free form JSON object for arbitrary data. Supports up to 100 properties per object and a maximum nesting depth of 10 levels. + :type custom: AlertEventCustomAttributesCustom, optional + + :param links: The links related to the event. Maximum of 20 links allowed. + :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 """ 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..937206a44d --- /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 ID sourced from integration manifests. + + :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 e30ae22117..15d561cee7 100644 --- a/src/datadog_api_client/v2/models/__init__.py +++ b/src/datadog_api_client/v2/models/__init__.py @@ -93,6 +93,14 @@ from datadog_api_client.v2.model.active_billing_dimensions_type import ActiveBillingDimensionsType from datadog_api_client.v2.model.add_member_team_request import AddMemberTeamRequest 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 @@ -1150,8 +1158,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 @@ -3590,6 +3600,12 @@ "ActiveBillingDimensionsType", "AddMemberTeamRequest", "Advisory", + "AlertEventCustomAttributes", + "AlertEventCustomAttributesCustom", + "AlertEventCustomAttributesLinksItems", + "AlertEventCustomAttributesLinksItemsCategory", + "AlertEventCustomAttributesPriority", + "AlertEventCustomAttributesStatus", "Annotation", "AnnotationDisplay", "AnnotationDisplayBounds", @@ -4351,8 +4367,10 @@ "EventCreateResponseAttributesAttributes", "EventCreateResponseAttributesAttributesEvt", "EventCreateResponsePayload", + "EventCreateResponsePayloadLinks", "EventPayload", "EventPayloadAttributes", + "EventPayloadIntegrationId", "EventPriority", "EventResponse", "EventResponseAttributes", diff --git a/tests/v2/cassettes/test_scenarios/test_post_an_event_returns_bad_request_response.frozen b/tests/v2/cassettes/test_scenarios/test_post_an_event_returns_bad_request_response.frozen new file mode 100644 index 0000000000..a1cd4e8e4a --- /dev/null +++ b/tests/v2/cassettes/test_scenarios/test_post_an_event_returns_bad_request_response.frozen @@ -0,0 +1 @@ +2025-06-10T15:38:58.529Z \ No newline at end of file diff --git a/tests/v2/cassettes/test_scenarios/test_post_an_event_returns_bad_request_response.yaml b/tests/v2/cassettes/test_scenarios/test_post_an_event_returns_bad_request_response.yaml new file mode 100644 index 0000000000..6e18cd495a --- /dev/null +++ b/tests/v2/cassettes/test_scenarios/test_post_an_event_returns_bad_request_response.yaml @@ -0,0 +1,23 @@ +interactions: +- request: + 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 + feature flag has been enabled","tags":["env:api_client_test"],"title":"payment_processed + feature flag updated"},"type":"event"}}' + headers: + accept: + - application/json + content-type: + - application/json + method: POST + uri: https://event-management-intake.datadoghq.com/api/v2/events + response: + body: + string: '{"errors":[{"status":"400","title":"Bad Request","detail":"JSON validation + failed at $.data.attributes.category: value must be one of: [\"alert\", \"change\"]."}]}' + headers: + content-type: + - application/json + status: + code: 400 + message: Bad Request +version: 1 diff --git a/tests/v2/cassettes/test_scenarios/test_post_an_event_returns_ok_response.frozen b/tests/v2/cassettes/test_scenarios/test_post_an_event_returns_ok_response.frozen new file mode 100644 index 0000000000..42309286e2 --- /dev/null +++ b/tests/v2/cassettes/test_scenarios/test_post_an_event_returns_ok_response.frozen @@ -0,0 +1 @@ +2025-06-10T15:38:58.954Z \ No newline at end of file diff --git a/tests/v2/cassettes/test_scenarios/test_post_an_event_returns_ok_response.yaml b/tests/v2/cassettes/test_scenarios/test_post_an_event_returns_ok_response.yaml new file mode 100644 index 0000000000..3af38bf756 --- /dev/null +++ b/tests/v2/cassettes/test_scenarios/test_post_an_event_returns_ok_response.yaml @@ -0,0 +1,22 @@ +interactions: +- request: + 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 + feature flag has been enabled","tags":["env:api_client_test"],"title":"payment_processed + feature flag updated"},"type":"event"}}' + headers: + accept: + - application/json + content-type: + - application/json + method: POST + uri: https://event-management-intake.datadoghq.com/api/v2/events + response: + body: + string: '{"data":{"attributes":{"attributes":{"evt":{"uid":"AZdafqaTAACKG_iMQ82pmAAA"}}},"id":"_","type":"event"},"links":{"self":"https://app.datadoghq.com/event/event?uid=AZdafqaTAACKG_iMQ82pmAAA"}}' + headers: + content-type: + - application/json + status: + code: 202 + message: Accepted +version: 1 diff --git a/tests/v2/features/events.feature b/tests/v2/features/events.feature index a8c1307ac6..0a69d19520 100644 --- a/tests/v2/features/events.feature +++ b/tests/v2/features/events.feature @@ -50,19 +50,21 @@ Feature: Events Then the response status is 200 OK And the response "data" has length 0 - @generated @skip @team:DataDog/event-management + @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": "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"}} When the request is sent Then the response status is 400 Bad request - @generated @skip @team:DataDog/event-management + @skip-validation @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": "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"}} When the request is sent - Then the response status is 200 OK + Then the response status is 202 OK + And the response "data.type" is equal to "event" + And the response "data.attributes.attributes.evt" has field "uid" @team:DataDog/event-management Scenario: Search events returns "Bad Request" response diff --git a/tests/v2/features/undo.json b/tests/v2/features/undo.json index e81cb7b7ce..3cc857a736 100644 --- a/tests/v2/features/undo.json +++ b/tests/v2/features/undo.json @@ -934,7 +934,7 @@ "CreateEvent": { "tag": "Events", "undo": { - "type": "unsafe" + "type": "safe" } }, "SearchEvents": {