recipients.
*
* @return conditionalRecipients
*/
@@ -127,7 +128,7 @@ public MonitorNotificationRuleAttributes addRecipientsItem(String recipientsItem
/**
* A list of recipients to notify. Uses the same format as the monitor message field.
- * Must not start with an '@'.
+ * Must not start with an '@'. Cannot be used with conditional_recipients.
*
* @return recipients
*/
diff --git a/src/main/java/com/datadog/api/client/v2/model/MonitorNotificationRuleCondition.java b/src/main/java/com/datadog/api/client/v2/model/MonitorNotificationRuleCondition.java
index 7f9612d974c..69f3cf3e1a5 100644
--- a/src/main/java/com/datadog/api/client/v2/model/MonitorNotificationRuleCondition.java
+++ b/src/main/java/com/datadog/api/client/v2/model/MonitorNotificationRuleCondition.java
@@ -56,7 +56,7 @@ public MonitorNotificationRuleCondition addRecipientsItem(String recipientsItem)
/**
* A list of recipients to notify. Uses the same format as the monitor message field.
- * Must not start with an '@'.
+ * Must not start with an '@'. Cannot be used with conditional_recipients.
*
* @return recipients
*/
diff --git a/src/main/java/com/datadog/api/client/v2/model/MonitorNotificationRuleConditionalRecipients.java b/src/main/java/com/datadog/api/client/v2/model/MonitorNotificationRuleConditionalRecipients.java
index 827abb94604..85a0371d1ca 100644
--- a/src/main/java/com/datadog/api/client/v2/model/MonitorNotificationRuleConditionalRecipients.java
+++ b/src/main/java/com/datadog/api/client/v2/model/MonitorNotificationRuleConditionalRecipients.java
@@ -19,7 +19,10 @@
import java.util.Map;
import java.util.Objects;
-/** 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.
+ */
@JsonPropertyOrder({
MonitorNotificationRuleConditionalRecipients.JSON_PROPERTY_CONDITIONS,
MonitorNotificationRuleConditionalRecipients.JSON_PROPERTY_FALLBACK_RECIPIENTS
@@ -91,7 +94,7 @@ public MonitorNotificationRuleConditionalRecipients addFallbackRecipientsItem(
/**
* A list of recipients to notify. Uses the same format as the monitor message field.
- * Must not start with an '@'.
+ * Must not start with an '@'. Cannot be used with conditional_recipients.
*
* @return fallbackRecipients
*/
diff --git a/src/main/java/com/datadog/api/client/v2/model/MonitorNotificationRuleFilter.java b/src/main/java/com/datadog/api/client/v2/model/MonitorNotificationRuleFilter.java
index 408c3182c76..32e0c79b4b2 100644
--- a/src/main/java/com/datadog/api/client/v2/model/MonitorNotificationRuleFilter.java
+++ b/src/main/java/com/datadog/api/client/v2/model/MonitorNotificationRuleFilter.java
@@ -127,6 +127,54 @@ public MonitorNotificationRuleFilter deserialize(JsonParser jp, DeserializationC
Level.FINER, "Input data does not match schema 'MonitorNotificationRuleFilterTags'", e);
}
+ // deserialize MonitorNotificationRuleFilterScope
+ try {
+ boolean attemptParsing = true;
+ // ensure that we respect type coercion as set on the client ObjectMapper
+ if (MonitorNotificationRuleFilterScope.class.equals(Integer.class)
+ || MonitorNotificationRuleFilterScope.class.equals(Long.class)
+ || MonitorNotificationRuleFilterScope.class.equals(Float.class)
+ || MonitorNotificationRuleFilterScope.class.equals(Double.class)
+ || MonitorNotificationRuleFilterScope.class.equals(Boolean.class)
+ || MonitorNotificationRuleFilterScope.class.equals(String.class)) {
+ attemptParsing = typeCoercion;
+ if (!attemptParsing) {
+ attemptParsing |=
+ ((MonitorNotificationRuleFilterScope.class.equals(Integer.class)
+ || MonitorNotificationRuleFilterScope.class.equals(Long.class))
+ && token == JsonToken.VALUE_NUMBER_INT);
+ attemptParsing |=
+ ((MonitorNotificationRuleFilterScope.class.equals(Float.class)
+ || MonitorNotificationRuleFilterScope.class.equals(Double.class))
+ && (token == JsonToken.VALUE_NUMBER_FLOAT
+ || token == JsonToken.VALUE_NUMBER_INT));
+ attemptParsing |=
+ (MonitorNotificationRuleFilterScope.class.equals(Boolean.class)
+ && (token == JsonToken.VALUE_FALSE || token == JsonToken.VALUE_TRUE));
+ attemptParsing |=
+ (MonitorNotificationRuleFilterScope.class.equals(String.class)
+ && token == JsonToken.VALUE_STRING);
+ }
+ }
+ if (attemptParsing) {
+ tmp = tree.traverse(jp.getCodec()).readValueAs(MonitorNotificationRuleFilterScope.class);
+ // TODO: there is no validation against JSON schema constraints
+ // (min, max, enum, pattern...), this does not perform a strict JSON
+ // validation, which means the 'match' count may be higher than it should be.
+ if (!((MonitorNotificationRuleFilterScope) tmp).unparsed) {
+ deserialized = tmp;
+ match++;
+ }
+ log.log(Level.FINER, "Input data matches schema 'MonitorNotificationRuleFilterScope'");
+ }
+ } catch (Exception e) {
+ // deserialization failed, continue
+ log.log(
+ Level.FINER,
+ "Input data does not match schema 'MonitorNotificationRuleFilterScope'",
+ e);
+ }
+
MonitorNotificationRuleFilter ret = new MonitorNotificationRuleFilter();
if (match == 1) {
ret.setActualInstance(deserialized);
@@ -162,10 +210,18 @@ public MonitorNotificationRuleFilter(MonitorNotificationRuleFilterTags o) {
setActualInstance(o);
}
+ public MonitorNotificationRuleFilter(MonitorNotificationRuleFilterScope o) {
+ super("oneOf", Boolean.FALSE);
+ setActualInstance(o);
+ }
+
static {
schemas.put(
"MonitorNotificationRuleFilterTags",
new GenericTypeIt could be an instance of the 'oneOf' schemas. The oneOf child schemas may themselves be a
* composed schema (allOf, anyOf, oneOf).
@@ -189,18 +246,27 @@ public void setActualInstance(Object instance) {
super.setActualInstance(instance);
return;
}
+ if (JSON.isInstanceOf(
+ MonitorNotificationRuleFilterScope.class, instance, new HashSetrecipients.
*
* @return conditionalRecipients
*/
@@ -174,7 +175,7 @@ public MonitorNotificationRuleResponseAttributes addRecipientsItem(String recipi
/**
* A list of recipients to notify. Uses the same format as the monitor message field.
- * Must not start with an '@'.
+ * Must not start with an '@'. Cannot be used with conditional_recipients.
*
* @return recipients
*/
diff --git a/src/test/resources/cassettes/features/v2/Create_a_monitor_notification_rule_with_scope_returns_OK_response.freeze b/src/test/resources/cassettes/features/v2/Create_a_monitor_notification_rule_with_scope_returns_OK_response.freeze
new file mode 100644
index 00000000000..94917c9e8b9
--- /dev/null
+++ b/src/test/resources/cassettes/features/v2/Create_a_monitor_notification_rule_with_scope_returns_OK_response.freeze
@@ -0,0 +1 @@
+2025-11-11T21:28:39.129Z
\ No newline at end of file
diff --git a/src/test/resources/cassettes/features/v2/Create_a_monitor_notification_rule_with_scope_returns_OK_response.json b/src/test/resources/cassettes/features/v2/Create_a_monitor_notification_rule_with_scope_returns_OK_response.json
new file mode 100644
index 00000000000..cfd28750f81
--- /dev/null
+++ b/src/test/resources/cassettes/features/v2/Create_a_monitor_notification_rule_with_scope_returns_OK_response.json
@@ -0,0 +1,57 @@
+[
+ {
+ "httpRequest": {
+ "body": {
+ "type": "JSON",
+ "json": "{\"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\"}}"
+ },
+ "headers": {},
+ "method": "POST",
+ "path": "/api/v2/monitor/notification_rule",
+ "keepAlive": false,
+ "secure": true
+ },
+ "httpResponse": {
+ "body": "{\"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",
+ "headers": {
+ "Content-Type": [
+ "application/json"
+ ]
+ },
+ "statusCode": 200,
+ "reasonPhrase": "OK"
+ },
+ "times": {
+ "remainingTimes": 1
+ },
+ "timeToLive": {
+ "unlimited": true
+ },
+ "id": "e4be868d-ca8d-7434-0ab1-7b06ab95288e"
+ },
+ {
+ "httpRequest": {
+ "headers": {},
+ "method": "DELETE",
+ "path": "/api/v2/monitor/notification_rule/bbea2907-c191-48d0-9e0f-1ec5881ee37c",
+ "keepAlive": false,
+ "secure": true
+ },
+ "httpResponse": {
+ "headers": {
+ "Content-Type": [
+ "text/html; charset=utf-8"
+ ]
+ },
+ "statusCode": 204,
+ "reasonPhrase": "No Content"
+ },
+ "times": {
+ "remainingTimes": 1
+ },
+ "timeToLive": {
+ "unlimited": true
+ },
+ "id": "00d5556e-17c8-27a0-dc4a-a1c17361ac26"
+ }
+]
\ No newline at end of file
diff --git a/src/test/resources/cassettes/features/v2/Update_a_monitor_notification_rule_with_scope_returns_OK_response.freeze b/src/test/resources/cassettes/features/v2/Update_a_monitor_notification_rule_with_scope_returns_OK_response.freeze
new file mode 100644
index 00000000000..ab91f3c3d08
--- /dev/null
+++ b/src/test/resources/cassettes/features/v2/Update_a_monitor_notification_rule_with_scope_returns_OK_response.freeze
@@ -0,0 +1 @@
+2025-11-11T21:28:40.357Z
\ No newline at end of file
diff --git a/src/test/resources/cassettes/features/v2/Update_a_monitor_notification_rule_with_scope_returns_OK_response.json b/src/test/resources/cassettes/features/v2/Update_a_monitor_notification_rule_with_scope_returns_OK_response.json
new file mode 100644
index 00000000000..0817a949c6c
--- /dev/null
+++ b/src/test/resources/cassettes/features/v2/Update_a_monitor_notification_rule_with_scope_returns_OK_response.json
@@ -0,0 +1,87 @@
+[
+ {
+ "httpRequest": {
+ "body": {
+ "type": "JSON",
+ "json": "{\"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\"}}"
+ },
+ "headers": {},
+ "method": "POST",
+ "path": "/api/v2/monitor/notification_rule",
+ "keepAlive": false,
+ "secure": true
+ },
+ "httpResponse": {
+ "body": "{\"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",
+ "headers": {
+ "Content-Type": [
+ "application/json"
+ ]
+ },
+ "statusCode": 200,
+ "reasonPhrase": "OK"
+ },
+ "times": {
+ "remainingTimes": 1
+ },
+ "timeToLive": {
+ "unlimited": true
+ },
+ "id": "00cda7cf-fe4c-75a8-bc28-baa5933cbfec"
+ },
+ {
+ "httpRequest": {
+ "body": {
+ "type": "JSON",
+ "json": "{\"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\"}}"
+ },
+ "headers": {},
+ "method": "PATCH",
+ "path": "/api/v2/monitor/notification_rule/827442a0-5d3e-408c-a930-7ac44775fff1",
+ "keepAlive": false,
+ "secure": true
+ },
+ "httpResponse": {
+ "body": "{\"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",
+ "headers": {
+ "Content-Type": [
+ "application/json"
+ ]
+ },
+ "statusCode": 200,
+ "reasonPhrase": "OK"
+ },
+ "times": {
+ "remainingTimes": 1
+ },
+ "timeToLive": {
+ "unlimited": true
+ },
+ "id": "91f1a6b8-c117-246d-fceb-72c3ec665801"
+ },
+ {
+ "httpRequest": {
+ "headers": {},
+ "method": "DELETE",
+ "path": "/api/v2/monitor/notification_rule/827442a0-5d3e-408c-a930-7ac44775fff1",
+ "keepAlive": false,
+ "secure": true
+ },
+ "httpResponse": {
+ "headers": {
+ "Content-Type": [
+ "text/html; charset=utf-8"
+ ]
+ },
+ "statusCode": 204,
+ "reasonPhrase": "No Content"
+ },
+ "times": {
+ "remainingTimes": 1
+ },
+ "timeToLive": {
+ "unlimited": true
+ },
+ "id": "d37e3788-b9fd-b869-41be-d09511fde9b5"
+ }
+]
\ No newline at end of file
diff --git a/src/test/resources/com/datadog/api/client/v2/api/monitors.feature b/src/test/resources/com/datadog/api/client/v2/api/monitors.feature
index 346a646f83b..e84062637c1 100644
--- a/src/test/resources/com/datadog/api/client/v2/api/monitors.feature
+++ b/src/test/resources/com/datadog/api/client/v2/api/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