From 7980aee1238c7e392897265ede22a38a64ca0618 Mon Sep 17 00:00:00 2001 From: "ci.datadog-api-spec" Date: Thu, 5 Jun 2025 21:32:13 +0000 Subject: [PATCH] Regenerate client from commit 698653bf of spec repo --- .apigentools-info | 8 +- .generator/schemas/v2/openapi.yaml | 209 ++++++++++++++++-- examples/v2_events_CreateEvent.rs | 82 ++++--- src/datadog/configuration.rs | 78 +++++++ src/datadogV2/api/api_events.rs | 8 +- src/datadogV2/model/mod.rs | 14 ++ .../model_alert_event_custom_attributes.rs | 157 +++++++++++++ ...ert_event_custom_attributes_links_items.rs | 116 ++++++++++ ..._custom_attributes_links_items_category.rs | 54 +++++ ..._alert_event_custom_attributes_priority.rs | 60 +++++ ...el_alert_event_custom_attributes_status.rs | 54 +++++ .../model_change_event_custom_attributes.rs | 26 +-- ...l_change_event_custom_attributes_author.rs | 24 +- ...vent_custom_attributes_changed_resource.rs | 22 +- ...tom_attributes_impacted_resources_items.rs | 22 +- src/datadogV2/model/model_event_category.rs | 3 + .../model/model_event_create_request.rs | 37 +--- .../model_event_create_request_payload.rs | 21 +- .../model/model_event_create_response.rs | 2 +- ...eate_response_attributes_attributes_evt.rs | 24 +- .../model_event_create_response_payload.rs | 21 ++ ...del_event_create_response_payload_links.rs | 105 +++++++++ src/datadogV2/model/model_event_payload.rs | 58 +++-- .../model/model_event_payload_attributes.rs | 11 +- .../model_event_payload_integration_id.rs | 48 ++++ ...-event-returns-Bad-request-response.frozen | 1 + ...an-event-returns-Bad-request-response.json | 39 ++++ .../Post-an-event-returns-OK-response.frozen | 1 + .../Post-an-event-returns-OK-response.json | 39 ++++ tests/scenarios/features/v2/events.feature | 12 +- tests/scenarios/features/v2/undo.json | 2 +- 31 files changed, 1142 insertions(+), 216 deletions(-) create mode 100644 src/datadogV2/model/model_alert_event_custom_attributes.rs create mode 100644 src/datadogV2/model/model_alert_event_custom_attributes_links_items.rs create mode 100644 src/datadogV2/model/model_alert_event_custom_attributes_links_items_category.rs create mode 100644 src/datadogV2/model/model_alert_event_custom_attributes_priority.rs create mode 100644 src/datadogV2/model/model_alert_event_custom_attributes_status.rs create mode 100644 src/datadogV2/model/model_event_create_response_payload_links.rs create mode 100644 src/datadogV2/model/model_event_payload_integration_id.rs create mode 100644 tests/scenarios/cassettes/v2/events/Post-an-event-returns-Bad-request-response.frozen create mode 100644 tests/scenarios/cassettes/v2/events/Post-an-event-returns-Bad-request-response.json create mode 100644 tests/scenarios/cassettes/v2/events/Post-an-event-returns-OK-response.frozen create mode 100644 tests/scenarios/cassettes/v2/events/Post-an-event-returns-OK-response.json diff --git a/.apigentools-info b/.apigentools-info index c6c860465..45836f8b7 100644 --- a/.apigentools-info +++ b/.apigentools-info @@ -4,13 +4,13 @@ "spec_versions": { "v1": { "apigentools_version": "1.6.6", - "regenerated": "2025-06-05 09:49:39.264892", - "spec_repo_commit": "faa72400" + "regenerated": "2025-06-05 21:26:09.273300", + "spec_repo_commit": "698653bf" }, "v2": { "apigentools_version": "1.6.6", - "regenerated": "2025-06-05 09:49:39.280328", - "spec_repo_commit": "faa72400" + "regenerated": "2025-06-05 21:26:09.289440", + "spec_repo_commit": "698653bf" } } } \ No newline at end of file diff --git a/.generator/schemas/v2/openapi.yaml b/.generator/schemas/v2/openapi.yaml index 2ea6329ff..29ca8a2de 100644 --- a/.generator/schemas/v2/openapi.yaml +++ b/.generator/schemas/v2/openapi.yaml @@ -2211,6 +2211,97 @@ 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' + required: + - status + 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. 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 title 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. Defaults to `5`. + 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! @@ -6903,6 +6994,7 @@ components: type: integer type: object ChangeEventCustomAttributes: + additionalProperties: false description: Object representing custom change event attributes. properties: author: @@ -6926,12 +7018,13 @@ components: to provide an impacted resource to display the change event at the right location. Only resources of type `service` - are supported.' + 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: {} @@ -6955,13 +7048,15 @@ 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: Object representing the entity that made the change. Optional field + but if provided should include `type` and `name`. properties: name: description: Author's name. Limited to 128 characters. example: datadog@datadog.com maxLength: 128 + minLength: 1 type: string type: $ref: '#/components/schemas/ChangeEventCustomAttributesAuthorType' @@ -6980,11 +7075,14 @@ components: - USER - SYSTEM ChangeEventCustomAttributesChangedResource: + additionalProperties: false description: Object representing a uniquely identified resource. properties: name: description: Resource's name. example: fallback_payments_test + maxLength: 128 + minLength: 1 type: string type: $ref: '#/components/schemas/ChangeEventCustomAttributesChangedResourceType' @@ -7003,12 +7101,15 @@ components: - FEATURE_FLAG - CONFIGURATION ChangeEventCustomAttributesImpactedResourcesItems: + additionalProperties: false description: Object representing a uniquely identified resource. Only the resource type `service` is supported. properties: name: description: Resource's name. example: payments_api + maxLength: 128 + minLength: 1 type: string type: $ref: '#/components/schemas/ChangeEventCustomAttributesImpactedResourcesItemsType' @@ -14542,15 +14643,15 @@ 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. enum: - change + - alert example: change type: string x-enum-varnames: - CHANGE + - ALERT EventCreateRequest: description: Object representing an event creation request. properties: @@ -14558,12 +14659,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. @@ -14579,7 +14685,7 @@ components: attributes: $ref: '#/components/schemas/EventCreateResponseAttributes' type: - description: Event type + description: Event type. example: event type: string type: object @@ -14600,7 +14706,12 @@ components: description: JSON object of event system attributes. properties: id: - description: Event id + deprecated: true + description: (Deprecated) Event id. Use `uid` instead. + type: string + uid: + description: A unique identifier for the event. You can use this id to query + or reference the event. type: string type: object EventCreateResponsePayload: @@ -14608,23 +14719,40 @@ 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 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. + 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. 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. @@ -14634,7 +14762,11 @@ components: - env: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) @@ -14649,6 +14781,7 @@ components: description: The event title. Limited to 500 characters. example: payment_processed feature flag updated maxLength: 500 + minLength: 1 type: string required: - title @@ -14656,10 +14789,20 @@ components: - attributes type: object EventPayloadAttributes: - description: JSON object for custom attributes. Schema are different per each - event category. + description: JSON object for custom attributes. Schema is different per 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: @@ -46725,9 +46868,12 @@ 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." + please use the V1 endpoint.\n\n\u274C Currently, notifications are not supported + for events sent to this endpoint, please use the V1 endpoint for notification + functionality." operationId: CreateEvent requestBody: content: @@ -46737,6 +46883,7 @@ paths: value: data: attributes: + aggregation_key: aggregation_key_123 attributes: author: name: datadog@datadog.com @@ -46765,9 +46912,11 @@ paths: rule: datacenter: devcycle.us1.prod category: change + integration_id: custom-events message: payment_processed feature flag has been enabled tags: - env:test + timestamp: '2020-01-01T01:30:15.010000Z' title: payment_processed feature flag updated type: event schema: @@ -46775,7 +46924,7 @@ paths: description: Event request object required: true responses: - '200': + '202': content: application/json: schema: @@ -46798,6 +46947,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/examples/v2_events_CreateEvent.rs b/examples/v2_events_CreateEvent.rs index 41b12a62a..7bd8a7239 100644 --- a/examples/v2_events_CreateEvent.rs +++ b/examples/v2_events_CreateEvent.rs @@ -14,53 +14,51 @@ use datadog_api_client::datadogV2::model::EventCreateRequestPayload; use datadog_api_client::datadogV2::model::EventCreateRequestType; use datadog_api_client::datadogV2::model::EventPayload; use datadog_api_client::datadogV2::model::EventPayloadAttributes; +use datadog_api_client::datadogV2::model::EventPayloadIntegrationId; use serde_json::Value; use std::collections::BTreeMap; #[tokio::main] async fn main() { - let body = EventCreateRequestPayload::new().data( - EventCreateRequest::new() - .attributes( - EventPayload::new( - EventPayloadAttributes::ChangeEventCustomAttributes(Box::new( - ChangeEventCustomAttributes::new( - ChangeEventCustomAttributesChangedResource::new( - "fallback_payments_test".to_string(), - ChangeEventCustomAttributesChangedResourceType::FEATURE_FLAG, - ), - ) - .author(ChangeEventCustomAttributesAuthor::new( - "datadog@datadog.com".to_string(), - ChangeEventCustomAttributesAuthorType::USER, - )) - .change_metadata(BTreeMap::from([( - "resource_link".to_string(), - Value::from("datadog.com/feature/fallback_payments_test"), - )])) - .impacted_resources(vec![ - ChangeEventCustomAttributesImpactedResourcesItems::new( - "payments_api".to_string(), - ChangeEventCustomAttributesImpactedResourcesItemsType::SERVICE, - ), - ]) - .new_value(BTreeMap::from([ - ("enabled".to_string(), Value::from("True")), - ("percentage".to_string(), Value::from("50%")), - ])) - .prev_value(BTreeMap::from([ - ("enabled".to_string(), Value::from("True")), - ("percentage".to_string(), Value::from("10%")), - ])), - )), - EventCategory::CHANGE, - "payment_processed feature flag updated".to_string(), - ) - .message("payment_processed feature flag has been enabled".to_string()) - .tags(vec!["env:test".to_string()]), - ) - .type_(EventCreateRequestType::EVENT), - ); + let body = EventCreateRequestPayload::new(EventCreateRequest::new( + EventPayload::new( + EventPayloadAttributes::ChangeEventCustomAttributes(Box::new( + ChangeEventCustomAttributes::new(ChangeEventCustomAttributesChangedResource::new( + "fallback_payments_test".to_string(), + ChangeEventCustomAttributesChangedResourceType::FEATURE_FLAG, + )) + .author(ChangeEventCustomAttributesAuthor::new( + "datadog@datadog.com".to_string(), + ChangeEventCustomAttributesAuthorType::USER, + )) + .change_metadata(BTreeMap::from([( + "resource_link".to_string(), + Value::from("datadog.com/feature/fallback_payments_test"), + )])) + .impacted_resources(vec![ + ChangeEventCustomAttributesImpactedResourcesItems::new( + "payments_api".to_string(), + ChangeEventCustomAttributesImpactedResourcesItemsType::SERVICE, + ), + ]) + .new_value(BTreeMap::from([ + ("enabled".to_string(), Value::from("True")), + ("percentage".to_string(), Value::from("50%")), + ])) + .prev_value(BTreeMap::from([ + ("enabled".to_string(), Value::from("True")), + ("percentage".to_string(), Value::from("10%")), + ])), + )), + EventCategory::CHANGE, + "Datadog api client test".to_string(), + ) + .aggregation_key("aggregation_key_123".to_string()) + .integration_id(EventPayloadIntegrationId::CUSTOM_EVENTS) + .message("payment_processed feature flag has been enabled".to_string()) + .tags(vec!["env:test".to_string()]), + EventCreateRequestType::EVENT, + )); let configuration = datadog::Configuration::new(); let api = EventsAPI::with_config(configuration); let resp = api.create_event(body).await; diff --git a/src/datadog/configuration.rs b/src/datadog/configuration.rs index 838cd3b63..01573ebd6 100644 --- a/src/datadog/configuration.rs +++ b/src/datadog/configuration.rs @@ -473,6 +473,84 @@ lazy_static! { }, ], ), + ( + "v2.create_event".into(), + vec![ + ServerConfiguration { + url: "https://{subdomain}.{site}".into(), + description: "No description provided".into(), + variables: HashMap::from([ + ( + "site".into(), + ServerVariable { + description: "The regional site for customers.".into(), + default_value: "datadoghq.com".into(), + enum_values: vec![ + "datadoghq.com".into(), + "us3.datadoghq.com".into(), + "us5.datadoghq.com".into(), + "ap1.datadoghq.com".into(), + "datadoghq.eu".into(), + "ddog-gov.com".into(), + ], + }, + ), + ( + "subdomain".into(), + ServerVariable { + description: "The subdomain where the API is deployed.".into(), + default_value: "event-management-intake".into(), + enum_values: vec![], + }, + ), + ]), + }, + ServerConfiguration { + url: "{protocol}://{name}".into(), + description: "No description provided".into(), + variables: HashMap::from([ + ( + "name".into(), + ServerVariable { + description: "Full site DNS name.".into(), + default_value: "event-management-intake.datadoghq.com".into(), + enum_values: vec![], + }, + ), + ( + "protocol".into(), + ServerVariable { + description: "The protocol for accessing the API.".into(), + default_value: "https".into(), + enum_values: vec![], + }, + ), + ]), + }, + ServerConfiguration { + url: "https://{subdomain}.{site}".into(), + description: "No description provided".into(), + variables: HashMap::from([ + ( + "site".into(), + ServerVariable { + description: "Any Datadog deployment.".into(), + default_value: "datadoghq.com".into(), + enum_values: vec![], + }, + ), + ( + "subdomain".into(), + ServerVariable { + description: "The subdomain where the API is deployed.".into(), + default_value: "event-management-intake".into(), + enum_values: vec![], + }, + ), + ]), + }, + ], + ), ( "v2.submit_log".into(), vec![ diff --git a/src/datadogV2/api/api_events.rs b/src/datadogV2/api/api_events.rs index 49e7e0e97..32ac0d5eb 100644 --- a/src/datadogV2/api/api_events.rs +++ b/src/datadogV2/api/api_events.rs @@ -171,9 +171,11 @@ impl EventsAPI { /// 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. + /// + /// ❌ Currently, notifications are not supported for events sent to this endpoint, please use the V1 endpoint for notification functionality. pub async fn create_event( &self, body: crate::datadogV2::model::EventCreateRequestPayload, @@ -195,9 +197,11 @@ impl EventsAPI { /// 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. + /// + /// ❌ Currently, notifications are not supported for events sent to this endpoint, please use the V1 endpoint for notification functionality. pub async fn create_event_with_http_info( &self, body: crate::datadogV2::model::EventCreateRequestPayload, diff --git a/src/datadogV2/model/mod.rs b/src/datadogV2/model/mod.rs index aa19fa20a..cfd08c096 100644 --- a/src/datadogV2/model/mod.rs +++ b/src/datadogV2/model/mod.rs @@ -1506,10 +1506,22 @@ pub mod model_change_event_custom_attributes_impacted_resources_items; pub use self::model_change_event_custom_attributes_impacted_resources_items::ChangeEventCustomAttributesImpactedResourcesItems; pub mod model_change_event_custom_attributes_impacted_resources_items_type; pub use self::model_change_event_custom_attributes_impacted_resources_items_type::ChangeEventCustomAttributesImpactedResourcesItemsType; +pub mod model_alert_event_custom_attributes; +pub use self::model_alert_event_custom_attributes::AlertEventCustomAttributes; +pub mod model_alert_event_custom_attributes_links_items; +pub use self::model_alert_event_custom_attributes_links_items::AlertEventCustomAttributesLinksItems; +pub mod model_alert_event_custom_attributes_links_items_category; +pub use self::model_alert_event_custom_attributes_links_items_category::AlertEventCustomAttributesLinksItemsCategory; +pub mod model_alert_event_custom_attributes_priority; +pub use self::model_alert_event_custom_attributes_priority::AlertEventCustomAttributesPriority; +pub mod model_alert_event_custom_attributes_status; +pub use self::model_alert_event_custom_attributes_status::AlertEventCustomAttributesStatus; pub mod model_event_payload_attributes; pub use self::model_event_payload_attributes::EventPayloadAttributes; pub mod model_event_category; pub use self::model_event_category::EventCategory; +pub mod model_event_payload_integration_id; +pub use self::model_event_payload_integration_id::EventPayloadIntegrationId; pub mod model_event_create_request_type; pub use self::model_event_create_request_type::EventCreateRequestType; pub mod model_event_create_response_payload; @@ -1522,6 +1534,8 @@ pub mod model_event_create_response_attributes_attributes; pub use self::model_event_create_response_attributes_attributes::EventCreateResponseAttributesAttributes; pub mod model_event_create_response_attributes_attributes_evt; pub use self::model_event_create_response_attributes_attributes_evt::EventCreateResponseAttributesAttributesEvt; +pub mod model_event_create_response_payload_links; +pub use self::model_event_create_response_payload_links::EventCreateResponsePayloadLinks; pub mod model_events_list_request; pub use self::model_events_list_request::EventsListRequest; pub mod model_events_query_filter; diff --git a/src/datadogV2/model/model_alert_event_custom_attributes.rs b/src/datadogV2/model/model_alert_event_custom_attributes.rs new file mode 100644 index 000000000..a36131b41 --- /dev/null +++ b/src/datadogV2/model/model_alert_event_custom_attributes.rs @@ -0,0 +1,157 @@ +// 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. +use serde::de::{Error, MapAccess, Visitor}; +use serde::{Deserialize, Deserializer, Serialize}; +use serde_with::skip_serializing_none; +use std::fmt::{self, Formatter}; + +/// Object representing custom alert event attributes. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct AlertEventCustomAttributes { + /// Custom attributes. Support up to 100 properties and a maximum nesting depth of 10 levels. + #[serde(rename = "custom")] + pub custom: Option>, + /// The links related to the event. Maximum of 20 links allowed. + #[serde(rename = "links")] + pub links: Option>, + /// The priority of the alert. Defaults to `5`. + #[serde(rename = "priority")] + pub priority: Option, + /// The status of the alert. + #[serde(rename = "status")] + pub status: crate::datadogV2::model::AlertEventCustomAttributesStatus, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl AlertEventCustomAttributes { + pub fn new( + status: crate::datadogV2::model::AlertEventCustomAttributesStatus, + ) -> AlertEventCustomAttributes { + AlertEventCustomAttributes { + custom: None, + links: None, + priority: None, + status, + _unparsed: false, + } + } + + pub fn custom(mut self, value: std::collections::BTreeMap) -> Self { + self.custom = Some(value); + self + } + + pub fn links( + mut self, + value: Vec, + ) -> Self { + self.links = Some(value); + self + } + + pub fn priority( + mut self, + value: crate::datadogV2::model::AlertEventCustomAttributesPriority, + ) -> Self { + self.priority = Some(value); + self + } +} + +impl<'de> Deserialize<'de> for AlertEventCustomAttributes { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct AlertEventCustomAttributesVisitor; + impl<'a> Visitor<'a> for AlertEventCustomAttributesVisitor { + type Value = AlertEventCustomAttributes; + + fn expecting(&self, f: &mut Formatter<'_>) -> fmt::Result { + f.write_str("a mapping") + } + + fn visit_map(self, mut map: M) -> Result + where + M: MapAccess<'a>, + { + let mut custom: Option> = + None; + let mut links: Option< + Vec, + > = None; + let mut priority: Option< + crate::datadogV2::model::AlertEventCustomAttributesPriority, + > = None; + let mut status: Option = + None; + let mut _unparsed = false; + + while let Some((k, v)) = map.next_entry::()? { + match k.as_str() { + "custom" => { + if v.is_null() { + continue; + } + custom = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "links" => { + if v.is_null() { + continue; + } + links = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "priority" => { + if v.is_null() { + continue; + } + priority = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + if let Some(ref _priority) = priority { + match _priority { + crate::datadogV2::model::AlertEventCustomAttributesPriority::UnparsedObject(_priority) => { + _unparsed = true; + }, + _ => {} + } + } + } + "status" => { + status = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + if let Some(ref _status) = status { + match _status { + crate::datadogV2::model::AlertEventCustomAttributesStatus::UnparsedObject(_status) => { + _unparsed = true; + }, + _ => {} + } + } + } + &_ => { + return Err(serde::de::Error::custom( + "Additional properties not allowed", + )); + } + } + } + let status = status.ok_or_else(|| M::Error::missing_field("status"))?; + + let content = AlertEventCustomAttributes { + custom, + links, + priority, + status, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(AlertEventCustomAttributesVisitor) + } +} diff --git a/src/datadogV2/model/model_alert_event_custom_attributes_links_items.rs b/src/datadogV2/model/model_alert_event_custom_attributes_links_items.rs new file mode 100644 index 000000000..0dae191a7 --- /dev/null +++ b/src/datadogV2/model/model_alert_event_custom_attributes_links_items.rs @@ -0,0 +1,116 @@ +// 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. +use serde::de::{Error, MapAccess, Visitor}; +use serde::{Deserialize, Deserializer, Serialize}; +use serde_with::skip_serializing_none; +use std::fmt::{self, Formatter}; + +/// A link. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct AlertEventCustomAttributesLinksItems { + /// The category of the link. + #[serde(rename = "category")] + pub category: crate::datadogV2::model::AlertEventCustomAttributesLinksItemsCategory, + /// The title of the link. Limited to 300 characters. + #[serde(rename = "title")] + pub title: Option, + /// The URL of the link. Limited to 2048 characters. + #[serde(rename = "url")] + pub url: String, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl AlertEventCustomAttributesLinksItems { + pub fn new( + category: crate::datadogV2::model::AlertEventCustomAttributesLinksItemsCategory, + url: String, + ) -> AlertEventCustomAttributesLinksItems { + AlertEventCustomAttributesLinksItems { + category, + title: None, + url, + _unparsed: false, + } + } + + pub fn title(mut self, value: String) -> Self { + self.title = Some(value); + self + } +} + +impl<'de> Deserialize<'de> for AlertEventCustomAttributesLinksItems { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct AlertEventCustomAttributesLinksItemsVisitor; + impl<'a> Visitor<'a> for AlertEventCustomAttributesLinksItemsVisitor { + type Value = AlertEventCustomAttributesLinksItems; + + fn expecting(&self, f: &mut Formatter<'_>) -> fmt::Result { + f.write_str("a mapping") + } + + fn visit_map(self, mut map: M) -> Result + where + M: MapAccess<'a>, + { + let mut category: Option< + crate::datadogV2::model::AlertEventCustomAttributesLinksItemsCategory, + > = None; + let mut title: Option = None; + let mut url: Option = None; + let mut _unparsed = false; + + while let Some((k, v)) = map.next_entry::()? { + match k.as_str() { + "category" => { + category = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + if let Some(ref _category) = category { + match _category { + crate::datadogV2::model::AlertEventCustomAttributesLinksItemsCategory::UnparsedObject(_category) => { + _unparsed = true; + }, + _ => {} + } + } + } + "title" => { + if v.is_null() { + continue; + } + title = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "url" => { + url = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + &_ => { + return Err(serde::de::Error::custom( + "Additional properties not allowed", + )); + } + } + } + let category = category.ok_or_else(|| M::Error::missing_field("category"))?; + let url = url.ok_or_else(|| M::Error::missing_field("url"))?; + + let content = AlertEventCustomAttributesLinksItems { + category, + title, + url, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(AlertEventCustomAttributesLinksItemsVisitor) + } +} diff --git a/src/datadogV2/model/model_alert_event_custom_attributes_links_items_category.rs b/src/datadogV2/model/model_alert_event_custom_attributes_links_items_category.rs new file mode 100644 index 000000000..23273759c --- /dev/null +++ b/src/datadogV2/model/model_alert_event_custom_attributes_links_items_category.rs @@ -0,0 +1,54 @@ +// 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. + +use serde::{Deserialize, Deserializer, Serialize, Serializer}; + +#[non_exhaustive] +#[derive(Clone, Debug, Eq, PartialEq)] +pub enum AlertEventCustomAttributesLinksItemsCategory { + RUNBOOK, + DOCUMENTATION, + DASHBOARD, + UnparsedObject(crate::datadog::UnparsedObject), +} + +impl ToString for AlertEventCustomAttributesLinksItemsCategory { + fn to_string(&self) -> String { + match self { + Self::RUNBOOK => String::from("runbook"), + Self::DOCUMENTATION => String::from("documentation"), + Self::DASHBOARD => String::from("dashboard"), + Self::UnparsedObject(v) => v.value.to_string(), + } + } +} + +impl Serialize for AlertEventCustomAttributesLinksItemsCategory { + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + match self { + Self::UnparsedObject(v) => v.serialize(serializer), + _ => serializer.serialize_str(self.to_string().as_str()), + } + } +} + +impl<'de> Deserialize<'de> for AlertEventCustomAttributesLinksItemsCategory { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + let s: String = String::deserialize(deserializer)?; + Ok(match s.as_str() { + "runbook" => Self::RUNBOOK, + "documentation" => Self::DOCUMENTATION, + "dashboard" => Self::DASHBOARD, + _ => Self::UnparsedObject(crate::datadog::UnparsedObject { + value: serde_json::Value::String(s.into()), + }), + }) + } +} diff --git a/src/datadogV2/model/model_alert_event_custom_attributes_priority.rs b/src/datadogV2/model/model_alert_event_custom_attributes_priority.rs new file mode 100644 index 000000000..3eacfb3c8 --- /dev/null +++ b/src/datadogV2/model/model_alert_event_custom_attributes_priority.rs @@ -0,0 +1,60 @@ +// 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. + +use serde::{Deserialize, Deserializer, Serialize, Serializer}; + +#[non_exhaustive] +#[derive(Clone, Debug, Eq, PartialEq)] +pub enum AlertEventCustomAttributesPriority { + PRIORITY_ONE, + PRIORITY_TWO, + PRIORITY_THREE, + PRIORITY_FOUR, + PRIORITY_FIVE, + UnparsedObject(crate::datadog::UnparsedObject), +} + +impl ToString for AlertEventCustomAttributesPriority { + fn to_string(&self) -> String { + match self { + Self::PRIORITY_ONE => String::from("1"), + Self::PRIORITY_TWO => String::from("2"), + Self::PRIORITY_THREE => String::from("3"), + Self::PRIORITY_FOUR => String::from("4"), + Self::PRIORITY_FIVE => String::from("5"), + Self::UnparsedObject(v) => v.value.to_string(), + } + } +} + +impl Serialize for AlertEventCustomAttributesPriority { + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + match self { + Self::UnparsedObject(v) => v.serialize(serializer), + _ => serializer.serialize_str(self.to_string().as_str()), + } + } +} + +impl<'de> Deserialize<'de> for AlertEventCustomAttributesPriority { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + let s: String = String::deserialize(deserializer)?; + Ok(match s.as_str() { + "1" => Self::PRIORITY_ONE, + "2" => Self::PRIORITY_TWO, + "3" => Self::PRIORITY_THREE, + "4" => Self::PRIORITY_FOUR, + "5" => Self::PRIORITY_FIVE, + _ => Self::UnparsedObject(crate::datadog::UnparsedObject { + value: serde_json::Value::String(s.into()), + }), + }) + } +} diff --git a/src/datadogV2/model/model_alert_event_custom_attributes_status.rs b/src/datadogV2/model/model_alert_event_custom_attributes_status.rs new file mode 100644 index 000000000..8abf708dd --- /dev/null +++ b/src/datadogV2/model/model_alert_event_custom_attributes_status.rs @@ -0,0 +1,54 @@ +// 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. + +use serde::{Deserialize, Deserializer, Serialize, Serializer}; + +#[non_exhaustive] +#[derive(Clone, Debug, Eq, PartialEq)] +pub enum AlertEventCustomAttributesStatus { + WARN, + ERROR, + OK, + UnparsedObject(crate::datadog::UnparsedObject), +} + +impl ToString for AlertEventCustomAttributesStatus { + fn to_string(&self) -> String { + match self { + Self::WARN => String::from("warn"), + Self::ERROR => String::from("error"), + Self::OK => String::from("ok"), + Self::UnparsedObject(v) => v.value.to_string(), + } + } +} + +impl Serialize for AlertEventCustomAttributesStatus { + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + match self { + Self::UnparsedObject(v) => v.serialize(serializer), + _ => serializer.serialize_str(self.to_string().as_str()), + } + } +} + +impl<'de> Deserialize<'de> for AlertEventCustomAttributesStatus { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + let s: String = String::deserialize(deserializer)?; + Ok(match s.as_str() { + "warn" => Self::WARN, + "error" => Self::ERROR, + "ok" => Self::OK, + _ => Self::UnparsedObject(crate::datadog::UnparsedObject { + value: serde_json::Value::String(s.into()), + }), + }) + } +} diff --git a/src/datadogV2/model/model_change_event_custom_attributes.rs b/src/datadogV2/model/model_change_event_custom_attributes.rs index c97ea6e0d..c247cae21 100644 --- a/src/datadogV2/model/model_change_event_custom_attributes.rs +++ b/src/datadogV2/model/model_change_event_custom_attributes.rs @@ -11,7 +11,7 @@ use std::fmt::{self, Formatter}; #[skip_serializing_none] #[derive(Clone, Debug, PartialEq, Serialize)] pub struct ChangeEventCustomAttributes { - /// Object representing the entity which made the change. Optional field but if provided should include `type` and `name`. + /// Object representing the entity that made the change. Optional field but if provided should include `type` and `name`. #[serde(rename = "author")] pub author: Option, /// Free form object with information related to the `change` event. Can be arbitrarily nested and contain any valid JSON. @@ -21,7 +21,7 @@ pub struct ChangeEventCustomAttributes { #[serde(rename = "changed_resource")] pub changed_resource: crate::datadogV2::model::ChangeEventCustomAttributesChangedResource, /// 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 right location. Only resources of type `service` are supported. Maximum of 100 impacted resources allowed. #[serde(rename = "impacted_resources")] pub impacted_resources: Option>, @@ -31,8 +31,6 @@ pub struct ChangeEventCustomAttributes { /// Free form object to track previous value of the changed resource. #[serde(rename = "prev_value")] pub prev_value: Option>, - #[serde(flatten)] - pub additional_properties: std::collections::BTreeMap, #[serde(skip)] #[serde(default)] pub(crate) _unparsed: bool, @@ -49,7 +47,6 @@ impl ChangeEventCustomAttributes { impacted_resources: None, new_value: None, prev_value: None, - additional_properties: std::collections::BTreeMap::new(), _unparsed: false, } } @@ -93,14 +90,6 @@ impl ChangeEventCustomAttributes { self.prev_value = Some(value); self } - - pub fn additional_properties( - mut self, - value: std::collections::BTreeMap, - ) -> Self { - self.additional_properties = value; - self - } } impl<'de> Deserialize<'de> for ChangeEventCustomAttributes { @@ -135,10 +124,6 @@ impl<'de> Deserialize<'de> for ChangeEventCustomAttributes { None; let mut prev_value: Option> = None; - let mut additional_properties: std::collections::BTreeMap< - String, - serde_json::Value, - > = std::collections::BTreeMap::new(); let mut _unparsed = false; while let Some((k, v)) = map.next_entry::()? { @@ -180,9 +165,9 @@ impl<'de> Deserialize<'de> for ChangeEventCustomAttributes { prev_value = Some(serde_json::from_value(v).map_err(M::Error::custom)?); } &_ => { - if let Ok(value) = serde_json::from_value(v.clone()) { - additional_properties.insert(k, value); - } + return Err(serde::de::Error::custom( + "Additional properties not allowed", + )); } } } @@ -196,7 +181,6 @@ impl<'de> Deserialize<'de> for ChangeEventCustomAttributes { impacted_resources, new_value, prev_value, - additional_properties, _unparsed, }; diff --git a/src/datadogV2/model/model_change_event_custom_attributes_author.rs b/src/datadogV2/model/model_change_event_custom_attributes_author.rs index f18b0ae18..e7e1b6bae 100644 --- a/src/datadogV2/model/model_change_event_custom_attributes_author.rs +++ b/src/datadogV2/model/model_change_event_custom_attributes_author.rs @@ -6,7 +6,7 @@ use serde::{Deserialize, Deserializer, Serialize}; use serde_with::skip_serializing_none; use std::fmt::{self, Formatter}; -/// Object representing the entity which made the change. Optional field but if provided should include `type` and `name`. +/// Object representing the entity that made the change. Optional field but if provided should include `type` and `name`. #[non_exhaustive] #[skip_serializing_none] #[derive(Clone, Debug, PartialEq, Serialize)] @@ -17,8 +17,6 @@ pub struct ChangeEventCustomAttributesAuthor { /// Author's type. #[serde(rename = "type")] pub type_: crate::datadogV2::model::ChangeEventCustomAttributesAuthorType, - #[serde(flatten)] - pub additional_properties: std::collections::BTreeMap, #[serde(skip)] #[serde(default)] pub(crate) _unparsed: bool, @@ -32,18 +30,9 @@ impl ChangeEventCustomAttributesAuthor { ChangeEventCustomAttributesAuthor { name, type_, - additional_properties: std::collections::BTreeMap::new(), _unparsed: false, } } - - pub fn additional_properties( - mut self, - value: std::collections::BTreeMap, - ) -> Self { - self.additional_properties = value; - self - } } impl<'de> Deserialize<'de> for ChangeEventCustomAttributesAuthor { @@ -67,10 +56,6 @@ impl<'de> Deserialize<'de> for ChangeEventCustomAttributesAuthor { let mut type_: Option< crate::datadogV2::model::ChangeEventCustomAttributesAuthorType, > = None; - let mut additional_properties: std::collections::BTreeMap< - String, - serde_json::Value, - > = std::collections::BTreeMap::new(); let mut _unparsed = false; while let Some((k, v)) = map.next_entry::()? { @@ -90,9 +75,9 @@ impl<'de> Deserialize<'de> for ChangeEventCustomAttributesAuthor { } } &_ => { - if let Ok(value) = serde_json::from_value(v.clone()) { - additional_properties.insert(k, value); - } + return Err(serde::de::Error::custom( + "Additional properties not allowed", + )); } } } @@ -102,7 +87,6 @@ impl<'de> Deserialize<'de> for ChangeEventCustomAttributesAuthor { let content = ChangeEventCustomAttributesAuthor { name, type_, - additional_properties, _unparsed, }; diff --git a/src/datadogV2/model/model_change_event_custom_attributes_changed_resource.rs b/src/datadogV2/model/model_change_event_custom_attributes_changed_resource.rs index a392665aa..710c5d573 100644 --- a/src/datadogV2/model/model_change_event_custom_attributes_changed_resource.rs +++ b/src/datadogV2/model/model_change_event_custom_attributes_changed_resource.rs @@ -17,8 +17,6 @@ pub struct ChangeEventCustomAttributesChangedResource { /// Resource's type. #[serde(rename = "type")] pub type_: crate::datadogV2::model::ChangeEventCustomAttributesChangedResourceType, - #[serde(flatten)] - pub additional_properties: std::collections::BTreeMap, #[serde(skip)] #[serde(default)] pub(crate) _unparsed: bool, @@ -32,18 +30,9 @@ impl ChangeEventCustomAttributesChangedResource { ChangeEventCustomAttributesChangedResource { name, type_, - additional_properties: std::collections::BTreeMap::new(), _unparsed: false, } } - - pub fn additional_properties( - mut self, - value: std::collections::BTreeMap, - ) -> Self { - self.additional_properties = value; - self - } } impl<'de> Deserialize<'de> for ChangeEventCustomAttributesChangedResource { @@ -67,10 +56,6 @@ impl<'de> Deserialize<'de> for ChangeEventCustomAttributesChangedResource { let mut type_: Option< crate::datadogV2::model::ChangeEventCustomAttributesChangedResourceType, > = None; - let mut additional_properties: std::collections::BTreeMap< - String, - serde_json::Value, - > = std::collections::BTreeMap::new(); let mut _unparsed = false; while let Some((k, v)) = map.next_entry::()? { @@ -90,9 +75,9 @@ impl<'de> Deserialize<'de> for ChangeEventCustomAttributesChangedResource { } } &_ => { - if let Ok(value) = serde_json::from_value(v.clone()) { - additional_properties.insert(k, value); - } + return Err(serde::de::Error::custom( + "Additional properties not allowed", + )); } } } @@ -102,7 +87,6 @@ impl<'de> Deserialize<'de> for ChangeEventCustomAttributesChangedResource { let content = ChangeEventCustomAttributesChangedResource { name, type_, - additional_properties, _unparsed, }; diff --git a/src/datadogV2/model/model_change_event_custom_attributes_impacted_resources_items.rs b/src/datadogV2/model/model_change_event_custom_attributes_impacted_resources_items.rs index bfa7b99a3..eef488c72 100644 --- a/src/datadogV2/model/model_change_event_custom_attributes_impacted_resources_items.rs +++ b/src/datadogV2/model/model_change_event_custom_attributes_impacted_resources_items.rs @@ -17,8 +17,6 @@ pub struct ChangeEventCustomAttributesImpactedResourcesItems { /// Resource's type. #[serde(rename = "type")] pub type_: crate::datadogV2::model::ChangeEventCustomAttributesImpactedResourcesItemsType, - #[serde(flatten)] - pub additional_properties: std::collections::BTreeMap, #[serde(skip)] #[serde(default)] pub(crate) _unparsed: bool, @@ -32,18 +30,9 @@ impl ChangeEventCustomAttributesImpactedResourcesItems { ChangeEventCustomAttributesImpactedResourcesItems { name, type_, - additional_properties: std::collections::BTreeMap::new(), _unparsed: false, } } - - pub fn additional_properties( - mut self, - value: std::collections::BTreeMap, - ) -> Self { - self.additional_properties = value; - self - } } impl<'de> Deserialize<'de> for ChangeEventCustomAttributesImpactedResourcesItems { @@ -67,10 +56,6 @@ impl<'de> Deserialize<'de> for ChangeEventCustomAttributesImpactedResourcesItems let mut type_: Option< crate::datadogV2::model::ChangeEventCustomAttributesImpactedResourcesItemsType, > = None; - let mut additional_properties: std::collections::BTreeMap< - String, - serde_json::Value, - > = std::collections::BTreeMap::new(); let mut _unparsed = false; while let Some((k, v)) = map.next_entry::()? { @@ -90,9 +75,9 @@ impl<'de> Deserialize<'de> for ChangeEventCustomAttributesImpactedResourcesItems } } &_ => { - if let Ok(value) = serde_json::from_value(v.clone()) { - additional_properties.insert(k, value); - } + return Err(serde::de::Error::custom( + "Additional properties not allowed", + )); } } } @@ -102,7 +87,6 @@ impl<'de> Deserialize<'de> for ChangeEventCustomAttributesImpactedResourcesItems let content = ChangeEventCustomAttributesImpactedResourcesItems { name, type_, - additional_properties, _unparsed, }; diff --git a/src/datadogV2/model/model_event_category.rs b/src/datadogV2/model/model_event_category.rs index 88e9853f0..250a498af 100644 --- a/src/datadogV2/model/model_event_category.rs +++ b/src/datadogV2/model/model_event_category.rs @@ -8,6 +8,7 @@ use serde::{Deserialize, Deserializer, Serialize, Serializer}; #[derive(Clone, Debug, Eq, PartialEq)] pub enum EventCategory { CHANGE, + ALERT, UnparsedObject(crate::datadog::UnparsedObject), } @@ -15,6 +16,7 @@ impl ToString for EventCategory { fn to_string(&self) -> String { match self { Self::CHANGE => String::from("change"), + Self::ALERT => String::from("alert"), Self::UnparsedObject(v) => v.value.to_string(), } } @@ -40,6 +42,7 @@ impl<'de> Deserialize<'de> for EventCategory { let s: String = String::deserialize(deserializer)?; Ok(match s.as_str() { "change" => Self::CHANGE, + "alert" => Self::ALERT, _ => Self::UnparsedObject(crate::datadog::UnparsedObject { value: serde_json::Value::String(s.into()), }), diff --git a/src/datadogV2/model/model_event_create_request.rs b/src/datadogV2/model/model_event_create_request.rs index e3c94c233..4215a535f 100644 --- a/src/datadogV2/model/model_event_create_request.rs +++ b/src/datadogV2/model/model_event_create_request.rs @@ -13,10 +13,10 @@ use std::fmt::{self, Formatter}; pub struct EventCreateRequest { /// Event attributes. #[serde(rename = "attributes")] - pub attributes: Option, + pub attributes: crate::datadogV2::model::EventPayload, /// Entity type. #[serde(rename = "type")] - pub type_: Option, + pub type_: crate::datadogV2::model::EventCreateRequestType, #[serde(flatten)] pub additional_properties: std::collections::BTreeMap, #[serde(skip)] @@ -25,25 +25,18 @@ pub struct EventCreateRequest { } impl EventCreateRequest { - pub fn new() -> EventCreateRequest { + pub fn new( + attributes: crate::datadogV2::model::EventPayload, + type_: crate::datadogV2::model::EventCreateRequestType, + ) -> EventCreateRequest { EventCreateRequest { - attributes: None, - type_: None, + attributes, + type_, additional_properties: std::collections::BTreeMap::new(), _unparsed: false, } } - pub fn attributes(mut self, value: crate::datadogV2::model::EventPayload) -> Self { - self.attributes = Some(value); - self - } - - pub fn type_(mut self, value: crate::datadogV2::model::EventCreateRequestType) -> Self { - self.type_ = Some(value); - self - } - pub fn additional_properties( mut self, value: std::collections::BTreeMap, @@ -53,12 +46,6 @@ impl EventCreateRequest { } } -impl Default for EventCreateRequest { - fn default() -> Self { - Self::new() - } -} - impl<'de> Deserialize<'de> for EventCreateRequest { fn deserialize(deserializer: D) -> Result where @@ -87,15 +74,9 @@ impl<'de> Deserialize<'de> for EventCreateRequest { while let Some((k, v)) = map.next_entry::()? { match k.as_str() { "attributes" => { - if v.is_null() { - continue; - } attributes = Some(serde_json::from_value(v).map_err(M::Error::custom)?); } "type" => { - if v.is_null() { - continue; - } type_ = Some(serde_json::from_value(v).map_err(M::Error::custom)?); if let Some(ref _type_) = type_ { match _type_ { @@ -113,6 +94,8 @@ impl<'de> Deserialize<'de> for EventCreateRequest { } } } + let attributes = attributes.ok_or_else(|| M::Error::missing_field("attributes"))?; + let type_ = type_.ok_or_else(|| M::Error::missing_field("type_"))?; let content = EventCreateRequest { attributes, diff --git a/src/datadogV2/model/model_event_create_request_payload.rs b/src/datadogV2/model/model_event_create_request_payload.rs index 6c3647d74..867aba6f9 100644 --- a/src/datadogV2/model/model_event_create_request_payload.rs +++ b/src/datadogV2/model/model_event_create_request_payload.rs @@ -13,7 +13,7 @@ use std::fmt::{self, Formatter}; pub struct EventCreateRequestPayload { /// Object representing an event creation request. #[serde(rename = "data")] - pub data: Option, + pub data: crate::datadogV2::model::EventCreateRequest, #[serde(flatten)] pub additional_properties: std::collections::BTreeMap, #[serde(skip)] @@ -22,19 +22,14 @@ pub struct EventCreateRequestPayload { } impl EventCreateRequestPayload { - pub fn new() -> EventCreateRequestPayload { + pub fn new(data: crate::datadogV2::model::EventCreateRequest) -> EventCreateRequestPayload { EventCreateRequestPayload { - data: None, + data, additional_properties: std::collections::BTreeMap::new(), _unparsed: false, } } - pub fn data(mut self, value: crate::datadogV2::model::EventCreateRequest) -> Self { - self.data = Some(value); - self - } - pub fn additional_properties( mut self, value: std::collections::BTreeMap, @@ -44,12 +39,6 @@ impl EventCreateRequestPayload { } } -impl Default for EventCreateRequestPayload { - fn default() -> Self { - Self::new() - } -} - impl<'de> Deserialize<'de> for EventCreateRequestPayload { fn deserialize(deserializer: D) -> Result where @@ -77,9 +66,6 @@ impl<'de> Deserialize<'de> for EventCreateRequestPayload { while let Some((k, v)) = map.next_entry::()? { match k.as_str() { "data" => { - if v.is_null() { - continue; - } data = Some(serde_json::from_value(v).map_err(M::Error::custom)?); } &_ => { @@ -89,6 +75,7 @@ impl<'de> Deserialize<'de> for EventCreateRequestPayload { } } } + let data = data.ok_or_else(|| M::Error::missing_field("data"))?; let content = EventCreateRequestPayload { data, diff --git a/src/datadogV2/model/model_event_create_response.rs b/src/datadogV2/model/model_event_create_response.rs index f2221e65c..d0beefffc 100644 --- a/src/datadogV2/model/model_event_create_response.rs +++ b/src/datadogV2/model/model_event_create_response.rs @@ -14,7 +14,7 @@ pub struct EventCreateResponse { /// JSON object containing all events attributes and their associated values. #[serde(rename = "attributes")] pub attributes: Option, - /// Event type + /// Event type. #[serde(rename = "type")] pub type_: Option, #[serde(flatten)] diff --git a/src/datadogV2/model/model_event_create_response_attributes_attributes_evt.rs b/src/datadogV2/model/model_event_create_response_attributes_attributes_evt.rs index b84d12c63..778dd2827 100644 --- a/src/datadogV2/model/model_event_create_response_attributes_attributes_evt.rs +++ b/src/datadogV2/model/model_event_create_response_attributes_attributes_evt.rs @@ -11,9 +11,13 @@ use std::fmt::{self, Formatter}; #[skip_serializing_none] #[derive(Clone, Debug, PartialEq, Serialize)] pub struct EventCreateResponseAttributesAttributesEvt { - /// Event id + /// (Deprecated) Event id. Use `uid` instead. + #[deprecated] #[serde(rename = "id")] pub id: Option, + /// A unique identifier for the event. You can use this id to query or reference the event. + #[serde(rename = "uid")] + pub uid: Option, #[serde(flatten)] pub additional_properties: std::collections::BTreeMap, #[serde(skip)] @@ -23,18 +27,27 @@ pub struct EventCreateResponseAttributesAttributesEvt { impl EventCreateResponseAttributesAttributesEvt { pub fn new() -> EventCreateResponseAttributesAttributesEvt { + #[allow(deprecated)] EventCreateResponseAttributesAttributesEvt { id: None, + uid: None, additional_properties: std::collections::BTreeMap::new(), _unparsed: false, } } + #[allow(deprecated)] pub fn id(mut self, value: String) -> Self { self.id = Some(value); self } + #[allow(deprecated)] + pub fn uid(mut self, value: String) -> Self { + self.uid = Some(value); + self + } + pub fn additional_properties( mut self, value: std::collections::BTreeMap, @@ -68,6 +81,7 @@ impl<'de> Deserialize<'de> for EventCreateResponseAttributesAttributesEvt { M: MapAccess<'a>, { let mut id: Option = None; + let mut uid: Option = None; let mut additional_properties: std::collections::BTreeMap< String, serde_json::Value, @@ -82,6 +96,12 @@ impl<'de> Deserialize<'de> for EventCreateResponseAttributesAttributesEvt { } id = Some(serde_json::from_value(v).map_err(M::Error::custom)?); } + "uid" => { + if v.is_null() { + continue; + } + uid = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } &_ => { if let Ok(value) = serde_json::from_value(v.clone()) { additional_properties.insert(k, value); @@ -90,8 +110,10 @@ impl<'de> Deserialize<'de> for EventCreateResponseAttributesAttributesEvt { } } + #[allow(deprecated)] let content = EventCreateResponseAttributesAttributesEvt { id, + uid, additional_properties, _unparsed, }; diff --git a/src/datadogV2/model/model_event_create_response_payload.rs b/src/datadogV2/model/model_event_create_response_payload.rs index 89502129a..ef81ca741 100644 --- a/src/datadogV2/model/model_event_create_response_payload.rs +++ b/src/datadogV2/model/model_event_create_response_payload.rs @@ -14,6 +14,9 @@ pub struct EventCreateResponsePayload { /// Object containing an event response. #[serde(rename = "data")] pub data: Option, + /// Links attributes. + #[serde(rename = "links")] + pub links: Option, #[serde(flatten)] pub additional_properties: std::collections::BTreeMap, #[serde(skip)] @@ -25,6 +28,7 @@ impl EventCreateResponsePayload { pub fn new() -> EventCreateResponsePayload { EventCreateResponsePayload { data: None, + links: None, additional_properties: std::collections::BTreeMap::new(), _unparsed: false, } @@ -35,6 +39,14 @@ impl EventCreateResponsePayload { self } + pub fn links( + mut self, + value: crate::datadogV2::model::EventCreateResponsePayloadLinks, + ) -> Self { + self.links = Some(value); + self + } + pub fn additional_properties( mut self, value: std::collections::BTreeMap, @@ -68,6 +80,8 @@ impl<'de> Deserialize<'de> for EventCreateResponsePayload { M: MapAccess<'a>, { let mut data: Option = None; + let mut links: Option = + None; let mut additional_properties: std::collections::BTreeMap< String, serde_json::Value, @@ -82,6 +96,12 @@ impl<'de> Deserialize<'de> for EventCreateResponsePayload { } data = Some(serde_json::from_value(v).map_err(M::Error::custom)?); } + "links" => { + if v.is_null() { + continue; + } + links = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } &_ => { if let Ok(value) = serde_json::from_value(v.clone()) { additional_properties.insert(k, value); @@ -92,6 +112,7 @@ impl<'de> Deserialize<'de> for EventCreateResponsePayload { let content = EventCreateResponsePayload { data, + links, additional_properties, _unparsed, }; diff --git a/src/datadogV2/model/model_event_create_response_payload_links.rs b/src/datadogV2/model/model_event_create_response_payload_links.rs new file mode 100644 index 000000000..87182f8fb --- /dev/null +++ b/src/datadogV2/model/model_event_create_response_payload_links.rs @@ -0,0 +1,105 @@ +// 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. +use serde::de::{Error, MapAccess, Visitor}; +use serde::{Deserialize, Deserializer, Serialize}; +use serde_with::skip_serializing_none; +use std::fmt::{self, Formatter}; + +/// Links attributes. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct EventCreateResponsePayloadLinks { + /// The URL of the event. This link is only functional when using the default subdomain. + #[serde(rename = "self")] + pub self_: Option, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl EventCreateResponsePayloadLinks { + pub fn new() -> EventCreateResponsePayloadLinks { + EventCreateResponsePayloadLinks { + self_: None, + additional_properties: std::collections::BTreeMap::new(), + _unparsed: false, + } + } + + pub fn self_(mut self, value: String) -> Self { + self.self_ = Some(value); + self + } + + pub fn additional_properties( + mut self, + value: std::collections::BTreeMap, + ) -> Self { + self.additional_properties = value; + self + } +} + +impl Default for EventCreateResponsePayloadLinks { + fn default() -> Self { + Self::new() + } +} + +impl<'de> Deserialize<'de> for EventCreateResponsePayloadLinks { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct EventCreateResponsePayloadLinksVisitor; + impl<'a> Visitor<'a> for EventCreateResponsePayloadLinksVisitor { + type Value = EventCreateResponsePayloadLinks; + + fn expecting(&self, f: &mut Formatter<'_>) -> fmt::Result { + f.write_str("a mapping") + } + + fn visit_map(self, mut map: M) -> Result + where + M: MapAccess<'a>, + { + let mut self_: Option = None; + let mut additional_properties: std::collections::BTreeMap< + String, + serde_json::Value, + > = std::collections::BTreeMap::new(); + let mut _unparsed = false; + + while let Some((k, v)) = map.next_entry::()? { + match k.as_str() { + "self" => { + if v.is_null() { + continue; + } + self_ = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + &_ => { + if let Ok(value) = serde_json::from_value(v.clone()) { + additional_properties.insert(k, value); + } + } + } + } + + let content = EventCreateResponsePayloadLinks { + self_, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(EventCreateResponsePayloadLinksVisitor) + } +} diff --git a/src/datadogV2/model/model_event_payload.rs b/src/datadogV2/model/model_event_payload.rs index bda36f4d2..00f88ac12 100644 --- a/src/datadogV2/model/model_event_payload.rs +++ b/src/datadogV2/model/model_event_payload.rs @@ -11,15 +11,18 @@ use std::fmt::{self, Formatter}; #[skip_serializing_none] #[derive(Clone, Debug, PartialEq, Serialize)] pub struct EventPayload { - /// An arbitrary string to use for aggregation when correlating events. Limited to 100 characters. + /// An arbitrary string to use for aggregation when correlating events. If you specify a key, events are deduplicated to alerts based on this key. Limited to 100 characters. #[serde(rename = "aggregation_key")] pub aggregation_key: Option, - /// JSON object for custom attributes. Schema are different per each event category. + /// JSON object for custom attributes. Schema is different per event category. #[serde(rename = "attributes")] pub attributes: crate::datadogV2::model::EventPayloadAttributes, - /// 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. #[serde(rename = "category")] pub category: crate::datadogV2::model::EventCategory, + /// Integration IDs sourced from integration manifests. Currently, only `custom-events` is supported. + #[serde(rename = "integration_id")] + pub integration_id: Option, /// The body of the event. Limited to 4000 characters. #[serde(rename = "message")] pub message: Option, @@ -35,8 +38,6 @@ pub struct EventPayload { /// The event title. Limited to 500 characters. #[serde(rename = "title")] pub title: String, - #[serde(flatten)] - pub additional_properties: std::collections::BTreeMap, #[serde(skip)] #[serde(default)] pub(crate) _unparsed: bool, @@ -52,11 +53,11 @@ impl EventPayload { aggregation_key: None, attributes, category, + integration_id: None, message: None, tags: None, timestamp: None, title, - additional_properties: std::collections::BTreeMap::new(), _unparsed: false, } } @@ -66,6 +67,14 @@ impl EventPayload { self } + pub fn integration_id( + mut self, + value: crate::datadogV2::model::EventPayloadIntegrationId, + ) -> Self { + self.integration_id = Some(value); + self + } + pub fn message(mut self, value: String) -> Self { self.message = Some(value); self @@ -80,14 +89,6 @@ impl EventPayload { self.timestamp = Some(value); self } - - pub fn additional_properties( - mut self, - value: std::collections::BTreeMap, - ) -> Self { - self.additional_properties = value; - self - } } impl<'de> Deserialize<'de> for EventPayload { @@ -110,14 +111,12 @@ impl<'de> Deserialize<'de> for EventPayload { let mut aggregation_key: Option = None; let mut attributes: Option = None; let mut category: Option = None; + let mut integration_id: Option = + None; let mut message: Option = None; let mut tags: Option> = None; let mut timestamp: Option = None; let mut title: Option = None; - let mut additional_properties: std::collections::BTreeMap< - String, - serde_json::Value, - > = std::collections::BTreeMap::new(); let mut _unparsed = false; while let Some((k, v)) = map.next_entry::()? { @@ -153,6 +152,21 @@ impl<'de> Deserialize<'de> for EventPayload { } } } + "integration_id" => { + if v.is_null() { + continue; + } + integration_id = + Some(serde_json::from_value(v).map_err(M::Error::custom)?); + if let Some(ref _integration_id) = integration_id { + match _integration_id { + crate::datadogV2::model::EventPayloadIntegrationId::UnparsedObject(_integration_id) => { + _unparsed = true; + }, + _ => {} + } + } + } "message" => { if v.is_null() { continue; @@ -175,9 +189,9 @@ impl<'de> Deserialize<'de> for EventPayload { title = Some(serde_json::from_value(v).map_err(M::Error::custom)?); } &_ => { - if let Ok(value) = serde_json::from_value(v.clone()) { - additional_properties.insert(k, value); - } + return Err(serde::de::Error::custom( + "Additional properties not allowed", + )); } } } @@ -189,11 +203,11 @@ impl<'de> Deserialize<'de> for EventPayload { aggregation_key, attributes, category, + integration_id, message, tags, timestamp, title, - additional_properties, _unparsed, }; diff --git a/src/datadogV2/model/model_event_payload_attributes.rs b/src/datadogV2/model/model_event_payload_attributes.rs index 30e651ce1..5e1da9d9b 100644 --- a/src/datadogV2/model/model_event_payload_attributes.rs +++ b/src/datadogV2/model/model_event_payload_attributes.rs @@ -3,12 +3,13 @@ // Copyright 2019-Present Datadog, Inc. use serde::{Deserialize, Deserializer, Serialize}; -/// JSON object for custom attributes. Schema are different per each event category. +/// JSON object for custom attributes. Schema is different per event category. #[non_exhaustive] #[derive(Clone, Debug, PartialEq, Serialize)] #[serde(untagged)] pub enum EventPayloadAttributes { ChangeEventCustomAttributes(Box), + AlertEventCustomAttributes(Box), UnparsedObject(crate::datadog::UnparsedObject), } @@ -26,6 +27,14 @@ impl<'de> Deserialize<'de> for EventPayloadAttributes { return Ok(EventPayloadAttributes::ChangeEventCustomAttributes(_v)); } } + if let Ok(_v) = serde_json::from_value::< + Box, + >(value.clone()) + { + if !_v._unparsed { + return Ok(EventPayloadAttributes::AlertEventCustomAttributes(_v)); + } + } return Ok(EventPayloadAttributes::UnparsedObject( crate::datadog::UnparsedObject { value }, diff --git a/src/datadogV2/model/model_event_payload_integration_id.rs b/src/datadogV2/model/model_event_payload_integration_id.rs new file mode 100644 index 000000000..cfcf3cc4e --- /dev/null +++ b/src/datadogV2/model/model_event_payload_integration_id.rs @@ -0,0 +1,48 @@ +// 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. + +use serde::{Deserialize, Deserializer, Serialize, Serializer}; + +#[non_exhaustive] +#[derive(Clone, Debug, Eq, PartialEq)] +pub enum EventPayloadIntegrationId { + CUSTOM_EVENTS, + UnparsedObject(crate::datadog::UnparsedObject), +} + +impl ToString for EventPayloadIntegrationId { + fn to_string(&self) -> String { + match self { + Self::CUSTOM_EVENTS => String::from("custom-events"), + Self::UnparsedObject(v) => v.value.to_string(), + } + } +} + +impl Serialize for EventPayloadIntegrationId { + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + match self { + Self::UnparsedObject(v) => v.serialize(serializer), + _ => serializer.serialize_str(self.to_string().as_str()), + } + } +} + +impl<'de> Deserialize<'de> for EventPayloadIntegrationId { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + let s: String = String::deserialize(deserializer)?; + Ok(match s.as_str() { + "custom-events" => Self::CUSTOM_EVENTS, + _ => Self::UnparsedObject(crate::datadog::UnparsedObject { + value: serde_json::Value::String(s.into()), + }), + }) + } +} diff --git a/tests/scenarios/cassettes/v2/events/Post-an-event-returns-Bad-request-response.frozen b/tests/scenarios/cassettes/v2/events/Post-an-event-returns-Bad-request-response.frozen new file mode 100644 index 000000000..3687695be --- /dev/null +++ b/tests/scenarios/cassettes/v2/events/Post-an-event-returns-Bad-request-response.frozen @@ -0,0 +1 @@ +2025-06-05T17:32:11.751Z \ No newline at end of file diff --git a/tests/scenarios/cassettes/v2/events/Post-an-event-returns-Bad-request-response.json b/tests/scenarios/cassettes/v2/events/Post-an-event-returns-Bad-request-response.json new file mode 100644 index 000000000..18b870fe9 --- /dev/null +++ b/tests/scenarios/cassettes/v2/events/Post-an-event-returns-Bad-request-response.json @@ -0,0 +1,39 @@ +{ + "http_interactions": [ + { + "request": { + "body": { + "string": "{\"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\":\"invalid\",\"integration_id\":\"custom-events\",\"message\":\"payment_processed feature flag has been enabled\",\"tags\":[\"env:test\"],\"title\":\"Datadog api client test\"},\"type\":\"event\"}}", + "encoding": null + }, + "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\"}]}", + "encoding": null + }, + "headers": { + "Content-Type": [ + "application/json" + ] + }, + "status": { + "code": 400, + "message": "Bad Request" + } + }, + "recorded_at": "Thu, 05 Jun 2025 17:32:11 GMT" + } + ], + "recorded_with": "VCR 6.0.0" +} \ No newline at end of file diff --git a/tests/scenarios/cassettes/v2/events/Post-an-event-returns-OK-response.frozen b/tests/scenarios/cassettes/v2/events/Post-an-event-returns-OK-response.frozen new file mode 100644 index 000000000..7ae815ceb --- /dev/null +++ b/tests/scenarios/cassettes/v2/events/Post-an-event-returns-OK-response.frozen @@ -0,0 +1 @@ +2025-06-05T18:20:54.371Z \ No newline at end of file diff --git a/tests/scenarios/cassettes/v2/events/Post-an-event-returns-OK-response.json b/tests/scenarios/cassettes/v2/events/Post-an-event-returns-OK-response.json new file mode 100644 index 000000000..512b890ed --- /dev/null +++ b/tests/scenarios/cassettes/v2/events/Post-an-event-returns-OK-response.json @@ -0,0 +1,39 @@ +{ + "http_interactions": [ + { + "request": { + "body": { + "string": "{\"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\":\"Datadog api client test\"},\"type\":\"event\"}}", + "encoding": null + }, + "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\":\"AZdBJDwVAAAKdndVgBFRzAAA\"}}},\"id\":\"_\",\"type\":\"event\"},\"links\":{\"self\":\"https://app.datadoghq.com/event/event?uid=AZdBJDwVAAAKdndVgBFRzAAA\"}}", + "encoding": null + }, + "headers": { + "Content-Type": [ + "application/json" + ] + }, + "status": { + "code": 202, + "message": "Accepted" + } + }, + "recorded_at": "Thu, 05 Jun 2025 18:20:54 GMT" + } + ], + "recorded_with": "VCR 6.0.0" +} \ No newline at end of file diff --git a/tests/scenarios/features/v2/events.feature b/tests/scenarios/features/v2/events.feature index a8c1307ac..71daeb472 100644 --- a/tests/scenarios/features/v2/events.feature +++ b/tests/scenarios/features/v2/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": "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": "invalid", "integration_id": "custom-events", "message": "payment_processed feature flag has been enabled", "tags": ["env:test"], "title": "Datadog api client test"}, "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": "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": "Datadog api client test"}, "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/scenarios/features/v2/undo.json b/tests/scenarios/features/v2/undo.json index a7a5bb3ac..03a1b5986 100644 --- a/tests/scenarios/features/v2/undo.json +++ b/tests/scenarios/features/v2/undo.json @@ -909,7 +909,7 @@ "CreateEvent": { "tag": "Events", "undo": { - "type": "unsafe" + "type": "safe" } }, "SearchEvents": {