diff --git a/.generator/schemas/v2/openapi.yaml b/.generator/schemas/v2/openapi.yaml index 2b877f268..92c61b23a 100644 --- a/.generator/schemas/v2/openapi.yaml +++ b/.generator/schemas/v2/openapi.yaml @@ -32305,15 +32305,23 @@ components: properties: recipients: $ref: '#/components/schemas/MonitorNotificationRuleRecipients' + description: A list of recipients to notify. Uses the same format as the + monitor `message` field. Must not start with an '@'. scope: - $ref: '#/components/schemas/MonitorNotificationRuleScope' + $ref: '#/components/schemas/MonitorNotificationRuleConditionScope' required: - scope - recipients type: object + MonitorNotificationRuleConditionScope: + description: The scope to which the monitor applied. + example: transition_type:alert + maxLength: 3000 + minLength: 1 + type: string MonitorNotificationRuleConditionalRecipients: description: Use conditional recipients to define different recipients for different - situations. + situations. Cannot be used with `recipients`. properties: conditions: description: Conditions of the notification rule. @@ -32363,12 +32371,30 @@ components: description: Filter used to associate the notification rule with monitors. oneOf: - $ref: '#/components/schemas/MonitorNotificationRuleFilterTags' + - $ref: '#/components/schemas/MonitorNotificationRuleFilterScope' + MonitorNotificationRuleFilterScope: + additionalProperties: false + description: Filter monitor notifications. A monitor notification must match + the scope. + properties: + scope: + description: A scope composed of one or several key:value pairs, which can + be used to filter monitor notifications on monitor and group tags. + example: service:(foo OR bar) AND team:test NOT environment:staging + maxLength: 3000 + minLength: 1 + type: string + required: + - scope + type: object MonitorNotificationRuleFilterTags: additionalProperties: false - description: Filter monitors by tags. Monitors must match all tags. + description: Filter monitor notifications by tags. A monitor notification must + match all tags. properties: tags: - description: A list of monitor tags. + description: A list of tags (key:value pairs), which can be used to filter + monitor notifications on monitor and group tags. example: - team:product - host:abc @@ -32408,7 +32434,7 @@ components: type: string MonitorNotificationRuleRecipients: description: A list of recipients to notify. Uses the same format as the monitor - `message` field. Must not start with an '@'. + `message` field. Must not start with an '@'. Cannot be used with `conditional_recipients`. example: - slack-test-channel - jira-test @@ -32491,12 +32517,6 @@ components: description: An object related to a monitor notification rule. oneOf: - $ref: '#/components/schemas/User' - MonitorNotificationRuleScope: - description: The scope to which the monitor applied. - example: transition_type:alert - maxLength: 3000 - minLength: 1 - type: string MonitorNotificationRuleUpdateRequest: description: Request for updating a monitor notification rule. properties: diff --git a/examples/v2_monitors_CreateMonitorNotificationRule_1379932371.rs b/examples/v2_monitors_CreateMonitorNotificationRule_1379932371.rs new file mode 100644 index 000000000..901068a62 --- /dev/null +++ b/examples/v2_monitors_CreateMonitorNotificationRule_1379932371.rs @@ -0,0 +1,36 @@ +// Create a monitor notification rule with scope returns "OK" response +use datadog_api_client::datadog; +use datadog_api_client::datadogV2::api_monitors::MonitorsAPI; +use datadog_api_client::datadogV2::model::MonitorNotificationRuleAttributes; +use datadog_api_client::datadogV2::model::MonitorNotificationRuleCreateRequest; +use datadog_api_client::datadogV2::model::MonitorNotificationRuleCreateRequestData; +use datadog_api_client::datadogV2::model::MonitorNotificationRuleFilter; +use datadog_api_client::datadogV2::model::MonitorNotificationRuleFilterScope; +use datadog_api_client::datadogV2::model::MonitorNotificationRuleResourceType; + +#[tokio::main] +async fn main() { + let body = MonitorNotificationRuleCreateRequest::new( + MonitorNotificationRuleCreateRequestData::new( + MonitorNotificationRuleAttributes::new("test rule".to_string()) + .filter( + MonitorNotificationRuleFilter::MonitorNotificationRuleFilterScope(Box::new( + MonitorNotificationRuleFilterScope::new("test:example-monitor".to_string()), + )), + ) + .recipients(vec![ + "slack-test-channel".to_string(), + "jira-test".to_string(), + ]), + ) + .type_(MonitorNotificationRuleResourceType::MONITOR_NOTIFICATION_RULE), + ); + let configuration = datadog::Configuration::new(); + let api = MonitorsAPI::with_config(configuration); + let resp = api.create_monitor_notification_rule(body).await; + if let Ok(value) = resp { + println!("{:#?}", value); + } else { + println!("{:#?}", resp.unwrap_err()); + } +} diff --git a/examples/v2_monitors_UpdateMonitorNotificationRule_1446058210.rs b/examples/v2_monitors_UpdateMonitorNotificationRule_1446058210.rs new file mode 100644 index 000000000..9aac88640 --- /dev/null +++ b/examples/v2_monitors_UpdateMonitorNotificationRule_1446058210.rs @@ -0,0 +1,39 @@ +// Update a monitor notification rule with scope returns "OK" response +use datadog_api_client::datadog; +use datadog_api_client::datadogV2::api_monitors::MonitorsAPI; +use datadog_api_client::datadogV2::model::MonitorNotificationRuleAttributes; +use datadog_api_client::datadogV2::model::MonitorNotificationRuleFilter; +use datadog_api_client::datadogV2::model::MonitorNotificationRuleFilterScope; +use datadog_api_client::datadogV2::model::MonitorNotificationRuleResourceType; +use datadog_api_client::datadogV2::model::MonitorNotificationRuleUpdateRequest; +use datadog_api_client::datadogV2::model::MonitorNotificationRuleUpdateRequestData; + +#[tokio::main] +async fn main() { + // there is a valid "monitor_notification_rule" in the system + let monitor_notification_rule_data_id = + std::env::var("MONITOR_NOTIFICATION_RULE_DATA_ID").unwrap(); + let body = MonitorNotificationRuleUpdateRequest::new( + MonitorNotificationRuleUpdateRequestData::new( + MonitorNotificationRuleAttributes::new("updated rule".to_string()) + .filter( + MonitorNotificationRuleFilter::MonitorNotificationRuleFilterScope(Box::new( + MonitorNotificationRuleFilterScope::new("test:example-monitor".to_string()), + )), + ) + .recipients(vec!["slack-test-channel".to_string()]), + monitor_notification_rule_data_id.clone(), + ) + .type_(MonitorNotificationRuleResourceType::MONITOR_NOTIFICATION_RULE), + ); + let configuration = datadog::Configuration::new(); + let api = MonitorsAPI::with_config(configuration); + let resp = api + .update_monitor_notification_rule(monitor_notification_rule_data_id.clone(), body) + .await; + if let Ok(value) = resp { + println!("{:#?}", value); + } else { + println!("{:#?}", resp.unwrap_err()); + } +} diff --git a/src/datadogV2/model/mod.rs b/src/datadogV2/model/mod.rs index 1878768c9..3f37a5846 100644 --- a/src/datadogV2/model/mod.rs +++ b/src/datadogV2/model/mod.rs @@ -3688,6 +3688,8 @@ pub mod model_monitor_notification_rule_condition; pub use self::model_monitor_notification_rule_condition::MonitorNotificationRuleCondition; pub mod model_monitor_notification_rule_filter_tags; pub use self::model_monitor_notification_rule_filter_tags::MonitorNotificationRuleFilterTags; +pub mod model_monitor_notification_rule_filter_scope; +pub use self::model_monitor_notification_rule_filter_scope::MonitorNotificationRuleFilterScope; pub mod model_monitor_notification_rule_filter; pub use self::model_monitor_notification_rule_filter::MonitorNotificationRuleFilter; pub mod model_monitor_notification_rule_relationships; diff --git a/src/datadogV2/model/model_monitor_notification_rule_attributes.rs b/src/datadogV2/model/model_monitor_notification_rule_attributes.rs index dcb3666a3..df53e0380 100644 --- a/src/datadogV2/model/model_monitor_notification_rule_attributes.rs +++ b/src/datadogV2/model/model_monitor_notification_rule_attributes.rs @@ -11,7 +11,7 @@ use std::fmt::{self, Formatter}; #[skip_serializing_none] #[derive(Clone, Debug, PartialEq, Serialize)] pub struct MonitorNotificationRuleAttributes { - /// Use conditional recipients to define different recipients for different situations. + /// Use conditional recipients to define different recipients for different situations. Cannot be used with `recipients`. #[serde(rename = "conditional_recipients")] pub conditional_recipients: Option, @@ -21,7 +21,7 @@ pub struct MonitorNotificationRuleAttributes { /// The name of the monitor notification rule. #[serde(rename = "name")] pub name: String, - /// A list of recipients to notify. Uses the same format as the monitor `message` field. Must not start with an '@'. + /// A list of recipients to notify. Uses the same format as the monitor `message` field. Must not start with an '@'. Cannot be used with `conditional_recipients`. #[serde(rename = "recipients")] pub recipients: Option>, #[serde(skip)] diff --git a/src/datadogV2/model/model_monitor_notification_rule_condition.rs b/src/datadogV2/model/model_monitor_notification_rule_condition.rs index fce098126..4fac3a698 100644 --- a/src/datadogV2/model/model_monitor_notification_rule_condition.rs +++ b/src/datadogV2/model/model_monitor_notification_rule_condition.rs @@ -11,7 +11,7 @@ use std::fmt::{self, Formatter}; #[skip_serializing_none] #[derive(Clone, Debug, PartialEq, Serialize)] pub struct MonitorNotificationRuleCondition { - /// A list of recipients to notify. Uses the same format as the monitor `message` field. Must not start with an '@'. + /// A list of recipients to notify. Uses the same format as the monitor `message` field. Must not start with an '@'. Cannot be used with `conditional_recipients`. #[serde(rename = "recipients")] pub recipients: Vec, /// The scope to which the monitor applied. diff --git a/src/datadogV2/model/model_monitor_notification_rule_conditional_recipients.rs b/src/datadogV2/model/model_monitor_notification_rule_conditional_recipients.rs index e41ef44f2..72f152f0a 100644 --- a/src/datadogV2/model/model_monitor_notification_rule_conditional_recipients.rs +++ b/src/datadogV2/model/model_monitor_notification_rule_conditional_recipients.rs @@ -6,7 +6,7 @@ use serde::{Deserialize, Deserializer, Serialize}; use serde_with::skip_serializing_none; use std::fmt::{self, Formatter}; -/// Use conditional recipients to define different recipients for different situations. +/// Use conditional recipients to define different recipients for different situations. Cannot be used with `recipients`. #[non_exhaustive] #[skip_serializing_none] #[derive(Clone, Debug, PartialEq, Serialize)] @@ -14,7 +14,7 @@ pub struct MonitorNotificationRuleConditionalRecipients { /// Conditions of the notification rule. #[serde(rename = "conditions")] pub conditions: Vec, - /// A list of recipients to notify. Uses the same format as the monitor `message` field. Must not start with an '@'. + /// A list of recipients to notify. Uses the same format as the monitor `message` field. Must not start with an '@'. Cannot be used with `conditional_recipients`. #[serde(rename = "fallback_recipients")] pub fallback_recipients: Option>, #[serde(flatten)] diff --git a/src/datadogV2/model/model_monitor_notification_rule_filter.rs b/src/datadogV2/model/model_monitor_notification_rule_filter.rs index f0f7f8ce9..46b147a68 100644 --- a/src/datadogV2/model/model_monitor_notification_rule_filter.rs +++ b/src/datadogV2/model/model_monitor_notification_rule_filter.rs @@ -11,6 +11,9 @@ pub enum MonitorNotificationRuleFilter { MonitorNotificationRuleFilterTags( Box, ), + MonitorNotificationRuleFilterScope( + Box, + ), UnparsedObject(crate::datadog::UnparsedObject), } @@ -28,6 +31,14 @@ impl<'de> Deserialize<'de> for MonitorNotificationRuleFilter { return Ok(MonitorNotificationRuleFilter::MonitorNotificationRuleFilterTags(_v)); } } + if let Ok(_v) = serde_json::from_value::< + Box, + >(value.clone()) + { + if !_v._unparsed { + return Ok(MonitorNotificationRuleFilter::MonitorNotificationRuleFilterScope(_v)); + } + } return Ok(MonitorNotificationRuleFilter::UnparsedObject( crate::datadog::UnparsedObject { value }, diff --git a/src/datadogV2/model/model_monitor_notification_rule_filter_scope.rs b/src/datadogV2/model/model_monitor_notification_rule_filter_scope.rs new file mode 100644 index 000000000..105cc326a --- /dev/null +++ b/src/datadogV2/model/model_monitor_notification_rule_filter_scope.rs @@ -0,0 +1,73 @@ +// 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}; + +/// Filter monitor notifications. A monitor notification must match the scope. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct MonitorNotificationRuleFilterScope { + /// A scope composed of one or several key:value pairs, which can be used to filter monitor notifications on monitor and group tags. + #[serde(rename = "scope")] + pub scope: String, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl MonitorNotificationRuleFilterScope { + pub fn new(scope: String) -> MonitorNotificationRuleFilterScope { + MonitorNotificationRuleFilterScope { + scope, + _unparsed: false, + } + } +} + +impl<'de> Deserialize<'de> for MonitorNotificationRuleFilterScope { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct MonitorNotificationRuleFilterScopeVisitor; + impl<'a> Visitor<'a> for MonitorNotificationRuleFilterScopeVisitor { + type Value = MonitorNotificationRuleFilterScope; + + 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 scope: Option = None; + let mut _unparsed = false; + + while let Some((k, v)) = map.next_entry::()? { + match k.as_str() { + "scope" => { + scope = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + &_ => { + return Err(serde::de::Error::custom( + "Additional properties not allowed", + )); + } + } + } + let scope = scope.ok_or_else(|| M::Error::missing_field("scope"))?; + + let content = MonitorNotificationRuleFilterScope { scope, _unparsed }; + + Ok(content) + } + } + + deserializer.deserialize_any(MonitorNotificationRuleFilterScopeVisitor) + } +} diff --git a/src/datadogV2/model/model_monitor_notification_rule_filter_tags.rs b/src/datadogV2/model/model_monitor_notification_rule_filter_tags.rs index 412b3b26f..2d5034cb5 100644 --- a/src/datadogV2/model/model_monitor_notification_rule_filter_tags.rs +++ b/src/datadogV2/model/model_monitor_notification_rule_filter_tags.rs @@ -6,12 +6,12 @@ use serde::{Deserialize, Deserializer, Serialize}; use serde_with::skip_serializing_none; use std::fmt::{self, Formatter}; -/// Filter monitors by tags. Monitors must match all tags. +/// Filter monitor notifications by tags. A monitor notification must match all tags. #[non_exhaustive] #[skip_serializing_none] #[derive(Clone, Debug, PartialEq, Serialize)] pub struct MonitorNotificationRuleFilterTags { - /// A list of monitor tags. + /// A list of tags (key:value pairs), which can be used to filter monitor notifications on monitor and group tags. #[serde(rename = "tags")] pub tags: Vec, #[serde(skip)] diff --git a/src/datadogV2/model/model_monitor_notification_rule_response_attributes.rs b/src/datadogV2/model/model_monitor_notification_rule_response_attributes.rs index f59b95939..4774bf226 100644 --- a/src/datadogV2/model/model_monitor_notification_rule_response_attributes.rs +++ b/src/datadogV2/model/model_monitor_notification_rule_response_attributes.rs @@ -11,7 +11,7 @@ use std::fmt::{self, Formatter}; #[skip_serializing_none] #[derive(Clone, Debug, PartialEq, Serialize)] pub struct MonitorNotificationRuleResponseAttributes { - /// Use conditional recipients to define different recipients for different situations. + /// Use conditional recipients to define different recipients for different situations. Cannot be used with `recipients`. #[serde(rename = "conditional_recipients")] pub conditional_recipients: Option, @@ -27,7 +27,7 @@ pub struct MonitorNotificationRuleResponseAttributes { /// The name of the monitor notification rule. #[serde(rename = "name")] pub name: Option, - /// A list of recipients to notify. Uses the same format as the monitor `message` field. Must not start with an '@'. + /// A list of recipients to notify. Uses the same format as the monitor `message` field. Must not start with an '@'. Cannot be used with `conditional_recipients`. #[serde(rename = "recipients")] pub recipients: Option>, #[serde(flatten)] diff --git a/tests/scenarios/cassettes/v2/monitors/Create-a-monitor-notification-rule-with-scope-returns-OK-response.frozen b/tests/scenarios/cassettes/v2/monitors/Create-a-monitor-notification-rule-with-scope-returns-OK-response.frozen new file mode 100644 index 000000000..94917c9e8 --- /dev/null +++ b/tests/scenarios/cassettes/v2/monitors/Create-a-monitor-notification-rule-with-scope-returns-OK-response.frozen @@ -0,0 +1 @@ +2025-11-11T21:28:39.129Z \ No newline at end of file diff --git a/tests/scenarios/cassettes/v2/monitors/Create-a-monitor-notification-rule-with-scope-returns-OK-response.json b/tests/scenarios/cassettes/v2/monitors/Create-a-monitor-notification-rule-with-scope-returns-OK-response.json new file mode 100644 index 000000000..9a77d76d1 --- /dev/null +++ b/tests/scenarios/cassettes/v2/monitors/Create-a-monitor-notification-rule-with-scope-returns-OK-response.json @@ -0,0 +1,67 @@ +{ + "http_interactions": [ + { + "request": { + "body": { + "string": "{\"data\":{\"attributes\":{\"filter\":{\"scope\":\"test:test-create_a_monitor_notification_rule_with_scope_returns_ok_response-1762896519\"},\"name\":\"test rule\",\"recipients\":[\"slack-test-channel\",\"jira-test\"]},\"type\":\"monitor-notification-rule\"}}", + "encoding": null + }, + "headers": { + "Accept": [ + "application/json" + ], + "Content-Type": [ + "application/json" + ] + }, + "method": "post", + "uri": "https://api.datadoghq.com/api/v2/monitor/notification_rule" + }, + "response": { + "body": { + "string": "{\"data\":{\"type\":\"monitor-notification-rule\",\"attributes\":{\"modified_at\":\"1970-01-01T00:00:00+00:00\",\"filter\":{\"scope\":\"test:test-create_a_monitor_notification_rule_with_scope_returns_ok_response-1762896519\"},\"name\":\"test rule\",\"recipients\":[\"slack-test-channel\",\"jira-test\"],\"created_at\":\"2025-11-11T21:28:40.032148+00:00\"},\"relationships\":{\"created_by\":{\"data\":{\"type\":\"users\",\"id\":\"9919ec9b-ebc7-49ee-8dc8-03626e717cca\"}}},\"id\":\"bbea2907-c191-48d0-9e0f-1ec5881ee37c\"},\"included\":[{\"type\":\"users\",\"id\":\"9919ec9b-ebc7-49ee-8dc8-03626e717cca\",\"attributes\":{\"name\":\"CI Account\",\"handle\":\"9919ec9b-ebc7-49ee-8dc8-03626e717cca\",\"created_at\":\"2020-12-29T22:58:44.733921+00:00\",\"modified_at\":\"2021-04-27T13:54:01.547888+00:00\",\"email\":\"team-intg-tools-libs-spam@datadoghq.com\",\"icon\":\"https://secure.gravatar.com/avatar/b7c189b5b4c2c429d7c1e0bc3749330e?s=48&d=retro\",\"title\":null,\"verified\":true,\"service_account\":true,\"disabled\":false,\"allowed_login_methods\":[],\"status\":\"Active\",\"last_login_time\":null}}]}\n", + "encoding": null + }, + "headers": { + "Content-Type": [ + "application/json" + ] + }, + "status": { + "code": 200, + "message": "OK" + } + }, + "recorded_at": "Tue, 11 Nov 2025 21:28:39 GMT" + }, + { + "request": { + "body": "", + "headers": { + "Accept": [ + "*/*" + ] + }, + "method": "delete", + "uri": "https://api.datadoghq.com/api/v2/monitor/notification_rule/bbea2907-c191-48d0-9e0f-1ec5881ee37c" + }, + "response": { + "body": { + "string": "", + "encoding": null + }, + "headers": { + "Content-Type": [ + "text/html; charset=utf-8" + ] + }, + "status": { + "code": 204, + "message": "No Content" + } + }, + "recorded_at": "Tue, 11 Nov 2025 21:28:39 GMT" + } + ], + "recorded_with": "VCR 6.0.0" +} \ No newline at end of file diff --git a/tests/scenarios/cassettes/v2/monitors/Update-a-monitor-notification-rule-with-scope-returns-OK-response.frozen b/tests/scenarios/cassettes/v2/monitors/Update-a-monitor-notification-rule-with-scope-returns-OK-response.frozen new file mode 100644 index 000000000..ab91f3c3d --- /dev/null +++ b/tests/scenarios/cassettes/v2/monitors/Update-a-monitor-notification-rule-with-scope-returns-OK-response.frozen @@ -0,0 +1 @@ +2025-11-11T21:28:40.357Z \ No newline at end of file diff --git a/tests/scenarios/cassettes/v2/monitors/Update-a-monitor-notification-rule-with-scope-returns-OK-response.json b/tests/scenarios/cassettes/v2/monitors/Update-a-monitor-notification-rule-with-scope-returns-OK-response.json new file mode 100644 index 000000000..801a4e712 --- /dev/null +++ b/tests/scenarios/cassettes/v2/monitors/Update-a-monitor-notification-rule-with-scope-returns-OK-response.json @@ -0,0 +1,101 @@ +{ + "http_interactions": [ + { + "request": { + "body": { + "string": "{\"data\":{\"attributes\":{\"filter\":{\"tags\":[\"app:test-update_a_monitor_notification_rule_with_scope_returns_ok_response-1762896520\"]},\"name\":\"test rule\",\"recipients\":[\"slack-monitor-app\"]},\"type\":\"monitor-notification-rule\"}}", + "encoding": null + }, + "headers": { + "Accept": [ + "application/json" + ], + "Content-Type": [ + "application/json" + ] + }, + "method": "post", + "uri": "https://api.datadoghq.com/api/v2/monitor/notification_rule" + }, + "response": { + "body": { + "string": "{\"data\":{\"type\":\"monitor-notification-rule\",\"attributes\":{\"recipients\":[\"slack-monitor-app\"],\"modified_at\":\"1970-01-01T00:00:00+00:00\",\"created_at\":\"2025-11-11T21:28:40.540848+00:00\",\"name\":\"test rule\",\"filter\":{\"tags\":[\"app:test-update_a_monitor_notification_rule_with_scope_returns_ok_response-1762896520\"]}},\"relationships\":{\"created_by\":{\"data\":{\"type\":\"users\",\"id\":\"9919ec9b-ebc7-49ee-8dc8-03626e717cca\"}}},\"id\":\"827442a0-5d3e-408c-a930-7ac44775fff1\"},\"included\":[{\"type\":\"users\",\"id\":\"9919ec9b-ebc7-49ee-8dc8-03626e717cca\",\"attributes\":{\"name\":\"CI Account\",\"handle\":\"9919ec9b-ebc7-49ee-8dc8-03626e717cca\",\"created_at\":\"2020-12-29T22:58:44.733921+00:00\",\"modified_at\":\"2021-04-27T13:54:01.547888+00:00\",\"email\":\"team-intg-tools-libs-spam@datadoghq.com\",\"icon\":\"https://secure.gravatar.com/avatar/b7c189b5b4c2c429d7c1e0bc3749330e?s=48&d=retro\",\"title\":null,\"verified\":true,\"service_account\":true,\"disabled\":false,\"allowed_login_methods\":[],\"status\":\"Active\",\"last_login_time\":null}}]}\n", + "encoding": null + }, + "headers": { + "Content-Type": [ + "application/json" + ] + }, + "status": { + "code": 200, + "message": "OK" + } + }, + "recorded_at": "Tue, 11 Nov 2025 21:28:40 GMT" + }, + { + "request": { + "body": { + "string": "{\"data\":{\"attributes\":{\"filter\":{\"scope\":\"test:test-update_a_monitor_notification_rule_with_scope_returns_ok_response-1762896520\"},\"name\":\"updated rule\",\"recipients\":[\"slack-test-channel\"]},\"id\":\"827442a0-5d3e-408c-a930-7ac44775fff1\",\"type\":\"monitor-notification-rule\"}}", + "encoding": null + }, + "headers": { + "Accept": [ + "application/json" + ], + "Content-Type": [ + "application/json" + ] + }, + "method": "patch", + "uri": "https://api.datadoghq.com/api/v2/monitor/notification_rule/827442a0-5d3e-408c-a930-7ac44775fff1" + }, + "response": { + "body": { + "string": "{\"data\":{\"type\":\"monitor-notification-rule\",\"attributes\":{\"filter\":{\"scope\":\"test:test-update_a_monitor_notification_rule_with_scope_returns_ok_response-1762896520\"},\"recipients\":[\"slack-test-channel\"],\"created_at\":\"2025-11-11T21:28:40.540848+00:00\",\"name\":\"updated rule\",\"modified_at\":\"2025-11-11T21:28:40.815544+00:00\"},\"id\":\"827442a0-5d3e-408c-a930-7ac44775fff1\",\"relationships\":{\"created_by\":{\"data\":{\"type\":\"users\",\"id\":\"9919ec9b-ebc7-49ee-8dc8-03626e717cca\"}}}},\"included\":[{\"type\":\"users\",\"id\":\"9919ec9b-ebc7-49ee-8dc8-03626e717cca\",\"attributes\":{\"name\":\"CI Account\",\"handle\":\"9919ec9b-ebc7-49ee-8dc8-03626e717cca\",\"created_at\":\"2020-12-29T22:58:44.733921+00:00\",\"modified_at\":\"2021-04-27T13:54:01.547888+00:00\",\"email\":\"team-intg-tools-libs-spam@datadoghq.com\",\"icon\":\"https://secure.gravatar.com/avatar/b7c189b5b4c2c429d7c1e0bc3749330e?s=48&d=retro\",\"title\":null,\"verified\":true,\"service_account\":true,\"disabled\":false,\"allowed_login_methods\":[],\"status\":\"Active\",\"last_login_time\":null}}]}\n", + "encoding": null + }, + "headers": { + "Content-Type": [ + "application/json" + ] + }, + "status": { + "code": 200, + "message": "OK" + } + }, + "recorded_at": "Tue, 11 Nov 2025 21:28:40 GMT" + }, + { + "request": { + "body": "", + "headers": { + "Accept": [ + "*/*" + ] + }, + "method": "delete", + "uri": "https://api.datadoghq.com/api/v2/monitor/notification_rule/827442a0-5d3e-408c-a930-7ac44775fff1" + }, + "response": { + "body": { + "string": "", + "encoding": null + }, + "headers": { + "Content-Type": [ + "text/html; charset=utf-8" + ] + }, + "status": { + "code": 204, + "message": "No Content" + } + }, + "recorded_at": "Tue, 11 Nov 2025 21:28:40 GMT" + } + ], + "recorded_with": "VCR 6.0.0" +} \ No newline at end of file diff --git a/tests/scenarios/features/v2/monitors.feature b/tests/scenarios/features/v2/monitors.feature index 346a646f8..e84062637 100644 --- a/tests/scenarios/features/v2/monitors.feature +++ b/tests/scenarios/features/v2/monitors.feature @@ -52,6 +52,14 @@ Feature: Monitors Then the response status is 200 OK And the response "data.attributes.name" is equal to "test rule" + @team:DataDog/monitor-app + Scenario: Create a monitor notification rule with scope returns "OK" response + Given new "CreateMonitorNotificationRule" request + And body with value {"data": {"attributes": {"filter": {"scope": "test:{{ unique_lower }}"}, "name": "test rule", "recipients": ["slack-test-channel", "jira-test"]}, "type": "monitor-notification-rule"}} + When the request is sent + Then the response status is 200 OK + And the response "data.attributes.name" is equal to "test rule" + @skip-validation @team:DataDog/monitor-app Scenario: Create a monitor user template returns "Bad Request" response Given new "CreateMonitorUserTemplate" request @@ -272,6 +280,16 @@ Feature: Monitors Then the response status is 200 OK And the response "data.attributes.name" is equal to "updated rule" + @team:DataDog/monitor-app + Scenario: Update a monitor notification rule with scope returns "OK" response + Given there is a valid "monitor_notification_rule" in the system + And new "UpdateMonitorNotificationRule" request + And request contains "rule_id" parameter from "monitor_notification_rule.data.id" + And body with value {"data": {"attributes": {"filter": {"scope": "test:{{ unique_lower }}"}, "name": "updated rule", "recipients": ["slack-test-channel"]}, "id": "{{ monitor_notification_rule.data.id }}", "type": "monitor-notification-rule"}} + When the request is sent + Then the response status is 200 OK + And the response "data.attributes.name" is equal to "updated rule" + @skip-validation @team:DataDog/monitor-app Scenario: Update a monitor user template to a new version returns "Bad Request" response Given there is a valid "monitor_user_template" in the system